本文整理汇总了PHP中wc_get_attribute_taxonomies函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_get_attribute_taxonomies函数的具体用法?PHP wc_get_attribute_taxonomies怎么用?PHP wc_get_attribute_taxonomies使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_get_attribute_taxonomies函数的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: __construct
/**
* Constructor.
*/
public function __construct()
{
// Category/term ordering
add_action('create_term', array($this, 'create_term'), 5, 3);
add_action('delete_term', array($this, 'delete_term'), 5);
// Add form
add_action('product_cat_add_form_fields', array($this, 'add_category_fields'));
add_action('product_cat_edit_form_fields', array($this, 'edit_category_fields'), 10);
add_action('created_term', array($this, 'save_category_fields'), 10, 3);
add_action('edit_term', array($this, 'save_category_fields'), 10, 3);
// Add columns
add_filter('manage_edit-product_cat_columns', array($this, 'product_cat_columns'));
add_filter('manage_product_cat_custom_column', array($this, 'product_cat_column'), 10, 3);
// Taxonomy page descriptions
add_action('product_cat_pre_add_form', array($this, 'product_cat_description'));
add_action('product_shipping_class_pre_add_form', array($this, 'shipping_class_description'));
$attribute_taxonomies = wc_get_attribute_taxonomies();
if ($attribute_taxonomies) {
foreach (array_keys($attribute_taxonomies) as $attribute) {
add_action($attribute . '_pre_add_form', array($this, 'product_attribute_description'));
}
}
// Maintain hierarchy of terms
add_filter('wp_terms_checklist_args', array($this, 'disable_checked_ontop'));
}
示例3: 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;
}
示例4: 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' => ''));
}
}
}
}
}
示例5: 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'));
}
}
}
示例6: color_layered_nav_init
public function color_layered_nav_init()
{
if (!is_active_widget(false, false, 'woocommerce_layered_nav', true) && !is_admin()) {
global $_chosen_attributes;
$_chosen_attributes = array();
$attribute_taxonomies = wc_get_attribute_taxonomies();
if ($attribute_taxonomies) {
foreach ($attribute_taxonomies as $tax) {
if ($tax->attribute_name == "color") {
$attribute = wc_sanitize_taxonomy_name($tax->attribute_name);
$taxonomy = wc_attribute_taxonomy_name($attribute);
$name = 'filter_' . $attribute;
$query_type_name = 'query_type_' . $attribute;
$taxonomy_exists = in_array($taxonomy, wc_get_attribute_taxonomy_names());
if (!empty($_GET[$name]) && $taxonomy_exists) {
$_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]);
}
}
}
}
}
$wc_query = new WC_Query();
add_filter('loop_shop_post_in', array($wc_query, 'layered_nav_query'));
}
}
示例7: 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');
}
}
示例8: 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;
}
示例9: pf_init_attribute_image
public function pf_init_attribute_image()
{
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_pf_thumbs_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_get_attribute_taxonomies();
if ($attribute_taxonomies) {
foreach ($attribute_taxonomies as $tax) {
add_action('pa_' . $tax->attribute_name . '_add_form_fields', array(&$this, 'pf_add_attribute_image'), 10, 2);
add_action('pa_' . $tax->attribute_name . '_edit_form_fields', array(&$this, 'pf_edit_attribute_image'), 10, 2);
add_filter('manage_edit-pa_' . $tax->attribute_name . '_columns', array(&$this, 'pf_attribute_columns'));
add_filter('manage_pa_' . $tax->attribute_name . '_custom_column', array(&$this, 'pf_attribute_column'), 10, 3);
}
}
}
}
示例10: init_form_fields
public function init_form_fields()
{
global $woocommerce;
$attribute_taxonomies = wc_get_attribute_taxonomies();
$args = array('data_hook' => sanitize_text_field($_POST[$this->plugin_id . '_data_hook']) ?: get_option($this->plugin_id . '_data_hook'), 'dom_selector' => sanitize_text_field($_POST[$this->plugin_id . '_dom_selector']) ?: get_option($this->plugin_id . '_dom_selector'), 'data_selector' => sanitize_text_field($_POST[$this->plugin_id . '_data_selector']) ?: get_option($this->plugin_id . '_data_selector'));
$this->form_fields = array('data_hook' => array('title' => __('<b>Place holder for variation data</b>', 'mp_wc_vdopp'), 'description' => __('Choose a CSS class or id where you want to hook variation data. For instance: .variations or .product_meta. Default value: .variations', 'mp_wc_vdopp'), 'type' => 'text', 'default' => $args['data_hook']), 'dom_selector' => array('title' => __('<b>DOM Selector</b>', 'mp_wc_vdopp'), 'description' => __('Define the selector that will trigger show data event. Default value: form.cart select', 'mp_wc_vdopp'), 'type' => 'text', 'default' => $args['dom_selector']), 'data_selector' => array('title' => __('<b>Data Selector</b>', 'mp_wc_vdopp'), 'description' => __('Choose the id/class of displayed data. Default value: .product_details', 'mp_wc_vdopp'), 'type' => 'text', 'default' => $args['data_selector']));
}
示例11: wc_get_attribute_taxonomies
public static function wc_get_attribute_taxonomies()
{
global $woocommerce;
if (self::is_wc_version_gte_2_1()) {
return wc_get_attribute_taxonomies();
} else {
return $woocommerce->get_attribute_taxonomies();
}
}
示例12: 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;
}
示例13: 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);
}
示例14: adminAssets
function adminAssets()
{
if (!$this->ourPage()) {
return;
}
wp_enqueue_style('wc-attribute-sets', $this->url . '/assets/css/wc-attribute-sets.css');
// Registers and adds the required assets to admin pages
wp_enqueue_script('wc-attribute-sets-angularjs', $this->url . '/assets/js/angular.min.js', null, null, false);
wp_enqueue_script('wc-attribute-sets-angularjs-route', $this->url . '/assets/js/angular-route.min.js', array('wc-attribute-sets-angularjs'), null, false);
wp_enqueue_script('wc-attribute-sets-app', $this->url . '/assets/js/wc-attribute-sets-app.js', array('wc-attribute-sets-angularjs-route'), 1.0, false);
wp_localize_script('wc-attribute-sets-app', 'wcAttributeSets', array('productsAttributes' => wc_get_attribute_taxonomies(), 'viewsUrl' => $this->url . '/views/app/', 'ajaxUrl' => admin_url('admin-ajax.php')));
}
示例15: manageAttrLablesTranslation
/**
* Make all attributes lables managed by polylang string translation
*
* @global \Polylang $polylang
* @global \WooCommerce $woocommerce
*
* @return boolean false if polylang or woocommerce can not be found
*/
public function manageAttrLablesTranslation()
{
global $polylang, $woocommerce;
if (!$polylang || !$woocommerce) {
return false;
}
$attrs = wc_get_attribute_taxonomies();
$section = __('Woocommerce Attributes', 'woo-poly-integration');
foreach ($attrs as $attr) {
pll_register_string($attr->attribute_label, $attr->attribute_label, $section);
}
}