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


PHP is_taxonomy_hierarchical函数代码示例

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


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

示例1: get_choices

 function get_choices($options = array())
 {
     // defaults
     $options = acf_parse_args($options, array('post_id' => 0, 's' => '', 'field_key' => ''));
     // vars
     $r = array();
     $args = array('hide_empty' => false);
     // load field
     $field = acf_get_field($options['field_key']);
     if (!$field) {
         return false;
     }
     // search
     if ($options['s']) {
         $args['search'] = $options['s'];
     }
     // filters
     $args = apply_filters('acf/fields/taxonomy/query', $args, $field, $options['post_id']);
     $args = apply_filters('acf/fields/taxonomy/query/name=' . $field['name'], $args, $field, $options['post_id']);
     $args = apply_filters('acf/fields/taxonomy/query/key=' . $field['key'], $args, $field, $options['post_id']);
     // get terms
     $terms = get_terms($field['taxonomy'], $args);
     // sort into hierachial order!
     if (is_taxonomy_hierarchical($field['taxonomy'])) {
         // get parent
         $parent = acf_maybe_get($args, 'parent', 0);
         $parent = acf_maybe_get($args, 'child_of', $parent);
         // this will fail if a search has taken place because parents wont exist
         if (empty($args['search'])) {
             $terms = _get_term_children($parent, $terms, $field['taxonomy']);
         }
     }
     /// append to r
     foreach ($terms as $term) {
         // add to json
         $r[] = array('id' => $term->term_id, 'text' => $this->get_term_title($term, $field, $options['post_id']));
     }
     // return
     return $r;
 }
开发者ID:brycefrees,项目名称:nddLive,代码行数:40,代码来源:taxonomy.php

示例2: isParentOf

 public function isParentOf($query)
 {
     $this->setupBaseInfo();
     if (!$query->is_archive || !is_taxonomy_hierarchical($this->type)) {
         return false;
     }
     $taxonomy = null;
     $term_id = null;
     if ($query->is_tax) {
         $taxonomy = $query->query_vars['taxonomy'];
         $term = get_term_by('slug', $query->query['term'], $query->query_vars['taxonomy'], OBJECT, 'raw');
         if ($term === false) {
             return false;
         }
         $term_id = $term->term_id;
     } else {
         if ($query->is_category) {
             $taxonomy = "category";
             $term_id = $query->query_vars['cat'];
         }
     }
     if ($this->type != $taxonomy) {
         return false;
     }
     $depth = 0;
     return $this->findChild($this->id, $term_id, $this->children, $depth);
 }
开发者ID:rotoballer,项目名称:emily,代码行数:27,代码来源:archive.class.php

示例3: jetpack_breadcrumbs

/**
 * Plugin Name: Site Breadcrumbs
 * Plugin URI: https://wordpress.com
 * Description: Quickly add breadcrumbs to the single view of a hierarchical post type or a hierarchical taxonomy.
 * Author: Automattic
 * Version: 1.0
 * Author URI: https://wordpress.com
 * License: GPL2 or later
 */
function jetpack_breadcrumbs()
{
    $taxonomy = is_category() ? 'category' : get_query_var('taxonomy');
    $is_taxonomy_hierarchical = is_taxonomy_hierarchical($taxonomy);
    $post_type = is_page() ? 'page' : get_query_var('post_type');
    $is_post_type_hierarchical = is_post_type_hierarchical($post_type);
    if (!($is_post_type_hierarchical || $is_taxonomy_hierarchical) || is_front_page()) {
        return;
    }
    $breadcrumb = '';
    if ($is_post_type_hierarchical) {
        $post_id = get_queried_object_id();
        $ancestors = array_reverse(get_post_ancestors($post_id));
        if ($ancestors) {
            foreach ($ancestors as $ancestor) {
                $breadcrumb .= '<span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><a href="' . esc_url(get_permalink($ancestor)) . '" itemprop="item"><span itemprop="name">' . esc_html(get_the_title($ancestor)) . '</span></a></span>';
            }
        }
        $breadcrumb .= '<span class="current-page" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><span itemprop="name">' . esc_html(get_the_title($post_id)) . '</span></span>';
    } elseif ($is_taxonomy_hierarchical) {
        $current = get_term(get_queried_object_id(), $taxonomy);
        if (is_wp_error($current)) {
            return;
        }
        if ($current->parent) {
            $breadcrumb = jetpack_get_term_parents($current->parent, $taxonomy);
        }
        $breadcrumb .= '<span class="current-category" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><span itemprop="name">' . esc_html($current->name) . '</span></span>';
    }
    $home = '<span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><a href="' . esc_url(home_url('/')) . '" class="home-link" itemprop="item" rel="home"><span itemprop="name">' . esc_html__('Home', 'jetpack') . '</span></a></span>';
    echo '<nav class="entry-breadcrumbs" itemscope itemtype="https://schema.org/BreadcrumbList">' . $home . $breadcrumb . '</nav>';
}
开发者ID:kanei,项目名称:vantuch.cz,代码行数:41,代码来源:site-breadcrumbs.php

示例4: start_el

 function start_el(&$output, $term, $depth = 0, $args = array(), $id = 0)
 {
     global $post;
     /* $args array includes:
        taxonomy
        disabled
        selected_cats
        popular_cats
        has_children
        */
     //echo '<pre>'; var_dump( $args ); echo '</pre>';
     extract($args);
     if (empty($taxonomy)) {
         $taxonomy = 'category';
     }
     $name = 'radio_tax_input[' . $taxonomy . ']';
     //get first term object
     $current_term = !empty($selected_cats) && !is_wp_error($selected_cats) ? array_pop($selected_cats) : false;
     // if no term, match the 0 "no term" option
     $current_id = $current_term ? $current_term : 0;
     //small tweak so that it works for both hierarchical and non-hierarchical tax
     $value = is_taxonomy_hierarchical($taxonomy) ? $term->term_id : $term->slug;
     $class = in_array($term->term_id, $popular_cats) ? ' class="popular-category"' : '';
     $output .= sprintf("\n" . '<li id="%1$s-%2$s" %3$s><label class="selectit"><input id="%4$s" type="radio" name="%5$s" value="%6$s" %7$s %8$s/> %9$s</label>', $taxonomy, $value, $class, "in-{$taxonomy}-{$term->term_id}", $name . '[]', esc_attr(trim($value)), checked($current_id, $term->term_id, false), disabled(empty($args['disabled']), false, false), esc_html(apply_filters('the_category', $term->name)));
 }
开发者ID:enlacee,项目名称:anb.platicom.com.pe,代码行数:25,代码来源:class.Walker_Category_Radio.php

示例5: isHierarchical

 /**
  * put your comment there...
  * 
  */
 protected function isHierarchical()
 {
     // Initialize.
     $typeParams =& $this->getTypeParams();
     // Check if post_type hierarchical.
     return is_taxonomy_hierarchical($typeParams['type']);
 }
开发者ID:JSreactor,项目名称:MarketCrater.com,代码行数:11,代码来源:taxonomy.php

示例6: form_tax_query

 /**
  * @param $filters
  * @param $operand
  *
  * @return array|null
  */
 public static function form_tax_query($filters, $operand)
 {
     if (empty($filters)) {
         return null;
     }
     $tax_query = array();
     foreach ($filters as $tax => $terms) {
         if (empty($terms)) {
             continue;
         }
         $tax_operand = 'AND';
         if ($operand == 'OR') {
             $tax_operand = 'IN';
         }
         if ('AND' === $tax_operand && is_taxonomy_hierarchical($tax)) {
             /*
              * When making and AND query on a hierarchical taxonomy where 'include_children'
              * is true (the default), WP requires all matches to have ALL child terms,
              * not just one child of each of the supplied terms. By breaking this up
              * into multiple tax queries ANDed together, you get the results that
              * are more naturally expected.
              */
             foreach ($terms as $term) {
                 $tax_query[] = array('taxonomy' => $tax, 'field' => 'id', 'terms' => array($term));
             }
         } else {
             $tax_query[] = array('taxonomy' => $tax, 'field' => 'id', 'operator' => $tax_operand, 'terms' => $terms);
         }
     }
     if (count($tax_query) > 1) {
         $tax_query['relation'] = $operand;
     }
     return $tax_query;
 }
开发者ID:acutedeveloper,项目名称:havering-intranet-development,代码行数:40,代码来源:Widgets.php

示例7: wpcf7_flamingo_add_channel

function wpcf7_flamingo_add_channel($slug, $name = '')
{
    if (!class_exists('Flamingo_Inbound_Message')) {
        return false;
    }
    $parent = term_exists('contact-form-7', Flamingo_Inbound_Message::channel_taxonomy);
    if (!$parent) {
        $parent = wp_insert_term(__('Contact Form 7', 'contact-form-7'), Flamingo_Inbound_Message::channel_taxonomy, array('slug' => 'contact-form-7'));
        if (is_wp_error($parent)) {
            return false;
        }
    }
    $parent = (int) $parent['term_id'];
    if (!is_taxonomy_hierarchical(Flamingo_Inbound_Message::channel_taxonomy)) {
        // backward compat for Flamingo 1.0.4 and lower
        return $parent;
    }
    if (empty($name)) {
        $name = $slug;
    }
    $channel = term_exists($slug, Flamingo_Inbound_Message::channel_taxonomy, $parent);
    if (!$channel) {
        $channel = wp_insert_term($name, Flamingo_Inbound_Message::channel_taxonomy, array('slug' => $slug, 'parent' => $parent));
        if (is_wp_error($channel)) {
            return false;
        }
    }
    return (int) $channel['term_id'];
}
开发者ID:aim-web-projects,项目名称:kobe-chuoh,代码行数:29,代码来源:flamingo.php

示例8: get_terms_for_site

 /**
  * Return the terms for the given type.
  *
  * @param int $site_id Blog ID.
  *
  * @return array
  */
 public function get_terms_for_site($site_id)
 {
     $out = [];
     switch_to_blog($site_id);
     $taxonomy_object = get_taxonomy($this->taxonomy_name);
     if (!current_user_can($taxonomy_object->cap->edit_terms)) {
         $terms = [];
     } else {
         $terms = get_terms($this->taxonomy_name, ['hide_empty' => FALSE]);
     }
     foreach ($terms as $term) {
         if (is_taxonomy_hierarchical($this->taxonomy_name)) {
             $ancestors = get_ancestors($term->term_id, $this->taxonomy_name);
             if (!empty($ancestors)) {
                 foreach ($ancestors as $ancestor) {
                     $parent_term = get_term($ancestor, $this->taxonomy_name);
                     $term->name = $parent_term->name . '/' . $term->name;
                 }
             }
         }
         $out[$term->term_taxonomy_id] = esc_html($term->name);
     }
     restore_current_blog();
     uasort($out, 'strcasecmp');
     return $out;
 }
开发者ID:inpsyde,项目名称:multilingual-press,代码行数:33,代码来源:Mlp_Term_Translation_Presenter.php

示例9: widget

 function widget($args, $instance)
 {
     global $wp_query;
     extract($args);
     $current_taxonomy = $this->_get_current_taxonomy($instance);
     if (!empty($instance['title'])) {
         $title = $instance['title'];
     } else {
         if ('post_tag' == $current_taxonomy) {
             $title = __('Tags');
         } else {
             $tax = get_taxonomy($current_taxonomy);
             $title = $tax->labels->name;
         }
     }
     $use_desc_for_title = isset($instance['use_desc_for_title']) ? $instance['use_desc_for_title'] : true;
     $count = isset($instance['count']) ? $instance['count'] : false;
     $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     $current_term = false;
     $current_term_id = $current_post_id = 0;
     if (suwp::is_tax($current_taxonomy)) {
         $current_term = $wp_query->get_queried_object();
         $current_term_id = $wp_query->get_queried_object_id();
         $title = $current_term->name;
     } elseif (is_singular()) {
         $current_post_id = $wp_query->get_queried_object_id();
         $post_terms = get_the_terms($current_post_id, $current_taxonomy);
         if (is_array($post_terms) && count($post_terms)) {
             $current_term = reset($post_terms);
             $current_term_id = $current_term->term_id;
             $title = $current_term->name;
         }
     }
     $term_args = array('taxonomy' => $current_taxonomy, 'orderby' => 'name', 'show_count' => $count ? '1' : '0', 'hierarchical' => '0', 'title_li' => '', 'parent' => $current_term_id, 'show_option_none' => false, 'use_desc_for_title' => $use_desc_for_title ? '1' : '0', 'echo' => false);
     $category_output = $post_output = '';
     if (!$current_term || is_taxonomy_hierarchical($current_taxonomy)) {
         $category_output = wp_list_categories($term_args);
     }
     if ($current_term) {
         $child_posts = get_posts(array('taxonomy' => $current_taxonomy, 'term' => $current_term->slug, 'numberposts' => 5));
         foreach ($child_posts as $child_post) {
             $css_class = '';
             if ($child_post->ID == $current_post_id) {
                 $css_class = 'current_post_item';
             }
             $post_output .= "\n\t\t\t<li class=\"" . $css_class . '"><a href="' . get_permalink($child_post->ID) . '" title="' . esc_attr(wp_strip_all_tags(apply_filters('the_title', $child_post->post_title, $child_post->ID))) . '">' . apply_filters('the_title', $child_post->post_title, $child_post->ID) . "</a></li>\n";
         }
     }
     if ($category_output || $post_output) {
         echo $before_widget;
         if ($title) {
             echo $before_title . $title . $after_title;
         }
         echo "\n\t\t<ul>\n";
         echo $category_output;
         echo $post_output;
         echo "\n\t\t</ul>\n";
         echo $after_widget;
     }
 }
开发者ID:grantschulte,项目名称:suna-wordpress,代码行数:60,代码来源:widgets.php

示例10: get_markup

 public function get_markup()
 {
     $walker = new WCMF_walker();
     foreach ($this->taxonomies as $tax) {
         wp_dropdown_categories(array('taxonomy' => $tax, 'hide_if_empty' => true, 'show_option_all' => sprintf(get_taxonomy($tax)->labels->all_items), 'hide_empty' => true, 'hierarchical' => is_taxonomy_hierarchical($tax), 'show_count' => true, 'orderby' => 'name', 'selected' => '0' !== get_query_var($tax) ? get_query_var($tax) : false, 'name' => $tax, 'id' => $tax, 'walker' => $walker));
     }
 }
开发者ID:nengineer,项目名称:WP-Anatomy,代码行数:7,代码来源:filter.class.php

示例11: wplb_get_taxonomies_by_post_type

 function wplb_get_taxonomies_by_post_type($post_types = array('post'))
 {
     if (!empty($post_types)) {
         if (is_string($post_types)) {
             $post_types = explode(',', $post_types);
         }
         foreach ($post_types as $post_type) {
             $post_type_object = get_post_type_object($post_type);
             $taxonomies = get_object_taxonomies($post_type);
             if ($taxonomies) {
                 foreach ($taxonomies as $taxonomy) {
                     if (!is_taxonomy_hierarchical($taxonomy)) {
                         continue;
                     }
                     $terms = get_terms($taxonomy, array('hide_empty' => false));
                     if ($terms) {
                         foreach ($terms as $term) {
                             $returns[$term->term_id] = $term->name;
                         }
                     }
                 }
             }
         }
     }
     return $returns;
 }
开发者ID:huuhabn,项目名称:wplb-widgets-total,代码行数:26,代码来源:wplb-function.php

示例12: act_save_item

 public static function act_save_item($term_id, $tt_id, $taxonomy)
 {
     if (!in_array($taxonomy, pp_get_enabled_taxonomies())) {
         if (!empty($_REQUEST['pp_enable_taxonomy'])) {
             $enabled_taxonomies = get_option('pp_enabled_taxonomies');
             $enabled_taxonomies[$taxonomy] = '1';
             update_option('pp_enabled_taxonomies', $enabled_taxonomies);
         }
         return;
     }
     static $saved_terms;
     if (!isset($saved_terms)) {
         $saved_terms = array();
     }
     // so this filter doesn't get called by hook AND internally
     if (isset($saved_terms[$taxonomy][$tt_id])) {
         return;
     }
     // parent settings can affect the auto-assignment of propagating exceptions
     $set_parent = is_taxonomy_hierarchical($taxonomy) && !empty($_REQUEST['parent']) ? (int) $_REQUEST['parent'] : 0;
     if ($set_parent < 0) {
         $set_parent = 0;
     }
     $saved_terms[$taxonomy][$tt_id] = 1;
     // Determine whether this object is new (first time this PP filter has run for it, though the object may already be inserted into db)
     $last_parent = 0;
     if (!($last_parents = get_option("pp_last_{$taxonomy}_parents"))) {
         $last_parents = array();
     }
     if (!isset($last_parents[$tt_id])) {
         $is_new = true;
         $last_parents = array();
     } else {
         $is_new = false;
     }
     if (isset($last_parents[$tt_id])) {
         $last_parent = $last_parents[$tt_id];
     }
     if ($set_parent != $last_parent && ($set_parent || $last_parent)) {
         $last_parents[$tt_id] = $set_parent;
         update_option("pp_last_{$taxonomy}_parents", $last_parents);
     }
     $exceptions_customized = false;
     if (!$is_new) {
         if ($custom_exc_objects = get_option("pp_custom_{$taxonomy}")) {
             $exceptions_customized = isset($custom_exc_objects[$tt_id]);
         }
     }
     global $typenow;
     require_once dirname(__FILE__) . '/item-save_pp.php';
     $args = compact('is_new', 'set_parent', 'last_parent', 'disallow_manual_entry');
     $args['via_item_type'] = $taxonomy;
     PP_ItemSave::item_update_process_exceptions('term', 'post', $tt_id, $args);
     do_action('pp_update_item_exceptions', 'term', $tt_id, $args);
 }
开发者ID:severnrescue,项目名称:web,代码行数:55,代码来源:term-save_pp.php

示例13: __construct

 public function __construct($element_type, $root = false)
 {
     global $sitepress;
     $this->taxonomy = $element_type;
     $this->root_trid = $root;
     $this->tree = false;
     /* If accidentally passed a non-hierarchical taxonomy, we cannot create a tree for it. */
     if (is_taxonomy_hierarchical($element_type) && $sitepress->get_option('sync_taxonomy_parents')) {
         $this->tree = $this->get_all_elements($element_type);
     }
 }
开发者ID:Calraiser,项目名称:flux,代码行数:11,代码来源:wpml-translation-tree.class.php

示例14: of_cme_supported_taxonomies

/**
* Get supported taxonomies
*
* @since 0.4.0
*/
function of_cme_supported_taxonomies()
{
    $taxes = get_taxonomies();
    $results = array();
    foreach ($taxes as $tax) {
        if (is_taxonomy_hierarchical($tax)) {
            $results[] = $tax;
        }
    }
    return $results;
}
开发者ID:lytranuit,项目名称:wordpress,代码行数:16,代码来源:helper-functions.php

示例15: get_terms_html

function get_terms_html($id, $taxonomy, $args = [])
{
    if (empty($id) || !is_int($id) || empty($taxonomy) || !is_taxonomy_hierarchical($taxonomy) || empty($args)) {
        return;
    }
    $html = [];
    if ($terms = get_terms($args)) {
        foreach ($terms as $term) {
            $html[] = sprintf('<span class="p-category"><a href="%s" rel="tag">%s</a></span>', get_term_link($term), $term->name);
        }
    }
    return $html;
}
开发者ID:synapticism,项目名称:ubik,代码行数:13,代码来源:terms.php


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