| 1 |
<?php |
| 2 |
/** |
| 3 |
* Snippets Taxonomy |
| 4 |
* |
| 5 |
* @package Woody_Code_Snippets |
| 6 |
*/ |
| 7 |
|
| 8 |
// Exit if accessed directly |
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
/** |
| 14 |
* Class WINP_SnippetsTaxonomy |
| 15 |
* |
| 16 |
* Handles registration of the snippets taxonomy. |
| 17 |
*/ |
| 18 |
class WINP_SnippetsTaxonomy { |
| 19 |
|
| 20 |
/** |
| 21 |
* Taxonomy name. |
| 22 |
* |
| 23 |
* @var string |
| 24 |
*/ |
| 25 |
private $name = WINP_SNIPPETS_TAXONOMY; |
| 26 |
|
| 27 |
/** |
| 28 |
* Post type(s) this taxonomy applies to. |
| 29 |
* |
| 30 |
* @var string |
| 31 |
*/ |
| 32 |
private $post_types = WINP_SNIPPETS_POST_TYPE; |
| 33 |
|
| 34 |
/** |
| 35 |
* Constructor. |
| 36 |
*/ |
| 37 |
public function __construct() { |
| 38 |
add_action( 'init', [ $this, 'register' ] ); |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Register the taxonomy. |
| 43 |
* |
| 44 |
* @return void |
| 45 |
*/ |
| 46 |
public function register() { |
| 47 |
$labels = [ |
| 48 |
'name' => __( 'Tags', 'insert-php' ), |
| 49 |
'singular_name' => __( 'Tag', 'insert-php' ), |
| 50 |
'search_items' => __( 'Search Tags', 'insert-php' ), |
| 51 |
'popular_items' => __( 'Popular Tags', 'insert-php' ), |
| 52 |
'all_items' => __( 'All Tags', 'insert-php' ), |
| 53 |
'parent_item' => __( 'Parent Tag', 'insert-php' ), |
| 54 |
'parent_item_colon' => __( 'Parent Tag:', 'insert-php' ), |
| 55 |
'edit_item' => __( 'Edit Tag', 'insert-php' ), |
| 56 |
'update_item' => __( 'Update Tag', 'insert-php' ), |
| 57 |
'add_new_item' => __( 'Add New Tag', 'insert-php' ), |
| 58 |
'new_item_name' => __( 'New Tag Name', 'insert-php' ), |
| 59 |
'separate_items_with_commas' => __( 'Separate Tags with commas', 'insert-php' ), |
| 60 |
'add_or_remove_items' => __( 'Add or remove Tags', 'insert-php' ), |
| 61 |
'choose_from_most_used' => __( 'Choose from the most used Tags', 'insert-php' ), |
| 62 |
'not_found' => __( 'No Tags found.', 'insert-php' ), |
| 63 |
'menu_name' => __( 'Tags', 'insert-php' ), |
| 64 |
]; |
| 65 |
|
| 66 |
$args = [ |
| 67 |
'labels' => $labels, |
| 68 |
'public' => false, |
| 69 |
'show_ui' => true, |
| 70 |
'show_in_menu' => true, |
| 71 |
'show_in_nav_menus' => true, |
| 72 |
'show_tagcloud' => false, |
| 73 |
'show_in_quick_edit' => true, |
| 74 |
'show_admin_column' => true, |
| 75 |
'show_in_rest' => false, |
| 76 |
'hierarchical' => false, |
| 77 |
'publicly_queryable' => false, |
| 78 |
'exclude_from_search' => true, |
| 79 |
'query_var' => true, |
| 80 |
'rewrite' => false, |
| 81 |
'capabilities' => [ |
| 82 |
'manage_terms' => 'manage_options', |
| 83 |
'edit_terms' => 'manage_options', |
| 84 |
'delete_terms' => 'manage_options', |
| 85 |
'assign_terms' => 'manage_options', |
| 86 |
], |
| 87 |
]; |
| 88 |
|
| 89 |
register_taxonomy( $this->name, $this->post_types, $args ); |
| 90 |
} |
| 91 |
} |
| 92 |
|