Yoast\WP\SEO\Memoizers
Meta_Tags_Context_Memoizer::get
Gets the meta tags context given an indexable. This function is memoized by the indexable so every call with the same indexable will yield 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->get( $indexable, $page_type );
- $indexable(Indexable) (обязательный)
- The indexable.
- $page_type(строка) (обязательный)
- The page type.
Код Meta_Tags_Context_Memoizer::get() Meta Tags Context Memoizer::get Yoast 26.7
public function get( Indexable $indexable, $page_type ) {
if ( ! isset( $this->cache[ $indexable->id ] ) ) {
$blocks = [];
$post = null;
if ( $indexable->object_type === 'post' ) {
$post = \get_post( $indexable->object_id );
$blocks = $this->blocks->get_all_blocks_from_content( $post->post_content );
}
$context = $this->context_prototype->of(
[
'indexable' => $indexable,
'blocks' => $blocks,
'post' => $post,
'page_type' => $page_type,
]
);
$context->presentation = $this->presentation_memoizer->get( $indexable, $context, $page_type );
$this->cache[ $indexable->id ] = $context;
}
return $this->cache[ $indexable->id ];
}