/** * 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 YMBESEO_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, $post; $focuskw = ''; $score = ''; $seo_url = get_admin_url(null, 'admin.php?page=YMBESEO_dashboard'); if ((is_singular() || is_admin() && in_array($GLOBALS['pagenow'], array('post.php', 'post-new.php'), true)) && isset($post) && is_object($post) && apply_filters('YMBESEO_use_page_analysis', true) === true) { $focuskw = YMBESEO_Meta::get_value('focuskw', $post->ID); $perc_score = YMBESEO_Meta::get_value('linkdex', $post->ID); $calc_score = YMBESEO_Utils::calc($perc_score, '/', 10, true); $txtscore = YMBESEO_Utils::translate_score($calc_score); $title = YMBESEO_Utils::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 .= '#YMBESEO_linkdex'; } } $wp_admin_bar->add_menu(array('id' => 'wpseo-menu', 'title' => __('SEO', 'ymbeseo') . $score, 'href' => $seo_url)); $wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-kwresearch', 'title' => __('Keyword Research', 'ymbeseo'), '#')); $wp_admin_bar->add_menu(array('parent' => 'wpseo-kwresearch', 'id' => 'wpseo-adwordsexternal', 'title' => __('AdWords External', 'ymbeseo'), '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', 'ymbeseo'), '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', 'ymbeseo'), 'href' => 'http://tools.seobook.com/keyword-tools/seobook/?keyword=' . urlencode($focuskw), 'meta' => array('target' => '_blank'))); if (!is_admin()) { $url = YMBESEO_Frontend::get_instance()->canonical(false); if (is_string($url)) { $wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-analysis', 'title' => __('Analyze this page', 'ymbeseo'), '#')); $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-inlinks-ose', 'title' => __('Check Inlinks (OSE)', 'ymbeseo'), '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', 'ymbeseo'), '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', 'ymbeseo'), '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', 'ymbeseo'), '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', 'ymbeseo'), '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', 'ymbeseo'), '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', 'ymbeseo'), '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', 'ymbeseo'), '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', 'ymbeseo'), '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', 'ymbeseo'), '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', 'ymbeseo'), 'href' => '//www.modern.ie/en-us/report#' . urlencode($url), 'meta' => array('target' => '_blank'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-google-mobile-friendly', 'title' => __('Mobile-Friendly Test', 'ymbeseo'), 'href' => 'https://www.google.com/webmasters/tools/mobile-friendly/?url=' . urlencode($url), 'meta' => array('target' => '_blank'))); } } $admin_menu = current_user_can('manage_options'); if (!$admin_menu && is_multisite()) { $options = get_site_option('YMBESEO_ms'); $admin_menu = $options['access'] === 'superadmin' && is_super_admin(); } // @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', 'ymbeseo'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-general', 'title' => __('General', 'ymbeseo'), 'href' => admin_url('admin.php?page=YMBESEO_dashboard'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-titles', 'title' => __('Titles & Metas', 'ymbeseo'), 'href' => admin_url('admin.php?page=YMBESEO_titles'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-social', 'title' => __('Social', 'ymbeseo'), 'href' => admin_url('admin.php?page=YMBESEO_social'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-xml', 'title' => __('XML Sitemaps', 'ymbeseo'), 'href' => admin_url('admin.php?page=YMBESEO_xml'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-YMBESEO_advanced', 'title' => __('Advanced', 'ymbeseo'), 'href' => admin_url('admin.php?page=YMBESEO_advanced'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-licenses', 'title' => __('Extensions', 'ymbeseo'), 'href' => admin_url('admin.php?page=YMBESEO_licenses'))); } }
/** * Output the page analysis results. * * @param object $post Post to output the page analysis results for. * * @return string */ function linkdex_output($post) { $results = $this->calculate_results($post); if (is_wp_error($results)) { $error = $results->get_error_messages(); return '<tr><td><div class="YMBESEO_msg"><p><strong>' . esc_html($error[0]) . '</strong></p></div></td></tr>'; } $output = ''; if (is_array($results) && $results !== array()) { $output = '<table class="wpseoanalysis">'; $perc_score = absint($results['total']); unset($results['total']); // Unset to prevent echoing it. foreach ($results as $result) { if (is_array($result)) { $score = YMBESEO_Utils::translate_score($result['val']); $output .= '<tr><td class="score"><div class="' . esc_attr('wpseo-score-icon ' . $score) . '"></div></td><td>' . $result['msg'] . '</td></tr>'; } } unset($result, $score); $output .= '</table>'; if (WP_DEBUG === true || defined('YMBESEO_DEBUG') && YMBESEO_DEBUG === true) { $output .= '<p><small>(' . $perc_score . '%)</small></p>'; } } $output = '<div class="YMBESEO_msg"><p>' . __('To update this page analysis, save as draft or update and check this tab again', 'ymbeseo') . '.</p></div>' . $output; unset($results); return $output; }
/** * Translates a decimal analysis score into a textual one. * * @deprecated 1.5.6.1 * @deprecated use YMBESEO_Utils::translate_score() * @see YMBESEO_Utils::translate_score() * * @param int $val The decimal score to translate. * @param bool $css_value Whether to return the i18n translated score or the CSS class value. * * @return string */ function YMBESEO_translate_score($val, $css_value = true) { _deprecated_function(__FUNCTION__, 'WPSEO 1.5.6.1', 'YMBESEO_Utils::translate_score()'); return YMBESEO_Utils::translate_score(); }