|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
if ( ! class_exists('Spurs_CPT_Creator') ) { |
|
4
|
|
|
class Spurs_CPT_Creator{ |
|
5
|
|
|
|
|
6
|
|
|
public function register_cpt( $post_type, $names, $icon ) { |
|
7
|
|
|
|
|
8
|
|
|
$args = [ |
|
9
|
|
|
'labels' => [ |
|
10
|
|
|
'name' => $names['uc_plural'], |
|
11
|
|
|
'all_items' => $names['uc_plural'], |
|
12
|
|
|
'add_new' => 'Add New ' . $names['uc_singular'], |
|
13
|
|
|
'add_new_item' => 'Add New ' . $names['uc_singular'], |
|
14
|
|
|
'menu_name' => $names['uc_plural'], |
|
15
|
|
|
'singular_name' => $names['uc_singular'], |
|
16
|
|
|
'edit_item' => 'Edit ' . $names['uc_singular'], |
|
17
|
|
|
'new_item' => 'New ' . $names['uc_singular'], |
|
18
|
|
|
'view_item' => 'View ' . $names['uc_singular'], |
|
19
|
|
|
'items_archive' => $names['uc_plural'], |
|
20
|
|
|
'search_items' => 'Search ' . $names['uc_plural'], |
|
21
|
|
|
'not_found' => 'None found', |
|
22
|
|
|
'not_found_in_trash' => 'None found in trash', |
|
23
|
|
|
], |
|
24
|
|
|
'public' => true, |
|
25
|
|
|
'query_var' => true, |
|
26
|
|
|
'rewrite' => array( 'slug' => $names['single'], 'with_front' => false ), |
|
27
|
|
|
'menu_icon' => 'dashicons-'.$icon, |
|
28
|
|
|
'has_archive' => true, |
|
29
|
|
|
'can_export' => true, |
|
30
|
|
|
'supports' => [ 'title', 'editor', 'thumbnail', 'excerpt' ], |
|
31
|
|
|
]; |
|
32
|
|
|
|
|
33
|
|
|
register_post_type( $post_type, $args ); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function register_taxonomy( $taxonomy, $post_type, $names, $hierarchical ) { |
|
37
|
|
|
$labels = array( |
|
38
|
|
|
'name' => _x( $names['uc_plural'], 'Categories', 'spurs' ), |
|
39
|
|
|
'singular_name' => _x( $names['uc_singular'], 'Category', 'spurs' ), |
|
40
|
|
|
'search_items' => __( 'Search ' . $names['uc_plural'], 'spurs' ), |
|
41
|
|
|
'popular_items' => __( 'Popular ' . $names['uc_plural'], 'spurs' ), |
|
42
|
|
|
'all_items' => __( 'All ' . $names['uc_plural'], 'spurs' ), |
|
43
|
|
|
'parent_item' => null, |
|
44
|
|
|
'parent_item_colon' => null, |
|
45
|
|
|
'edit_item' => __( 'Edit ' . $names['uc_singular'], 'spurs' ), |
|
46
|
|
|
'update_item' => __( 'Update ' . $names['uc_singular'], 'spurs' ), |
|
47
|
|
|
'add_new_item' => __( 'Add New ' . $names['uc_singular'], 'spurs' ), |
|
48
|
|
|
'new_item_name' => __( 'New ' . $names['uc_singular'] . ' Name', 'spurs' ), |
|
49
|
|
|
'separate_items_with_commas' => __( 'Separate ' . $names['plural'] . ' with commas', 'spurs' ), |
|
50
|
|
|
'add_or_remove_items' => __( 'Add or remove ' . $names['plural'], 'spurs' ), |
|
51
|
|
|
'choose_from_most_used' => __( 'Choose from the most used ' . $names['plural'], 'spurs' ), |
|
52
|
|
|
'not_found' => __( 'No ' . $names['plural'] . ' found.', 'spurs' ), |
|
53
|
|
|
'menu_name' => __( $names['uc_plural'], 'spurs' ), |
|
54
|
|
|
); |
|
55
|
|
|
|
|
56
|
|
|
$args = array( |
|
57
|
|
|
'hierarchical' => $hierarchical, |
|
58
|
|
|
'labels' => $labels, |
|
59
|
|
|
'show_ui' => true, |
|
60
|
|
|
'show_admin_column' => true, |
|
61
|
|
|
'query_var' => true, |
|
62
|
|
|
'rewrite' => array( 'slug' => $taxonomy ), |
|
63
|
|
|
); |
|
64
|
|
|
|
|
65
|
|
|
register_taxonomy( $taxonomy, $post_type, $args ); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|