/** * Register taxonomy * */ public function register_taxonomy() { if (!empty($this->taxonomies)) { foreach ($this->taxonomies as $taxonomy) { // Predefined taxonomy if (!is_array($taxonomy)) { switch ($taxonomy) { // Categories (predefined): WordPress provides translation case 'cat': register_taxonomy($this->the_post_type . '_category', array($this->the_post_type), array('hierarchical' => true, 'rewrite' => array('slug' => $this->slug . '-' . Riesma::slugify(__('Categories')), 'with_front' => true))); break; // Tags (predefined): WordPress provides translation // Tags (predefined): WordPress provides translation case 'tag': register_taxonomy($this->the_post_type . '_tag', array($this->the_post_type), array('hierarchical' => false, 'rewrite' => array('slug' => $this->slug . '-' . Riesma::slugify(__('Tags')), 'with_front' => true))); break; // WordPress default post categories // WordPress default post categories case 'WP_cat': register_taxonomy_for_object_type('category', $this->the_post_type); break; // WordPress default post tags // WordPress default post tags case 'WP_tag': register_taxonomy_for_object_type('post_tag', $this->the_post_type); break; } } else { if (is_array($taxonomy)) { $the_taxonomy = $this->the_post_type . '_' . $taxonomy['taxonomy']; $tax_name = $this->the_post_type . '_' . $taxonomy['name']; $tax_plural = $taxonomy['plural']; $tax_singular = $taxonomy['singular']; $tax_hierarchical = !empty($taxonomy['hierarchical']) ? $taxonomy['hierarchical'] : true; $tax_slug = $this->slug . '-' . Riesma::slugify($tax_name); register_taxonomy($the_taxonomy, array($this->the_post_type), array('labels' => array('name' => __($tax_plural), 'singular_name' => __($tax_singular)), 'hierarchical' => $tax_hierarchical, 'public' => true, 'show_ui' => true, 'show_in_nav_menus' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array('slug' => $tax_slug, 'with_front' => true))); } } } // end foreach taxonomy } }