/** * Build a sub-sitemap for a specific taxonomy -- example.com/tax-sitemap.xml * * @param string $taxonomy Registered taxonomy's slug */ function build_tax_map($taxonomy) { $options = get_wpseo_options(); if (isset($options['taxonomies-' . $taxonomy->name . '-not_in_sitemap']) && $options['taxonomies-' . $taxonomy->name . '-not_in_sitemap'] || in_array($taxonomy, array('link_category', 'nav_menu', 'post_format'))) { $this->bad_sitemap = true; return; } $terms = get_terms($taxonomy->name, array('hide_empty' => true)); global $wpdb; $output = ''; foreach ($terms as $c) { $url = array(); if (wpseo_get_term_meta($c, $c->taxonomy, 'noindex') && wpseo_get_term_meta($c, $c->taxonomy, 'sitemap_include') != 'always') { continue; } if (wpseo_get_term_meta($c, $c->taxonomy, 'sitemap_include') == 'never') { continue; } $url['loc'] = wpseo_get_term_meta($c, $c->taxonomy, 'canonical'); if (!$url['loc']) { $url['loc'] = get_term_link($c, $c->taxonomy); if (isset($options['trailingslash']) && $options['trailingslash']) { $url['loc'] = trailingslashit($url['loc']); } } if ($c->count > 10) { $url['pri'] = 0.6; } else { if ($c->count > 3) { $url['pri'] = 0.4; } else { $url['pri'] = 0.2; } } // Grab last modified date $sql = "SELECT MAX(p.post_date) AS lastmod\n\t\t\t\t\tFROM\t{$wpdb->posts} AS p\n\t\t\t\t\tINNER JOIN {$wpdb->term_relationships} AS term_rel\n\t\t\t\t\tON\t\tterm_rel.object_id = p.ID\n\t\t\t\t\tINNER JOIN {$wpdb->term_taxonomy} AS term_tax\n\t\t\t\t\tON\t\tterm_tax.term_taxonomy_id = term_rel.term_taxonomy_id\n\t\t\t\t\tAND\t\tterm_tax.taxonomy = '{$c->taxonomy}'\n\t\t\t\t\tAND\t\tterm_tax.term_id = {$c->term_id}\n\t\t\t\t\tWHERE\tp.post_status = 'publish'\n\t\t\t\t\tAND\t\tp.post_password = ''"; $url['mod'] = $wpdb->get_var($sql); $url['chf'] = 'weekly'; $output .= $this->sitemap_url($url); } if (empty($output)) { $this->bad_sitemap = true; return; } $this->sitemap = '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '; $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>'; }
/** * Outputs the meta description element or returns the description text. * * @param bool $echo Whether or not to echo the description. * @return string */ function metadesc($echo = true) { if (get_query_var('paged') && get_query_var('paged') > 1) { return; } global $post, $wp_query; $options = get_wpseo_options(); $metadesc = ''; if (is_singular()) { $metadesc = wpseo_get_value('metadesc'); if ($metadesc == '' || !$metadesc) { if (isset($options['metadesc-' . $post->post_type]) && $options['metadesc-' . $post->post_type] != '') { $metadesc = wpseo_replace_vars($options['metadesc-' . $post->post_type], (array) $post); } } } else { if (is_search()) { $metadesc = ''; } else { if ($this->is_home_posts_page() && isset($options['metadesc-home'])) { $metadesc = wpseo_replace_vars($options['metadesc-home'], array()); } else { if ($this->is_posts_page()) { $metadesc = wpseo_get_value('metadesc', get_option('page_for_posts')); if (($metadesc == '' || !$metadesc) && isset($options['metadesc-' . $post->post_type])) { $page = get_post(get_option('page_for_posts')); $metadesc = wpseo_replace_vars($options['metadesc-' . $post->post_type], (array) $page); } } else { if ($this->is_home_static_page()) { global $post; $metadesc = wpseo_get_value('metadesc'); if (($metadesc == '' || !$metadesc) && isset($options['metadesc-' . $post->post_type])) { $metadesc = wpseo_replace_vars($options['metadesc-' . $post->post_type], (array) $post); } } else { if (is_category() || is_tag() || is_tax()) { $term = $wp_query->get_queried_object(); $metadesc = wpseo_get_term_meta($term, $term->taxonomy, 'desc'); if (!$metadesc && isset($options['metadesc-' . $term->taxonomy])) { $metadesc = wpseo_replace_vars($options['metadesc-' . $term->taxonomy], (array) $term); } } else { if (is_author()) { $author_id = get_query_var('author'); $metadesc = get_the_author_meta('wpseo_metadesc', $author_id); if (!$metadesc && isset($options['metadesc-author'])) { $metadesc = wpseo_replace_vars($options['metadesc-author'], (array) $wp_query->get_queried_object()); } } else { if (function_exists('is_post_type_archive') && is_post_type_archive()) { $post_type = get_post_type(); if (isset($options['metadesc-ptarchive-' . $post_type]) && '' != $options['metadesc-ptarchive-' . $post_type]) { $metadesc = $options['metadesc-ptarchive-' . $post_type]; } } } } } } } } } $metadesc = apply_filters('wpseo_metadesc', trim($metadesc)); if ($echo) { if (!empty($metadesc)) { echo '<meta name="description" content="' . esc_attr(strip_tags(stripslashes($metadesc))) . '"/>' . "\n"; } else { if (current_user_can('manage_options') && is_singular()) { echo '<!-- ' . __('Admin only notice: this page doesn\'t show a meta description because it doesn\'t have one, either write it for this page specifically or go into the SEO -> Titles menu and set up a template.', 'wordpress-seo') . ' -->' . "\n"; } } } else { return $metadesc; } }
private function title() { global $post, $wp_query; if (empty($post) && is_singular()) { $post = $wp_query->get_queried_object(); } $options = get_wpseo_options(); if (is_home() && 'posts' == get_option('show_on_front')) { if (isset($options['title-home']) && $options['title-home'] != '') { $title = wpseo_replace_vars($options['title-home'], array()); } else { $title = get_bloginfo('name'); } } else { if (is_home() && 'posts' != get_option('show_on_front')) { // For some reason, in some instances is_home returns true for the front page when page_for_posts is not set. if (get_option('page_for_posts') == 0) { $post = get_post(get_option('page_on_front')); } else { $post = get_post(get_option('page_for_posts')); } $fixed_title = wpseo_get_value('title'); if ($fixed_title) { $title = $fixed_title; } else { if (isset($options['title-' . $post->post_type]) && !empty($options['title-' . $post->post_type])) { $title = wpseo_replace_vars($options['title-' . $post->post_type], (array) $post); } else { $title = get_bloginfo('name'); } } } else { if (is_singular()) { $fixed_title = wpseo_get_value('title'); if ($fixed_title) { $title = $fixed_title; } else { if (isset($options['title-' . $post->post_type]) && !empty($options['title-' . $post->post_type])) { $title = wpseo_replace_vars($options['title-' . $post->post_type], (array) $post); } else { $title = get_the_title(); $title = apply_filters('single_post_title', $title); } } } else { if (is_category() || is_tag() || is_tax()) { $term = $wp_query->get_queried_object(); $title = trim(wpseo_get_term_meta($term, $term->taxonomy, 'title')); if (!$title || empty($title)) { if (isset($options['title-' . $term->taxonomy]) && !empty($options['title-' . $term->taxonomy])) { $title = wpseo_replace_vars($options['title-' . $term->taxonomy], (array) $term); } else { if (is_category()) { $title = single_cat_title('', false); } else { if (is_tag()) { $title = single_tag_title('', false); } else { if (is_tax()) { if (function_exists('single_term_title')) { $title = single_term_title('', false); } else { $term = $wp_query->get_queried_object(); $title = $term->name; } } } } } } } else { if (is_search()) { if (isset($options['title-search']) && !empty($options['title-search'])) { $title = wpseo_replace_vars($options['title-search'], (array) $wp_query->get_queried_object()); } else { $title = __('Search for "') . get_search_query() . '"'; } } else { if (is_author()) { $author_id = get_query_var('author'); $title = get_the_author_meta('wpseo_title', $author_id); if (empty($title)) { if (isset($options['title-author']) && !empty($options['title-author'])) { $title = wpseo_replace_vars($options['title-author'], array()); } else { $title = get_the_author_meta('display_name', $author_id); } } } else { if (is_post_type_archive()) { $post_type = get_post_type(); if (isset($options['title-ptarchive-' . $post_type]) && '' != $options['title-ptarchive-' . $post_type]) { return $options['title-ptarchive-' . $post_type]; } else { $post_type_obj = get_post_type_object($post_type); $title = $post_type_obj->labels->menu_name; } } else { if (is_archive()) { if (isset($options['title-archive']) && !empty($options['title-archive'])) { $title = wpseo_replace_vars($options['title-archive'], array('post_title' => $title)); } else { if (is_month()) { $title = single_month_title(' ', false) . ' ' . __('Archives'); } else { if (is_year()) { $title = get_query_var('year') . ' ' . __('Archives'); } } } } else { if (is_404()) { if (isset($options['title-404']) && !empty($options['title-404'])) { $title = wpseo_replace_vars($options['title-404'], array('post_title' => $title)); } else { $title = __('Page not found'); } } } } } } } } } } echo "<meta property='og:title' content='" . esc_attr(strip_tags(stripslashes($title))) . "'/>\n"; }
function fbrogmt() { if (is_plugin_active('shopp/Shopp.php')) { if (shopp('catalog', 'is-product')) { $meta[] = __(trim(shopp('product', 'name', 'return=1'))) . ' - ' . shopp('product', 'price', 'return=1'); $meta[] = shopp('product', 'link', 'return=1'); $meta[] = get_option('blogname'); //Site name //get summary, or use description if no summary is set. $description = trim(strip_tags(shopp('product', 'summary', 'return=1'))); $long_description = trim(strip_tags(shopp('product', 'description', 'return=1'))); if ('' == $description) { $description = $long_description; } //truncate description to 300 if (strlen($description) > 300) { $description = substr($description, 0, 297) . '...'; } $meta[] = $description; $meta[] = 'product'; foreach (all_images_shopp() as $img_meta) { // The loop to dish out all the images meta tags explained lower echo $img_meta; } } else { if (is_single()) { // Post if (have_posts()) { while (have_posts()) { the_post(); $meta[] = get_the_title($post->post_title); // Gets the title $meta[] = get_permalink(); // gets the url of the post $meta[] = get_option('blogname'); //Site name $meta[] = the_excerpt_max_charlength(300) . '...'; //Description comes from the excerpt, because by using the_content, it will dish out the [caption id...] $meta[] = 'article'; // $meta[]=get_the_image();//Gets the first image of a post/page if there is one -- Remove this for now foreach (all_images() as $img_meta) { // The loop to dish out all the images meta tags explained lower echo $img_meta; } } } } elseif (is_page()) { // Page if (have_posts()) { while (have_posts()) { the_post(); $meta[] = get_the_title($post->post_title); // Gets the title $meta[] = get_permalink(); // gets the url of the post $meta[] = get_option('blogname'); //Site name $meta[] = the_excerpt_max_charlength(300) . '...'; //Description comes from the excerpt, because by using the_content, it will dish out the [caption id...] $meta[] = 'article'; // $meta[]=get_the_image();//Gets the first image of a post/page if there is one -- Remove this for now foreach (all_images() as $img_meta) { // The loop to dish out all the images meta tags explained lower echo $img_meta; } } } } elseif (is_category()) { global $post, $wp_query; $category_id = get_cat_ID(single_cat_title('', false)); // Get the URL of this category $category_link = get_category_link($category_id); $term = $wp_query->get_queried_object(); if (is_plugin_active('wordpress-seo/wp-seo.php')) { //checks for yoast seo plugin for description of category $metadesc = wpseo_get_term_meta($term, $term->taxonomy, 'desc'); } else { $metadesc = category_description($category_id); } $meta[] = wp_title('', false); //Title $meta[] = $category_link; //URL $meta[] = get_option('blogname'); //Site name $meta[] = $metadesc; //Description $meta[] = 'website'; foreach (all_images() as $img_meta) { // The loop to dish out all the images meta tags explained lower echo $img_meta; } } elseif (is_home() || is_front_page()) { $meta[] = get_option('blogname'); //Title $meta[] = get_option('siteurl'); //URL $meta[] = get_option('blogname'); //Site name $meta[] = get_option('blogdescription'); //Description $meta[] = 'website'; } else { $meta[] = get_option('blogname'); //Title $meta[] = get_option('siteurl'); //URL $meta[] = get_option('blogname'); //Site name $meta[] = get_option('blogdescription'); //Description $meta[] = 'article'; } } } else { if (is_single()) { // Post if (have_posts()) { while (have_posts()) { the_post(); $meta[] = get_the_title($post->post_title); // Gets the title $meta[] = get_permalink(); // gets the url of the post $meta[] = get_option('blogname'); //Site name $meta[] = the_excerpt_max_charlength(300) . '...'; //Description comes from the excerpt, because by using the_content, it will dish out the [caption id...] $meta[] = 'article'; // $meta[]=get_the_image();//Gets the first image of a post/page if there is one -- Remove this for now foreach (all_images() as $img_meta) { // The loop to dish out all the images meta tags explained lower echo $img_meta; } } } } elseif (is_page()) { // Page if (have_posts()) { while (have_posts()) { the_post(); $meta[] = get_the_title($post->post_title); // Gets the title $meta[] = get_permalink(); // gets the url of the post $meta[] = get_option('blogname'); //Site name $meta[] = the_excerpt_max_charlength(300) . '...'; //Description comes from the excerpt, because by using the_content, it will dish out the [caption id...] $meta[] = 'article'; // $meta[]=get_the_image();//Gets the first image of a post/page if there is one -- Remove this for now foreach (all_images() as $img_meta) { // The loop to dish out all the images meta tags explained lower echo $img_meta; } } } } elseif (is_category()) { global $post, $wp_query; $category_id = get_cat_ID(single_cat_title('', false)); // Get the URL of this category $category_link = get_category_link($category_id); $term = $wp_query->get_queried_object(); if (is_plugin_active('wordpress-seo/wp-seo.php')) { //checks for yoast seo plugin for description of category $metadesc = wpseo_get_term_meta($term, $term->taxonomy, 'desc'); } else { $metadesc = category_description($category_id); } $meta[] = wp_title('', false); //Title $meta[] = $category_link; //URL $meta[] = get_option('blogname'); //Site name $meta[] = $metadesc; //Description $meta[] = 'website'; foreach (all_images() as $img_meta) { // The loop to dish out all the images meta tags explained lower echo $img_meta; } } elseif (is_home() || is_front_page()) { $meta[] = get_option('blogname'); //Title $meta[] = get_option('siteurl'); //URL $meta[] = get_option('blogname'); //Site name $meta[] = get_option('blogdescription'); //Description $meta[] = 'website'; } else { $meta[] = get_option('blogname'); //Title $meta[] = get_option('siteurl'); //URL $meta[] = get_option('blogname'); //Site name $meta[] = get_option('blogdescription'); //Description $meta[] = 'article'; } } echo tags($meta); }
/** * Build a sub-sitemap for a specific taxonomy -- example.com/tax-sitemap.xml * * @param string $taxonomy Registered taxonomy's slug */ function build_tax_map($taxonomy) { if (isset($this->options['taxonomies-' . $taxonomy->name . '-not_in_sitemap']) && $this->options['taxonomies-' . $taxonomy->name . '-not_in_sitemap'] || in_array($taxonomy, array('link_category', 'nav_menu', 'post_format')) || apply_filters('wpseo_sitemap_exclude_taxonomy', false, $taxonomy->name)) { $this->bad_sitemap = true; return; } global $wpdb; $output = ''; $steps = $this->max_entries; $n = (int) get_query_var('sitemap_n'); $offset = $n > 1 ? ($n - 1) * $this->max_entries : 0; $total = $offset + $this->max_entries; $terms = get_terms($taxonomy->name, array('hide_empty' => true)); $terms = array_splice($terms, $offset, $steps); foreach ($terms as $c) { $url = array(); if (wpseo_get_term_meta($c, $c->taxonomy, 'noindex') && !in_array(wpseo_get_term_meta($c, $c->taxonomy, 'sitemap_include'), array('always', '-'))) { continue; } if (wpseo_get_term_meta($c, $c->taxonomy, 'sitemap_include') == 'never') { continue; } $url['loc'] = wpseo_get_term_meta($c, $c->taxonomy, 'canonical'); if (!$url['loc']) { $url['loc'] = get_term_link($c, $c->taxonomy); if (isset($this->options['trailingslash']) && $this->options['trailingslash']) { $url['loc'] = trailingslashit($url['loc']); } } if ($c->count > 10) { $url['pri'] = 0.6; } else { if ($c->count > 3) { $url['pri'] = 0.4; } else { $url['pri'] = 0.2; } } // Grab last modified date $sql = $wpdb->prepare("SELECT MAX(p.post_modified_gmt) AS lastmod\n\t\t\t\t\tFROM\t{$wpdb->posts} AS p\n\t\t\t\t\tINNER JOIN {$wpdb->term_relationships} AS term_rel\n\t\t\t\t\tON\t\tterm_rel.object_id = p.ID\n\t\t\t\t\tINNER JOIN {$wpdb->term_taxonomy} AS term_tax\n\t\t\t\t\tON\t\tterm_tax.term_taxonomy_id = term_rel.term_taxonomy_id\n\t\t\t\t\tAND\t\tterm_tax.taxonomy = %s\n\t\t\t\t\tAND\t\tterm_tax.term_id = %d\n\t\t\t\t\tWHERE\tp.post_status IN ('publish','inherit')\n\t\t\t\t\tAND\t\tp.post_password = ''", $c->taxonomy, $c->term_id); $url['mod'] = $wpdb->get_var($sql); $url['chf'] = 'weekly'; $output .= $this->sitemap_url($url); } if (empty($output)) { $this->bad_sitemap = true; return; } $this->sitemap = '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '; $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>'; }
public function _meta_keywords() { $wpseo_front = null; if (isset($GLOBALS['wpseo_front'])) { $wpseo_front = $GLOBALS['wpseo_front']; } elseif (class_exists('WPSEO_Frontend') && method_exists('WPSEO_Frontend', 'get_instance')) { $wpseo_front = WPSEO_Frontend::get_instance(); } $current_action = $this->controller->get_current_action(); switch ($current_action) { case 'showlisting': global $post; $listing_id = get_query_var('listing') ? wpbdp_get_post_by_slug(get_query_var('listing'))->ID : wpbdp_getv($_GET, 'id', get_query_var('id')); $prev_post = $post; $post = get_post($listing_id); if (is_object($wpseo_front)) { $wpseo_front->metadesc(); $wpseo_front->metakeywords(); } $post = $prev_post; break; case 'browsecategory': case 'browsetag': if ($current_action == 'browsetag') { $term = get_term_by('slug', get_query_var('tag'), WPBDP_TAGS_TAX); } else { $term = get_term_by('slug', get_query_var('category'), WPBDP_CATEGORY_TAX); if (!$term && get_query_var('category_id')) { $term = get_term_by('id', get_query_var('category_id'), WPBDP_CATEGORY_TAX); } } if ($term) { $metadesc = method_exists('WPSEO_Taxonomy_Meta', 'get_term_meta') ? WPSEO_Taxonomy_Meta::get_term_meta($term, $term->taxonomy, 'desc') : wpseo_get_term_meta($term, $term->taxonomy, 'desc'); if (!$metadesc && is_object($wpseo_front) && isset($wpseo_front->options['metadesc-tax-' . $term->taxonomy])) { $metadesc = wpseo_replace_vars($wpseo_front->options['metadesc-tax-' . $term->taxonomy], (array) $term); } if ($metadesc) { echo '<meta name="description" content="' . esc_attr(strip_tags(stripslashes($metadesc))) . '"/>' . "\n"; } } break; case 'main': if (is_object($wpseo_front)) { $wpseo_front->metadesc(); $wpseo_front->metakeywords(); } break; default: break; } }
/** * 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'] : '»'; $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 . '>'); }
function breadcrumb($prefix = '', $suffix = '', $display = true) { $options = get_wpseo_options(); global $wp_query, $post, $paged; $opt = get_option("wpseo_internallinks"); $on_front = get_option('show_on_front'); $blog_page = get_option('page_for_posts'); $sep = isset($opt['breadcrumbs-sep']) && $opt['breadcrumbs-sep'] != '' ? $opt['breadcrumbs-sep'] : '»'; $home = isset($opt['breadcrumbs-home']) && $opt['breadcrumbs-home'] != '' ? $opt['breadcrumbs-home'] : __('Home'); $selmenu = isset($opt['breadcrumbs-selectedmenu']) && $opt['breadcrumbs-selectedmenu'] != '' ? $opt['breadcrumbs-selectedmenu'] : 0; if ($on_front == "page" && $post->post_type == 'post') { $homelink = '<a href="' . get_permalink(get_option('page_on_front')) . '">' . $home . '</a>'; $bloglink = $homelink; if ($blog_page && (!isset($opt['breadcrumbs-blog-remove']) || !$opt['breadcrumbs-blog-remove'])) { $bloglink = $homelink . ' ' . $sep . ' <a href="' . get_permalink($blog_page) . '">' . $this->get_bc_title($blog_page) . '</a>'; } } else { $homelink = '<a href="' . get_bloginfo('url') . '">' . $home . '</a>'; $bloglink = $homelink; } if ($on_front == "page" && is_front_page() || $on_front == "posts" && is_home()) { $output = $this->bold_or_not($home); } else { if ($on_front == "page" && is_home()) { $output = $homelink . ' ' . $sep . ' ' . $this->bold_or_not($this->get_bc_title($blog_page)); } else { if (is_singular()) { $output = $bloglink . ' ' . $sep . ' '; if (isset($opt['breadcrumbs-menus']) && ($opt['breadcrumbs-menus'] = 'on')) { $use_menu = $this->in_menu($selmenu); } if (function_exists('bbp_body_class') && count(bbp_body_class(array())) > 1) { remove_filter('bbp_get_breadcrumb', '__return_false'); $output .= bbp_get_breadcrumb(' ' . $sep . ' '); add_filter('bbp_get_breadcrumb', '__return_false'); } else { if (isset($use_menu) && $use_menu) { $trail = $this->get_menu_trail(); $trail = array_reverse($trail); $trailposts = array(); for ($t = 0; $t < count($trail); $t++) { $trailposts[] = $this->get_post_for_menunode($trail[$t]); } for ($t = 0; $t < count($trail); $t++) { $bctitle = get_the_title($trail[$t]) == '' ? get_the_title($trailposts[$t]) : get_the_title($trail[$t]); $output .= '<a href="' . get_permalink($trailposts[$t]) . '">' . $bctitle . '</a> ' . $sep . ' '; } $output .= $this->bold_or_not($this->get_bc_title($post->ID)); } else { $post_type = get_post_type(); if (function_exists('get_post_type_archive_link') && get_post_type_archive_link($post_type)) { if (isset($options['bctitle-ptarchive-' . $post_type]) && '' != $options['bctitle-ptarchive-' . $post_type]) { $archive_title = $options['bctitle-ptarchive-' . $post_type]; } else { $post_type_obj = get_post_type_object($post_type); $archive_title = $post_type_obj->labels->menu_name; } $output .= '<a href="' . get_post_type_archive_link($post_type) . '">' . $archive_title . '</a> ' . $sep . ' '; } if (0 == $post->post_parent) { if (isset($opt['post_types-' . $post->post_type . '-maintax']) && $opt['post_types-' . $post->post_type . '-maintax'] != '0') { $main_tax = $opt['post_types-' . $post->post_type . '-maintax']; $terms = wp_get_object_terms($post->ID, $main_tax); if (is_taxonomy_hierarchical($main_tax) && $terms[0]->parent != 0) { $parents = $this->get_term_parents($terms[0], $main_tax); $parents = array_reverse($parents); foreach ($parents as $parent) { $bctitle = wpseo_get_term_meta($parent, $main_tax, 'bctitle'); if (!$bctitle) { $bctitle = $parent->name; } $output .= '<a href="' . get_term_link($parent, $main_tax) . '">' . $bctitle . '</a> ' . $sep . ' '; } } if (count($terms) > 0) { $bctitle = wpseo_get_term_meta($terms[0], $main_tax, 'bctitle'); if (!$bctitle) { $bctitle = $terms[0]->name; } $output .= '<a href="' . get_term_link($terms[0], $main_tax) . '">' . $bctitle . '</a> ' . $sep . ' '; } } $output .= $this->bold_or_not($this->get_bc_title($post->ID)); } else { if (isset($post->ancestors)) { if (is_array($post->ancestors)) { $ancestors = array_values($post->ancestors); } else { $ancestors = array($post->ancestors); } } else { $ancestors = array($post->post_parent); } // Reverse the order so it's oldest to newest $ancestors = array_reverse($ancestors); foreach ($ancestors as $ancestor) { $output .= '<a href="' . get_permalink($ancestor) . '">' . $this->get_bc_title($ancestor) . '</a> ' . $sep . ' '; } $output .= $this->bold_or_not($this->get_bc_title($post->ID)); } } } } else { if (!is_404()) { $output = $bloglink . ' ' . $sep . ' '; } else { $output = $homelink . ' ' . $sep . ' '; } // echo '<pre>'.print_r($wp_query,1).'</pre>'; if (function_exists('is_post_type_archive') && is_post_type_archive()) { $post_type = get_post_type(); if (isset($options['bctitle-ptarchive-' . $post_type]) && '' != $options['bctitle-ptarchive-' . $post_type]) { $archive_title = $options['bctitle-ptarchive-' . $post_type]; } else { $post_type_obj = get_post_type_object($post_type); $archive_title = $post_type_obj->labels->menu_name; } $output .= $this->bold_or_not($archive_title); } else { if (is_tax() || is_tag() || is_category()) { $term = $wp_query->get_queried_object(); if (isset($options['taxonomy-' . $term->taxonomy . '-ptparent']) && $options['taxonomy-' . $term->taxonomy . '-ptparent'] != '') { $post_type = $options['taxonomy-' . $term->taxonomy . '-ptparent']; if ('post' == $post_type && get_option('show_on_front') == 'page') { $posts_page = get_option('page_for_posts'); if ($posts_page) { $output .= '<a href="' . get_permalink($posts_page) . '">' . $this->get_bc_title($posts_page) . '</a> ' . $sep . ' '; } } else { if (isset($options['bctitle-ptarchive-' . $post_type]) && '' != $options['bctitle-ptarchive-' . $post_type]) { $archive_title = $options['bctitle-ptarchive-' . $post_type]; } else { $post_type_obj = get_post_type_object($post_type); $archive_title = $post_type_obj->labels->menu_name; } $output .= '<a href="' . get_post_type_archive_link($post_type) . '">' . $archive_title . '</a> ' . $sep . ' '; } } if (is_taxonomy_hierarchical($term->taxonomy) && $term->parent != 0) { $parents = $this->get_term_parents($term, $term->taxonomy); $parents = array_reverse($parents); foreach ($parents as $parent) { $bctitle = wpseo_get_term_meta($parent, $term->taxonomy, 'bctitle'); if (!$bctitle) { $bctitle = $parent->name; } $output .= '<a href="' . get_term_link($parent, $term->taxonomy) . '">' . $bctitle . '</a> ' . $sep . ' '; } } $bctitle = wpseo_get_term_meta($term, $term->taxonomy, 'bctitle'); if (!$bctitle) { $bctitle = $term->name; } if ($paged) { $output .= $this->bold_or_not('<a href="' . get_term_link($term, $term->taxonomy) . '">' . $bctitle . '</a>'); } else { $output .= $this->bold_or_not($bctitle); } } else { if (is_date()) { if (isset($opt['breadcrumbs-archiveprefix'])) { $bc = $opt['breadcrumbs-archiveprefix']; } else { $bc = __('Archives for'); } if (is_day()) { global $wp_locale; $output .= '<a href="' . get_month_link(get_query_var('year'), get_query_var('monthnum')) . '">' . $wp_locale->get_month(get_query_var('monthnum')) . ' ' . get_query_var('year') . '</a> ' . $sep . ' '; $output .= $this->bold_or_not($bc . " " . get_the_date()); } else { if (is_month()) { $output .= $this->bold_or_not($bc . " " . single_month_title(' ', false)); } else { if (is_year()) { $output .= $this->bold_or_not($bc . " " . get_query_var('year')); } } } } elseif (is_author()) { if (isset($opt['breadcrumbs-archiveprefix'])) { $bc = $opt['breadcrumbs-archiveprefix']; } else { $bc = __('Archives for'); } $user = $wp_query->get_queried_object(); $output .= $this->bold_or_not($bc . " " . $user->display_name); } elseif (is_search()) { if (isset($opt['breadcrumbs-searchprefix']) && $opt['breadcrumbs-searchprefix'] != '') { $bc = $opt['breadcrumbs-searchprefix']; } else { $bc = __('You searched for'); } $output .= $this->bold_or_not($bc . ' "' . stripslashes(strip_tags(get_search_query())) . '"'); } elseif (isset($wp_query->query_vars['bbp_topic_tag'])) { remove_filter('bbp_get_breadcrumb', '__return_false'); $output .= bbp_get_breadcrumb(' ' . $sep . ' '); add_filter('bbp_get_breadcrumb', '__return_false'); } elseif (is_404()) { if (isset($opt['breadcrumbs-404crumb']) && $opt['breadcrumbs-404crumb'] != '') { $crumb404 = $opt['breadcrumbs-404crumb']; } else { $crumb404 = __('Error 404: Page not found'); } $output .= $this->bold_or_not($crumb404); } } } } } } if (isset($opt['breadcrumbs-prefix']) && $opt['breadcrumbs-prefix'] != "") { $output = $opt['breadcrumbs-prefix'] . " " . $output; } if ($display) { echo $prefix . $output . $suffix; return true; } else { return $prefix . $output . $suffix; } }
/** * 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'] : '»'; $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 . '>'); }
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; }