|
|
@@ -19,6 +19,8 @@ if ( ! defined( 'WPINC' ) ) { die; }
|
|
19
|
19
|
require_once 'includes/cmb2/init.php';
|
|
20
|
20
|
|
|
21
|
21
|
include('includes/custom-types.php');
|
|
|
22
|
+include('includes/custom-taxonomies.php');
|
|
|
23
|
+include('includes/custom-metaboxes.php');
|
|
22
|
24
|
include('includes/p2p-mappings.php');
|
|
23
|
25
|
|
|
24
|
26
|
/**
|
|
|
@@ -45,7 +47,7 @@ class PostType {
|
|
45
|
47
|
/** Register custom post type call-back */
|
|
46
|
48
|
public function register_post_type() {
|
|
47
|
49
|
$args = [
|
|
48
|
|
- 'label' => esc_html( $this->post_type, 'test-plugin' ),
|
|
|
50
|
+ 'label' => esc_html( ucfirst($this->post_type), 'test-plugin' ),
|
|
49
|
51
|
'public' => true,
|
|
50
|
52
|
'menu_position' => 47,
|
|
51
|
53
|
'menu_icon' => $this->icon,
|
|
|
@@ -74,109 +76,13 @@ endforeach;
|
|
74
|
76
|
/**
|
|
75
|
77
|
* Create taxonomies
|
|
76
|
78
|
*/
|
|
77
|
|
-
|
|
78
|
79
|
add_action('init', 'create_materials_taxonomy');
|
|
79
|
|
-function create_materials_taxonomy() {
|
|
80
|
|
- $post_types_that_show_materials = [ 'artist', 'exhibition', 'event' ];
|
|
81
|
|
- register_taxonomy('material', $post_types_that_show_materials, [ "label" => "Materials"]);
|
|
82
|
|
-}
|
|
83
|
|
-
|
|
84
|
|
-add_action('init', 'create_artist_types_taxonomy');
|
|
85
|
|
-function create_artist_types_taxonomy() {
|
|
86
|
|
- $post_types_that_show_artist_types = [ 'artist' ];
|
|
87
|
|
- register_taxonomy('artist type', $post_types_that_show_artist_types, [ "label" => "Artist Type"]);
|
|
88
|
|
-}
|
|
89
|
|
-
|
|
90
|
|
-add_action('init', 'create_event_types_taxonomy');
|
|
91
|
|
-function create_event_types_taxonomy() {
|
|
92
|
|
- $post_types_that_show_event_types = [ 'event' ];
|
|
93
|
|
- register_taxonomy('event type', $post_types_that_show_event_types, [ "label" => "Event Type"]);
|
|
94
|
|
-}
|
|
95
|
|
-
|
|
96
|
|
-add_action('init', 'create_exhibit_types_taxonomy');
|
|
97
|
|
-function create_exhibit_types_taxonomy() {
|
|
98
|
|
- $post_types_that_show_exhibit_types = [ 'exhibition' ];
|
|
99
|
|
- register_taxonomy('Exhibition type', $post_types_that_show_exhibit_types, [ "label" => "Exhibition Type"]);
|
|
100
|
|
-}
|
|
101
|
|
-/* Plugin Logic -- END * /
|
|
|
80
|
+add_action('init', 'create_types_taxonomy');
|
|
102
|
81
|
|
|
103
|
82
|
/**
|
|
104
|
|
- * Custom Fields
|
|
105
|
|
- * Defining our HERO, and Name override fields
|
|
|
83
|
+ * Create CMB Metaboxes
|
|
106
|
84
|
*/
|
|
107
|
85
|
add_action( 'cmb2_admin_init', 'cmb2_hero_metaboxes' );
|
|
108
|
|
-
|
|
109
|
|
-function sanitize_hero_urls( $value, $field_args, $field ) {
|
|
110
|
|
- $encoded = wp_json_encode( array( 'url' => $value ), true );
|
|
111
|
|
- return $encoded;
|
|
112
|
|
-}
|
|
113
|
|
-
|
|
114
|
|
-function cmb_hero_render_row_cb( $field_args, $field ) {
|
|
115
|
|
- $id = $field->args( 'id' );
|
|
116
|
|
- $label = $field->args( 'name' );
|
|
117
|
|
- $name = $field->args( '_name' );
|
|
118
|
|
- $value = $field->escaped_value();
|
|
119
|
|
- $description = $field->args( 'description' );
|
|
120
|
|
- // !: Impossible to fine " conversion
|
|
121
|
|
- $decoded = json_decode( str_replace('"', '"', $value), true );
|
|
122
|
|
- ?>
|
|
123
|
|
- <div class="custom-field-row">
|
|
124
|
|
- <p>
|
|
125
|
|
- <label for="<?php echo $id; ?>"><?php echo $label; ?></label>
|
|
126
|
|
- <input style="width: 100%;" id="<?php echo $id; ?>" type="text" name="<?php echo $name; ?>"
|
|
127
|
|
- value="<?php echo $decoded['url']; ?>"/>
|
|
128
|
|
- </p>
|
|
129
|
|
- <p class="description"><?php echo $description; ?></p>
|
|
130
|
|
- </div>
|
|
131
|
|
- <?php
|
|
132
|
|
-}
|
|
133
|
|
-
|
|
134
|
|
-/**
|
|
135
|
|
- * Define the metabox and field configurations.
|
|
136
|
|
- */
|
|
137
|
|
-function cmb2_hero_metaboxes() {
|
|
138
|
|
-
|
|
139
|
|
- /**
|
|
140
|
|
- * Initiate the metabox
|
|
141
|
|
- */
|
|
142
|
|
- $cmb = new_cmb2_box( array(
|
|
143
|
|
- 'id' => 'hero_metabox',
|
|
144
|
|
- 'title' => __( 'Hero', 'cmb2' ),
|
|
145
|
|
- 'object_types' => array( 'artist', ), // Post type
|
|
146
|
|
- 'context' => 'normal',
|
|
147
|
|
- 'priority' => 'high',
|
|
148
|
|
- 'show_names' => true, // Show field names on the left
|
|
149
|
|
- 'show_in_rest' => WP_REST_Server::READABLE
|
|
150
|
|
- // 'cmb_styles' => false, // false to disable the CMB stylesheet
|
|
151
|
|
- // 'closed' => true, // Keep the metabox closed by default
|
|
152
|
|
- ) );
|
|
153
|
|
-
|
|
154
|
|
- // URL text field
|
|
155
|
|
- $cmb->add_field( array(
|
|
156
|
|
- 'name' => __( 'YouTube URL', 'cmb2' ),
|
|
157
|
|
- 'desc' => __( 'Video for the hero section to display', 'cmb2' ),
|
|
158
|
|
- 'id' => 'hero_header',
|
|
159
|
|
- 'type' => 'text',
|
|
160
|
|
- 'sanitization_cb' => 'sanitize_hero_urls',
|
|
161
|
|
- 'render_row_cb' => 'cmb_hero_render_row_cb'
|
|
162
|
|
- ) );
|
|
163
|
|
-}
|
|
164
|
|
-
|
|
165
|
86
|
add_action( 'cmb2_admin_init', 'cmb2_artist_sort_metaboxes' );
|
|
166
|
|
-function cmb2_artist_sort_metaboxes() {
|
|
167
|
|
- $cmb = new_cmb2_box( array(
|
|
168
|
|
- 'id' => 'artist_sort_metabox',
|
|
169
|
|
- 'title' => __( 'Name Override', 'cmb2' ),
|
|
170
|
|
- 'object_types' => array( 'artist' ),
|
|
171
|
|
- 'context' => 'normal',
|
|
172
|
|
- 'priority' => 'high',
|
|
173
|
|
- 'show_names' => true,
|
|
174
|
|
- 'show_in_rest' => WP_REST_Server::READABLE
|
|
175
|
|
- ) );
|
|
176
|
|
- $cmb->add_field( array(
|
|
177
|
|
- 'name' => __( 'Alternate Name', 'cmb2' ),
|
|
178
|
|
- 'desc' => __( 'Name to use for alphabetical sorting', 'cmb2' ),
|
|
179
|
|
- 'id' => 'artist-sort-name',
|
|
180
|
|
- 'type' => 'text'
|
|
181
|
|
- ) );
|
|
182
|
|
-}
|
|
|
87
|
+
|
|
|
88
|
+/* Plugin Logic -- END * /
|