本文整理汇总了PHP中wc_attribute_taxonomy_name函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_attribute_taxonomy_name函数的具体用法?PHP wc_attribute_taxonomy_name怎么用?PHP wc_attribute_taxonomy_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_attribute_taxonomy_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: get_item_data
function get_item_data($other_data, $cart_item)
{
if (isset($cart_item["wpb_cart_items"])) {
$wpb_cart_items = $cart_item["wpb_cart_items"];
$other_data = array();
$variation_data = $cart_item["variation"];
if (!empty($variation_data)) {
foreach ($variation_data as $attribute => $variation) {
$taxonomy = wc_attribute_taxonomy_name(str_replace('attribute_pa_', '', urldecode($attribute)));
$term = get_term_by('slug', $variation, $taxonomy);
$attribute_type = WPB_Common_Functions::get_variation_attribute_type($taxonomy);
if ($attribute_type == "carousel") {
$other_data[] = array('name' => wc_attribute_label($taxonomy), 'display' => $term->name, 'value' => '', 'hidden' => false);
}
if ($attribute_type == "extra") {
$extra_options = $wpb_cart_items["extra"];
$display_label = !empty($extra_options[$taxonomy]) ? $term->name . '(' . $extra_options[$taxonomy] . ')' : $term->name;
$other_data[] = array('name' => wc_attribute_label($taxonomy), 'display' => $display_label, 'value' => '', 'hidden' => false);
}
if ($attribute_type == "size") {
$size_options = $wpb_cart_items["size"];
$display_label = !empty($size_options[$taxonomy]) ? $size_options[$taxonomy] : "";
$other_data[] = array('name' => wc_attribute_label($taxonomy), 'display' => $display_label, 'value' => '', 'hidden' => false);
}
}
}
}
return $other_data;
}
示例3: attribute_taxonomies
public static function attribute_taxonomies()
{
global $woocommerce;
if (!isset($woocommerce)) {
return array();
}
$attributes = array();
if (function_exists('wc_get_attribute_taxonomies') && function_exists('wc_attribute_taxonomy_name')) {
$attribute_taxonomies = wc_get_attribute_taxonomies();
if (empty($attribute_taxonomies)) {
return array();
}
foreach ($attribute_taxonomies as $attribute) {
$tax = wc_attribute_taxonomy_name($attribute->attribute_name);
if (taxonomy_exists($tax)) {
$attributes[$tax] = ucfirst($attribute->attribute_name);
}
}
} else {
$attribute_taxonomies = $woocommerce->get_attribute_taxonomies();
if (empty($attribute_taxonomies)) {
return array();
}
foreach ($attribute_taxonomies as $attribute) {
$tax = $woocommerce->attribute_taxonomy_name($attribute->attribute_name);
if (taxonomy_exists($tax)) {
$attributes[$tax] = ucfirst($attribute->attribute_name);
}
}
}
return $attributes;
}
示例4: LoadRestrictions
/**
* Load the restrictions from the database
*/
private function LoadRestrictions()
{
if ($this->restrictions_loaded) {
return;
}
// Attribute/Variation Restrictions
$attribute_taxonomies = wc_get_attribute_taxonomies();
$taxonomies = array();
foreach ($attribute_taxonomies as $taxonomy) {
$taxonomies[] = wc_attribute_taxonomy_name($taxonomy->attribute_name);
}
$restrictions = get_terms(array('taxonomy' => $taxonomies, 'meta_query' => array(array('key' => 'multiple_of', 'compare' => 'EXISTS')), 'hide_empty' => false));
if (is_array($restrictions)) {
foreach ($restrictions as $restriction) {
$this->multiple_ofs_attributes[$restriction->term_id] = $this->GetMultipleOfForAttribute($restriction->term_id);
if (!$this->multiple_ofs_attributes[$restriction->term_id]) {
unset($this->multiple_ofs_attributes[$restriction->term_id]);
}
}
}
// Category Restrictions
$restrictions = get_terms(array('taxonomy' => 'product_cat', 'meta_query' => array(array('key' => 'cat_multiple_of', 'compare' => 'EXISTS')), 'hide_empty' => false));
if (is_array($restrictions)) {
foreach ($restrictions as $restriction) {
$this->multiple_ofs_categories[$restriction->term_id] = $this->GetMultipleOfForCategory($restriction->term_id);
if (!$this->multiple_ofs_categories[$restriction->term_id]) {
unset($this->multiple_ofs_categories[$restriction->term_id]);
}
}
}
$this->cart_must_be_multiple_of = intval(get_option('woocommerce_cart_multiple_of', 0));
$this->restrictions_loaded = true;
}
示例5: addAttributeSetToProduct
static function addAttributeSetToProduct()
{
ob_start();
global $wc_product_attributes;
$attributeSetKey = $_POST['key'];
$db = new WCAttributeSetsDb();
$attributeSet = $db->get($attributeSetKey);
if (empty($attributeSet->attributes)) {
die;
}
foreach ($attributeSet->attributes as $attributeKey) {
$thepostid = 0;
$taxonomy = wc_attribute_taxonomy_name($attributeKey);
$i = absint($_POST['i']);
$position = 0;
$metabox_class = array();
$attribute = array('name' => $taxonomy, 'value' => '', 'is_visible' => apply_filters('woocommerce_attribute_default_visibility', 1), 'is_variation' => 0, 'is_taxonomy' => $taxonomy ? 1 : 0);
if ($taxonomy) {
$attribute_taxonomy = $wc_product_attributes[$taxonomy];
$metabox_class[] = 'taxonomy';
$metabox_class[] = $taxonomy;
$attribute_label = wc_attribute_label($taxonomy);
} else {
$attribute_label = '';
}
include WC()->plugin_path() . '/includes/admin/meta-boxes/views/html-product-attribute.php';
}
die;
}
示例6: woocommerce_layered_nav_init
/**
* Layered Nav Init
*
* @package WooCommerce/Widgets
* @access public
* @return void
*/
public function woocommerce_layered_nav_init()
{
if (is_active_widget(false, false, 'yith-woo-ajax-navigation', true) && !is_admin()) {
global $_chosen_attributes, $woocommerce;
$_chosen_attributes = array();
/* FIX TO WOOCOMMERCE 2.1 */
$attibute_taxonomies = function_exists('wc_get_attribute_taxonomies') ? $attribute_taxonomies = wc_get_attribute_taxonomies() : ($attribute_taxonomies = $woocommerce->get_attribute_taxonomies());
if ($attribute_taxonomies) {
foreach ($attribute_taxonomies as $tax) {
$attribute = wc_sanitize_taxonomy_name($tax->attribute_name);
/* FIX TO WOOCOMMERCE 2.1 */
if (function_exists('wc_attribute_taxonomy_name')) {
$taxonomy = wc_attribute_taxonomy_name($attribute);
} else {
$taxonomy = $woocommerce->attribute_taxonomy_name($attribute);
}
$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]) || !in_array(strtolower($_GET[$query_type_name]), array('and', 'or'))) {
$_chosen_attributes[$taxonomy]['query_type'] = apply_filters('woocommerce_layered_nav_default_query_type', 'and');
} else {
$_chosen_attributes[$taxonomy]['query_type'] = strtolower($_GET[$query_type_name]);
}
}
}
}
if (version_compare(preg_replace('/-beta-([0-9]+)/', '', $woocommerce->version), '2.1', '<')) {
add_filter('loop_shop_post_in', 'woocommerce_layered_nav_query');
} else {
add_filter('loop_shop_post_in', array(WC()->query, 'layered_nav_query'));
}
}
}
示例7: automatic_add_features
/**
* Automatic Set all Product Attribute as Compare Features
*
*/
public function automatic_add_features()
{
$current_db_version = get_option('woocommerce_db_version', null);
if (version_compare($current_db_version, '2.1.0', '<') && null !== $current_db_version) {
global $woocommerce;
$top_variations = $woocommerce->get_attribute_taxonomies();
} else {
$top_variations = wc_get_attribute_taxonomies();
}
if ($top_variations) {
foreach ($top_variations as $top_variation) {
$check_existed = WC_Compare_Data::get_count("field_name='" . trim(addslashes($top_variation->attribute_label)) . "'");
if ($check_existed < 1) {
$child_variations = get_terms(version_compare($current_db_version, '2.1.0', '<') && null !== $current_db_version ? $woocommerce->attribute_taxonomy_name($top_variation->attribute_name) : wc_attribute_taxonomy_name($top_variation->attribute_name), array('parent' => 0, 'hide_empty' => 0, 'hierarchical' => 0));
$default_value = '';
if (count($child_variations) > 0) {
$line = '';
foreach ($child_variations as $child_variation) {
$default_value .= $line . addslashes($child_variation->name);
$line = '
';
}
}
if (trim($default_value) != '') {
$feature_id = WC_Compare_Data::insert_row(array('field_name' => trim(addslashes($top_variation->attribute_label)), 'field_type' => 'checkbox', 'field_unit' => '', 'default_value' => $default_value));
} else {
$feature_id = WC_Compare_Data::insert_row(array('field_name' => trim(addslashes($top_variation->attribute_label)), 'field_type' => 'input-text', 'field_unit' => '', 'default_value' => ''));
}
}
}
}
}
示例8: 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');
}
}
示例9: widget
/**
* Output widget.
*
* @see WP_Widget
*
* @param array $args
* @param array $instance
*/
public function widget($args, $instance)
{
if (!is_post_type_archive('product') && !is_tax(get_object_taxonomies('product'))) {
return;
}
$_chosen_attributes = WC_Query::get_layered_nav_chosen_attributes();
$taxonomy = isset($instance['attribute']) ? wc_attribute_taxonomy_name($instance['attribute']) : $this->settings['attribute']['std'];
$query_type = isset($instance['query_type']) ? $instance['query_type'] : $this->settings['query_type']['std'];
$display_type = isset($instance['display_type']) ? $instance['display_type'] : $this->settings['display_type']['std'];
if (!taxonomy_exists($taxonomy)) {
return;
}
$get_terms_args = array('hide_empty' => '1');
$orderby = wc_attribute_orderby($taxonomy);
switch ($orderby) {
case 'name':
$get_terms_args['orderby'] = 'name';
$get_terms_args['menu_order'] = false;
break;
case 'id':
$get_terms_args['orderby'] = 'id';
$get_terms_args['order'] = 'ASC';
$get_terms_args['menu_order'] = false;
break;
case 'menu_order':
$get_terms_args['menu_order'] = 'ASC';
break;
}
$terms = get_terms($taxonomy, $get_terms_args);
if (0 === sizeof($terms)) {
return;
}
switch ($orderby) {
case 'name_num':
usort($terms, '_wc_get_product_terms_name_num_usort_callback');
break;
case 'parent':
usort($terms, '_wc_get_product_terms_parent_usort_callback');
break;
}
ob_start();
$this->widget_start($args, $instance);
if ('dropdown' === $display_type) {
$found = $this->layered_nav_dropdown($terms, $taxonomy, $query_type);
} else {
$found = $this->layered_nav_list($terms, $taxonomy, $query_type);
}
$this->widget_end($args);
// Force found when option is selected - do not force found on taxonomy attributes
if (!is_tax() && is_array($_chosen_attributes) && array_key_exists($taxonomy, $_chosen_attributes)) {
$found = true;
}
if (!$found) {
ob_end_clean();
} else {
echo ob_get_clean();
}
}
示例10: wc_attribute_taxonomy_name
public static function wc_attribute_taxonomy_name($name)
{
if (self::is_wc_version_gte_2_1()) {
return wc_attribute_taxonomy_name($name);
} else {
global $woocommerce;
return $woocommerce->attribute_taxonomy_name($name);
}
}
示例11: wc_get_attribute_taxonomy_names
/**
* Get an array of product attribute taxonomies.
*
* @access public
* @return array
*/
function wc_get_attribute_taxonomy_names()
{
$taxonomy_names = array();
$attribute_taxonomies = wc_get_attribute_taxonomies();
if ($attribute_taxonomies) {
foreach ($attribute_taxonomies as $tax) {
$taxonomy_names[] = wc_attribute_taxonomy_name($tax->attribute_name);
}
}
return $taxonomy_names;
}
示例12: br_aapf_get_attributes
/**
* Get all possible woocommerce attribute taxonomies
*
* @return mixed|void
*/
function br_aapf_get_attributes()
{
$attribute_taxonomies = wc_get_attribute_taxonomies();
$attributes = array();
if ($attribute_taxonomies) {
foreach ($attribute_taxonomies as $tax) {
$attributes[wc_attribute_taxonomy_name($tax->attribute_name)] = $tax->attribute_label;
}
}
return apply_filters('berocket_aapf_get_attributes', $attributes);
}
示例13: get_list_attribute_slug
public function get_list_attribute_slug()
{
$list = $this->get_list_attributes();
$return = array();
foreach ($list as $item) {
$return[$item->attribute_id]['id'] = $item->attribute_id;
$return[$item->attribute_id]['tax_slug'] = wc_attribute_taxonomy_name($item->attribute_name);
$return[$item->attribute_id]['name'] = $item->attribute_name;
$return[$item->attribute_id]['label'] = $item->attribute_label;
}
return $return;
}
示例14: get_woo_attribute_taxonomies
protected function get_woo_attribute_taxonomies()
{
$attribute_array = array();
$attribute_taxonomies = wc_get_attribute_taxonomies();
if ($attribute_taxonomies) {
foreach ($attribute_taxonomies as $tax) {
if (taxonomy_exists(wc_attribute_taxonomy_name($tax->attribute_name))) {
$attribute_array[$tax->attribute_name] = $tax->attribute_name;
}
}
}
return $attribute_array;
}
示例15: constant
function constant()
{
$this->attr_slug = '';
$attribute_name = wc_attribute_taxonomy_name($this->term_slug);
$attribute_name_array = wc_get_attribute_taxonomy_names();
$taxonomy_exists = in_array($attribute_name, $attribute_name_array);
if ($taxonomy_exists) {
$this->attr_slug = $attribute_name;
add_image_size('ts_prod_color_thumb', 30, 30, true);
$this->init_handle();
add_action('admin_enqueue_scripts', array($this, 'register_admin_scripts'));
}
}