WPSEO_Primary_Term_Admin::enqueue_assets()publicYoast 1.0

Enqueues all the assets needed for the primary term interface.

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

Хуков нет.

Возвращает

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

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

$WPSEO_Primary_Term_Admin = new WPSEO_Primary_Term_Admin();
$WPSEO_Primary_Term_Admin->enqueue_assets();

Код WPSEO_Primary_Term_Admin::enqueue_assets() Yoast 22.4

public function enqueue_assets() {
	global $pagenow;

	if ( ! WPSEO_Metabox::is_post_edit( $pagenow ) ) {
		return;
	}

	$taxonomies = $this->get_primary_term_taxonomies();

	// Only enqueue if there are taxonomies that need a primary term.
	if ( empty( $taxonomies ) ) {
		return;
	}

	$asset_manager = new WPSEO_Admin_Asset_Manager();
	$asset_manager->enqueue_style( 'primary-category' );

	$mapped_taxonomies = $this->get_mapped_taxonomies_for_js( $taxonomies );

	$data = [
		'taxonomies' => $mapped_taxonomies,
	];

	$asset_manager->localize_script( 'post-edit', 'wpseoPrimaryCategoryL10n', $data );
	$asset_manager->localize_script( 'post-edit-classic', 'wpseoPrimaryCategoryL10n', $data );
}