本文整理汇总了PHP中get_taxonomies函数的典型用法代码示例。如果您正苦于以下问题:PHP get_taxonomies函数的具体用法?PHP get_taxonomies怎么用?PHP get_taxonomies使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_taxonomies函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepare_items
function prepare_items()
{
$all_categories = array();
$taxonomies = get_taxonomies($args = array('public' => true, '_builtin' => false));
$taxonomies['category'] = 'category';
$all_terms = get_terms($taxonomies, 'orderby=count&hide_empty=0&order=DESC');
$totalitems = count($all_terms);
$perpage = 100;
$paged = !empty($_GET["paged"]) ? sanitize_text_field($_GET["paged"]) : '';
if (empty($paged) || !is_numeric($paged) || $paged <= 0) {
$paged = 1;
}
$totalpages = ceil($totalitems / $perpage);
$offset = 0;
if (!empty($paged) && !empty($perpage)) {
$offset = ($paged - 1) * $perpage;
}
for ($i = $offset; $i < (int) $offset + (int) $perpage && !empty($all_terms[$i]); $i++) {
$all_categories[] = $all_terms[$i];
}
$this->set_pagination_args(array("total_items" => $totalitems, "total_pages" => $totalpages, "per_page" => $perpage));
$columns = $this->get_columns();
$hidden = array();
$sortable = $this->get_sortable_columns();
$this->_column_headers = array($columns, $hidden, $sortable);
$this->items = $all_categories;
}
示例2: post_types
function post_types($categoryId=false){
$ret='';
/*получаем все пользовательские типы записей*/
$post_types=get_post_types(array(
'public' => true,
'_builtin' => false,
), 'objects');
foreach ($post_types as $post_type) {
$ret .= '<strong>'. $post_type->labels->singular_name. '</strong>';
$ret .= '<p class="news-yandex-ru-description">выберите рубрики посты из которых выводить в rss для яндекса. У выбранной рубрики в фид также будут включены все записи дочерних ей рубрик.</p>';
$ret .= '<p>';
/*получаем все иерархические taxonomies для типа записи*/
$taxonomies=get_taxonomies(array(
'hierarchical' => true,
'public' => true,
'_builtin' => false,
'object_type' => array($post_type->name),
), 'objects');
foreach ($taxonomies as $taxonomy) {
$ret .= $this->taxonomies(0, $taxonomy->name, $post_type->name);
}
$ret .= '</p>';
}
return $ret;
}
示例3: getPicklistOptions
/**
*
* @return array;
*/
public function getPicklistOptions()
{
$tax_args = array('public' => true, '_builtin' => false);
$taxonomies = get_taxonomies($tax_args);
$taxonomies[] = 'category';
$args = array('type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 1, 'hierarchical' => 1, 'taxonomy' => $taxonomies, 'pad_counts' => true);
$categories = get_categories($args);
$children = array();
if ($categories) {
foreach ($categories as $v) {
$v->title = $v->cat_name;
$v->parent_id = $v->category_parent;
$v->id = $v->cat_ID;
$pt = $v->category_parent;
$list = @$children[$pt] ? $children[$pt] : array();
array_push($list, $v);
$children[$pt] = $list;
}
}
//treecurse function from functions.php
$list = treerecurse($children);
$mitems = array();
foreach ($list as $item) {
$mitems[$item->id] = $item->treename;
}
return $mitems;
}
示例4: filter_content
public function filter_content($content)
{
// Get Templates
$templates = self::get_option('rwp_templates');
$terms = wp_get_object_terms(get_the_ID(), array_keys(get_taxonomies()));
$terms_keys = array();
foreach ($terms as $term) {
$terms_keys[$term->taxonomy][] = $term->term_id;
}
//self::pretty_print( $terms_keys );
foreach ($templates as $template) {
if (isset($template['template_auto_reviews']) && !empty($template['template_auto_reviews'])) {
if (is_singular($template['template_auto_reviews']) && is_main_query()) {
if (isset($template['template_exclude_terms'])) {
$to_exclude = false;
foreach ($template['template_exclude_terms'] as $id) {
$i = explode('-', $id);
if (in_array($i[1], $terms_keys[$i[0]])) {
$to_exclude = true;
break;
}
}
if ($to_exclude) {
continue;
}
}
$new_content = '[rwp-review id="-1" template="' . $template['template_id'] . '"]';
$content .= $new_content;
}
}
}
return $content;
}
示例5: getTaxonomies
protected function getTaxonomies($args = [])
{
$defaults = ['show_ui' => true];
$args = wp_parse_args($args, $defaults);
$taxonomies = get_taxonomies(apply_filters('g5_assignments_get_taxonomies_args', $args), 'object');
return $taxonomies;
}
示例6: get_all_taxonomies
/**
* Get a definitive set of all taxonomies recognized by Types.
*
* Respects if some builtin taxonomy is overridden by Types.
*
* @return array
* @since 1.9
*/
public static function get_all_taxonomies()
{
// todo add simple caching
$taxonomies = array();
// Read Types taxonomies first.
$types_taxonomies = get_option(WPCF_OPTION_NAME_CUSTOM_TAXONOMIES, array());
if (is_array($types_taxonomies)) {
foreach ($types_taxonomies as $slug => $data) {
$taxonomies[$slug] = $data;
}
}
// Get all taxonomies and add them to the set, but avoid overwriting Types taxonomies
$all_taxonomies = self::object_to_array_deep(get_taxonomies(array('public' => true), 'objects'));
foreach ($all_taxonomies as $slug => $data) {
// check if taxonomies are already saved as custom taxonomies
if (isset($taxonomies[$slug])) {
continue;
}
if (!isset($data['slug'])) {
$data['slug'] = $slug;
}
$taxonomies[$slug] = $data;
}
return $taxonomies;
}
示例7: column
public function column()
{
global $wp_version;
$is_wp_v3_1 = version_compare($wp_version, '3.0.999', '>');
add_filter('manage_media_columns', array($this, 'add'));
add_action('manage_media_custom_column', array($this, 'value'), 10, 2);
add_filter('manage_link-manager_columns', array($this, 'add'));
add_action('manage_link_custom_column', array($this, 'value'), 10, 2);
add_action('manage_edit-link-categories_columns', array($this, 'add'));
add_filter('manage_link_categories_custom_column', array($this, 'returnvalue'), 10, 3);
foreach (get_taxonomies() as $taxonomy) {
add_action("manage_edit-{$taxonomy}_columns", array($this, 'add'));
add_filter("manage_{$taxonomy}_custom_column", array($this, 'returnvalue'), 10, 3);
if ($is_wp_v3_1) {
add_filter("manage_edit-{$taxonomy}_sortable_columns", array($this, 'add'));
}
}
foreach (get_post_types() as $post_type) {
add_action("manage_edit-{$post_type}_columns", array($this, 'add'));
add_filter("manage_{$post_type}_posts_custom_column", array($this, 'value'), 10, 3);
if ($is_wp_v3_1) {
add_filter("manage_edit-{$post_type}_sortable_columns", array($this, 'add'));
}
}
add_action('manage_users_columns', array($this, 'add'));
add_filter('manage_users_custom_column', array($this, 'returnvalue'), 10, 3);
if ($is_wp_v3_1) {
add_filter("manage_users_sortable_columns", array($this, 'add'));
}
add_action('manage_edit-comments_columns', array($this, 'add'));
add_action('manage_comments_custom_column', array($this, 'value'), 10, 2);
if ($is_wp_v3_1) {
add_filter("manage_edit-comments_sortable_columns", array($this, 'add'));
}
}
示例8: wptouch_register_theme_custom_post_types
function wptouch_register_theme_custom_post_types()
{
if (wptouch_is_mobile_theme_showing()) {
$settings = foundation_get_settings();
$post_types_to_preserve = get_option('wptouch_custom_post_types');
$post_types_to_register = array();
$registered_types = wptouch_custom_posts_get_list(true);
if (is_array($post_types_to_preserve) && count($post_types_to_preserve) > 0) {
foreach ($post_types_to_preserve as $type => $object) {
if (!is_object($object)) {
$object = maybe_unserialize(urldecode($object));
}
if (!in_array($type, $registered_types)) {
$args = array('labels' => array('name' => $object->labels->name, 'singular_name' => $object->labels->singular_name), 'taxonomies' => $object->taxonomies, 'hierarchical' => $object->hierarchical, 'public' => $object->public, 'has_archive' => $object->has_archive, 'exclude_from_search' => $object->exclude_from_search, 'publicly_queryable' => $object->publicly_queryable, 'rewrite' => $object->rewrite, 'query_var' => $object->query_var);
register_post_type($type, $args);
}
}
}
$taxonomies_to_preserve = get_option('wptouch_custom_taxonomies');
$taxonomies_to_register = array();
$args = array('public' => true);
$output = 'names';
$registered_taxonomies = get_taxonomies($args, $output);
if (is_array($taxonomies_to_preserve)) {
foreach ($taxonomies_to_preserve as $taxonomy => $object) {
if (!in_array($taxonomy, $registered_taxonomies)) {
$args = array('hierarchical' => $object->hierarchical, 'query_var' => $object->query_var, 'rewrite' => $object->rewrite);
register_taxonomy($taxonomy, $object->object_type, $args);
}
}
}
}
}
示例9: display_field
public function display_field($field, $group_index = 1, $field_index = 1)
{
global $mf_domain;
// If is not required this field be added a None value
$notype = "";
if (!$field['required_field']) {
$notype = !empty($field['options']['notype']) ? $field['options']['notype'] : __("-- None --", $mf_domain);
}
$output = '';
// Get the taxonomie as dropdownoption
$select = array();
$tax = get_taxonomies();
foreach ($tax as $k => $v) {
$select[] = $v;
}
$option_from_term_array = $field['options']['term'];
$options = get_terms($select[$option_from_term_array], array('hide_empty' => false));
$output = '<div class="mf-dropdown-box">';
$value = $field['input_value'];
$output .= sprintf('<select class="dropdown_mf" id="%s" name="%s" >', $field['input_id'], $field['input_name']);
if ($notype != "") {
$output .= "<option value=''>{$notype}</option>";
}
foreach ($options as $option) {
$check = $option->slug == $value ? 'selected="selected"' : '';
$output .= sprintf('<option value="%s" %s >%s</option>', esc_attr($option->slug), $check, esc_attr($option->name));
}
$output .= '</select>';
$output .= '</div>';
return $output;
}
示例10: easy_wp_pagenavigation_set_posts_per_page
function easy_wp_pagenavigation_set_posts_per_page($query)
{
if (is_admin()) {
return;
}
$options = get_option(EWPN_ST);
// Get taxonomies custom posts per page
$args = array('public' => true, 'show_ui' => true);
$taxonomies = get_taxonomies($args);
if (!empty($taxonomies)) {
foreach ($taxonomies as $key => $val) {
if (isset($options[$key]) && !empty($options[$key]) && is_numeric($options[$key])) {
if ($key == 'category') {
if (is_category() && $query->is_main_query()) {
$query->set('posts_per_page', $options[$key]);
}
} elseif ($key == 'post_tag') {
if (is_tag() && $query->is_main_query()) {
$query->set('posts_per_page', $options[$key]);
}
} else {
if (is_tax($key) && $query->is_main_query()) {
$query->set('posts_per_page', $options[$key]);
}
}
}
}
}
}
示例11: 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'));
}
示例12: mla_admin_init_action
/**
* Adds Custom Field support to the Edit Media screen.
* Declared public because it is an action.
*
* @since 0.80
*
* @return void echoes the HTML markup for the label and value
*/
public static function mla_admin_init_action()
{
static $mc_att_category_metabox = array();
/*
* Enable the enhanced "Media Categories" searchable metaboxes for hiearchical taxonomies
*/
if (class_exists('Media_Categories') && ('checked' == MLAOptions::mla_get_option(MLAOptions::MLA_MEDIA_MODAL_DETAILS_CATEGORY_METABOX) || 'checked' == MLAOptions::mla_get_option(MLAOptions::MLA_MEDIA_MODAL_DETAILS_TAG_METABOX))) {
$taxonomies = get_taxonomies(array('show_ui' => true), 'objects');
foreach ($taxonomies as $key => $value) {
if (MLAOptions::mla_taxonomy_support($key)) {
if ($value->hierarchical) {
if ('checked' == MLAOptions::mla_get_option(MLAOptions::MLA_MEDIA_MODAL_DETAILS_CATEGORY_METABOX)) {
$mc_att_category_metabox[] = new Media_Categories($key);
}
} else {
if ('checked' == MLAOptions::mla_get_option(MLAOptions::MLA_MEDIA_MODAL_DETAILS_TAG_METABOX)) {
$mc_att_category_metabox[] = new Media_Categories($key);
}
}
// flat
}
// is supported
}
// foreach
}
// class_exists
add_post_type_support('attachment', 'custom-fields');
}
示例13: 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();
}
示例14: taxonomy_slug_rewrite
function taxonomy_slug_rewrite($wp_rewrite)
{
$rules = array();
// get all custom taxonomies
$taxonomies = get_taxonomies(array('_builtin' => false), 'objects');
// get all custom post types
$post_types = get_post_types(array('public' => true, '_builtin' => false), 'objects');
foreach ($post_types as $post_type) {
foreach ($taxonomies as $taxonomy) {
// go through all post types which this taxonomy is assigned to
foreach ($taxonomy->object_type as $object_type) {
// check if taxonomy is registered for this custom type
if ($object_type == $post_type->rewrite['slug']) {
// get category objects
$terms = get_categories(array('type' => $object_type, 'taxonomy' => $taxonomy->name, 'hide_empty' => 0));
// make rules
foreach ($terms as $term) {
$rules[$object_type . '/' . $term->slug . '/?$'] = 'index.php?' . $term->taxonomy . '=' . $term->slug;
}
}
}
}
}
// merge with global rules
$wp_rewrite->rules = $rules + $wp_rewrite->rules;
}
示例15: parse_request
public function parse_request($qty, $request = array())
{
if (is_null($qty)) {
$qty = Utils::instance()->get_qty_from_range(Variable::super(INPUT_POST, array(Plugin::$slug, 'qty'), FILTER_UNSAFE_RAW));
}
if (0 === $qty) {
return esc_attr__('Zero is not a good number of terms to fake...', 'fakerpress');
}
$name_size = Variable::super(INPUT_POST, array(Plugin::$slug, 'size'), FILTER_UNSAFE_RAW);
// Fetch taxomies
$taxonomies = Variable::super($request, array('taxonomies'), FILTER_SANITIZE_STRING);
$taxonomies = array_map('trim', explode(',', $taxonomies));
$taxonomies = array_intersect(get_taxonomies(array('public' => true)), $taxonomies);
// Only has meta after 4.4-beta
$has_metas = version_compare($GLOBALS['wp_version'], '4.4-beta', '>=');
if ($has_metas) {
$metas = Variable::super($request, array('meta'), FILTER_UNSAFE_RAW);
}
for ($i = 0; $i < $qty; $i++) {
$this->set('taxonomy', $taxonomies);
$this->set('name', $name_size);
$this->set('description');
$this->set('parent_term');
$term_id = $this->generate()->save();
if ($has_metas && $term_id && is_numeric($term_id)) {
foreach ($metas as $meta_index => $meta) {
Meta::instance()->object($term_id, 'term')->generate($meta['type'], $meta['name'], $meta)->save();
}
}
$results[] = $term_id;
}
$results = array_filter((array) $results, 'absint');
return $results;
}