本文整理汇总了PHP中WPSEO_Meta::get_value方法的典型用法代码示例。如果您正苦于以下问题:PHP WPSEO_Meta::get_value方法的具体用法?PHP WPSEO_Meta::get_value怎么用?PHP WPSEO_Meta::get_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPSEO_Meta
的用法示例。
在下文中一共展示了WPSEO_Meta::get_value方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_get_value
/**
* @covers WPSEO_Meta::get_value()
*/
public function test_get_value()
{
// create and go to post
$post_id = $this->factory->post->create();
$this->go_to(get_permalink($post_id));
update_post_meta($post_id, WPSEO_Meta::$meta_prefix . 'test_get_value_key', 'test_get_value_value');
$this->assertEquals('test_get_value_value', WPSEO_Meta::get_value('test_get_value_key'));
// TODO test for defaults
// TODO test if non-existing keys return an empty string
}
示例2: has_video
/**
* Helper function to check if the metabox functionality should be loaded
*
* @return bool
*/
public function has_video()
{
if (isset($GLOBALS['post']->ID)) {
$video = WPSEO_Meta::get_value('video_meta', $GLOBALS['post']->ID);
if (is_array($video) && $video !== array()) {
return true;
}
}
return false;
}
示例3: description
/**
* Output the Google+ specific description
*/
public function description()
{
if (is_singular()) {
$desc = WPSEO_Meta::get_value('google-plus-description');
/**
* Filter: 'wpseo_googleplus_desc' - Allow developers to change the Google+ specific description output
*
* @api string $desc The description string
*/
$desc = apply_filters('wpseo_googleplus_desc', $desc);
if (is_string($desc) && '' !== $desc) {
echo '<meta itemprop="description" content="' . $desc . '">' . "\n";
}
}
}
示例4: italystrap_open_graph_desc
/**
* Display post description for Open Graph and Twitter card
*
* @return string A description text of post
*
* @todo Sanitize $excerpt http://codex.wordpress.org/Function_Reference/sanitize_text_field
*/
function italystrap_open_graph_desc()
{
global $post;
if (function_exists('aioseop_load_modules')) {
$excerpt = get_post_meta($post->ID, '_aioseop_description', true);
} else {
if (class_exists('WPSEO_Meta')) {
$excerpt = WPSEO_Meta::get_value('metadesc');
} else {
if ($post->post_excerpt) {
$excerpt = trim(str_replace(array("\n", "\r", "\t"), ' ', substr(strip_tags($post->post_excerpt), 0, 200)));
} else {
$excerpt = trim(str_replace(array("\n", "\r", "\t", "[", "]", "\""), ' ', substr(strip_tags($post->post_content), 0, 200))) . ' ...';
}
}
}
echo $excerpt;
}
示例5: status_transition
/**
* Hooked into transition_post_status. Will initiate search engine pings
* if the post is being published, is a post type that a sitemap is built for
* and is a post that is included in sitemaps.
*/
function status_transition($new_status, $old_status, $post)
{
if ($new_status != 'publish') {
return;
}
wp_cache_delete('lastpostmodified:gmt:' . $post->post_type, 'timeinfo');
// #17455
$options = WPSEO_Options::get_all();
if (isset($options['post_types-' . $post->post_type . '-not_in_sitemap']) && $options['post_types-' . $post->post_type . '-not_in_sitemap'] === true) {
return;
}
if (WP_CACHE) {
wp_schedule_single_event(time() + 300, 'wpseo_hit_sitemap_index');
}
// Allow the pinging to happen slightly after the hit sitemap index so the sitemap is fully regenerated when the ping happens.
if (WPSEO_Meta::get_value('sitemap-include', $post->ID) !== 'never') {
if (defined('YOAST_SEO_PING_IMMEDIATELY') && YOAST_SEO_PING_IMMEDIATELY) {
wpseo_ping_search_engines();
} else {
wp_schedule_single_event(time() + 300, 'wpseo_ping_search_engines');
}
}
}
示例6: build_post_type_map
/**
* Build a sub-sitemap for a specific post type -- example.com/post_type-sitemap.xml
*
* @param string $post_type Registered post type's slug
*/
function build_post_type_map($post_type)
{
global $wpdb;
if (isset($this->options['post_types-' . $post_type . '-not_in_sitemap']) && $this->options['post_types-' . $post_type . '-not_in_sitemap'] === true || in_array($post_type, array('revision', 'nav_menu_item')) || apply_filters('wpseo_sitemap_exclude_post_type', false, $post_type)) {
$this->bad_sitemap = true;
return;
}
$output = '';
$steps = 25 > $this->max_entries ? $this->max_entries : 25;
$n = (int) $this->n;
$offset = $n > 1 ? ($n - 1) * $this->max_entries : 0;
$total = $offset + $this->max_entries;
$join_filter = '';
$join_filter = apply_filters('wpseo_typecount_join', $join_filter, $post_type);
$where_filter = '';
$where_filter = apply_filters('wpseo_typecount_where', $where_filter, $post_type);
$query = $wpdb->prepare("SELECT COUNT(ID) FROM {$wpdb->posts} {$join_filter} WHERE post_status IN ('publish','inherit') AND post_password = '' AND post_type = %s " . $where_filter, $post_type);
$typecount = $wpdb->get_var($query);
if ($total > $typecount) {
$total = $typecount;
}
if ($n == 1) {
$front_id = get_option('page_on_front');
if (!$front_id && ($post_type == 'post' || $post_type == 'page')) {
$output .= $this->sitemap_url(array('loc' => $this->home_url, 'pri' => 1, 'chf' => $this->filter_frequency('homepage', 'daily', $this->home_url)));
} else {
if ($front_id && $post_type == 'post') {
$page_for_posts = get_option('page_for_posts');
if ($page_for_posts) {
$page_for_posts_url = get_permalink($page_for_posts);
$output .= $this->sitemap_url(array('loc' => $page_for_posts_url, 'pri' => 1, 'chf' => $change_freq = $this->filter_frequency('blogpage', 'daily', $page_for_posts_url)));
}
}
}
$archive = get_post_type_archive_link($post_type);
if ($archive) {
$output .= $this->sitemap_url(array('loc' => $archive, 'pri' => 0.8, 'chf' => $this->filter_frequency($post_type . '_archive', 'weekly', $archive), 'mod' => $this->get_last_modified($post_type)));
}
}
if ($typecount == 0 && empty($archive)) {
$this->bad_sitemap = true;
return;
}
$stackedurls = array();
// Make sure you're wpdb->preparing everything you throw into this!!
$join_filter = apply_filters('wpseo_posts_join', false, $post_type);
$where_filter = apply_filters('wpseo_posts_where', false, $post_type);
$status = $post_type == 'attachment' ? 'inherit' : 'publish';
/**
* We grab post_date, post_name, post_author and post_status too so we can throw these objects
* into get_permalink, which saves a get_post call for each permalink.
*/
while ($total > $offset) {
// Optimized query per this thread: http://wordpress.org/support/topic/plugin-wordpress-seo-by-yoast-performance-suggestion
// Also see http://explainextended.com/2009/10/23/mysql-order-by-limit-performance-late-row-lookups/
$query = $wpdb->prepare("\n\t\t\t\t\tSELECT l.ID, post_content, post_name, post_author, post_parent, post_modified_gmt,\n\t\t\t\t\t\tpost_date, post_date_gmt\n\t\t\t\t\tFROM (\n\t\t\t\t\t\tSELECT ID FROM {$wpdb->posts} {$join_filter}\n\t\t\t\t\t\t\tWHERE post_status = '%s'\n\t\t\t\t\t\t\tAND\tpost_password = ''\n\t\t\t\t\t\t\tAND post_type = '%s'\n\t\t\t\t\t\t\t{$where_filter}\n\t\t\t\t\t\t\tORDER BY post_modified ASC\n\t\t\t\t\t\t\tLIMIT %d OFFSET %d ) o\n\t\t\t\t\t\tJOIN {$wpdb->posts} l\n\t\t\t\t\t\tON l.ID = o.ID\n\t\t\t\t\t\tORDER BY l.ID\n\t\t\t\t\t", $status, $post_type, $steps, $offset);
$posts = $wpdb->get_results($query);
$offset = $offset + $steps;
if (is_array($posts) && $posts !== array()) {
foreach ($posts as $p) {
$p->post_type = $post_type;
$p->post_status = 'publish';
$p->filter = 'sample';
if (WPSEO_Meta::get_value('meta-robots-noindex', $p->ID) === '1' && WPSEO_Meta::get_value('sitemap-include', $p->ID) !== 'always') {
continue;
}
if (WPSEO_Meta::get_value('sitemap-include', $p->ID) === 'never') {
continue;
}
if (WPSEO_Meta::get_value('redirect', $p->ID) !== '') {
continue;
}
$url = array();
$url['mod'] = isset($p->post_modified_gmt) && $p->post_modified_gmt != '0000-00-00 00:00:00' && $p->post_modified_gmt > $p->post_date_gmt ? $p->post_modified_gmt : $p->post_date_gmt;
$url['loc'] = get_permalink($p);
/**
* Filter: 'wpseo_xml_sitemap_post_url' - Allow changing the URL WordPress SEO uses in the XML sitemap.
*
* Note that only absolute local URLs are allowed as the check after this removes external URLs.
*
* @api string $url URL to use in the XML sitemap
*
* @param object $p Post object for the URL
*/
$url['loc'] = apply_filters('wpseo_xml_sitemap_post_url', $url['loc'], $p);
$url['chf'] = $this->filter_frequency($post_type . '_single', 'weekly', $url['loc']);
/**
* Do not include external URLs.
* @see https://wordpress.org/plugins/page-links-to/ can rewrite permalinks to external URLs.
*/
if (false === strpos($url['loc'], $this->home_url)) {
continue;
}
$canonical = WPSEO_Meta::get_value('canonical', $p->ID);
if ($canonical !== '' && $canonical !== $url['loc']) {
//.........这里部分代码省略.........
示例7: image
/**
* Displays the image for Twitter
*
* Only used when OpenGraph is inactive or Summary Large Image card is chosen.
*/
public function image()
{
global $post;
if (is_singular()) {
if (is_front_page()) {
if ($this->options['og_frontpage_image'] !== '') {
$this->image_output($this->options['og_frontpage_image']);
}
}
$twitter_img = WPSEO_Meta::get_value('twitter-image');
if ($twitter_img !== '') {
$this->image_output($twitter_img);
return;
} elseif (function_exists('has_post_thumbnail') && has_post_thumbnail($post->ID)) {
/**
* Filter: 'wpseo_twitter_image_size' - Allow changing the Twitter Card image size
*
* @api string $featured_img Image size string
*/
$featured_img = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), apply_filters('wpseo_twitter_image_size', 'full'));
if ($featured_img) {
$this->image_output($featured_img[0]);
}
} elseif (preg_match_all('`<img [^>]+>`', $post->post_content, $matches)) {
foreach ($matches[0] as $img) {
if (preg_match('`src=(["\'])(.*?)\\1`', $img, $match)) {
$this->image_output($match[2]);
}
}
}
}
if (count($this->shown_images) == 0 && $this->options['og_default_image'] !== '') {
$this->image_output($this->options['og_default_image']);
}
}
示例8: bloginfo
bloginfo('template_directory');
?>
/favicon/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="114x114" href="<?php
bloginfo('template_directory');
?>
/favicon/apple-touch-icon-114x114.png">
<!-- Facebook open graph tags -->
<meta property="og:title" content="<?php
the_title();
?>
"/>
<meta property="og:description" content="<?php
if (function_exists('WPSEO_Meta::get_value()')) {
echo WPSEO_Meta::get_value('metadesc');
} else {
echo $post->post_excerpt;
}
?>
"/>
<?php
if (have_posts()) {
while (have_posts()) {
the_post();
}
}
?>
<meta property="fb:app_id" content="496408310403833" />
<?php
示例9: etm_wpseo_replace_vars
function etm_wpseo_replace_vars($string, $args, $omit = array())
{
$args = (array) $args;
$string = strip_tags($string);
// Let's see if we can bail super early.
if (strpos($string, '%%') === false) {
return trim(preg_replace('`\\s+`u', ' ', $string));
}
global $sep;
if (!isset($sep) || empty($sep)) {
$sep = '-';
}
$simple_replacements = array('%%sep%%' => $sep, '%%sitename%%' => get_bloginfo('name'), '%%sitedesc%%' => get_bloginfo('description'), '%%currenttime%%' => date(get_option('time_format')), '%%currentdate%%' => date(get_option('date_format')), '%%currentday%%' => date('j'), '%%currentmonth%%' => date('F'), '%%currentyear%%' => date('Y'));
foreach ($simple_replacements as $var => $repl) {
$string = str_replace($var, $repl, $string);
}
// Let's see if we can bail early.
if (strpos($string, '%%') === false) {
return trim(preg_replace('`\\s+`u', ' ', $string));
}
global $wp_query;
$defaults = array('ID' => '', 'name' => '', 'post_author' => '', 'post_content' => '', 'post_date' => '', 'post_excerpt' => '', 'post_modified' => '', 'post_title' => '', 'taxonomy' => '', 'term_id' => '', 'term404' => '');
if (isset($args['post_content'])) {
$args['post_content'] = wpseo_strip_shortcode($args['post_content']);
}
if (isset($args['post_excerpt'])) {
$args['post_excerpt'] = wpseo_strip_shortcode($args['post_excerpt']);
}
$r = (object) wp_parse_args($args, $defaults);
$max_num_pages = 1;
if (!is_singular()) {
$pagenum = get_query_var('paged');
if ($pagenum === 0) {
$pagenum = 1;
}
if (isset($wp_query->max_num_pages) && $wp_query->max_num_pages != '' && $wp_query->max_num_pages != 0) {
$max_num_pages = $wp_query->max_num_pages;
}
} else {
global $post;
$pagenum = get_query_var('page');
$max_num_pages = isset($post->post_content) ? substr_count($post->post_content, '<!--nextpage-->') : 1;
if ($max_num_pages >= 1) {
$max_num_pages++;
}
}
// Let's do date first as it's a bit more work to get right.
if ($r->post_date != '') {
$date = mysql2date(get_option('date_format'), $r->post_date);
} else {
if (get_query_var('day') && get_query_var('day') != '') {
$date = get_the_date();
} else {
if (single_month_title(' ', false) && single_month_title(' ', false) != '') {
$date = single_month_title(' ', false);
} elseif (get_query_var('year') != '') {
$date = get_query_var('year');
} else {
$date = '';
}
}
}
$replacements = array('%%date%%' => $date, '%%searchphrase%%' => esc_html(get_query_var('s')), '%%page%%' => $max_num_pages > 1 && $pagenum > 1 ? sprintf($sep . ' ' . __('Page %d of %d', 'wordpress-seo'), $pagenum, $max_num_pages) : '', '%%pagetotal%%' => $max_num_pages, '%%pagenumber%%' => $pagenum, '%%term404%%' => sanitize_text_field(str_replace('-', ' ', $r->term404)));
if (isset($r->ID)) {
$translatede_title = get_post_meta($r->ID, 'ect_tran_title_' . $this->selectede_lang, true);
if (empty($translatede_title)) {
$translatede_title = $r->post_title;
}
$replacements = array_merge($replacements, array('%%caption%%' => $r->post_excerpt, '%%category%%' => wpseo_get_terms($r->ID, 'category'), '%%excerpt%%' => !empty($r->post_excerpt) ? strip_tags($r->post_excerpt) : wp_html_excerpt(strip_shortcodes($r->post_content), 155), '%%excerpt_only%%' => strip_tags($r->post_excerpt), '%%focuskw%%' => WPSEO_Meta::get_value('focuskw', $r->ID), '%%id%%' => $r->ID, '%%modified%%' => mysql2date(get_option('date_format'), $r->post_modified), '%%name%%' => get_the_author_meta('display_name', !empty($r->post_author) ? $r->post_author : get_query_var('author')), '%%tag%%' => wpseo_get_terms($r->ID, 'post_tag'), '%%title%%' => stripslashes($translatede_title), '%%userid%%' => !empty($r->post_author) ? $r->post_author : get_query_var('author')));
}
if (!empty($r->taxonomy)) {
$replacements = array_merge($replacements, array('%%category_description%%' => trim(strip_tags(get_term_field('description', $r->term_id, $r->taxonomy))), '%%tag_description%%' => trim(strip_tags(get_term_field('description', $r->term_id, $r->taxonomy))), '%%term_description%%' => trim(strip_tags(get_term_field('description', $r->term_id, $r->taxonomy))), '%%term_title%%' => $r->name));
}
/**
* Filter: 'wpseo_replacements' - Allow customization of the replacements before they are applied
*
* @api array $replacements The replacements
*/
$replacements = apply_filters("wpseo_replacements", $replacements);
foreach ($replacements as $var => $repl) {
if (!in_array($var, $omit)) {
$string = str_replace($var, $repl, $string);
}
}
if (strpos($string, '%%') === false) {
$string = preg_replace('`\\s+`u', ' ', $string);
return trim($string);
}
if (isset($wp_query->query_vars['post_type']) && preg_match_all('`%%pt_([^%]+)%%`u', $string, $matches, PREG_SET_ORDER)) {
$pt = get_post_type_object($wp_query->query_vars['post_type']);
$pt_plural = $pt_singular = $pt->name;
if (isset($pt->labels->singular_name)) {
$pt_singular = $pt->labels->singular_name;
}
if (isset($pt->labels->name)) {
$pt_plural = $pt->labels->name;
}
$string = str_replace('%%pt_single%%', $pt_singular, $string);
$string = str_replace('%%pt_plural%%', $pt_plural, $string);
}
//.........这里部分代码省略.........
示例10: wpseo_adminbar_content_score
/**
* Returns the content score element for the adminbar.
*
* @return string
*/
function wpseo_adminbar_content_score()
{
$rating = WPSEO_Meta::get_value('content_score', get_the_ID());
return wpseo_adminbar_score($rating);
}
示例11: get_focus_keyword_usage
/**
* Counting the number of given keyword used for other posts than given post_id
*
* @return array
*/
private function get_focus_keyword_usage()
{
$post = $this->get_metabox_post();
if (is_object($post)) {
$keyword = WPSEO_Meta::get_value('focuskw', $post->ID);
return array($keyword => WPSEO_Meta::keyword_usage($keyword, $post->ID));
}
return array();
}
示例12: wpseo_admin_bar_menu
/**
* 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, $post;
$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);
$txtscore = WPSEO_Utils::translate_score($perc_score);
$title = WPSEO_Utils::translate_score($perc_score, false);
$score = '<div title="' . esc_attr($title) . '" class="' . esc_attr('wpseo-score-icon ' . $txtscore . ' ' . $perc_score) . ' adminbar-seo-score' . '"></div>';
$seo_url = get_edit_post_link($post->ID);
}
$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()) {
$url = WPSEO_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', 'wordpress-seo'), '#'));
$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')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-google-mobile-friendly', 'title' => __('Mobile-Friendly Test', 'wordpress-seo'), '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('wpseo_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', 'wordpress-seo')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-general', 'title' => __('General', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_dashboard')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-titles', 'title' => __('Titles & 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-wpseo-advanced', 'title' => __('Advanced', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_advanced')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-tools', 'title' => __('Tools', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_tools')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-search-console', 'title' => __('Search Console', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_search_console')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-licenses', 'title' => '<span style="color:#f18500">' . __('Extensions', 'wordpress-seo') . '</span>', 'href' => admin_url('admin.php?page=wpseo_licenses')));
}
}
示例13: get_keywords
/**
* Getting the keywords
*
* @param WP_Post $post The post object with the values.
*
* @return string
*/
private function get_keywords($post)
{
$keywords = WPSEO_Meta::get_value('metakeywords', $post->ID);
$option_meta_key = 'metakey-' . $post->post_type;
if ($keywords === '' && (is_object($post) && (isset($this->options[$option_meta_key]) && $this->options[$option_meta_key] !== ''))) {
$keywords = wpseo_replace_vars($this->options[$option_meta_key], $post);
}
return $keywords;
}
示例14: calculate_results
/**
* Calculate the page analysis results for post.
*
* @internal Unfortunately there isn't a filter available to hook into before returning the results
* for get_post_meta(), get_post_custom() and the likes. That would have been the preferred solution.
*
* @see function calculate_results() in wordpress-seo\admin\class-metabox.php
* @scope admin
* @since 1.2.2
*
* @param array $results
* @param string $post_content
* @param array $job,
* @param WP_Post object $post Post to calculate the results for.
*
* @return array
*/
public static function calculate_results($results, $post_content, $job, $post)
{
$WPSEO_Metabox = new WPSEO_Metabox();
$dom = new domDocument();
$dom->strictErrorChecking = false;
$dom->preserveWhiteSpace = false;
// Check if the post content is not empty.
if (!empty($post_content)) {
@$dom->loadHTML($post_content);
}
unset($post_content);
$xpath = new DOMXPath($dom);
// Check if this focus keyword has been used already.
$WPSEO_Metabox->check_double_focus_keyword($job, $results);
// Keyword.
$WPSEO_Metabox->score_keyword($job['keyword'], $results);
// Title.
$title = WPSEO_Meta::get_value('title', $post->ID);
if ($title !== '') {
$job['title'] = $title;
} else {
if (isset($options['title-' . $post->post_type]) && $options['title-' . $post->post_type] !== '') {
$title_template = $options['title-' . $post->post_type];
} else {
$title_template = '%%title%% - %%sitename%%';
}
$job['title'] = wpseo_replace_vars($title_template, $post);
}
unset($title);
$WPSEO_Metabox->score_title($job, $results);
// Meta description.
$description = '';
// $desc_meta = WPSEO_Meta::get_value( 'metadesc', $post->ID );
$desc_meta = WPGlobus_Core::text_filter(WPSEO_Meta::get_value('metadesc', $post->ID), WPGlobus::Config()->default_language);
if ($desc_meta !== '') {
$description = $desc_meta;
} elseif (isset($options['metadesc-' . $post->post_type]) && $options['metadesc-' . $post->post_type] !== '') {
$description = wpseo_replace_vars($options['metadesc-' . $post->post_type], $post);
}
unset($desc_meta);
WPSEO_Meta::$meta_length = apply_filters('wpseo_metadesc_length', WPSEO_Meta::$meta_length, $post);
$WPSEO_Metabox->score_description($job, $results, $description, WPSEO_Meta::$meta_length);
unset($description);
// Body.
// $body = $WPSEO_Metabox->get_body( $post );
$body = WPGlobus_Core::text_filter($WPSEO_Metabox->get_body($post), WPGlobus::Config()->default_language);
$firstp = $WPSEO_Metabox->get_first_paragraph($body);
$WPSEO_Metabox->score_body($job, $results, $body, $firstp);
unset($firstp);
// URL.
$WPSEO_Metabox->score_url($job, $results);
// Headings.
$headings = $WPSEO_Metabox->get_headings($body);
$WPSEO_Metabox->score_headings($job, $results, $headings);
unset($headings);
// Images.
$imgs = array();
$imgs['count'] = substr_count($body, '<img');
$imgs = $WPSEO_Metabox->get_images_alt_text($post->ID, $body, $imgs);
// Check featured image.
if (function_exists('has_post_thumbnail') && has_post_thumbnail()) {
$imgs['count'] += 1;
if (empty($imgs['alts'])) {
$imgs['alts'] = array();
}
$imgs['alts'][] = $WPSEO_Metabox->strtolower_utf8(get_post_meta(get_post_thumbnail_id($post->ID), '_wp_attachment_image_alt', true));
}
$WPSEO_Metabox->score_images_alt_text($job, $results, $imgs);
unset($imgs);
unset($body);
// Anchors.
$anchors = $WPSEO_Metabox->get_anchor_texts($xpath);
$count = $WPSEO_Metabox->get_anchor_count($xpath);
$WPSEO_Metabox->score_anchor_texts($job, $results, $anchors, $count);
unset($anchors, $count, $dom);
return $results;
}
示例15: wpseo_admin_bar_menu
/**
* 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 & 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' ), ) );
}
}