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

WPSEO_Metabox::enqueue() public Yoast 1.0

Enqueues all the needed JS and CSS.

Ищем WP-разработчика! Фулл-тайм, удаленка, хорошая зарплата, соц. пакет. Подробности.
Компания Boosta.

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

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

Возвращает

null. Ничего.

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

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

Код WPSEO_Metabox::enqueue() Yoast 17.7.1

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' );

		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( filter_input( INPUT_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( $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' );

	$asset_manager->localize_script( $post_edit_handle, 'wpseoAdminL10n', WPSEO_Utils::get_admin_l10n() );

	$plugins_script_data = [
		'replaceVars' => [
			'no_parent_text'           => __( '(no parent)', 'wordpress-seo' ),
			'replace_vars'             => $this->get_replace_vars(),
			'hidden_replace_vars'      => $this->get_hidden_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_script_data = [
		'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(),
	];

	$alert_dismissal_action = YoastSEO()->classes->get( \Yoast\WP\SEO\Actions\Alert_Dismissal_Action::class );
	$dismissed_alerts       = $alert_dismissal_action->all_dismissed();

	$script_data = [
		// @todo replace this translation with JavaScript translations.
		'media'            => [ 'choose_image' => __( 'Use Image', 'wordpress-seo' ) ],
		'metabox'          => $this->get_metabox_script_data(),
		'userLanguageCode' => WPSEO_Language_Utils::get_language( \get_user_locale() ),
		'isPost'           => true,
		'isBlockEditor'    => $is_block_editor,
		'analysis'         => [
			'plugins'                     => $plugins_script_data,
			'worker'                      => $worker_script_data,
			'estimatedReadingTimeEnabled' => $this->estimated_reading_time_conditional->is_met(),
		],
		'dismissedAlerts'  => $dismissed_alerts,
	];

	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' ),
		];
	}

	$asset_manager->localize_script( $post_edit_handle, 'wpseoScriptData', $script_data );
	$asset_manager->enqueue_user_language_script();
}