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


PHP _make_cat_compat函数代码示例

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


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

示例1: setUp

 function setUp()
 {
     global $wp_rewrite;
     parent::setUp();
     set_current_screen('front');
     $GLOBALS['wp_the_query'] = new WP_Query();
     $GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
     $wp_rewrite->init();
     $wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/');
     create_initial_taxonomies();
     register_taxonomy('testtax', 'post', array('public' => true));
     $wp_rewrite->flush_rules();
     $this->tag_id = $this->factory->tag->create(array('slug' => 'tag-slug'));
     $this->cat_id = $this->factory->category->create(array('slug' => 'cat-slug'));
     $this->tax_id = $this->factory->term->create(array('taxonomy' => 'testtax', 'slug' => 'tax-slug'));
     $this->tax_id2 = $this->factory->term->create(array('taxonomy' => 'testtax', 'slug' => 'tax-slug2'));
     $this->post_id = $this->factory->post->create();
     wp_set_object_terms($this->post_id, $this->cat_id, 'category');
     wp_set_object_terms($this->post_id, array($this->tax_id, $this->tax_id2), 'testtax');
     $this->cat = get_term($this->cat_id, 'category');
     _make_cat_compat($this->cat);
     $this->tag = get_term($this->tag_id, 'post_tag');
     $this->uncat = get_term_by('slug', 'uncategorized', 'category');
     _make_cat_compat($this->uncat);
     add_action('pre_get_posts', array($this, 'pre_get_posts_tax_category_tax_query'));
 }
开发者ID:boonebgorges,项目名称:wp,代码行数:26,代码来源:taxQuery.php

示例2: get_category_by_slug

function get_category_by_slug( $slug  ) {
	$category = get_term_by('slug', $slug, 'category');
	if ( $category )
		_make_cat_compat($category);

	return $category;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:7,代码来源:category.php

示例3: test__make_cat_compat

 /**
  * Validate _make_cat_compat function
  */
 function test__make_cat_compat()
 {
     // create Test Categories and Array Representations
     $testcat_array = array('slug' => 'testmcc', 'name' => 'Test MCC', 'description' => 'Category Test');
     $testcat = self::factory()->category->create_and_get($testcat_array);
     $testcat_array['term_id'] = $testcat->term_id;
     $testcat2_array = array('slug' => 'testmcc', 'name' => 'Test MCC', 'description' => 'Category Test', 'parent' => $testcat->term_id);
     $testcat2 = self::factory()->category->create_and_get($testcat2_array);
     $testcat2_array['term_id'] = $testcat2->term_id;
     // unset properties to enable validation of object
     unset($testcat->cat_ID);
     unset($testcat->category_count);
     unset($testcat->category_description);
     unset($testcat->cat_name);
     unset($testcat->category_nicename);
     unset($testcat->category_parent);
     unset($testcat2->cat_ID);
     unset($testcat2->category_count);
     unset($testcat2->category_description);
     unset($testcat2->cat_name);
     unset($testcat2->category_nicename);
     unset($testcat2->category_parent);
     // make Compatible
     _make_cat_compat($testcat);
     _make_cat_compat($testcat2);
     _make_cat_compat($testcat_array);
     _make_cat_compat($testcat2_array);
     // Validate Compatibility Object
     $this->assertEquals($testcat->cat_ID, $testcat->term_id);
     $this->assertEquals($testcat->category_count, $testcat->count);
     $this->assertEquals($testcat->category_description, $testcat->description);
     $this->assertEquals($testcat->cat_name, $testcat->name);
     $this->assertEquals($testcat->category_nicename, $testcat->slug);
     $this->assertEquals($testcat->category_parent, $testcat->parent);
     // Validate Compatibility Object with Parent
     $this->assertEquals($testcat->cat_ID, $testcat->term_id);
     $this->assertEquals($testcat->category_count, $testcat->count);
     $this->assertEquals($testcat->category_description, $testcat->description);
     $this->assertEquals($testcat->cat_name, $testcat->name);
     $this->assertEquals($testcat->category_nicename, $testcat->slug);
     $this->assertEquals($testcat->category_parent, $testcat->parent);
     // Validate Compatibility Array
     $this->assertEquals($testcat_array['cat_ID'], $testcat_array['term_id']);
     $this->assertEquals($testcat_array['category_count'], $testcat_array['count']);
     $this->assertEquals($testcat_array['category_description'], $testcat_array['description']);
     $this->assertEquals($testcat_array['cat_name'], $testcat_array['name']);
     $this->assertEquals($testcat_array['category_nicename'], $testcat_array['slug']);
     $this->assertEquals($testcat_array['category_parent'], $testcat_array['parent']);
     // Validate Compatibility Array with Parent
     $this->assertEquals($testcat_array['cat_ID'], $testcat_array['term_id']);
     $this->assertEquals($testcat_array['category_count'], $testcat_array['count']);
     $this->assertEquals($testcat_array['category_description'], $testcat_array['description']);
     $this->assertEquals($testcat_array['cat_name'], $testcat_array['name']);
     $this->assertEquals($testcat_array['category_nicename'], $testcat_array['slug']);
     $this->assertEquals($testcat_array['category_parent'], $testcat_array['parent']);
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:59,代码来源:category.php

示例4: widget

 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('xt_widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
     global $xt;
     if ($xt->is_daogou) {
         $cats = get_the_terms(null, 'daogou_category');
         if (!$cats || is_wp_error($cats)) {
             $cats = array();
         }
         $cats = array_values($cats);
         foreach (array_keys($cats) as $key) {
             _make_cat_compat($cats[$key]);
         }
         $cids = array();
         if (!empty($cats)) {
             foreach ($cats as $cat) {
                 $cids[] = $cat->cat_ID;
             }
         }
         $cids = implode(',', $cids);
         $show = intval($instance['show']);
         $count = intval($instance['count']);
         $sortOrder = $instance['sortOrder'];
         $isDaogouList = $layout == 'span9' && $show == 2;
         if ($isDaogouList) {
             echo str_replace('xt-widget-blog', 'xt-widget-daogou', $before_widget);
         } else {
             echo $before_widget;
         }
         echo '<div class="hd"><h4 class="xt-bd-l" style="' . (empty($title) ? 'display:none' : '') . '"><span>' . $title . '</span></h4></div><div class="bd">';
         $_params = array('post_type' => 'daogou', 'posts_per_page' => $count, 'orderby' => $sortOrder);
         if (!empty($cids)) {
             $_params['tax_query'] = array(array("taxonomy" => "daogou_category", "field" => "id", "terms" => $cids));
         }
         query_posts($_params);
         if ($isDaogouList) {
             _xt_widget_blog_daogou($layout);
         } else {
             if ($show == 0) {
                 echo '<ul class="xt-bd-list unstyled clearfix">';
             } else {
                 echo '<ul class="media-list clearfix">';
             }
             $_post_count = 0;
             while (have_posts()) {
                 the_post();
                 _xt_widget_blog_li($show, $_post_count);
                 $_post_count++;
             }
             echo '</ul>';
         }
         echo '</div>';
         echo $after_widget;
     }
 }
开发者ID:aspirin,项目名称:wp-xintaoke,代码行数:56,代码来源:default-page-widgets.php

示例5: get_the_category

/**
 * Retrieve post categories.
 *
 * @since 0.71
 * @uses $post
 *
 * @param int $id Optional, default to current post ID. The post ID.
 * @return array
 */
function get_the_category($id = false)
{
    $categories = get_the_terms($id, 'category');
    if (!$categories) {
        $categories = array();
    }
    $categories = array_values($categories);
    foreach (array_keys($categories) as $key) {
        _make_cat_compat($categories[$key]);
    }
    // Filter name is plural because we return alot of categories (possibly more than #13237) not just one
    return apply_filters('get_the_categories', $categories);
}
开发者ID:jawandsingh,项目名称:wordpress_with_sql_azure,代码行数:22,代码来源:category-template.php

示例6: get_categories

/**
 * Retrieve list of category objects.
 *
 * If you change the type to 'link' in the arguments, then the link categories
 * will be returned instead. Also all categories will be updated to be backwards
 * compatible with pre-2.3 plugins and themes.
 *
 * @since 2.1.0
 * @see get_terms() Type of arguments that can be changed.
 * @link http://codex.wordpress.org/Function_Reference/get_categories
 *
 * @param string|array $args Optional. Change the defaults retrieving categories.
 * @return array List of categories.
 */
function get_categories($args = '')
{
    $defaults = array('taxonomy' => 'category');
    $args = wp_parse_args($args, $defaults);
    $taxonomy = apply_filters('get_categories_taxonomy', $args['taxonomy'], $args);
    // Back compat
    if (isset($args['type']) && 'link' == $args['type']) {
        _deprecated_argument(__FUNCTION__, '3.0', '');
        $taxonomy = $args['taxonomy'] = 'link_category';
    }
    $categories = (array) get_terms($taxonomy, $args);
    foreach (array_keys($categories) as $k) {
        _make_cat_compat($categories[$k]);
    }
    return $categories;
}
开发者ID:n1ckyr0m3r0,项目名称:hacking,代码行数:30,代码来源:wp-thumb.php

示例7: get_the_category

/**
 * Retrieve post categories.
 *
 * @since 0.71
 *
 * @param int $id Optional, default to current post ID. The post ID.
 * @return array
 */
function get_the_category($id = false)
{
    $categories = get_the_terms($id, 'category');
    if (!$categories || is_wp_error($categories)) {
        $categories = array();
    }
    $categories = array_values($categories);
    foreach (array_keys($categories) as $key) {
        _make_cat_compat($categories[$key]);
    }
    /**
     * Filter the array of categories to return for a post.
     *
     * @since 3.1.0
     *
     * @param array $categories An array of categories to return for the post.
     */
    return apply_filters('get_the_categories', $categories);
}
开发者ID:ConceptHaus,项目名称:paravivir,代码行数:27,代码来源:category-template.php

示例8: get_the_category

function get_the_category($id = false)
{
    global $post, $term_cache, $blog_id;
    $id = (int) $id;
    if (!$id) {
        $id = (int) $post->ID;
    }
    $categories = get_object_term_cache($id, 'category');
    if (false === $categories) {
        $categories = wp_get_object_terms($id, 'category');
    }
    if (!empty($categories)) {
        usort($categories, '_usort_terms_by_name');
    } else {
        $categories = array();
    }
    foreach (array_keys($categories) as $key) {
        _make_cat_compat($categories[$key]);
    }
    return $categories;
}
开发者ID:helmonaut,项目名称:owb-mirror,代码行数:21,代码来源:category-template.php

示例9: get_queried_object

 /**
  * Retrieve queried object.
  *
  * If queried object is not set, then the queried object will be set from
  * the category, tag, taxonomy, posts page, single post, page, or author
  * query variable. After it is set up, it will be returned.
  *
  * @since 1.5.0
  * @access public
  *
  * @return object
  */
 public function get_queried_object()
 {
     if (isset($this->queried_object)) {
         return $this->queried_object;
     }
     $this->queried_object = null;
     $this->queried_object_id = null;
     if ($this->is_category || $this->is_tag || $this->is_tax) {
         if ($this->is_category) {
             if ($this->get('cat')) {
                 $term = get_term($this->get('cat'), 'category');
             } elseif ($this->get('category_name')) {
                 $term = get_term_by('slug', $this->get('category_name'), 'category');
             }
         } elseif ($this->is_tag) {
             if ($this->get('tag_id')) {
                 $term = get_term($this->get('tag_id'), 'post_tag');
             } elseif ($this->get('tag')) {
                 $term = get_term_by('slug', $this->get('tag'), 'post_tag');
             }
         } else {
             // For other tax queries, grab the first term from the first clause.
             $tax_query_in_and = wp_list_filter($this->tax_query->queried_terms, array('operator' => 'NOT IN'), 'NOT');
             if (!empty($tax_query_in_and)) {
                 $queried_taxonomies = array_keys($tax_query_in_and);
                 $matched_taxonomy = reset($queried_taxonomies);
                 $query = $tax_query_in_and[$matched_taxonomy];
                 if ($query['terms']) {
                     if ('term_id' == $query['field']) {
                         $term = get_term(reset($query['terms']), $matched_taxonomy);
                     } else {
                         $term = get_term_by($query['field'], reset($query['terms']), $matched_taxonomy);
                     }
                 }
             }
         }
         if (!empty($term) && !is_wp_error($term)) {
             $this->queried_object = $term;
             $this->queried_object_id = (int) $term->term_id;
             if ($this->is_category && 'category' === $this->queried_object->taxonomy) {
                 _make_cat_compat($this->queried_object);
             }
         }
     } elseif ($this->is_post_type_archive) {
         $post_type = $this->get('post_type');
         if (is_array($post_type)) {
             $post_type = reset($post_type);
         }
         $this->queried_object = get_post_type_object($post_type);
     } elseif ($this->is_posts_page) {
         $page_for_posts = get_option('page_for_posts');
         $this->queried_object = get_post($page_for_posts);
         $this->queried_object_id = (int) $this->queried_object->ID;
     } elseif ($this->is_singular && !empty($this->post)) {
         $this->queried_object = $this->post;
         $this->queried_object_id = (int) $this->post->ID;
     } elseif ($this->is_author) {
         $this->queried_object_id = (int) $this->get('author');
         $this->queried_object = get_userdata($this->queried_object_id);
     }
     return $this->queried_object;
 }
开发者ID:inpsyde,项目名称:wordpress-dev,代码行数:74,代码来源:class-wp-query.php

示例10: wp_update_category

/**
 * Aliases wp_insert_category() with minimal args.
 *
 * If you want to update only some fields of an existing category, call this
 * function with only the new values set inside $catarr.
 *
 * @since 2.0.0
 *
 * @param array $catarr The 'cat_ID' value is required. All other keys are optional.
 * @return int|bool The ID number of the new or updated Category on success. Zero or FALSE on failure.
 */
function wp_update_category($catarr)
{
    $cat_ID = (int) $catarr['cat_ID'];
    if (isset($catarr['category_parent']) && $cat_ID == $catarr['category_parent']) {
        return false;
    }
    // First, get all of the original fields
    $category = get_term($cat_ID, 'category', ARRAY_A);
    _make_cat_compat($category);
    // Escape data pulled from DB.
    $category = wp_slash($category);
    // Merge old and new fields with new fields overwriting old ones.
    $catarr = array_merge($category, $catarr);
    return wp_insert_category($catarr);
}
开发者ID:nstungxd,项目名称:F2CA5,代码行数:26,代码来源:taxonomy.php

示例11: dhwc_list_brands

/**
 * Display or retrieve the HTML list of brands.
 * 
 * @return string HTML content only if 'echo' argument is 0.
 */
function dhwc_list_brands($args = '')
{
    $defaults = array('show_option_all' => '', 'show_option_none' => __('No brands'), 'orderby' => 'name', 'order' => 'ASC', 'style' => 'list', 'show_count' => 0, 'hide_empty' => 1, 'use_desc_for_title' => 1, 'child_of' => 0, 'feed' => '', 'feed_type' => '', 'feed_image' => '', 'exclude' => '', 'exclude_tree' => '', 'current_brand' => 0, 'hierarchical' => true, 'title_li' => __('Brands'), 'echo' => 1, 'depth' => 0, 'taxonomy' => 'product_brand');
    $r = wp_parse_args($args, $defaults);
    if (!isset($r['pad_counts']) && $r['show_count'] && $r['hierarchical']) {
        $r['pad_counts'] = true;
    }
    if (true == $r['hierarchical']) {
        $r['exclude_tree'] = $r['exclude'];
        $r['exclude'] = '';
    }
    if (!isset($r['class'])) {
        $r['class'] = 'brand' == $r['taxonomy'] ? 'brands' : $r['taxonomy'];
    }
    extract($r);
    if (!taxonomy_exists($taxonomy)) {
        return false;
    }
    $brans = (array) get_terms($taxonomy, $args);
    foreach (array_keys($brans) as $k) {
        _make_cat_compat($brans[$k]);
    }
    $output = '';
    if ($title_li && 'list' == $style) {
        $output = '<li class="' . esc_attr($class) . '">' . $title_li . '<ul>';
    }
    if (empty($brans)) {
        if (!empty($show_option_none)) {
            if ('list' == $style) {
                $output .= '<li>' . $show_option_none . '</li>';
            } else {
                $output .= $show_option_none;
            }
        }
    } else {
        if (!empty($show_option_all)) {
            $posts_page = 'page' == get_option('show_on_front') && get_option('page_for_posts') ? get_permalink(get_option('page_for_posts')) : home_url('/');
            $posts_page = esc_url($posts_page);
            if ('list' == $style) {
                $output .= "<li><a href='{$posts_page}'>{$show_option_all}</a></li>";
            } else {
                $output .= "<a href='{$posts_page}'>{$show_option_all}</a>";
            }
        }
        if (empty($r['current_brand']) && is_tax()) {
            $current_term_object = get_queried_object();
            if ($current_term_object && $r['taxonomy'] === $current_term_object->taxonomy) {
                $r['current_brand'] = get_queried_object_id();
            }
        }
        if ($hierarchical) {
            $depth = $r['depth'];
        } else {
            $depth = -1;
        }
        // Flat.
        $output .= walk_category_tree($brans, $depth, $r);
    }
    if ($title_li && 'list' == $style) {
        $output .= '</ul></li>';
    }
    $output = apply_filters('dhwc_list_brands', $output, $args);
    if ($echo) {
        echo $output;
    } else {
        return $output;
    }
}
开发者ID:jmead,项目名称:trucell-cms,代码行数:73,代码来源:dhwc-brand-functions.php

示例12: get_queried_object

 /**
  * Retrieve queried object.
  *
  * If queried object is not set, then the queried object will be set from
  * the category, tag, taxonomy, posts page, single post, page, or author
  * query variable. After it is set up, it will be returned.
  *
  * @since 1.5.0
  * @access public
  *
  * @return object
  */
 function get_queried_object()
 {
     if (isset($this->queried_object)) {
         return $this->queried_object;
     }
     $this->queried_object = null;
     $this->queried_object_id = 0;
     if ($this->is_category || $this->is_tag || $this->is_tax) {
         $tax_query_in_and = wp_list_filter($this->tax_query->queries, array('operator' => 'NOT IN'), 'NOT');
         $query = reset($tax_query_in_and);
         if ('term_id' == $query['field']) {
             $term = get_term(reset($query['terms']), $query['taxonomy']);
         } else {
             $term = get_term_by($query['field'], reset($query['terms']), $query['taxonomy']);
         }
         if ($term && !is_wp_error($term)) {
             $this->queried_object = $term;
             $this->queried_object_id = (int) $term->term_id;
             if ($this->is_category) {
                 _make_cat_compat($this->queried_object);
             }
         }
     } elseif ($this->is_post_type_archive) {
         $this->queried_object = get_post_type_object($this->get('post_type'));
     } elseif ($this->is_posts_page) {
         $page_for_posts = get_option('page_for_posts');
         $this->queried_object =& get_page($page_for_posts);
         $this->queried_object_id = (int) $this->queried_object->ID;
     } elseif ($this->is_singular && !is_null($this->post)) {
         $this->queried_object = $this->post;
         $this->queried_object_id = (int) $this->post->ID;
     } elseif ($this->is_author) {
         $this->queried_object_id = (int) $this->get('author');
         $this->queried_object = get_userdata($this->queried_object_id);
     }
     return $this->queried_object;
 }
开发者ID:nunomorgadinho,项目名称:WordPress,代码行数:49,代码来源:query.php

示例13: TS_VCSC_GetTheCategoryByTax

 function TS_VCSC_GetTheCategoryByTax($id = false, $tcat = 'category')
 {
     $categories = get_the_terms($id, $tcat);
     if (!$categories || is_wp_error($categories)) {
         $categories = array();
     }
     $categories = array_values($categories);
     foreach (array_keys($categories) as $key) {
         _make_cat_compat($categories[$key]);
     }
     return apply_filters('get_the_categories', $categories);
 }
开发者ID:baochung26,项目名称:happy-c,代码行数:12,代码来源:ts_vcsc_registrations_functions.php

示例14: get_post_category

/**
 * Filter the array of categories to return for a post.
 *
 * @since 4.4.0 Added `$id` parameter.
 * @param bool|int $id ID of the post.
 * @return mixed|void
 */
function get_post_category($id = false)
{
    $categories = get_the_terms($id, 'category');
    if (!$categories || is_wp_error($categories)) {
        $categories = array();
    }
    $categories = array_values($categories);
    foreach (array_keys($categories) as $key) {
        _make_cat_compat($categories[$key]);
    }
    $category_print = '';
    if ($categories) {
        $category_print = _e('in', 'clean-blog');
        foreach ($categories as $category) {
            $category_link = get_category_link($category->cat_ID);
            // Get the URL of this category
            $category_name = $category->name;
            $category_print .= ' <a href="' . $category_link . '" title="' . $category_name . '">' . $category_name . '</a>,';
        }
        $category_print = rtrim($category_print, ',');
        // remove last comma from string
    }
    return $category_print;
}
开发者ID:Draffix,项目名称:clean-blog,代码行数:31,代码来源:functions.php

示例15: get_category

 public static function get_category($category, $output = OBJECT, $filter = 'raw')
 {
     static $caches = [];
     $cache_id = md5(json_encode(func_get_args()));
     if (isset($caches[$cache_id])) {
         return $caches[$cache_id];
     }
     $category = get_term($category, 'category', $output, $filter);
     if (is_wp_error($category)) {
         $caches[$cache_id] = $category;
         return $category;
     }
     _make_cat_compat($category);
     $caches[$cache_id] = $category;
     return $category;
 }
开发者ID:ClayMoreBoy,项目名称:wp-theme-inn2015v2,代码行数:16,代码来源:cache.php


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