wpseo_init()Yoast 1.0

On plugins_loaded: load the minimum amount of essential files for this plugin.

Хуки из функции

Возвращает

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

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

wpseo_init();

Код wpseo_init() Yoast 28.0

function wpseo_init() {
	require_once WPSEO_PATH . 'inc/wpseo-functions.php';
	require_once WPSEO_PATH . 'inc/wpseo-functions-deprecated.php';

	// Make sure our option and meta value validation routines and default values are always registered and available.
	WPSEO_Options::get_instance();
	WPSEO_Meta::init();

	if ( version_compare( WPSEO_Options::get( 'version', 1, [ 'wpseo' ] ), WPSEO_VERSION, '<' ) ) {
		// Invalidate the opcache in 50% of the cases, randomly staggered based on the site URL.
		// @TODO: Move the staggering logic to its own class, but only after a few releases after the complete sunset of the opcache invalidation. Make sure to document that in the future, maybe `12` should be used as modulus, so that it's easier to tinker the percentage (divisible by 2, 3, 4, 6). (see the technical choices of https://github.com/Yoast/wordpress-seo/pull/22812).
		$random_seed               = hexdec( substr( hash( 'sha256', site_url() ), 0, 8 ) );
		$should_invalidate_opcache = ( $random_seed % 2 ) !== 0;

		/**
		 * Filter: 'Yoast\WP\SEO\should_invalidate_opcache' - Allow developers to enable / disable
		 * opcache invalidation upon upgrade of the Yoast SEO plugin.
		 *
		 * @since 26.1
		 *
		 * @param bool $should_invalidate Whether opcache should be invalidated.
		 */
		$should_invalidate_opcache = (bool) apply_filters( 'Yoast\WP\SEO\should_invalidate_opcache', $should_invalidate_opcache );
		if ( $should_invalidate_opcache && function_exists( 'opcache_reset' ) ) {
			// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Prevent notices when opcache.restrict_api is set.
			@opcache_reset();
		}

		new WPSEO_Upgrade();
		// Get a cleaned up version of the $options.
	}

	$GLOBALS['wpseo_rewrite'] = new WPSEO_Rewrite();

	if ( WPSEO_Options::get( 'enable_xml_sitemap', null, [ 'wpseo' ] ) === true ) {
		$GLOBALS['wpseo_sitemaps'] = new WPSEO_Sitemaps();
	}

	if ( ! wp_doing_ajax() ) {
		require_once WPSEO_PATH . 'inc/wpseo-non-ajax-functions.php';
	}

	$integrations   = [];
	$integrations[] = new WPSEO_Slug_Change_Watcher();

	foreach ( $integrations as $integration ) {
		$integration->register_hooks();
	}
}