• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_objects_in_term函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: jr_process_filter_form

/**
 * JobRoller Application Process
 * Processes a job application sent via the form in a post.
 *
 *
 * @version 1.0
 * @author AppThemes
 * @package JobRoller
 * @copyright 2010 all rights reserved
 *
 */
function jr_process_filter_form()
{
    global $wp_query, $featured_job_cat_id, $find_posts_in, $search_result_ids;
    if (get_query_var('paged')) {
        $paged = get_query_var('paged');
    } elseif (get_query_var('page')) {
        $paged = get_query_var('page');
    } else {
        $paged = 1;
    }
    $args = array('post_type' => 'job_listing', 'post_status' => 'publish', 'paged' => $paged);
    $cats = array();
    $filter_args = array();
    if (isset($_GET['action']) && $_GET['action'] == 'Filter') {
        $job_types = get_terms('job_type', array('hide_empty' => '0'));
        if ($job_types && sizeof($job_types) > 0) {
            foreach ($job_types as $type) {
                if (isset($_GET[$type->slug])) {
                    // Filter is ON
                    $cats[] = $type->term_id;
                }
            }
        }
        if (sizeof($cats) == 0) {
            $cats = array(0);
        }
        // Annoyingly, wordpress won't let you query multiple terms from a custom taxonomy - we have to do this the hard way until support is added
        $post_ids = array();
        // *sigh* get posts in each type...
        foreach ($cats as $cat) {
            $ids = get_objects_in_term($cat, 'job_type');
            $post_ids = array_merge($post_ids, $ids);
        }
        // Only unique ones needed
        $post_ids = array_unique($post_ids);
        // If we are doing location search, find common ids
        if (isset($find_posts_in) && is_array($find_posts_in)) {
            $post_ids = array_intersect($post_ids, $find_posts_in);
        }
        if (isset($search_result_ids) && is_array($search_result_ids)) {
            $post_ids = array_intersect($post_ids, $search_result_ids);
        }
        $post_ids[] = 0;
        // Merge with query args
        $filter_args = array('post__in' => $post_ids);
        $args = array_merge($filter_args, $args);
    } elseif (isset($find_posts_in) && is_array($find_posts_in)) {
        if (isset($search_result_ids) && is_array($search_result_ids)) {
            $find_posts_in = array_intersect($find_posts_in, $search_result_ids);
        }
        $find_posts_in[] = 0;
        $filter_args = array('post__in' => $find_posts_in);
        $args = array_merge($filter_args, $args);
    } elseif (isset($search_result_ids) && is_array($search_result_ids)) {
        $filter_args = array('post__in' => $search_result_ids);
        $args = array_merge($filter_args, $args);
    }
    //$args = array_merge($wp_query->query, $args);
    return $args;
}
开发者ID:besimhu,项目名称:legacy,代码行数:71,代码来源:filter-process.php


示例2: get_products_in_category

 /**
  * Get all product ids in a category (and its children)
  *
  * @param  int $category_id
  * @return array
  */
 public function get_products_in_category($category_id)
 {
     $term_ids = get_term_children($category_id, 'product_cat');
     $term_ids[] = $category_id;
     $product_ids = get_objects_in_term($term_ids, 'product_cat');
     return array_unique(apply_filters('woocommerce_report_sales_by_category_get_products_in_category', $product_ids, $category_id));
 }
开发者ID:dabodude,项目名称:woocommerce,代码行数:13,代码来源:class-wc-report-sales-by-category.php


示例3: get_letters_in_snap

/**
 * Get letters with posts associated
 * 
 * @access public
 * @return void
 * @author Nicolas Juen
 */
function get_letters_in_snap() {
	global $wpdb;
	$post_in = '';
	
	//If we have the right slug in url
	if( get_query_var( SNAP_CAT_GLOSSARY ) ){
		//Get the id of the current term
		$termId = get_term_by( 'slug', get_query_var( SNAP_CAT_GLOSSARY ), SNAP_CAT_GLOSSARY )->term_id;
		
		//If the term exists we get the related posts
		if( !empty( $termId ) || !is_wp_error( $termId ) ){	
			//Get related posts		
			$posts_id = get_objects_in_term( $termId, SNAP_CAT_GLOSSARY );
			
			//Build the additionnal query if we have relatd posts
			if( !empty( $posts_id ) && !is_wp_error( $posts_id ) ){
				$post_in = ' AND p.ID IN (';
				$post_in .= implode(',',$posts_id );
				$post_in .= ' )';
			}
		}
	}
	
	//Make the query and return it
	return $wpdb->get_col( $wpdb->prepare("SELECT DISTINCT(LEFT(p.post_title, 1)) FROM  $wpdb->posts AS p WHERE p.post_type = '".SNAP_POSTTYPE."' AND p.post_status = 'publish'".$post_in) );
}
开发者ID:herewithme,项目名称:simple-snap,代码行数:33,代码来源:function.php


示例4: mf_sponsor_list

function mf_sponsor_list($category_name, $slug = '')
{
    //get the list of links based on faire name
    $sponsors = get_bookmarks(array('orderby' => 'name', 'category_name' => $category_name, 'limit' => 40));
    $slugData = get_term_by('slug', $slug, 'link_category', OBJECT);
    if (is_object($slugData)) {
        $slugCat = get_objects_in_term($slugData->term_id, 'link_category');
    } else {
        $slugCat = array();
    }
    //get the list of links based on sponsor category name
    $slugData = get_term_by('slug', $category_name, 'link_category', OBJECT);
    $sponsorName = get_objects_in_term($slugData->term_id, 'link_category');
    //find the links that are in both the sponsor category and specified faire
    if (!empty($slugCat)) {
        $category = array_intersect($slugCat, $sponsorName);
    } else {
        $category = $sponsorName;
    }
    $include = implode(',', $category);
    $sponsors = array();
    if (!empty($include)) {
        $sponsors = get_bookmarks(array('orderby' => 'name', 'limit' => 40, 'include' => $include));
    }
    // Get the output started.
    $output = '<ul>';
    // Loop through each block of sponsors
    foreach ($sponsors as $idx => $spon) {
        //foreach ($sponsor as $spon) {
        $output .= '<li><a href="' . esc_url($spon->link_url) . '"><img src="' . legacy_get_resized_remote_image_url($spon->link_image, 125, 105) . '" alt=""></a></li>';
        //}
    }
    $output .= '</ul>';
    return $output;
}
开发者ID:hansstam,项目名称:makerfaire,代码行数:35,代码来源:sponsor.php


示例5: multiple_tax_fix

function multiple_tax_fix($wp_query)
{
    global $wp_taxonomies;
    $query = array();
    foreach ($wp_taxonomies as $taxonomy => $t) {
        if ($t->query_var) {
            if ($var = $wp_query->get($t->query_var)) {
                $query[$taxonomy] = $var;
            }
        }
    }
    if (count($query) <= 1) {
        return;
    }
    $ids = array();
    foreach ($query as $tax => $term_slug) {
        if (!($term = get_term_by('slug', $term_slug, $tax))) {
            return $wp_query->set_404();
        }
        $posts = get_objects_in_term($term->term_id, $tax);
        if (empty($posts)) {
            return $wp_query->set_404();
        }
        $ids[] = $posts;
    }
    $ids = call_user_func_array('array_intersect', $ids);
    if (empty($ids)) {
        $wp_query->set_404();
    }
    $wp_query->set('post__in', $ids);
}
开发者ID:sudar,项目名称:rolopress-core,代码行数:31,代码来源:query-multiple-taxonomies.php


示例6: wcapf_get_term_objects

 function wcapf_get_term_objects($term_id, $taxonomy)
 {
     global $wcapf;
     $unfiltered_product_ids = $wcapf->unfilteredProductIds();
     $transient_name = 'wcapf_term_objects_' . md5(sanitize_key($taxonomy) . sanitize_key($term_id));
     if (false === ($objects_in_term = get_transient($transient_name))) {
         $objects_in_term = get_objects_in_term($term_id, $taxonomy);
         $objects_in_term = array_intersect($objects_in_term, $unfiltered_product_ids);
         set_transient($transient_name, $objects_in_term, WCAPF_CACHE_TIME);
     }
     return (array) $objects_in_term;
 }
开发者ID:wptailor,项目名称:wc-ajax-product-filter,代码行数:12,代码来源:functions.php


示例7: get_posts_related_by_taxonomy

function get_posts_related_by_taxonomy($post_id, $taxonomy, $notin, $args = array())
{
    $query = new WP_Query();
    $terms = wp_get_object_terms($post_id, $taxonomy);
    if (count($terms)) {
        // Assumes only one term for per post in this taxonomy
        $post_ids = get_objects_in_term($terms[0]->term_id, $taxonomy);
        $post = get_post($post_id);
        $args = wp_parse_args($args, array('post_type' => $post->post_type, 'post__not_in' => array($notin), 'taxonomy' => $taxonomy, 'term' => $terms[0]->slug, 'posts_per_page' => get_option('tz_related_portfolio_number')));
        $query = new WP_Query($args);
    }
    return $query;
}
开发者ID:vpatrinica,项目名称:jfdesign,代码行数:13,代码来源:functions.php


示例8: fontello_conversion

/**
 * Convert items in the social menu to icons in the Fontello icon font
 */
function fontello_conversion($title, $id = null)
{
    if (has_nav_menu('social_links')) {
        if (in_array($id, get_objects_in_term(wp_get_nav_menu_object(get_nav_menu_locations()['social_links'])->term_id, 'nav_menu'))) {
            switch (strtolower($title)) {
                case "facebook":
                case "fb":
                    return "f";
                    break;
                case "flickr":
                case "flicker":
                    return "F";
                    break;
                case "google+":
                case "g":
                case "g+":
                case "googleplus":
                case "google plus":
                    return "G";
                    break;
                case "instagram":
                    return "i";
                    break;
                case "linked in":
                case "linkedin":
                case "li":
                    return "L";
                    break;
                case "twitter":
                    return "T";
                    break;
                case "vimeo":
                    return "v";
                    break;
                case "vine":
                    return "V";
                    break;
                case "yelp":
                    return "Y";
                    break;
                case "youtube":
                    return "y";
                    break;
                default:
                    return strtolower($title[0]);
            }
        }
    }
    return $title;
}
开发者ID:razordaze,项目名称:cutter,代码行数:53,代码来源:extras.php


示例9: jigoshop_product_type_options_box

/**
 * Product type meta box
 * 
 * Display the product type meta box which contains a hook for product types to hook into and show their options
 *
 * @since 		1.0
 */
function jigoshop_product_type_options_box() {

	global $post;
	?>
	<div id="simple_product_options" class="panel jigoshop_options_panel">
		<?php
			// List Grouped products
			$posts_in = (array) get_objects_in_term( get_term_by( 'slug', 'grouped', 'product_type' )->term_id, 'product_type' );
			$posts_in = array_unique($posts_in);
			
			$field = array( 'id' => 'parent_id', 'label' => __('Parent post', 'jigoshop') );
			echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label><select id="'.$field['id'].'" name="'.$field['id'].'"><option value="">'.__('Choose a grouped product&hellip;', 'jigoshop').'</option>';

			if (sizeof($posts_in)>0) :
				$args = array(
					'post_type'	=> 'product',
					'post_status' => 'publish',
					'numberposts' => -1,
					'orderby' => 'title',
					'order' => 'asc',
					'post_parent' => 0,
					'include' => $posts_in,
				);
				$grouped_products = get_posts($args);
				$loop = 0;
				if ($grouped_products) : foreach ($grouped_products as $product) :
					
					if ($product->ID==$post->ID) continue;
					
					echo '<option value="'.$product->ID.'" ';
					if ($post->post_parent==$product->ID) echo 'selected="selected"';
					echo '>'.$product->post_title.'</option>';
			
				endforeach; endif; 
			endif;

			echo '</select></p>';
			
			// Ordering
			$menu_order = $post->menu_order;
			$field = array( 'id' => 'menu_order', 'label' => _x('Order', 'ordering', 'jigoshop') );
			echo '<p class="form-field">
				<label for="'.$field['id'].'">'.$field['label'].':</label>
				<input type="text" class="short" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$menu_order.'" /></p>';

		?>
	</div>
	<?php 
	do_action('jigoshop_product_type_options_box');
}
开发者ID:rszczypka,项目名称:jigoshop,代码行数:57,代码来源:product-type.php


示例10: get_posts_related_by_taxonomy

function get_posts_related_by_taxonomy($taxonomy, $posts_per_page, $args = array())
{
    global $post;
    $post_id = $post->ID;
    $query = new WP_Query();
    $terms = wp_get_object_terms($post_id, $taxonomy);
    if (count($terms)) {
        // Assumes only one term for per post in this taxonomy
        $post_ids = get_objects_in_term($terms[0]->term_id, $taxonomy);
        $post = get_post($post_id);
        $args = wp_parse_args($args, array('post_type' => $post->post_type, 'post__not_in' => array($post_id), 'taxonomy' => $taxonomy, 'term' => $terms[0]->slug, 'exclude' => $post, 'posts_per_page' => $posts_per_page));
        $query = new WP_Query($args);
    }
    return $query;
}
开发者ID:yelingkong,项目名称:wordpresszt,代码行数:15,代码来源:dj_get_options.php


示例11: get_posts_related_by_taxonomy

function get_posts_related_by_taxonomy($post_id, $taxonomy, $args = array())
{
    $terms = wp_get_object_terms($post_id, $taxonomy);
    $query = new WP_Query();
    if (count($terms)) {
        // Assumes only one term for per post in this taxonomy
        $post_ids = get_objects_in_term($terms[0]->term_id, $taxonomy);
        $post = get_post($post_id);
        $post_id_array = array($post_id);
        $post_ids_excl = array_diff($post_ids, $post_id_array);
        $args = wp_parse_args($args, array('post_type' => $post->post_type, 'post__in' => $post_ids_excl, 'taxonomy' => $taxonomy, 'term' => $terms[0]->slug, 'showposts' => 3, 'no_found_rows' => true));
        $query = new WP_Query($args);
    }
    return $query;
}
开发者ID:developmentDM2,项目名称:CZND,代码行数:15,代码来源:related.php


示例12: handle_duplicate

 function handle_duplicate()
 {
     if (isset($_REQUEST['_td_nonce']) && check_admin_referer('duplicate_term', '_td_nonce')) {
         $term_id = $_REQUEST['term_duplicator_term'];
         $term_tax = $_REQUEST['taxonomy'];
         $existing_taxonomy_term = get_term($term_id, $term_tax);
         $new_term = wp_insert_term("{$existing_taxonomy_term->name} Copy", $term_tax, array('description' => $existing_taxonomy_term->description, 'slug' => "{$existing_taxonomy_term->slug}-copy", 'parent' => $existing_taxonomy_term->parent));
         if (!is_wp_error($new_term)) {
             // add all existing posts to new term
             $posts = get_objects_in_term($term_id, $term_tax);
             if (!is_wp_error($posts)) {
                 foreach ($posts as $post_id) {
                     $result = wp_set_post_terms($post_id, $new_term['term_id'], $term_tax, true);
                 }
             }
         }
     }
 }
开发者ID:clifgriffin,项目名称:Term-Duplicator,代码行数:18,代码来源:term-duplicator.php


示例13: go_gold_store_sc

function go_gold_store_sc($atts, $content = null)
{
    $args = array('post_type' => 'go_store', 'posts_per_page' => 10);
    // Defines args used to get custom post type content
    $loop = new WP_Query($args);
    // Loops in custom post type content
    if (count(array_keys($loop->posts)) > 0) {
        $output_array = array();
        extract(shortcode_atts(array('cats' => '', 'id' => ''), $atts));
        if ($cats) {
            // the idea is that teachers/educators can leave an optional space between the items in their store.
            // e.g. [go_store cats='time, music, bathroom-passes'] or [go_store cats='time,music,bathroom-passes']
            $cat_array_raw = explode(", ", $cats);
            // remove comma-space blocks and create an array
            $cat_string = implode(",", $cat_array_raw);
            // join the array into a string with commas
            $cat_array = explode(",", $cat_string);
            // remove comma blocks and break the string into an array
            for ($i = 0; $i < count($cat_array); $i++) {
                $the_term_id = get_term_by('name', $cat_array[$i], 'store_types')->term_id;
                $the_args = array('orderby' => 'name');
                $the_items = get_objects_in_term($the_term_id, 'store_types', $the_args);
                $upp_cat = ucwords($cat_array[$i]);
                array_push($output_array, "<h3>" . $upp_cat . "</h3>");
                for ($x = 0; $x < count($the_items); $x++) {
                    $the_title = get_the_title($the_items[$x]);
                    array_push($output_array, "<a class='go_str_item' onclick='go_lb_opener(" . $the_items[$x] . ");'>" . $the_title . "</a><br/>");
                }
            }
            $output_array = implode(" ", $output_array);
            return $output_array;
        } else {
            if ($id) {
                $the_title = get_the_title($id);
                // get item title
                $custom_fields = get_post_custom($id);
                $req_currency = $custom_fields['go_mta_store_currency'][0];
                return '<a class="go_str_item" onclick="go_lb_opener(' . $id . ');">' . $the_title . '</a>';
            }
        }
    }
}
开发者ID:SpencerNussbaum,项目名称:game-on,代码行数:42,代码来源:store-shortcode.php


示例14: max_query_term_posts

 function max_query_term_posts($showposts = PER_PAGE_DEFAULT, $id_array, $type = 'gallery', $random = false, $taxonomy = GALLERY_TAXONOMY, $sorting = false, $filter_current = false)
 {
     global $post, $max_random_posts_query;
     $rand = !$random ? "" : $random;
     $sort = !$sorting ? "" : $sorting;
     $posts_to_query = get_objects_in_term($id_array, $taxonomy);
     if ($filter_current === true) {
         $_array_diff = array(0 => $post->ID);
         $posts_to_query = array_diff($posts_to_query, $_array_diff);
     }
     $seed = date('Ymdhi');
     // Use date('Ymdh') to get an hourly change
     $max_random_posts_query = " ORDER BY rand({$seed}) ";
     // set the query args
     $defaults = array('ignore_sticky_posts' => 1, 'showposts' => $showposts, 'post_type' => $type, 'post__in' => $posts_to_query, 'orderby' => $rand, 'order' => $sort);
     // query the posts
     $queried_posts = query_posts($defaults);
     $max_random_posts_query = '';
     return $queried_posts;
 }
开发者ID:erdidoqan,项目名称:fishcom,代码行数:20,代码来源:max_posts.php


示例15: ac_portfolio_get_related

function ac_portfolio_get_related($post = 0)
{
    $posts = array();
    // Get the post
    $post = get_post($post);
    // Get the term objects
    $terms = wp_get_object_terms($post->ID, 'portfolio-category');
    // Get the posts for these terms
    $post_ids = array();
    if (count($terms)) {
        $post_ids = get_objects_in_term($terms[0]->term_id, 'portfolio-category');
    }
    // Remove this post from the list
    $index = array_search($post->ID, $post_ids);
    if ($index !== false) {
        unset($post_ids[$index]);
    }
    if ($post_ids) {
        $args = array('post_type' => 'ac_portfolio', 'post__in' => $post_ids, 'posts_per_page' => 3, 'orderby' => 'meta_value', 'order' => 'date');
        $posts = get_posts($args);
    }
    return $posts;
}
开发者ID:Jhorton4,项目名称:Bohldfeys_Portfolio,代码行数:23,代码来源:ac-portfolio.php


示例16: convert_tags

 function convert_tags()
 {
     global $wpdb;
     if ((!isset($_POST['tags_to_convert']) || !is_array($_POST['tags_to_convert'])) && empty($this->tags_to_convert)) {
         echo '<div class="narrow">';
         echo '<p>' . sprintf(__('Uh, oh. Something didn&#8217;t work. Please <a href="%s">try again</a>.'), 'admin.php?import=wp-cat2tag&amp;step=3') . '</p>';
         echo '</div>';
         return;
     }
     if (empty($this->tags_to_convert)) {
         $this->tags_to_convert = $_POST['tags_to_convert'];
     }
     $hybrid_tags = $clear_parents = false;
     $clean_cat_cache = $clean_term_cache = array();
     $default_cat = get_option('default_category');
     echo '<ul>';
     foreach ((array) $this->tags_to_convert as $tag_id) {
         $tag_id = (int) $tag_id;
         if ($tag = get_term($tag_id, 'post_tag')) {
             printf('<li>' . __('Converting tag <strong>%s</strong> ... '), $tag->name);
             if ($cat_ttid = $wpdb->get_var($wpdb->prepare("SELECT term_taxonomy_id FROM {$wpdb->term_taxonomy} WHERE term_id = %d AND taxonomy = 'category'", $tag->term_id))) {
                 $objects_ids = get_objects_in_term($tag->term_id, 'post_tag');
                 $cat_ttid = (int) $cat_ttid;
                 $term_order = 0;
                 foreach ($objects_ids as $object_id) {
                     $values[] = $wpdb->prepare("(%d, %d, %d)", $object_id, $cat_ttid, $term_order);
                     clean_post_cache($object_id);
                 }
                 if ($values) {
                     $wpdb->query("INSERT INTO {$wpdb->term_relationships} (object_id, term_taxonomy_id, term_order) VALUES " . join(',', $values) . " ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)");
                     if ($default_cat != $tag->term_id) {
                         $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->term_relationships} WHERE term_taxonomy_id = %d", $tag->term_id));
                         $wpdb->query($wpdb->prepare("UPDATE {$wpdb->term_taxonomy} SET count = %d WHERE term_id = %d AND taxonomy = 'category'", $count, $tag->term_id));
                     }
                 }
                 $hybrid_tags = true;
                 $clean_term_cache[] = $tag->term_id;
                 $clean_cat_cache[] = $tag->term_id;
                 echo __('All posts were added to the category with the same name.') . " *</li>\n";
                 continue;
             }
             // Change the tag to a category.
             $parent = $wpdb->get_var($wpdb->prepare("SELECT parent FROM {$wpdb->term_taxonomy} WHERE term_id = %d AND taxonomy = 'post_tag'", $tag->term_id));
             if (0 == $parent || 0 < (int) $parent && $this->_category_exists($parent)) {
                 $reset_parent = '';
                 $clear_parents = true;
             } else {
                 $reset_parent = ", parent = '0'";
             }
             $wpdb->query($wpdb->prepare("UPDATE {$wpdb->term_taxonomy} SET taxonomy = 'category' {$reset_parent} WHERE term_id = %d AND taxonomy = 'post_tag'", $tag->term_id));
             $clean_term_cache[] = $tag->term_id;
             $clean_cat_cache[] = $cat['term_id'];
             echo __('Converted successfully.') . "</li>\n";
         } else {
             printf('<li>' . __('Tag #%s doesn\'t exist!') . "</li>\n", $tag_id);
         }
     }
     if (!empty($clean_term_cache)) {
         $clean_term_cache = array_unique(array_values($clean_term_cache));
         foreach ($clean_term_cache as $id) {
             wp_cache_delete($id, 'post_tag');
         }
     }
     if (!empty($clean_cat_cache)) {
         $clean_cat_cache = array_unique(array_values($clean_cat_cache));
         foreach ($clean_cat_cache as $id) {
             wp_cache_delete($id, 'category');
         }
     }
     if ($clear_parents) {
         delete_option('category_children');
     }
     echo '</ul>';
     if ($hybrid_tags) {
         echo '<p>' . sprintf(__('* This tag is also a category. The converter has added all posts from it to the category. If you want to remove it, please confirm that all posts were added successfully, then delete it from the <a href="%s">Manage Tags</a> page.'), 'edit-tags.php') . '</p>';
     }
     echo '<p>' . sprintf(__('We&#8217;re all done here, but you can always <a href="%s">convert more</a>.'), 'admin.php?import=wp-cat2tag&amp;step=3') . '</p>';
 }
开发者ID:BGCX262,项目名称:zxhproject-svn-to-git,代码行数:78,代码来源:wp-cat2tag.php


示例17: fusion_get_adjacent_post_plus


//.........这里部分代码省略.........
            if ($in_same_cat) {
                $cat_array = wp_get_object_terms($post->ID, $taxonomies, array('fields' => 'ids'));
            }
            if ($in_same_tax && !$in_same_cat) {
                if (true === $in_same_tax) {
                    if (array('category') != $taxonomies) {
                        $taxonomies = array_diff($taxonomies, array('category'));
                    }
                } else {
                    $taxonomies = (array) $in_same_tax;
                }
                $tax_array = wp_get_object_terms($post->ID, $taxonomies, array('fields' => 'ids'));
            }
            if ($in_same_format) {
                $taxonomies[] = 'post_format';
                $format_array = wp_get_object_terms($post->ID, 'post_format', array('fields' => 'ids'));
            }
            $join .= " INNER JOIN {$wpdb->term_relationships} AS tr ON p.ID = tr.object_id INNER JOIN {$wpdb->term_taxonomy} tt ON tr.term_taxonomy_id = tt.term_taxonomy_id AND tt.taxonomy IN (\"" . implode('", "', $taxonomies) . "\")";
            $term_array = array_unique(array_merge($cat_array, $tax_array, $format_array));
            if (!empty($term_array)) {
                $in_same_term_sql = "AND tt.term_id IN (" . implode(',', $term_array) . ")";
            }
            if (!empty($excluded_categories)) {
                // Support for both (1 and 5 and 15) and (1, 5, 15) delimiter styles
                $delimiter = strpos($excluded_categories, ',') !== false ? ',' : 'and';
                $excluded_categories = array_map('intval', explode($delimiter, $excluded_categories));
                // Three category exclusion methods are supported: 'strong', 'diff', and 'weak'.
                // Default is 'weak'. See the plugin documentation for more information.
                if ('strong' === $ex_cats_method) {
                    $taxonomies = array_filter(get_post_taxonomies($post->ID), 'is_taxonomy_hierarchical');
                    if (function_exists('get_post_format')) {
                        $taxonomies[] = 'post_format';
                    }
                    $ex_cats_posts = get_objects_in_term($excluded_categories, $taxonomies);
                    if (!empty($ex_cats_posts)) {
                        $ex_cats_sql = "AND p.ID NOT IN (" . implode($ex_cats_posts, ',') . ")";
                    }
                } else {
                    if (!empty($term_array) && !in_array($ex_cats_method, array('diff', 'differential'))) {
                        $excluded_categories = array_diff($excluded_categories, $term_array);
                    }
                    if (!empty($excluded_categories)) {
                        $ex_cats_sql = "AND tt.term_id NOT IN (" . implode($excluded_categories, ',') . ')';
                    }
                }
            }
            if (!empty($included_categories)) {
                $in_same_term_sql = '';
                // in_cats overrides in_same_cat
                $delimiter = false !== strpos($included_categories, ',') ? ',' : 'and';
                $included_categories = array_map('intval', explode($delimiter, $included_categories));
                $in_cats_sql = "AND tt.term_id IN (" . implode(',', $included_categories) . ")";
            }
        }
        // Optionally restrict next/previous links to same author
        if ($in_same_author) {
            $in_same_author_sql = $wpdb->prepare("AND p.post_author = %d", $post->post_author);
        }
        // Optionally restrict next/previous links to same meta value
        if ($in_same_meta && 'custom' != $r['order_by'] && 'numeric' != $r['order_by']) {
            $in_same_meta_sql = $wpdb->prepare("AND m.meta_value = %s", get_post_meta($post->ID, $in_same_meta, true));
        }
        // Optionally exclude individual post IDs
        if (!empty($excluded_posts)) {
            $excluded_posts = array_map('intval', explode(',', $excluded_posts));
            $ex_posts_sql = " AND p.ID NOT IN (" . implode(',', $excluded_posts) . ")";
开发者ID:pedrom40,项目名称:sazoo.org,代码行数:67,代码来源:post-link-plus.php


示例18: woocommerce_products_will_display

 /**
  * Check if we will be showing products or not (and not subcats only)
  *
  * @access public
  * @subpackage	Loop
  * @return bool
  */
 function woocommerce_products_will_display()
 {
     if (is_shop()) {
         return get_option('woocommerce_shop_page_display') != 'subcategories';
     }
     if (!is_product_taxonomy()) {
         return false;
     }
     if (is_search() || is_filtered() || is_paged()) {
         return true;
     }
     $term = get_queried_object();
     if (is_product_category()) {
         switch (get_woocommerce_term_meta($term->term_id, 'display_type', true)) {
             case 'subcategories':
                 // Nothing - we want to continue to see if there are products/subcats
                 break;
             case 'products':
             case 'both':
                 return true;
                 break;
             default:
                 // Default - no setting
                 if (get_option('woocommerce_category_archive_display') != 'subcategories') {
                     return true;
                 }
                 break;
         }
     }
     // Begin subcategory logic
     global $wpdb;
     $parent_id = empty($term->term_id) ? 0 : $term->term_id;
     $taxonomy = empty($term->taxonomy) ? '' : $term->taxonomy;
     $products_will_display = true;
     if (!$parent_id && !$taxonomy) {
         return true;
     }
     $transient_name = 'wc_products_will_display_' . $parent_id . WC_Cache_Helper::get_transient_version('product_query');
     if (false === ($products_will_display = get_transient($transient_name))) {
         $has_children = $wpdb->get_col($wpdb->prepare("SELECT term_id FROM {$wpdb->term_taxonomy} WHERE parent = %d AND taxonomy = %s", $parent_id, $taxonomy));
         if ($has_children) {
             // Check terms have products inside - parents first. If products are found inside, subcats will be shown instead of products so we can return false.
             if (sizeof(get_objects_in_term($has_children, $taxonomy)) > 0) {
                 $products_will_display = false;
             } else {
                 // If we get here, the parents were empty so we're forced to check children
                 foreach ($has_children as $term) {
                     $children = get_term_children($term, $taxonomy);
                     if (sizeof(get_objects_in_term($children, $taxonomy)) > 0) {
                         $products_will_display = false;
                         break;
                     }
                 }
             }
         } else {
             $products_will_display = true;
         }
     }
     set_transient($transient_name, $products_will_display, YEAR_IN_SECONDS);
     return $products_will_display;
 }
开发者ID:uwitec,项目名称:findgreatmaster,代码行数:68,代码来源:wc-template-functions.php


示例19: _use_categories_in_all_languages

 function _use_categories_in_all_languages($product_ids, $category_id)
 {
     global $sitepress;
     $category_term = get_term($category_id, 'product_cat');
     if (!is_wp_error($category_term)) {
         $trid = $sitepress->get_element_trid($category_term->term_taxonomy_id, 'tax_product_cat');
         $translations = $sitepress->get_element_translations($trid, 'tax_product_cat', true);
         foreach ($translations as $translation) {
             if ($translation->term_id != $category_id) {
                 $term_ids = get_term_children($translation->term_id, 'product_cat');
                 $term_ids[] = $translation->term_id;
                 $product_ids = array_merge(array_unique($product_ids), get_objects_in_term($term_ids, 'product_cat'));
             }
         }
     }
     return $product_ids;
 }
开发者ID:sergioblanco86,项目名称:git-gitlab.com-kinivo-kinivo.com,代码行数:17,代码来源:multi-currency.class.php


示例20: widget

 /**
  * widget function.
  *
  * @see WP_Widget
  * @access public
  * @param array $args
  * @param array $instance
  * @return void
  */
 function widget($args, $instance)
 {
     extract($args);
     global $_chosen_attributes, $woocommerce, $_attributes_array;
     if (!is_post_type_archive('product') && !is_tax(array_merge($_attributes_array, array('product_cat', 'product_tag')))) {
         return;
     }
     $current_term = $_attributes_array && is_tax($_attributes_array) ? get_queried_object()->term_id : '';
     $current_tax = $_attributes_array && is_tax($_attributes_array) ? get_queried_object()->taxonomy : '';
     $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     $taxonomy = $woocommerce->attribute_taxonomy_name($instance['attribute']);
     $query_type = isset($instance['query_type']) ? $instance['query_type'] : 'and';
     $display_type = isset($instance['display_type']) ? $instance['display_type'] : 'list';
     if (!taxonomy_exists($taxonomy)) {
         return;
     }
     $args = array('hide_empty' => '1');
     $terms = get_terms($taxonomy, $args);
     $count = count($terms);
     if ($count > 0) {
         $found = false;
         ob_start();
         echo $before_widget . $before_title . $title . $after_title;
         // Force found when option is selected - do not force found on taxonomy attributes
         if (!$_attributes_array || !is_tax($_attributes_array)) {
             if (is_array($_chosen_attributes) && array_key_exists($taxonomy, $_chosen_attributes)) {
                 $found = true;
             }
         }
         if ($display_type == 'dropdown') {
             // skip when viewing the taxonomy
             if ($current_tax && $taxonomy == $current_tax) {
                 $found = false;
             } else {
                 $taxonomy_filter = str_replace('pa_', '', $taxonomy);
                 $found = true;
                 echo '<select id="dropdown_layered_nav_' . $taxonomy_filter . '">';
                 echo '<option value="">' . sprintf(__('Any %s', 'woocommerce'), $woocommerce->attribute_label($taxonomy)) . '</option>';
                 foreach ($terms as $term) {
                     // If on a term page, skip that term in widget list
                     if ($term->term_id == $current_term) {
                         continue;
                     }
                     // Get count based on current view - uses transients
                     $transient_name = 'wc_ln_count_' . md5(sanitize_key($taxonomy) . sanitize_key($term->term_id));
                     if (false === ($_products_in_term = get_transient($transient_name))) {
                         $_products_in_term = get_objects_in_term($term->term_id, $taxonomy);
                         set_transient($transient_name, $_products_in_term);
                     }
                     $option_is_set = isset($_chosen_attributes[$taxonomy]) && in_array($term->term_id, $_chosen_attributes[$taxonomy]['terms']);
                     // If this is an AND query, only show options with count > 0
                     if ($query_type == 'and') {
                         $count = sizeof(array_intersect($_products_in_term, $woocommerce->query->filtered_product_ids));
                         if ($count > 0) {
                             $found = true;
                         }
                         if ($count == 0 && !$option_is_set) {
                             continue;
                         }
                         // If this is an OR query, show all options so search can be expanded
                     } else {
                         $count = sizeof(array_intersect($_products_in_term, $woocommerce->query->unfiltered_product_ids));
                         if ($count > 0) {
                             $found = true;
                         }
                     }
                     echo '<option value="' . $term->term_id . '" ' . selected(isset($_GET['filter_' . $taxonomy_filter]) ? $_GET['filter_' . $taxonomy_filter] : '', $term->term_id, false) . '>' . $term->name . '</option>';
                 }
                 echo '</select>';
                 $woocommerce->add_inline_js("\n\n\t\t\t\t\t\tjQuery('#dropdown_layered_nav_{$taxonomy_filter}').change(function(){\n\n\t\t\t\t\t\t\tlocation.href = '" . add_query_arg('filtering', '1', remove_query_arg('filter_' . $taxonomy_filter)) . "&filter_{$taxonomy_filter}=' + jQuery('#dropdown_layered_nav_{$taxonomy_filter}').val();\n\n\t\t\t\t\t\t}); 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_observer_hash函数代码示例发布时间:2022-05-15
下一篇:
PHP get_object_vars_final函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap