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

WPSEO_Admin_Bar_Menu::add_analysis_submenu() protected Yoast 1.0

Adds the admin bar analysis submenu.

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

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

Хуков нет.

Возвращает

null. Ничего.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->add_analysis_submenu( $wp_admin_bar );
$wp_admin_bar(WP_Admin_Bar) (обязательный)
Admin bar instance to add the menu to.

Код WPSEO_Admin_Bar_Menu::add_analysis_submenu() Yoast 17.4

protected function add_analysis_submenu( WP_Admin_Bar $wp_admin_bar ) {
	try {
		$url = YoastSEO()->meta->for_current_page()->canonical;
	} catch ( Exception $e ) {
		// This is not the type of error we can handle here.
		return;
	}

	$focus_keyword = '';

	if ( ! $url ) {
		return;
	}

	$post = $this->get_singular_post();
	if ( $post ) {
		$focus_keyword = $this->get_post_focus_keyword( $post );
	}

	$menu_args = [
		'parent' => self::MENU_IDENTIFIER,
		'id'     => self::ANALYSIS_SUBMENU_IDENTIFIER,
		'title'  => __( 'Analyze this page', 'wordpress-seo' ),
		'meta'   => [ 'tabindex' => '0' ],
	];
	$wp_admin_bar->add_menu( $menu_args );

	$encoded_url   = urlencode( $url );
	$submenu_items = [
		[
			'id'     => 'wpseo-inlinks',
			'title'  => __( 'Check links to this URL', 'wordpress-seo' ),
			'href'   => 'https://search.google.com/search-console/links/drilldown?resource_id=' . urlencode( get_option( 'siteurl' ) ) . '&type=EXTERNAL&target=' . $encoded_url . '&domain=',
		],
		[
			'id'     => 'wpseo-kwdensity',
			'title'  => __( 'Check Keyphrase Density', 'wordpress-seo' ),
			// HTTPS not available.
			'href'   => 'http://www.zippy.co.uk/keyworddensity/index.php?url=' . $encoded_url . '&keyword=' . urlencode( $focus_keyword ),
		],
		[
			'id'     => 'wpseo-cache',
			'title'  => __( 'Check Google Cache', 'wordpress-seo' ),
			'href'   => '//webcache.googleusercontent.com/search?strip=1&q=cache:' . $encoded_url,
		],
		[
			'id'     => 'wpseo-structureddata',
			'title'  => __( 'Google Rich Results Test', 'wordpress-seo' ),
			'href'   => 'https://search.google.com/test/rich-results?url=' . $encoded_url,
		],
		[
			'id'     => 'wpseo-facebookdebug',
			'title'  => __( 'Facebook Debugger', 'wordpress-seo' ),
			'href'   => '//developers.facebook.com/tools/debug/?q=' . $encoded_url,
		],
		[
			'id'     => 'wpseo-pinterestvalidator',
			'title'  => __( 'Pinterest Rich Pins Validator', 'wordpress-seo' ),
			'href'   => 'https://developers.pinterest.com/tools/url-debugger/?link=' . $encoded_url,
		],
		[
			'id'     => 'wpseo-htmlvalidation',
			'title'  => __( 'HTML Validator', 'wordpress-seo' ),
			'href'   => '//validator.w3.org/check?uri=' . $encoded_url,
		],
		[
			'id'     => 'wpseo-cssvalidation',
			'title'  => __( 'CSS Validator', 'wordpress-seo' ),
			'href'   => '//jigsaw.w3.org/css-validator/validator?uri=' . $encoded_url,
		],
		[
			'id'     => 'wpseo-pagespeed',
			'title'  => __( 'Google Page Speed Test', 'wordpress-seo' ),
			'href'   => '//developers.google.com/speed/pagespeed/insights/?url=' . $encoded_url,
		],
		[
			'id'     => 'wpseo-google-mobile-friendly',
			'title'  => __( 'Mobile-Friendly Test', 'wordpress-seo' ),
			'href'   => 'https://www.google.com/webmasters/tools/mobile-friendly/?url=' . $encoded_url,
		],
	];

	foreach ( $submenu_items as $menu_item ) {
		$menu_args = [
			'parent' => self::ANALYSIS_SUBMENU_IDENTIFIER,
			'id'     => $menu_item['id'],
			'title'  => $menu_item['title'],
			'href'   => $menu_item['href'],
			'meta'   => [ 'target' => '_blank' ],
		];
		$wp_admin_bar->add_menu( $menu_args );
	}
}