WPSEO_Metabox::get_metabox_script_data()publicYoast 1.0

Passes variables to js for use with the post-scraper.

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

Хуки из метода

Возвращает

Массив<Строку,Строку|Массив<Строку|int|true|false>|true|false|int>.

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

$WPSEO_Metabox = new WPSEO_Metabox();
$WPSEO_Metabox->get_metabox_script_data();

Код WPSEO_Metabox::get_metabox_script_data() Yoast 22.4

public function get_metabox_script_data() {
	$permalink = '';

	if ( is_object( $this->get_metabox_post() ) ) {
		$permalink = get_sample_permalink( $this->get_metabox_post()->ID );
		$permalink = $permalink[0];
	}

	$post_formatter = new WPSEO_Metabox_Formatter(
		new WPSEO_Post_Metabox_Formatter( $this->get_metabox_post(), [], $permalink )
	);

	$values = $post_formatter->get_values();
	/** This filter is documented in admin/filters/class-cornerstone-filter.php. */
	$post_types = apply_filters( 'wpseo_cornerstone_post_types', WPSEO_Post_Type::get_accessible_post_types() );
	if ( $values['cornerstoneActive'] && ! in_array( $this->get_metabox_post()->post_type, $post_types, true ) ) {
		$values['cornerstoneActive'] = false;
	}

	if ( $values['semrushIntegrationActive'] && $this->post->post_type === 'attachment' ) {
		$values['semrushIntegrationActive'] = 0;
	}

	if ( $values['wincherIntegrationActive'] && $this->post->post_type === 'attachment' ) {
		$values['wincherIntegrationActive'] = 0;
	}

	return $values;
}