WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Самая быстрая Тема-конструктор для WordPress
функция не описана

WPSEO_Metabox::enqueue() public Yoast 1.0

Enqueues all the needed JS and CSS.

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

Хуки из метода
Возвращает

Null. Ничего.

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

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

Код WPSEO_Metabox::enqueue() Yoast 15.2

<?php
public function enqueue() {
	global $pagenow;

	$asset_manager = new WPSEO_Admin_Asset_Manager();

	$is_editor = self::is_post_overview( $pagenow ) || self::is_post_edit( $pagenow );

	if ( self::is_post_overview( $pagenow ) ) {
		$asset_manager->enqueue_style( 'edit-page' );
		$asset_manager->enqueue_script( 'edit-page-script' );

		return;
	}

	/* Filter 'wpseo_always_register_metaboxes_on_admin' documented in wpseo-main.php */
	if ( ( $is_editor === false && apply_filters( 'wpseo_always_register_metaboxes_on_admin', false ) === false ) || $this->display_metabox() === false ) {
		return;
	}

	$post_id = get_queried_object_id();
	if ( empty( $post_id ) && isset( $_GET['post'] ) ) {
		$post_id = sanitize_text_field( $_GET['post'] );
	}

	if ( $post_id !== 0 ) {
		// Enqueue files needed for upload functionality.
		wp_enqueue_media( [ 'post' => $post_id ] );
	}

	$asset_manager->enqueue_style( 'metabox-css' );
	$asset_manager->enqueue_style( 'scoring' );
	$asset_manager->enqueue_style( 'select2' );
	$asset_manager->enqueue_style( 'monorepo' );

	$is_block_editor  = WP_Screen::get()->is_block_editor();
	$post_edit_handle = 'post-edit';
	if ( ! $is_block_editor ) {
		$post_edit_handle = 'post-edit-classic';
	}
	$asset_manager->enqueue_script( $post_edit_handle );
	$asset_manager->enqueue_style( 'admin-css' );

	$yoast_components_l10n = new WPSEO_Admin_Asset_Yoast_Components_L10n();
	$yoast_components_l10n->localize_script( WPSEO_Admin_Asset_Manager::PREFIX . $post_edit_handle );

	/**
	 * Removes the emoji script as it is incompatible with both React and any
	 * contenteditable fields.
	 */
	remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );

	wp_localize_script( WPSEO_Admin_Asset_Manager::PREFIX . $post_edit_handle, 'wpseoAdminL10n', WPSEO_Utils::get_admin_l10n() );
	wp_localize_script( WPSEO_Admin_Asset_Manager::PREFIX . $post_edit_handle, 'wpseoFeaturesL10n', WPSEO_Utils::retrieve_enabled_features() );

	$analysis_worker_location          = new WPSEO_Admin_Asset_Analysis_Worker_Location( $asset_manager->flatten_version( WPSEO_VERSION ) );
	$used_keywords_assessment_location = new WPSEO_Admin_Asset_Analysis_Worker_Location( $asset_manager->flatten_version( WPSEO_VERSION ), 'used-keywords-assessment' );

	$script_data = [
		'analysis'         => [
			'plugins' => [
				'replaceVars' => [
					'no_parent_text'           => __( '(no parent)', 'wordpress-seo' ),
					'replace_vars'             => $this->get_replace_vars(),
					'recommended_replace_vars' => $this->get_recommended_replace_vars(),
					'scope'                    => $this->determine_scope(),
					'has_taxonomies'           => $this->current_post_type_has_taxonomies(),
				],
				'shortcodes' => [
					'wpseo_filter_shortcodes_nonce' => wp_create_nonce( 'wpseo-filter-shortcodes' ),
					'wpseo_shortcode_tags'          => $this->get_valid_shortcode_tags(),
				],
			],
			'worker'  => [
				'url'                     => $analysis_worker_location->get_url( $analysis_worker_location->get_asset(), WPSEO_Admin_Asset::TYPE_JS ),
				'keywords_assessment_url' => $used_keywords_assessment_location->get_url( $used_keywords_assessment_location->get_asset(), WPSEO_Admin_Asset::TYPE_JS ),
				'log_level'               => WPSEO_Utils::get_analysis_worker_log_level(),
				// We need to make the feature flags separately available inside of the analysis web worker.
				'enabled_features'        => WPSEO_Utils::retrieve_enabled_features(),
			],
		],
		'media'            => [
			// @todo replace this translation with JavaScript translations.
			'choose_image' => __( 'Use Image', 'wordpress-seo' ),
		],
		'metabox'          => $this->get_metabox_script_data(),
		'userLanguageCode' => WPSEO_Language_Utils::get_language( WPSEO_Language_Utils::get_user_locale() ),
		'isPost'           => true,
		'isBlockEditor'    => $is_block_editor,
	];

	if ( post_type_supports( get_post_type(), 'thumbnail' ) ) {
		$asset_manager->enqueue_style( 'featured-image' );

		// @todo replace this translation with JavaScript translations.
		$script_data['featuredImage'] = [
			'featured_image_notice' => __( 'SEO issue: The featured image should be at least 200 by 200 pixels to be picked up by Facebook and other social media sites.', 'wordpress-seo' ),
		];
	}

	wp_localize_script( WPSEO_Admin_Asset_Manager::PREFIX . $post_edit_handle, 'wpseoScriptData', $script_data );
}