WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Получай пассивный доход от сайта
функция не описана

Yoast\WP\SEO\Memoizers

Meta_Tags_Context_Memoizer::for_current_page() public Yoast 1.0

Gets the meta tags context for the current page. This function is memoized so every call will return the same result.

{} Это метод класса: Meta_Tags_Context_Memoizer{}

Хуков нет.

Возвращает

Meta_Tags_Context. The meta tags context.

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

$Meta_Tags_Context_Memoizer = new Meta_Tags_Context_Memoizer();
$Meta_Tags_Context_Memoizer->for_current_page();

Код Meta_Tags_Context_Memoizer::for_current_page() Yoast 16.8

<?php
public function for_current_page() {
	if ( ! isset( $this->cache['current_page'] ) ) {
		// First reset the query to ensure we actually have the current page.
		global $wp_query;

		$old_wp_query = $wp_query;
		// phpcs:ignore WordPress.WP.DiscouragedFunctions.wp_reset_query_wp_reset_query -- Reason: The recommended function, wp_reset_postdata, doesn't reset wp_query.
		\wp_reset_query();

		$indexable = $this->repository->for_current_page();
		$page_type = $this->current_page->get_page_type();

		if ( $page_type === 'Fallback' ) {
			// Do not cache the context if it's a fallback page.
			// The likely cause for this is that this function was called before the query was loaded.
			$context = $this->get( $indexable, $page_type );

			// Restore the previous query.
			// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Reason: we have to restore the query.
			$GLOBALS['wp_query'] = $old_wp_query;

			return $context;
		}
		$this->cache['current_page'] = $this->get( $indexable, $page_type );

		// Restore the previous query.
		// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Reason: we have to restore the query.
		$GLOBALS['wp_query'] = $old_wp_query;
	}

	return $this->cache['current_page'];
}