WPSEO_Options::reset_ms_blog()public staticYoast 1.0

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.

Метод класса: WPSEO_Options{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$result = WPSEO_Options::reset_ms_blog( $blog_id );
$blog_id(int|строка) (обязательный)
Blog id of the blog for which to reset the options.

Код WPSEO_Options::reset_ms_blog() Yoast 22.4

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 );
			}
		}
	}
}