コード例 #1
0
ファイル: open_graph.php プロジェクト: pslorus/WebsiteTinTuc
function _likebtn_og_get_description()
{
    $description = null;
    if (function_exists('aioseop_get_version')) {
        $description = trim(get_post_meta(get_the_ID(), '_aioseop_description', true));
    } else {
        if (function_exists('wpseo_get_value')) {
            $description = wpseo_get_value('metadesc', get_the_ID());
        }
    }
    return empty($description) ? strip_tags(get_the_excerpt()) : $description;
}
コード例 #2
0
 /**
  * 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 = get_wpseo_options();
     if (isset($options['post_types-' . $post->post_type . '-not_in_sitemap']) && $options['post_types-' . $post->post_type . '-not_in_sitemap']) {
         return;
     }
     if (WP_CACHE) {
         wp_schedule_single_event(time(), '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_get_value('sitemap-include', $post->ID) != 'never') {
         wp_schedule_single_event(time() + 60, 'wpseo_ping_search_engines');
     }
 }
コード例 #3
0
 function page_title($postid)
 {
     $fixed_title = wpseo_get_value('title', $postid);
     if ($fixed_title) {
         return $fixed_title;
     } else {
         $post = get_post($postid);
         $options = get_wpseo_options();
         if (isset($options['title-' . $post->post_type]) && !empty($options['title-' . $post->post_type])) {
             return wpseo_replace_vars($options['title-' . $post->post_type], (array) $post);
         } else {
             return wpseo_replace_vars('%%title%%', (array) $post);
         }
     }
 }
コード例 #4
0
 public function getTitle()
 {
     if ($this->title_is_loaded === false) {
         $this->title_is_loaded = true;
         if ($this->post_loaded || $this->category_loaded) {
             $this->loadTheQuery();
             ob_start();
             $object = $GLOBALS['wp_query']->get_queried_object();
             if (function_exists('get_plugin_data') !== true) {
                 require_once $this->wordpress_location . '/wp-admin/includes/plugin.php';
             }
             if (file_exists($this->wordpress_location . '/wp-content/plugins/wordpress-seo/wp-seo.php') === true) {
                 $arDataWpSeo = get_plugin_data($this->wordpress_location . '/wp-content/plugins/wordpress-seo/wp-seo.php');
                 if (isset($arDataWpSeo['Version']) === true) {
                     $isRecentWpSeoVersion = version_compare($arDataWpSeo['Version'], '1.5.0', '>=');
                     if ($isRecentWpSeoVersion === false) {
                         if ($this->post_loaded) {
                             if (function_exists('wpseo_get_value')) {
                                 $titleSeo = wpseo_get_value('title', $object->ID);
                             }
                         } elseif ($this->category_loaded) {
                             if (function_exists('wpseo_get_term_meta')) {
                                 $titleSeo = wpseo_get_term_meta($object, $object->taxonomy, 'title');
                             }
                         }
                     } else {
                         if ($this->post_loaded) {
                             if (method_exists('\\WPSEO_Meta', 'get_value')) {
                                 $titleSeo = \WPSEO_Meta::get_value('title', $object->ID);
                             }
                         } elseif ($this->category_loaded) {
                             if (method_exists('\\WPSEO_Taxonomy_Meta', 'get_term_meta')) {
                                 $titleSeo = \WPSEO_Taxonomy_Meta::get_term_meta($object, $object->taxonomy, 'title');
                             }
                         }
                     }
                 }
             }
             if (isset($titleSeo) === true) {
                 echo $titleSeo;
             } else {
                 the_title();
             }
             $this->title = ob_get_clean();
         }
     }
     return $this->title;
 }
コード例 #5
0
ファイル: wpseo-functions.php プロジェクト: juslee/e27
/**
 * @param string $string the string to replace the variables in.
 * @param array  $args   the object some of the replacement values might come from, could be a post, taxonomy or term.
 * @param array  $omit   variables that should not be replaced by this function.
 * @return string
 */
function 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('H:i'), '%%currentdate%%' => date('M jS Y'), '%%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' => '');
    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_single()) {
        $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);
            } else {
                if (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);
    if (isset($r->ID)) {
        $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) : utf8_encode(substr(strip_shortcodes(strip_tags(utf8_decode($r->post_content))), 0, 155)), '%%excerpt_only%%' => strip_tags($r->post_excerpt), '%%focuskw%%' => wpseo_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($r->post_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));
    }
    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);
    }
    if (preg_match_all('/%%cf_([^%]+)%%/u', $string, $matches, PREG_SET_ORDER)) {
        global $post;
        foreach ($matches as $match) {
            $string = str_replace($match[0], get_post_meta($post->ID, $match[1], true), $string);
        }
    }
    if (preg_match_all('/%%ct_desc_([^%]+)?%%/u', $string, $matches, PREG_SET_ORDER)) {
        global $post;
        foreach ($matches as $match) {
            $terms = get_the_terms($post->ID, $match[1]);
            $string = str_replace($match[0], get_term_field('description', $terms[0]->term_id, $match[1]), $string);
        }
    }
    if (preg_match_all('/%%ct_([^%]+)%%(single%%)?/u', $string, $matches, PREG_SET_ORDER)) {
        foreach ($matches as $match) {
            $single = false;
            if (isset($match[2]) && $match[2] == 'single%%') {
                $single = true;
            }
            $ct_terms = wpseo_get_terms($r->ID, $match[1], $single);
            $string = str_replace($match[0], $ct_terms, $string);
        }
    }
    $string = preg_replace('/\\s+/u', ' ', $string);
    return trim($string);
}
コード例 #6
0
ファイル: class-wc-query.php プロジェクト: hscale/webento
 /**
  * wpseo_metakey function.
  * 
  * @access public
  * @return void
  */
 function wpseo_metakey()
 {
     return wpseo_get_value('metakey', woocommerce_get_page_id('shop'));
 }
コード例 #7
0
ファイル: class-metabox.php プロジェクト: macosxvn/techheroes
 /**
  * Calculate the page analysis results for post.
  *
  * @param object $post Post to calculate the results for.
  * @return array
  */
 function calculate_results($post)
 {
     $options = get_wpseo_options();
     if (!class_exists('DOMDocument')) {
         $result = new WP_Error('no-domdocument', sprintf(__("Your hosting environment does not support PHP's %sDocument Object Model%s.", 'wordpress-seo'), '<a href="http://php.net/manual/en/book.dom.php">', '</a>') . ' ' . __("To enjoy all the benefits of the page analysis feature, you'll need to (get your host to) install it.", 'wordpress-seo'));
         return $result;
     }
     if (!wpseo_get_value('focuskw', $post->ID)) {
         $result = new WP_Error('no-focuskw', sprintf(__('No focus keyword was set for this %s. If you do not set a focus keyword, no score can be calculated.', 'wordpress-seo'), $post->post_type));
         wpseo_set_value('linkdex', 0, $post->ID);
         return $result;
     }
     $results = array();
     $job = array();
     $sampleurl = get_sample_permalink($post);
     $job["pageUrl"] = preg_replace('/%(post|page)name%/', $sampleurl[1], $sampleurl[0]);
     $job["pageSlug"] = urldecode($post->post_name);
     $job["keyword"] = trim(wpseo_get_value('focuskw'));
     $job["keyword_folded"] = $this->strip_separators_and_fold($job["keyword"]);
     $job["post_id"] = $post->ID;
     $dom = new domDocument();
     $dom->strictErrorChecking = false;
     $dom->preserveWhiteSpace = false;
     @$dom->loadHTML($post->post_content);
     $xpath = new DOMXPath($dom);
     $statistics = new Yoast_TextStatistics();
     // Check if this focus keyword has been used already.
     $this->check_double_focus_keyword($job, $results);
     // Keyword
     $this->score_keyword($job['keyword'], $results);
     // Title
     if (wpseo_get_value('title')) {
         $job['title'] = wpseo_get_value('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, (array) $post);
     }
     $this->score_title($job, $results, $statistics);
     // Meta description
     $description = '';
     if (wpseo_get_value('metadesc')) {
         $description = wpseo_get_value('metadesc');
     } else {
         if (isset($options['metadesc-' . $post->post_type]) && !empty($options['metadesc-' . $post->post_type])) {
             $description = wpseo_replace_vars($options['metadesc-' . $post->post_type], (array) $post);
         }
     }
     $meta_length = apply_filters('wpseo_metadesc_length', 156, $post);
     $this->score_description($job, $results, $description, $statistics, $meta_length);
     unset($description);
     // Body
     $body = $this->get_body($post);
     $firstp = $this->get_first_paragraph($post);
     $this->score_body($job, $results, $body, $firstp, $statistics);
     unset($body);
     unset($firstp);
     // URL
     $this->score_url($job, $results, $statistics);
     // Headings
     $headings = $this->get_headings($post->post_content);
     $this->score_headings($job, $results, $headings);
     unset($headings);
     // Images
     $imgs = array();
     $imgs['count'] = substr_count($post->post_content, '<img');
     $imgs = $this->get_images_alt_text($post, $imgs);
     $this->score_images_alt_text($job, $results, $imgs);
     unset($imgs);
     // Anchors
     $anchors = $this->get_anchor_texts($xpath);
     $count = $this->get_anchor_count($xpath);
     $this->score_anchor_texts($job, $results, $anchors, $count);
     unset($anchors, $count, $dom);
     $results = apply_filters('wpseo_linkdex_results', $results, $job, $post);
     $this->aasort($results, 'val');
     $overall = 0;
     $overall_max = 0;
     foreach ($results as $result) {
         $overall += $result['val'];
         $overall_max += 9;
     }
     if ($overall < 1) {
         $overall = 1;
     }
     $score = round($overall / $overall_max * 100);
     wpseo_set_value('linkdex', absint($score), $post->ID);
     return $results;
 }
コード例 #8
0
ファイル: linkdex.php プロジェクト: Joshuwar/Masterson
 function output($post)
 {
     global $wpseo_metabox;
     $options = get_wpseo_options();
     if (is_int($post)) {
         $post = get_post($post);
     }
     if (!$post) {
         return;
     }
     if (!class_exists('DOMDocument')) {
         $output = '<div class="wpseo_msg"><p><strong>' . __('Error') . ':</strong> ' . sprintf(__("your hosting environment does not support PHP's %sDocument Object Model%s."), '<a href="http://php.net/manual/en/book.dom.php">', '</a>') . ' ' . __("To enjoy all the benefits of the page analysis feature, you'll need to (get your host to) install it.") . '</p></div>';
         return $output;
     }
     if (!wpseo_get_value('focuskw')) {
         $output = '<div class="wpseo_msg"><p><strong>' . __('Error') . ':</strong> ' . __("you have not specified a focus keyword, you'll have to enter one, then save or update this post, before this report works.") . '</p></div>';
         return $output;
     }
     $output = '<div class="wpseo_msg"><p><strong>' . __('Note') . ':</strong> ' . __('to update this page analysis, save as draft or update and check this tab again') . '.</p></div>';
     $results = '';
     $job = array();
     $sampleurl = get_sample_permalink($post->ID);
     $job["pageUrl"] = str_replace('%postname%', $sampleurl[1], $sampleurl[0]);
     $job["pageSlug"] = urldecode($post->post_name);
     $job["keyword"] = wpseo_get_value('focuskw');
     $job["keyword_folded"] = $this->strip_separators_and_fold($job["keyword"]);
     $dom = new domDocument();
     $dom->strictErrorChecking = false;
     $dom->preserveWhiteSpace = false;
     @$dom->loadHTML($post->post_content);
     $xpath = new DOMXPath($dom);
     $statistics = new TextStatistics();
     // Keyword
     $this->ScoreKeyword($job, $results);
     // Title
     if (wpseo_get_value('title')) {
         $title = wpseo_get_value('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%%';
         }
         $title = wpseo_replace_vars($title_template, (array) $post);
     }
     $this->ScoreTitle($job, $results, $title, $statistics);
     unset($title);
     // Meta description
     $description = '';
     if (wpseo_get_value('metadesc')) {
         $description = wpseo_get_value('metadesc');
     } else {
         if (isset($options['metadesc-' . $post->post_type]) && $options['metadesc-' . $post->post_type] != '') {
             $description = wpseo_replace_vars($options['metadesc-' . $post->post_type], (array) $post);
         }
     }
     $this->ScoreDescription($job, $results, $description, $wpseo_metabox->wpseo_meta_length, $statistics);
     unset($description);
     // Body
     $body = $this->GetBody($post);
     $firstp = $this->GetFirstParagraph($post);
     $this->ScoreBody($job, $results, $body, $firstp, $statistics);
     unset($body);
     unset($firstp);
     // URL
     $this->ScoreUrl($job, $results, $statistics);
     // Headings
     $headings = $this->GetHeadings($post->post_content);
     $this->ScoreHeadings($job, $results, $headings);
     unset($headings);
     // Images
     $alts = $this->GetImagesAltText($post->post_content);
     $imgs = $this->GetImageCount($dom, $xpath);
     $this->ScoreImagesAltText($job, $results, $alts, $imgs);
     unset($alts);
     unset($imgs);
     // Anchors
     $anchors = $this->GetAnchorTexts($dom, $xpath);
     $count = $this->GetAnchorCount($dom, $xpath);
     $this->ScoreAnchorTexts($job, $results, $anchors, $count);
     unset($anchors);
     unset($count);
     unset($dom);
     asort($results);
     $output .= '<table class="wpseoanalysis">';
     foreach ($results as $result) {
         $scoreval = substr($result, 0, 1);
         switch ($scoreval) {
             case 1:
             case 2:
             case 3:
                 $score = 'poor';
                 break;
             case 4:
             case 5:
             case 6:
                 $score = 'ok';
                 break;
             case 7:
             case 8:
             case 9:
                 $score = 'good';
                 break;
         }
         $analysis = substr($result, 2, strlen($result));
         $output .= '<tr><td class="score"><img alt="' . $score . '" src="' . WPSEO_URL . 'images/score_' . $score . '.png"/></td><td>' . $analysis . '</td></tr>';
     }
     $output .= '</table>';
     $output .= '<hr/>';
     $output .= '<p style="font-size: 13px;"><a href="http://yoa.st/linkdex"><img class="alignleft" style="margin: 0 10px 5px 0;" src="' . WPSEO_URL . 'images/linkdex-logo.png" alt="Linkdex"/></a>' . 'This page analysis brought to you by the collaboration of Yoast and <a href="http://yoa.st/linkdex">Linkdex</a>. <a href="http://yoa.st/linkdex">Linkdex</a> is an SEO suite that helps you optimize your site and offers you all the SEO tools you\'ll need. Yoast uses <a href="http://yoa.st/linkdex">Linkdex</a> and highly recommends you do too!' . '</p>';
     unset($results);
     unset($job);
     return $output;
 }
コード例 #9
0
ファイル: class-opengraph.php プロジェクト: jimlongo56/bhouse
 /**
  * Output the OpenGraph description, specific OG description first, if not, grab the meta description.
  *
  * @param bool $echo Whether to echo or return the description
  * @return string $ogdesc
  */
 public function description($echo = true)
 {
     $ogdesc = '';
     if (is_front_page()) {
         if (isset($this->options['og_frontpage_desc'])) {
             $ogdesc = $this->options['og_frontpage_desc'];
         }
     }
     if (is_singular()) {
         $ogdesc = wpseo_get_value('opengraph-description');
         if (!$ogdesc) {
             $ogdesc = $this->metadesc(false);
         }
     }
     $ogdesc = apply_filters('wpseo_opengraph_desc', $ogdesc);
     if ($ogdesc && $ogdesc != '') {
         if ($echo !== false) {
             echo "<meta property='og:description' content='" . esc_attr($ogdesc) . "'/>\n";
         } else {
             return $ogdesc;
         }
     }
 }
コード例 #10
0
 /**
  * Display the optional sources link elements in the <code>&lt;head&gt;</code>.
  */
 public function head()
 {
     if (is_singular()) {
         global $post;
         $meta_news_keywords = trim(wpseo_get_value('newssitemap-keywords', $post->ID));
         if (!empty($meta_news_keywords)) {
             echo '<meta name="news_keywords" content="' . $meta_news_keywords . '" />' . "\n";
         }
         $original_source = trim(wpseo_get_value('newssitemap-original', $post->ID));
         if (!empty($original_source)) {
             echo '<link rel="original-source" href="' . get_permalink($post->ID) . '" />' . "\n";
         } else {
             $sources = explode('|', $original_source);
             foreach ($sources as $source) {
                 echo '<link rel="original-source" href="' . $source . '" />' . "\n";
             }
         }
     }
 }
コード例 #11
0
 /**
  * Output the OpenGraph description, specific OG description first, if not, grab the meta description.
  *
  * @param bool $echo Whether to echo or return the description
  * @return string $ogdesc
  */
 public function description($echo = true)
 {
     $ogdesc = '';
     if (is_front_page()) {
         if (isset($this->options['og_frontpage_desc'])) {
             $ogdesc = $this->options['og_frontpage_desc'];
         }
     }
     if (is_singular()) {
         $ogdesc = wpseo_get_value('opengraph-description');
         if (!$ogdesc) {
             $ogdesc = $this->metadesc(false);
         }
         // og:description is still blank so grab it from get_the_excerpt()
         if (!$ogdesc) {
             $ogdesc = strip_tags(get_the_excerpt());
         }
     }
     $ogdesc = apply_filters('wpseo_opengraph_desc', $ogdesc);
     if ($ogdesc && (is_string($ogdesc) && $ogdesc != '')) {
         if ($echo !== false) {
             echo '<meta property="og:description" content="' . esc_attr($ogdesc) . "\"/>\n";
         } else {
             return $ogdesc;
         }
     }
 }
コード例 #12
0
 function get_bc_title($id_or_name, $type = 'post_type')
 {
     $bctitle = wpseo_get_value('bctitle', $id_or_name);
     return !empty($bctitle) ? $bctitle : strip_tags(get_the_title($id_or_name));
 }
コード例 #13
0
 /**
  * Take the links array and return a full breadcrumb string.
  *
  * Each element of the links array can either have one of these keys:
  *       "id"            for post types;
  *    "ptarchive"  for a post type archive;
  *    "term"         for a taxonomy term.
  * If either of these 3 are set, the url and text are retrieved. If not, url and text have to be set.
  *
  * @link http://support.google.com/webmasters/bin/answer.py?hl=en&answer=185417 Google documentation on RDFA
  *
  * @param array  $links   The links that should be contained in the breadcrumb.
  * @param string $wrapper The wrapping element for the entire breadcrumb path.
  * @param string $element The wrapping element for each individual link.
  * @return string
  */
 function create_breadcrumbs_string($links, $wrapper = 'span', $element = 'span')
 {
     global $paged;
     $opt = get_wpseo_options();
     $sep = isset($opt['breadcrumbs-sep']) && $opt['breadcrumbs-sep'] != '' ? $opt['breadcrumbs-sep'] : '&raquo;';
     $output = '';
     foreach ($links as $i => $link) {
         if (!empty($output)) {
             $output .= " {$sep} ";
         }
         if (isset($link['id'])) {
             $link['url'] = get_permalink($link['id']);
             $link['text'] = wpseo_get_value('bctitle', $link['id']);
             if (empty($link['text'])) {
                 $link['text'] = strip_tags(get_the_title($link['id']));
             }
             $link['text'] = apply_filters('wp_seo_get_bc_title', $link['text'], $link['id']);
         }
         if (isset($link['term'])) {
             $bctitle = wpseo_get_term_meta($link['term'], $link['term']->taxonomy, 'bctitle');
             if (!$bctitle) {
                 $bctitle = $link['term']->name;
             }
             $link['url'] = get_term_link($link['term']);
             $link['text'] = $bctitle;
         }
         if (isset($link['ptarchive'])) {
             if (isset($opt['bctitle-ptarchive-' . $link['ptarchive']]) && '' != $opt['bctitle-ptarchive-' . $link['ptarchive']]) {
                 $archive_title = $opt['bctitle-ptarchive-' . $link['ptarchive']];
             } else {
                 $post_type_obj = get_post_type_object($link['ptarchive']);
                 $archive_title = $post_type_obj->labels->menu_name;
             }
             $link['url'] = get_post_type_archive_link($link['ptarchive']);
             $link['text'] = $archive_title;
         }
         $element = esc_attr(apply_filters('wpseo_breadcrumb_single_link_wrapper', $element));
         $link_output = '<' . $element . ' typeof="v:Breadcrumb">';
         if (isset($link['url']) && ($i < count($links) - 1 || $paged)) {
             // add for breadcrumb translation as all text was hard coded - September 25, 2013
             if ($link['text'] == 'Investment Managers' && ICL_LANGUAGE_CODE == 'fr') {
                 $link['text'] = 'Gestionnaies de Placements';
             }
             if ($link['text'] == 'Prices & Performance' && ICL_LANGUAGE_CODE == 'fr') {
                 $link['text'] = 'Prix et Rendement';
             }
             if ($link['text'] == 'Investment Solutions > Mutual Funds' && ICL_LANGUAGE_CODE == 'fr') {
                 $link['text'] = 'Solutions D\'Investissement > Fonds communs de placement';
             }
             $link_output .= '<a href="' . esc_url($link['url']) . '" rel="v:url" property="v:title">' . esc_html($link['text']) . '</a>';
         } else {
             if (isset($opt['breadcrumbs-boldlast']) && $opt['breadcrumbs-boldlast']) {
                 $link_output .= '<strong class="breadcrumb_last" property="v:title">' . esc_html($link['text']) . '</strong>';
             } else {
                 $link_output .= '<span class="breadcrumb_last" property="v:title">' . esc_html($link['text']) . '</span>';
             }
         }
         $link_output .= '</' . $element . '>';
         $output .= apply_filters('wpseo_breadcrumb_single_link', $link_output, $link);
     }
     $id = apply_filters('wpseo_breadcrumb_output_id', false);
     if (!empty($id)) {
         $id = ' id="' . esc_attr($id) . '"';
     }
     $class = apply_filters('wpseo_breadcrumb_output_class', false);
     if (!empty($class)) {
         $class = ' class="' . esc_attr($class) . '"';
     }
     $wrapper = apply_filters('wpseo_breadcrumb_output_wrapper', $wrapper);
     return apply_filters('wpseo_breadcrumb_output', '<' . $wrapper . $id . $class . ' xmlns:v="http://rdf.data-vocabulary.org/#">' . $output . '</' . $wrapper . '>');
 }
コード例 #14
0
/**
 * 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;
    if (is_object($wpseo_front)) {
        $url = $wpseo_front->canonical(false);
    } else {
        $url = '';
    }
    if (isset($post) && is_object($post)) {
        $focuskw = wpseo_get_value('focuskw', $post->ID);
    } else {
        $focuskw = '';
    }
    $wp_admin_bar->add_menu(array('id' => 'wpseo-menu', 'title' => __('SEO'), 'href' => get_admin_url('admin.php?page=wpseo_dashboard')));
    $wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-kwresearch', 'title' => __('Keyword Research'), '#'));
    $wp_admin_bar->add_menu(array('parent' => 'wpseo-kwresearch', 'id' => 'wpseo-adwordsexternal', 'title' => __('AdWords External'), 'href' => 'https://adwords.google.com/select/KeywordToolExternal', 'meta' => array('target' => '_blank')));
    $wp_admin_bar->add_menu(array('parent' => 'wpseo-kwresearch', 'id' => 'wpseo-googleinsights', 'title' => __('Google Insights'), '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'), 'href' => 'http://tools.seobook.com/keyword-tools/seobook/?keyword=' . urlencode($focuskw), 'meta' => array('target' => '_blank')));
    if (!is_admin()) {
        $cleanurl = preg_replace('/^https?%3A%2F%2F/', '', urlencode($url));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-analysis', 'title' => __('Analyze this page'), '#'));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-inlinks-y', 'title' => __('Check Inlinks (Yahoo!)'), 'href' => 'https://siteexplorer.search.yahoo.com/search?p=' . $cleanurl . '&bwm=i&bwmo=d&bwmf=u', 'meta' => array('target' => '_blank')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-inlinks-ose', 'title' => __('Check Inlinks (OSE)'), 'href' => 'http://www.opensiteexplorer.org/' . str_replace('/', '%252F', preg_replace('/^https?:\\/\\//', '', $url)) . '/a!links', 'meta' => array('target' => '_blank')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-kwdensity', 'title' => __('Check Keyword Density'), 'href' => 'http://tools.davidnaylor.co.uk/keyworddensity/index.php?url=' . $url . '&keyword=' . urlencode($focuskw), 'meta' => array('target' => '_blank')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-cache', 'title' => __('Check Google Cache'), 'href' => 'http://webcache.googleusercontent.com/search?strip=1&q=cache:' . $url, 'meta' => array('target' => '_blank')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-header', 'title' => __('Check Headers'), 'href' => 'http://quixapp.com/headers/?r=' . urlencode($url), 'meta' => array('target' => '_blank')));
    }
    $admin_menu = false;
    if (function_exists('is_multisite') && is_multisite()) {
        $options = get_site_option('wpseo_ms');
        if (is_array($options) && isset($options['access']) && $options['access'] == 'superadmin') {
            if (is_super_admin()) {
                $admin_menu = true;
            } else {
                $admin_menu = false;
            }
        } else {
            if (current_user_can('level_7')) {
                $admin_menu = true;
            } else {
                $admin_menu = false;
            }
        }
    } else {
        if (current_user_can('level_7')) {
            $admin_menu = true;
        }
    }
    if ($admin_menu) {
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-settings', 'title' => __('SEO Settings'), 'href' => admin_url('admin.php?page=wpseo_titles')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-titles', 'title' => __('Titles'), 'href' => admin_url('admin.php?page=wpseo_titles')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-indexation', 'title' => __('Indexation'), 'href' => admin_url('admin.php?page=wpseo_indexation')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-xml', 'title' => __('XML Sitemaps'), 'href' => admin_url('admin.php?page=wpseo_xml')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-permalinks', 'title' => __('Permalinks'), 'href' => admin_url('admin.php?page=wpseo_permalinks')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-internal-links', 'title' => __('Internal Links'), 'href' => admin_url('admin.php?page=wpseo_internal-links')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-rss', 'title' => __('RSS'), 'href' => admin_url('admin.php?page=wpseo_rss')));
    }
}
コード例 #15
0
 /**
  * wpseo_metakey function.
  * Hooked into wpseo_ hook already, so no need for function_exist
  *
  * @access public
  * @return string
  */
 public function wpseo_metakey()
 {
     return wpseo_get_value('metakey', wc_get_page_id('shop'));
 }
コード例 #16
0
ファイル: class-opengraph.php プロジェクト: bulats/chef
 /**
  * Output the OpenGraph description, specific OG description first, if not, grab the meta description.
  *
  * @param bool $echo Whether to echo or return the description
  *
  * @return string $ogdesc
  */
 public function description($echo = true)
 {
     $ogdesc = '';
     if (is_front_page()) {
         if (isset($this->options['og_frontpage_desc']) && !empty($this->options['og_frontpage_desc'])) {
             $ogdesc = $this->options['og_frontpage_desc'];
         } else {
             $ogdesc = $this->metadesc(false);
         }
     }
     if (is_singular()) {
         $ogdesc = wpseo_get_value('opengraph-description');
         if (!$ogdesc) {
             $ogdesc = $this->metadesc(false);
         }
         // og:description is still blank so grab it from get_the_excerpt()
         if (!$ogdesc) {
             $ogdesc = str_replace('[&hellip;]', '&hellip;', strip_tags(get_the_excerpt()));
         }
     }
     if (is_tax()) {
         $ogdesc = trim(strip_tags(term_description()));
     }
     $ogdesc = apply_filters('wpseo_opengraph_desc', $ogdesc);
     if ($ogdesc && (is_string($ogdesc) && $ogdesc != '')) {
         if ($echo !== false) {
             $this->og_tag('og:description', $ogdesc);
         }
     }
     return $ogdesc;
 }
コード例 #17
0
 /**
  * Output the OpenGraph description, specific OG description first, if not, grab the meta description.
  */
 public function description()
 {
     $ogdesc = wpseo_get_value('opengraph-description');
     if (!$ogdesc) {
         $ogdesc = $this->metadesc(false);
     }
     if ($ogdesc && $ogdesc != '') {
         echo "<meta property='og:description' content='" . esc_attr($ogdesc) . "'/>\n";
     }
 }
コード例 #18
0
function 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+/', ' ', $string));
    }
    $simple_replacements = array('%%sitename%%' => get_bloginfo('name'), '%%sitedesc%%' => get_bloginfo('description'), '%%currenttime%%' => date('H:i'), '%%currentdate%%' => date('M jS Y'), '%%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+/', ' ', $string));
    }
    global $wp_query;
    $defaults = array('ID' => '', 'name' => '', 'post_author' => '', 'post_content' => '', 'post_date' => '', 'post_content' => '', 'post_excerpt' => '', 'post_modified' => '', 'post_title' => '', 'taxonomy' => '', 'term_id' => '');
    $pagenum = get_query_var('paged');
    if ($pagenum === 0) {
        if ($wp_query->max_num_pages > 1) {
            $pagenum = 1;
        } else {
            $pagenum = '';
        }
    }
    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);
    // Only global $post on single's, otherwise some expressions will return wrong results.
    if (is_singular() || is_front_page() && 'posts' != get_option('show_on_front')) {
        global $post;
    }
    // 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);
            } else {
                if (get_query_var('year') != '') {
                    $date = get_query_var('year');
                } else {
                    $date = '';
                }
            }
        }
    }
    $replacements = array('%%date%%' => $date, '%%title%%' => stripslashes($r->post_title), '%%excerpt%%' => !empty($r->post_excerpt) ? strip_tags($r->post_excerpt) : substr(strip_shortcodes(strip_tags($r->post_content)), 0, 155), '%%excerpt_only%%' => strip_tags($r->post_excerpt), '%%category%%' => wpseo_get_terms($r->ID, 'category'), '%%category_description%%' => !empty($r->taxonomy) ? trim(strip_tags(get_term_field('description', $r->term_id, $r->taxonomy))) : '', '%%tag_description%%' => !empty($r->taxonomy) ? trim(strip_tags(get_term_field('description', $r->term_id, $r->taxonomy))) : '', '%%term_description%%' => !empty($r->taxonomy) ? trim(strip_tags(get_term_field('description', $r->term_id, $r->taxonomy))) : '', '%%term_title%%' => $r->name, '%%focuskw%%' => wpseo_get_value('focuskw', $r->ID), '%%tag%%' => wpseo_get_terms($r->ID, 'post_tag'), '%%modified%%' => mysql2date(get_option('date_format'), $r->post_modified), '%%id%%' => $r->ID, '%%name%%' => get_the_author_meta('display_name', !empty($r->post_author) ? $r->post_author : get_query_var('author')), '%%userid%%' => !empty($r->post_author) ? $r->post_author : get_query_var('author'), '%%searchphrase%%' => esc_html(get_query_var('s')), '%%page%%' => get_query_var('paged') != 0 ? 'Page ' . get_query_var('paged') . ' of ' . $wp_query->max_num_pages : '', '%%pagetotal%%' => $wp_query->max_num_pages > 1 ? $wp_query->max_num_pages : '', '%%pagenumber%%' => $pagenum, '%%caption%%' => $r->post_excerpt);
    foreach ($replacements as $var => $repl) {
        if (!in_array($var, $omit)) {
            $string = str_replace($var, $repl, $string);
        }
    }
    if (strpos($string, '%%') === false) {
        $string = preg_replace('/\\s\\s+/', ' ', $string);
        return trim($string);
    }
    if (preg_match_all('/%%cf_([^%]+)%%/', $string, $matches, PREG_SET_ORDER)) {
        global $post;
        foreach ($matches as $match) {
            $string = str_replace($match[0], get_post_meta($post->ID, $match[1], true), $string);
        }
    }
    $string = preg_replace('/\\s\\s+/', ' ', $string);
    return trim($string);
}
コード例 #19
0
 /**
  * Output the OpenGraph description, specific OG description first, if not, grab the meta description.
  *
  * @param bool $echo Whether to echo or return the description
  * @return string $ogdesc
  */
 public function description($echo = true)
 {
     $ogdesc = wpseo_get_value('opengraph-description');
     if (!$ogdesc) {
         $ogdesc = $this->metadesc(false);
     }
     $ogdesc = apply_filters('wpseo_opengraph_desc', $ogdesc);
     if ($ogdesc && $ogdesc != '') {
         if ($echo !== false) {
             echo "<meta property='og:description' content='" . esc_attr($ogdesc) . "'/>\n";
         } else {
             return $ogdesc;
         }
     }
 }
コード例 #20
0
/**
 * 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;
    if (is_object($wpseo_front)) {
        $url = $wpseo_front->canonical(false);
    } else {
        $url = '';
    }
    $focuskw = '';
    $score = '';
    $seo_url = get_admin_url('admin.php?page=wpseo_dashboard');
    if (is_singular() && isset($post) && is_object($post) && apply_filters('wpseo_use_page_analysis', true) === true) {
        $focuskw = wpseo_get_value('focuskw', $post->ID);
        $perc_score = wpseo_get_value('linkdex', $post->ID);
        $txtscore = wpseo_translate_score(round($perc_score / 10));
        $score = '<div alt="' . ucfirst($txtscore) . '" title="' . ucfirst($txtscore) . '" class="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' => 'https://adwords.google.com/select/KeywordToolExternal', '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'), '#'));
        $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('/^https?:\\/\\//', '', $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://tools.davidnaylor.co.uk/keyworddensity/index.php?url=' . $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:' . $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')));
    }
    $admin_menu = false;
    if (function_exists('is_multisite') && is_multisite()) {
        $options = get_site_option('wpseo_ms');
        if (is_array($options) && isset($options['access']) && $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;
        }
    }
    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')));
    }
}
コード例 #21
0
 /**
  * Take the links array and return a full breadcrumb string.
  *
  * Each element of the links array can either have one of these keys:
  *       "id"            for post types;
  *    "ptarchive"  for a post type archive;
  *    "term"         for a taxonomy term.
  * If either of these 3 are set, the url and text are retrieved. If not, url and text have to be set.
  *
  * @link http://support.google.com/webmasters/bin/answer.py?hl=en&answer=185417 Google documentation on RDFA
  *
  * @param array  $links   The links that should be contained in the breadcrumb.
  * @param string $wrapper The wrapping element for the entire breadcrumb path.
  * @param string $element The wrapping element for each individual link.
  * @return string
  */
 function create_breadcrumbs_string($links, $wrapper = 'span', $element = 'span')
 {
     global $paged;
     $opt = get_wpseo_options();
     $sep = isset($opt['breadcrumbs-sep']) && $opt['breadcrumbs-sep'] != '' ? $opt['breadcrumbs-sep'] : '&raquo;';
     $output = '';
     foreach ($links as $i => $link) {
         if (!empty($output)) {
             $output .= " {$sep} ";
         }
         if (isset($link['id'])) {
             $link['url'] = get_permalink($link['id']);
             $link['text'] = wpseo_get_value('bctitle', $link['id']);
             if (empty($link['text'])) {
                 $link['text'] = strip_tags(get_the_title($link['id']));
             }
             $link['text'] = apply_filters('wp_seo_get_bc_title', $link['text'], $link['id']);
         }
         if (isset($link['term'])) {
             $bctitle = wpseo_get_term_meta($link['term'], $link['term']->taxonomy, 'bctitle');
             if (!$bctitle) {
                 $bctitle = $link['term']->name;
             }
             $link['url'] = get_term_link($link['term']);
             $link['text'] = $bctitle;
         }
         if (isset($link['ptarchive'])) {
             if (isset($opt['bctitle-ptarchive-' . $link['ptarchive']]) && '' != $opt['bctitle-ptarchive-' . $link['ptarchive']]) {
                 $archive_title = $opt['bctitle-ptarchive-' . $link['ptarchive']];
             } else {
                 $post_type_obj = get_post_type_object($link['ptarchive']);
                 $archive_title = $post_type_obj->labels->menu_name;
             }
             $link['url'] = get_post_type_archive_link($link['ptarchive']);
             $link['text'] = $archive_title;
         }
         $element = apply_filters('wpseo_breadcrumb_single_link_wrapper', $element);
         $link_output = '<' . $element . ' typeof="v:Breadcrumb">';
         if (isset($link['url']) && ($i < count($links) - 1 || $paged)) {
             $link_output .= '<a href="' . esc_attr($link['url']) . '" rel="v:url" property="v:title">' . $link['text'] . '</a>';
         } else {
             if (isset($opt['breadcrumbs-boldlast']) && $opt['breadcrumbs-boldlast']) {
                 $link_output .= '<strong class="breadcrumb_last" property="v:title">' . $link['text'] . '</strong>';
             } else {
                 $link_output .= '<span class="breadcrumb_last" property="v:title">' . $link['text'] . '</span>';
             }
         }
         $link_output .= '</' . $element . '>';
         $output .= apply_filters('wpseo_breadcrumb_single_link', $link_output, $link);
     }
     $id = apply_filters('wpseo_breadcrumb_output_id', false);
     if (!empty($id)) {
         $id = ' id="' . $id . '"';
     }
     $class = apply_filters('wpseo_breadcrumb_output_class', false);
     if (!empty($class)) {
         $class = ' class="' . $class . '"';
     }
     $wrapper = apply_filters('wpseo_breadcrumb_output_wrapper', $wrapper);
     return apply_filters('wpseo_breadcrumb_output', '<' . $wrapper . $id . $class . ' xmlns:v="http://rdf.data-vocabulary.org/#">' . $output . '</' . $wrapper . '>');
 }
コード例 #22
0
 /**
  * Based on the redirect meta value, this function determines whether it should redirect the current post / page.
  *
  * @return mixed
  */
 function page_redirect()
 {
     if (is_singular()) {
         global $post;
         if (!isset($post)) {
             return;
         }
         $redir = wpseo_get_value('redirect', $post->ID);
         if (!empty($redir)) {
             wp_redirect($redir, 301);
             exit;
         }
     }
 }
コード例 #23
0
 public function description()
 {
     $ogdesc = wpseo_get_value('opengraph-description');
     if (!$ogdesc) {
         $ogdesc = WPSEO_Frontend::metadesc(false);
     }
     if ($ogdesc && $ogdesc != '') {
         echo "<meta property='og:description' content='" . esc_attr($ogdesc) . "'/>\n";
     }
     //
     // $gplusdesc = wpseo_get_value('google-plus-description');
     //
     // if ( !$gplusdesc )
     // 	$gplusdesc = WPSEO_Frontend::metadesc( false );
     //
     // if ( $gplusdesc && $gplusdesc != '' )
     // 	echo "<meta itemprop='description' content='".esc_attr( $gplusdesc )."'/>\n";
 }
コード例 #24
0
 public function description()
 {
     $desc = wpseo_get_value('opengraph-description');
     if (!$desc) {
         $desc = WPSEO_Frontend::metadesc(false);
     }
     if ($desc && $desc != '') {
         echo "<meta property='og:description' content='" . esc_attr($desc) . "'/>\n";
     }
 }
コード例 #25
0
ファイル: class-sitemaps.php プロジェクト: Joshuwar/Masterson
 /**
  * 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.
  *
  * @todo Potentially schedule a cron event instead so that pinging runs in the background.
  */
 function status_transition($new_status, $old_status, $post)
 {
     if ($new_status != 'publish') {
         return;
     }
     wp_cache_delete('lastpostmodified:gmt:' . $post->post_type, 'timeinfo');
     // #17455
     $options = get_wpseo_options();
     if (isset($options['post_types-' . $post->post_type . '-not_in_sitemap']) && $options['post_types-' . $post->post_type . '-not_in_sitemap']) {
         return;
     }
     if (WP_CACHE) {
         wp_schedule_single_event(time(), 'wpseo_hit_sitemap_index');
     }
     if (wpseo_get_value('sitemap-include', $post->ID) != 'never') {
         $this->ping_search_engines();
     }
 }
コード例 #26
0
 /**
  * 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)
 {
     $options = get_wpseo_options();
     if (isset($options['post_types-' . $post_type . '-not_in_sitemap']) && $options['post_types-' . $post_type . '-not_in_sitemap'] || in_array($post_type, array('revision', 'nav_menu_item', 'attachment'))) {
         $this->bad_sitemap = true;
         return;
     }
     $output = '';
     $front_id = get_option('page_on_front');
     if (!$front_id && ($post_type == 'post' || $post_type == 'page')) {
         $output .= $this->sitemap_url(array('loc' => home_url('/'), 'pri' => 1, 'chf' => 'daily'));
     } else {
         if ($front_id && $post_type == 'post') {
             $page_for_posts = get_option('page_for_posts');
             if ($page_for_posts) {
                 $output .= $this->sitemap_url(array('loc' => get_permalink($page_for_posts), 'pri' => 1, 'chf' => 'daily'));
             }
         }
     }
     if (function_exists('get_post_type_archive_link')) {
         $archive = get_post_type_archive_link($post_type);
         if ($archive) {
             $output .= $this->sitemap_url(array('loc' => $archive, 'pri' => 0.8, 'chf' => 'weekly', 'mod' => $this->get_last_modified($post_type)));
         }
     }
     global $wpdb;
     $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);
     $typecount = $wpdb->get_var("SELECT COUNT(ID) FROM {$wpdb->posts} {$join_filter} WHERE post_status = 'publish' AND post_password = '' AND post_type = '{$post_type}' {$where_filter}");
     if ($typecount == 0 && empty($archive)) {
         $this->bad_sitemap = true;
         return;
     }
     $stackedurls = array();
     $steps = 25;
     $n = (int) get_query_var('sitemap_n');
     $offset = $n > 1 ? ($n - 1) * 1000 : 0;
     $total = $offset + 1000;
     if ($total > $typecount) {
         $total = $typecount;
     }
     // 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) {
         $join_filter = apply_filters('wpseo_posts_join', '', $post_type);
         $where_filter = apply_filters('wpseo_posts_where', '', $post_type);
         // 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/
         $posts = $wpdb->get_results("SELECT l.ID, post_content, post_name, post_author, post_parent, post_modified_gmt, post_date, post_date_gmt\n\t\t\tFROM ( \n\t\t\t\tSELECT ID FROM {$wpdb->posts} {$join_filter}\n\t\t\t\t\t\tWHERE post_status = 'publish'\n\t\t\t\t\t\tAND\tpost_password = ''\n\t\t\t\t\t\tAND post_type = '{$post_type}'\n\t\t\t\t\t\t{$where_filter}\n\t\t\t\t\t\tORDER BY post_modified ASC\n\t\t\t\t\t\tLIMIT {$steps} OFFSET {$offset} ) o\n\t\t\tJOIN {$wpdb->posts} l\n\t\t\t\tON l.ID = o.ID\n\t\t\t\tORDER BY l.ID");
         /*			$posts = $wpdb->get_results("SELECT ID, post_content, post_name, post_author, post_parent, post_modified_gmt, post_date, post_date_gmt
         		   FROM $wpdb->posts {$join_filter}
         		   WHERE post_status = 'publish'
         		   AND	post_password = ''
         		   AND post_type = '$post_type'
         		   {$where_filter}
         		   ORDER BY post_modified ASC
         		   LIMIT $steps OFFSET $offset"); */
         $offset = $offset + $steps;
         foreach ($posts as $p) {
             $p->post_type = $post_type;
             $p->post_status = 'publish';
             $p->filter = 'sample';
             if (wpseo_get_value('meta-robots-noindex', $p->ID) && wpseo_get_value('sitemap-include', $p->ID) != 'always') {
                 continue;
             }
             if (wpseo_get_value('sitemap-include', $p->ID) == 'never') {
                 continue;
             }
             if (wpseo_get_value('redirect', $p->ID) && strlen(wpseo_get_value('redirect', $p->ID)) > 0) {
                 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;
             $url['chf'] = 'weekly';
             $url['loc'] = get_permalink($p);
             $canonical = wpseo_get_value('canonical', $p->ID);
             if ($canonical && $canonical != '' && $canonical != $url['loc']) {
                 // Let's assume that if a canonical is set for this page and it's different from the URL of this post, that page is either
                 // already in the XML sitemap OR is on an external site, either way, we shouldn't include it here.
                 continue;
             } else {
                 if (isset($options['trailingslash']) && $options['trailingslash'] && $p->post_type != 'post') {
                     $url['loc'] = trailingslashit($url['loc']);
                 }
             }
             $pri = wpseo_get_value('sitemap-prio', $p->ID);
             if (is_numeric($pri)) {
                 $url['pri'] = $pri;
             } elseif ($p->post_parent == 0 && $p->post_type == 'page') {
                 $url['pri'] = 0.8;
             } else {
                 $url['pri'] = 0.6;
             }
             if ($p->ID == $front_id) {
                 $url['pri'] = 1.0;
             }
             $url['images'] = array();
             $content = $p->post_content;
             if (function_exists('get_the_post_thumbnail')) {
                 $content = '<p>' . get_the_post_thumbnail($p->ID, 'full') . '</p>' . $content;
             }
             $host = str_replace('www.', '', parse_url(get_bloginfo('url'), PHP_URL_HOST));
             if (preg_match_all('/<img [^>]+>/', $content, $matches)) {
                 foreach ($matches[0] as $img) {
                     if (preg_match('/src=("|\')([^"|\']+)("|\')/', $img, $match)) {
                         $src = $match[2];
                         if (strpos($src, 'http') !== 0) {
                             if ($src[0] != '/') {
                                 continue;
                             }
                             $src = get_bloginfo('url') . $src;
                         }
                         if (strpos($src, $host) === false) {
                             continue;
                         }
                         if ($src != esc_url($src)) {
                             continue;
                         }
                         if (isset($url['images'][$src])) {
                             continue;
                         }
                         $image = array('src' => apply_filters('wpseo_xml_sitemap_img_src', $src, $p));
                         if (preg_match('/title=("|\')([^"\']+)("|\')/', $img, $match)) {
                             $image['title'] = str_replace(array('-', '_'), ' ', $match[2]);
                         }
                         if (preg_match('/alt=("|\')([^"\']+)("|\')/', $img, $match)) {
                             $image['alt'] = str_replace(array('-', '_'), ' ', $match[2]);
                         }
                         $image = apply_filters('wpseo_xml_sitemap_img', $image, $p);
                         $url['images'][] = $image;
                     }
                 }
             }
             if (preg_match_all('/\\[gallery/', $p->post_content, $matches)) {
                 $attachments = get_children(array('post_parent' => $p->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image'));
                 foreach ($attachments as $att_id => $attachment) {
                     $src = wp_get_attachment_image_src($att_id, 'large', false);
                     $image = array('src' => apply_filters('wpseo_xml_sitemap_img_src', $src[0], $p));
                     if ($alt = get_post_meta($att_id, '_wp_attachment_image_alt', true)) {
                         $image['alt'] = $alt;
                     }
                     $image['title'] = $attachment->post_title;
                     $image = apply_filters('wpseo_xml_sitemap_img', $image, $p);
                     $url['images'][] = $image;
                 }
             }
             $url['images'] = apply_filters('wpseo_sitemap_urlimages', $url['images'], $p->ID);
             if (!in_array($url['loc'], $stackedurls)) {
                 $output .= $this->sitemap_url($url);
                 $stackedurls[] = $url['loc'];
             }
             // Clear the post_meta and the term cache for the post, as we no longer need it now.
             // wp_cache_delete( $p->ID, 'post_meta' );
             // clean_object_term_cache( $p->ID, $post_type );
         }
     }
     if (empty($output)) {
         $this->bad_sitemap = true;
         return;
     }
     $this->sitemap = '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" ';
     $this->sitemap .= 'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" ';
     $this->sitemap .= 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
     $this->sitemap .= $output;
     // Filter to allow adding extra URLs, only do this on the first XML sitemap, not on all.
     if ($n == 0) {
         $this->sitemap .= apply_filters('wpseo_sitemap_' . $post_type . '_content', '');
     }
     $this->sitemap .= '</urlset>';
 }
コード例 #27
0
 /**
  * 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 $wpseo_sitemaps;
     $options = get_wpseo_options();
     if (isset($options['post_types-' . $post_type . '-not_in_sitemap']) && $options['post_types-' . $post_type . '-not_in_sitemap'] || in_array($post_type, array('revision', 'nav_menu_item', 'attachment'))) {
         $this->bad_sitemap = true;
         $wpseo_sitemaps->set_bad_sitemap(true);
         return;
     }
     $output = '';
     $front_id = get_option('page_on_front');
     if (!$front_id && $post_type == 'post') {
         $output .= $wpseo_sitemaps->sitemap_url(array('loc' => home_url('/'), 'pri' => 1, 'chf' => 'daily'));
     } else {
         if ($front_id && $post_type == 'post') {
             $page_for_posts = get_option('page_for_posts');
             if ($page_for_posts) {
                 $output .= $wpseo_sitemaps->sitemap_url(array('loc' => get_permalink($page_for_posts), 'pri' => 1, 'chf' => 'daily'));
             }
         }
     }
     if (function_exists('get_post_type_archive_link')) {
         $archive = get_post_type_archive_link($post_type);
         if ($archive) {
             $output .= $wpseo_sitemaps->sitemap_url(array('loc' => $archive, 'pri' => 0.8, 'chf' => 'weekly', 'mod' => $wpseo_sitemaps->get_last_modified($post_type)));
         }
     }
     global $wpdb;
     $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);
     $typecount = $wpdb->get_var("SELECT COUNT(ID) FROM {$wpdb->posts} {$join_filter} WHERE post_status = 'publish' AND post_password = '' AND post_type = '{$post_type}' {$where_filter}");
     if ($typecount == 0 && empty($archive)) {
         $this->bad_sitemap = true;
         $wpseo_sitemaps->set_bad_sitemap(true);
         return;
     }
     // Let's flush the object cache so we're not left with garbage from other plugins
     wp_cache_flush();
     $stackedurls = array();
     $steps = 25;
     $n = (int) get_query_var('sitemap_n');
     $offset = $n > 1 ? ($n - 1) * 1000 : 0;
     $total = $offset + 1000;
     if ($total > $typecount) {
         $total = $typecount;
     }
     // 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) {
         $join_filter = '';
         $join_filter = apply_filters('wpseo_posts_join', $join_filter, $post_type);
         $where_filter = '';
         $where_filter = apply_filters('wpseo_posts_where', $where_filter, $post_type);
         $posts = $wpdb->get_results("SELECT ID, post_content, post_name, post_author, post_parent, post_modified_gmt, post_date, post_date_gmt\n\t\t\tFROM {$wpdb->posts} {$join_filter}\n\t\t\tWHERE post_status = 'publish'\n\t\t\tAND\tpost_password = ''\n\t\t\tAND post_type = '{$post_type}'\n\t\t\t{$where_filter}\n\t\t\tORDER BY post_modified ASC\n\t\t\tLIMIT {$steps} OFFSET {$offset}");
         $offset = $offset + $steps;
         $etm_current_data = etm_tools_retrive_aktiv_languages();
         $etm_tag_string = etm_tools_retrive_options('GP_name');
         $etm_permalinktilladelse = etm_tools_retrive_options('use_permalink');
         $etm_default_lang = etm_tools_retrive_options('default_language');
         $etm_tag_array = '';
         if (!empty($etm_tag_string)) {
             $etm_tag_array = explode('|', $etm_tag_string);
             $etm_tag_string = '';
         }
         foreach ($posts as $p) {
             $p->post_type = $post_type;
             $p->post_status = 'publish';
             $p->filter = 'sample';
             $runethrowlang = array();
             $runethrowlang[] = '';
             if ($post_type == 'post' || $post_type == 'page') {
                 $tmp_meta_data = '';
                 $tmp_meta_data = get_post_custom($p->ID);
                 foreach ($etm_current_data as $etm_lang_key => $etm_lang_data) {
                     $_tran_focuskw = '';
                     $_tran_title = '';
                     $_tran_metadesc = '';
                     $translations_header = '';
                     $translations_body = '';
                     $translations_permalink = '';
                     $_tran_focuskw = $tmp_meta_data['_yoast_wpseo_focuskw_' . $etm_lang_key][0];
                     $_tran_title = $tmp_meta_data['_yoast_wpseo_title_' . $etm_lang_key][0];
                     $_tran_metadesc = $tmp_meta_data['_yoast_wpseo_metadesc_' . $etm_lang_key][0];
                     $translations_header = $tmp_meta_data['ect_tran_title_' . $etm_lang_key][0];
                     $translations_body = $tmp_meta_data['ect_tran_content_' . $etm_lang_key][0];
                     $translations_permalink = $tmp_meta_data['ect_tran_permalink_' . $etm_lang_key][0];
                     if ($translations_permalink == '/' || !$etm_permalinktilladelse) {
                         $translations_permalink = '';
                     }
                     if (!empty($_tran_focuskw) || !empty($_tran_title) || !empty($_tran_metadesc) || !empty($translations_header) || !empty($translations_body)) {
                         $etm_tag_string = '';
                         $etm_permalin_string = '';
                         if (!empty($etm_tag_array) && empty($translations_permalink)) {
                             foreach ($etm_tag_array as $temp_dat) {
                                 if (!empty($etm_tag_string)) {
                                     $etm_tag_string .= '&';
                                 }
                                 $etm_tag_string .= $temp_dat . '=' . $etm_lang_key;
                             }
                         } else {
                             if (!empty($translations_permalink)) {
                                 $etm_permalin_string = $translations_permalink;
                             }
                         }
                         if (!empty($etm_tag_string)) {
                             $runethrowlang[$etm_lang_key]->url = $etm_tag_string;
                             $runethrowlang[$etm_lang_key]->permalink = 'false';
                         } else {
                             if (!empty($etm_permalin_string)) {
                                 $runethrowlang[$etm_lang_key]->url = $etm_permalin_string;
                                 $runethrowlang[$etm_lang_key]->permalink = 'true';
                             }
                         }
                     }
                 }
             }
             unset($tmp_meta_data);
             unset($_tran_focuskw);
             unset($_tran_title);
             unset($_tran_metadesc);
             unset($translations_header);
             unset($translations_body);
             unset($translations_permalink);
             foreach ($runethrowlang as $etm_translatede_key => $etm_translatede_data) {
                 if (wpseo_get_value('meta-robots-noindex', $p->ID) && wpseo_get_value('sitemap-include', $p->ID) != 'always') {
                     continue;
                 }
                 if (wpseo_get_value('sitemap-include', $p->ID) == 'never') {
                     continue;
                 }
                 if (wpseo_get_value('redirect', $p->ID) && strlen(wpseo_get_value('redirect', $p->ID)) > 0) {
                     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;
                 $url['chf'] = 'weekly';
                 $url['loc'] = get_permalink($p);
                 if (!empty($etm_translatede_data) && $etm_translatede_data->permalink == 'true') {
                     if (!empty($etm_translatede_data->url)) {
                         $url['loc'] = trailingslashit(get_option('siteurl')) . $etm_translatede_data->url;
                     }
                 } else {
                     if (!empty($etm_translatede_data)) {
                         $pieces = explode("?", $url['loc']);
                         if (count($pieces) > 1) {
                             $url['loc'] = $url['loc'] . '&' . $etm_translatede_data->url;
                         } else {
                             $url['loc'] = $url['loc'] . '?' . $etm_translatede_data->url;
                         }
                     }
                 }
                 $canonical = wpseo_get_value('canonical', $p->ID);
                 if ($canonical && $canonical != '' && $canonical != $url['loc']) {
                     continue;
                 } else {
                     if (isset($options['trailingslash']) && $options['trailingslash'] && $p->post_type != 'post') {
                         $url['loc'] = trailingslashit($url['loc']);
                     }
                 }
                 $pri = wpseo_get_value('sitemap-prio', $p->ID);
                 if (is_numeric($pri)) {
                     $url['pri'] = $pri;
                 } elseif ($p->post_parent == 0 && $p->post_type == 'page') {
                     $url['pri'] = 0.8;
                 } else {
                     $url['pri'] = 0.6;
                 }
                 if ($p->ID == $front_id) {
                     $url['pri'] = 1.0;
                 }
                 $url['images'] = array();
                 if (preg_match_all('/<img [^>]+>/', $p->post_content, $matches)) {
                     foreach ($matches[0] as $img) {
                         // FIXME: get true caption instead of alt / title
                         if (preg_match('/src=("|\')([^"|\']+)("|\')/', $img, $match)) {
                             $src = $match[2];
                             if (strpos($src, 'http') !== 0) {
                                 if ($src[0] != '/') {
                                     continue;
                                 }
                                 $src = get_bloginfo('url') . $src;
                             }
                             if ($src != esc_url($src)) {
                                 continue;
                             }
                             if (isset($url['images'][$src])) {
                                 continue;
                             }
                             $image = array();
                             if (preg_match('/title=("|\')([^"\']+)("|\')/', $img, $match)) {
                                 $image['title'] = str_replace(array('-', '_'), ' ', $match[2]);
                             }
                             if (preg_match('/alt=("|\')([^"\']+)("|\')/', $img, $match)) {
                                 $image['alt'] = str_replace(array('-', '_'), ' ', $match[2]);
                             }
                             $url['images'][$src] = $image;
                         }
                     }
                 }
                 if (preg_match_all('/\\[gallery/', $p->post_content, $matches)) {
                     $attachments = get_children(array('post_parent' => $p->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image'));
                     foreach ($attachments as $att_id => $attachment) {
                         $src = wp_get_attachment_image_src($att_id, 'large', false);
                         $src = $src[0];
                         $image = array();
                         if ($alt = get_post_meta($att_id, '_wp_attachment_image_alt', true)) {
                             $image['alt'] = $alt;
                         }
                         $image['title'] = $attachment->post_title;
                         $url['images'][$src] = $image;
                     }
                 }
                 $url['images'] = apply_filters('wpseo_sitemap_urlimages', $url['images'], $p->ID);
                 if (!in_array($url['loc'], $stackedurls)) {
                     $output .= $wpseo_sitemaps->sitemap_url($url);
                     $stackedurls[] = $url['loc'];
                 }
             }
             // Clear the post_meta and the term cache for the post, as we no longer need it now.
             wp_cache_delete($p->ID, 'post_meta');
             // clean_object_term_cache( $p->ID, $post_type );
         }
     }
     if (empty($output)) {
         $this->bad_sitemap = true;
         $wpseo_sitemaps->set_bad_sitemap(true);
         return;
     }
     $this->sitemap = '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" ';
     $this->sitemap .= 'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" ';
     $this->sitemap .= 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
     $this->sitemap .= $output . '</urlset>';
     $wpseo_sitemaps->set_sitemap($this->sitemap);
 }