ACF\AI\GEO
GEO::render_jsonld_script
Render a JSON-LD script tag with the provided data
Shared helper method for outputting JSON-LD structured data.
Метод класса: GEO{}
Хуки из метода
Возвращает
null. Ничего (null).
Использование
$result = GEO::render_jsonld_script( $jsonld_data );
- $jsonld_data(массив) (обязательный)
- The JSON-LD data array to output.
Список изменений
| С версии 6.8.0 | Введена. |
Код GEO::render_jsonld_script() GEO::render jsonld script ACF 6.8.8
public static function render_jsonld_script( $jsonld_data ) {
if ( empty( $jsonld_data ) ) {
return;
}
/**
* Action fired before rendering JSON-LD script tag
*
* Allows developers to output custom schemas or capture the data.
*
* @param array $jsonld_data The JSON-LD data array.
*/
do_action( 'acf/schema/render_script', $jsonld_data );
/**
* Filter to disable ACF's default JSON-LD output
*
* Return true to prevent ACF from outputting the JSON-LD script tag.
* Useful if you want to handle the output yourself via the action above.
*
* @param bool $disable Whether to disable default output. Default false.
* @param array $jsonld_data The JSON-LD data that would be output.
*/
$disable_output = apply_filters( 'acf/schema/disable_output', false, $jsonld_data );
if ( $disable_output ) {
return;
}
// Output the JSON-LD script tag.
echo "<script type=\"application/ld+json\">\n";
echo wp_json_encode( $jsonld_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_UNESCAPED_UNICODE );
echo "\n</script>\n";
}