) {
return static::save_option( $lookup_table[ $key ], $key, $value );
}
$patterns = static::get_pattern_table();
foreach ( $patterns as $pattern => $option ) {
if ( strpos( $key, $pattern ) === 0 ) {
return static::save_option( $option, $key, $value );
}
}
static::$option_values[ $key ] = $value;
}
/**
* Get an option only if it's been auto-loaded.
*
* @param string $option The option to retrieve.
* @param mixed $default_value A default value to return.
*
* @return mixed
*/
public static function get_autoloaded_option( $option, $default_value = false ) {
$value = wp_cache_get( $option, 'options' );
if ( $value === false ) {
$passed_default = func_num_args() > 1;
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Using WP native filter.
return apply_filters( "default_option_{$option}", $default_value, $option, $passed_default );
}
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Using WP native filter.
return apply_filters( "option_{$option}", maybe_unserialize( $value ), $option );
}
/**
* Run the clean up routine for one or all options.
*
* @param array|string|null $option_name Optional. the option you want to clean or an array of
* option names for the options you want to clean.
* If not set, all options will be cleaned.
* @param string|null $current_version Optional. Version from which to upgrade, if not set,
* version specific upgrades will be disregarded.
*
* @return void
*/
public static function clean_up( $option_name = null, $current_version = null ) {
if ( isset( $option_name ) && is_string( $option_name ) && $option_name !== '' ) {
if ( isset( static::$option_instances[ $option_name ] ) ) {
static::$option_instances[ $option_name ]->clean( $current_version );
}
}
elseif ( isset( $option_name ) && is_array( $option_name ) && $option_name !== [] ) {
foreach ( $option_name as $option ) {
if ( isset( static::$option_instances[ $option ] ) ) {
static::$option_instances[ $option ]->clean( $current_version );
}
}
unset( $option );
}
else {
foreach ( static::$option_instances as $instance ) {
$instance->clean( $current_version );
}
unset( $instance );
// If we've done a full clean-up, we can safely remove this really old option.
delete_option( 'wpseo_indexation' );
}
}
/**
* Check that all options exist in the database and add any which don't.
*
* @return void
*/
public static function ensure_options_exist() {
foreach ( static::$option_instances as $instance ) {
$instance->maybe_add_option();
}
}
/**
* Initialize some options on first install/activate/reset.
*
* @return void
*/
public static function initialize() {
/* Force WooThemes to use Yoast SEO data. */
if ( function_exists( 'woo_version_init' ) ) {
update_option( 'seo_woo_use_third_party_data', 'true' );
}
}
/**
* Reset all options to their default values and rerun some tests.
*
* @return void
*/
public static function reset() {
if ( ! is_multisite() ) {
$option_names = static::get_option_names();
if ( is_array( $option_names ) && $option_names !== [] ) {
foreach ( $option_names as $option_name ) {
delete_option( $option_name );
update_option( $option_name, get_option( $option_name ) );
}
}
unset( $option_names );
}
else {
// Reset MS blog based on network default blog setting.
static::reset_ms_blog( get_current_blog_id() );
}
static::initialize();
}
/**
* Initialize default values for a new multisite blog.
*
* @param bool $force_init Whether to always do the initialization routine (title/desc test).
*
* @return void
*/
public static function maybe_set_multisite_defaults( $force_init = false ) {
$option = get_option( 'wpseo' );
if ( is_multisite() ) {
if ( $option['ms_defaults_set'] === false ) {
static::reset_ms_blog( get_current_blog_id() );
static::initialize();
}
elseif ( $force_init === true ) {
static::initialize();
}
}
}
/**
* Reset all options for a specific multisite blog to their default values based upon a
* specified default blog if one was chosen on the network page or the plugin defaults if it was not.
*
* @param int|string $blog_id Blog id of the blog for which to reset the options.
*
* @return void
*/
public static function reset_ms_blog( $blog_id ) {
if ( is_multisite() ) {
$options = get_site_option( 'wpseo_ms' );
$option_names = static::get_option_names();
if ( is_array( $option_names ) && $option_names !== [] ) {
$base_blog_id = $blog_id;
if ( $options['defaultblog'] !== '' && $options['defaultblog'] !== 0 ) {
$base_blog_id = $options['defaultblog'];
}
foreach ( $option_names as $option_name ) {
delete_blog_option( $blog_id, $option_name );
$new_option = get_blog_option( $base_blog_id, $option_name );
/* Remove sensitive, theme dependent and site dependent info. */
if ( isset( static::$option_instances[ $option_name ] ) && static::$option_instances[ $option_name ]->ms_exclude !== [] ) {
foreach ( static::$option_instances[ $option_name ]->ms_exclude as $key ) {
unset( $new_option[ $key ] );
}
}
if ( $option_name === 'wpseo' ) {
$new_option['ms_defaults_set'] = true;
}
update_blog_option( $blog_id, $option_name, $new_option );
}
}
}
}
/**
* Saves the option to the database.
*
* @param string $wpseo_options_group_name The name for the wpseo option group in the database.
* @param string $option_name The name for the option to set.
* @param mixed $option_value The value for the option.
*
* @return bool Returns true if the option is successfully saved in the database.
*/
public static function save_option( $wpseo_options_group_name, $option_name, $option_value ) {
$options = static::get_option( $wpseo_options_group_name );
$options[ $option_name ] = $option_value;
if ( isset( static::$option_instances[ $wpseo_options_group_name ] ) && static::$option_instances[ $wpseo_options_group_name ]->multisite_only === true ) {
static::update_site_option( $wpseo_options_group_name, $options );
}
else {
update_option( $wpseo_options_group_name, $options );
}
// Check if everything got saved properly.
$saved_option = static::get_option( $wpseo_options_group_name );
// Clear our cache.
static::clear_cache();
return $saved_option[ $option_name ] === $options[ $option_name ];
}
/**
* Adds the multisite options to the option stack if relevant.
*
* @param array $option The currently present options settings.
*
* @return array Options possibly including multisite.
*/
protected static function add_ms_option( $option ) {
if ( ! is_multisite() ) {
return $option;
}
$ms_option = static::get_option( 'wpseo_ms' );
if ( $ms_option === null ) {
return $option;
}
return array_merge( $option, $ms_option );
}
/**
* Checks if installation is multisite.
*
* @return bool True when is multisite.
*/
protected static function is_multisite() {
static $is_multisite;
if ( $is_multisite === null ) {
$is_multisite = is_multisite();
}
return $is_multisite;
}
/**
* Retrieves a lookup table to find in which option_group a key is stored.
*
* @return array The lookup table.
*/
private static function get_lookup_table() {
$lookup_table = [];
foreach ( array_keys( static::$options ) as $option_name ) {
$full_option = static::get_option( $option_name );
foreach ( $full_option as $key => $value ) {
$lookup_table[ $key ] = $option_name;
}
}
return $lookup_table;
}
/**
* Retrieves a lookup table to find in which option_group a key is stored.
*
* @return array The lookup table.
*/
private static function get_pattern_table() {
$pattern_table = [];
foreach ( static::$options as $option_name => $option_class ) {
$instance = call_user_func( [ $option_class, 'get_instance' ] );
foreach ( $instance->get_patterns() as $key ) {
$pattern_table[ $key ] = $option_name;
}
}
return $pattern_table;
}
}
Fatal error: Uncaught Error: Class 'WPSEO_Options' not found in /home/healths/public_html/wp-content/plugins/wordpress-seo/wp-seo-main.php:341
Stack trace:
#0 /home/healths/public_html/wp-includes/class-wp-hook.php(324): wpseo_init()
#1 /home/healths/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#2 /home/healths/public_html/wp-includes/plugin.php(517): WP_Hook->do_action()
#3 /home/healths/public_html/wp-settings.php(550): do_action()
#4 /home/healths/public_html/wp-config.php(99): require_once('/home/healths/p...')
#5 /home/healths/public_html/wp-load.php(50): require_once('/home/healths/p...')
#6 /home/healths/public_html/wp-blog-header.php(13): require_once('/home/healths/p...')
#7 /home/healths/public_html/index.php(17): require('/home/healths/p...')
#8 {main}
thrown in /home/healths/public_html/wp-content/plugins/wordpress-seo/wp-seo-main.php on line 341