Yoast\WP\SEO\Generators\Schema
WebPage::add_potential_action
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(array<string|array
>) (обязательный) - The WebPage data.
Код WebPage::add_potential_action() WebPage::add potential action Yoast 26.9
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.
*
* @param array<string> $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;
}