当前位置: 首页>>代码示例>>PHP>>正文


PHP get_term_field函数代码示例

本文整理汇总了PHP中get_term_field函数的典型用法代码示例。如果您正苦于以下问题:PHP get_term_field函数的具体用法?PHP get_term_field怎么用?PHP get_term_field使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_term_field函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store_seo_info

function store_seo_info()
{
    if (get_post_type() == 'store' && !is_singular()) {
        $id = get_queried_object_id();
        if ((taxonomy_exists('products_category') || taxonomy_exists('products_tag')) && $id != 0) {
            $term_name = get_term_field('name', $id, 'products_category');
            $title = $term_name;
            $paged = get_query_var('paged');
            if ($paged > 1) {
                $title .= sprintf(__(' - 第 %s 页 ', 'tinection'), $paged);
            }
            $title .= ' - ' . get_bloginfo('name') . '商城';
            $keywords = $term_name . ",商城";
            $description = strip_tags(term_description());
        } elseif (is_archive() && $id == 0) {
            $title = ot_get_option('shop_archives_title', 'WordPress商店');
            $paged = get_query_var('paged');
            if ($paged > 1) {
                $title .= sprintf(__(' - 第 %s 页 ', 'tinection'), $paged);
            }
            $title .= ' - ' . get_bloginfo('name');
            $keywords = '商品归档,商城,归档';
            $description = get_bloginfo('name') . '商城';
        }
        $seo_text = '<title>' . $title . '</title><meta name="description" content="' . $description . '" /><meta name="keywords" content="' . $keywords . '" />';
    } else {
        $seo_text = '';
    }
    return $seo_text;
}
开发者ID:xiapistudio,项目名称:tinection-fixed,代码行数:30,代码来源:shop.php

示例2: get_the_term

 public static function get_the_term($taxonomy, $b = '', $a = '', $f = FALSE, $args = array())
 {
     self::__dep();
     global $post;
     if (!self::is_active()) {
         return;
     }
     $args = wp_parse_args($args, array('id' => $post->ID, 'echo' => TRUE, 'def' => '', 'sep' => ', ', 'class' => 'term'));
     $html = '';
     $terms = get_the_terms($args['id'], $taxonomy);
     if ($terms && !is_wp_error($terms)) {
         foreach ($terms as $term) {
             $desc = get_term_field('description', $term->term_id, $term->taxonomy);
             //$desc = is_wp_error( $desc ) ? '' : wpautop( $desc, FALSE );
             $desc = is_wp_error($desc) ? '' : strip_tags($desc);
             $html .= '<a href="' . get_term_link($term, $taxonomy) . '" title="' . esc_attr($desc) . '" class="' . $args['class'] . '" >' . $term->name . '</a>' . $args['sep'];
         }
         if (!empty($html)) {
             if (isset($args['echo']) && $args['echo']) {
                 echo $b . rtrim($html, $args['sep']) . $a;
                 return;
             }
             return $b . rtrim($html, $args['sep']) . $a;
         }
     }
     if (isset($args['def']) && $args['def']) {
         if (isset($args['echo']) && $args['echo']) {
             echo $args['def'];
             return;
         }
         return $args['def'];
     }
 }
开发者ID:geminorum,项目名称:gmember,代码行数:33,代码来源:metacore.class.php

示例3: test_get_term_field_invalid_term_should_return_WP_Error

 /**
  * @ticket 34245
  */
 public function test_get_term_field_invalid_term_should_return_WP_Error()
 {
     $found = get_term_field('taxonomy', 0, $this->taxonomy);
     $this->assertWPError($found);
     $this->assertSame('invalid_term', $found->get_error_code());
     $_found = get_term_field('taxonomy', 0);
     $this->assertWPError($_found);
     $this->assertSame('invalid_term', $_found->get_error_code());
 }
开发者ID:rclilly,项目名称:wordpress-develop,代码行数:12,代码来源:getTermField.php

示例4: start_el

 /**
 * @see Walker::start_el()
 * @since 3.0.0
 *
 * @param string $output Passed by reference. Used to append additional content.
 * @param object $item Menu item data object.
 * @param int $depth Depth of menu item. Used for padding.
 * @param object $args
 */
 function start_el(&$output, $object, $depth = 0, $args = array(), $current_object_id = 0)
 {
     global $_wp_nav_menu_max_depth;
     $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
     $item = $object;
     $indent = $depth ? str_repeat("\t", $depth) : '';
     ob_start();
     //        $item_id = esc_attr( $item->ID );
     $removed_args = array('action', 'customlink-tab', 'edit-menu-item', 'menu-item', 'page-tab', '_wpnonce');
     $original_title = '';
     if ('taxonomy' == $item->type) {
         $original_title = get_term_field('name', $item->object_id, $item->object, 'raw');
         if (is_wp_error($original_title)) {
             $original_title = false;
         }
     } elseif ('post_type' == $item->type) {
         $original_object = get_post($item->object_id);
         $original_title = $original_object->post_title;
     }
     $item_id = esc_attr($item->ID);
     $classes = array('menu-item menu-item-depth-' . $depth, 'menu-item-' . esc_attr($item->object), 'menu-item-edit-' . (isset($_GET['edit-menu-item']) && $item_id == $_GET['edit-menu-item'] ? 'active' : 'inactive'));
     $title = $item->title;
     if (!empty($item->_invalid)) {
         $classes[] = 'menu-item-invalid';
         /* translators: %s: title of menu item which is invalid */
         $title = sprintf(__('%s (Invalid)'), $item->title);
     } elseif (isset($item->post_status) && 'draft' == $item->post_status) {
         $classes[] = 'pending';
         /* translators: %s: title of menu item in draft status */
         $title = sprintf(__('%s (Pending)'), $item->title);
     }
     $title = !isset($item->label) || '' == $item->label ? $title : $item->label;
     $submenu_text = '';
     if (0 == $depth) {
         $submenu_text = 'style="display: none;"';
     }
     $megamenu_title = $item->megamenuActive == "active" ? '<span class="is-submenu">mega menu</span>' : '';
     switch ($item->url) {
         case '#MegaMenuColumn':
             $item->type_label = 'Column';
             $this->doColumnTemplate($output, $item, $depth, $args, $item_id, $classes, $title, $megamenu_title, $submenu_text, $removed_args, $original_title);
             break;
         case '#MegaMenuHeading':
             $item->type_label = 'Heading';
             $this->doHeadingTemplate($output, $item, $depth, $args, $item_id, $classes, $title, $megamenu_title, $submenu_text, $removed_args, $original_title);
             break;
         case '#MegaMenuContent':
             $item->type_label = 'Content';
             $this->doContentTemplate($output, $item, $depth, $args, $item_id, $classes, $title, $megamenu_title, $submenu_text, $removed_args, $original_title);
             break;
         default:
             $this->doDefaultTemplate($output, $item, $depth, $args, $item_id, $classes, $title, $megamenu_title, $submenu_text, $removed_args, $original_title);
             break;
     }
     $output .= ob_get_clean();
 }
开发者ID:ravenvn,项目名称:sandau,代码行数:65,代码来源:class-tfingi-megamenu-walker.php

示例5: socially_awkward_nav_menu_css_class

/**
 * Adds custom nav menu item classes.
 *
 * @since  0.1.0
 * @access public
 * @param  array   $classes
 * @param  object  $item
 * @param  object  $args
 */
function socially_awkward_nav_menu_css_class($classes, $item, $args)
{
    if ('formats' === $args->theme_location && 'taxonomy' === $item->type && 'post_format' === $item->object) {
        $classes[] = 'menu-item-' . hybrid_clean_post_format_slug(get_term_field('slug', $item->object_id, $item->object, 'attribute'));
    }
    if ('post_type' === $item->type && 'page' === $item->object && $item->object_id == get_option('page_for_posts')) {
        $classes[] = 'menu-item-blog';
    }
    return $classes;
}
开发者ID:Jessphung,项目名称:Phungtastic,代码行数:19,代码来源:socially-awkward.php

示例6: wds_replace_vars

function wds_replace_vars($string, $args)
{
    global $wp_query;
    $defaults = array('ID' => '', 'name' => '', 'post_author' => '', 'post_content' => '', 'post_date' => '', 'post_excerpt' => '', 'post_modified' => '', 'post_title' => '', 'taxonomy' => '', 'description' => '', 'username' => '', 'full_name' => '');
    $pagenum = get_query_var('paged');
    if ($pagenum === 0) {
        $pagenum = $wp_query->max_num_pages > 1 ? 1 : '';
    }
    $r = wp_parse_args($args, $defaults);
    $replacements = array('%%date%%' => $r['post_date'], '%%title%%' => stripslashes($r['post_title']), '%%sitename%%' => get_bloginfo('name'), '%%sitedesc%%' => get_bloginfo('description'), '%%excerpt%%' => wds_get_trimmed_excerpt($r['post_excerpt'], $r['post_content']), '%%excerpt_only%%' => $r['post_excerpt'], '%%category%%' => get_the_category_list('', '', $r['ID']) != '' ? get_the_category_list('', '', $r['ID']) : $r['name'], '%%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'], '%%tag%%' => $r['name'], '%%modified%%' => $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')), '%%currenttime%%' => date('H:i'), '%%currentdate%%' => date('M jS Y'), '%%currentmonth%%' => date('F'), '%%currentyear%%' => date('Y'), '%%page%%' => get_query_var('paged') != 0 ? 'Page ' . get_query_var('paged') . ' of ' . $wp_query->max_num_pages : '', '%%spell_page%%' => get_query_var('paged') != 0 ? 'Page ' . wds_spell_number(get_query_var('paged')) . ' of ' . wds_spell_number($wp_query->max_num_pages) : '', '%%pagetotal%%' => $wp_query->max_num_pages > 1 ? $wp_query->max_num_pages : '', '%%spell_pagetotal%%' => $wp_query->max_num_pages > 1 ? wds_spell_number($wp_query->max_num_pages) : '', '%%pagenumber%%' => $pagenum, '%%spell_pagenumber%%' => wds_spell_number($pagenum), '%%caption%%' => $r['post_excerpt'], '%%bp_group_name%%' => $r['name'], '%%bp_group_description%%' => wds_get_trimmed_excerpt('', $r['description']), '%%bp_user_username%%' => $r['username'], '%%bp_user_full_name%%' => $r['full_name']);
    foreach ($replacements as $var => $repl) {
        $repl = apply_filters('wds-macro-variable_replacement', $repl, $var);
        $string = str_replace($var, $repl, $string);
    }
    return $string;
}
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:16,代码来源:wds-core.php

示例7: munsa_lite_archive_description_filter

/**
 * Filters `get_the_archve_description` to add better archive descriptions than core.
 *
 * @since  1.0.0
 *
 * @param  string  $desc
 * @return string
 */
function munsa_lite_archive_description_filter($desc)
{
    if (is_home() && !is_front_page()) {
        $desc = get_post_field('post_content', get_queried_object_id(), 'raw');
    } elseif (is_category()) {
        $desc = get_term_field('description', get_queried_object_id(), 'category', 'raw');
    } elseif (is_tag()) {
        $desc = get_term_field('description', get_queried_object_id(), 'post_tag', 'raw');
    } elseif (is_tax()) {
        $desc = get_term_field('description', get_queried_object_id(), get_query_var('taxonomy'), 'raw');
    } elseif (is_author()) {
        $desc = get_the_author_meta('description', get_query_var('author'));
    } elseif (is_post_type_archive()) {
        $desc = get_post_type_object(get_query_var('post_type'))->description;
    }
    return apply_filters('munsa_lite_archive_description', $desc);
}
开发者ID:samikeijonen,项目名称:munsa-lite,代码行数:25,代码来源:archive-filters.php

示例8: link_cat_row

function link_cat_row($category)
{
    global $class;
    if (current_user_can('manage_categories')) {
        $edit = "<a href='link-category.php?action=edit&amp;cat_ID={$category->term_id}' class='edit'>" . __('Edit') . "</a></td>";
        $default_cat_id = (int) get_option('default_link_category');
        if ($category->term_id != $default_cat_id) {
            $edit .= "<td><a href='" . wp_nonce_url("link-category.php?action=delete&amp;cat_ID={$category->term_id}", 'delete-link-category_' . $category->term_id) . "' onclick=\"return deleteSomething( 'cat', {$category->term_id}, '" . js_escape(sprintf(__("You are about to delete the category '%s'.\nAll links that were only assigned to this category will be assigned to the '%s' category.\n'OK' to delete, 'Cancel' to stop."), $category->name, get_term_field('name', $default_cat_id, 'link_category'))) . "' );\" class='delete'>" . __('Delete') . "</a>";
        } else {
            $edit .= "<td style='text-align:center'>" . __("Default");
        }
    } else {
        $edit = '';
    }
    $class = defined('DOING_AJAX') && DOING_AJAX || " class='alternate'" == $class ? '' : " class='alternate'";
    $category->count = number_format_i18n($category->count);
    $count = $category->count > 0 ? "<a href='link-manager.php?cat_id={$category->term_id}'>{$category->count}</a>" : $category->count;
    return "<tr id='cat-{$category->term_id}'{$class}>\n\t\t<th scope='row' style='text-align: center'>{$category->term_id}</th>\n\t\t<td>" . ($name_override ? $name_override : $pad . ' ' . $category->name) . "</td>\n\t\t<td>{$category->description}</td>\n\t\t<td align='center'>{$count}</td>\n\t\t<td>{$edit}</td>\n\t</tr>\n";
}
开发者ID:helmonaut,项目名称:owb-mirror,代码行数:19,代码来源:edit-link-categories.php

示例9: term_description

/**
 * Retrieve term description.
 *
 * @since 2.8.0
 *
 * @param int $term Optional. Term ID. Will use global term ID by default.
 * @param string $taxonomy Optional taxonomy name. Defaults to 'post_tag'.
 * @return string Term description, available.
 */
function term_description($term = 0, $taxonomy = 'post_tag')
{
    if (!$term && (is_tax() || is_tag() || is_category())) {
        $term = get_queried_object();
        if ($term) {
            $taxonomy = $term->taxonomy;
            $term = $term->term_id;
        }
    }
    $description = get_term_field('description', $term, $taxonomy);
    return is_wp_error($description) ? '' : $description;
}
开发者ID:CompositeUK,项目名称:clone.WordPress-Core,代码行数:21,代码来源:category-template.php

示例10: woo_shortcode_post_categories

 function woo_shortcode_post_categories($atts)
 {
     $defaults = array('sep' => ', ', 'before' => '', 'after' => '', 'taxonomy' => 'category');
     $atts = shortcode_atts($defaults, $atts);
     $atts = array_map('wp_kses_post', $atts);
     $terms = get_the_terms(get_the_ID(), esc_html($atts['taxonomy']));
     $cats = '';
     if (is_array($terms) && 0 < count($terms)) {
         $links_array = array();
         foreach ($terms as $k => $v) {
             $term_name = get_term_field('name', $v->term_id, $atts['taxonomy']);
             $links_array[] = '<a href="' . esc_url(get_term_link($v, $atts['taxonomy'])) . '" title="' . esc_attr(sprintf(__('View all items in %s', 'woothemes'), $term_name)) . '">' . esc_html($term_name) . '</a>';
         }
         $cats = join($atts['sep'], $links_array);
     }
     $output = sprintf('<span class="categories">%2$s%1$s%3$s</span> ', $cats, $atts['before'], $atts['after']);
     return apply_filters('woo_shortcode_post_categories', $output, $atts);
 }
开发者ID:plusplusminus,项目名称:athol,代码行数:18,代码来源:theme-shortcodes.php

示例11: start_el

    /**
     * @see Walker::start_el()
     * @since 3.0.0
     *
     * @param string $output Passed by reference. Used to append additional content.
     * @param object $item Menu item data object.
     * @param int $depth Depth of menu item. Used for padding.
     * @param object $args
     */
    function start_el(&$output, $item, $depth, $args)
    {
        global $_wp_nav_menu_max_depth;
        $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
        $indent = $depth ? str_repeat("\t", $depth) : '';
        ob_start();
        $item_id = esc_attr($item->ID);
        $removed_args = array('action', 'customlink-tab', 'edit-menu-item', 'menu-item', 'page-tab', '_wpnonce');
        $original_title = '';
        if ('taxonomy' == $item->type) {
            $original_title = get_term_field('name', $item->object_id, $item->object, 'raw');
            if (is_wp_error($original_title)) {
                $original_title = false;
            }
        } elseif ('post_type' == $item->type) {
            $original_object = get_post($item->object_id);
            $original_title = $original_object->post_title;
        }
        $classes = array('menu-item menu-item-depth-' . $depth, 'menu-item-' . esc_attr($item->object), 'menu-item-edit-' . (isset($_GET['edit-menu-item']) && $item_id == $_GET['edit-menu-item'] ? 'active' : 'inactive'));
        $title = $item->title;
        if (!empty($item->_invalid)) {
            $classes[] = 'menu-item-invalid';
            /* translators: %s: title of menu item which is invalid */
            $title = sprintf(__('%s (Invalid)'), $item->title);
        } elseif (isset($item->post_status) && 'draft' == $item->post_status) {
            $classes[] = 'pending';
            /* translators: %s: title of menu item in draft status */
            $title = sprintf(__('%s (Pending)'), $item->title);
        }
        $title = empty($item->label) ? $title : $item->label;
        ?>
		<li id="menu-item-<?php 
        echo $item_id;
        ?>
" class="<?php 
        echo implode(' ', $classes);
        ?>
">
			<dl class="menu-item-bar">
				<dt class="menu-item-handle">
					<span class="item-title"><?php 
        echo esc_html($title);
        ?>
</span>
					<span class="item-controls">
						<span class="item-type"><?php 
        echo esc_html($item->type_label);
        ?>
</span>
						<span class="item-order">
							<a href="<?php 
        echo wp_nonce_url(add_query_arg(array('action' => 'move-up-menu-item', 'menu-item' => $item_id), remove_query_arg($removed_args, admin_url('nav-menus.php'))), 'move-menu_item');
        ?>
" class="item-move-up"><abbr title="<?php 
        esc_attr_e('Move up');
        ?>
">&#8593;</abbr></a>
							|
							<a href="<?php 
        echo wp_nonce_url(add_query_arg(array('action' => 'move-down-menu-item', 'menu-item' => $item_id), remove_query_arg($removed_args, admin_url('nav-menus.php'))), 'move-menu_item');
        ?>
" class="item-move-down"><abbr title="<?php 
        esc_attr_e('Move down');
        ?>
">&#8595;</abbr></a>
						</span>
						<a class="item-edit" id="edit-<?php 
        echo $item_id;
        ?>
" title="<?php 
        _e('Edit Menu Item');
        ?>
" href="<?php 
        echo isset($_GET['edit-menu-item']) && $item_id == $_GET['edit-menu-item'] ? admin_url('nav-menus.php') : add_query_arg('edit-menu-item', $item_id, remove_query_arg($removed_args, admin_url('nav-menus.php#menu-item-settings-' . $item_id)));
        ?>
"><?php 
        _e('Edit Menu Item');
        ?>
</a>
					</span>
				</dt>
			</dl>

			<div class="menu-item-settings" id="menu-item-settings-<?php 
        echo $item_id;
        ?>
">
				<?php 
        if ('custom' == $item->type) {
            ?>
					<p class="field-url description description-wide">
//.........这里部分代码省略.........
开发者ID:vpatrinica,项目名称:jfdesign,代码行数:101,代码来源:nav-menu.php

示例12: wp_setup_nav_menu_item

/**
 * Decorates a menu item object with the shared navigation menu item properties.
 *
 * Properties:
 * - db_id: 		The DB ID of this item as a nav_menu_item object, if it exists (0 if it doesn't exist).
 * - object_id:		The DB ID of the original object this menu item represents, e.g. ID for posts and term_id for categories.
 * - type:		The family of objects originally represented, such as "post_type" or "taxonomy."
 * - object:		The type of object originally represented, such as "category," "post", or "attachment."
 * - type_label:	The singular label used to describe this type of menu item.
 * - post_parent:	The DB ID of the original object's parent object, if any (0 otherwise).
 * - menu_item_parent: 	The DB ID of the nav_menu_item that is this item's menu parent, if any. 0 otherwise.
 * - url:		The URL to which this menu item points.
 * - title:		The title of this menu item.
 * - target: 		The target attribute of the link element for this menu item.
 * - attr_title:	The title attribute of the link element for this menu item.
 * - classes:		The array of class attribute values for the link element of this menu item.
 * - xfn:		The XFN relationship expressed in the link of this menu item.
 * - description:	The description of this menu item.
 *
 * @since 3.0.0
 *
 * @param object $menu_item The menu item to modify.
 * @return object $menu_item The menu item with standard menu item properties.
 */
function wp_setup_nav_menu_item($menu_item)
{
    if (isset($menu_item->post_type)) {
        if ('nav_menu_item' == $menu_item->post_type) {
            $menu_item->db_id = (int) $menu_item->ID;
            $menu_item->menu_item_parent = empty($menu_item->menu_item_parent) ? get_post_meta($menu_item->ID, '_menu_item_menu_item_parent', true) : $menu_item->menu_item_parent;
            $menu_item->object_id = empty($menu_item->object_id) ? get_post_meta($menu_item->ID, '_menu_item_object_id', true) : $menu_item->object_id;
            $menu_item->object = empty($menu_item->object) ? get_post_meta($menu_item->ID, '_menu_item_object', true) : $menu_item->object;
            $menu_item->type = empty($menu_item->type) ? get_post_meta($menu_item->ID, '_menu_item_type', true) : $menu_item->type;
            if ('post_type' == $menu_item->type) {
                $object = get_post_type_object($menu_item->object);
                if ($object) {
                    $menu_item->type_label = $object->labels->singular_name;
                } else {
                    $menu_item->type_label = $menu_item->object;
                    $menu_item->_invalid = true;
                }
                $menu_item->url = get_permalink($menu_item->object_id);
                $original_object = get_post($menu_item->object_id);
                $original_title = $original_object->post_title;
                $menu_item->title = '' == $menu_item->post_title ? $original_title : $menu_item->post_title;
            } elseif ('taxonomy' == $menu_item->type) {
                $object = get_taxonomy($menu_item->object);
                if ($object) {
                    $menu_item->type_label = $object->labels->singular_name;
                } else {
                    $menu_item->type_label = $menu_item->object;
                    $menu_item->_invalid = true;
                }
                $term_url = get_term_link((int) $menu_item->object_id, $menu_item->object);
                $menu_item->url = !is_wp_error($term_url) ? $term_url : '';
                $original_title = get_term_field('name', $menu_item->object_id, $menu_item->object, 'raw');
                if (is_wp_error($original_title)) {
                    $original_title = false;
                }
                $menu_item->title = '' == $menu_item->post_title ? $original_title : $menu_item->post_title;
            } else {
                $menu_item->type_label = __('Custom');
                $menu_item->title = $menu_item->post_title;
                $menu_item->url = empty($menu_item->url) ? get_post_meta($menu_item->ID, '_menu_item_url', true) : $menu_item->url;
            }
            $menu_item->target = empty($menu_item->target) ? get_post_meta($menu_item->ID, '_menu_item_target', true) : $menu_item->target;
            $menu_item->attr_title = empty($menu_item->attr_title) ? apply_filters('nav_menu_attr_title', $menu_item->post_excerpt) : $menu_item->attr_title;
            if (empty($menu_item->description)) {
                $menu_item->description = apply_filters('nav_menu_description', wp_trim_words($menu_item->post_content, 200));
            }
            $menu_item->classes = empty($menu_item->classes) ? (array) get_post_meta($menu_item->ID, '_menu_item_classes', true) : $menu_item->classes;
            $menu_item->xfn = empty($menu_item->xfn) ? get_post_meta($menu_item->ID, '_menu_item_xfn', true) : $menu_item->xfn;
        } else {
            $menu_item->db_id = 0;
            $menu_item->menu_item_parent = 0;
            $menu_item->object_id = (int) $menu_item->ID;
            $menu_item->type = 'post_type';
            $object = get_post_type_object($menu_item->post_type);
            $menu_item->object = $object->name;
            $menu_item->type_label = $object->labels->singular_name;
            $menu_item->title = $menu_item->post_title;
            $menu_item->url = get_permalink($menu_item->ID);
            $menu_item->target = '';
            $menu_item->attr_title = apply_filters('nav_menu_attr_title', '');
            $menu_item->description = apply_filters('nav_menu_description', '');
            $menu_item->classes = array();
            $menu_item->xfn = '';
        }
    } elseif (isset($menu_item->taxonomy)) {
        $menu_item->ID = $menu_item->term_id;
        $menu_item->db_id = 0;
        $menu_item->menu_item_parent = 0;
        $menu_item->object_id = (int) $menu_item->term_id;
        $menu_item->post_parent = (int) $menu_item->parent;
        $menu_item->type = 'taxonomy';
        $object = get_taxonomy($menu_item->taxonomy);
        $menu_item->object = $object->name;
        $menu_item->type_label = $object->labels->singular_name;
        $menu_item->title = $menu_item->name;
        $menu_item->url = get_term_link($menu_item, $menu_item->taxonomy);
//.........这里部分代码省略.........
开发者ID:jcsilkey,项目名称:CodeReviewSecurityRepo,代码行数:101,代码来源:nav-menu.php

示例13: test_get_term_field_parent

 public function test_get_term_field_parent()
 {
     $parent = self::factory()->term->create_and_get(array('taxonomy' => $this->taxonomy));
     $term = self::factory()->term->create_and_get(array('taxonomy' => $this->taxonomy, 'parent' => $parent->term_id));
     $this->assertSame($parent->term_id, get_term_field('parent', $term));
     $this->assertSame($parent->term_id, get_term_field('parent', $term->data));
     $this->assertSame($parent->term_id, get_term_field('parent', $term->term_id));
 }
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:8,代码来源:getTermField.php

示例14: get_term_field

 /**
  * @since 2.2.1
  */
 protected function get_term_field($field, $term_id, $taxonomy)
 {
     $term_field = get_term_field($field, $term_id, $taxonomy, 'display');
     if (is_wp_error($term_field)) {
         return false;
     }
     return $term_field;
 }
开发者ID:Clear-Space,项目名称:meritq,代码行数:11,代码来源:column.php

示例15: wpseo_replace_vars


//.........这里部分代码省略.........
		}
	}

	$replacements = array(
		'%%date%%'         => $date,
		'%%searchphrase%%' => esc_html( get_query_var( 's' ) ),
		'%%page%%'         => ( $max_num_pages > 1 && $pagenum > 1 ) ? sprintf( $sep . ' ' . __( 'Page %d of %d', 'wordpress-seo' ), $pagenum, $max_num_pages ) : '',
		'%%pagetotal%%'    => $max_num_pages,
		'%%pagenumber%%'   => $pagenum,
		'%%term404%%'	   => sanitize_text_field( str_replace( '-', ' ', $r->term404 ) ),
	);

	if ( isset( $r->ID ) ) {
		$replacements = array_merge(
			$replacements, array(
				'%%caption%%'      => $r->post_excerpt,
				'%%category%%'     => wpseo_get_terms( $r->ID, 'category' ),
				'%%excerpt%%'      => ( ! empty( $r->post_excerpt ) ) ? strip_tags( $r->post_excerpt ) : wp_html_excerpt( strip_shortcodes( $r->post_content ),155 ),
				'%%excerpt_only%%' => strip_tags( $r->post_excerpt ),
				'%%focuskw%%'      => WPSEO_Meta::get_value( 'focuskw', $r->ID ),
				'%%id%%'           => $r->ID,
				'%%modified%%'     => mysql2date( get_option( 'date_format' ), $r->post_modified ),
				'%%name%%'         => get_the_author_meta( 'display_name', ! empty( $r->post_author ) ? $r->post_author : get_query_var( 'author' ) ),
				'%%tag%%'          => wpseo_get_terms( $r->ID, 'post_tag' ),
				'%%title%%'        => stripslashes( $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,
			)
		);
	}

	/**
	* Filter: 'wpseo_replacements' - Allow customization of the replacements before they are applied
	*
	* @api array $replacements The replacements
	*/
	$replacements = apply_filters( 'wpseo_replacements', $replacements );

	foreach ( $replacements as $var => $repl ) {
		if ( ! in_array( $var, $omit ) ) {
			$string = str_replace( $var, $repl, $string );
		}
	}

	if ( strpos( $string, '%%' ) === false ) {
		$string = preg_replace( '`\s+`u', ' ', $string );
		return trim( $string );
	}

	if ( isset( $wp_query->query_vars['post_type'] ) && preg_match_all( '`%%pt_([^%]+)%%`u', $string, $matches, PREG_SET_ORDER ) ) {
		$post_type = $wp_query->query_vars['post_type'];

		if ( is_array( $post_type ) ) {
			$post_type = reset( $post_type );
		}
开发者ID:xiaoguizhidao,项目名称:autotech_design,代码行数:66,代码来源:wpseo-functions.php


注:本文中的get_term_field函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。