_id, $option_name ); /* Remove sensitive, theme dependent and site dependent info. */ if ( isset( self::$option_instances[ $option_name ] ) && self::$option_instances[ $option_name ]->ms_exclude !== [] ) { foreach ( self::$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 boolean 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 = self::get_option( $wpseo_options_group_name ); $options[ $option_name ] = $option_value; if ( isset( self::$option_instances[ $wpseo_options_group_name ] ) && self::$option_instances[ $wpseo_options_group_name ]->multisite_only === true ) { self::update_site_option( $wpseo_options_group_name, $options ); } else { update_option( $wpseo_options_group_name, $options ); } // Check if everything got saved properly. $saved_option = self::get_option( $wpseo_options_group_name ); 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 = self::get_option( 'wpseo_ms' ); 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 = []; self::$backfill->remove_hooks(); foreach ( array_keys( self::$options ) as $option_name ) { $full_option = self::get_option( $option_name ); foreach ( $full_option as $key => $value ) { $lookup_table[ $key ] = $option_name; } } self::$backfill->register_hooks(); 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 ( self::$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; } /* ********************* DEPRECATED METHODS ********************* */ /** * Correct the inadvertent removal of the fallback to default values from the breadcrumbs. * * @since 1.5.2.3 * * @deprecated 7.0 * @codeCoverageIgnore */ public static function bring_back_breadcrumb_defaults() { _deprecated_function( __METHOD__, 'WPSEO 7.0' ); } }