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


PHP get_object_taxonomies函数代码示例

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


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

示例1: mltlngg_admin_init

 function mltlngg_admin_init()
 {
     global $bws_plugin_info, $mltlngg_plugin_info, $bws_shortcode_list;
     if (!isset($bws_plugin_info) || empty($bws_plugin_info)) {
         $bws_plugin_info = array('id' => '143', 'version' => $mltlngg_plugin_info["Version"]);
     }
     /* Actions for categories & tags translation */
     $mltlngg_taxonomies = get_object_taxonomies('post');
     if (is_array($mltlngg_taxonomies)) {
         foreach ($mltlngg_taxonomies as $mltlngg_taxonomy) {
             add_action($mltlngg_taxonomy . '_add_form_fields', 'mltlngg_new_terms_translate');
             add_action('created_' . $mltlngg_taxonomy, 'mltlngg_new_terms_created');
             add_action($mltlngg_taxonomy . '_edit_form_fields', 'mltlngg_terms_translate');
             add_action('edited_' . $mltlngg_taxonomy, 'mltlngg_terms_update');
             add_action('delete_' . $mltlngg_taxonomy, 'mltlngg_delete_term');
             /* Add language column in the taxonomy wp_list_table to display if language is translated */
             add_filter('manage_edit-' . $mltlngg_taxonomy . '_columns', 'mltlngg_add_term_column');
             add_filter('manage_' . $mltlngg_taxonomy . '_custom_column', 'mltlngg_term_column', 10, 3);
         }
     }
     /* Add language column in the post wp_list_table to display if language is translated */
     add_filter('manage_edit-post_columns', 'mltlngg_add_post_column');
     add_filter('manage_post_posts_custom_column', 'mltlngg_post_column', 10, 3);
     add_filter('manage_edit-page_columns', 'mltlngg_add_post_column');
     add_filter('manage_page_posts_custom_column', 'mltlngg_post_column', 10, 3);
     /* add Multilanguage to global $bws_shortcode_list  */
     $bws_shortcode_list['mltlngg'] = array('name' => 'Multilanguage');
     /* add 'Multilanguage switcher' into the Menu */
     add_action('wp_update_nav_menu_item', 'mltlngg_wp_update_nav_menu_item', 10, 2);
     add_meta_box('mltlngg_language_switcher_box', __('Multilanguage switcher', 'multilanguage'), 'mltlngg_language_switcher_box', 'nav-menus', 'side', 'high');
 }
开发者ID:egore,项目名称:wordpress-multilanguage,代码行数:31,代码来源:multilanguage.php

示例2: widget

    /**
     * widget function.
     *
     * @see WP_Widget
     *
     * @param array $args
     * @param array $instance
     */
    public function widget($args, $instance)
    {
        global $_chosen_attributes, $wpdb, $wp;
        if (!is_post_type_archive('product') && !is_tax(get_object_taxonomies('product'))) {
            return;
        }
        if (!sizeof(WC()->query->unfiltered_product_ids)) {
            return;
            // None shown - return
        }
        $min_rating = isset($_GET['min_rating']) ? absint($_GET['min_rating']) : '';
        $this->widget_start($args, $instance);
        echo '<ul>';
        for ($rating = 4; $rating >= 1; $rating--) {
            $link = $this->get_page_base_url();
            $link = $min_rating !== $rating ? add_query_arg('min_rating', $rating, $link) : $link;
            echo '<li class="wc-layered-nav-rating ' . (!empty($_GET['min_rating']) && $rating === absint($_GET['min_rating']) ? 'chosen' : '') . '">';
            echo '<a href="' . esc_url(apply_filters('woocommerce_rating_filter_link', $link)) . '">';
            echo '<span class="star-rating" title="' . esc_attr(sprintf(__('Rated %s and above', 'woocommerce'), $rating)) . '">
					<span style="width:' . esc_attr($rating / 5 * 100) . '%">' . sprintf(__('Rated %s and above', 'woocommerce'), $rating) . '</span>
				</span>';
            echo '</a>';
            echo '</li>';
        }
        echo '</ul>';
        $this->widget_end($args);
    }
开发者ID:KristoferN,项目名称:woocommerce,代码行数:35,代码来源:class-wc-widget-rating-filter.php

示例3: add

 public function add()
 {
     $this->validateNonce();
     if (!isset($_REQUEST['id'])) {
         die('ID not specified');
     }
     // Код товара
     $id = (int) $_REQUEST['id'];
     $product = get_post($id);
     $title = $product->post_title;
     // Цена
     $price = simple_basket_custom_fields($id, get_option('simple_basket_catalog_price'));
     // Вычисляем категорию по таксономии
     $category = '';
     // Тип записи каталога товара
     $postType = $product->post_type;
     // Таксономии записи
     $taxonomies = get_object_taxonomies($postType);
     // Ищем таксономию, которая не тег
     foreach ($taxonomies as $taxonomy) {
         if (strpos($taxonomy, 'tag') !== FALSE) {
             continue;
         }
         // Берем элементы этой таксономии
         $categories = get_the_terms($id, $taxonomy);
         $category = count($categories) > 0 ? $categories[0]->name : '';
         // Следующие таксономии не рассматриваем
         break;
     }
     // Добавляем в корзину
     if (!empty($title)) {
         $this->basket->add($id, $title, $price, $category);
     }
     $this->responce($this->basket);
 }
开发者ID:shugich,项目名称:simple-basket,代码行数:35,代码来源:ajax-api.php

示例4: sell_media_set_default_terms

/**
 * Set Default Terms
 * Used in attachment-functions.php
 *
 * @since 0.1
 */
function sell_media_set_default_terms($post_id, $post = null, $term_ids = null)
{
    if (is_null($post)) {
        $post_type = get_post_type($post_id);
    } else {
        $post_type = $post->post_type;
        $post_status = $post->post_status;
    }
    if (empty($post_status)) {
        return;
    }
    if (empty($term_ids) || $term_ids === true) {
        $term_ids = sell_media_get_default_terms();
    }
    $taxonomy = 'licenses';
    $default_terms = array();
    foreach ($term_ids as $term_id) {
        $tmp_term_id = get_term_by('id', $term_id, $taxonomy);
        if ($tmp_term_id) {
            $default_terms[] = (int) $tmp_term_id->term_id;
            $default_terms[] = (int) $tmp_term_id->parent;
        }
    }
    $defaults = array($taxonomy => $default_terms);
    $taxonomies = get_object_taxonomies($post_type);
    foreach ((array) $taxonomies as $taxonomy) {
        $terms = wp_get_post_terms($post_id, $taxonomy);
        if (empty($terms) && array_key_exists($taxonomy, $defaults)) {
            wp_set_object_terms($post_id, $defaults[$taxonomy], $taxonomy);
        }
    }
}
开发者ID:rickalday,项目名称:Sell-Media,代码行数:38,代码来源:term-meta.php

示例5: get_rocket_post_terms_urls

/**
 * Get all terms archives urls associated to a specific post
 *
 * @since 1.0
 *
 * @param int $post_ID The post ID
 * @return array $urls List of taxonomies URLs
 */
function get_rocket_post_terms_urls($post_ID)
{
    $urls = array();
    $taxonomies = get_object_taxonomies(get_post_type($post_ID), 'objects');
    foreach ($taxonomies as $taxonomy) {
        if (!$taxonomy->public) {
            continue;
        }
        // Get the terms related to post
        $terms = get_the_terms($post_ID, $taxonomy->name);
        if (!empty($terms)) {
            foreach ($terms as $term) {
                $term_url = get_term_link($term->slug, $taxonomy->name);
                if (!is_wp_error($term_url)) {
                    $urls[] = $term_url;
                }
            }
        }
    }
    /**
     * Filter the list of taxonomies URLs
     *
     * @since 1.1.0
     *
     * @param array $urls List of taxonomies URLs
     */
    $urls = apply_filters('rocket_post_terms_urls', $urls);
    return $urls;
}
开发者ID:EliasGoldberg,项目名称:troop-sim,代码行数:37,代码来源:posts.php

示例6: load_static_vars

 /**
  *  Load constants
  */
 public static function load_static_vars()
 {
     if (!isset($_REQUEST['page']) || $_REQUEST['page'] != 'lead_management') {
         return;
     }
     /* clean POST and REQUEST arrays of added slashes */
     $_POST = stripslashes_deep($_POST);
     $_REQUEST = stripslashes_deep($_REQUEST);
     /* set ordering & paging vars */
     self::$per_page = 60;
     self::$page = empty($_REQUEST['pull_page']) ? 1 : intval($_REQUEST['pull_page']);
     self::$paged = empty($_REQUEST['paged']) ? 1 : intval($_REQUEST['paged']);
     self::$orderby = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : '';
     self::$order = isset($_REQUEST['order']) ? strtoupper($_REQUEST['order']) : 'ASC';
     /* set ordering vars */
     self::$orderbys = array(__('Date First Created', 'leads') => 'date', __('Date Last Modified', 'leads') => 'modified', __('Alphabetical Sort', 'leads') => 'title', __('Status', 'leads') => 'post_status');
     /* set ordering vars */
     self::$orderbys_flip = array_flip(self::$orderbys);
     /* number of leads affected by action if any */
     self::$num = isset($_REQUEST['num']) ? intval($_REQUEST['num']) : 0;
     self::$what = isset($_REQUEST['what']) ? htmlentities($_REQUEST['what']) : "";
     self::$relation = isset($_REQUEST['relation']) ? htmlentities($_REQUEST['relation']) : "AND";
     self::$on = isset($_REQUEST['on']) ? htmlentities($_REQUEST['on']) : "";
     self::$tag = isset($_REQUEST['t']) ? $_REQUEST['t'] : '';
     self::$keyword = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
     self::$taxonomies = get_object_taxonomies('wp-lead', 'objects');
 }
开发者ID:jyotiprava,项目名称:45serverbackup,代码行数:30,代码来源:class.lead-management.php

示例7: get_related

 /**
  * Get related post ids
  *
  * @param int $post_id
  *
  * @return array Post ids
  */
 function get_related($post_id)
 {
     $related = array();
     $taxonomies = get_object_taxonomies($this->post->post_type);
     if ($taxonomies) {
         foreach ($taxonomies as $taxonomy) {
             $terms = wp_get_post_terms($this->post->ID, $taxonomy);
             if ($terms) {
                 foreach ($terms as $term) {
                     $posts = new WP_Query(wp_parse_args(array('posts_per_page' => '-1', 'tax_query' => array(array('taxonomy' => $taxonomy, 'terms' => $term->slug, 'field' => 'slug'))), $this->args));
                     if ($posts->have_posts()) {
                         while ($posts->have_posts()) {
                             $posts->the_post();
                             if (!isset($related[get_the_ID()])) {
                                 $related[get_the_ID()] = 0;
                             }
                             $related[get_the_ID()] += 1;
                         }
                     }
                     wp_reset_postdata();
                 }
             }
         }
     }
     //Put them in the right order and chop off what we don't need
     asort($related);
     $related = array_reverse($related, true);
     if ($this->args['posts_per_page'] != -1) {
         $related = array_chunk($related, $this->args['posts_per_page'], true);
     } else {
         $related = array($related);
     }
     return isset($related[0]) ? array_keys($related[0]) : array();
 }
开发者ID:trendwerk,项目名称:related,代码行数:41,代码来源:class-tp-related.php

示例8: deleted_term_relationships

 /**
  * This action is hooked to the 'deleted_term_relationships' hook.
  * It removes terms from translated posts as soon as they are removed from the original post.
  * It only fires, if the setting 'sync_post_taxonomies' is activated.
  *
  * @param int   $post_id      ID of the post the deleted terms were attached to
  * @param array $delete_terms Array of term taxonomy id's for those terms that were deleted from the post.
  */
 public function deleted_term_relationships($post_id, $delete_terms)
 {
     $post = get_post($post_id);
     $trid = $this->sitepress->get_element_trid($post_id, 'post_' . $post->post_type);
     if ($trid) {
         $translations = $this->sitepress->get_element_translations($trid, 'post_' . $post->post_type);
         foreach ($translations as $translation) {
             if ($translation->original == 1 && $translation->element_id == $post_id) {
                 $taxonomies = get_object_taxonomies($post->post_type);
                 foreach ($taxonomies as $taxonomy) {
                     foreach ($delete_terms as $delete_term) {
                         $trid = $this->sitepress->get_element_trid($delete_term, 'tax_' . $taxonomy);
                         if ($trid) {
                             $tags = $this->sitepress->get_element_translations($trid, 'tax_' . $taxonomy);
                             foreach ($tags as $tag) {
                                 if (!$tag->original && isset($translations[$tag->language_code])) {
                                     $translated_post = $translations[$tag->language_code];
                                     $this->wpdb->delete($this->wpdb->term_relationships, array('object_id' => $translated_post->element_id, 'term_taxonomy_id' => $tag->element_id));
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:35,代码来源:class-wpml-term-actions.php

示例9: gencwooc_template_loader

/**
 * Load the Genesis-fied templates, instead of the WooCommerce defaults.
 *
 * Hooked to 'template_include' filter
 *
 * This template loader determines which template file will be used for the requested page, and uses the
 * following hierarchy to find the template:
 * 1. First looks in the child theme's 'woocommerce' folder.
 * 2. If no template found, falls back to GCW's templates.
 *
 * For taxonomy templates, first looks in child theme's 'woocommerce' folder and searches for term specific template,
 * then taxonomy specific template, then taxonomy.php. If no template found, falls back to GCW's taxonomy.php.
 *
 * GCW provides three templates in the plugin's 'templates' directory:
 * - single-product.php
 * - archive-product.php
 * - taxonomy.php
 *
 * Users can override GCW templates by placing their own templates in their child theme's 'woocommerce' folder.
 * The 'woocommerce' folder must be a folder in the child theme's root directory, eg themes/my-child-theme/woocommerce
 * Permitted user templates (as per WP Template Hierarchy) are:
 * - single-product.php
 * - archive-product.php
 * - taxonomy-{taxonomy-name}-{term-name}.php
 * - taxonomy-{taxonomy-name}.php
 * - taxonomy.php
 *
 * Note that in the case of taxonomy templates, this function accommodates ALL taxonomies registered to the
 * 'product' custom post type. This means that it will cater for users' own custom taxonomies as well as WooC's.
 *
 * @since 0.9.0
 *
 * @param string $template Template file as per template hierarchy
 * @return string $template Specific GCW template if a product page (single or archive)
 * or a product taxonomy term, or returns original template
 */
function gencwooc_template_loader($template)
{
    if (is_single() && 'product' == get_post_type()) {
        $template = locate_template(array('woocommerce/single-product.php'));
        if (!$template) {
            $template = GCW_TEMPLATE_DIR . '/single-product.php';
        }
    } elseif (is_post_type_archive('product') || is_page(get_option('woocommerce_shop_page_id'))) {
        $template = locate_template(array('woocommerce/archive-product.php'));
        if (!$template) {
            $template = GCW_TEMPLATE_DIR . '/archive-product.php';
        }
    } elseif (is_tax()) {
        $term = get_query_var('term');
        $tax = get_query_var('taxonomy');
        /** Get an array of all relevant taxonomies */
        $taxonomies = get_object_taxonomies('product', 'names');
        if (in_array($tax, $taxonomies)) {
            $tax = sanitize_title($tax);
            $term = sanitize_title($term);
            $templates = array('woocommerce/taxonomy-' . $tax . '-' . $term . '.php', 'woocommerce/taxonomy-' . $tax . '.php', 'woocommerce/taxonomy.php');
            $template = locate_template($templates);
            /** Fallback to GCW template */
            if (!$template) {
                $template = GCW_TEMPLATE_DIR . '/taxonomy.php';
            }
        }
    }
    return $template;
}
开发者ID:hscale,项目名称:webento,代码行数:66,代码来源:template-loader.php

示例10: admin_init

 public function admin_init()
 {
     //set the settings
     $page = $this->page;
     //add_section
     //you can pass section_id, section_title, section_description, the section id must be unique for this page, section descriptiopn is optional
     $page->add_section('basic_section', __('Settings', 'buddyblog'), __('Settings for BuddyBlog.', 'buddyblog'));
     $post_types = get_post_types(array('public' => true));
     //public post types
     $post_type_options = array();
     foreach ($post_types as $post_type) {
         $post_type_object = get_post_type_object($post_type);
         $post_type_options[$post_type] = $post_type_object->labels->name;
     }
     $post_statuses = array('publish' => __('Published', 'buddyblog'), 'draft' => __('Draft', 'buddyblog'));
     $comment_statuses = array('open' => __('Open', 'buddyblog'), 'close' => __('Closed', 'buddyblog'));
     $default_post_type = buddyblog_get_posttype() ? buddyblog_get_posttype() : 'post';
     $taxonomies = get_object_taxonomies($default_post_type);
     if (isset($taxonomies['post_format'])) {
         unset($taxonomies['post_format']);
     }
     $tax = array();
     foreach ($taxonomies as $taxonomy) {
         $tax_object = get_taxonomy($taxonomy);
         $tax[$taxonomy] = $tax_object->labels->name;
     }
     //add fields
     $page->get_section('basic_section')->add_fields(array(array('name' => 'post_type', 'label' => __('Blog Post Type', 'buddyblog'), 'desc' => __('Set the post type for user blog.', 'buddyblog'), 'type' => 'select', 'default' => $default_post_type, 'options' => $post_type_options), array('name' => 'post_status', 'label' => __('Default post status', 'buddyblog'), 'desc' => __('What should be the post status when user submits the form?', 'buddyblog'), 'type' => 'select', 'default' => 'publish', 'options' => $post_statuses), array('name' => 'comment_status', 'label' => __('Comment status?', 'buddyblog'), 'desc' => __('Do you want to allow commenting on user posts?', 'buddyblog'), 'type' => 'select', 'default' => 'open', 'options' => $comment_statuses), array('name' => 'show_comment_option', 'label' => __('Allow post author to enable/disable comment?', 'buddyblog'), 'desc' => __('If you enable, A user will be able to change the comment status for his/her post.', 'buddyblog'), 'type' => 'radio', 'default' => 1, 'options' => array(1 => __('Yes', 'buddyblog'), 0 => __('No', 'buddyblog'))), array('name' => 'enable_taxonomy', 'label' => __('Enable Taxonomy?', 'buddyblog'), 'desc' => __('If you enable, users will be able to select terms from the selected taxonomies.', 'buddyblog'), 'type' => 'radio', 'default' => 1, 'options' => array(1 => __('Yes', 'buddyblog'), 0 => __('No', 'buddyblog'))), array('name' => 'allowed_taxonomies', 'label' => __('Select allowed taxonomies', 'buddyblog'), 'desc' => __('Please check the taxonomies you want users to be able to attach to their post.', 'buddyblog'), 'type' => 'multicheck', 'default' => 'category', 'options' => $tax), array('name' => 'show_posts_on_profile', 'label' => __('Show single posts on user profile?', 'buddyblog'), 'desc' => __('If you enable it, the permalink to single post will be something like http://yoursite.com/members/username/buddyblog/postname.', 'buddyblog'), 'type' => 'radio', 'default' => 0, 'options' => array(1 => __('Yes', 'buddyblog'), 0 => __('No', 'buddyblog'))), array('name' => 'limit_no_of_posts', 'label' => __('Limit number of posts a user can create?', 'buddyblog'), 'desc' => __('If you enable it, You can control the allowed number of posts from the next option.', 'buddyblog'), 'type' => 'radio', 'default' => 0, 'options' => array(1 => __('Yes', 'buddyblog'), 0 => __('No', 'buddyblog'))), array('name' => 'max_allowed_posts', 'label' => __('How many posts a user can create?', 'buddyblog'), 'desc' => __('Only applies if you have enabled the limit on posts from above option.', 'buddyblog'), 'type' => 'text', 'default' => 10), array('name' => 'publish_cap', 'label' => __('Which capability is required for pusblishing?', 'buddyblog'), 'desc' => __('Please check for https://codex.wordpress.org/Roles_and_Capabilities allowed capabilities.', 'buddyblog'), 'type' => 'text', 'default' => 'read'), array('name' => 'allow_unpublishing', 'label' => __('Allow users to unpublish their own post?', 'buddyblog'), 'desc' => '', 'type' => 'radio', 'default' => 0, 'options' => array(1 => __('Yes', 'buddyblog'), 0 => __('No', 'buddyblog'))), array('name' => 'post_cap', 'label' => __('Which capability is required for creating post?', 'buddyblog'), 'desc' => __('Please check for https://codex.wordpress.org/Roles_and_Capabilities allowed capabilities.', 'buddyblog'), 'type' => 'text', 'default' => 'read'), array('name' => 'allow_edit', 'label' => __('Allow user to edit their post?', 'buddyblog'), 'desc' => __('if you disable it, user will not be able to edit their own post.', 'buddyblog'), 'type' => 'radio', 'default' => 1, 'options' => array(1 => __('Yes', 'buddyblog'), 0 => __('No', 'buddyblog'))), array('name' => 'dashboard_edit_cap', 'label' => __('Which capability can edit post in backend(WordPress Dashboard)?', 'buddyblog'), 'desc' => __('User with these capabilities will nto be redirected to front end editor for editing post., user will not be able to edit their own post.', 'buddyblog'), 'type' => 'text', 'default' => 'publish_posts'), array('name' => 'allow_delete', 'label' => __('Allow user to delete their post?', 'buddyblog'), 'desc' => __('if you disable it, user will not be able to delete their own post.', 'buddyblog'), 'type' => 'radio', 'default' => 1, 'options' => array(1 => __('Yes', 'buddyblog'), 0 => __('No', 'buddyblog')))));
     $page->init();
 }
开发者ID:poweronio,项目名称:mbsite,代码行数:30,代码来源:admin.php

示例11: sync_variation_swatches_and_photos

 function sync_variation_swatches_and_photos($original_product_id, $trnsl_product_id, $data = false)
 {
     global $sitepress, $wpdb;
     $atts = maybe_unserialize(get_post_meta($original_product_id, '_swatch_type_options', true));
     if (!is_array($atts)) {
         return;
     }
     $lang = $sitepress->get_language_for_element($trnsl_product_id, 'post_product');
     $tr_atts = $atts;
     $original_product_post = get_post($original_product_id);
     $original_product_taxonomies = get_object_taxonomies($original_product_post);
     $original_product_terms = get_terms($original_product_taxonomies);
     if (is_array($original_product_terms)) {
         foreach ($atts as $att_name => $att_opts) {
             $attributes_hashed_names = array_keys($att_opts['attributes']);
             foreach ($original_product_terms as $original_product_term) {
                 $original_product_term_slug_md5 = md5($original_product_term->slug);
                 if (in_array($original_product_term_slug_md5, $attributes_hashed_names)) {
                     $translated_product_term_id = apply_filters('wpml_object_id', $original_product_term->term_id, $original_product_term->taxonomy, false, $lang);
                     $translated_product_term = get_term($translated_product_term_id, $original_product_term->taxonomy);
                     if (is_object($translated_product_term)) {
                         $translated_product_term_slug_md5 = md5($translated_product_term->slug);
                         $tr_atts[$att_name]['attributes'][$translated_product_term_slug_md5] = $tr_atts[$att_name]['attributes'][$original_product_term_slug_md5];
                         unset($tr_atts[$att_name]['attributes'][$original_product_term_slug_md5]);
                     }
                 }
             }
         }
     }
     update_post_meta($trnsl_product_id, '_swatch_type_options', $tr_atts);
     // Meta gets overwritten
 }
开发者ID:yjhcfzx,项目名称:test_woo,代码行数:32,代码来源:class-wcml-variation-swatches-and-photos.php

示例12: __construct

 public function __construct($data)
 {
     parent::__construct($data);
     if ('' === $this->name) {
         $this->name = 'taxonomy-list';
     }
     // If a taxonomy wasn't passed in, assume the first taxonomy associated with the post type.
     if (!isset($data['taxonomy'])) {
         $post_object_taxonomies = get_object_taxonomies($this->post_object);
         $this->taxonomy = array_shift($post_object_taxonomies);
     } else {
         $this->taxonomy = $data['taxonomy'];
     }
     $this->before_list = isset($data['before-list']) ? $data['before-list'] : '';
     $this->separator = isset($data['separator']) ? $data['separator'] : ', ';
     $this->after_list = isset($data['after-list']) ? $data['after-list'] : '';
     $this->include_links = isset($data['include-links']) ? $data['include-links'] : true;
     $this->tag = isset($data['tag']) ? $data['tag'] : 'p';
     if (true === $this->include_links) {
         $this->content = get_the_term_list($this->post_object->ID, $this->taxonomy, $this->before_list, $this->separator, $this->after_list);
     } else {
         $terms_arr = get_the_terms($this->post_object->ID, $this->taxonomy);
         $term_names_arr = array();
         if (!empty($terms_arr)) {
             foreach ($terms_arr as $term_obj) {
                 $term_names_arr[] = '<span class="name">' . $term_obj->name . '</span>';
             }
             $terms_list = implode($this->separator, $term_names_arr);
             $this->content = $this->before_list . $terms_list . $this->after_list;
         } else {
             $this->content = '';
         }
     }
 }
开发者ID:Clark-Nikdel-Powell,项目名称:Pattern-Library,代码行数:34,代码来源:taxonomy-list.php

示例13: get_terms_list_callback

function get_terms_list_callback()
{
    global $wpdb;
    $selected_post_type = $_POST['selected_post_type'];
    if ($_POST['widget_name']) {
        $widget_option = get_option('widget_' . $_POST['widget_name']);
        $post_category = $widget_option[$_POST['instance_id']]['post_category'];
    }
    $taxonomies = get_object_taxonomies($selected_post_type);
    if (!empty($taxonomies)) {
        $categories_content = '';
        foreach ($taxonomies as $taxonomy) {
            $args = array('taxonomy' => $taxonomy, 'orderby' => 'name', 'show_count' => 0, 'pad_counts' => 0, 'hierarchical' => 1, 'hide_empty' => 0);
            $categories = get_categories($args);
            foreach ($categories as $category) {
                if (!empty($post_category)) {
                    if (is_array($post_category) && in_array($category->term_id, $post_category)) {
                        $checked = 'checked="checked"';
                    } else {
                        $checked = '';
                    }
                } else {
                    $checked = '';
                }
                $categories_content .= '<li id="category-' . $category->term_id . '"><label class="selectit"><input type="checkbox" id="in-category-' . $category->term_id . '" name="post_category[]" value="' . $category->term_id . '" ' . $checked . '> ' . $category->name . '</label></li>' . "\n";
            }
        }
    } else {
        $categories_content = 'No taxonomies for selected post type';
    }
    echo $categories_content;
    wp_die();
}
开发者ID:johnmanlove,项目名称:JMMC_Corp-Site,代码行数:33,代码来源:lptw-recent-posts-backend.php

示例14: yt_to_posts_getPostTypeCats

function yt_to_posts_getPostTypeCats()
{
    // Returns an array of all Youtube ID (to check dupes)
    $type = $_POST['post_type'];
    $taxs = get_object_taxonomies($type);
    $results = array();
    if (empty($taxs)) {
        echo 'empty';
    } else {
        foreach ($taxs as $tax) {
            if ($tax === "post_tag" || $tax === "post_format") {
            } else {
                $args = array('orderby' => 'name', 'order' => 'ASC', 'hide_empty' => false, 'exclude' => array(), 'exclude_tree' => array(), 'include' => array(), 'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '', 'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name__like' => '', 'description__like' => '', 'pad_counts' => false, 'offset' => '', 'search' => '', 'cache_domain' => 'core');
                $tax_terms = get_terms($tax, $args);
                // var_dump($tax_terms);
                foreach ($tax_terms as $tax_term) {
                    if ($tax_term) {
                        $object = new stdClass();
                        $object->id = $tax_term->term_id;
                        $object->name = $tax_term->name;
                        $results[] = $object;
                    }
                }
            }
        }
        $results = json_encode($results);
        echo $results;
    }
    die;
}
开发者ID:enguerranws,项目名称:import-youtube-videos-as-wp-posts,代码行数:30,代码来源:import-youtube-videos-as-wp-post.php

示例15: default_item

 function default_item($key = 0, $old = array())
 {
     $default = array('title' => '', 'field' => '', 'taxonomy' => '', 'order' => '', 'style' => 'dark');
     extract(wp_parse_args($old, $default));
     $taxonomy_html = '<select name="taxonomy[' . $key . ']" class="widefat field_taxonomy">';
     $tax = get_object_taxonomies('st_rental', 'OBJECTS');
     if (!empty($tax)) {
         foreach ($tax as $key2 => $value2) {
             $taxonomy_html .= "<option " . selected($key2, $taxonomy, false) . " value='{$key2}'>{$value2->label}</option>";
         }
     }
     $taxonomy_html .= '</select>';
     $fields = '<select name="field[' . $key . ']" class="widefat field_name">
                 <option ' . selected('price', $field, false) . ' value="price">' . __('Price', ST_TEXTDOMAIN) . '</option>
                 <option ' . selected('rate', $field, false) . ' value="rate">' . __('Rate', ST_TEXTDOMAIN) . '</option>
                 <option ' . selected('taxonomy', $field, false) . ' value="taxonomy">' . __('Taxonomy', ST_TEXTDOMAIN) . '</option>
             </select>';
     return '<li class="ui-state-default">
         <p><label>' . __('Title', ST_TEXTDOMAIN) . ':</label><input class="widefat field_title" name="title[' . $key . ']" type="text" value="' . $title . '"></p>
         <input type="hidden" class="field_order" name="order[' . $key . ']" value="' . $key . '">
         <p><label>' . __('Field', ST_TEXTDOMAIN) . ':</label>' . $fields . '</p>
         <p class=""><label>' . __('Taxonomy', ST_TEXTDOMAIN) . ':</label>' . $taxonomy_html . '</p>
         <p class="field_tax_wrap"><a href="#" class="button st_delete_field" onclick="return false">' . __('Delete', ST_TEXTDOMAIN) . '</a></p>
         </li>';
 }
开发者ID:HatchForce,项目名称:bachtraveller,代码行数:25,代码来源:st-search-rental.php


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