WPSEO_Admin_Pages::config_page_scripts()publicYoast 1.0

Loads the required scripts for the config page.

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

Хуков нет.

Возвращает

null. Ничего.

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

$WPSEO_Admin_Pages = new WPSEO_Admin_Pages();
$WPSEO_Admin_Pages->config_page_scripts();

Код WPSEO_Admin_Pages::config_page_scripts() Yoast 19.7.1

public function config_page_scripts() {
	$this->asset_manager->enqueue_script( 'settings' );
	wp_enqueue_script( 'dashboard' );
	wp_enqueue_script( 'thickbox' );

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

	$script_data = [
		'userLanguageCode'        => WPSEO_Language_Utils::get_language( \get_user_locale() ),
		'dismissedAlerts'         => $dismissed_alerts,
		'isRtl'                   => is_rtl(),
		'isPremium'               => YoastSEO()->helpers->product->is_premium(),
		'webinarIntroSettingsUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/webinar-intro-settings' ),
	];

	$page = filter_input( INPUT_GET, 'page' );

	if ( $page === 'wpseo_titles' ) {
		$script_data['analysis'] = [
			'plugins' => [
				'replaceVars' => $this->get_replace_vars_script_data(),
			],
		];

		$schema_types                    = new Schema_Types();
		$script_data['searchAppearance'] = [
			'isRtl'                            => is_rtl(),
			'userEditUrl'                      => add_query_arg( 'user_id', '{user_id}', admin_url( 'user-edit.php' ) ),
			'brushstrokeBackgroundURL'         => plugins_url( 'images/brushstroke_background.svg', WPSEO_FILE ),
			'showLocalSEOUpsell'               => $this->should_show_local_seo_upsell(),
			'localSEOUpsellURL'                => WPSEO_Shortlinker::get( 'https://yoa.st/3mp' ),
			'showNewsSEOUpsell'                => $this->should_show_news_seo_upsell(),
			'newsSEOUpsellURL'                 => WPSEO_Shortlinker::get( 'https://yoa.st/get-news-settings' ),
			'knowledgeGraphCompanyInfoMissing' => WPSEO_Language_Utils::get_knowledge_graph_company_info_missing_l10n(),
			'schema'                           => [
				'pageTypeOptions'    => $schema_types->get_page_type_options(),
				'articleTypeOptions' => $schema_types->get_article_type_options(),
			],
		];

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

	if ( in_array( $page, [ 'wpseo_social', WPSEO_Admin::PAGE_IDENTIFIER, 'wpseo_titles', 'wpseo_workouts' ], true ) ) {
		wp_enqueue_media();

		$script_data['media'] = [
			'choose_image' => __( 'Use Image', 'wordpress-seo' ),
		];

		$script_data['userEditUrl'] = add_query_arg( 'user_id', '{user_id}', admin_url( 'user-edit.php' ) );
	}

	if ( $page === 'wpseo_tools' ) {
		$this->enqueue_tools_scripts();
	}

	if ( $page === 'wpseo_social' ) {
		$user_id = WPSEO_Options::get( 'company_or_person_user_id', '' );
		$user    = \get_userdata( $user_id );

		$user_name = '';
		if ( $user instanceof \WP_User ) {
			$user_name = $user->get( 'display_name' );
		}

		$script_data['social'] = [
			'facebook_url'      => WPSEO_Options::get( 'facebook_site', '' ),
			'twitter_username'  => WPSEO_Options::get( 'twitter_site', '' ),
			'other_social_urls' => WPSEO_Options::get( 'other_social_urls', [] ),
			'company_or_person' => WPSEO_Options::get( 'company_or_person', '' ),
			'user_id'           => $user_id,
			'user_name'         => $user_name,
		];

		$script_data['search_appearance_link'] = admin_url( 'admin.php?page=wpseo_titles' );

		$script_data['force_organization'] = ( defined( 'WPSEO_LOCAL_FILE' ) );
	}

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