Yoast\WP\SEO\Schema_Aggregator\Application\Enhancement

Article_Schema_Enhancer::get_article_body │ private │ Yoast 1.0

Get article body (full post content)

Extracts full post content with optional HTML and shortcode stripping. Respects max_length configuration if set.

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

Хуков нет.

Возвращает

string|null. Article body or null if unavailable.

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

// private - только в коде основоного (родительского) класса
$result = $this->get_article_body( $post_id ): ?string;
$post_id(int) (обязательный)
Post ID.

Код Article_Schema_Enhancer::get_article_body() Yoast 28.9

private function get_article_body( int $post_id ): ?string {
	try {
		$content = \get_post_field( 'post_content', $post_id );

		if ( \is_wp_error( $content ) || empty( $content ) ) {
			return null;
		}

		if ( $this->config->get_config_value( 'strip_shortcodes_from_body', true ) ) {
			$content = \strip_shortcodes( $content );
		}

		if ( $this->config->get_config_value( 'strip_html_from_body', true ) ) {
			$content = \wp_strip_all_tags( $content );
		}

		$max_length = $this->config->get_config_value( 'article_body_max_length', Article_Config::DEFAULT_MAX_ARTICLE_BODY_LENGTH );

		return $this->trim_content_to_max_length( $max_length, $content );
	} catch ( Exception $e ) {
		return null;
	}
}