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

PHP get_taxonomy函数代码示例

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

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



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

示例1: normalize_field

 /**
  * Add default value for 'taxonomy' field
  *
  * @param $field
  *
  * @return array
  */
 static function normalize_field($field)
 {
     $default_args = array('hide_empty' => false);
     // Set default args
     $field['options']['args'] = !isset($field['options']['args']) ? $default_args : wp_parse_args($field['options']['args'], $default_args);
     $tax = get_taxonomy($field['options']['taxonomy']);
     $field['placeholder'] = empty($field['placeholder']) ? sprintf(__('Select a %s', 'framework'), $tax->labels->singular_name) : $field['placeholder'];
     switch ($field['options']['type']) {
         case 'select_advanced':
             $field = RWMB_Select_Advanced_Field::normalize_field($field);
             break;
         case 'checkbox_list':
         case 'checkbox_tree':
             $field = RWMB_Checkbox_List_Field::normalize_field($field);
             break;
         case 'select':
         case 'select_tree':
             $field = RWMB_Select_Field::normalize_field($field);
             break;
         default:
             $field['options']['type'] = 'select';
             $field = RWMB_Select_Field::normalize_field($field);
     }
     if (in_array($field['options']['type'], array('checkbox_tree', 'select_tree'))) {
         if (isset($field['options']['args']['parent'])) {
             $field['options']['parent'] = $field['options']['args']['parent'];
             unset($field['options']['args']['parent']);
         } else {
             $field['options']['parent'] = 0;
         }
     }
     $field['field_name'] = "{$field['id']}[]";
     return $field;
 }
开发者ID:ahmedelhadi,项目名称:TestProject,代码行数:41,代码来源:taxonomy.php


示例2: scoper_force_custom_taxonomy_filters

function scoper_force_custom_taxonomy_filters($post_id, $post)
{
    $post_type_obj = get_post_type_object($post->post_type);
    foreach ($post_type_obj->taxonomies as $taxonomy) {
        // if terms were selected, WP core already applied the filter and there is no need to apply default terms
        if (in_array($taxonomy, array('category', 'post_tag')) || did_action("pre_post_{$taxonomy}")) {
            continue;
        }
        // don't filter term selection for non-hierarchical taxonomies
        if (empty($GLOBALS['wp_taxonomies'][$taxonomy]->hierarchical)) {
            continue;
        }
        if ($taxonomy_obj = get_taxonomy($taxonomy)) {
            if (!empty($_POST['tax_input'][$taxonomy]) && is_array($_POST['tax_input'][$taxonomy]) && (reset($_POST['tax_input'][$taxonomy]) || count($_POST['tax_input'][$taxonomy]) > 1)) {
                // complication because (as of 3.0) WP always includes a zero-valued first array element
                $tags = $_POST['tax_input'][$taxonomy];
            } elseif ('auto-draft' != $post->post_status) {
                $tags = (array) get_option("default_{$taxonomy}");
            } else {
                $tags = array();
            }
            if ($tags) {
                if (!empty($_POST['tax_input']) && is_array($_POST['tax_input'][$taxonomy])) {
                    // array = hierarchical, string = non-hierarchical.
                    $tags = array_filter($tags);
                }
                if (current_user_can($taxonomy_obj->cap->assign_terms)) {
                    $tags = apply_filters("pre_post_{$taxonomy}", $tags);
                    $tags = apply_filters("{$taxonomy}_pre", $tags);
                    wp_set_post_terms($post_id, $tags, $taxonomy);
                }
            }
        }
    }
}
开发者ID:btj,项目名称:cscircles-wp-content,代码行数:35,代码来源:filters-admin-save_rs.php


示例3: widget

 /**
  * This function creates and prints the widget's HTML for the front-end.
  *
  * As of 1.1, you are allowed to select whether you want the
  * term to link to the archive page or the actual post.
  * 
  * @since 1.0
  * @uses $cpt_onomies_manager, $cpt_onomy
  * @param array $args - arguments to customize the widget
  * @param array $instance - the widget's saved information
  */
 function widget($args, $instance)
 {
     global $cpt_onomies_manager, $cpt_onomy;
     extract($args);
     if (isset($instance['taxonomy'])) {
         $current_taxonomy = $instance['taxonomy'];
         if ($cpt_onomies_manager->is_registered_cpt_onomy($current_taxonomy)) {
             // get tag cloud
             $tag_cloud = $cpt_onomy->wp_tag_cloud(apply_filters('widget_tag_cloud_args', array('taxonomy' => $current_taxonomy, 'echo' => false, 'link' => isset($instance['term_link']) && $instance['term_link'] == 'cpt_post' ? 'cpt_post' : 'view')));
             // if empty, and they dont' want to show if empty, then don't show
             if ($instance['show_if_empty'] || !$instance['show_if_empty'] && !empty($tag_cloud)) {
                 if (!empty($instance['title'])) {
                     $title = $instance['title'];
                 } else {
                     $tax = get_taxonomy($current_taxonomy);
                     $title = $tax->labels->name;
                 }
                 $title = apply_filters('widget_title', $title, $instance, $this->id_base);
                 echo $before_widget;
                 if ($title) {
                     echo $before_title . __($title, CPT_ONOMIES_TEXTDOMAIN) . $after_title;
                 }
                 echo '<div class="tagcloud">' . $tag_cloud . "</div>\n";
                 echo $after_widget;
             }
         }
     }
 }
开发者ID:aarongillett,项目名称:B22-151217,代码行数:39,代码来源:widgets.php


示例4: 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


示例5: build_taxo_dd_filter

 function build_taxo_dd_filter()
 {
     $tax_name = $this->name;
     $tax_obj = get_taxonomy($tax_name);
     $selected = empty($_GET[$tax_name]) ? '' : $_GET[$tax_name];
     wp_dropdown_categories(array('show_option_all' => __('Show All ' . $tax_obj->label . '&nbsp;'), 'taxonomy' => $tax_name, 'name' => $tax_obj->name, 'orderby' => 'name', 'selected' => $selected, 'hierarchical' => $tax_obj->hierarchical, 'show_count' => false, 'hide_empty' => false));
 }
开发者ID:srolland,项目名称:dev,代码行数:7,代码来源:qqp_ctax.php


示例6: test_unregister

 public function test_unregister()
 {
     $tag = new Attachment_Tag();
     $tag->unregister();
     $tax = get_taxonomy('attachment_tag');
     $this->assertFalse($tax);
 }
开发者ID:felixarntz,项目名称:content-types,代码行数:7,代码来源:test-taxonomy.php


示例7: add_taxonomy

 public function add_taxonomy($taxonomy)
 {
     if (!array_search($taxonomy, $this->get_taxonomies())) {
         $this->taxonomies[] = $taxonomy;
         $this->add_taxonomy_object(get_taxonomy($taxonomy));
     }
 }
开发者ID:skylarkcob,项目名称:hocwp-projects,代码行数:7,代码来源:class-hocwp-rewrite.php


示例8: postStoreProcess

 public function postStoreProcess($table, $newTags = array(), $replace = true)
 {
     return false;
     if (!empty($table->newTags) && empty($newTags)) {
         $newTags = $table->newTags;
     }
     // If existing row, check to see if tags have changed.
     $newTable = clone $table;
     $newTable->reset();
     $key = $newTable->getKeyName();
     $typeAlias = $this->typeAlias;
     $result = false;
     if ($this->tagsChanged || !empty($newTags) && $newTags[0] != '') {
         $taxonomy_obj = get_taxonomy($typeAlias);
         if (is_array($newTags)) {
             // array = hierarchical, string = non-hierarchical.
             $newTags = array_filter($newTags);
         }
         if (current_user_can($taxonomy_obj->cap->assign_terms)) {
             $result = wp_set_post_terms($table->id, $newTags, $typeAlias);
             if (is_array($result) && count($result) > 0) {
                 $result = true;
             } elseif (is_object($result)) {
                 $result = false;
             }
         }
     }
     return $result;
 }
开发者ID:vanie3,项目名称:appland,代码行数:29,代码来源:tags.php


示例9: add_attachment_fields_to_edit

 static function add_attachment_fields_to_edit($form_fields, $post)
 {
     $terms = get_object_term_cache($post->ID, self::TAXONOMY);
     $field = array();
     $taxonomy_obj = (array) get_taxonomy(self::TAXONOMY);
     if (!$taxonomy_obj['public'] || !$taxonomy_obj['show_ui']) {
         continue;
     }
     if (false === $terms) {
         $terms = wp_get_object_terms($post->ID, self::TAXONOMY);
     }
     $values = wp_list_pluck($terms, 'term_id');
     ob_start();
     wp_terms_checklist($post->ID, array('taxonomy' => self::TAXONOMY, 'checked_ontop' => false, 'walker' => new Walker_WP_Media_Taxonomy_Checklist($post->ID)));
     $output = ob_get_clean();
     if (!empty($output)) {
         $output = '<ul class="term-list">' . $output . '</ul>';
         $output .= wp_nonce_field('save_attachment_media_categories', 'media_category_nonce', false, false);
     } else {
         $output = '<ul class="term-list"><li>No ' . $taxonomy_obj['label'] . '</li></ul>';
     }
     $field = array('label' => !empty($taxonomy_obj['label']) ? $taxonomy_obj['label'] : self::TAXONOMY, 'value' => join(', ', $values), 'show_in_edit' => false, 'input' => 'html', 'html' => $output);
     $form_fields[self::TAXONOMY] = $field;
     return $form_fields;
 }
开发者ID:kevinlangleyjr,项目名称:wp-media-categories,代码行数:25,代码来源:wp-media-categories.php


示例10: handler

	static function handler() {
		$defaults = array(
			'taxonomy' => 'post_tag',
			'delete_tags' => false,
			'action' => false,
			'action2' => false
		);

		$data = shortcode_atts( $defaults, $_REQUEST );

		$tax = get_taxonomy( $data['taxonomy'] );
		if ( !$tax )
			return;

		if ( !current_user_can( $tax->cap->manage_terms ) )
			return;

		add_action( 'admin_enqueue_scripts', array( __CLASS__, 'script' ) );
		add_action( 'admin_footer', array( __CLASS__, 'inputs' ) );

		$action = false;
		foreach ( array( 'action', 'action2' ) as $key ) {
			if ( $data[ $key ] && '-1' != $data[ $key ] ) {
				$action = $data[ $key ];
			}
		}

		if ( !$action )
			return;

		self::delegate_handling( $action, $data['taxonomy'], $data['delete_tags'] );
	}
开发者ID:universitytimes,项目名称:site,代码行数:32,代码来源:term-management-tools.php


示例11: load

 /**
  * Create a new instance from an existing taxonomy.
  *
  * @param  string $id The taxonomy identifier
  *
  * @throws NonExistentTaxonomyException
  *
  * @return static
  */
 public static function load($id)
 {
     if (!($object = get_taxonomy($id))) {
         throw new NonExistentTaxonomyException("No taxonomy exists with name '{$id}'.");
     }
     return new static($object);
 }
开发者ID:aaemnnosttv,项目名称:silk,代码行数:16,代码来源:Taxonomy.php


示例12: initialize

 /**
  * Initialization function, similar to __construct()
  *
  * @since 0.1
  */
 public static function initialize()
 {
     self::$wp_4dot0_plus = version_compare(get_bloginfo('version'), '4.0', '>=');
     /*
      * Set up the Media/Assistant submenu table column definitions
      */
     $taxonomies = get_taxonomies(array('show_ui' => true), 'names');
     foreach ($taxonomies as $tax_name) {
         if (MLACore::mla_taxonomy_support($tax_name)) {
             $tax_object = get_taxonomy($tax_name);
             self::$default_columns['t_' . $tax_name] = esc_html($tax_object->labels->name);
             self::$default_hidden_columns[] = 't_' . $tax_name;
             // self::$default_sortable_columns [] = none at this time
         }
         // supported taxonomy
     }
     // foreach $tax_name
     /*
      * For WP 4.3+ icon will be merged with the first visible preferred column
      */
     if (MLATest::$wp_4dot3_plus) {
         unset(self::$default_columns['icon']);
     }
     self::$default_columns = array_merge(self::$default_columns, MLACore::mla_custom_field_support('default_columns'));
     self::$default_hidden_columns = array_merge(self::$default_hidden_columns, MLACore::mla_custom_field_support('default_hidden_columns'));
     self::$default_sortable_columns = array_merge(self::$default_sortable_columns, MLACore::mla_custom_field_support('default_sortable_columns'));
 }
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:32,代码来源:class-mla-data-query.php


示例13: testGetTermAuthor

 /**
  * Testing Sensei_Core_Modules::get_term_author
  */
 public function testGetTermAuthor()
 {
     // setup assertions
     $test_user_id = wp_create_user('teacherGetTermAuthor', 'teacherGetTermAuthor', '[email protected]');
     //insert a general term
     wp_insert_term('Get Started', 'module');
     //insert a term as if from the user
     wp_insert_term('Get Started Today', 'module', array('description' => 'A yummy apple.', 'slug' => $test_user_id . '-get-started-today'));
     // does the function exist?
     $this->assertTrue(method_exists('Sensei_Core_Modules', 'get_term_authors'), 'The function Sensei_Core_Modules::get_term_author does not exist ');
     // does the taxonomy exist
     $module_taxonomy = get_taxonomy('module');
     $this->assertTrue($module_taxonomy->public, 'The module taxonomy is not loaded');
     // does it return empty array id for bogus term nam?
     $term_authors = Sensei_Core_Modules::get_term_authors('bogusnonexistan');
     $this->assertTrue(empty($term_authors), 'The function should return false for an invalid term');
     //does it return the admin user for a valid term ?
     $admin = get_user_by('email', get_bloginfo('admin_email'));
     $term_authors = Sensei_Core_Modules::get_term_authors('Get Started');
     $this->assertTrue($admin == $term_authors[0], 'The function should return admin user for normal module term.');
     // does it return the expected new user for the given term registered with that id in front of the slug?
     $term_authors = Sensei_Core_Modules::get_term_authors('Get Started Today');
     $this->assertTrue(get_userdata($test_user_id) == $term_authors[0], 'The function should admin user for normal module term.');
     // what about terms with the same name but different slug?
     // It should return 2 authors as we've created 2 with the same name
     // insert a term that is the same as the first one
     wp_insert_term('Get Started', 'module', array('description' => 'A yummy apple.', 'slug' => $test_user_id . '-get-started'));
     $term_authors = Sensei_Core_Modules::get_term_authors('Get Started');
     $this->assertTrue(2 == count($term_authors), 'The function should admin user for normal module term.');
 }
开发者ID:pra85,项目名称:sensei,代码行数:33,代码来源:test-class-modules.php


示例14: sandwich_tag_cloud_widget_shortcode

function sandwich_tag_cloud_widget_shortcode($attr, $content)
{
    $default = '';
    foreach (get_taxonomies() as $taxonomy) {
        $tax = get_taxonomy($taxonomy);
        if (!$tax->show_tagcloud || empty($tax->labels->name)) {
            continue;
        }
        $default = esc_attr($taxonomy);
        break;
    }
    $attr = wp_parse_args($attr, array('title' => __('Tag Cloud', 'pbsandwich'), 'taxonomy' => $default, 'hide_title' => false));
    $hideTitleClass = '';
    if ($attr['hide_title']) {
        $hideTitleClass = 'hide_title';
    }
    ob_start();
    ?>
	<div class="sandwich <?php 
    echo $hideTitleClass;
    ?>
">
		<?php 
    the_widget('WP_Widget_Tag_Cloud', $attr);
    ?>
	</div>
	
	<?php 
    return ob_get_clean();
}
开发者ID:bruno-barros,项目名称:w.eloquent.light,代码行数:30,代码来源:widget-tag-cloud.php


示例15: migrate

 /**
  * Migrate meta values to taxonomy terms. Delete meta after import
  *
  * ## OPTIONS
  *
  * <meta-key>
  * : Meta key to convert
  *
  * <taxonomy-slug>
  * : Taxonomy to move values into
  *
  * [--<field>=<value>]
  * : One or more args to pass to WP_Query.
  *
  * ## EXAMPLES
  *
  *     wp mtt migrate meta_key taxonomy_slug
  *     wp mtt migrate meta_key taxonomy_slug --posts_per_page=200 --paged=2
  *
  */
 function migrate($args, $assoc_args)
 {
     list($meta_key, $taxonomy) = $args;
     if (!($taxonomy_object = get_taxonomy($taxonomy))) {
         WP_CLI::error(sprintf("The taxonomy '%s' doesn't exist", $taxonomy));
     }
     $defaults = array('post_type' => $taxonomy_object->object_type, 'posts_per_page' => -1, 'post_status' => 'any');
     $query_args = array_merge($defaults, $assoc_args);
     $query = new WP_Query($query_args);
     // summary
     WP_CLI::log(sprintf("---\nPer page: %d \nPage: %d \nTotal pages: %d\n---", $query_args['posts_per_page'], isset($query_args['paged']) ? $query_args['paged'] : 1, $query->max_num_pages));
     while ($query->have_posts()) {
         $query->the_post();
         $id = get_the_id();
         // get meta
         $metas = get_post_meta($id, $meta_key);
         // create term
         if (!$metas) {
             WP_CLI::log(WP_CLI::colorize("%c[{$id}]%n No meta, skipped"));
         } else {
             if (!is_wp_error(wp_set_object_terms($id, $metas, $taxonomy, true))) {
                 WP_CLI::log(WP_CLI::colorize("%g[{$id}]%n Migrated: " . implode(', ', $metas)));
                 // clean meta
                 delete_post_meta($id, $meta_key);
             } else {
                 WP_CLI::log(WP_CLI::colorize("%r[{$id}]%n Error: Could not set terms for post"));
             }
         }
     }
 }
开发者ID:trepmal,项目名称:wp-cli-meta-to-term,代码行数:50,代码来源:meta-to-term-cli.php


示例16: scoper_admin_terms_js

function scoper_admin_terms_js()
{
    if (!empty($_REQUEST['action']) && 'edit' == $_REQUEST['action']) {
        return;
    }
    if (!empty($_REQUEST['taxonomy'])) {
        // using this with edit-link-categories
        if ($tx_obj = get_taxonomy($_REQUEST['taxonomy'])) {
            $cap_name = $tx_obj->cap->manage_terms;
        }
    }
    if (empty($cap_name)) {
        $cap_name = 'manage_categories';
    }
    if (cr_user_can($cap_name, BLOG_SCOPE_RS)) {
        return;
    }
    ?>

<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready( function($) {
	$('#parent option[value="-1"]').remove();
});
/* ]]> */
</script>
<?php 
}
开发者ID:Netsoro,项目名称:gdnlteamgroup,代码行数:28,代码来源:filters-admin-terms_rs.php


示例17: papi_get_taxonomy_label

/**
 * Get taxonomy label.
 *
 * @param  string $taxonomy
 * @param  string $label
 * @param  string $default
 *
 * @return string
 */
function papi_get_taxonomy_label($taxonomy, $label, $default = '')
{
    if (!taxonomy_exists($taxonomy)) {
        return $default;
    }
    return get_taxonomy($taxonomy)->labels->{$label};
}
开发者ID:wp-papi,项目名称:papi,代码行数:16,代码来源:taxonomy.php


示例18: get_taxonomy

 public function get_taxonomy($output = 'name')
 {
     if ('object' === $output) {
         return get_taxonomy($this->item->taxonomy);
     }
     return $this->item->taxonomy;
 }
开发者ID:felixarntz,项目名称:wp-objects,代码行数:7,代码来源:Term.php


示例19: _act_get_body_data

function _act_get_body_data()
{
    global $post;
    $body_data = array();
    //  echo 'pid';
    //
    $post_type = get_post_type(get_the_ID());
    if (is_archive()) {
        $post_type = "archive";
    }
    if (is_front_page()) {
        $post_type = 'home';
    }
    $body_data['post-type'] = $post_type;
    $post_slug = $post->post_name;
    if (is_archive() and isset(get_queried_object()->taxonomy)) {
        $tax = get_taxonomy(get_queried_object()->taxonomy);
        $post_slug = sanitize_title($tax->labels->singular_name);
    } elseif (is_archive() and !isset(get_queried_object()->taxonomy)) {
        $post_slug = get_queried_object()->name;
    }
    if (is_home()) {
        $post_slug = 'blog';
    }
    if (is_home() && is_paged()) {
        $post_slug = 'blog_paged';
    }
    $body_data['post-slug'] = $post_slug;
    return $body_data;
}
开发者ID:ambercouch,项目名称:ac_timber,代码行数:30,代码来源:functions--body-data.php


示例20: init

 public function init()
 {
     global $sitepress;
     $tax_get = filter_input(INPUT_GET, 'taxonomy');
     require ICL_PLUGIN_PATH . '/menu/term-taxonomy-menus/wpml-term-language-filter.class.php';
     if (($trid = filter_input(INPUT_GET, 'trid')) && ($source_lang = filter_input(INPUT_GET, 'source_lang')) && get_taxonomy($tax_get) !== false) {
         $translations = $sitepress->get_element_translations($trid, 'tax_' . $this->taxonomy);
         if (isset($translations[$_GET['lang']]) && !empty($translations[$_GET['lang']]->term_id)) {
             wp_redirect(get_edit_term_link($translations[$_GET['lang']]->term_id, $tax_get));
             exit;
         } else {
             add_action('admin_notices', array($this, '_tax_adding'));
         }
     }
     $term_lang_filter = new WPML_Term_Language_Filter(icl_get_setting('default_language'));
     if ($this->taxonomy === 'category') {
         add_action('edit_category_form', array($this, 'wpml_edit_term_form'));
     } else {
         add_action('add_tag_form', array($this, 'wpml_edit_term_form'));
         add_action('edit_tag_form', array($this, 'wpml_edit_term_form'));
     }
     add_action('admin_print_scripts-edit-tags.php', array($this, 'js_scripts_tags'));
     add_filter('wp_dropdown_cats', array($this, 'wp_dropdown_cats_select_parent'), 10, 2);
     add_action('admin_footer', array($term_lang_filter, 'terms_language_filter'));
 }
开发者ID:pcuervo,项目名称:odc,代码行数:25,代码来源:wpml-tax-menu-loader.class.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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