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


PHP acf_get_taxonomies函数代码示例

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


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

示例1: render_field_settings

 function render_field_settings($field)
 {
     // Add option to select taxonomy used for field
     acf_render_field_setting($field, array('label' => __('User Taxonomy', 'acf'), 'instructions' => __('Select the taxonomy to be displayed', 'acf'), 'type' => 'select', 'name' => 'taxonomy', 'choices' => acf_get_taxonomies()));
     // Allow field to not be set.
     acf_render_field_setting($field, array('label' => __('Allow Null', 'acf'), 'instructions' => '', 'type' => 'true_false', 'name' => 'allow_null'));
 }
开发者ID:bonnerl,项目名称:acf-user-taxonomy,代码行数:7,代码来源:acf-user-taxonomy-v5.php

示例2: create_options

    function create_options($field)
    {
        $field = array_merge($this->defaults, $field);
        // key is needed in the field names to correctly save the data
        $key = $field['name'];
        // Create Field Options HTML
        ?>
<tr class="field_option field_option_<?php 
        echo $this->name;
        ?>
">
	<td class="label">
		<label><?php 
        _e("User Taxonomy", 'acf');
        ?>
</label>
		<p class="description"><?php 
        _e("Select the taxonomy to be displayed", 'acf');
        ?>
</p>
	</td>
	<td>
		<?php 
        do_action('acf/create_field', array('type' => 'select', 'name' => 'fields[' . $key . '][taxonomy]', 'value' => $field['taxonomy'], 'choices' => acf_get_taxonomies()));
        ?>
	</td>
</tr>
<tr class="field_option field_option_<?php 
        echo $this->name;
        ?>
">
	<td class="label">
		<label><?php 
        _e("Allow Null", 'acf');
        ?>
</label>
		<p class="description"></p>
	</td>
	<td>
		<?php 
        do_action('acf/create_field', array('type' => 'true_false', 'name' => 'fields[' . $key . '][allow_null]', 'value' => $field['allow_null']));
        ?>
	</td>
</tr>
		<?php 
    }
开发者ID:bonnerl,项目名称:acf-user-taxonomy,代码行数:46,代码来源:acf-user-taxonomy-v4.php

示例3: render_location_value


//.........这里部分代码省略.........
             if (!empty($terms)) {
                 $choices = array_pop($terms);
             }
             break;
         case "post_format":
             $choices = get_post_format_strings();
             break;
         case "post_status":
             $choices = array('publish' => __('Publish', 'acf'), 'pending' => __('Pending Review', 'acf'), 'draft' => __('Draft', 'acf'), 'future' => __('Future', 'acf'), 'private' => __('Private', 'acf'), 'inherit' => __('Revision', 'acf'), 'trash' => __('Trash', 'acf'));
             break;
         case "post_taxonomy":
             $choices = acf_get_taxonomy_terms();
             // unset post_format
             if (isset($choices['post_format'])) {
                 unset($choices['post_format']);
             }
             break;
             /*
              *  Page
              */
         /*
          *  Page
          */
         case "page":
             // get posts grouped by post type
             $groups = acf_get_posts(array('post_type' => 'page'));
             if (!empty($groups)) {
                 foreach (array_keys($groups) as $group_title) {
                     // vars
                     $posts = acf_extract_var($groups, $group_title);
                     // override post data
                     foreach (array_keys($posts) as $post_id) {
                         // update
                         $posts[$post_id] = acf_get_post_title($posts[$post_id]);
                     }
                     // append to $choices
                     $choices = $posts;
                 }
             }
             break;
         case "page_type":
             $choices = array('front_page' => __("Front Page", 'acf'), 'posts_page' => __("Posts Page", 'acf'), 'top_level' => __("Top Level Page (parent of 0)", 'acf'), 'parent' => __("Parent Page (has children)", 'acf'), 'child' => __("Child Page (has parent)", 'acf'));
             break;
         case "page_parent":
             // refer to "page"
             break;
         case "page_template":
             $choices = array('default' => __("Default Template", 'acf'));
             $templates = get_page_templates();
             foreach ($templates as $k => $v) {
                 $choices[$v] = $k;
             }
             break;
             /*
              *  User
              */
         /*
          *  User
          */
         case "user_role":
             global $wp_roles;
             $choices = array_merge(array('all' => __('All', 'acf')), $wp_roles->get_names());
             break;
         case "user_form":
             $choices = array('all' => __('All', 'acf'), 'edit' => __('Add / Edit', 'acf'), 'register' => __('Register', 'acf'));
             break;
             /*
              *  Forms
              */
         /*
          *  Forms
          */
         case "attachment":
             $choices = array('all' => __('All', 'acf'));
             break;
         case "taxonomy":
             $choices = array_merge(array('all' => __('All', 'acf')), acf_get_taxonomies());
             // unset post_format
             if (isset($choices['post_format'])) {
                 unset($choices['post_format']);
             }
             break;
         case "comment":
             $choices = array('all' => __('All', 'acf'));
             break;
         case "widget":
             global $wp_widget_factory;
             $choices = array('all' => __('All', 'acf'));
             if (!empty($wp_widget_factory->widgets)) {
                 foreach ($wp_widget_factory->widgets as $widget) {
                     $choices[$widget->id_base] = $widget->name;
                 }
             }
             break;
     }
     // allow custom location rules
     $choices = apply_filters('acf/location/rule_values/' . $options['param'], $choices);
     // create field
     acf_render_field(array('type' => 'select', 'prefix' => "acf_field_group[location][{$options['group_id']}][{$options['rule_id']}]", 'name' => 'value', 'value' => $options['value'], 'choices' => $choices));
 }
开发者ID:eea76,项目名称:hammer,代码行数:101,代码来源:field-group.php

示例4: render_field_settings

 function render_field_settings($field)
 {
     // default_value
     acf_render_field_setting($field, array('label' => __('Taxonomy', 'acf'), 'type' => 'select', 'name' => 'taxonomy', 'choices' => acf_get_taxonomies()));
     // field_type
     acf_render_field_setting($field, array('label' => __('Field Type', 'acf'), 'instructions' => '', 'type' => 'select', 'name' => 'field_type', 'optgroup' => true, 'choices' => array(__("Multiple Values", 'acf') => array('checkbox' => __('Checkbox', 'acf'), 'multi_select' => __('Multi Select', 'acf')), __("Single Value", 'acf') => array('radio' => __('Radio Buttons', 'acf'), 'select' => __('Select', 'acf')))));
     // allow_null
     acf_render_field_setting($field, array('label' => __('Allow Null?', 'acf'), 'instructions' => '', 'type' => 'radio', 'name' => 'allow_null', 'choices' => array(1 => __("Yes", 'acf'), 0 => __("No", 'acf')), 'layout' => 'horizontal'));
     // allow_null
     acf_render_field_setting($field, array('label' => __('Load & Save Terms to Post', 'acf'), 'instructions' => '', 'type' => 'true_false', 'name' => 'load_save_terms', 'message' => __("Load value based on the post's terms and update the post's terms on save", 'acf')));
     // return_format
     acf_render_field_setting($field, array('label' => __('Return Value', 'acf'), 'instructions' => '', 'type' => 'radio', 'name' => 'return_format', 'choices' => array('object' => __("Term Object", 'acf'), 'id' => __("Term ID", 'acf')), 'layout' => 'horizontal'));
 }
开发者ID:mariussunde,项目名称:Sn-hetta-Designmanual-WP-Theme,代码行数:13,代码来源:taxonomy.php

示例5: acf_get_pretty_taxonomies

function acf_get_pretty_taxonomies($taxonomies = array())
{
    // get post types
    if (empty($taxonomies)) {
        // get all custom post types
        $taxonomies = acf_get_taxonomies();
    }
    // get labels
    $ref = array();
    $r = array();
    foreach (array_keys($taxonomies) as $i) {
        // vars
        $taxonomy = acf_extract_var($taxonomies, $i);
        $obj = get_taxonomy($taxonomy);
        $name = $obj->labels->singular_name;
        // append to r
        $r[$taxonomy] = $name;
        // increase counter
        if (!isset($ref[$name])) {
            $ref[$name] = 0;
        }
        $ref[$name]++;
    }
    // get slugs
    foreach (array_keys($r) as $i) {
        // vars
        $taxonomy = $r[$i];
        if ($ref[$taxonomy] > 1) {
            $r[$i] .= ' (' . $i . ')';
        }
    }
    // return
    return $r;
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:34,代码来源:api-helpers.php

示例6: render_field

        function render_field($field)
        {
            // vars
            $values = array();
            $atts = array('id' => $field['id'], 'class' => "acf-relationship {$field['class']}", 'data-min' => $field['min'], 'data-max' => $field['max'], 'data-s' => '', 'data-post_type' => '', 'data-taxonomy' => '', 'data-paged' => 1);
            // Lang
            if (defined('ICL_LANGUAGE_CODE')) {
                $atts['data-lang'] = ICL_LANGUAGE_CODE;
            }
            // data types
            $field['post_type'] = acf_force_type_array($field['post_type']);
            $field['taxonomy'] = acf_force_type_array($field['taxonomy']);
            // post_types
            $post_types = array();
            if (!empty($field['post_type'])) {
                $post_types = $field['post_type'];
            } else {
                $post_types = acf_get_post_types();
            }
            $post_types = acf_get_pretty_post_types($post_types);
            // taxonomies
            $taxonomies = array();
            if (!empty($field['taxonomy'])) {
                // get the field's terms
                $term_groups = acf_force_type_array($field['taxonomy']);
                $term_groups = acf_decode_taxonomy_terms($term_groups);
                // update taxonomies
                $taxonomies = array_keys($term_groups);
            } elseif (!empty($field['post_type'])) {
                // loop over post types and find connected taxonomies
                foreach ($field['post_type'] as $post_type) {
                    $post_taxonomies = get_object_taxonomies($post_type);
                    // bail early if no taxonomies
                    if (empty($post_taxonomies)) {
                        continue;
                    }
                    foreach ($post_taxonomies as $post_taxonomy) {
                        if (!in_array($post_taxonomy, $taxonomies)) {
                            $taxonomies[] = $post_taxonomy;
                        }
                    }
                }
            } else {
                $taxonomies = acf_get_taxonomies();
            }
            // terms
            $term_groups = acf_get_taxonomy_terms($taxonomies);
            // update $term_groups with specific terms
            if (!empty($field['taxonomy'])) {
                foreach (array_keys($term_groups) as $taxonomy) {
                    foreach (array_keys($term_groups[$taxonomy]) as $term) {
                        if (!in_array($term, $field['taxonomy'])) {
                            unset($term_groups[$taxonomy][$term]);
                        }
                    }
                }
            }
            // width for select filters
            $width = array('search' => 0, 'post_type' => 0, 'taxonomy' => 0);
            if (!empty($field['filters'])) {
                $width = array('search' => 50, 'post_type' => 25, 'taxonomy' => 25);
                foreach (array_keys($width) as $k) {
                    if (!in_array($k, $field['filters'])) {
                        $width[$k] = 0;
                    }
                }
                // search
                if ($width['search'] == 0) {
                    $width['post_type'] = $width['post_type'] == 0 ? 0 : 50;
                    $width['taxonomy'] = $width['taxonomy'] == 0 ? 0 : 50;
                }
                // post_type
                if ($width['post_type'] == 0) {
                    $width['taxonomy'] = $width['taxonomy'] == 0 ? 0 : 50;
                }
                // taxonomy
                if ($width['taxonomy'] == 0) {
                    $width['post_type'] = $width['post_type'] == 0 ? 0 : 50;
                }
                // search
                if ($width['post_type'] == 0 && $width['taxonomy'] == 0) {
                    $width['search'] = $width['search'] == 0 ? 0 : 100;
                }
            }
            ?>
<div <?php 
            acf_esc_attr_e($atts);
            ?>
>
	
	<div class="acf-hidden">
		<input type="hidden" name="<?php 
            echo $field['name'];
            ?>
" value="" />
	</div>
	
	<?php 
            if ($width['search'] > 0 || $width['post_type'] > 0 || $width['taxonomy'] > 0) {
                ?>
//.........这里部分代码省略.........
开发者ID:quangnpd,项目名称:jobshop_web,代码行数:101,代码来源:relationship.php

示例7: render_field_settings

 function render_field_settings($field)
 {
     // default_value
     acf_render_field_setting($field, array('label' => __('Taxonomy', 'acf'), 'instructions' => __('Select the taxonomy to be displayed', 'acf'), 'type' => 'select', 'name' => 'taxonomy', 'choices' => acf_get_taxonomies()));
     // field_type
     acf_render_field_setting($field, array('label' => __('Appearance', 'acf'), 'instructions' => __('Select the appearance of this field', 'acf'), 'type' => 'select', 'name' => 'field_type', 'optgroup' => true, 'choices' => array(__("Multiple Values", 'acf') => array('checkbox' => __('Checkbox', 'acf'), 'multi_select' => __('Multi Select', 'acf')), __("Single Value", 'acf') => array('radio' => __('Radio Buttons', 'acf'), 'select' => __('Select', 'acf')))));
     // allow_null
     acf_render_field_setting($field, array('label' => __('Allow Null?', 'acf'), 'instructions' => '', 'type' => 'radio', 'name' => 'allow_null', 'choices' => array(1 => __("Yes", 'acf'), 0 => __("No", 'acf')), 'layout' => 'horizontal'));
     // add_term
     acf_render_field_setting($field, array('label' => __('Create Terms', 'acf'), 'instructions' => __('Allow new terms to be created whilst editing', 'acf'), 'type' => 'radio', 'name' => 'add_term', 'choices' => array(1 => __("Yes", 'acf'), 0 => __("No", 'acf')), 'layout' => 'horizontal'));
     // load_save_terms
     acf_render_field_setting($field, array('label' => __('Sync Terms', 'acf'), 'instructions' => __('Connect selected terms to the post', 'acf'), 'type' => 'radio', 'name' => 'load_save_terms', 'choices' => array(1 => __("Yes", 'acf'), 0 => __("No", 'acf')), 'layout' => 'horizontal'));
     // return_format
     acf_render_field_setting($field, array('label' => __('Return Value', 'acf'), 'instructions' => '', 'type' => 'radio', 'name' => 'return_format', 'choices' => array('object' => __("Term Object", 'acf'), 'id' => __("Term ID", 'acf')), 'layout' => 'horizontal'));
 }
开发者ID:shelbyneilsmith,项目名称:wptools,代码行数:15,代码来源:taxonomy.php

示例8: elseif

    } elseif (!empty($field['post_type'])) {
        // loop over post types and find connected taxonomies
        foreach ($field['post_type'] as $post_type) {
            $post_taxonomies = get_object_taxonomies($post_type);
            // bail early if no taxonomies
            if (empty($post_taxonomies)) {
                continue;
            }
            foreach ($post_taxonomies as $post_taxonomy) {
                if (!in_array($post_taxonomy, $taxonomies)) {
                    $taxonomies[] = $post_taxonomy;
                }
            }
        }
    } else {
        $taxonomies = acf_get_taxonomies();
    }
    // terms
    $term_groups = acf_get_taxonomy_terms($taxonomies);
    // update $term_groups with specific terms
    if (!empty($field['taxonomy'])) {
        foreach (array_keys($term_groups) as $taxonomy) {
            foreach (array_keys($term_groups[$taxonomy]) as $term) {
                if (!in_array($term, $field['taxonomy'])) {
                    unset($term_groups[$taxonomy][$term]);
                }
            }
        }
    }
}
// end taxonomy filter
开发者ID:NiviJah,项目名称:acf-api-fields,代码行数:31,代码来源:relationship.php

示例9: render_location_value


//.........这里部分代码省略.........
              *  Page
              */
         /*
          *  Page
          */
         case "page":
             // get posts grouped by post type
             $groups = acf_get_grouped_posts(array('post_type' => 'page'));
             if (!empty($groups)) {
                 foreach (array_keys($groups) as $group_title) {
                     // vars
                     $posts = acf_extract_var($groups, $group_title);
                     // override post data
                     foreach (array_keys($posts) as $post_id) {
                         // update
                         $posts[$post_id] = acf_get_post_title($posts[$post_id]);
                     }
                     // append to $choices
                     $choices = $posts;
                 }
             }
             break;
         case "page_type":
             $choices = array('front_page' => __("Front Page", 'acf'), 'posts_page' => __("Posts Page", 'acf'), 'top_level' => __("Top Level Page (no parent)", 'acf'), 'parent' => __("Parent Page (has children)", 'acf'), 'child' => __("Child Page (has parent)", 'acf'));
             break;
         case "page_parent":
             // refer to "page"
             break;
         case "page_template":
             // vars
             $templates = wp_get_theme()->get_page_templates();
             $default = apply_filters('default_page_template_title', __('Default Template', 'acf'));
             // merge
             $choices = array_merge(array('default' => $default), $templates);
             break;
             /*
              *  User
              */
         /*
          *  User
          */
         case "current_user":
             // viewing
             $choices = array('logged_in' => __('Logged in', 'acf'), 'viewing_front' => __('Viewing front end', 'acf'), 'viewing_back' => __('Viewing back end', 'acf'));
             break;
         case "current_user_role":
             // global
             global $wp_roles;
             // specific roles
             $choices = $wp_roles->get_names();
             // multi-site
             if (is_multisite()) {
                 $choices = array_merge(array('super_admin' => __('Super Admin', 'acf')), $choices);
             }
             break;
         case "user_role":
             global $wp_roles;
             $choices = array_merge(array('all' => __('All', 'acf')), $wp_roles->get_names());
             break;
         case "user_form":
             $choices = array('all' => __('All', 'acf'), 'edit' => __('Add / Edit', 'acf'), 'register' => __('Register', 'acf'));
             break;
             /*
              *  Forms
              */
         /*
          *  Forms
          */
         case "attachment":
             $choices = array('all' => __('All', 'acf'));
             break;
         case "taxonomy":
             $choices = array_merge(array('all' => __('All', 'acf')), acf_get_taxonomies());
             // unset post_format
             if (isset($choices['post_format'])) {
                 unset($choices['post_format']);
             }
             break;
         case "comment":
             // vars
             $choices = array('all' => __('All', 'acf'));
             // append post types
             $choices = array_merge($choices, acf_get_pretty_post_types());
             // end
             break;
         case "widget":
             global $wp_widget_factory;
             $choices = array('all' => __('All', 'acf'));
             if (!empty($wp_widget_factory->widgets)) {
                 foreach ($wp_widget_factory->widgets as $widget) {
                     $choices[$widget->id_base] = $widget->name;
                 }
             }
             break;
     }
     // allow custom location rules
     $choices = apply_filters('acf/location/rule_values/' . $options['param'], $choices);
     // create field
     acf_render_field(array('type' => 'select', 'prefix' => "acf_field_group[location][{$options['group_id']}][{$options['rule_id']}]", 'name' => 'value', 'value' => $options['value'], 'choices' => $choices));
 }
开发者ID:rmikeska,项目名称:ushipnetwork,代码行数:101,代码来源:field-group.php


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