|
|
@@ -44,16 +44,19 @@ class PostType {
|
|
44
|
44
|
|
|
45
|
45
|
/** Register custom post type call-back */
|
|
46
|
46
|
public function register_post_type() {
|
|
47
|
|
- $args = array(
|
|
|
47
|
+ $args = [
|
|
48
|
48
|
'label' => esc_html( $this->post_type, 'test-plugin' ),
|
|
49
|
49
|
'public' => true,
|
|
50
|
50
|
'menu_position' => 47,
|
|
51
|
51
|
'menu_icon' => $this->icon,
|
|
52
|
|
- 'supports' => array( 'title', 'editor', 'revisions', 'thumbnail' ),
|
|
|
52
|
+ 'supports' => ['title', 'editor', 'revisions', 'thumbnail'],
|
|
53
|
53
|
'has_archive' => false,
|
|
54
|
54
|
'show_in_rest' => true,
|
|
55
|
|
- 'publicly_queryable' => false,
|
|
56
|
|
- );
|
|
|
55
|
+ 'publicly_queryable' => false
|
|
|
56
|
+ ];
|
|
|
57
|
+
|
|
|
58
|
+ if( $this->post_type == 'artist' ) { $args['taxonomies'] = ['category']; }
|
|
|
59
|
+
|
|
57
|
60
|
register_post_type( $this->post_type, $args );
|
|
58
|
61
|
}
|
|
59
|
62
|
}
|
|
|
@@ -65,13 +68,16 @@ class PostType {
|
|
65
|
68
|
$custom_types = get_all_custom_types();
|
|
66
|
69
|
foreach ($custom_types as $type):
|
|
67
|
70
|
$icon = get_icon($type);
|
|
68
|
|
- add_action( 'init', [ new PostType($type, $icon), 'register_post_type' ] );
|
|
|
71
|
+ $custom_type_instance = new PostType($type, $icon);
|
|
69
|
72
|
|
|
70
|
|
- // Register custom meta-boxes
|
|
71
|
|
- // register_custom_meta_box( 'hero_box' 'Custom Hero Section', 'hero', $type );
|
|
|
73
|
+ add_action( 'init', [ $custom_type_instance, 'register_post_type' ], 10 );
|
|
72
|
74
|
endforeach;
|
|
73
|
75
|
|
|
74
|
|
-add_action( 'cmb2_admin_init', 'cmb2_sample_metaboxes' );
|
|
|
76
|
+/**
|
|
|
77
|
+ * Custom Fields
|
|
|
78
|
+ * Defining our HERO, and Name override fields
|
|
|
79
|
+ */
|
|
|
80
|
+add_action( 'cmb2_admin_init', 'cmb2_hero_metaboxes' );
|
|
75
|
81
|
|
|
76
|
82
|
function sanitize_hero_urls( $value, $field_args, $field ) {
|
|
77
|
83
|
$encoded = wp_json_encode( array( 'url' => $value ), true );
|
|
|
@@ -101,7 +107,7 @@ function cmb_hero_render_row_cb( $field_args, $field ) {
|
|
101
|
107
|
/**
|
|
102
|
108
|
* Define the metabox and field configurations.
|
|
103
|
109
|
*/
|
|
104
|
|
-function cmb2_sample_metaboxes() {
|
|
|
110
|
+function cmb2_hero_metaboxes() {
|
|
105
|
111
|
|
|
106
|
112
|
/**
|
|
107
|
113
|
* Initiate the metabox
|
|
|
@@ -146,4 +152,4 @@ function cmb2_artist_sort_metaboxes() {
|
|
146
|
152
|
'id' => 'artist-sort-name',
|
|
147
|
153
|
'type' => 'text'
|
|
148
|
154
|
) );
|
|
149
|
|
-}
|
|
|
155
|
+}
|