本文整理汇总了PHP中wpseo_get_term_meta函数的典型用法代码示例。如果您正苦于以下问题:PHP wpseo_get_term_meta函数的具体用法?PHP wpseo_get_term_meta怎么用?PHP wpseo_get_term_meta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpseo_get_term_meta函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: build_tax_map
/**
* 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>';
}
开发者ID:robjcordes,项目名称:nexnewwp,代码行数:54,代码来源:class-sitemaps.php
示例2: metadesc
/**
* 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;
}
}
开发者ID:robjcordes,项目名称:nexnewwp,代码行数:82,代码来源:class-frontend.php
示例3: title
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'])) {
//.........这里部分代码省略.........
开发者ID:Joshuwar,项目名称:Masterson,代码行数:101,代码来源:class-opengraph.php
示例4: fbrogmt
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');
//.........这里部分代码省略.........
开发者ID:fwelections,项目名称:fwelections,代码行数:101,代码来源:index.php
示例5: build_tax_map
/**
* 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>';
}
开发者ID:jeetututeja,项目名称:Ingenia,代码行数:58,代码来源:class-sitemaps.php
示例6: _meta_keywords
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;
}
}
开发者ID:Nedick,项目名称:stzagora-website,代码行数:51,代码来源:business-directory-plugin.php
示例7: create_breadcrumbs_string
/**
* 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 . '>');
}
开发者ID:batruji,项目名称:metareading,代码行数:77,代码来源:class-breadcrumbs.php
示例8: breadcrumb
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));
}
//.........这里部分代码省略.........
开发者ID:kitfrench,项目名称:Futurestep,代码行数:101,代码来源:class-breadcrumbs.php
示例9: create_breadcrumbs_string
/**
* 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 . '>');
}
开发者ID:jimlongo56,项目名称:bhouse,代码行数:87,代码来源:class-breadcrumbs.php
示例10: getTitle
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;
}
开发者ID:cmoncy,项目名称:WordpressBundle,代码行数:48,代码来源:WordpressLoader.php
注:本文中的wpseo_get_term_meta函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论