Yoast\WP\SEO\Generators\Schema

HowTo::add_steps()privateYoast 1.0

Adds the steps to our How-To output.

Метод класса: HowTo{}

Хуков нет.

Возвращает

null. Ничего (null).

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

// private - только в коде основоного (родительского) класса
$result = $this->add_steps( $data, $steps );
$data(массив) (обязательный) (передается по ссылке — &)
Our How-To schema data.
$steps(массив) (обязательный)
Our How-To block's steps.

Код HowTo::add_steps() Yoast 22.4

private function add_steps( &$data, $steps ) {
	foreach ( $steps as $step ) {
		$schema_id   = $this->context->canonical . '#' . \esc_attr( $step['id'] );
		$schema_step = [
			'@type' => 'HowToStep',
			'url'   => $schema_id,
		];

		if ( isset( $step['jsonText'] ) ) {
			$json_text = $this->helpers->schema->html->sanitize( $step['jsonText'] );
		}

		if ( isset( $step['jsonName'] ) ) {
			$json_name = $this->helpers->schema->html->smart_strip_tags( $step['jsonName'] );
		}

		if ( empty( $json_name ) ) {
			if ( empty( $step['text'] ) ) {
				continue;
			}

			$schema_step['text'] = '';

			$this->add_step_image( $schema_step, $step );

			// If there is no text and no image, don't output the step.
			if ( empty( $json_text ) && empty( $schema_step['image'] ) ) {
				continue;
			}

			if ( ! empty( $json_text ) ) {
				$schema_step['text'] = $json_text;
			}
		}

		elseif ( empty( $json_text ) ) {
			$schema_step['text'] = $json_name;
		}
		else {
			$schema_step['name'] = $json_name;

			$this->add_step_description( $schema_step, $json_text );
			$this->add_step_image( $schema_step, $step );
		}

		$data['step'][] = $schema_step;
	}
}