本文整理汇总了PHP中get_term_field函数的典型用法代码示例。如果您正苦于以下问题:PHP get_term_field函数的具体用法?PHP get_term_field怎么用?PHP get_term_field使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_term_field函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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&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&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');
?>
">↑</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');
?>
">↓</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
示例16: esc_attr_e
</option>
</select>
<input type="submit" value="<?php
esc_attr_e('Apply');
?>
" name="doaction2" id="doaction2" class="button-secondary action" />
</div>
<br class="clear" />
</div>
<br class="clear" />
</form>
<div class="form-wrap">
<p><?php
printf(__('<strong>Note:</strong><br />Deleting a category does not delete the links in that category. Instead, links that were only assigned to the deleted category are set to the category <strong>%s</strong>.'), get_term_field('name', get_option('default_link_category'), 'link_category'));
?>
</p>
</div>
</div>
</div><!-- /col-right -->
<div id="col-left">
<div class="col-wrap">
<?php
if (current_user_can('manage_categories')) {
$category = (object) array();
$category->parent = 0;
开发者ID:jinpingv,项目名称:website_wrapper,代码行数:31,代码来源:edit-link-categories.php
示例17: gantry_assignment_item_menu_meta_box
function gantry_assignment_item_menu_meta_box($object, $menu, $assignments)
{
$menu_name = $menu['args']->name;
$args = array('child_of' => 0, 'exclude' => '', 'hide_empty' => false, 'hierarchical' => 1, 'include' => '', 'include_last_update_time' => false, 'order' => 'ASC', 'orderby' => 'name', 'pad_counts' => false);
$menu_items = wp_get_nav_menu_items($menu_name);
if (!$menu_items || is_wp_error($menu_items)) {
echo '<p>' . _g('No items.') . '</p>';
return;
}
foreach ($menu_items as $menu_item) {
$menu_item->menu_id = $menu_name;
}
$menu_entires = array();
foreach ($menu_items as $menu_item) {
$item = new AssignmentItem();
$item->archetype = $menu['args']->archetype;
$item->type = $menu_name;
$item->id = $menu_item->ID;
$item->single_label = $menu['args']->single_label;
$item->parent_id = empty($menu_item->menu_item_parent) ? get_post_meta($menu_item->ID, '_menu_item_menu_item_parent', true) : $menu_item->menu_item_parent;
// Get the title and url info
$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);
$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);
$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');
$menu_item->title = '' == $menu_item->post_title ? $original_title : $menu_item->post_title;
} else {
$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;
}
$item->title = $menu_item->title;
$menu_entires[] = $item;
}
$walker = new GantryAssignmentWalker();
$args['assignments'] = $assignments;
?>
<div id="menu-<?php
echo $menu_name;
?>
" class="menudiv">
<ul id="<?php
echo $menu_name;
?>
checklist"
class="list:<?php
echo $menu_name;
?>
categorychecklist form-no-clear">
<?php
$args['walker'] = $walker;
echo gantry_walk_assignment_tree($menu_entires, 0, (object) $args);
?>
</ul>
</div><!-- /.menudiv -->
<?php
}
开发者ID:rotoballer,项目名称:emily,代码行数:66,代码来源:assignment_functions.php
示例18: ut_wp_update_nav_menu_item
function ut_wp_update_nav_menu_item($menu_id = 0, $menu_item_db_id = 0, $menu_item_data = array())
{
$menu_id = (int) $menu_id;
$menu_item_db_id = (int) $menu_item_db_id;
// make sure that we don't convert non-nav_menu_item objects into nav_menu_item objects
if (!empty($menu_item_db_id) && !is_nav_menu_item($menu_item_db_id)) {
return new WP_Error('update_nav_menu_item_failed', __('The given object ID is not that of a menu item.', 'unitedthemes'));
}
$menu = wp_get_nav_menu_object($menu_id);
if (!$menu && 0 !== $menu_id || is_wp_error($menu)) {
return $menu;
}
$defaults = array('menu-item-db-id' => $menu_item_db_id, 'menu-item-object-id' => 0, 'menu-item-object' => '', 'menu-item-parent-id' => 0, 'menu-item-position' => 0, 'menu-item-type' => 'custom', 'menu-item-title' => '', 'menu-item-url' => '', 'menu-item-description' => '', 'menu-item-attr-title' => '', 'menu-item-target' => '', 'menu-item-classes' => '', 'menu-item-xfn' => '', 'menu-item-menutype' => '', 'menu-item-status' => '');
$args = wp_parse_args($menu_item_data, $defaults);
if (0 == $menu_id) {
$args['menu-item-position'] = 1;
} elseif (0 == (int) $args['menu-item-position']) {
$menu_items = 0 == $menu_id ? array() : (array) wp_get_nav_menu_items($menu_id, array('post_status' => 'publish,draft'));
$last_item = array_pop($menu_items);
$args['menu-item-position'] = $last_item && isset($last_item->menu_order) ? 1 + $last_item->menu_order : count($menu_items);
}
$original_parent = 0 < $menu_item_db_id ? get_post_field('post_parent', $menu_item_db_id) : 0;
if ('custom' != $args['menu-item-type']) {
/* if non-custom menu item, then:
* use original object's URL
* blank default title to sync with original object's
*/
$args['menu-item-url'] = '';
$original_title = '';
if ('taxonomy' == $args['menu-item-type']) {
$original_parent = get_term_field('parent', $args['menu-item-object-id'], $args['menu-item-object'], 'raw');
$original_title = get_term_field('name', $args['menu-item-object-id'], $args['menu-item-object'], 'raw');
} elseif ('post_type' == $args['menu-item-type']) {
$original_object = get_post($args['menu-item-object-id']);
$original_parent = (int) $original_object->post_parent;
$original_title = $original_object->post_title;
}
if ($args['menu-item-title'] == $original_title) {
$args['menu-item-title'] = '';
}
// hack to get wp to create a post object when too many properties are empty
if ('' == $args['menu-item-title'] && '' == $args['menu-item-description']) {
$args['menu-item-description'] = ' ';
}
}
// Populate the menu item object
$post = array('menu_order' => $args['menu-item-position'], 'ping_status' => 0, 'post_content' => $args['menu-item-description'], 'post_excerpt' => $args['menu-item-attr-title'], 'post_parent' => $original_parent, 'post_title' => $args['menu-item-title'], 'post_type' => 'nav_menu_item');
$update = 0 != $menu_item_db_id;
// Only set the menu term if it isn't set to avoid unnecessary wp_get_object_terms()
if ($menu_id && (!$update || !is_object_in_term($menu_item_db_id, 'nav_menu', (int) $menu->term_id))) {
$post['tax_input'] = array('nav_menu' => array(intval($menu->term_id)));
}
// New menu item. Default is draft status
if (!$update) {
$post['ID'] = 0;
$post['post_status'] = 'publish' == $args['menu-item-status'] ? 'publish' : 'draft';
$menu_item_db_id = wp_insert_post($post);
if (!$menu_item_db_id || is_wp_error($menu_item_db_id)) {
return $menu_item_db_id;
}
}
if ('custom' == $args['menu-item-type']) {
$args['menu-item-object-id'] = $menu_item_db_id;
$args['menu-item-object'] = 'custom';
}
$menu_item_db_id = (int) $menu_item_db_id;
update_post_meta($menu_item_db_id, '_menu_item_type', sanitize_key($args['menu-item-type']));
update_post_meta($menu_item_db_id, '_menu_item_menu_item_parent', strval((int) $args['menu-item-parent-id']));
update_post_meta($menu_item_db_id, '_menu_item_object_id', strval((int) $args['menu-item-object-id']));
update_post_meta($menu_item_db_id, '_menu
|
请发表评论