本文整理匯總了PHP中is_object_in_term函數的典型用法代碼示例。如果您正苦於以下問題:PHP is_object_in_term函數的具體用法?PHP is_object_in_term怎麽用?PHP is_object_in_term使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了is_object_in_term函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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');
}
}
示例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;
}
示例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
}
}
}
}
}
示例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;
}
示例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;
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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>';
}
示例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;
}
}
}
示例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;
}
示例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;
}