本文整理汇总了PHP中is_object_in_term函数的典型用法代码示例。如果您正苦于以下问题:PHP is_object_in_term函数的具体用法?PHP is_object_in_term怎么用?PHP is_object_in_term使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_object_in_term函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: jp_disable_wish_list
function jp_disable_wish_list()
{
// replace category-goes-here below with your category slug
if (is_singular('download') && is_object_in_term(get_the_ID(), 'download_category', 'category-slug-goes-here')) {
remove_action('edd_purchase_link_top', 'edd_wl_load_wish_list_link');
}
}
开发者ID:mintplugins,项目名称:library,代码行数:7,代码来源:disable-wish-lists-by-category.php
示例2: my_custom_filters
function my_custom_filters($continue, $args)
{
if (is_object_in_term($args['info']['id'], 'category', array('wordpress', 'plugins')) && $args['info']['authId'] == 2) {
$continue = false;
}
return $continue;
}
开发者ID:joedolson,项目名称:plugin-extensions,代码行数:7,代码来源:filter-by-author-and-category.php
示例3: appthemes_get_custom_taxonomy
function appthemes_get_custom_taxonomy($post_id, $tax_name, $tax_arg)
{
$tax_array = get_terms($tax_name, array('hide_empty' => '0'));
if ($tax_array && sizeof($tax_array) > 0) {
if (is_object_in_term($post_id, $tax_name)) {
foreach ($tax_array as $tax_val) {
if (is_object_in_term($post_id, $tax_name, array($tax_val->term_id))) {
switch ($tax_arg) {
case 'slug':
$link = get_term_link($tax_val, $tax_name);
if (is_wp_error($link)) {
return $link;
}
return $link;
break;
case 'slug_name':
return $tax_val->slug;
break;
case 'name':
return $tax_val->name;
break;
case 'term_id':
return $tax_val->term_id;
break;
default:
return;
break;
}
// end switch
}
}
}
}
}
开发者ID:joaosigno,项目名称:dazake-job,代码行数:34,代码来源:appthemes-functions.php
示例4: remove_main_account_by_category
function remove_main_account_by_category($authors, $post_info)
{
$categories = array('wordpress', 'plugins');
if (is_object_in_term($post_info['id'], 'category', $categories)) {
unset($authors['main']);
}
return $authors;
}
开发者ID:joedolson,项目名称:plugin-extensions,代码行数:8,代码来源:remove-author-by-category.php
示例5: woocommerce_dynamic_pricing_is_applied_to
function woocommerce_dynamic_pricing_is_applied_to($process_discounts, $_product, $module_id, $obj, $cat_id)
{
if ($cat_id && isset($obj->available_rulesets) && count($obj->available_rulesets) > 0) {
global $sitepress;
$cat_id = apply_filters('translate_object_id', $cat_id, 'product_cat', true, $sitepress->get_current_language());
$process_discounts = is_object_in_term($_product->id, 'product_cat', $cat_id);
}
return $process_discounts;
}
开发者ID:mahirziyaokan,项目名称:woocommerce-multilingual,代码行数:9,代码来源:wc_dynamic_pricing.class.php
示例6: test_should_not_return_true_if_term_name_begins_with_existing_term_id
/**
* @ticket 29467
*/
public function test_should_not_return_true_if_term_name_begins_with_existing_term_id()
{
register_taxonomy('wptests_tax', 'post');
$t = $this->factory->term->create(array('taxonomy' => 'wptests_tax'));
$post_ID = $this->factory->post->create();
wp_set_object_terms($post_ID, $t, 'wptests_tax');
$int_tax_name = $t . '_term_name';
$this->assertFalse(is_object_in_term($post_ID, 'wptests_tax', $int_tax_name));
// Verify it works properly when the post is actually in the term.
wp_set_object_terms($post_ID, array($int_tax_name), 'wptests_tax');
$this->assertTrue(is_object_in_term($post_ID, 'wptests_tax', $int_tax_name));
}
开发者ID:Benrajalu,项目名称:philRaj,代码行数:15,代码来源:isObjectInTerm.php
示例7: has_mediatag
function has_mediatag($tag = '', $_post = null)
{
if ($_post) {
$_post = get_post($_post);
} else {
$_post =& $GLOBALS['post'];
}
if (!$_post) {
return false;
}
$r = is_object_in_term($_post->ID, MEDIA_TAGS_TAXONOMY, $tag);
if (is_wp_error($r)) {
return false;
}
return $r;
}
开发者ID:vsalx,项目名称:rattieinfo,代码行数:16,代码来源:mediatags_template_functions.php
示例8: send_to_user_account_by_category
function send_to_user_account_by_category($authors, $post_info)
{
/*
* Define an array with the slugs of all categories you want sent to this set of authors
* You can repeat this pattern to send different categories to different authors
*/
$categories = array('wordpress', 'plugins');
if (is_object_in_term($post_info['id'], 'category', $categories)) {
/* Define array of author IDs that this set of categories are sent to */
$authors = array(5);
}
$categories = array('drupal', 'core');
if (is_object_in_term($post_info['id'], 'category', $categories)) {
/* Define array of author IDs that this set of categories are sent to */
$authors = array(4);
}
return $authors;
}
开发者ID:joedolson,项目名称:plugin-extensions,代码行数:18,代码来源:filter-to-author-by-category.php
示例9: cftl_find_override_page
function cftl_find_override_page(&$query_obj)
{
$override_query = array('post_type' => 'cftl-tax-landing', 'post_status' => 'publish', 'numberposts' => 1, 'tax_query' => $query_obj->tax_query->queries);
if (is_array($override_query['tax_query'])) {
foreach (array_keys($override_query['tax_query']) as $key) {
if (is_array($override_query['tax_query'][$key])) {
$override_query['tax_query'][$key]['include_children'] = false;
}
}
}
$landings = get_posts($override_query);
if (!is_array($landings) || empty($landings)) {
return false;
}
foreach ($query_obj->tax_query->queries as $tax_query) {
if (is_object_in_term($landings[0]->ID, $tax_query['taxonomy'], $tax_query['terms'])) {
return $landings[0];
}
}
return false;
}
开发者ID:netconstructor,项目名称:wp-taxonomy-landing,代码行数:21,代码来源:cftl-intercept-queries.php
示例10: has_term
/**
* Returns whether or not the given term(s) are associated with the post. If no terms are provided
* then whether or not the post has any terms within the taxonomy
* @param string $taxonomy Single taxonomy name
* @param int|string|array $term Optional. Term term_id, name, slug or array of said. Default null.
* @return boolean
*/
public function has_term($taxonomy, $term = null)
{
$result = is_object_in_term($this->id, $taxonomy, $term);
return $result && !is_wp_error($result);
}
开发者ID:JasonTheAdams,项目名称:WP-Controllers,代码行数:12,代码来源:Post.php
示例11: is_applied_to_product
public function is_applied_to_product($_product, $cat_id = false)
{
if (is_admin() && !is_ajax()) {
return false;
}
$process_discounts = false;
if (isset($this->available_rulesets) && count($this->available_rulesets) > 0 || isset($this->available_advanced_rulesets) && count($this->available_advanced_rulesets)) {
if ($cat_id) {
$process_discounts = is_object_in_term($_product->id, 'product_cat', $cat_id);
}
}
return apply_filters('woocommerce_dynamic_pricing_is_applied_to', $process_discounts, $_product, $this->module_id, $this, $cat_id);
}
开发者ID:GarryVeles,项目名称:Artibaltika,代码行数:13,代码来源:class-wc-dynamic-pricing-simple-category.php
示例12: language_picker_meta_box
/**
* Outputs the contents of the language picker meta box for the write screen
*/
public function language_picker_meta_box()
{
global $post;
$get_terms_args = array('hide_empty' => false);
// Default language
if ($default_language = $this->get_term($this->default_language)) {
$get_terms_args['exclude'] = $this->default_language;
$default_language = array($default_language);
}
$languages = get_terms($this->taxonomy_name, $get_terms_args);
// If there's a default language, push it onto the front of the array
// It won't appear twice as we excluded it already
if (!empty($get_terms_args['exclude'])) {
$languages = array_merge($default_language, $languages);
}
echo '<p><select name="' . esc_attr($this->taxonomy_name) . '_picker" style="width:100%">';
foreach ($languages as $language) {
echo '<option value="' . esc_attr($language->term_id) . '"';
if (true === is_object_in_term($post->ID, $this->taxonomy_name, $language->term_id)) {
echo ' selected="selected"';
}
echo '>' . esc_html($language->name) . '</option>';
}
echo '</select></p>';
}
开发者ID:Automattic,项目名称:Internacional,代码行数:28,代码来源:internacional.php
示例13: appthemes_get_custom_taxonomy
/**
* Returns term data specified in arguments
*
* @param int $post_id Post ID
* @param string $taxonomy The taxonomy
* @param string $tax_arg The term data to retrieve
*
* @return string|bool The term data specified by $tax_arg or bool false if post has no terms
*/
function appthemes_get_custom_taxonomy($post_id, $taxonomy, $tax_arg)
{
$tax_array = get_terms($taxonomy, array('hide_empty' => '0'));
if (empty($tax_array)) {
return false;
}
if (!is_object_in_term($post_id, $taxonomy)) {
return false;
}
foreach ($tax_array as $tax_val) {
if (!is_object_in_term($post_id, $taxonomy, array($tax_val->term_id))) {
continue;
}
switch ($tax_arg) {
case 'slug':
$link = get_term_link($tax_val, $taxonomy);
return $link;
break;
case 'slug_name':
return $tax_val->slug;
break;
case 'name':
return $tax_val->name;
break;
case 'term_id':
return $tax_val->term_id;
break;
default:
return false;
break;
}
}
}
开发者ID:TopLineMediaTeam,项目名称:horseshow,代码行数:42,代码来源:functions.php
示例14: filter_shortcode
/**
* returns list of a comma delimited field names matching the custom term supplied
*
* @terms Comma separated list of terms.
* @content Comma separated list of custom field ids.
*
* @return Comma separated list of field IDs filtered by terms
*/
function filter_shortcode($atts, $content = null)
{
global $post;
extract(shortcode_atts(array('terms' => '', 'not' => 'false'), $atts));
$post_type = get_post_type($post->ID);
$content = do_shortcode($content);
$content = preg_replace('/\\s/', '', $content);
$fields = array_map('trim', (array) explode(',', $content));
if (!empty($terms)) {
$belongs = false;
$taxonomies = array_values(get_object_taxonomies($post_type, 'object'));
$term_names = array_map('trim', (array) explode(',', $terms));
foreach ($taxonomies as $taxonomy) {
if ($taxonomy->hierarchical) {
//Only the category like
foreach ($term_names as $name) {
$term = get_term_by('slug', $name, $taxonomy->name);
if (empty($term->parent)) {
$children = get_term_children($term->term_id, $taxonomy->name);
if (is_object_in_term($post->ID, $taxonomy->name, $children)) {
$belongs = true;
}
}
if (is_object_in_term($post->ID, $taxonomy->name, $name)) {
$belongs = true;
}
}
}
}
if (!$belongs) {
$fields = array();
}
}
if ($not == 'true') {
foreach ($fields as &$field) {
$field = preg_replace('/^(_ct|ct)_/', '', $field);
}
$fields = array_keys(array_diff_key($this->all_custom_fields, array_flip($fields)));
}
$result = implode(',', array_filter($fields));
//filter blanks
if ($result) {
$result .= ',';
}
$result = apply_filters('custom_fields_filter', $result, $atts, $content);
return $result;
}
开发者ID:nayabbukhari,项目名称:circulocristiano,代码行数:55,代码来源:content-types.php
示例15: getOverrideIds
/**
* Obtains the gallery and overlay IDs for the post based on its categories, if any
*
* @param int $post_id The Post ID to check against
* @param mixed $tax The queried object containing the taxonomy details
*/
protected function getOverrideIds($post_id, $tax = null)
{
$cache_id = 'myatu_bgm_' . md5('override' . $this->taxonomy . (is_null($tax) ? $post_id : $tax->slug));
// Check if we already have a cached value
if ($cached_val = get_transient($cache_id)) {
return unserialize($cached_val);
}
// Grab the galleries
$galleries = get_posts(array('numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC', 'post_type' => \Myatu\WordPress\BackgroundManager\Main::PT_GALLERY));
// Iterate galleries
foreach ($galleries as $gallery) {
$overriding_tax = get_post_meta($gallery->ID, $this->meta_tax, true);
// Grab the meta containing the overriding tax from gallery
if (is_array($overriding_tax) && !empty($overriding_tax)) {
$match = false;
if (is_null($tax)) {
// Check if the specified post contains an overrding tax
$match = is_object_in_term($post_id, $this->taxonomy, $overriding_tax);
} else {
// Check if the specified tax is in the overriding tax
$match = in_array($tax->term_id, $overriding_tax) || in_array($tax->name, $overriding_tax) || in_array($tax->slug, $overriding_tax);
}
// Match found
if ($match) {
$cached_val = array('gallery_id' => $gallery->ID, 'overlay_id' => get_post_meta($gallery->ID, $this->meta_tax . static::MT_OVERLAY, true), 'background_color' => get_post_meta($gallery->ID, $this->meta_tax . static::MT_COLOR, true));
// Cache response before returning - WP claims it will serialize, but doesn't seem to work well for this
set_transient($cache_id, serialize($cached_val), 10);
return $cached_val;
}
}
}
// If we reach this point, there's nothing to override
set_transient($cache_id, serialize(false), 10);
return false;
}
开发者ID:zhengxiexie,项目名称:wordpress,代码行数:41,代码来源:Taxonomy.php
示例16: section_meta_box
//.........这里部分代码省略.........
}
else
$("#posttypeselector").hide();
});
$('#section').trigger('change');
});
</script>
<div id="posttypeselector" class="jaxtag ifnews boxhider" style="display: none;">
<div id="newswoo">
<?php
wp_nonce_field('newsnonce', 'news_noncefield');
?>
<select name="news_articletype" class='postform' >
<option class="level-0" value="1183" <?php
if (is_object_in_term($post->ID, 'articletype', 'newsarticle')) {
echo 'selected="selected"';
} else {
echo '';
}
?>
>News Article</option>
<option class="level-0" value="1184" <?php
if (is_object_in_term($post->ID, 'articletype', 'newsfeature')) {
echo 'selected="selected"';
} else {
echo '';
}
?>
>News Feature</option>
</select>
</div>
<div id="opinionwoo">
<?php
wp_nonce_field('opinionnonce', 'opinion_noncefield');
?>
<select name="opinion_articletype" class='postform' >
开发者ID:universitytimes,项目名称:site,代码行数:65,代码来源:custommetabox.php
示例17: wp_update_nav_menu_item
/**
* Save the properties of a menu item or create a new one.
*
* @since 3.0.0
*
* @param int $menu_id The ID of the menu. Required. If "0", makes the menu item a draft orphan.
* @param int $menu_item_db_id The ID of the menu item. If "0", creates a new menu item.
* @param array $menu_item_data The menu item's data.
* @return int|WP_Error The menu item's database ID or WP_Error object on failure.
*/
function 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.'));
}
$menu = wp_get_nav_menu_object($menu_id);
if (!$menu && 0 !== $menu_id) {
return new WP_Error('invalid_menu_id', __('Invalid menu ID.'));
}
if (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-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;
// 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;
}
}
// Associate the menu item with the menu term
// 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))) {
wp_set_object_terms($menu_item_db_id, array($menu->term_id), 'nav_menu');
}
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_item_object', sanitize_key($args['menu-item-object']));
update_post_meta($menu_item_db_id, '_menu_item_target', sanitize_key($args['menu-item-target']));
$args['menu-item-classes'] = array_map('sanitize_html_class', explode(' ', $args['menu-item-classes']));
$args['menu-item-xfn'] = implode(' ', array_map('sanitize_html_class', explode(' ', $args['menu-item-xfn'])));
update_post_meta($menu_item_db_id, '_menu_item_classes', $args['menu-item-classes']);
update_post_meta($menu_item_db_id, '_menu_item_xfn', $args['menu-item-xfn']);
update_post_meta($menu_item_db_id, '_menu_item_url', esc_url_raw($args['menu-item-url']));
if (0 == $menu_id) {
update_post_meta($menu_item_db_id, '_menu_item_orphaned', (string) time());
} elseif (get_post_meta($menu_item_db_id, '_menu_item_orphaned')) {
delete_post_meta($menu_item_db_id, '_menu_item_orphaned');
}
// Update existing menu item. Default is publish status
if ($update) {
$post['ID'] = $menu_item_db_id;
$post['post_status'] = 'draft' == $args['menu-item-status'] ? 'draft' : 'publish';
wp_update_post($post);
//.........这里部分代码省略.........
开发者ID:valiror,项目名称:sharingdais_demo1,代码行数:101,代码来源:nav-menu.php
示例18: array
<?php
global $featured_job_cat_id;
$post_class = array('job');
$expired = jr_check_expired($post);
if ($expired) {
$post_class[] = 'job-expired';
$action = get_option('jr_expired_action');
if ($action == 'hide') {
continue;
}
}
$alt = $alt * -1;
if ($alt == 1) {
$post_class[] = 'job-alt';
}
if (is_object_in_term($post->ID, 'job_cat', array($featured_job_cat_id))) {
$post_class[] = 'job-featured';
}
?>
<li class="<?php
echo implode(' ', $post_class);
?>
">
<dl>
<dt><?php
_e('Type', 'appthemes');
?>
</dt>
开发者ID:besimhu,项目名称:legacy,代码行数:31,代码来源:loop-job.php
示例19: jr_get_custom_taxonomy
function jr_get_custom_taxonomy($post_id, $tax_name, $tax_class)
{
$tax_array = get_terms($tax_name, array('hide_empty' => '0'));
if ($tax_array && sizeof($tax_array) > 0) {
foreach ($tax_array as $tax_val) {
if (is_object_in_term($post_id, $tax_name, array($tax_val->term_id))) {
echo '<span class="' . $tax_class . ' ' . $tax_val->slug . '">' . $tax_val->name . '</span>';
break;
}
}
}
}
开发者ID:besimhu,项目名称:legacy,代码行数:12,代码来源:theme-functions.php
示例20: tribe_event_in_category
/**
* Event in Category Conditional
*
* Returns true if the event is in the specified category slug
*
* @category Events
* @param string $event_cat_slug
* @param int $event_id
*
* @return boolean
*/
function tribe_event_in_category($event_cat_slug, $event_id = null)
{
if (empty($event_id)) {
$event_id = get_the_ID();
}
$term = term_exists($event_cat_slug, Tribe__Events__Main::TAXONOMY);
if (tribe_is_event($event_id) && is_object_in_term($event_id, Tribe__Events__Main::TAXONOMY, array($term['term_id']))) {
$return = true;
} else {
$return = false;
}
return apply_filters('tribe_event_in_category', $return);
}
开发者ID:TMBR,项目名称:johnjohn,代码行数:24,代码来源:general.php
注:本文中的is_object_in_term函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论