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

PHP get_taxonomy_labels函数代码示例

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

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



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

示例1: new_duplicated_terms_filter

function new_duplicated_terms_filter($post_ids, $duplicates_only = true)
{
    global $wpdb, $sitepress, $wpml_admin_notices;
    require_once ICL_PLUGIN_PATH . '/inc/taxonomy-term-translation/wpml-term-hierarchy-duplication.class.php';
    $hier_dupl = new WPML_Term_Hierarchy_Duplication($wpdb, $sitepress);
    $taxonomies = $hier_dupl->duplicates_require_sync($post_ids, $duplicates_only);
    if ((bool) $taxonomies) {
        $text = __('<p>Some taxonomy terms are out of sync between languages. This means that content in some languages will not have the correct tags or categories.</p>
			 <p>In order to synchronize the taxonomies, you need to go over each of them from the following list and click the "Update taxonomy hierarchy" button.</p>', 'wpml-translation-management');
        $collapsed = 'Taxonomy sync problem';
        foreach ($taxonomies as $taxonomy) {
            $text .= '<p><a href="admin.php?page=' . ICL_PLUGIN_FOLDER . '/menu/taxonomy-translation.php&taxonomy=' . $taxonomy . '&sync=1">' . get_taxonomy_labels(get_taxonomy($taxonomy))->name . '</a></p>';
        }
        $text .= '<p align="right"><a target="_blank" href="https://wpml.org/documentation/getting-started-guide/translating-post-categories-and-custom-taxonomies/#synchronizing-hierarchical-taxonomies">Help about translating taxonomy >></a></p>';
        $notice = new WPML_Notice('wpml-taxonomy-hierarchy-sync', $text, 'wpml-core');
        $notice->set_css_class_types('info');
        $notice->set_collapsed_text($collapsed);
        $notice->set_hideable(false);
        $notice->set_dismissible(false);
        $notice->set_collapsable(true);
        $wpml_admin_notices->add_notice($notice);
    } else {
        remove_taxonomy_hierarchy_message();
    }
}
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:25,代码来源:wpml-private-actions.php


示例2: testFilterEventCategoryLabel

 function testFilterEventCategoryLabel()
 {
     add_filter('eventorganiser_register_taxonomy_event-category', array($this, '_filterCatLabels'));
     eventorganiser_create_event_taxonomies();
     remove_filter('eventorganiser_register_taxonomy_event-category', array($this, '_filterCatLabels'));
     $tax = get_taxonomy('event-category');
     $tax_labels = get_taxonomy_labels($tax);
     $this->assertEquals('Event Types', $tax_labels->name);
 }
开发者ID:Borgoroth,项目名称:Event-Organiser,代码行数:9,代码来源:taxonomyTest.php


示例3: setupRender

 public function setupRender(\WP_Post $post, array $box, \stdClass $taxonomy)
 {
     $labels = get_taxonomy_labels($taxonomy);
     $renderSettings = ['name' => 'tax_input[' . esc_attr($taxonomy->name) . ']', 'delimiter' => _x(',', 'tag delimiter'), 'options' => $this->get_options($post, $box, $taxonomy), 'items' => $this->get_items($post, $box, $taxonomy), 'disabled' => !current_user_can($taxonomy->cap->assign_terms)] + $this->settings;
     if (value($renderSettings, 'label') === true) {
         $renderSettings['label'] = $labels->{value($renderSettings, 'multiple', false) ? "singular_name" : "name"};
     }
     $renderSettings = apply_filters('tf_setup_render', $renderSettings, $post, $box, $taxonomy);
     return apply_filters(sprintf('tf_%s_setup_render', $taxonomy->name), $renderSettings, $post, $box, $taxonomy);
 }
开发者ID:edygar,项目名称:wp-extensions,代码行数:10,代码来源:taxonomy-metabox.php


示例4: wpml_new_duplicated_terms_filter

function wpml_new_duplicated_terms_filter($post_ids, $duplicates_only = true)
{
    require_once ICL_PLUGIN_PATH . '/inc/taxonomy-term-translation/wpml-term-hierarchy-duplication.class.php';
    $hier_dupl = new WPML_Term_Hierarchy_Duplication();
    $taxonomies = $hier_dupl->duplicates_require_sync($post_ids, $duplicates_only);
    if ((bool) $taxonomies) {
        $text = __("The posts you just saved led to the creation of new hierarchical terms.\nTheir hierarchical relationship to one another is not yet synchronized with the original post's terms for the following taxonomies:", 'wpml-translation-management');
        $text = '<p>' . $text . '</p>';
        foreach ($taxonomies as $taxonomy) {
            $text .= '<p><a href="admin.php?page=' . ICL_PLUGIN_FOLDER . '/menu/taxonomy-translation.php&taxonomy=' . $taxonomy . '&sync=1">' . get_taxonomy_labels(get_taxonomy($taxonomy))->name . '</a></p>';
        }
        $message_args = array('id' => 'duplication-tm-dashboard-notification', 'text' => $text, 'type' => 'information', 'group' => 'duplication-notification', 'admin_notice' => true, 'show_once' => true, 'hide_per_user' => true);
        ICL_AdminNotifier::add_message($message_args);
    }
}
开发者ID:pcuervo,项目名称:odc,代码行数:15,代码来源:wpml-private-actions.php


示例5: register

 /**
  * Registers the taxonomy.
  *
  * If the taxonomy already exists, some of the arguments will be merged into the existing taxonomy object.
  *
  * @since 0.5.0
  */
 public function register()
 {
     if ($this->registered) {
         return;
     }
     if (!$this->is_already_added()) {
         $_taxonomy_args = $this->args;
         unset($_taxonomy_args['title']);
         unset($_taxonomy_args['singular_title']);
         unset($_taxonomy_args['title_gender']);
         unset($_taxonomy_args['messages']);
         unset($_taxonomy_args['help']);
         $_taxonomy_args['label'] = $this->args['title'];
         $taxonomy_args = array();
         foreach ($_taxonomy_args as $key => $value) {
             if (null !== $value) {
                 $taxonomy_args[$key] = $value;
             }
         }
         register_taxonomy($this->slug, null, $taxonomy_args);
     } else {
         // merge several properties into existing taxonomy
         global $wp_taxonomies;
         if ($this->args['labels']) {
             // merge the slug as $name into the arguments (required for `get_taxonomy_labels()`)
             $wp_taxonomies[$this->slug]->labels = get_taxonomy_labels((object) array_merge($this->args, array('name' => $this->slug)));
             $wp_taxonomies[$this->slug]->label = $wp_taxonomies[$this->slug]->labels->name;
         }
     }
     if (wpptd_supports_termmeta()) {
         add_action('wpptd_add_term_meta_boxes_' . $this->slug, array($this, 'add_meta_boxes'), 10, 1);
     }
     $this->registered = true;
 }
开发者ID:felixarntz,项目名称:post-types-definitely,代码行数:41,代码来源:Taxonomy.php


示例6: get_attribute_taxonomy_label

 /**
  * Get attribute taxonomy label.
  *
  * @param  string $name Taxonomy name.
  * @return string
  */
 protected function get_attribute_taxonomy_label($name)
 {
     $tax = get_taxonomy($name);
     $labels = get_taxonomy_labels($tax);
     return $labels->singular_name;
 }
开发者ID:shivapoudel,项目名称:woocommerce,代码行数:12,代码来源:class-wc-rest-products-controller.php


示例7: register_taxonomy

/**
 * Create or modify a taxonomy object. Do not use before init.
 *
 * A simple function for creating or modifying a taxonomy object based on the
 * parameters given. The function will accept an array (third optional
 * parameter), along with strings for the taxonomy name and another string for
 * the object type.
 *
 * Nothing is returned, so expect error maybe or use taxonomy_exists() to check
 * whether taxonomy exists.
 *
 * Optional $args contents:
 *
 * label - Name of the taxonomy shown in the menu. Usually plural. If not set, labels['name'] will be used.
 *
 * hierarchical - has some defined purpose at other parts of the API and is a
 * boolean value.
 *
 * update_count_callback - works much like a hook, in that it will be called
 * when the count is updated.
 *
 * rewrite - false to prevent rewrite, or array('slug'=>$slug) to customize
 * permastruct; default will use $taxonomy as slug.
 *
 * query_var - false to prevent queries, or string to customize query var
 * (?$query_var=$term); default will use $taxonomy as query var.
 *
 * public - If the taxonomy should be publically queryable; //@TODO not implemented.
 * defaults to true.
 *
 * show_ui - If the WordPress UI admin tags UI should apply to this taxonomy;
 * defaults to public.
 *
 * show_in_nav_menus - true makes this taxonomy available for selection in navigation menus.
 * Defaults to public.
 *
 * show_tagcloud - false to prevent the taxonomy being listed in the Tag Cloud Widget;
 * defaults to show_ui which defalts to public.
 *
 * labels - An array of labels for this taxonomy. You can see accepted values in {@link get_taxonomy_labels()}. By default tag labels are used for non-hierarchical types and category labels for hierarchical ones.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 * @uses $wp_taxonomies Inserts new taxonomy object into the list
 * @uses $wp_rewrite Adds rewrite tags and permastructs
 * @uses $wp Adds query vars
 *
 * @param string $taxonomy Name of taxonomy object
 * @param array|string $object_type Name of the object type for the taxonomy object.
 * @param array|string $args See above description for the two keys values.
 */
function register_taxonomy($taxonomy, $object_type, $args = array())
{
    global $wp_taxonomies, $wp_rewrite, $wp;
    if (!is_array($wp_taxonomies)) {
        $wp_taxonomies = array();
    }
    $defaults = array('hierarchical' => false, 'update_count_callback' => '', 'rewrite' => true, 'query_var' => $taxonomy, 'public' => true, 'show_ui' => null, 'show_tagcloud' => null, '_builtin' => false, 'labels' => array(), 'capabilities' => array(), 'show_in_nav_menus' => null);
    $args = wp_parse_args($args, $defaults);
    if (false !== $args['query_var'] && !empty($wp)) {
        if (true === $args['query_var']) {
            $args['query_var'] = $taxonomy;
        }
        $args['query_var'] = sanitize_title_with_dashes($args['query_var']);
        $wp->add_query_var($args['query_var']);
    }
    if (false !== $args['rewrite'] && '' != get_option('permalink_structure')) {
        $args['rewrite'] = wp_parse_args($args['rewrite'], array('slug' => sanitize_title_with_dashes($taxonomy), 'with_front' => true, 'hierarchical' => false));
        if ($args['hierarchical'] && $args['rewrite']['hierarchical']) {
            $tag = '(.+?)';
        } else {
            $tag = '([^/]+)';
        }
        $wp_rewrite->add_rewrite_tag("%{$taxonomy}%", $tag, $args['query_var'] ? "{$args['query_var']}=" : "taxonomy={$taxonomy}&term=");
        $wp_rewrite->add_permastruct($taxonomy, "{$args['rewrite']['slug']}/%{$taxonomy}%", $args['rewrite']['with_front']);
    }
    if (is_null($args['show_ui'])) {
        $args['show_ui'] = $args['public'];
    }
    // Whether to show this type in nav-menus.php. Defaults to the setting for public.
    if (null === $args['show_in_nav_menus']) {
        $args['show_in_nav_menus'] = $args['public'];
    }
    if (is_null($args['show_tagcloud'])) {
        $args['show_tagcloud'] = $args['show_ui'];
    }
    $default_caps = array('manage_terms' => 'manage_categories', 'edit_terms' => 'manage_categories', 'delete_terms' => 'manage_categories', 'assign_terms' => 'edit_posts');
    $args['cap'] = (object) array_merge($default_caps, $args['capabilities']);
    unset($args['capabilities']);
    $args['name'] = $taxonomy;
    $args['object_type'] = array_unique((array) $object_type);
    $args['labels'] = get_taxonomy_labels((object) $args);
    $args['label'] = $args['labels']->name;
    $wp_taxonomies[$taxonomy] = (object) $args;
    // register callback handling for metabox
    add_filter('wp_ajax_add-' . $taxonomy, '_wp_ajax_add_hierarchical_term');
}
开发者ID:fka2004,项目名称:webkit,代码行数:98,代码来源:taxonomy.php


示例8: check_meta_values

 /**
  * Track changes to ACF values within rendered post meta forms
  *
  * @param string $type       Type of object, post or user
  * @param string $action     Added, updated, deleted
  * @param integer $meta_id
  * @param integer $object_id
  * @param string $key
  * @param mixed|null $value
  *
  * @return bool
  */
 public function check_meta_values($type, $action, $meta_id, $object_id, $key, $value = null)
 {
     unset($action);
     unset($meta_id);
     if (empty($this->cached_field_values_updates)) {
         return false;
     }
     $object_key = $object_id;
     if ('user' === $type) {
         $object_key = 'user_' . $object_id;
     } elseif ('taxonomy' === $type) {
         if (0 === strpos($key, '_')) {
             // Ignore the 'revision' stuff!
             return false;
         }
         if (1 !== preg_match('#([a-z0-9_-]+)_([\\d]+)_([a-z0-9_-]+)#', $key, $matches)) {
             return false;
         }
         list(, $taxonomy, $term_id, $key) = $matches;
         // Skips 0 index
         $object_key = $taxonomy . '_' . $term_id;
     }
     if (isset($this->cached_field_values_updates[$object_key][$key])) {
         if ('post' === $type) {
             $posts_connector = new Connector_Posts();
             $post = get_post($object_id);
             $title = $post->post_title;
             $type_name = strtolower($posts_connector->get_post_type_name($post->post_type));
         } elseif ('user' === $type) {
             $user = new \WP_User($object_id);
             $title = $user->get('display_name');
             $type_name = esc_html__('user', 'stream');
         } elseif ('taxonomy' === $type && isset($term_id) && isset($taxonomy)) {
             $term = get_term($term_id, $taxonomy);
             $title = $term->name;
             $tax_obj = get_taxonomy($taxonomy);
             $type_name = strtolower(get_taxonomy_labels($tax_obj)->singular_name);
         } else {
             return false;
         }
         $cache = $this->cached_field_values_updates[$object_key][$key];
         $this->log(esc_html_x('"%1$s" of "%2$s" %3$s updated', 'acf', 'stream'), array('field_label' => $cache['field']['label'], 'title' => $title, 'singular_name' => $type_name, 'meta_value' => $value, 'meta_key' => $key, 'meta_type' => $type), $object_id, 'values', 'updated');
     }
     return true;
 }
开发者ID:selectSIFISO,项目名称:.comsite,代码行数:57,代码来源:class-connector-acf.php


示例9: _registered_taxonomy

 /**
  * Catch registration of taxonomies after inital loading, so we can cache its labels
  *
  * @action registered_taxonomy
  *
  * @param string       $taxonomy    Taxonomy slug
  * @param array|string $object_type Object type or array of object types
  * @param array|string $args        Array or string of taxonomy registration arguments
  */
 public static function _registered_taxonomy($taxonomy, $object_type, $args)
 {
     $taxonomy_obj = (object) $args;
     $label = get_taxonomy_labels($taxonomy_obj)->name;
     self::$context_labels[$taxonomy] = $label;
     WP_Stream_Connectors::$term_labels['stream_context'][$taxonomy] = $label;
 }
开发者ID:xwp,项目名称:stream-legacy,代码行数:16,代码来源:taxonomies.php


示例10: fwp_category_box

function fwp_category_box($checked, $object, $tags = array(), $params = array())
{
    global $wp_db_version;
    if (is_string($params)) {
        $prefix = $params;
        $taxonomy = 'category';
    } elseif (is_array($params)) {
        $prefix = isset($params['prefix']) ? $params['prefix'] : '';
        $taxonomy = isset($params['taxonomy']) ? $params['taxonomy'] : 'category';
    }
    $oTax = get_taxonomy($taxonomy);
    $oTaxLabels = get_taxonomy_labels($oTax);
    if (strlen($prefix) > 0) {
        $idPrefix = $prefix . '-';
        $idSuffix = "-" . $prefix;
        $namePrefix = $prefix . '_';
    } else {
        $idPrefix = 'feedwordpress-';
        $idSuffix = "-feedwordpress";
        $namePrefix = 'feedwordpress_';
    }
    ?>
<div id="<?php 
    print $idPrefix;
    ?>
taxonomy-<?php 
    print $taxonomy;
    ?>
" class="feedwordpress-category-div">
  <ul id="<?php 
    print $idPrefix;
    print $taxonomy;
    ?>
-tabs" class="category-tabs">
    <li class="ui-tabs-selected tabs"><a href="#<?php 
    print $idPrefix;
    print $taxonomy;
    ?>
-all" tabindex="3"><?php 
    _e('All posts');
    ?>
</a>
    <p style="font-size:smaller;font-style:bold;margin:0">Give <?php 
    print $object;
    ?>
 these <?php 
    print $oTaxLabels->name;
    ?>
</p>
    </li>
  </ul>

<div id="<?php 
    print $idPrefix;
    print $taxonomy;
    ?>
-all" class="tabs-panel">
    <input type="hidden" value="0" name="tax_input[<?php 
    print $taxonomy;
    ?>
][]" />
    <ul id="<?php 
    print $idPrefix;
    print $taxonomy;
    ?>
checklist" class="list:<?php 
    print $taxonomy;
    ?>
 categorychecklist form-no-clear">
	<?php 
    fwp_category_checklist(NULL, false, $checked, $params);
    ?>
    </ul>
</div>

<div id="<?php 
    print $idPrefix;
    print $taxonomy;
    ?>
-adder" class="<?php 
    print $taxonomy;
    ?>
-adder wp-hidden-children">
    <h4><a id="<?php 
    print $idPrefix;
    print $taxonomy;
    ?>
-add-toggle" class="category-add-toggle" href="#<?php 
    print $idPrefix;
    print $taxonomy;
    ?>
-add" class="hide-if-no-js" tabindex="3"><?php 
    _e('+ Add New Category');
    ?>
</a></h4>
    <p id="<?php 
    print $idPrefix;
    print $taxonomy;
    ?>
-add" class="category-add wp-hidden-child">
//.........这里部分代码省略.........
开发者ID:radgeek,项目名称:feedwordpress,代码行数:101,代码来源:admin-ui.php


示例11: action_links

 /**
  * Add action links to Stream drop row in admin list screen
  *
  * @filter wp_stream_action_links_{connector}
  *
  * @param  array  $links     Previous links registered
  * @param  object $record    Stream record
  *
  * @return array             Action links
  */
 public static function action_links($links, $record)
 {
     if (in_array($record->context, array('downloads'))) {
         $links = WP_Stream_Connector_Posts::action_links($links, $record);
     } elseif (in_array($record->context, array('discounts'))) {
         $post_type_label = get_post_type_labels(get_post_type_object('edd_discount'))->singular_name;
         $base = admin_url('edit.php?post_type=download&page=edd-discounts');
         $links[sprintf(__('Edit %s', 'stream'), $post_type_label)] = add_query_arg(array('edd-action' => 'edit_discount', 'discount' => $record->object_id), $base);
         if ('active' === get_post($record->object_id)->post_status) {
             $links[sprintf(__('Deactivate %s', 'stream'), $post_type_label)] = add_query_arg(array('edd-action' => 'deactivate_discount', 'discount' => $record->object_id), $base);
         } else {
             $links[sprintf(__('Activate %s', 'stream'), $post_type_label)] = add_query_arg(array('edd-action' => 'activate_discount', 'discount' => $record->object_id), $base);
         }
     } elseif (in_array($record->context, array('download_category', 'download_tag'))) {
         $tax_label = get_taxonomy_labels(get_taxonomy($record->context))->singular_name;
         $links[sprintf(__('Edit %s', 'stream'), $tax_label)] = get_edit_term_link($record->object_id, wp_stream_get_meta($record, 'taxonomy', true));
     } elseif ('api_keys' === $record->context) {
         $user = new WP_User($record->object_id);
         if (apply_filters('edd_api_log_requests', true)) {
             $links[__('View API Log', 'stream')] = add_query_arg(array('view' => 'api_requests', 'post_type' => 'download', 'page' => 'edd-reports', 'tab' => 'logs', 's' => $user->user_email), 'edit.php');
         }
         $links[__('Revoke', 'stream')] = add_query_arg(array('post_type' => 'download', 'user_id' => $record->object_id, 'edd_action' => 'process_api_key', 'edd_api_process' => 'revoke'), 'edit.php');
         $links[__('Reissue', 'stream')] = add_query_arg(array('post_type' => 'download', 'user_id' => $record->object_id, 'edd_action' => 'process_api_key', 'edd_api_process' => 'regenerate'), 'edit.php');
     }
     return $links;
 }
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:36,代码来源:class-wp-stream-connector-edd.php


示例12: get_taxonomy_labels

$labels = get_taxonomy_labels($tax);
print_r($labels);
</pre>
	<?php 
$tax = get_taxonomy('category');
$labels = get_taxonomy_labels($tax);
print_r($labels);
?>
	
	<br /><br /><br /><br />

<pre>
$tax = get_taxonomy('field'); 
$labels = get_taxonomy_labels($tax);
print_r($labels);
</pre>
	<?php 
$tax = get_taxonomy('field');
$labels = get_taxonomy_labels($tax);
print_r($labels);
?>

	</p>

	</div>

</div>


<?php 
get_footer();
开发者ID:aarongillett,项目名称:B22-151217,代码行数:31,代码来源:test.php


示例13: get_no_terms_found_message

 /**
  * Create the message to display when there are not terms on the other site
  *
  * @param  int $site_id
  * @return string
  */
 private function get_no_terms_found_message($site_id)
 {
     $taxonomy_name = $this->presenter->get_taxonomy();
     $taxonomy_object = get_taxonomy($taxonomy_name);
     $taxonomy_labels = get_taxonomy_labels($taxonomy_object);
     $text = esc_html($taxonomy_labels->not_found);
     $admin_url = get_admin_url($site_id, 'edit-tags.php');
     $taxonomy_edit_url = add_query_arg('taxonomy', $taxonomy_name, $admin_url);
     $url = esc_url($taxonomy_edit_url);
     return sprintf('<p><a href="%1$s">%2$s</a></p>', $url, $text);
 }
开发者ID:ycms,项目名称:framework,代码行数:17,代码来源:Mlp_Term_Translation_Selector.php


示例14: set_props

 /**
  * Sets taxonomy properties.
  *
  * @since 4.7.0
  * @access public
  *
  * @param array|string $object_type Name of the object type for the taxonomy object.
  * @param array|string $args        Array or query string of arguments for registering a taxonomy.
  */
 public function set_props($object_type, $args)
 {
     $args = wp_parse_args($args);
     /**
      * Filters the arguments for registering a taxonomy.
      *
      * @since 4.4.0
      *
      * @param array  $args        Array of arguments for registering a taxonomy.
      * @param string $taxonomy    Taxonomy key.
      * @param array  $object_type Array of names of object types for the taxonomy.
      */
     $args = apply_filters('register_taxonomy_args', $args, $this->name, (array) $object_type);
     $defaults = array('labels' => array(), 'description' => '', 'public' => true, 'publicly_queryable' => null, 'hierarchical' => false, 'show_ui' => null, 'show_in_menu' => null, 'show_in_nav_menus' => null, 'show_tagcloud' => null, 'show_in_quick_edit' => null, 'show_admin_column' => false, 'meta_box_cb' => null, 'capabilities' => array(), 'rewrite' => true, 'query_var' => $this->name, 'update_count_callback' => '', '_builtin' => false);
     $args = array_merge($defaults, $args);
     // If not set, default to the setting for public.
     if (null === $args['publicly_queryable']) {
         $args['publicly_queryable'] = $args['public'];
     }
     if (false !== $args['query_var'] && (is_admin() || false !== $args['publicly_queryable'])) {
         if (true === $args['query_var']) {
             $args['query_var'] = $this->name;
         } else {
             $args['query_var'] = sanitize_title_with_dashes($args['query_var']);
         }
     } else {
         // Force query_var to false for non-public taxonomies.
         $args['query_var'] = false;
     }
     if (false !== $args['rewrite'] && (is_admin() || '' != get_option('permalink_structure'))) {
         $args['rewrite'] = wp_parse_args($args['rewrite'], array('with_front' => true, 'hierarchical' => false, 'ep_mask' => EP_NONE));
         if (empty($args['rewrite']['slug'])) {
             $args['rewrite']['slug'] = sanitize_title_with_dashes($this->name);
         }
     }
     // If not set, default to the setting for public.
     if (null === $args['show_ui']) {
         $args['show_ui'] = $args['public'];
     }
     // If not set, default to the setting for show_ui.
     if (null === $args['show_in_menu'] || !$args['show_ui']) {
         $args['show_in_menu'] = $args['show_ui'];
     }
     // If not set, default to the setting for public.
     if (null === $args['show_in_nav_menus']) {
         $args['show_in_nav_menus'] = $args['public'];
     }
     // If not set, default to the setting for show_ui.
     if (null === $args['show_tagcloud']) {
         $args['show_tagcloud'] = $args['show_ui'];
     }
     // If not set, default to the setting for show_ui.
     if (null === $args['show_in_quick_edit']) {
         $args['show_in_quick_edit'] = $args['show_ui'];
     }
     $default_caps = array('manage_terms' => 'manage_categories', 'edit_terms' => 'manage_categories', 'delete_terms' => 'manage_categories', 'assign_terms' => 'edit_posts');
     $args['cap'] = (object) array_merge($default_caps, $args['capabilities']);
     unset($args['capabilities']);
     $args['object_type'] = array_unique((array) $object_type);
     // If not set, use the default meta box
     if (null === $args['meta_box_cb']) {
         if ($args['hierarchical']) {
             $args['meta_box_cb'] = 'post_categories_meta_box';
         } else {
             $args['meta_box_cb'] = 'post_tags_meta_box';
         }
     }
     foreach ($args as $property_name => $property_value) {
         $this->{$property_name} = $property_value;
     }
     $this->labels = get_taxonomy_labels($this);
     $this->label = $this->labels->name;
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:82,代码来源:class-wp-taxonomy.php


示例15: searchNSelectField

/**
 * Generates a taxonomy metabox function callback together with seletize
 * @since 0.1.0
 *
 * @global array 	$defaultSettings	Default settings applied to all TSNS fields
 * @global wpdb 	$wpdb							WordPress database abstraction object.
 *
 * @param array $settings {
 * 		Settings to describe how the TSNS fields should work
 *
 *		@type string		$ajax_url					url ajax target. Defaults to `ajaxurl`
 *		@type array 		$selector_setup		Selectize Setup
 *		@type array 		$ajax_data				Aditional data to be served by ajax.
 *																		 	By default, wp_ajax settings are assumed.
 *		@type string		$ajax_query_field	field in ajax data for the query, which
 *																			is overwrited in runtime by current one.
 *
 *		@type	int|bool	$terms_limit		defines how much terms can be assigned to
 *																		the post. Define *false* for no limit.
 *
 * } *
 * @return function Returns a function which should be passed to 'meta_box_cb'
 * 									of {@link register_taxonomy()}'s $args
 *              		if no taxonomy is specified and the term ID exists. Returns
 *              		an array of the term ID and the term taxonomy ID the taxonomy
 *              		is specified and the pairing exists.
 */
function searchNSelectField($settings = [])
{
    global $defaultSettings, $tsns_initiated;
    $settings += ['selector_setup' => [], 'ajax_url' => false, 'ajax_query_field' => 'query', 'terms_limit' => false];
    return function (\WP_Post $post, array $box) use($settings) {
        $tax_name = $box['args']['taxonomy'];
        $taxonomy = get_taxonomy($tax_name);
        $user_can_assign_terms = current_user_can($taxonomy->cap->assign_terms);
        $comma = _x(',', 'tag delimiter');
        $terms = wp_get_object_terms($post->ID, $tax_name);
        $labels = get_taxonomy_labels($taxonomy);
        $new_label = $labels->add_new_item;
        $preload = [];
        if ($preload_length = value($settings, 'preload', 10)) {
            $preload = get_terms($tax_name, ['number' => $preload_length, 'hide_empty' => false, 'orderby' => 'count']);
        }
        /**
         * Filters the selectize settings before its conversion to JSON
         *
         * @since 0.1.0
         *
         * @param array 	$settings	Original settings to passed to selectize.js
         * @param WP_Post $post 		The post currently being edited
         * @param object 	$taxonomy	Taxonomy for the current metabox
         * @param array 	$settings	Options this current fields
         */
        $config = apply_filters('tsns_selector_setup', $settings['selector_setup'] + ['loadThrottle' => 100, 'valueField' => 'term_id', 'labelField' => 'name', 'searchField' => 'name', 'maxOptions' => 10, 'optionsTemplate' => '<div class="option"><%- option.name %></div>', 'createTemplate' => "<div class='create'>{$new_label}: <%- input %></div>", 'itemsTemplate' => '<div class="item"><%- item.name %></div>', 'maxItems' => $settings['terms_limit'], 'delimiter' => $comma, 'options' => $terms + $preload, 'items' => array_map(function ($term) {
            return $term->term_id;
        }, $terms), 'create' => $user_can_assign_terms], $post, $taxonomy, $settings);
        /**
         * Filters the selectize settings before its conversion to JSON specifically
         * to {taxonomy}, after filtered by {@link tsns_selector_setup}
         *
         * @since 0.1.0
         *
         * @param array 	$settings	Original settings to passed to selectize.js
         * @param WP_Post $post 		The post currently being edited
         * @param object 	$taxonomy	Taxonomy for the current metabox
         * @param array 	$settings	Options this current fields
         */
        $config = apply_filters(sprintf('tsns_%s_selector_setup', $tax_name), $config, $post, $taxonomy, $settings);
        /**
         * Filter ajax data to be sent along with the query
         *
         * @since 0.1.0
         *
         * @param array 	$ajax_data	Original ajax data
         * @param WP_Post $post 			The post currently being edited
         * @param object 	$taxonomy		Taxonomy for the current metabox
         * @param array 	$settings		Options this current fields
         */
        $ajax_data = apply_filters('tsns_ajax_data', value($settings, 'ajax_data', ['action' => "tsns_search", 'taxonomy' => $tax_name]), $post, $taxonomy, $settings);
        /**
         * Filter ajax data to be sent along with the query specifically to
         * {taxonomy}, after filtered by {@link tsns_setup_selector}
         *
         * @since 0.1.0
         *
         * @param array 	$settings	Original settings to passed to selectize.js
         * @param WP_Post $post 		The post currently being edited
         * @param object 	$taxonomy	Taxonomy for the current metabox
         * @param array 	$settings	Options this current fields
         */
        $ajax_data = apply_filters(sprintf('tsns_%s_ajax_data', $tax_name), $ajax_data, $post, $taxonomy, $settings);
        if ($ajax_url = value($settings, 'ajax_url', false)) {
            $ajax_url = json_encode($ajax_url);
        } else {
            $ajax_url = 'ajaxurl';
        }
        ?>
    <div class="selectize-taxonomy">
			<textarea
				name="<?php 
//.........这里部分代码省略.........
开发者ID:edygar,项目名称:wp-extensions,代码行数:101,代码来源:search-n-select.php


示例16: register_taxonomy


//.........这里部分代码省略.........
 *
 * show_in_nav_menus - true makes this taxonomy available for selection in navigation menus.
 * Defaults to public.
 *
 * show_tagcloud - false to prevent the taxonomy being listed in the Tag Cloud Widget;
 * defaults to show_ui which defaults to public.
 *
 * labels - An array of labels for this taxonomy. You can see accepted values in {@link get_taxonomy_labels()}. By default tag labels are used for non-hierarchical types and category labels for hierarchical ones.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 * @uses $wp_taxonomies Inserts new taxonomy object into the list
 * @uses $wp Adds query vars
 *
 * @param string $taxonomy Name of taxonomy object
 * @param array|string $object_type Name of the object type for the taxonomy object.
 * @param array|string $args See above description for the two keys values.
 * @return null|WP_Error WP_Error if errors, otherwise null.
 */
function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
	global $wp_taxonomies, $wp;

	if ( ! is_array($wp_taxonomies) )
		$wp_taxonomies = array();

	$defaults = array(	'hierarchical' => false,
						'update_count_callback' => '',
						'rewrite' => true,
						'query_var' => $taxonomy,
						'public' => true,
						'show_ui' => null,
						'show_tagcloud' => null,
						'_builtin' => false,
						'labels' => array(),
						'capabilities' => array(),
						'show_in_nav_menus' => null,
					);
	$args = wp_parse_args($args, $defaults);

	if ( strlen( $taxonomy ) > 32 )
		return new WP_Error( 'taxonomy_too_long', __( 'Taxonomies cannot exceed 32 characters in length' ) );

	if ( false !== $args['query_var'] && !empty($wp) ) {
		if ( true === $args['query_var'] )
			$args['query_var'] = $taxonomy;
		else
			$args['query_var'] = sanitize_title_with_dashes($args['query_var']);
		$wp->add_query_var($args['query_var']);
	}

	if ( false !== $args['rewrite'] && ( is_admin() || '' != get_option('permalink_structure') ) ) {
		$args['rewrite'] = wp_parse_args($args['rewrite'], array(
			'slug' => sanitize_title_with_dashes($taxonomy),
			'with_front' => true,
			'hierarchical' => false,
			'ep_mask' => EP_NONE,
		));

		if ( $args['hierarchical'] && $args['rewrite']['hierarchical'] )
			$tag = '(.+?)';
		else
			$tag = '([^/]+)';

		add_rewrite_tag( "%$taxonomy%", $tag, $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term=" );
		add_permastruct( $taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite'] );
	}

	if ( is_null($args['show_ui']) )
		$args['show_ui'] = $args['public'];

	// Whether to show this type in nav-menus.php. Defaults to the setting for public.
	if ( null === $args['show_in_nav_menus'] )
		$args['show_in_nav_menus'] = $args['public'];

	if ( is_null($args['show_tagcloud']) )
		$args['show_tagcloud'] = $args['show_ui'];

	$default_caps = array(
		'manage_terms' => 'manage_categories',
		'edit_terms'   => 'manage_categories',
		'delete_terms' => 'manage_categories',
		'assign_terms' => 'edit_posts',
	);
	$args['cap'] = (object) array_merge( $default_caps, $args['capabilities'] );
	unset( $args['capabilities'] );

	$args['name'] = $taxonomy;
	$args['object_type'] =  array_unique( (array)$object_type );

	$args['labels'] = get_taxonomy_labels( (object) $args );
	$args['label'] = $args['labels']->name;

	$wp_taxonomies[$taxonomy] = (object) $args;

	// register callback handling for metabox
 	add_filter('wp_ajax_add-' . $taxonomy, '_wp_ajax_add_hierarchical_term');

	do_action( 'registered_taxonomy', $taxonomy, $object_type, $args );
}
开发者ID:pauEscarcia,项目名称:AIMM,代码行数:101,代码来源:TAXONOMY.PHP


示例17: _registered_taxonomy

 /**
  * Catch registration of taxonomies after inital loading, so we can cache its labels
  *
  * @action registered_taxonomy
  *
  * @param string $taxonomy          Taxonomy slug
  * @param array|string $object_type Object type or array of object types
  * @param array|string $args        Array or string of taxonomy registration arguments
  */
 public function _registered_taxonomy($taxonomy, $object_type, $args)
 {
     unset($object_type);
     $taxonomy_obj = (object) $args;
     $label = get_taxonomy_labels($taxonomy_obj)->name;
     $this->context_labels[$taxonomy] = $label;
     wp_stream_get_instance()->connectors->term_labels['stream_context'][$taxonomy] = $label;
 }
开发者ID:evgenykireev,项目名称:stream,代码行数:17,代码来源:class-connector-taxonomies.php


示例18: rtbiz_get_tex_diff

function rtbiz_get_tex_diff($post_id, $texonomy)
{
    $post_terms = wp_get_post_terms($post_id, $texonomy);
    $postterms = array_filter($_POST['tax_input'][$texonomy]);
    $termids = wp_list_pluck($post_terms, 'term_id');
    $diff = array_diff($postterms, $termids);
    $diff2 = array_diff($termids, $postterms);
    $diff_tax1 = array();
    $diff_tax2 = array();
    foreach ($diff as $tax_id) {
        $tmp = get_term_by('id', $tax_id, $texonomy);
        $diff_tax1[] = $tmp->name;
    }
    foreach ($diff2 as $tax_id) {
        $tmp = get_term_by('id', $tax_id, $texonomy);
        $diff_tax2[] = $tmp->name;
    }
    $difftxt = rtbiz_text_diff(implode(' ', $diff_tax2), implode(' ', $diff_tax1));
    if (!empty($difftxt) || '' != $difftxt) {
        $tax = get_taxonomy($texonomy);
        $lable = get_taxonomy_labels($tax);
        $body = '<strong>' . __($lable->name) . '</strong> : ' . $difftxt;
        return $body;
    }
    return '';
}
开发者ID:chandra-patel,项目名称:rtbiz,代码行数:26,代码来源:rtbiz-functions.php


示例19: register_taxonomy


//.........这里部分代码省略.........
 *                                                counting them. Default _update_generic_term_count() for taxonomies
 *                                                attached to other object types, such as users.
 *     @type bool          $_builtin              This taxonomy is a "built-in" taxonomy. INTERNAL USE ONLY!
 *                                                Default false.
 * }
 * @return WP_Error|void WP_Error, if errors.
 */
function register_taxonomy($taxonomy, $object_type, $args = array())
{
    global $wp_taxonomies, $wp;
    if (!is_array($wp_taxonomies)) {
        $wp_taxonomies = array();
    }
    $args = wp_parse_args($args);
    /**
     * Filter the arguments for registering a taxonomy.
     *
     * @since 4.4.0
     *
     * @param array  $args        Array of arguments for registering a taxonomy.
     * @param array  $object_type Array of names of object types for the taxonomy.
     * @param string $taxonomy    Taxonomy key.
     */
    $args = apply_filters('register_taxonomy_args', $args, $taxonomy, (array) $object_type);
    $defaults = array('labels' => array(), 'description' => '', 'public' => true, 'hierarchical' => false, 'show_ui' => null, 'show_in_menu' => null, 'show_in_nav_menus' => null, 'show_tagcloud' => null, 'show_in_quick_edit' => null, 'show_admin_column' => false, 'meta_box_cb' => null, 'capabilities' => array(), 'rewrite' => true, 'query_var' => $taxonomy, 'update_count_callback' => '', '_builtin' => false);
    $args = array_merge($defaults, $args);
    if (empty($taxonomy) || strlen($taxonomy) > 32) {
        _doing_it_wrong(__FUNCTION__, __('Taxonomy names must be between 1 and 32 characters in length.'), '4.2');
        return new WP_Error('taxonomy_length_invalid', __('Taxonomy names must be between 1 and 32 characters in length.'));
    }
    if (false !== $args['query_var'] && !empty($wp)) {
        i 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP get_taxonomy_template函数代码示例发布时间:2022-05-15
下一篇:
PHP get_taxonomy函数代码示例发布时间: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