Yoast\WP\SEO\Generators\Schema
HowTo::add_step_description
Checks if we have a step description, if we do, add it.
Метод класса: HowTo{}
Хуков нет.
Возвращает
void. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->add_step_description( $schema_step, $json_text );
- $schema_step(массив) (обязательный) (передается по ссылке — &)
- Our Schema output for the Step.
- $json_text(строка) (обязательный)
- The step text.
Код HowTo::add_step_description() HowTo::add step description Yoast 28.6
private function add_step_description( &$schema_step, $json_text ) {
// Decode HTML entities.
$json_text = \html_entity_decode( $json_text );
// Remove the image from the text if it exists. Search and replace the img tag.
$json_text = \preg_replace( '/<img[^>]+>/i', '', $json_text );
// Strip all HTML tags to ensure plain text for the JSON-LD output.
$json_text = \wp_strip_all_tags( $json_text );
// Trim whitespace.
$json_text = \trim( $json_text );
$schema_step['itemListElement'] = [
[
'@type' => 'HowToDirection',
'text' => $json_text,
],
];
}