taxonomy = $taxonomy; $this->plural = $plural; $this->single = $single; if ( ! is_array( $post_types ) ) { $post_types = array( $post_types ); } $this->post_types = $post_types; $this->taxonomy_args = $tax_args; // Register taxonomy. add_action( 'init', array( $this, 'register_taxonomy' ) ); } /** * Register new taxonomy * * @return void */ public function register_taxonomy() { //phpcs:disable $labels = array( 'name' => $this->plural, 'singular_name' => $this->single, 'menu_name' => $this->plural, 'all_items' => sprintf( __( 'All %s', 'bricksable' ), $this->plural ), 'edit_item' => sprintf( __( 'Edit %s', 'bricksable' ), $this->single ), 'view_item' => sprintf( __( 'View %s', 'bricksable' ), $this->single ), 'update_item' => sprintf( __( 'Update %s', 'bricksable' ), $this->single ), 'add_new_item' => sprintf( __( 'Add New %s', 'bricksable' ), $this->single ), 'new_item_name' => sprintf( __( 'New %s Name', 'bricksable' ), $this->single ), 'parent_item' => sprintf( __( 'Parent %s', 'bricksable' ), $this->single ), 'parent_item_colon' => sprintf( __( 'Parent %s:', 'bricksable' ), $this->single ), 'search_items' => sprintf( __( 'Search %s', 'bricksable' ), $this->plural ), 'popular_items' => sprintf( __( 'Popular %s', 'bricksable' ), $this->plural ), 'separate_items_with_commas' => sprintf( __( 'Separate %s with commas', 'bricksable' ), $this->plural ), 'add_or_remove_items' => sprintf( __( 'Add or remove %s', 'bricksable' ), $this->plural ), 'choose_from_most_used' => sprintf( __( 'Choose from the most used %s', 'bricksable' ), $this->plural ), 'not_found' => sprintf( __( 'No %s found', 'bricksable' ), $this->plural ), ); //phpcs:enable $args = array( 'label' => $this->plural, 'labels' => apply_filters( $this->taxonomy . '_labels', $labels ), 'hierarchical' => true, 'public' => true, 'show_ui' => true, 'show_in_nav_menus' => true, 'show_tagcloud' => true, 'meta_box_cb' => null, 'show_admin_column' => true, 'show_in_quick_edit' => true, 'update_count_callback' => '', 'show_in_rest' => true, 'rest_base' => $this->taxonomy, 'rest_controller_class' => 'WP_REST_Terms_Controller', 'query_var' => $this->taxonomy, 'rewrite' => true, 'sort' => '', ); $args = array_merge( $args, $this->taxonomy_args ); register_taxonomy( $this->taxonomy, $this->post_types, apply_filters( $this->taxonomy . '_register_args', $args, $this->taxonomy, $this->post_types ) ); } }