WC_Post_Types::register_taxonomies() – Register core taxonomies.

You appear to be a bot. Output may be restricted

Description

Register core taxonomies.

Usage

WC_Post_Types::register_taxonomies();

Parameters

Returns

void

Source

File name: woocommerce/includes/class-wc-post-types.php


Lines:

1 to 100 of 246
  public static function register_taxonomies() {

    if ( ! is_blog_installed() ) {
      return;
    }

    if ( taxonomy_exists( 'product_type' ) ) {
      return;
    }

    do_action( 'woocommerce_register_taxonomy' );

    $permalinks = wc_get_permalink_structure();

    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,
          'label'             => _x( 'Product type', 'Taxonomy name', 'woocommerce' ),
        )
      )
    );

    register_taxonomy(
      'product_visibility',
      apply_filters( 'woocommerce_taxonomy_objects_product_visibility', array( 'product', 'product_variation' ) ),
      apply_filters(
        'woocommerce_taxonomy_args_product_visibility',
        array(
          'hierarchical'      => false,
          'show_ui'           => false,
          'show_in_nav_menus' => false,
          'query_var'         => is_admin(),
          'rewrite'           => false,
          'public'            => false,
          'label'             => _x( 'Product visibility', 'Taxonomy name', 'woocommerce' ),
        )
      )
    );

    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' ),
            'item_link'             => __( 'Product Category Link', 'woocommerce' ),
            'item_link_description' => __( 'A link to a product category.', 'woocommerce' ),
          ),
          'show_in_rest'          => true,
          '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'         => $permalinks['category_rewrite_slug'],
            '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' ),

 View on GitHub View on Trac