WPSEO_Upgrade::reset_og_settings_to_default_values()publicYoast 1.0

Reset the social options with the correct default values.

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

Хуков нет.

Возвращает

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

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

$WPSEO_Upgrade = new WPSEO_Upgrade();
$WPSEO_Upgrade->reset_og_settings_to_default_values();

Код WPSEO_Upgrade::reset_og_settings_to_default_values() Yoast 22.1

public function reset_og_settings_to_default_values() {
	$wpseo_titles    = get_option( 'wpseo_titles' );
	$updated_options = [];

	$updated_options['social-title-author-wpseo']  = '%%name%%';
	$updated_options['social-title-archive-wpseo'] = '%%date%%';

	/* translators: %s expands to the name of a post type (plural). */
	$post_type_archive_default = sprintf( __( '%s Archive', 'wordpress-seo' ), '%%pt_plural%%' );

	/* translators: %s expands to the variable used for term title. */
	$term_archive_default = sprintf( __( '%s Archives', 'wordpress-seo' ), '%%term_title%%' );

	$post_type_objects = get_post_types( [ 'public' => true ], 'objects' );

	if ( $post_type_objects ) {
		foreach ( $post_type_objects as $pt ) {
			// Post types.
			if ( isset( $wpseo_titles[ 'social-title-' . $pt->name ] ) ) {
				$updated_options[ 'social-title-' . $pt->name ] = '%%title%%';
			}
			// Post type archives.
			if ( isset( $wpseo_titles[ 'social-title-ptarchive-' . $pt->name ] ) ) {
				$updated_options[ 'social-title-ptarchive-' . $pt->name ] = $post_type_archive_default;
			}
		}
	}

	$taxonomy_objects = get_taxonomies( [ 'public' => true ], 'object' );

	if ( $taxonomy_objects ) {
		foreach ( $taxonomy_objects as $tax ) {
			if ( isset( $wpseo_titles[ 'social-title-tax-' . $tax->name ] ) ) {
				$updated_options[ 'social-title-tax-' . $tax->name ] = $term_archive_default;
			}
		}
	}

	$wpseo_titles = array_merge( $wpseo_titles, $updated_options );

	update_option( 'wpseo_titles', $wpseo_titles );
}