public static function register_taxonomies()
{
if (!is_blog_installed()) {
return;
}
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' => __('Categories', 'woocommerce'), 'labels' => array('name' => __('Product categories', 'woocommerce'), 'singular_name' => __('Category', 'woocommerce'), 'menu_name' => _x('Categories', 'Admin menu name', 'woocommerce'), 'search_items' => __('Search categories', 'woocommerce'), 'all_items' => __('All categories', 'woocommerce'), 'parent_item' => __('Parent category', 'woocommerce'), 'parent_item_colon' => __('Parent category:', 'woocommerce'), 'edit_item' => __('Edit category', 'woocommerce'), 'update_item' => __('Update category', 'woocommerce'), 'add_new_item' => __('Add new category', 'woocommerce'), 'new_item_name' => __('New category name', 'woocommerce'), 'not_found' => __('No categories 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['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' => __('Tag', 'woocommerce'), 'menu_name' => _x('Tags', 'Admin menu name', 'woocommerce'), 'search_items' => __('Search tags', 'woocommerce'), 'all_items' => __('All tags', 'woocommerce'), 'edit_item' => __('Edit tag', 'woocommerce'), 'update_item' => __('Update tag', 'woocommerce'), 'add_new_item' => __('Add new tag', 'woocommerce'), 'new_item_name' => __('New tag name', 'woocommerce'), 'popular_items' => __('Popular tags', 'woocommerce'), 'separate_items_with_commas' => __('Separate tags with commas', 'woocommerce'), 'add_or_remove_items' => __('Add or remove tags', 'woocommerce'), 'choose_from_most_used' => __('Choose from the most used tags', 'woocommerce'), 'not_found' => __('No 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' => false, 'update_count_callback' => '_update_post_term_count', 'label' => __('Shipping classes', 'woocommerce'), 'labels' => array('name' => __('Product 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_quick_edit' => 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' => sprintf(_x('Product %s', 'Product Attribute', 'woocommerce'), $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), 'not_found' => sprintf(__('No "%s" found', 'woocommerce'), $label)), 'show_ui' => true, 'show_in_quick_edit' => false, 'show_in_menu' => false, 'show_in_nav_menus' => false, 'meta_box_cb' => 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');
}