lidation will take care of cleaning out array keys which
* should no longer be there.
*/
if ( $this->multisite_only !== true ) {
update_option( $this->option_name, $option_value );
}
else {
$this->update_site_option( $this->option_name, $option_value );
}
}
/**
* Returns the variable array key patterns for an options class.
*
* @return array
*/
public function get_patterns() {
return (array) $this->variable_array_key_patterns;
}
/**
* Retrieves the option name.
*
* @return string The set option name.
*/
public function get_option_name() {
return $this->option_name;
}
/*
* Concrete classes *may* contain a clean_option method which will clean out old/renamed
* values within the option.
*
* ```
* abstract public function clean_option( $option_value, $current_version = null, $all_old_option_values = null );
* ```
*/
/* *********** HELPER METHODS for internal use. *********** */
/**
* Helper method - Combines a fixed array of default values with an options array
* while filtering out any keys which are not in the defaults array.
*
* @todo [JRF] - shouldn't this be a straight array merge ? at the end of the day, the validation
* removes any invalid keys on save.
*
* @param array|null $options Optional. Current options. If not set, the option defaults
* for the $option_key will be returned.
*
* @return array Combined and filtered options array.
*/
protected function array_filter_merge( $options = null ) {
$defaults = $this->get_defaults();
if ( ! isset( $options ) || $options === false || $options === [] ) {
return $defaults;
}
$options = (array) $options;
/*
$filtered = array();
if ( $defaults !== array() ) {
foreach ( $defaults as $key => $default_value ) {
// @todo should this walk through array subkeys ?
$filtered[ $key ] = ( isset( $options[ $key ] ) ? $options[ $key ] : $default_value );
}
}
*/
$filtered = array_merge( $defaults, $options );
return $filtered;
}
/**
* Sets updated values for variables that are disabled via the override option back to their previous values.
*
* @param array $updated Updated option value.
* @param array $old Old option value.
*
* @return array Updated option value, with all disabled variables set to their old values.
*/
protected function prevent_disabled_options_update( $updated, $old ) {
$override_option = $this->get_override_option();
if ( empty( $override_option ) ) {
return $updated;
}
/*
* This loop could as well call `is_disabled( $key )` for each iteration,
* however this would be worse performance-wise.
*/
foreach ( $old as $key => $value ) {
if ( isset( $override_option[ self::ALLOW_KEY_PREFIX . $key ] ) && ! $override_option[ self::ALLOW_KEY_PREFIX . $key ] ) {
$updated[ $key ] = $old[ $key ];
}
}
return $updated;
}
/**
* Retrieves the value of the override option, if available.
*
* An override option contains values that may determine access to certain sub-variables
* of this option.
*
* Only regular options in multisite can have override options, which in that case
* would be network options.
*
* @return array Override option value, or empty array if unavailable.
*/
protected function get_override_option() {
if ( empty( $this->override_option_name ) || $this->multisite_only === true || ! is_multisite() ) {
return [];
}
return get_site_option( $this->override_option_name, [] );
}
/**
* Make sure that any set option values relating to post_types and/or taxonomies are retained,
* even when that post_type or taxonomy may not yet have been registered.
*
* {@internal The wpseo_titles concrete class overrules this method. Make sure that any
* changes applied here, also get ported to that version.}}
*
* @param array $dirty Original option as retrieved from the database.
* @param array $clean Filtered option where any options which shouldn't be in our option
* have already been removed and any options which weren't set
* have been set to their defaults.
*
* @return array
*/
protected function retain_variable_keys( $dirty, $clean ) {
if ( ( is_array( $this->variable_array_key_patterns ) && $this->variable_array_key_patterns !== [] ) && ( is_array( $dirty ) && $dirty !== [] ) ) {
foreach ( $dirty as $key => $value ) {
// Do nothing if already in filtered options.
if ( isset( $clean[ $key ] ) ) {
continue;
}
foreach ( $this->variable_array_key_patterns as $pattern ) {
if ( strpos( $key, $pattern ) === 0 ) {
$clean[ $key ] = $value;
break;
}
}
}
}
return $clean;
}
/**
* Check whether a given array key conforms to one of the variable array key patterns for this option.
*
* @used-by validate_option() methods for options with variable array keys.
*
* @param string $key Array key to check.
*
* @return string Pattern if it conforms, original array key if it doesn't or if the option
* does not have variable array keys.
*/
protected function get_switch_key( $key ) {
if ( ! isset( $this->variable_array_key_patterns ) || ( ! is_array( $this->variable_array_key_patterns ) || $this->variable_array_key_patterns === [] ) ) {
return $key;
}
foreach ( $this->variable_array_key_patterns as $pattern ) {
if ( strpos( $key, $pattern ) === 0 ) {
return $pattern;
}
}
return $key;
}
}
Warning: call_user_func() expects parameter 1 to be a valid callback, class 'WPSEO_Option_Wpseo' not found in /home/merciket/public_html/wp-content/plugins/wordpress-seo/inc/options/class-wpseo-options.php on line 63
Fatal error: Uncaught Error: Class 'WPSEO_Option' not found in /home/merciket/public_html/wp-content/plugins/wordpress-seo/inc/options/class-wpseo-option-wpseo.php:11
Stack trace:
#0 /home/merciket/public_html/wp-content/plugins/persian-date02/vendor/composer/ClassLoader.php(444): include()
#1 /home/merciket/public_html/wp-content/plugins/persian-date02/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile('/home/merciket/...')
#2 [internal function]: Composer\Autoload\ClassLoader->loadClass('WPSEO_Option_Wp...')
#3 /home/merciket/public_html/wp-content/plugins/wordpress-seo/inc/options/class-wpseo-options.php(63): spl_autoload_call('WPSEO_Option_Wp...')
#4 /home/merciket/public_html/wp-content/plugins/wordpress-seo/inc/options/class-wpseo-options.php(86): WPSEO_Options->__construct()
#5 /home/merciket/public_html/wp-content/plugins/wordpress-seo/wp-seo-main.php(341): WPSEO_Options::get_instance()
#6 /home/merciket/public_html/wp-includes/class-wp-hook.php(324): wpseo_init('')
#7 /home/merciket/public_html/w in /home/merciket/public_html/wp-content/plugins/wordpress-seo/inc/options/class-wpseo-option-wpseo.php on line 11