本文整理汇总了PHP中taxonomy_exists函数的典型用法代码示例。如果您正苦于以下问题:PHP taxonomy_exists函数的具体用法?PHP taxonomy_exists怎么用?PHP taxonomy_exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了taxonomy_exists函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_url
/**
* get_url - Returns a url based on a string that holds either post type and id or taxonomy and id
*/
static function get_url($link, $post_id = false)
{
$link = explode(',', $link);
if ($link[0] == 'lightbox') {
$link = wp_get_attachment_image_src($post_id, apply_filters('avf_avia_builder_helper_lightbox_size', 'large'));
return $link[0];
}
if (empty($link[1])) {
return $link[0];
}
if ($link[0] == 'manually') {
return $link[1];
}
if (post_type_exists($link[0])) {
return get_permalink($link[1]);
}
if (taxonomy_exists($link[0])) {
$return = get_term_link(get_term($link[1], $link[0]));
if (is_object($return)) {
$return = "";
}
//if an object is returned it is a WP_Error object and something was not found
return $return;
}
}
开发者ID:erynet,项目名称:SUAWEBv2,代码行数:28,代码来源:generic-helper.class.php
示例2: ajax_local_tags
/**
* Display a javascript collection for autocompletion script !
*
* @return void
* @author Amaury Balmer
*/
public static function ajax_local_tags()
{
status_header(200);
// Send good header HTTP
header("Content-Type: application/json; charset=" . get_bloginfo('charset'));
$taxonomy = 'post_tag';
if (isset($_REQUEST['taxonomy']) && taxonomy_exists($_REQUEST['taxonomy'])) {
$taxonomy = $_REQUEST['taxonomy'];
}
if ((int) wp_count_terms($taxonomy, 'ignore_empty=false') == 0) {
// No tags to suggest
json_encode(array());
exit;
}
// Prepare search
$search = isset($_GET['term']) ? trim(stripslashes($_GET['term'])) : '';
// Get all terms, or filter with search
$terms = SimpleTags_Admin::getTermsForAjax($taxonomy, $search);
if (empty($terms) || $terms == false) {
json_encode(array());
exit;
}
// Format terms
$results = array();
foreach ((array) $terms as $term) {
$term->name = stripslashes($term->name);
$term->name = str_replace(array("\r\n", "\r", "\n"), '', $term->name);
$results[] = array('id' => $term->term_id, 'label' => $term->name, 'value' => $term->name);
}
echo json_encode($results);
exit;
}
开发者ID:rongandat,项目名称:best-picture,代码行数:38,代码来源:class.admin.autocomplete.php
示例3: attribute_taxonomies
public static function attribute_taxonomies()
{
global $woocommerce;
if (!isset($woocommerce)) {
return array();
}
$attributes = array();
if (function_exists('wc_get_attribute_taxonomies')) {
$attribute_taxonomies = wc_get_attribute_taxonomies();
} else {
$attribute_taxonomies = $woocommerce->get_attribute_taxonomies();
}
if (empty($attribute_taxonomies)) {
return array();
}
foreach ($attribute_taxonomies as $attribute) {
/* FIX TO WOOCOMMERCE 2.1 */
if (function_exists('wc_attribute_taxonomy_name')) {
$taxonomy = wc_attribute_taxonomy_name($attribute->attribute_name);
} else {
$taxonomy = $woocommerce->attribute_taxonomy_name($attribute->attribute_name);
}
if (taxonomy_exists($taxonomy)) {
$attributes[] = $attribute->attribute_name;
}
}
return $attributes;
}
开发者ID:GaryJones,项目名称:goombiel,代码行数:28,代码来源:class.yith-wcan-helper.php
示例4: register_custom_taxonomy
/**
* Register custom post status taxonomy - used by workflows.
*
* @since 2.0
*/
public function register_custom_taxonomy()
{
if (!taxonomy_exists($this->taxonomy_key)) {
$args = array('hierarchical' => false, 'update_count_callback' => '_update_post_term_count', 'label' => false, 'query_var' => false, 'rewrite' => false, 'show_ui' => false);
register_taxonomy($this->taxonomy_key, 'post', $args);
}
}
开发者ID:andyUA,项目名称:kabmin-new,代码行数:12,代码来源:class-ow-custom-statuses.php
示例5: zfwca_list_categories
/**
* Display a list categories
* @param array $args
* @return bool
*/
function zfwca_list_categories($args = array())
{
$defaults = array('show_option_all' => '', 'orderby' => 'name', 'order' => 'ASC', 'show_count' => 0, 'hide_empty' => 1, 'use_desc_for_title' => 1, 'child_of' => 0, 'exclude' => '', 'include' => '', 'exclude_tree' => '', 'current_category' => 0, 'taxonomy' => 'category');
$r = wp_parse_args($args, $defaults);
$r['walker'] = new ZFWCA_Post_Category_Walker();
if (!isset($r['class'])) {
$r['class'] = 'category' == $r['taxonomy'] ? 'categories' : $r['taxonomy'];
}
extract($r);
if (!taxonomy_exists($taxonomy)) {
return false;
}
$categories = get_categories($r);
$output = '';
if (empty($categories)) {
$output .= 'No categories';
} else {
if (empty($r['current_category']) && (is_category() || is_tax() || is_tag())) {
$current_term_object = get_queried_object();
if ($current_term_object && $r['taxonomy'] === $current_term_object->taxonomy) {
$r['current_category'] = get_queried_object_id();
}
}
$output .= walk_category_tree($categories, 0, $r);
}
$output = apply_filters('zfwca_wp_list_categories', $output, $args);
return $output;
}
开发者ID:Juni4567,项目名称:meritscholarship,代码行数:33,代码来源:functions.php
示例6: register_taxonomies
/**
* Register core taxonomies.
*/
public static function register_taxonomies()
{
if (taxonomy_exists('product_type')) {
return;
}
do_action('woocommerce_register_taxonomy');
$permalinks = get_option('woocommerce_permalinks');
register_taxonomy('product_type', apply_filters('woocommerce_taxonomy_objects_product_type', array('product')), apply_filters('woocommerce_taxonomy_args_product_type', array('hierarchical' => false, 'show_ui' => false, 'show_in_nav_menus' => false, 'query_var' => is_admin(), 'rewrite' => false, 'public' => false)));
register_taxonomy('product_cat', apply_filters('woocommerce_taxonomy_objects_product_cat', array('product')), apply_filters('woocommerce_taxonomy_args_product_cat', array('hierarchical' => true, 'update_count_callback' => '_wc_term_recount', 'label' => __('Product Categories', 'woocommerce'), 'labels' => array('name' => __('Product Categories', 'woocommerce'), 'singular_name' => __('Product Category', 'woocommerce'), 'menu_name' => _x('Categories', 'Admin menu name', 'woocommerce'), 'search_items' => __('Search Product Categories', 'woocommerce'), 'all_items' => __('All Product Categories', 'woocommerce'), 'parent_item' => __('Parent Product Category', 'woocommerce'), 'parent_item_colon' => __('Parent Product Category:', 'woocommerce'), 'edit_item' => __('Edit Product Category', 'woocommerce'), 'update_item' => __('Update Product Category', 'woocommerce'), 'add_new_item' => __('Add New Product Category', 'woocommerce'), 'new_item_name' => __('New Product Category Name', 'woocommerce')), 'show_ui' => true, 'query_var' => true, 'capabilities' => array('manage_terms' => 'manage_product_terms', 'edit_terms' => 'edit_product_terms', 'delete_terms' => 'delete_product_terms', 'assign_terms' => 'assign_product_terms'), 'rewrite' => array('slug' => empty($permalinks['category_base']) ? _x('product-category', 'slug', 'woocommerce') : $permalinks['category_base'], 'with_front' => false, 'hierarchical' => true))));
register_taxonomy('product_tag', apply_filters('woocommerce_taxonomy_objects_product_tag', array('product')), apply_filters('woocommerce_taxonomy_args_product_tag', array('hierarchical' => false, 'update_count_callback' => '_wc_term_recount', 'label' => __('Product Tags', 'woocommerce'), 'labels' => array('name' => __('Product Tags', 'woocommerce'), 'singular_name' => __('Product Tag', 'woocommerce'), 'menu_name' => _x('Tags', 'Admin menu name', 'woocommerce'), 'search_items' => __('Search Product Tags', 'woocommerce'), 'all_items' => __('All Product Tags', 'woocommerce'), 'edit_item' => __('Edit Product Tag', 'woocommerce'), 'update_item' => __('Update Product Tag', 'woocommerce'), 'add_new_item' => __('Add New Product Tag', 'woocommerce'), 'new_item_name' => __('New Product Tag Name', 'woocommerce'), 'popular_items' => __('Popular Product Tags', 'woocommerce'), 'separate_items_with_commas' => __('Separate Product Tags with commas', 'woocommerce'), 'add_or_remove_items' => __('Add or remove Product Tags', 'woocommerce'), 'choose_from_most_used' => __('Choose from the most used Product tags', 'woocommerce'), 'not_found' => __('No Product Tags found', 'woocommerce')), 'show_ui' => true, 'query_var' => true, 'capabilities' => array('manage_terms' => 'manage_product_terms', 'edit_terms' => 'edit_product_terms', 'delete_terms' => 'delete_product_terms', 'assign_terms' => 'assign_product_terms'), 'rewrite' => array('slug' => empty($permalinks['tag_base']) ? _x('product-tag', 'slug', 'woocommerce') : $permalinks['tag_base'], 'with_front' => false))));
register_taxonomy('product_shipping_class', apply_filters('woocommerce_taxonomy_objects_product_shipping_class', array('product', 'product_variation')), apply_filters('woocommerce_taxonomy_args_product_shipping_class', array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'label' => __('Shipping Classes', 'woocommerce'), 'labels' => array('name' => __('Shipping Classes', 'woocommerce'), 'singular_name' => __('Shipping Class', 'woocommerce'), 'menu_name' => _x('Shipping Classes', 'Admin menu name', 'woocommerce'), 'search_items' => __('Search Shipping Classes', 'woocommerce'), 'all_items' => __('All Shipping Classes', 'woocommerce'), 'parent_item' => __('Parent Shipping Class', 'woocommerce'), 'parent_item_colon' => __('Parent Shipping Class:', 'woocommerce'), 'edit_item' => __('Edit Shipping Class', 'woocommerce'), 'update_item' => __('Update Shipping Class', 'woocommerce'), 'add_new_item' => __('Add New Shipping Class', 'woocommerce'), 'new_item_name' => __('New Shipping Class Name', 'woocommerce')), 'show_ui' => false, 'show_in_nav_menus' => false, 'query_var' => is_admin(), 'capabilities' => array('manage_terms' => 'manage_product_terms', 'edit_terms' => 'edit_product_terms', 'delete_terms' => 'delete_product_terms', 'assign_terms' => 'assign_product_terms'), 'rewrite' => false)));
global $wc_product_attributes;
$wc_product_attributes = array();
if ($attribute_taxonomies = wc_get_attribute_taxonomies()) {
foreach ($attribute_taxonomies as $tax) {
if ($name = wc_attribute_taxonomy_name($tax->attribute_name)) {
$tax->attribute_public = absint(isset($tax->attribute_public) ? $tax->attribute_public : 1);
$label = !empty($tax->attribute_label) ? $tax->attribute_label : $tax->attribute_name;
$wc_product_attributes[$name] = $tax;
$taxonomy_data = array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'labels' => array('name' => $label, 'singular_name' => $label, 'search_items' => sprintf(__('Search %s', 'woocommerce'), $label), 'all_items' => sprintf(__('All %s', 'woocommerce'), $label), 'parent_item' => sprintf(__('Parent %s', 'woocommerce'), $label), 'parent_item_colon' => sprintf(__('Parent %s:', 'woocommerce'), $label), 'edit_item' => sprintf(__('Edit %s', 'woocommerce'), $label), 'update_item' => sprintf(__('Update %s', 'woocommerce'), $label), 'add_new_item' => sprintf(__('Add New %s', 'woocommerce'), $label), 'new_item_name' => sprintf(__('New %s', 'woocommerce'), $label)), 'show_ui' => false, 'query_var' => 1 === $tax->attribute_public, 'rewrite' => false, 'sort' => false, 'public' => 1 === $tax->attribute_public, 'show_in_nav_menus' => 1 === $tax->attribute_public && apply_filters('woocommerce_attribute_show_in_nav_menus', false, $name), 'capabilities' => array('manage_terms' => 'manage_product_terms', 'edit_terms' => 'edit_product_terms', 'delete_terms' => 'delete_product_terms', 'assign_terms' => 'assign_product_terms'));
if (1 === $tax->attribute_public) {
$taxonomy_data['rewrite'] = array('slug' => empty($permalinks['attribute_base']) ? '' : trailingslashit($permalinks['attribute_base']) . sanitize_title($tax->attribute_name), 'with_front' => false, 'hierarchical' => true);
}
register_taxonomy($name, apply_filters("woocommerce_taxonomy_objects_{$name}", array('product')), apply_filters("woocommerce_taxonomy_args_{$name}", $taxonomy_data));
}
}
do_action('woocommerce_after_register_taxonomy');
}
}
开发者ID:flasomm,项目名称:Montkailash,代码行数:32,代码来源:class-wc-post-types.php
示例7: init_attribute_image_selector
public function init_attribute_image_selector()
{
global $woocommerce, $_wp_additional_image_sizes;
$screen = get_current_screen();
if (strpos($screen->id, 'pa_') !== false) {
$this->taxonomy = $_REQUEST['taxonomy'];
if (taxonomy_exists($_REQUEST['taxonomy'])) {
$term_id = term_exists(isset($_REQUEST['tag_ID']) ? $_REQUEST['tag_ID'] : 0, $_REQUEST['taxonomy']);
$term = 0;
if ($term_id) {
$term = get_term($term_id, $_REQUEST['taxonomy']);
}
$this->image_size = apply_filters('woocommerce_get_swatches_image_size', $this->image_size, $_REQUEST['taxonomy'], $term_id);
}
$the_size = isset($_wp_additional_image_sizes[$this->image_size]) ? $_wp_additional_image_sizes[$this->image_size] : $_wp_additional_image_sizes['shop_thumbnail'];
if (isset($the_size['width']) && isset($the_size['height'])) {
$this->image_width = $the_size['width'];
$this->image_height = $the_size['height'];
} else {
$this->image_width = 32;
$this->image_height = 32;
}
$attribute_taxonomies = WC_Swatches_Compatibility::wc_get_attribute_taxonomies();
if ($attribute_taxonomies) {
foreach ($attribute_taxonomies as $tax) {
add_action('pa_' . $tax->attribute_name . '_add_form_fields', array(&$this, 'woocommerce_add_attribute_thumbnail_field'));
add_action('pa_' . $tax->attribute_name . '_edit_form_fields', array(&$this, 'woocommerce_edit_attributre_thumbnail_field'), 10, 2);
add_filter('manage_edit-pa_' . $tax->attribute_name . '_columns', array(&$this, 'woocommerce_product_attribute_columns'));
add_filter('manage_pa_' . $tax->attribute_name . '_custom_column', array(&$this, 'woocommerce_product_attribute_column'), 10, 3);
}
}
}
}
开发者ID:k2jysy,项目名称:kshop,代码行数:33,代码来源:class-wc-swatches-product-attribute-images.php
示例8: __construct
public function __construct($name = null, $post_types = array(), $args = array(), $capabilities = array(), $labels = array())
{
$this->taxonomy_name = Custom_Post_Type::uglify($name);
$this->taxonomy_post_types = $post_types;
$this->taxonomy_args = $args;
$this->taxonomy_capabilities = $capabilities;
$this->taxonomy_labels = $labels;
if (!taxonomy_exists($this->taxonomy_name)) {
$name = Custom_Post_Type::beautify($name);
$plural = Custom_Post_Type::pluralize($name);
$labels = array_merge(array('name' => _x($plural, 'taxonomy general name'), 'singular_name' => _x($name, 'taxonomy singular name'), 'search_items' => __('Search ' . $plural), 'all_items' => __('All ' . $plural), 'parent_item' => __('Parent ' . $name), 'parent_item_colon' => __('Parent ' . $name . ':'), 'edit_item' => __('Edit ' . $name), 'update_item' => __('Update ' . $name), 'add_new_item' => __('Add New ' . $name), 'new_item_name' => __('New ' . $name . ' Name'), 'menu_name' => __($name)), $this->taxonomy_labels);
$capabilities = $this->merge_caps($this->taxonomy_args, $this->taxonomy_capabilities);
// Default arguments, overwritten with the given arguments
$args = array_merge(array('label' => $plural, 'labels' => $labels, 'public' => true, 'show_ui' => true, 'show_in_nav_menus' => true, 'hierarchical' => true, '_builtin' => false, 'capabilities' => $capabilities), $this->taxonomy_args);
// Add the taxonomy to the post types
add_action('init', function () use($args) {
register_taxonomy($this->taxonomy_name, $this->taxonomy_post_types, $args);
});
} else {
/* The taxonomy already exists. We are going to attach the existing taxonomy to the object type (post type) */
add_action('init', function () {
foreach ($this->taxonomy_post_types as $type) {
register_taxonomy_for_object_type($this->taxonomy_name, $type);
}
});
}
}
开发者ID:sunielsambasivan,项目名称:nommytrips,代码行数:27,代码来源:class-custom-taxonomy.php
示例9: woocommerce_import_start
/**
* Functions for handling WordPress import to make it compatable with WooCommerce
*
* WordPress import should work - however, it fails to import custom product attribute taxonomies.
* This code grabs the file before it is imported and ensures the taxonomies are created.
*
* @author WooThemes
* @category Admin
* @package WooCommerce
*/
function woocommerce_import_start()
{
global $wpdb;
$id = (int) $_POST['import_id'];
$file = get_attached_file($id);
$parser = new WXR_Parser();
$import_data = $parser->parse($file);
if (isset($import_data['posts'])) {
$posts = $import_data['posts'];
if ($posts && sizeof($posts) > 0) {
foreach ($posts as $post) {
if ($post['post_type'] == 'product') {
if ($post['terms'] && sizeof($post['terms']) > 0) {
foreach ($post['terms'] as $term) {
$domain = $term['domain'];
if (strstr($domain, 'pa_')) {
// Make sure it exists!
if (!taxonomy_exists($domain)) {
$nicename = strtolower(sanitize_title(str_replace('pa_', '', $domain)));
$exists_in_db = $wpdb->get_var("SELECT attribute_id FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_name = '" . $nicename . "';");
if (!$exists_in_db) {
// Create the taxonomy
$wpdb->insert($wpdb->prefix . "woocommerce_attribute_taxonomies", array('attribute_name' => $nicename, 'attribute_type' => 'select'), array('%s', '%s'));
}
// Register the taxonomy now so that the import works!
register_taxonomy($domain, array('product'), array('hierarchical' => true, 'labels' => array('name' => $nicename, 'singular_name' => $nicename, 'search_items' => __('Search', 'woothemes') . ' ' . $nicename, 'all_items' => __('All', 'woothemes') . ' ' . $nicename, 'parent_item' => __('Parent', 'woothemes') . ' ' . $nicename, 'parent_item_colon' => __('Parent', 'woothemes') . ' ' . $nicename . ':', 'edit_item' => __('Edit', 'woothemes') . ' ' . $nicename, 'update_item' => __('Update', 'woothemes') . ' ' . $nicename, 'add_new_item' => __('Add New', 'woothemes') . ' ' . $nicename, 'new_item_name' => __('New', 'woothemes') . ' ' . $nicename), 'show_ui' => false, 'query_var' => true, 'rewrite' => array('slug' => strtolower(sanitize_title($nicename)), 'with_front' => false, 'hierarchical' => true)));
}
}
}
}
}
}
}
}
}
开发者ID:randyhoyt,项目名称:woocommerce,代码行数:45,代码来源:woocommerce-admin-import.php
示例10: ajaxLocalTags
/**
* Display a javascript collection for autocompletion script !
*
* @return void
* @author Amaury Balmer
*/
function ajaxLocalTags()
{
status_header(200);
// Send good header HTTP
header("Content-Type: text/plain; charset=" . get_bloginfo('charset'));
$taxonomy = 'post_tag';
if (isset($_REQUEST['taxonomy']) && taxonomy_exists($_REQUEST['taxonomy'])) {
$taxonomy = $_REQUEST['taxonomy'];
}
if ((int) wp_count_terms($taxonomy, 'ignore_empty=false') == 0) {
// No tags to suggest
exit;
}
// Prepare search
$search = isset($_GET['q']) ? trim(stripslashes($_GET['q'])) : '';
// Get all terms, or filter with search
$terms = $this->getTermsForAjax($taxonomy, $search);
if (empty($terms) || $terms == false) {
exit;
}
// Format terms
foreach ((array) $terms as $term) {
$term->name = stripslashes($term->name);
$term->name = str_replace(array("\r\n", "\r", "\n"), '', $term->name);
echo "{$term->term_id}|{$term->name}\n";
}
exit;
}
开发者ID:rubyerme,项目名称:rubyerme.github.com,代码行数:34,代码来源:class.admin.autocomplete.php
示例11: woocommerce_ultimatum_layered_nav_init
function woocommerce_ultimatum_layered_nav_init()
{
global $_chosen_attributes, $woocommerce, $_attributes_array;
$_chosen_attributes = $_attributes_array = array();
$attribute_taxonomies = $woocommerce->get_attribute_taxonomies();
if ($attribute_taxonomies) {
foreach ($attribute_taxonomies as $tax) {
$attribute = sanitize_title($tax->attribute_name);
$taxonomy = $woocommerce->attribute_taxonomy_name($attribute);
// create an array of product attribute taxonomies
$_attributes_array[] = $taxonomy;
$name = 'filter_' . $attribute;
$query_type_name = 'query_type_' . $attribute;
if (!empty($_GET[$name]) && taxonomy_exists($taxonomy)) {
$_chosen_attributes[$taxonomy]['terms'] = explode(',', $_GET[$name]);
if (!empty($_GET[$query_type_name]) && $_GET[$query_type_name] == 'or') {
$_chosen_attributes[$taxonomy]['query_type'] = 'or';
} else {
$_chosen_attributes[$taxonomy]['query_type'] = 'and';
}
}
}
}
add_filter('loop_shop_post_in', 'woocommerce_layered_nav_query');
}
开发者ID:shieldsdesignstudio,项目名称:forefield,代码行数:25,代码来源:devfuncs.php
示例12: avia_temp_products
function avia_temp_products()
{
if (post_type_exists('product')) {
return false;
}
$product_base = $base_slug = $category_base = "";
register_taxonomy('product_cat', array('product'), array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'label' => __('Categories', 'woothemes'), 'labels' => array('name' => __('Categories', 'woothemes'), 'singular_name' => __('Product Category', 'woothemes'), 'search_items' => __('Search Product Categories', 'woothemes'), 'all_items' => __('All Product Categories', 'woothemes'), 'parent_item' => __('Parent Product Category', 'woothemes'), 'parent_item_colon' => __('Parent Product Category:', 'woothemes'), 'edit_item' => __('Edit Product Category', 'woothemes'), 'update_item' => __('Update Product Category', 'woothemes'), 'add_new_item' => __('Add New Product Category', 'woothemes'), 'new_item_name' => __('New Product Category Name', 'woothemes')), 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => $category_base . _x('product-category', 'slug', 'woothemes'), 'with_front' => false)));
register_taxonomy('product_tag', array('product'), array('hierarchical' => false, 'label' => __('Tags', 'woothemes'), 'labels' => array('name' => __('Tags', 'woothemes'), 'singular_name' => __('Product Tag', 'woothemes'), 'search_items' => __('Search Product Tags', 'woothemes'), 'all_items' => __('All Product Tags', 'woothemes'), 'parent_item' => __('Parent Product Tag', 'woothemes'), 'parent_item_colon' => __('Parent Product Tag:', 'woothemes'), 'edit_item' => __('Edit Product Tag', 'woothemes'), 'update_item' => __('Update Product Tag', 'woothemes'), 'add_new_item' => __('Add New Product Tag', 'woothemes'), 'new_item_name' => __('New Product Tag Name', 'woothemes')), 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => $category_base . _x('product-tag', 'slug', 'woothemes'), 'with_front' => false)));
register_post_type("product", array('labels' => array('name' => __('Products', 'woothemes'), 'singular_name' => __('Product', 'woothemes'), 'add_new' => __('Add Product', 'woothemes'), 'add_new_item' => __('Add New Product', 'woothemes'), 'edit' => __('Edit', 'woothemes'), 'edit_item' => __('Edit Product', 'woothemes'), 'new_item' => __('New Product', 'woothemes'), 'view' => __('View Product', 'woothemes'), 'view_item' => __('View Product', 'woothemes'), 'search_items' => __('Search Products', 'woothemes'), 'not_found' => __('No Products found', 'woothemes'), 'not_found_in_trash' => __('No Products found in trash', 'woothemes'), 'parent' => __('Parent Product', 'woothemes')), 'description' => __('This is where you can add new products to your store.', 'woothemes'), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'publicly_queryable' => true, 'exclude_from_search' => false, 'hierarchical' => true, 'rewrite' => array('slug' => $product_base, 'with_front' => false), 'query_var' => true, 'supports' => array('title', 'editor', 'excerpt', 'thumbnail', 'comments'), 'has_archive' => $base_slug, 'show_in_nav_menus' => false));
register_post_type("product_variation", array('labels' => array('name' => __('Variations', 'woothemes'), 'singular_name' => __('Variation', 'woothemes'), 'add_new' => __('Add Variation', 'woothemes'), 'add_new_item' => __('Add New Variation', 'woothemes'), 'edit' => __('Edit', 'woothemes'), 'edit_item' => __('Edit Variation', 'woothemes'), 'new_item' => __('New Variation', 'woothemes'), 'view' => __('View Variation', 'woothemes'), 'view_item' => __('View Variation', 'woothemes'), 'search_items' => __('Search Variations', 'woothemes'), 'not_found' => __('No Variations found', 'woothemes'), 'not_found_in_trash' => __('No Variations found in trash', 'woothemes'), 'parent' => __('Parent Variation', 'woothemes')), 'public' => true, 'show_ui' => false, 'capability_type' => 'post', 'publicly_queryable' => true, 'exclude_from_search' => true, 'hierarchical' => true, 'rewrite' => false, 'query_var' => true, 'supports' => array('title', 'editor', 'custom-fields', 'page-attributes', 'thumbnail'), 'show_in_nav_menus' => false));
register_taxonomy('product_type', array('product'), array('hierarchical' => false, 'show_ui' => false, 'query_var' => true, 'show_in_nav_menus' => false));
register_post_type("shop_order", array('labels' => array('name' => __('Orders', 'woothemes'), 'singular_name' => __('Order', 'woothemes'), 'add_new' => __('Add Order', 'woothemes'), 'add_new_item' => __('Add New Order', 'woothemes'), 'edit' => __('Edit', 'woothemes'), 'edit_item' => __('Edit Order', 'woothemes'), 'new_item' => __('New Order', 'woothemes'), 'view' => __('View Order', 'woothemes'), 'view_item' => __('View Order', 'woothemes'), 'search_items' => __('Search Orders', 'woothemes'), 'not_found' => __('No Orders found', 'woothemes'), 'not_found_in_trash' => __('No Orders found in trash', 'woothemes'), 'parent' => __('Parent Orders', 'woothemes')), 'description' => __('This is where store orders are stored.', 'woothemes'), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'publicly_queryable' => false, 'exclude_from_search' => true, 'show_in_menu' => 'woocommerce', 'hierarchical' => false, 'show_in_nav_menus' => false, 'rewrite' => false, 'query_var' => true, 'supports' => array('title', 'comments', 'custom-fields'), 'has_archive' => false));
register_taxonomy('shop_order_status', array('shop_order'), array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'labels' => array('name' => __('Order statuses', 'woothemes'), 'singular_name' => __('Order status', 'woothemes'), 'search_items' => __('Search Order statuses', 'woothemes'), 'all_items' => __('All Order statuses', 'woothemes'), 'parent_item' => __('Parent Order status', 'woothemes'), 'parent_item_colon' => __('Parent Order status:', 'woothemes'), 'edit_item' => __('Edit Order status', 'woothemes'), 'update_item' => __('Update Order status', 'woothemes'), 'add_new_item' => __('Add New Order status', 'woothemes'), 'new_item_name' => __('New Order status Name', 'woothemes')), 'show_ui' => false, 'show_in_nav_menus' => false, 'query_var' => true, 'rewrite' => false));
register_post_type("shop_coupon", array('labels' => array('name' => __('Coupons', 'woothemes'), 'singular_name' => __('Coupon', 'woothemes'), 'add_new' => __('Add Coupon', 'woothemes'), 'add_new_item' => __('Add New Coupon', 'woothemes'), 'edit' => __('Edit', 'woothemes'), 'edit_item' => __('Edit Coupon', 'woothemes'), 'new_item' => __('New Coupon', 'woothemes'), 'view' => __('View Coupons', 'woothemes'), 'view_item' => __('View Coupon', 'woothemes'), 'search_items' => __('Search Coupons', 'woothemes'), 'not_found' => __('No Coupons found', 'woothemes'), 'not_found_in_trash' => __('No Coupons found in trash', 'woothemes'), 'parent' => __('Parent Coupon', 'woothemes')), 'description' => __('This is where you can add new coupons that customers can use in your store.', 'woothemes'), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'publicly_queryable' => true, 'exclude_from_search' => true, 'show_in_menu' => 'woocommerce', 'hierarchical' => false, 'rewrite' => false, 'query_var' => false, 'supports' => array('title'), 'show_in_nav_menus' => false));
if (!taxonomy_exists('product_type')) {
register_taxonomy('product_type', array('post'));
register_taxonomy('shop_order_status', array('post'));
}
$product_types = array('simple', 'grouped', 'variable', 'downloadable', 'virtual');
foreach ($product_types as $type) {
if (!get_term_by('slug', sanitize_title($type), 'product_type')) {
wp_insert_term($type, 'product_type');
}
}
$order_status = array('pending', 'failed', 'on-hold', 'processing', 'completed', 'refunded', 'cancelled');
foreach ($order_status as $status) {
if (!get_term_by('slug', sanitize_title($status), 'shop_order_status')) {
wp_insert_term($status, 'shop_order_status');
}
}
}
开发者ID:eddiewilson,项目名称:new-ke,代码行数:31,代码来源:admin-import.php
示例13: register_tree_taxonomy
public function register_tree_taxonomy()
{
/*
* The Tree Shapes
*/
if (!taxonomy_exists('tree_shapes')) {
$labels = array('name' => _tt('Shapes'), 'singular_name' => _tt('Shape'), 'menu_name' => _tt('Shapes'), 'all_items' => _tt('All Shapes'), 'parent_item' => _tt('Parent Shape'), 'parent_item_colon' => _tt('Parent Shape:'), 'new_item_name' => _tt('New Tree Shape'), 'add_new_item' => _tt('Add New Tree Shape'), 'edit_item' => _tt('Edit Shape'), 'update_item' => _tt('Update Shape'), 'separate_items_with_commas' => _tt('Separate Shapes with commas'), 'search_items' => _tt('Search Shapes'), 'add_or_remove_items' => _tt('Add or remove Shape'), 'choose_from_most_used' => _tt('Choose from the most used Shapes'), 'not_found' => _tt('Shape Not Found'));
$args = array('labels' => $labels, 'hierarchical' => true, 'public' => true, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'show_tagcloud' => false);
register_taxonomy('tree_shapes', 'tree_species', $args);
}
/*
* The Flower Colors
*/
if (!taxonomy_exists('tree_flower_colors')) {
$labels = array('name' => _tt('Flower Colors'), 'singular_name' => _tt('Flower Color'), 'menu_name' => _tt('Colors'), 'all_items' => _tt('All Flower Colors'), 'parent_item' => _tt('Parent Color'), 'parent_item_colon' => _tt('Parent Color:'), 'new_item_name' => _tt('New Flower Color'), 'add_new_item' => _tt('Add New Flower Color'), 'edit_item' => _tt('Edit Flower Color'), 'update_item' => _tt('Update Flower Color'), 'separate_items_with_commas' => _tt('Separate Flower Color with commas'), 'search_items' => _tt('Search Flower Color'), 'add_or_remove_items' => _tt('Add or remove Flower Color'), 'choose_from_most_used' => _tt('Choose from the most used colors'), 'not_found' => _tt('Color Not Found'));
$args = array('labels' => $labels, 'hierarchical' => true, 'public' => true, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'show_tagcloud' => false);
register_taxonomy('tree_flower_colors', 'tree_species', $args);
}
/*
* The Flower Colors
*/
if (!taxonomy_exists('tree_category')) {
$labels = array('name' => _tt('Tree Categories'), 'singular_name' => _tt('Tree Category'), 'menu_name' => _tt('Categories'), 'all_items' => _tt('All Tree Category'), 'parent_item' => _tt('Parent Tree Category'), 'parent_item_colon' => _tt('Parent Tree Category:'), 'new_item_name' => _tt('New Tree Category'), 'add_new_item' => _tt('Add New Tree Category'), 'edit_item' => _tt('Edit Tree Category'), 'update_item' => _tt('Update Tree Category'), 'separate_items_with_commas' => _tt('Separate Tree Category with commas'), 'search_items' => _tt('Search Tree Category'), 'add_or_remove_items' => _tt('Add or remove Tree Category'), 'choose_from_most_used' => _tt('Choose from the most used Tree Category'), 'not_found' => _tt('Category Not Found'));
$args = array('labels' => $labels, 'hierarchical' => true, 'public' => true, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'show_tagcloud' => false);
register_taxonomy('tree_category', 'tree_species', $args);
}
}
开发者ID:shaulfiron,项目名称:tree-species,代码行数:27,代码来源:tree-species-taxonomies.php
示例14: iconize_get_term_icon_by
/**
* Function for retriving taxonomy icons configured using taxonomy edit screens
*
*
* @since 1.1.0
*
* @param string $field Either 'slug', 'name' or 'id' (term_id)
* @param string|int $value Search for this term value
* @param string $taxonomy Taxonomy Name
* @param boolean $format return html markup or array? Either 'html' or 'array'
* @param string $after_icon
*
* @return string $icon_html, array of settings or empty string on failure
*/
function iconize_get_term_icon_by($field = 'id', $value, $taxonomy, $format = 'html', $after_icon = ' ')
{
$fields = array('name', 'slug', 'id');
$after = !is_string($after_icon) ? ' ' : $after_icon;
$format = !is_string($format) ? 'html' : $format;
if (!taxonomy_exists($taxonomy) || !in_array($field, $fields)) {
return '';
}
// get term object
$term = get_term_by($field, $value, $taxonomy);
if (!$term || is_wp_error($term)) {
return '';
}
$term_id = $term->term_id;
$icon_args = array();
$icon_html = '';
$opt_array = get_option('iconize_taxonomy_icons');
if ($opt_array && array_key_exists($taxonomy, $opt_array) && array_key_exists($term_id, $opt_array[$taxonomy])) {
$icon_args['icon_name'] = isset($opt_array[$taxonomy][$term_id]['icon_name']) ? $opt_array[$taxonomy][$term_id]['icon_name'] : '';
$icon_args['icon_set'] = isset($opt_array[$taxonomy][$term_id]['icon_set']) ? $opt_array[$taxonomy][$term_id]['icon_set'] : '';
$icon_args['icon_transform'] = isset($opt_array[$taxonomy][$term_id]['icon_transform']) ? $opt_array[$taxonomy][$term_id]['icon_transform'] : '';
$icon_args['icon_size'] = isset($opt_array[$taxonomy][$term_id]['icon_size']) ? $opt_array[$taxonomy][$term_id]['icon_size'] : '';
$icon_args['icon_align'] = isset($opt_array[$taxonomy][$term_id]['icon_align']) ? $opt_array[$taxonomy][$term_id]['icon_align'] : '';
$icon_args['icon_custom_classes'] = isset($opt_array[$taxonomy][$term_id]['icon_custom_classes']) ? $opt_array[$taxonomy][$term_id]['icon_custom_classes'] : '';
$icon_args['icon_color'] = isset($opt_array[$taxonomy][$term_id]['icon_color']) ? $opt_array[$taxonomy][$term_id]['icon_color'] : '';
// Generate icon html
$icon_html = iconize_get_icon($icon_args, $taxonomy, $after);
}
if ('array' === $format) {
return $icon_args;
} else {
return $icon_html;
}
}
开发者ID:nickkoskowski,项目名称:Work-Depot,代码行数:48,代码来源:icon-functions.php
示例15: init
public static function init()
{
global $ClevernessToDoList, $CTDL_Frontend_Checklist, $CTDL_Frontend_Admin, $CTDL_templates, $CTDL_Dashboard_Widget;
if (is_admin()) {
self::check_for_upgrade();
}
$general_options = get_option('CTDL_general') ? get_option('CTDL_general') : array();
$advanced_options = get_option('CTDL_advanced') ? get_option('CTDL_advanced') : array();
$permissions_options = get_option('CTDL_permissions') ? get_option('CTDL_permissions') : array();
self::$settings = array_merge($general_options, $advanced_options, $permissions_options);
self::$dashboard_settings = get_option('CTDL_dashboard_settings');
self::include_files();
if (!post_type_exists('todo')) {
self::setup_custom_post_type();
}
if (!taxonomy_exists('todocategories')) {
self::create_taxonomies();
}
self::call_wp_hooks();
$ClevernessToDoList = new ClevernessToDoList();
$CTDL_templates = new CTDL_Template_Loader();
if (is_admin()) {
new CTDL_Settings();
$CTDL_Dashboard_Widget = new CTDL_Dashboard_Widget();
}
$CTDL_Frontend_Admin = new CTDL_Frontend_Admin();
$CTDL_Frontend_Checklist = new CTDL_Frontend_Checklist();
new CTDL_Frontend_List();
}
开发者ID:abenamer,项目名称:thereveal,代码行数:29,代码来源:cleverness-to-do-list-loader.class.php
示例16: add_taxonomy
public function add_taxonomy($name, $args = array(), $labels = array())
{
if (!empty($name)) {
// We need to know the post type name, so the new taxonomy can be attached to it.
$post_type_name = $this->post_type_name;
// Taxonomy properties
$taxonomy_name = strtolower(str_replace(' ', '_', $name));
$taxonomy_labels = $labels;
$taxonomy_args = $args;
if (!taxonomy_exists($taxonomy_name)) {
//Capitilize the words and make it plural
$name = ucwords(str_replace('_', ' ', $name));
$plural = $name . 's';
// Default labels, overwrite them with the given labels.
$labels = array_merge(array('name' => _x($plural, 'taxonomy general name'), 'singular_name' => _x($name, 'taxonomy singular name'), 'search_items' => __('Search ' . $plural), 'all_items' => __('All ' . $plural), 'parent_item' => __('Parent ' . $name), 'parent_item_colon' => __('Parent ' . $name . ':'), 'edit_item' => __('Edit ' . $name), 'update_item' => __('Update ' . $name), 'add_new_item' => __('Add New ' . $name), 'new_item_name' => __('New ' . $name . ' Name'), 'menu_name' => __($name)), $taxonomy_labels);
// Default arguments, overwitten with the given arguments
$args = array_merge(array('label' => $plural, 'labels' => $labels, 'public' => true, 'show_ui' => true, 'show_in_nav_menus' => true, '_builtin' => false), $taxonomy_args);
// Add the taxonomy to the post type
add_action('init', function () use($taxonomy_name, $post_type_name, $args) {
register_taxonomy($taxonomy_name, $post_type_name, $args);
});
} else {
add_action('init', function () use($taxonomy_name, $post_type_name) {
register_taxonomy_for_object_type($taxonomy_name, $post_type_name);
});
}
}
}
开发者ID:nova4005,项目名称:CPT-Helper,代码行数:28,代码来源:cpt-class.php
示例17: new_question
/**
* Add activity after inserting new question.
* @param integer $question_id Post ID.
*/
public function new_question($question_id)
{
$question = get_post($question_id);
$question_title = '<a class="ap-q-link" href="' . wp_get_shortlink($question_id) . '">' . get_the_title($question_id) . '</a>';
$txo_type = '';
if (taxonomy_exists('q
|
请发表评论