Yoast\WP\SEO\Generators\Schema

WebPage::add_potential_action()privateYoast 1.0

Adds the potential action property to the WebPage Schema piece.

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

Возвращает

Массив. The WebPage data with the potential action added.

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

// private - только в коде основоного (родительского) класса
$result = $this->add_potential_action( $data );
$data(массив) (обязательный)
The WebPage data.

Код WebPage::add_potential_action() Yoast 19.7.1

private function add_potential_action( $data ) {
	$url = $this->context->canonical;
	if ( $data['@type'] === 'CollectionPage' || ( \is_array( $data['@type'] ) && \in_array( 'CollectionPage', $data['@type'], true ) ) ) {
		return $data;
	}

	/**
	 * Filter: 'wpseo_schema_webpage_potential_action_target' - Allows filtering of the schema WebPage potentialAction target.
	 *
	 * @api array $targets The URLs for the WebPage potentialAction target.
	 */
	$targets = \apply_filters( 'wpseo_schema_webpage_potential_action_target', [ $url ] );

	$data['potentialAction'][] = [
		'@type'  => 'ReadAction',
		'target' => $targets,
	];

	return $data;
}