/**
  * Score the body for length and keyword appearance.
  *
  * @param array  $job     The array holding the keywords.
  * @param array  $results The results array.
  * @param string $body    The body.
  * @param string $firstp  The first paragraph.
  */
 function score_body($job, &$results, $body, $firstp)
 {
     $lengthScore = array('good' => 300, 'ok' => 250, 'poor' => 200, 'bad' => 100);
     $lengthScore = apply_filters('wpseo_body_length_score', $lengthScore, $job);
     $scoreBodyGoodLength = __('There are %d words contained in the body copy, this is more than the %d word recommended minimum.', 'wordpress-seo');
     $scoreBodyPoorLength = __('There are %d words contained in the body copy, this is below the %d word recommended minimum. Add more useful content on this topic for readers.', 'wordpress-seo');
     $scoreBodyOKLength = __('There are %d words contained in the body copy, this is slightly below the %d word recommended minimum, add a bit more copy.', 'wordpress-seo');
     $scoreBodyBadLength = __('There are %d words contained in the body copy. This is far too low and should be increased.', 'wordpress-seo');
     $scoreKeywordDensityLow = __('The keyword density is %s%%, which is a bit low, the keyword was found %s times.', 'wordpress-seo');
     $scoreKeywordDensityHigh = __('The keyword density is %s%%, which is over the advised 4.5%% maximum, the keyword was found %s times.', 'wordpress-seo');
     $scoreKeywordDensityGood = __('The keyword density is %s%%, which is great, the keyword was found %s times.', 'wordpress-seo');
     $scoreFirstParagraphLow = __('The keyword doesn\'t appear in the first paragraph of the copy, make sure the topic is clear immediately.', 'wordpress-seo');
     $scoreFirstParagraphHigh = __('The keyword appears in the first paragraph of the copy.', 'wordpress-seo');
     $fleschurl = '<a href="http://en.wikipedia.org/wiki/Flesch-Kincaid_readability_test#Flesch_Reading_Ease">' . __('Flesch Reading Ease', 'wordpress-seo') . '</a>';
     $scoreFlesch = __('The copy scores %s in the %s test, which is considered %s to read. %s', 'wordpress-seo');
     // Replace images with their alt tags, then strip all tags
     $body = preg_replace('`<img(?:[^>]+)?alt="([^"]+)"(?:[^>]+)>`', '$1', $body);
     $body = strip_tags($body);
     // Copy length check
     $wordCount = $this->statistics()->word_count($body);
     if ($wordCount < $lengthScore['bad']) {
         $this->save_score_result($results, -20, sprintf($scoreBodyBadLength, $wordCount, $lengthScore['good']), 'body_length', $wordCount);
     } elseif ($wordCount < $lengthScore['poor']) {
         $this->save_score_result($results, -10, sprintf($scoreBodyPoorLength, $wordCount, $lengthScore['good']), 'body_length', $wordCount);
     } elseif ($wordCount < $lengthScore['ok']) {
         $this->save_score_result($results, 5, sprintf($scoreBodyPoorLength, $wordCount, $lengthScore['good']), 'body_length', $wordCount);
     } elseif ($wordCount < $lengthScore['good']) {
         $this->save_score_result($results, 7, sprintf($scoreBodyOKLength, $wordCount, $lengthScore['good']), 'body_length', $wordCount);
     } else {
         $this->save_score_result($results, 9, sprintf($scoreBodyGoodLength, $wordCount, $lengthScore['good']), 'body_length', $wordCount);
     }
     $body = $this->strtolower_utf8($body);
     $job['keyword'] = $this->strtolower_utf8($job['keyword']);
     $keywordWordCount = $this->statistics()->word_count($job['keyword']);
     if ($keywordWordCount > 10) {
         $this->save_score_result($results, 0, __('Your keyphrase is over 10 words, a keyphrase should be shorter and there can be only one keyphrase.', 'wordpress-seo'), 'focus_keyword_length');
     } else {
         // Keyword Density check
         $keywordDensity = 0;
         if ($wordCount > 100) {
             $keywordCount = preg_match_all('`\\b' . preg_quote($job['keyword'], '`') . '\\b`miu', utf8_encode($body), $res);
             if ($keywordCount > 0 && $keywordWordCount > 0 && $wordCount > $keywordCount) {
                 $keywordDensity = wpseo_calc(wpseo_calc($keywordCount, '/', wpseo_calc($wordCount, '-', wpseo_calc(wpseo_calc($keywordWordCount, '-', 1), '*', $keywordCount))), '*', 100, true, 2);
             }
             if ($keywordDensity < 1) {
                 $this->save_score_result($results, 4, sprintf($scoreKeywordDensityLow, $keywordDensity, $keywordCount), 'keyword_density');
             } elseif ($keywordDensity > 4.5) {
                 $this->save_score_result($results, -50, sprintf($scoreKeywordDensityHigh, $keywordDensity, $keywordCount), 'keyword_density');
             } else {
                 $this->save_score_result($results, 9, sprintf($scoreKeywordDensityGood, $keywordDensity, $keywordCount), 'keyword_density');
             }
         }
     }
     $firstp = $this->strtolower_utf8($firstp);
     // First Paragraph Test
     // check without /u modifier as well as /u might break with non UTF-8 chars.
     if (preg_match('`\\b' . preg_quote($job['keyword'], '`') . '\\b`miu', $firstp) || preg_match('`\\b' . preg_quote($job['keyword'], '`') . '\\b`mi', $firstp) || preg_match('`\\b' . preg_quote($job['keyword_folded'], '`') . '\\b`miu', $firstp)) {
         $this->save_score_result($results, 9, $scoreFirstParagraphHigh, 'keyword_first_paragraph');
     } else {
         $this->save_score_result($results, 3, $scoreFirstParagraphLow, 'keyword_first_paragraph');
     }
     $lang = get_bloginfo('language');
     if (substr($lang, 0, 2) == 'en' && $wordCount > 100) {
         // Flesch Reading Ease check
         $flesch = $this->statistics()->flesch_kincaid_reading_ease($body);
         $note = '';
         $level = '';
         $score = 1;
         if ($flesch >= 90) {
             $level = __('very easy', 'wordpress-seo');
             $score = 9;
         } elseif ($flesch >= 80) {
             $level = __('easy', 'wordpress-seo');
             $score = 9;
         } elseif ($flesch >= 70) {
             $level = __('fairly easy', 'wordpress-seo');
             $score = 8;
         } elseif ($flesch >= 60) {
             $level = __('OK', 'wordpress-seo');
             $score = 7;
         } elseif ($flesch >= 50) {
             $level = __('fairly difficult', 'wordpress-seo');
             $note = __('Try to make shorter sentences to improve readability.', 'wordpress-seo');
             $score = 6;
         } elseif ($flesch >= 30) {
             $level = __('difficult', 'wordpress-seo');
             $note = __('Try to make shorter sentences, using less difficult words to improve readability.', 'wordpress-seo');
             $score = 5;
         } elseif ($flesch >= 0) {
             $level = __('very difficult', 'wordpress-seo');
             $note = __('Try to make shorter sentences, using less difficult words to improve readability.', 'wordpress-seo');
             $score = 4;
         }
         $this->save_score_result($results, $score, sprintf($scoreFlesch, $flesch, $fleschurl, $level, $note), 'flesch_kincaid');
     }
 }
/**
 * Adds an SEO admin bar menu with several options. If the current user is an admin he can also go straight to several settings menu's from here.
 */
function wpseo_admin_bar_menu() {
	// If the current user can't write posts, this is all of no use, so let's not output an admin menu
	if ( ! current_user_can( 'edit_posts' ) ) {
		return;
	}

	global $wp_admin_bar, $wpseo_front, $post;

	$url = '';
	if ( is_object( $wpseo_front ) ) {
		$url = $wpseo_front->canonical( false );
	}

	$focuskw = '';
	$score   = '';
	$seo_url = get_admin_url( null, 'admin.php?page=wpseo_dashboard' );

	if ( ( is_singular() || ( is_admin() && in_array( $GLOBALS['pagenow'], array( 'post.php', 'post-new.php' ), true ) ) ) && isset( $post ) && is_object( $post ) && apply_filters( 'wpseo_use_page_analysis', true ) === true ) {
		$focuskw    = WPSEO_Meta::get_value( 'focuskw', $post->ID );
		$perc_score = WPSEO_Meta::get_value( 'linkdex', $post->ID );
		$calc_score = wpseo_calc( $perc_score, '/', 10, true );
		$txtscore   = wpseo_translate_score( $calc_score );
		$title      = wpseo_translate_score( $calc_score, false );
		$score      = '<div title="' . esc_attr( $title ) . '" class="' . esc_attr( 'wpseo_score_img ' . $txtscore . ' ' . $perc_score ) . '"></div>';

		$seo_url = get_edit_post_link( $post->ID );
		if ( $txtscore !== 'na' ) {
			$seo_url .= '#wpseo_linkdex';
		}
	}

	$wp_admin_bar->add_menu( array( 'id' => 'wpseo-menu', 'title' => __( 'SEO', 'wordpress-seo' ) . $score, 'href' => $seo_url, ) );
	$wp_admin_bar->add_menu( array( 'parent' => 'wpseo-menu', 'id' => 'wpseo-kwresearch', 'title' => __( 'Keyword Research', 'wordpress-seo' ), '#', ) );
	$wp_admin_bar->add_menu( array( 'parent' => 'wpseo-kwresearch', 'id' => 'wpseo-adwordsexternal', 'title' => __( 'AdWords External', 'wordpress-seo' ), 'href' => 'http://adwords.google.com/keywordplanner', 'meta' => array( 'target' => '_blank' ) ) );
	$wp_admin_bar->add_menu( array( 'parent' => 'wpseo-kwresearch', 'id' => 'wpseo-googleinsights', 'title' => __( 'Google Insights', 'wordpress-seo' ), 'href' => 'http://www.google.com/insights/search/#q=' . urlencode( $focuskw ) . '&cmpt=q', 'meta' => array( 'target' => '_blank' ) ) );
	$wp_admin_bar->add_menu( array( 'parent' => 'wpseo-kwresearch', 'id' => 'wpseo-wordtracker', 'title' => __( 'SEO Book', 'wordpress-seo' ), 'href' => 'http://tools.seobook.com/keyword-tools/seobook/?keyword=' . urlencode( $focuskw ), 'meta' => array( 'target' => '_blank' ) ) );

	if ( ! is_admin() ) {
		$wp_admin_bar->add_menu( array( 'parent' => 'wpseo-menu', 'id' => 'wpseo-analysis', 'title' => __( 'Analyze this page', 'wordpress-seo' ), '#', ) );
		if ( is_string( $url ) ) {
			// @todo [JRF => whomever] check if this url shouldn't be encoded either with urlencode or with esc_url or something
			$wp_admin_bar->add_menu( array( 'parent' => 'wpseo-analysis', 'id' => 'wpseo-inlinks-ose', 'title' => __( 'Check Inlinks (OSE)', 'wordpress-seo' ), 'href' => 'http://www.opensiteexplorer.org/' . str_replace( '/', '%252F', preg_replace( '`^http[s]?://`', '', $url ) ) . '/a!links', 'meta' => array( 'target' => '_blank' ) ) );
			$wp_admin_bar->add_menu( array( 'parent' => 'wpseo-analysis', 'id' => 'wpseo-kwdensity', 'title' => __( 'Check Keyword Density', 'wordpress-seo' ), 'href' => 'http://www.zippy.co.uk/keyworddensity/index.php?url=' . urlencode( $url ) . '&keyword=' . urlencode( $focuskw ), 'meta' => array( 'target' => '_blank' ) ) );
			$wp_admin_bar->add_menu( array( 'parent' => 'wpseo-analysis', 'id' => 'wpseo-cache', 'title' => __( 'Check Google Cache', 'wordpress-seo' ), 'href' => 'http://webcache.googleusercontent.com/search?strip=1&q=cache:' . urlencode( $url ), 'meta' => array( 'target' => '_blank' ) ) );
			$wp_admin_bar->add_menu( array( 'parent' => 'wpseo-analysis', 'id' => 'wpseo-header', 'title' => __( 'Check Headers', 'wordpress-seo' ), 'href' => 'http://quixapp.com/headers/?r=' . urlencode( $url ), 'meta' => array( 'target' => '_blank' ) ) );
			$wp_admin_bar->add_menu( array( 'parent' => 'wpseo-analysis', 'id' => 'wpseo-richsnippets', 'title' => __( 'Check Rich Snippets', 'wordpress-seo' ), 'href' => 'http://www.google.com/webmasters/tools/richsnippets?q=' . urlencode( $url ), 'meta' => array( 'target' => '_blank' ) ) );
			$wp_admin_bar->add_menu( array( 'parent' => 'wpseo-analysis', 'id' => 'wpseo-facebookdebug', 'title' => __( 'Facebook Debugger', 'wordpress-seo' ), 'href' => 'https://developers.facebook.com/tools/debug/og/object?q=' . urlencode( $url ), 'meta' => array( 'target' => '_blank' ) ) );
		}
	}

	$admin_menu = false;
	if ( function_exists( 'is_multisite' ) && is_multisite() ) {
		$options = get_site_option( 'wpseo_ms' );
		if ( $options['access'] === 'superadmin' ) {
			if ( is_super_admin() ) {
				$admin_menu = true;
			}
			else {
				$admin_menu = false;
			}
		}
		else {
			if ( current_user_can( 'manage_options' ) ) {
				$admin_menu = true;
			}
			else {
				$admin_menu = false;
			}
		}
	}
	else {
		if ( current_user_can( 'manage_options' ) ) {
			$admin_menu = true;
		}
	}

	// @todo: add links to bulk title and bulk description edit pages
	if ( $admin_menu ) {
		$wp_admin_bar->add_menu( array( 'parent' => 'wpseo-menu', 'id' => 'wpseo-settings', 'title' => __( 'SEO Settings', 'wordpress-seo' ), 'href' => admin_url( 'admin.php?page=wpseo_titles' ), ) );
		$wp_admin_bar->add_menu( array( 'parent' => 'wpseo-settings', 'id' => 'wpseo-titles', 'title' => __( 'Titles &amp; Metas', 'wordpress-seo' ), 'href' => admin_url( 'admin.php?page=wpseo_titles' ), ) );
		$wp_admin_bar->add_menu( array( 'parent' => 'wpseo-settings', 'id' => 'wpseo-social', 'title' => __( 'Social', 'wordpress-seo' ), 'href' => admin_url( 'admin.php?page=wpseo_social' ), ) );
		$wp_admin_bar->add_menu( array( 'parent' => 'wpseo-settings', 'id' => 'wpseo-xml', 'title' => __( 'XML Sitemaps', 'wordpress-seo' ), 'href' => admin_url( 'admin.php?page=wpseo_xml' ), ) );
		$wp_admin_bar->add_menu( array( 'parent' => 'wpseo-settings', 'id' => 'wpseo-permalinks', 'title' => __( 'Permalinks', 'wordpress-seo' ), 'href' => admin_url( 'admin.php?page=wpseo_permalinks' ), ) );
		$wp_admin_bar->add_menu( array( 'parent' => 'wpseo-settings', 'id' => 'wpseo-internal-links', 'title' => __( 'Internal Links', 'wordpress-seo' ), 'href' => admin_url( 'admin.php?page=wpseo_internal-links' ), ) );
		$wp_admin_bar->add_menu( array( 'parent' => 'wpseo-settings', 'id' => 'wpseo-rss', 'title' => __( 'RSS', 'wordpress-seo' ), 'href' => admin_url( 'admin.php?page=wpseo_rss' ), ) );
		$wp_admin_bar->add_menu( array( 'parent' => 'wpseo-settings', 'id' => 'wpseo-import', 'title' => __( 'Import & Export', 'wordpress-seo' ), 'href' => admin_url( 'admin.php?page=wpseo_import' ), ) );
		
		// Check where to add the edit files page
		if ( ! ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT ) && ! ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) ) {
			$wp_admin_bar->add_menu( array( 'parent' => 'wpseo-settings', 'id' => 'wpseo-files', 'title' => __( 'Edit Files', 'wordpress-seo'), 'href' => admin_url( 'admin.php?page=wpseo_files' ), ) );
		}	

		$wp_admin_bar->add_menu( array( 'parent' => 'wpseo-settings', 'id' => 'wpseo-licenses', 'title' => __( 'Extensions', 'wordpress-seo'), 'href' => admin_url( 'admin.php?page=wpseo_licenses' ), ) );	
	}
}
 /**
  * Normalizes score according to min & max allowed. If score larger
  * than max, max is returned. If score less than min, min is returned.
  * Also rounds result to specified precision.
  * Thanks to github.com/lvil.
  *
  * @param	int|float  $score	Initial score
  * @param	int 	   $min 	Minimum score allowed
  * @param	int 	   $max 	Maximum score allowed
  * @return	int|float
  */
 public function normalize_score($score, $min, $max, $dps = 1)
 {
     $score = wpseo_calc($score, '+', 0, true, $dps);
     // Round
     if (!$this->normalize) {
         return $score;
     }
     if ($score > $max) {
         $score = $max;
     } elseif ($score < $min) {
         $score = $min;
     }
     return $score;
 }
 /**
  * wpseo_calc has been deprecated in newer versions of wordpress-seo
  *
  * @param int    $number1
  * @param string $action
  * @param int    $number2
  * @param bool   $round
  *
  * @return mixed
  */
 protected function wpseo_calc($number1, $action, $number2, $round = false)
 {
     if (method_exists('WPSEO_Utils', 'calc')) {
         return WPSEO_Utils::calc($number1, $action, $number2, $round);
     }
     return wpseo_calc($number1, $action, $number2, $round);
 }
/**
 * Adds an SEO admin bar menu with several options. If the current user is an admin he can also go straight to several settings menu's from here.
 */
function wpseo_admin_bar_menu()
{
    // If the current user can't write posts, this is all of no use, so let's not output an admin menu
    if (!current_user_can('edit_posts')) {
        return;
    }
    global $wp_admin_bar, $wpseo_front, $post;
    $url = '';
    if (is_object($wpseo_front)) {
        $url = $wpseo_front->canonical(false);
    }
    $focuskw = '';
    $score = '';
    $seo_url = get_admin_url(null, 'admin.php?page=wpseo_dashboard');
    if ((is_singular() || is_admin() && in_array($GLOBALS['pagenow'], array('post.php', 'post-new.php'), true)) && isset($post) && is_object($post) && apply_filters('wpseo_use_page_analysis', true) === true) {
        $focuskw = WPSEO_Meta::get_value('focuskw', $post->ID);
        $perc_score = WPSEO_Meta::get_value('linkdex', $post->ID);
        $calc_score = wpseo_calc($perc_score, '/', 10, true);
        $txtscore = wpseo_translate_score($calc_score);
        $title = wpseo_translate_score($calc_score, false);
        $score = '<div title="' . esc_attr($title) . '" class="' . esc_attr('wpseo-score-icon ' . $txtscore . ' ' . $perc_score) . '"></div>';
        $seo_url = get_edit_post_link($post->ID);
        if ($txtscore !== 'na') {
            $seo_url .= '#wpseo_linkdex';
        }
    }
    $wp_admin_bar->add_menu(array('id' => 'wpseo-menu', 'title' => __('SEO', 'wordpress-seo') . $score, 'href' => $seo_url));
    $wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-kwresearch', 'title' => __('Keyword Research', 'wordpress-seo'), '#'));
    $wp_admin_bar->add_menu(array('parent' => 'wpseo-kwresearch', 'id' => 'wpseo-adwordsexternal', 'title' => __('AdWords External', 'wordpress-seo'), 'href' => 'http://adwords.google.com/keywordplanner', 'meta' => array('target' => '_blank')));
    $wp_admin_bar->add_menu(array('parent' => 'wpseo-kwresearch', 'id' => 'wpseo-googleinsights', 'title' => __('Google Insights', 'wordpress-seo'), 'href' => 'http://www.google.com/insights/search/#q=' . urlencode($focuskw) . '&cmpt=q', 'meta' => array('target' => '_blank')));
    $wp_admin_bar->add_menu(array('parent' => 'wpseo-kwresearch', 'id' => 'wpseo-wordtracker', 'title' => __('SEO Book', 'wordpress-seo'), 'href' => 'http://tools.seobook.com/keyword-tools/seobook/?keyword=' . urlencode($focuskw), 'meta' => array('target' => '_blank')));
    if (!is_admin()) {
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-analysis', 'title' => __('Analyze this page', 'wordpress-seo'), '#'));
        if (is_string($url)) {
            // @todo [JRF => whomever] check if this url shouldn't be encoded either with urlencode or with esc_url or something
            $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-inlinks-ose', 'title' => __('Check Inlinks (OSE)', 'wordpress-seo'), 'href' => '//moz.com/researchtools/ose/links?site=' . urlencode($url), 'meta' => array('target' => '_blank')));
            $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-kwdensity', 'title' => __('Check Keyword Density', 'wordpress-seo'), 'href' => '//www.zippy.co.uk/keyworddensity/index.php?url=' . urlencode($url) . '&keyword=' . urlencode($focuskw), 'meta' => array('target' => '_blank')));
            $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-cache', 'title' => __('Check Google Cache', 'wordpress-seo'), 'href' => '//webcache.googleusercontent.com/search?strip=1&q=cache:' . urlencode($url), 'meta' => array('target' => '_blank')));
            $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-header', 'title' => __('Check Headers', 'wordpress-seo'), 'href' => '//quixapp.com/headers/?r=' . urlencode($url), 'meta' => array('target' => '_blank')));
            $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-richsnippets', 'title' => __('Check Rich Snippets', 'wordpress-seo'), 'href' => '//www.google.com/webmasters/tools/richsnippets?q=' . urlencode($url), 'meta' => array('target' => '_blank')));
            $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-facebookdebug', 'title' => __('Facebook Debugger', 'wordpress-seo'), 'href' => '//developers.facebook.com/tools/debug/og/object?q=' . urlencode($url), 'meta' => array('target' => '_blank')));
            $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-pinterestvalidator', 'title' => __('Pinterest Rich Pins Validator', 'wordpress-seo'), 'href' => '//developers.pinterest.com/rich_pins/validator/?link=' . urlencode($url), 'meta' => array('target' => '_blank')));
            $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-htmlvalidation', 'title' => __('HTML Validator', 'wordpress-seo'), 'href' => '//validator.w3.org/check?uri=' . urlencode($url), 'meta' => array('target' => '_blank')));
            $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-cssvalidation', 'title' => __('CSS Validator', 'wordpress-seo'), 'href' => '//jigsaw.w3.org/css-validator/validator?uri=' . urlencode($url), 'meta' => array('target' => '_blank')));
            $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-pagespeed', 'title' => __('Google Page Speed Test', 'wordpress-seo'), 'href' => '//developers.google.com/speed/pagespeed/insights/?url=' . urlencode($url), 'meta' => array('target' => '_blank')));
            $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-modernie', 'title' => __('Modern IE Site Scan', 'wordpress-seo'), 'href' => '//www.modern.ie/en-us/report#' . urlencode($url), 'meta' => array('target' => '_blank')));
        }
    }
    $admin_menu = false;
    if (is_multisite()) {
        $options = get_site_option('wpseo_ms');
        if ($options['access'] === 'superadmin' && is_super_admin()) {
            $admin_menu = true;
        } elseif (current_user_can('manage_options')) {
            $admin_menu = true;
        }
    } elseif (current_user_can('manage_options')) {
        $admin_menu = true;
    }
    // @todo: add links to bulk title and bulk description edit pages
    if ($admin_menu) {
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-settings', 'title' => __('SEO Settings', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_titles')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-titles', 'title' => __('Titles &amp; Metas', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_titles')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-social', 'title' => __('Social', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_social')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-xml', 'title' => __('XML Sitemaps', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_xml')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-permalinks', 'title' => __('Permalinks', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_permalinks')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-internal-links', 'title' => __('Internal Links', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_internal-links')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-rss', 'title' => __('RSS', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_rss')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-import', 'title' => esc_html__('Import & Export', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_import')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo_bulk-editor', 'title' => __('Bulk Editor', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_bulk-editor')));
        // Check where to add the edit files page
        if (wpseo_allow_system_file_edit() === true) {
            $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-files', 'title' => __('Edit Files', 'wordpress-seo'), 'href' => network_admin_url('admin.php?page=wpseo_files')));
            // will auto-use admin_url if not in multi-site
        }
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-licenses', 'title' => __('Extensions', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_licenses')));
    }
}