Yoast\WP\SEO\Generators\Schema
Website::internal_search_section
Adds the internal search JSON LD code to the homepage if it's not disabled.
Метод класса: Website{}
Хуки из метода
Возвращает
Массив.
Использование
// private - только в коде основоного (родительского) класса $result = $this->internal_search_section( $data );
- $data(массив) (обязательный)
- The website data array.
Код Website::internal_search_section() Website::internal search section Yoast 27.3
private function internal_search_section( $data ) {
/**
* Filter: 'disable_wpseo_json_ld_search' - Allow disabling of the json+ld output.
*
* @param bool $display_search Whether or not to display json+ld search on the frontend.
*/
if ( \apply_filters( 'disable_wpseo_json_ld_search', false ) ) {
return $data;
}
/**
* Filter: 'wpseo_json_ld_search_url' - Allows filtering of the search URL for Yoast SEO.
*
* @param string $search_url The search URL for this site with a `{search_term_string}` variable.
*/
$search_url = \apply_filters( 'wpseo_json_ld_search_url', $this->context->site_url . '?s={search_term_string}' );
$data['potentialAction'][] = [
'@type' => 'SearchAction',
'target' => [
'@type' => 'EntryPoint',
'urlTemplate' => $search_url,
],
'query-input' => [
'@type' => 'PropertyValueSpecification',
'valueRequired' => true,
'valueName' => 'search_term_string',
],
];
return $data;
}