WPSEO_Taxonomy::admin_enqueue_scripts
Queue assets for taxonomy screens.
Метод класса: WPSEO_Taxonomy{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$WPSEO_Taxonomy = new WPSEO_Taxonomy(); $WPSEO_Taxonomy->admin_enqueue_scripts();
Список изменений
| С версии 1.5.0 | Введена. |
Код WPSEO_Taxonomy::admin_enqueue_scripts() WPSEO Taxonomy::admin enqueue scripts Yoast 26.5
public function admin_enqueue_scripts() {
$pagenow = $GLOBALS['pagenow'];
if ( ! ( self::is_term_edit( $pagenow ) || self::is_term_overview( $pagenow ) ) ) {
return;
}
$asset_manager = new WPSEO_Admin_Asset_Manager();
$asset_manager->enqueue_style( 'monorepo' );
$tag_id = $this::get_tag_id();
if (
self::is_term_edit( $pagenow )
&& $tag_id !== null
) {
wp_enqueue_media(); // Enqueue files needed for upload functionality.
$asset_manager->enqueue_style( 'metabox-css' );
if ( $this->analysis_readability->is_enabled() ) {
$asset_manager->enqueue_style( 'scoring' );
}
$asset_manager->enqueue_style( 'ai-generator' );
$asset_manager->enqueue_script( 'term-edit' );
/**
* Remove the emoji script as it is incompatible with both React and any
* contenteditable fields.
*/
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
$asset_manager->localize_script( 'term-edit', 'wpseoAdminL10n', WPSEO_Utils::get_admin_l10n() );
$script_data = [
'analysis' => [
'plugins' => [
'replaceVars' => [
'replace_vars' => $this->get_replace_vars(),
'recommended_replace_vars' => $this->get_recommended_replace_vars(),
'scope' => $this->determine_scope(),
],
'shortcodes' => [
'wpseo_shortcode_tags' => $this->get_valid_shortcode_tags(),
'wpseo_filter_shortcodes_nonce' => wp_create_nonce( 'wpseo-filter-shortcodes' ),
],
],
'worker' => [
'url' => YoastSEO()->helpers->asset->get_asset_url( 'yoast-seo-analysis-worker' ),
'dependencies' => YoastSEO()->helpers->asset->get_dependency_urls_by_handle( 'yoast-seo-analysis-worker' ),
'keywords_assessment_url' => YoastSEO()->helpers->asset->get_asset_url( 'yoast-seo-used-keywords-assessment' ),
'log_level' => WPSEO_Utils::get_analysis_worker_log_level(),
],
],
'metabox' => $this->localize_term_scraper_script( $tag_id ),
'isTerm' => true,
'postId' => $tag_id,
'postType' => $this->get_taxonomy(),
'usedKeywordsNonce' => wp_create_nonce( 'wpseo-keyword-usage' ),
];
/**
* The website information repository.
*
* @var Website_Information_Repository $repo
*/
$repo = YoastSEO()->classes->get( Website_Information_Repository::class );
$term_information = $repo->get_term_site_information();
$term_information->set_term( get_term_by( 'id', $tag_id, $this::get_taxonomy() ) );
$script_data = array_merge_recursive( $term_information->get_legacy_site_information(), $script_data );
$asset_manager->localize_script( 'term-edit', 'wpseoScriptData', $script_data );
}
if ( self::is_term_overview( $pagenow ) ) {
$asset_manager->enqueue_script( 'edit-page' );
$asset_manager->enqueue_style( 'edit-page' );
}
}