Website Summary Files Commits Branches @commit @diff @stats
path: root / wp-content / plugins / dx-vehicles / taxonomies-hierarchical-class.php
blob: 82c1089bc89539b82da0bf0c00d9d40f6cebbe09 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php

class TaxonomiesHierarchical {
    function init() {
        add_action( 'init', array( $this, 'tax_create' ) , 999 );
    }
    public function labels() {
        $arr = array (
            'name' => _x( 'Categories', 'taxonomy general name' ),
            'singular_name' => _x( 'Category', 'taxonomy singular name' ),
            'search_items' =>  __( 'Search Category', 'textdomain' ),
            'all_items' => __( 'All Categories', 'textdomain' ),
            'parent_item' => __( 'Parent Category', 'textdomain' ),
            'parent_item_colon' => __( 'Parent Category:', 'textdomain' ),
            'edit_item' => __( 'Edit Category' ),
            'update_item' => __( 'Update Category' ),
            'add_new_item' => __( 'Add New Category' ),
            'new_item_name' => __( 'New Category Name' ),
            'menu_name' => __( 'Category' ),
        );
        return $arr;
    }

    public function labels_types() {
        $arr = array (
            'name' => _x( 'Types', 'taxonomy general name' ),
            'singular_name' => _x( 'Type', 'taxonomy singular name' ),
            'search_items' =>  __( 'Search Type', 'textdomain' ),
            'all_items' => __( 'All Types', 'textdomain' ),
            'parent_item' => __( 'Parent Type', 'textdomain' ),
            'parent_item_colon' => __( 'Parent Type:', 'textdomain' ),
            'edit_item' => __( 'Edit Type' ),
            'update_item' => __( 'Update Type' ),
            'add_new_item' => __( 'Add New Type' ),
            'new_item_name' => __( 'New Type Name' ),
            'menu_name' => __( 'Type' ),
        );
        return $arr;
    }

    public function tax_create(){
        register_taxonomy( 'vehicle-category', 'vehicles', array(
            'hierarchical' => true,
            'labels' => $this->labels(),
            'show_ui' => true,
            'show_admin_column' => true,
            'show_in_rest' => true,
            'update_count_callback' => '_update_post_term_count',
            'query_var' => true,
            'rewrite' => array( 'slug' => 'vehicle-category' ),
            )
        );
        register_taxonomy( 'vehicle-type', 'vehicles', array(
            'hierarchical' => true,
            'labels' => $this->labels_types(),
            'show_ui' => true,
            'show_admin_column' => true,
            'show_in_rest' => true,
            'update_count_callback' => '_update_post_term_count',
            'query_var' => true,
            'rewrite' => array( 'slug' => 'car-type' ),
            )
        );
    }
}