Yoast\WP\SEO\Task_List\Application\Tasks

Delete_Sample_Page::get_sample_pageprivateYoast 1.0

Returns the sample page if it exists and is published.

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

Хуков нет.

Возвращает

WP_Post|null. The sample page or null if not found.

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

// private - только в коде основоного (родительского) класса
$result = $this->get_sample_page(): ?WP_Post;

Код Delete_Sample_Page::get_sample_page() Yoast 27.7

private function get_sample_page(): ?WP_Post {
	$pages = \get_posts(
		[
			'name'        => 'sample-page',
			'post_type'   => 'page',
			'post_status' => 'publish',
			'numberposts' => 1,
		],
	);

	if ( empty( $pages ) || $pages[0] instanceof WP_Post === false ) {
		return null;
	}

	return $pages[0];
}