@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @license GPL-2.0+ |
11 | 11 | */ |
12 | 12 | |
13 | -if ( ! class_exists( 'CMB2_Meta_Box' ) ) { |
|
13 | +if ( ! class_exists('CMB2_Meta_Box')) { |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Class CMB2_Meta_Box. |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function __construct() { |
56 | 56 | |
57 | - add_action( 'pre_current_active_plugins', array( $this, 'hide_cmb2_plugins' ) ); |
|
58 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
|
59 | - add_action( 'cmb2_init', array( $this, 'init_user_defined_meta_boxes_and_fields' ) ); |
|
57 | + add_action('pre_current_active_plugins', array($this, 'hide_cmb2_plugins')); |
|
58 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')); |
|
59 | + add_action('cmb2_init', array($this, 'init_user_defined_meta_boxes_and_fields')); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public static function get_instance() { |
68 | 68 | // If the single instance hasn't been set, set it now. |
69 | - if ( self::$instance === null ) { |
|
69 | + if (self::$instance === null) { |
|
70 | 70 | self::$instance = new self(); |
71 | 71 | } |
72 | 72 | |
@@ -81,17 +81,17 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function is_cmb2_allowed() { |
83 | 83 | |
84 | - $cmb2_settings = get_option( '_cmb2_settings' ); |
|
84 | + $cmb2_settings = get_option('_cmb2_settings'); |
|
85 | 85 | |
86 | - if ( empty( $cmb2_settings ) || current_user_can( 'administrator' ) ) { |
|
86 | + if (empty($cmb2_settings) || current_user_can('administrator')) { |
|
87 | 87 | // No settings saved. |
88 | 88 | return true; |
89 | 89 | } |
90 | 90 | |
91 | 91 | $current_user = wp_get_current_user(); |
92 | - $allowed_users = isset( $cmb2_settings['_cmb2_user_multicheckbox'] ) ? $cmb2_settings['_cmb2_user_multicheckbox'] : array(); |
|
92 | + $allowed_users = isset($cmb2_settings['_cmb2_user_multicheckbox']) ? $cmb2_settings['_cmb2_user_multicheckbox'] : array(); |
|
93 | 93 | |
94 | - return empty( $allowed_users ) || in_array( $current_user->ID, $allowed_users, true ); |
|
94 | + return empty($allowed_users) || in_array($current_user->ID, $allowed_users, true); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | public function hide_cmb2_plugins() { |
103 | 103 | |
104 | 104 | global $wp_list_table; |
105 | - if ( ! $this->is_cmb2_allowed() ) { |
|
106 | - $to_hide = array( CMB2AE_CMB2_PLUGIN_FILE, 'cmb2-admin-extension/cmb2-admin-extension.php' ); |
|
105 | + if ( ! $this->is_cmb2_allowed()) { |
|
106 | + $to_hide = array(CMB2AE_CMB2_PLUGIN_FILE, 'cmb2-admin-extension/cmb2-admin-extension.php'); |
|
107 | 107 | $plugins = $wp_list_table->items; |
108 | - foreach ( array_keys( $plugins ) as $key ) { |
|
109 | - if ( in_array( $key, $to_hide, true ) ) { |
|
110 | - unset( $wp_list_table->items[ $key ] ); |
|
108 | + foreach (array_keys($plugins) as $key) { |
|
109 | + if (in_array($key, $to_hide, true)) { |
|
110 | + unset($wp_list_table->items[$key]); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | } |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | public function enqueue_scripts() { |
122 | 122 | |
123 | 123 | $screen = get_current_screen(); |
124 | - if ( $screen->post_type === 'meta_box' ) { |
|
124 | + if ($screen->post_type === 'meta_box') { |
|
125 | 125 | |
126 | - wp_register_style( 'cmb2_admin_styles', CMB2AE_URI . '/css/meta-box-fields.css', array(), '0.0.8' ); |
|
127 | - wp_enqueue_style( 'cmb2_admin_styles' ); |
|
128 | - wp_enqueue_script( 'cmb2_admin_scripts', CMB2AE_URI . '/js/meta-box-fields.js', array( 'jquery' ), '0.0.8', true ); |
|
126 | + wp_register_style('cmb2_admin_styles', CMB2AE_URI . '/css/meta-box-fields.css', array(), '0.0.8'); |
|
127 | + wp_enqueue_style('cmb2_admin_styles'); |
|
128 | + wp_enqueue_script('cmb2_admin_scripts', CMB2AE_URI . '/js/meta-box-fields.js', array('jquery'), '0.0.8', true); |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @param string $field_type A CMB2 field type. |
137 | 137 | * @return boolean. |
138 | 138 | */ |
139 | - public function is_repeatable( $field_type ) { |
|
139 | + public function is_repeatable($field_type) { |
|
140 | 140 | |
141 | 141 | $repeatable_fields = array( |
142 | 142 | 'text', |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | 'file', |
162 | 162 | 'file_list', |
163 | 163 | ); |
164 | - return in_array( $field_type, $repeatable_fields, true ); |
|
164 | + return in_array($field_type, $repeatable_fields, true); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * @param string $field_type A CMB2 field type. |
172 | 172 | * @return boolean. |
173 | 173 | */ |
174 | - private function has_options( $field_type ) { |
|
174 | + private function has_options($field_type) { |
|
175 | 175 | |
176 | 176 | $options_fields = array( |
177 | 177 | 'radio', |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | 'taxonomy_multicheck', |
186 | 186 | 'taxonomy_multicheck_inline', |
187 | 187 | ); |
188 | - return in_array( $field_type, $options_fields, true ); |
|
188 | + return in_array($field_type, $options_fields, true); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -194,16 +194,16 @@ discard block |
||
194 | 194 | * @since 1.1.4 |
195 | 195 | * @param string $field_options String of options for fields liek select. |
196 | 196 | */ |
197 | - private function add_option_arg( $field_options ) { |
|
198 | - $field_options = preg_split( "/\\r\\n|\\r|\\n/", $field_options ); |
|
197 | + private function add_option_arg($field_options) { |
|
198 | + $field_options = preg_split("/\\r\\n|\\r|\\n/", $field_options); |
|
199 | 199 | $options = array(); |
200 | - foreach ( $field_options as $option ) { |
|
201 | - $opt_arr = explode( ',', $option ); |
|
202 | - if ( ! isset( $opt_arr[1] ) ) { |
|
203 | - $options[ $option ] = $option; |
|
200 | + foreach ($field_options as $option) { |
|
201 | + $opt_arr = explode(',', $option); |
|
202 | + if ( ! isset($opt_arr[1])) { |
|
203 | + $options[$option] = $option; |
|
204 | 204 | continue; |
205 | 205 | } |
206 | - $options[ $opt_arr[0] ] = $opt_arr[1]; |
|
206 | + $options[$opt_arr[0]] = $opt_arr[1]; |
|
207 | 207 | } |
208 | 208 | $this->field_args['options'] = $options; |
209 | 209 | } |
@@ -214,15 +214,15 @@ discard block |
||
214 | 214 | * @since 1.1.4 |
215 | 215 | * @param array $arg_value A CMB2 field type. |
216 | 216 | */ |
217 | - public function add_strpos_arg( $arg_value ) { |
|
217 | + public function add_strpos_arg($arg_value) { |
|
218 | 218 | |
219 | - if ( strpos( $this->field['_cmb2_field_type_select'], $arg_value[0] ) !== false && isset( $this->field[ $arg_value[2] ] ) && $this->field[ $arg_value[2] ] !== '' ) { |
|
219 | + if (strpos($this->field['_cmb2_field_type_select'], $arg_value[0]) !== false && isset($this->field[$arg_value[2]]) && $this->field[$arg_value[2]] !== '') { |
|
220 | 220 | |
221 | - if ( is_array( $arg_value[1] ) ) { |
|
222 | - $this->field_args[ $arg_value[1][0] ][ $arg_value[1][1] ] = $this->field[ $arg_value[2] ]; |
|
221 | + if (is_array($arg_value[1])) { |
|
222 | + $this->field_args[$arg_value[1][0]][$arg_value[1][1]] = $this->field[$arg_value[2]]; |
|
223 | 223 | return; |
224 | 224 | } |
225 | - $this->field_args[ $arg_value[1] ] = $this->field[ $arg_value[2] ]; |
|
225 | + $this->field_args[$arg_value[1]] = $this->field[$arg_value[2]]; |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
@@ -233,16 +233,16 @@ discard block |
||
233 | 233 | * @param string $arg Field definition. |
234 | 234 | * @param string|array $value A CMB2 field type. |
235 | 235 | */ |
236 | - public function add_arg( $arg, $value ) { |
|
236 | + public function add_arg($arg, $value) { |
|
237 | 237 | |
238 | - if ( $this->should_add_arg( $this->field, $arg, $value[1] ) ) { |
|
238 | + if ($this->should_add_arg($this->field, $arg, $value[1])) { |
|
239 | 239 | |
240 | - if ( is_array( $value[1] ) ) { |
|
240 | + if (is_array($value[1])) { |
|
241 | 241 | |
242 | - $this->field_args[ $value[0] ][ $value[1][0] ] = $this->field[ $value[1][1] ]; |
|
242 | + $this->field_args[$value[0]][$value[1][0]] = $this->field[$value[1][1]]; |
|
243 | 243 | return; |
244 | 244 | } |
245 | - $this->field_args[ $value[0] ] = $this->field[ $value[1] ]; |
|
245 | + $this->field_args[$value[0]] = $this->field[$value[1]]; |
|
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
@@ -255,9 +255,9 @@ discard block |
||
255 | 255 | * @param string $field_key Field key to check. |
256 | 256 | * @return boolean. |
257 | 257 | */ |
258 | - public static function should_add_arg( $field, $field_type, $field_key ) { |
|
258 | + public static function should_add_arg($field, $field_type, $field_key) { |
|
259 | 259 | |
260 | - return ( $field['_cmb2_field_type_select'] === $field_type && ( ! empty( $field[ $field_key ] ) && $field[ $field_key ] !== '' ) ); |
|
260 | + return ($field['_cmb2_field_type_select'] === $field_type && ( ! empty($field[$field_key]) && $field[$field_key] !== '')); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -268,19 +268,19 @@ discard block |
||
268 | 268 | * @param object $metabox Metabox object. |
269 | 269 | * @param mixed $group_field_id If is reaptable group this is the ID, and false otherwise. |
270 | 270 | */ |
271 | - public function add_field( $field, $metabox, $group_field_id ) { |
|
271 | + public function add_field($field, $metabox, $group_field_id) { |
|
272 | 272 | |
273 | - $field = wp_parse_args( $field, array( |
|
273 | + $field = wp_parse_args($field, array( |
|
274 | 274 | '_cmb2_name_text' => null, |
275 | 275 | '_cmb2_decription_textarea' => null, |
276 | 276 | '_cmb2_field_type_select' => null, |
277 | 277 | '_cmb2_options_textarea' => false, |
278 | 278 | '_cmb2_repeatable_checkbox' => null, |
279 | 279 | '_cmb2_none_checkbox' => null, |
280 | - ) ); |
|
280 | + )); |
|
281 | 281 | |
282 | 282 | $this->field = $field; |
283 | - $field_id = '_' . strtolower( str_replace( ' ', '_', $field['_cmb2_name_text'] ) ); |
|
283 | + $field_id = '_' . strtolower(str_replace(' ', '_', $field['_cmb2_name_text'])); |
|
284 | 284 | |
285 | 285 | $this->field_args = array( |
286 | 286 | 'name' => $field['_cmb2_name_text'], |
@@ -290,42 +290,42 @@ discard block |
||
290 | 290 | ); |
291 | 291 | |
292 | 292 | $field_options = $field['_cmb2_options_textarea']; |
293 | - if ( $field_options ) { |
|
294 | - $this->add_option_arg( $field_options ); |
|
293 | + if ($field_options) { |
|
294 | + $this->add_option_arg($field_options); |
|
295 | 295 | } |
296 | 296 | $should_add_strpos = array( |
297 | - array( 'tax', 'taxonomy', '_cmb2_tax_options_radio_inline' ), |
|
298 | - array( 'tax', array( 'options', 'no_terms_text' ), '_cmb2_no_terms_text' ), |
|
299 | - array( 'multicheck', 'select_all_button', '_cmb2_select_all_checkbox' ), |
|
297 | + array('tax', 'taxonomy', '_cmb2_tax_options_radio_inline'), |
|
298 | + array('tax', array('options', 'no_terms_text'), '_cmb2_no_terms_text'), |
|
299 | + array('multicheck', 'select_all_button', '_cmb2_select_all_checkbox'), |
|
300 | 300 | ); |
301 | - foreach ( $should_add_strpos as $arg_value ) { |
|
302 | - $this->add_strpos_arg( $arg_value ); |
|
301 | + foreach ($should_add_strpos as $arg_value) { |
|
302 | + $this->add_strpos_arg($arg_value); |
|
303 | 303 | } |
304 | - if ( $field['_cmb2_repeatable_checkbox'] === 'on' && $this->is_repeatable( $field['_cmb2_field_type_select'] ) ) { |
|
304 | + if ($field['_cmb2_repeatable_checkbox'] === 'on' && $this->is_repeatable($field['_cmb2_field_type_select'])) { |
|
305 | 305 | $this->field_args['repeatable'] = true; |
306 | 306 | } |
307 | - if ( $field['_cmb2_none_checkbox'] === 'on' && $this->has_options( $field['_cmb2_field_type_select'] ) ) { |
|
307 | + if ($field['_cmb2_none_checkbox'] === 'on' && $this->has_options($field['_cmb2_field_type_select'])) { |
|
308 | 308 | $this->field_args['show_option_none'] = true; |
309 | 309 | } |
310 | 310 | $should_add = array( |
311 | - 'text_url' => array( 'protocols', '_cmb2_protocols_checkbox' ), |
|
312 | - 'text_money' => array( 'before_field', '_cmb2_currency_text' ), |
|
313 | - 'text_time' => array( 'time_format', '_cmb2_time_format' ), |
|
314 | - 'text_datetime_timestamp_timezone' => array( 'time_format', '_cmb2_time_format' ), |
|
315 | - 'text_datetime_timestamp' => array( 'time_format', '_cmb2_time_format' ), |
|
316 | - 'text_date' => array( 'date_format', '_cmb2_date_format' ), |
|
317 | - 'text_date_timestamp' => array( 'date_format', '_cmb2_date_format' ), |
|
318 | - 'select_timezone' => array( 'timezone_meta_key', '_cmb2_time_zone_key_select' ), |
|
319 | - 'text_datetime_timestamp_timezone' => array( 'timezone_meta_key', '_cmb2_time_zone_key_select' ), |
|
311 | + 'text_url' => array('protocols', '_cmb2_protocols_checkbox'), |
|
312 | + 'text_money' => array('before_field', '_cmb2_currency_text'), |
|
313 | + 'text_time' => array('time_format', '_cmb2_time_format'), |
|
314 | + 'text_datetime_timestamp_timezone' => array('time_format', '_cmb2_time_format'), |
|
315 | + 'text_datetime_timestamp' => array('time_format', '_cmb2_time_format'), |
|
316 | + 'text_date' => array('date_format', '_cmb2_date_format'), |
|
317 | + 'text_date_timestamp' => array('date_format', '_cmb2_date_format'), |
|
318 | + 'select_timezone' => array('timezone_meta_key', '_cmb2_time_zone_key_select'), |
|
319 | + 'text_datetime_timestamp_timezone' => array('timezone_meta_key', '_cmb2_time_zone_key_select'), |
|
320 | 320 | ); |
321 | - foreach ( $should_add as $arg => $value ) { |
|
322 | - $this->add_arg( $arg, $value ); |
|
321 | + foreach ($should_add as $arg => $value) { |
|
322 | + $this->add_arg($arg, $value); |
|
323 | 323 | } |
324 | - if ( $group_field_id ) { |
|
325 | - $metabox->add_group_field( $group_field_id, $this->field_args ); |
|
324 | + if ($group_field_id) { |
|
325 | + $metabox->add_group_field($group_field_id, $this->field_args); |
|
326 | 326 | return; |
327 | 327 | } |
328 | - $metabox->add_field( $this->field_args ); |
|
328 | + $metabox->add_field($this->field_args); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | /** |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | * @since 0.2.0 |
335 | 335 | * @param string $meta Sting value of checkbox on. |
336 | 336 | */ |
337 | - public function string_to_bool( $meta ) { |
|
337 | + public function string_to_bool($meta) { |
|
338 | 338 | |
339 | 339 | return $meta === 'on' ? true : false; |
340 | 340 | } |
@@ -345,25 +345,25 @@ discard block |
||
345 | 345 | * @since 0.2.0 |
346 | 346 | * @param object $user_meta_box Post object. |
347 | 347 | */ |
348 | - public function get_meta_data( $user_meta_box ) { |
|
348 | + public function get_meta_data($user_meta_box) { |
|
349 | 349 | |
350 | 350 | $prefix = $this->prefix; |
351 | 351 | $metabox_id = $user_meta_box->ID; |
352 | 352 | |
353 | - $meta_data['title'] = get_the_title( $metabox_id ); |
|
354 | - $meta_data['id'] = str_replace( '-', '_', $user_meta_box->post_name ); |
|
355 | - $meta_data['post_type'] = cmbf( $metabox_id, $prefix . 'post_type_multicheckbox' ); |
|
356 | - $meta_data['post_id_text'] = cmbf( $metabox_id, $prefix . 'post_id_text' ); |
|
357 | - $meta_data['context'] = cmbf( $metabox_id, $prefix . 'context_radio' ); |
|
358 | - $meta_data['priority'] = cmbf( $metabox_id, $prefix . 'priority_radio' ); |
|
359 | - $meta_data['show_names'] = $this->string_to_bool( cmbf( $metabox_id, $prefix . 'show_names' ) ); |
|
360 | - $meta_data['disable_styles'] = $this->string_to_bool( cmbf( $metabox_id, $prefix . 'disable_styles' ) ); |
|
361 | - $meta_data['closed'] = $this->string_to_bool( cmbf( $metabox_id, $prefix . 'closed' ) ); |
|
362 | - $meta_data['repeatable'] = $this->string_to_bool( cmbf( $metabox_id, $prefix . 'repeatable_group' ) ); |
|
363 | - $meta_data['group_desc'] = cmbf( $metabox_id, $prefix . 'group_description' ); |
|
364 | - $entry_name = cmbf( $metabox_id, $prefix . 'entry_name' ); |
|
353 | + $meta_data['title'] = get_the_title($metabox_id); |
|
354 | + $meta_data['id'] = str_replace('-', '_', $user_meta_box->post_name); |
|
355 | + $meta_data['post_type'] = cmbf($metabox_id, $prefix . 'post_type_multicheckbox'); |
|
356 | + $meta_data['post_id_text'] = cmbf($metabox_id, $prefix . 'post_id_text'); |
|
357 | + $meta_data['context'] = cmbf($metabox_id, $prefix . 'context_radio'); |
|
358 | + $meta_data['priority'] = cmbf($metabox_id, $prefix . 'priority_radio'); |
|
359 | + $meta_data['show_names'] = $this->string_to_bool(cmbf($metabox_id, $prefix . 'show_names')); |
|
360 | + $meta_data['disable_styles'] = $this->string_to_bool(cmbf($metabox_id, $prefix . 'disable_styles')); |
|
361 | + $meta_data['closed'] = $this->string_to_bool(cmbf($metabox_id, $prefix . 'closed')); |
|
362 | + $meta_data['repeatable'] = $this->string_to_bool(cmbf($metabox_id, $prefix . 'repeatable_group')); |
|
363 | + $meta_data['group_desc'] = cmbf($metabox_id, $prefix . 'group_description'); |
|
364 | + $entry_name = cmbf($metabox_id, $prefix . 'entry_name'); |
|
365 | 365 | $meta_data['entry_name'] = $entry_name ? $entry_name : 'Entry'; |
366 | - $meta_data['fields'] = cmbf( $metabox_id, $prefix . 'custom_field' ); |
|
366 | + $meta_data['fields'] = cmbf($metabox_id, $prefix . 'custom_field'); |
|
367 | 367 | |
368 | 368 | return $meta_data; |
369 | 369 | } |
@@ -382,11 +382,11 @@ discard block |
||
382 | 382 | 'suppress_filters' => false, |
383 | 383 | ); |
384 | 384 | |
385 | - $user_meta_boxes = new WP_Query( $args ); |
|
385 | + $user_meta_boxes = new WP_Query($args); |
|
386 | 386 | |
387 | - foreach ( $user_meta_boxes->posts as $user_meta_box ) { |
|
387 | + foreach ($user_meta_boxes->posts as $user_meta_box) { |
|
388 | 388 | |
389 | - $meta_data = $this->get_meta_data( $user_meta_box ); |
|
389 | + $meta_data = $this->get_meta_data($user_meta_box); |
|
390 | 390 | /** |
391 | 391 | * Initiate the metabox. |
392 | 392 | */ |
@@ -400,40 +400,40 @@ discard block |
||
400 | 400 | 'cmb_styles' => $meta_data['disable_styles'], |
401 | 401 | 'closed' => $meta_data['closed'], |
402 | 402 | ); |
403 | - if ( $meta_data['post_id_text'] !== '' ) { |
|
403 | + if ($meta_data['post_id_text'] !== '') { |
|
404 | 404 | |
405 | 405 | $new_cmb2_args['show_on'] = array( |
406 | 406 | 'key' => 'id', |
407 | - 'value' => explode( ',', $meta_data['post_id_text'] ), |
|
407 | + 'value' => explode(',', $meta_data['post_id_text']), |
|
408 | 408 | ); |
409 | 409 | } |
410 | - ${ 'cmb_' . $meta_data['id'] } = new_cmb2_box( $new_cmb2_args ); |
|
410 | + ${ 'cmb_' . $meta_data['id'] } = new_cmb2_box($new_cmb2_args); |
|
411 | 411 | $meta_box = ${ 'cmb_' . $meta_data['id'] }; |
412 | 412 | $group_field_id = false; |
413 | - if ( $meta_data['repeatable'] ) { |
|
413 | + if ($meta_data['repeatable']) { |
|
414 | 414 | |
415 | - $group_field_id = ${ 'cmb_' . $meta_data['id'] }->add_field( array( |
|
415 | + $group_field_id = ${ 'cmb_' . $meta_data['id'] }->add_field(array( |
|
416 | 416 | 'id' => '_' . $meta_data['id'], |
417 | 417 | 'type' => 'group', |
418 | 418 | 'description' => $meta_data['group_desc'], |
419 | 419 | 'options' => array( |
420 | - 'group_title' => $meta_data['entry_name'] . __( ' {#}', 'cmb2' ), |
|
421 | - 'add_button' => __( 'Add Another ', 'cmb2' ) . $meta_data['entry_name'], |
|
422 | - 'remove_button' => __( 'Remove ', 'cmb2' ) . $meta_data['entry_name'], |
|
420 | + 'group_title' => $meta_data['entry_name'] . __(' {#}', 'cmb2'), |
|
421 | + 'add_button' => __('Add Another ', 'cmb2') . $meta_data['entry_name'], |
|
422 | + 'remove_button' => __('Remove ', 'cmb2') . $meta_data['entry_name'], |
|
423 | 423 | 'sortable' => true, |
424 | 424 | ), |
425 | - ) ); |
|
425 | + )); |
|
426 | 426 | } |
427 | - foreach ( $meta_data['fields'] as $field ) { |
|
427 | + foreach ($meta_data['fields'] as $field) { |
|
428 | 428 | |
429 | - $this->add_field( $field, $meta_box, $group_field_id ); |
|
429 | + $this->add_field($field, $meta_box, $group_field_id); |
|
430 | 430 | } |
431 | 431 | } |
432 | 432 | } |
433 | 433 | } |
434 | 434 | } |
435 | 435 | |
436 | -if ( ! function_exists( 'cmb2ae_metabox' ) ) { |
|
436 | +if ( ! function_exists('cmb2ae_metabox')) { |
|
437 | 437 | /** |
438 | 438 | * Main instance of CMB2_Meta_Box. |
439 | 439 | * |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @license GPL-2.0+ |
11 | 11 | */ |
12 | 12 | |
13 | -if ( ! class_exists( 'CMB2_Meta_Box_Post_Type' ) ) { |
|
13 | +if ( ! class_exists('CMB2_Meta_Box_Post_Type')) { |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Class CMB2_Meta_Box_Post_Type. |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function __construct() { |
43 | 43 | |
44 | - add_action( 'init', array( $this, 'init_post_type' ) ); |
|
45 | - add_action( 'add_meta_boxes', array( $this, 'remove_meta_box_slugdiv' ) ); |
|
46 | - add_action( 'admin_head', array( $this, 'hide_edit_slug_bar' ) ); |
|
47 | - add_action( 'cmb2_init', array( $this, 'init_custom_field_settings' ) ); |
|
48 | - add_action( 'cmb2_init', array( $this, 'init_meta_box_settings' ) ); |
|
49 | - add_filter( 'cmb2_row_classes', array( $this, 'show_hide_classes' ), 10, 2 ); |
|
44 | + add_action('init', array($this, 'init_post_type')); |
|
45 | + add_action('add_meta_boxes', array($this, 'remove_meta_box_slugdiv')); |
|
46 | + add_action('admin_head', array($this, 'hide_edit_slug_bar')); |
|
47 | + add_action('cmb2_init', array($this, 'init_custom_field_settings')); |
|
48 | + add_action('cmb2_init', array($this, 'init_meta_box_settings')); |
|
49 | + add_filter('cmb2_row_classes', array($this, 'show_hide_classes'), 10, 2); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -57,31 +57,31 @@ discard block |
||
57 | 57 | public function init_post_type() { |
58 | 58 | |
59 | 59 | $labels = array( |
60 | - 'name' => _x( 'Meta Boxes', 'Post Type General Name', 'cmb2-admin-extension' ), |
|
61 | - 'singular_name' => _x( 'Meta Box', 'Post Type Singular Name', 'cmb2-admin-extension' ), |
|
62 | - 'menu_name' => __( 'CMB2', 'cmb2-admin-extension' ), |
|
63 | - 'name_admin_bar' => __( 'Meta Box', 'cmb2-admin-extension' ), |
|
64 | - 'parent_item_colon' => __( 'Meta Box:', 'cmb2-admin-extension' ), |
|
65 | - 'all_items' => __( 'All Meta Boxes', 'cmb2-admin-extension' ), |
|
66 | - 'add_new_item' => __( 'Add New Meta Box', 'cmb2-admin-extension' ), |
|
67 | - 'add_new' => __( 'Add New Meta Box', 'cmb2-admin-extension' ), |
|
68 | - 'new_item' => __( 'New Meta Box', 'cmb2-admin-extension' ), |
|
69 | - 'edit_item' => __( 'Edit Meta Box', 'cmb2-admin-extension' ), |
|
70 | - 'update_item' => __( 'Update Meta Box', 'cmb2-admin-extension' ), |
|
71 | - 'view_item' => __( 'View Meta Box', 'cmb2-admin-extension' ), |
|
72 | - 'search_items' => __( 'Search Meta Box', 'cmb2-admin-extension' ), |
|
73 | - 'not_found' => __( 'Not found', 'cmb2-admin-extension' ), |
|
74 | - 'not_found_in_trash' => __( 'Not found in Trash', 'cmb2-admin-extension' ), |
|
60 | + 'name' => _x('Meta Boxes', 'Post Type General Name', 'cmb2-admin-extension'), |
|
61 | + 'singular_name' => _x('Meta Box', 'Post Type Singular Name', 'cmb2-admin-extension'), |
|
62 | + 'menu_name' => __('CMB2', 'cmb2-admin-extension'), |
|
63 | + 'name_admin_bar' => __('Meta Box', 'cmb2-admin-extension'), |
|
64 | + 'parent_item_colon' => __('Meta Box:', 'cmb2-admin-extension'), |
|
65 | + 'all_items' => __('All Meta Boxes', 'cmb2-admin-extension'), |
|
66 | + 'add_new_item' => __('Add New Meta Box', 'cmb2-admin-extension'), |
|
67 | + 'add_new' => __('Add New Meta Box', 'cmb2-admin-extension'), |
|
68 | + 'new_item' => __('New Meta Box', 'cmb2-admin-extension'), |
|
69 | + 'edit_item' => __('Edit Meta Box', 'cmb2-admin-extension'), |
|
70 | + 'update_item' => __('Update Meta Box', 'cmb2-admin-extension'), |
|
71 | + 'view_item' => __('View Meta Box', 'cmb2-admin-extension'), |
|
72 | + 'search_items' => __('Search Meta Box', 'cmb2-admin-extension'), |
|
73 | + 'not_found' => __('Not found', 'cmb2-admin-extension'), |
|
74 | + 'not_found_in_trash' => __('Not found in Trash', 'cmb2-admin-extension'), |
|
75 | 75 | ); |
76 | 76 | |
77 | 77 | $args = array( |
78 | - 'label' => __( 'meta_box', 'cmb2-admin-extension' ), |
|
79 | - 'description' => __( 'Create custom meta boxes and fields', 'cmb2-admin-extension' ), |
|
78 | + 'label' => __('meta_box', 'cmb2-admin-extension'), |
|
79 | + 'description' => __('Create custom meta boxes and fields', 'cmb2-admin-extension'), |
|
80 | 80 | 'labels' => $labels, |
81 | 81 | 'supports' => array(), |
82 | 82 | 'hierarchical' => false, |
83 | 83 | 'rewrite' => true, |
84 | - 'supports' => array( 'title' ), |
|
84 | + 'supports' => array('title'), |
|
85 | 85 | 'public' => true, |
86 | 86 | 'menu_position' => 100, |
87 | 87 | 'menu_icon' => 'dashicons-feedback', |
@@ -97,13 +97,13 @@ discard block |
||
97 | 97 | $args['show_ui'] = false; |
98 | 98 | $args['show_in_menu'] = false; |
99 | 99 | |
100 | - if ( $this->is_cmb2_allowed() ) { |
|
100 | + if ($this->is_cmb2_allowed()) { |
|
101 | 101 | |
102 | 102 | $args['show_ui'] = true; |
103 | 103 | $args['show_in_menu'] = true; |
104 | 104 | |
105 | 105 | } |
106 | - register_post_type( 'meta_box', $args ); |
|
106 | + register_post_type('meta_box', $args); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function remove_meta_box_slugdiv() { |
115 | 115 | |
116 | - remove_meta_box( 'slugdiv', 'page', 'normal' ); |
|
116 | + remove_meta_box('slugdiv', 'page', 'normal'); |
|
117 | 117 | |
118 | 118 | } |
119 | 119 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | global $post; |
128 | 128 | |
129 | - if ( isset( $post->post_type ) && $post->post_type === 'meta_box' ) { |
|
129 | + if (isset($post->post_type) && $post->post_type === 'meta_box') { |
|
130 | 130 | |
131 | 131 | echo '<style type="text/css"> #edit-slug-box, #minor-publishing { display: none; }</style>'; |
132 | 132 | |
@@ -142,17 +142,17 @@ discard block |
||
142 | 142 | */ |
143 | 143 | private function is_cmb2_allowed() { |
144 | 144 | |
145 | - $cmb2_settings = get_option( '_cmb2_settings' ); |
|
145 | + $cmb2_settings = get_option('_cmb2_settings'); |
|
146 | 146 | |
147 | - if ( empty( $cmb2_settings ) ) { |
|
147 | + if (empty($cmb2_settings)) { |
|
148 | 148 | // No settings saved. |
149 | 149 | return true; |
150 | 150 | } |
151 | 151 | |
152 | 152 | $current_user = wp_get_current_user(); |
153 | - $allowed_users = isset( $cmb2_settings['_cmb2_user_multicheckbox'] ) ? $cmb2_settings['_cmb2_user_multicheckbox'] : array(); |
|
153 | + $allowed_users = isset($cmb2_settings['_cmb2_user_multicheckbox']) ? $cmb2_settings['_cmb2_user_multicheckbox'] : array(); |
|
154 | 154 | |
155 | - if ( empty( $allowed_users ) || in_array( $current_user->ID, $allowed_users, true ) ) { |
|
155 | + if (empty($allowed_users) || in_array($current_user->ID, $allowed_users, true)) { |
|
156 | 156 | |
157 | 157 | return true; |
158 | 158 | |
@@ -170,10 +170,10 @@ discard block |
||
170 | 170 | * @param array $field_classes CSS Classes. |
171 | 171 | * @param string $classes CSS Classes to add. |
172 | 172 | */ |
173 | - public function conditionally_add_class( $field_id, $field_classes, $classes ) { |
|
173 | + public function conditionally_add_class($field_id, $field_classes, $classes) { |
|
174 | 174 | |
175 | - foreach ( $field_classes as $field => $class ) { |
|
176 | - if ( strpos( $field_id, $field ) !== false ) { |
|
175 | + foreach ($field_classes as $field => $class) { |
|
176 | + if (strpos($field_id, $field) !== false) { |
|
177 | 177 | return $classes . ' ' . $class; |
178 | 178 | } |
179 | 179 | } |
@@ -190,10 +190,10 @@ discard block |
||
190 | 190 | * @param array $classes CSS Classes. |
191 | 191 | * @param object $field CMB2 Field object. |
192 | 192 | */ |
193 | - public function show_hide_classes( $classes, $field ) { |
|
193 | + public function show_hide_classes($classes, $field) { |
|
194 | 194 | |
195 | 195 | $screen = get_current_screen(); |
196 | - if ( $screen->post_type === 'meta_box' ) { |
|
196 | + if ($screen->post_type === 'meta_box') { |
|
197 | 197 | $field_classes = array( |
198 | 198 | 'repeatable_checkbox' => 'cmb_hide_field text text_small text_medium text_email text_url text_money textarea textarea_small textarea_code text_date text_timeselect_timezone text_date_timestamp text_datetime_timestamp text_datetime_timestamp_timezone color_picker select multicheck multicheck_inline', |
199 | 199 | 'protocols_checkbox' => 'cmb_hide_field text_url', |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | 'default_value_text' => 'default_value', |
211 | 211 | ); |
212 | 212 | |
213 | - $classes = $this->conditionally_add_class( $field->args['_id'], $field_classes, $classes ); |
|
213 | + $classes = $this->conditionally_add_class($field->args['_id'], $field_classes, $classes); |
|
214 | 214 | } |
215 | 215 | return $classes; |
216 | 216 | |
@@ -223,11 +223,11 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function tax_options() { |
225 | 225 | |
226 | - $taxonomies = get_taxonomies( array( 'public' => true ), 'objects' ); |
|
226 | + $taxonomies = get_taxonomies(array('public' => true), 'objects'); |
|
227 | 227 | $tax_options = array(); |
228 | - foreach ( $taxonomies as $taxonomy ) { |
|
228 | + foreach ($taxonomies as $taxonomy) { |
|
229 | 229 | |
230 | - $tax_options[ $taxonomy->name ] = $taxonomy->labels->name; |
|
230 | + $tax_options[$taxonomy->name] = $taxonomy->labels->name; |
|
231 | 231 | |
232 | 232 | } |
233 | 233 | return $tax_options; |
@@ -242,118 +242,118 @@ discard block |
||
242 | 242 | public function init_meta_box_settings() { |
243 | 243 | |
244 | 244 | $prefix = $this->prefix; |
245 | - $post_type_objects = get_post_types( '', 'object' ); |
|
245 | + $post_type_objects = get_post_types('', 'object'); |
|
246 | 246 | $post_types = array(); |
247 | 247 | |
248 | - foreach ( $post_type_objects as $post_type_object ) { |
|
249 | - if ( $post_type_object->show_ui && $post_type_object->name !== 'meta_box' ) { |
|
250 | - $post_types[ $post_type_object->name ] = $post_type_object->label; |
|
248 | + foreach ($post_type_objects as $post_type_object) { |
|
249 | + if ($post_type_object->show_ui && $post_type_object->name !== 'meta_box') { |
|
250 | + $post_types[$post_type_object->name] = $post_type_object->label; |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
255 | 255 | * Initiate the metabox. |
256 | 256 | */ |
257 | - $cmb = new_cmb2_box( array( |
|
257 | + $cmb = new_cmb2_box(array( |
|
258 | 258 | 'id' => 'metabox_settings', |
259 | - 'title' => __( 'Metabox Settings', 'cmb2-admin-extension' ), |
|
260 | - 'object_types' => array( 'meta_box' ), // Post type. |
|
259 | + 'title' => __('Metabox Settings', 'cmb2-admin-extension'), |
|
260 | + 'object_types' => array('meta_box'), // Post type. |
|
261 | 261 | 'context' => 'side', |
262 | 262 | 'priority' => 'low', |
263 | 263 | 'show_names' => true, |
264 | - ) ); |
|
264 | + )); |
|
265 | 265 | |
266 | - $cmb->add_field( array( |
|
267 | - 'name' => __( 'Post Types', 'cmb2-admin-extension' ), |
|
268 | - 'desc' => __( 'Check the post types that you want to add this meta box to.', 'cmb2-admin-extension' ), |
|
266 | + $cmb->add_field(array( |
|
267 | + 'name' => __('Post Types', 'cmb2-admin-extension'), |
|
268 | + 'desc' => __('Check the post types that you want to add this meta box to.', 'cmb2-admin-extension'), |
|
269 | 269 | 'id' => $prefix . 'post_type_multicheckbox', |
270 | 270 | 'type' => 'multicheck', |
271 | 271 | 'options' => $post_types, |
272 | 272 | 'inline' => true, |
273 | - ) ); |
|
273 | + )); |
|
274 | 274 | |
275 | - $cmb->add_field( array( |
|
276 | - 'name' => __( 'Post IDs', 'cmb2-admin-extension' ), |
|
277 | - 'desc' => __( 'Enter the post ids that you want to add this meta box to. Separate multiple entries with a comma. Leave blank for the meta box to show up on all post IDs.', 'cmb2-admin-extension' ), |
|
275 | + $cmb->add_field(array( |
|
276 | + 'name' => __('Post IDs', 'cmb2-admin-extension'), |
|
277 | + 'desc' => __('Enter the post ids that you want to add this meta box to. Separate multiple entries with a comma. Leave blank for the meta box to show up on all post IDs.', 'cmb2-admin-extension'), |
|
278 | 278 | 'id' => $prefix . 'post_id_text', |
279 | 279 | 'type' => 'text', |
280 | 280 | 'inline' => true, |
281 | - ) ); |
|
281 | + )); |
|
282 | 282 | |
283 | - $cmb->add_field( array( |
|
284 | - 'name' => __( 'Priority', 'cmb2-admin-extension' ), |
|
285 | - 'desc' => __( 'This is to control what order your meta box appears in.', 'cmb2-admin-extension' ), |
|
283 | + $cmb->add_field(array( |
|
284 | + 'name' => __('Priority', 'cmb2-admin-extension'), |
|
285 | + 'desc' => __('This is to control what order your meta box appears in.', 'cmb2-admin-extension'), |
|
286 | 286 | 'id' => $prefix . 'priority_radio', |
287 | 287 | 'type' => 'radio', |
288 | 288 | 'default' => 'high', |
289 | 289 | 'options' => array( |
290 | - 'high' => __( 'High', 'cmb2-admin-extension' ), |
|
291 | - 'core' => __( 'Core', 'cmb2-admin-extension' ), |
|
292 | - 'default' => __( 'Default', 'cmb2-admin-extension' ), |
|
293 | - 'low' => __( 'Low', 'cmb2-admin-extension' ), |
|
290 | + 'high' => __('High', 'cmb2-admin-extension'), |
|
291 | + 'core' => __('Core', 'cmb2-admin-extension'), |
|
292 | + 'default' => __('Default', 'cmb2-admin-extension'), |
|
293 | + 'low' => __('Low', 'cmb2-admin-extension'), |
|
294 | 294 | ), |
295 | 295 | 'inline' => true, |
296 | - ) ); |
|
296 | + )); |
|
297 | 297 | |
298 | - $cmb->add_field( array( |
|
299 | - 'name' => __( 'Context', 'cmb2-admin-extension' ), |
|
300 | - 'desc' => __( 'This additional controls for positioning of the meta box. Advanced displays after Normal. Side places the meta box in the right sidebar.', 'cmb2-admin-extension' ), |
|
298 | + $cmb->add_field(array( |
|
299 | + 'name' => __('Context', 'cmb2-admin-extension'), |
|
300 | + 'desc' => __('This additional controls for positioning of the meta box. Advanced displays after Normal. Side places the meta box in the right sidebar.', 'cmb2-admin-extension'), |
|
301 | 301 | 'id' => $prefix . 'context_radio', |
302 | 302 | 'type' => 'radio', |
303 | 303 | 'default' => 'advanced', |
304 | 304 | 'options' => array( |
305 | - 'advanced' => __( 'Advanced', 'cmb2-admin-extension' ), |
|
306 | - 'normal' => __( 'Normal', 'cmb2-admin-extension' ), |
|
307 | - 'side' => __( 'Side', 'cmb2-admin-extension' ), |
|
305 | + 'advanced' => __('Advanced', 'cmb2-admin-extension'), |
|
306 | + 'normal' => __('Normal', 'cmb2-admin-extension'), |
|
307 | + 'side' => __('Side', 'cmb2-admin-extension'), |
|
308 | 308 | ), |
309 | 309 | 'inline' => true, |
310 | - ) ); |
|
310 | + )); |
|
311 | 311 | |
312 | - $cmb->add_field( array( |
|
313 | - 'name' => __( 'Show Names', 'cmb2-admin-extension' ), |
|
314 | - 'desc' => __( 'Show field names on the left', 'cmb2-admin-extension' ), |
|
312 | + $cmb->add_field(array( |
|
313 | + 'name' => __('Show Names', 'cmb2-admin-extension'), |
|
314 | + 'desc' => __('Show field names on the left', 'cmb2-admin-extension'), |
|
315 | 315 | 'id' => $prefix . 'show_names', |
316 | 316 | 'type' => 'checkbox', |
317 | 317 | 'default' => 'on', |
318 | - ) ); |
|
318 | + )); |
|
319 | 319 | |
320 | - $cmb->add_field( array( |
|
321 | - 'name' => __( 'Disable CMB2 Styles', 'cmb2-admin-extension' ), |
|
322 | - 'desc' => __( 'Check to disable the CMB stylesheet', 'cmb2-admin-extension' ), |
|
320 | + $cmb->add_field(array( |
|
321 | + 'name' => __('Disable CMB2 Styles', 'cmb2-admin-extension'), |
|
322 | + 'desc' => __('Check to disable the CMB stylesheet', 'cmb2-admin-extension'), |
|
323 | 323 | 'id' => $prefix . 'disable_styles', |
324 | 324 | 'type' => 'checkbox', |
325 | - ) ); |
|
325 | + )); |
|
326 | 326 | |
327 | - $cmb->add_field( array( |
|
328 | - 'name' => __( 'Closed by Default', 'cmb2-admin-extension' ), |
|
329 | - 'desc' => __( 'Check to keep the metabox closed by default', 'cmb2-admin-extension' ), |
|
327 | + $cmb->add_field(array( |
|
328 | + 'name' => __('Closed by Default', 'cmb2-admin-extension'), |
|
329 | + 'desc' => __('Check to keep the metabox closed by default', 'cmb2-admin-extension'), |
|
330 | 330 | 'id' => $prefix . 'closed', |
331 | 331 | 'type' => 'checkbox', |
332 | - ) ); |
|
332 | + )); |
|
333 | 333 | |
334 | - $cmb->add_field( array( |
|
335 | - 'name' => __( 'Repeatable Group', 'cmb2-admin-extension' ), |
|
336 | - 'desc' => __( 'Add these fields to a repeatable group.', 'cmb2-admin-extension' ), |
|
334 | + $cmb->add_field(array( |
|
335 | + 'name' => __('Repeatable Group', 'cmb2-admin-extension'), |
|
336 | + 'desc' => __('Add these fields to a repeatable group.', 'cmb2-admin-extension'), |
|
337 | 337 | 'id' => $prefix . 'repeatable_group', |
338 | 338 | 'type' => 'checkbox', |
339 | - ) ); |
|
339 | + )); |
|
340 | 340 | |
341 | - $cmb->add_field( array( |
|
342 | - 'name' => __( 'Description', 'cmb2-admin-extension' ), |
|
343 | - 'desc' => __( 'Short description for the repeatable group.', 'cmb2-admin-extension' ), |
|
341 | + $cmb->add_field(array( |
|
342 | + 'name' => __('Description', 'cmb2-admin-extension'), |
|
343 | + 'desc' => __('Short description for the repeatable group.', 'cmb2-admin-extension'), |
|
344 | 344 | 'id' => $prefix . 'group_description', |
345 | 345 | 'type' => 'textarea_small', |
346 | - ) ); |
|
346 | + )); |
|
347 | 347 | |
348 | - $cmb->add_field( array( |
|
349 | - 'name' => __( 'Entry Name', 'cmb2-admin-extension' ), |
|
350 | - 'desc' => __( 'Text to be used as entry name for each row (i.e. Entry 1). Defaults to the word "Entry".', 'cmb2-admin-extension' ), |
|
348 | + $cmb->add_field(array( |
|
349 | + 'name' => __('Entry Name', 'cmb2-admin-extension'), |
|
350 | + 'desc' => __('Text to be used as entry name for each row (i.e. Entry 1). Defaults to the word "Entry".', 'cmb2-admin-extension'), |
|
351 | 351 | 'id' => $prefix . 'entry_name', |
352 | 352 | 'type' => 'text', |
353 | 353 | 'inline' => true, |
354 | - ) ); |
|
354 | + )); |
|
355 | 355 | |
356 | - $cmb->add_field( array( |
|
356 | + $cmb->add_field(array( |
|
357 | 357 | 'name' => 'Native Usage', |
358 | 358 | 'description' => 'This is the WordPress ffunction used to get post meta. This should be treated as a starting point.', |
359 | 359 | 'id' => $prefix . 'get_post_meta_repeatable', |
@@ -365,9 +365,9 @@ discard block |
||
365 | 365 | 'readonly' => 'readonly', |
366 | 366 | 'disabled' => 'disabled', |
367 | 367 | ), |
368 | - ) ); |
|
368 | + )); |
|
369 | 369 | |
370 | - $cmb->add_field( array( |
|
370 | + $cmb->add_field(array( |
|
371 | 371 | 'name' => 'CMB2AE Usage', |
372 | 372 | 'description' => 'This is the CMB2 Admin Extension function used to get post meta. This should be treated as a starting point.', |
373 | 373 | 'id' => $prefix . 'cmbf_repeatable', |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | 'readonly' => 'readonly', |
380 | 380 | 'disabled' => 'disabled', |
381 | 381 | ), |
382 | - ) ); |
|
382 | + )); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
@@ -390,35 +390,35 @@ discard block |
||
390 | 390 | public function init_custom_field_settings() { |
391 | 391 | |
392 | 392 | $prefix = $this->prefix; |
393 | - $cmb_group = new_cmb2_box( array( |
|
393 | + $cmb_group = new_cmb2_box(array( |
|
394 | 394 | 'id' => $prefix . 'custom_fields', |
395 | - 'title' => __( 'Custom Field Settings', 'cmb2-admin-extension' ), |
|
396 | - 'object_types' => array( 'meta_box' ), |
|
397 | - ) ); |
|
395 | + 'title' => __('Custom Field Settings', 'cmb2-admin-extension'), |
|
396 | + 'object_types' => array('meta_box'), |
|
397 | + )); |
|
398 | 398 | |
399 | - $group_field_id = $cmb_group->add_field( array( |
|
399 | + $group_field_id = $cmb_group->add_field(array( |
|
400 | 400 | 'id' => $prefix . 'custom_field', |
401 | 401 | 'type' => 'group', |
402 | - 'description' => __( 'Add the custom fields that you want to display with in this meta box.', 'cmb2-admin-extension' ), |
|
402 | + 'description' => __('Add the custom fields that you want to display with in this meta box.', 'cmb2-admin-extension'), |
|
403 | 403 | 'options' => array( |
404 | - 'group_title' => __( 'Field {#}', 'cmb2-admin-extension' ), |
|
405 | - 'add_button' => __( 'Add Another Field', 'cmb2-admin-extension' ), |
|
406 | - 'remove_button' => __( 'Remove Field', 'cmb2-admin-extension' ), |
|
404 | + 'group_title' => __('Field {#}', 'cmb2-admin-extension'), |
|
405 | + 'add_button' => __('Add Another Field', 'cmb2-admin-extension'), |
|
406 | + 'remove_button' => __('Remove Field', 'cmb2-admin-extension'), |
|
407 | 407 | 'sortable' => true, // Beta. |
408 | 408 | ), |
409 | - ) ); |
|
409 | + )); |
|
410 | 410 | |
411 | - $cmb_group->add_group_field( $group_field_id, array( |
|
412 | - 'name' => __( 'Name', 'cmb2-admin-extension' ), |
|
413 | - 'desc' => __( 'Add a field name.', 'cmb2-admin-extension' ), |
|
411 | + $cmb_group->add_group_field($group_field_id, array( |
|
412 | + 'name' => __('Name', 'cmb2-admin-extension'), |
|
413 | + 'desc' => __('Add a field name.', 'cmb2-admin-extension'), |
|
414 | 414 | 'id' => $prefix . 'name_text', |
415 | 415 | 'type' => 'text', |
416 | 416 | 'attributes' => array( |
417 | 417 | 'class' => 'field_name', |
418 | 418 | ), |
419 | - ) ); |
|
419 | + )); |
|
420 | 420 | |
421 | - $cmb_group->add_group_field( $group_field_id, array( |
|
421 | + $cmb_group->add_group_field($group_field_id, array( |
|
422 | 422 | 'name' => 'Native Usage', |
423 | 423 | 'description' => 'This is the WordPress function used to get post meta. Copy and paste this code to your template files to use this meta data on the front end.', |
424 | 424 | 'id' => $prefix . 'get_post_meta', |
@@ -430,9 +430,9 @@ discard block |
||
430 | 430 | 'readonly' => 'readonly', |
431 | 431 | 'disabled' => 'disabled', |
432 | 432 | ), |
433 | - ) ); |
|
433 | + )); |
|
434 | 434 | |
435 | - $cmb_group->add_group_field( $group_field_id, array( |
|
435 | + $cmb_group->add_group_field($group_field_id, array( |
|
436 | 436 | 'name' => 'CMB2AE Usage', |
437 | 437 | 'description' => 'This is the CMB2 Admin Extension function used to get post meta. Copy and paste this code to your template files to use this meta data on the front end.', |
438 | 438 | 'id' => $prefix . 'cmbf', |
@@ -444,18 +444,18 @@ discard block |
||
444 | 444 | 'readonly' => 'readonly', |
445 | 445 | 'disabled' => 'disabled', |
446 | 446 | ), |
447 | - ) ); |
|
447 | + )); |
|
448 | 448 | |
449 | - $cmb_group->add_group_field( $group_field_id, array( |
|
450 | - 'name' => __( 'Description', 'cmb2-admin-extension' ), |
|
451 | - 'desc' => __( 'Add a field description.', 'cmb2-admin-extension' ), |
|
449 | + $cmb_group->add_group_field($group_field_id, array( |
|
450 | + 'name' => __('Description', 'cmb2-admin-extension'), |
|
451 | + 'desc' => __('Add a field description.', 'cmb2-admin-extension'), |
|
452 | 452 | 'id' => $prefix . 'decription_textarea', |
453 | 453 | 'type' => 'textarea_small', |
454 | - ) ); |
|
454 | + )); |
|
455 | 455 | |
456 | - $cmb_group->add_group_field( $group_field_id, array( |
|
457 | - 'name' => __( 'Field Type', 'cmb2-admin-extension' ), |
|
458 | - 'desc' => __( 'Pick what type of field to display.', 'cmb2-admin-extension' ) . '</br>' . __( 'For a full list of fields visit <a href="https://github.com/WebDevStudios/CMB2/wiki/Field-Types">the documentation</a>.', 'cmb2-admin-extension' ) . '</br>* ' . __( 'Not available as a repeatable field.', 'cmb2-admin-extension' ) . '</br>† ' . __( 'Use file_list for repeatable.', 'cmb2-admin-extension' ), |
|
456 | + $cmb_group->add_group_field($group_field_id, array( |
|
457 | + 'name' => __('Field Type', 'cmb2-admin-extension'), |
|
458 | + 'desc' => __('Pick what type of field to display.', 'cmb2-admin-extension') . '</br>' . __('For a full list of fields visit <a href="https://github.com/WebDevStudios/CMB2/wiki/Field-Types">the documentation</a>.', 'cmb2-admin-extension') . '</br>* ' . __('Not available as a repeatable field.', 'cmb2-admin-extension') . '</br>† ' . __('Use file_list for repeatable.', 'cmb2-admin-extension'), |
|
459 | 459 | 'id' => $prefix . 'field_type_select', |
460 | 460 | 'attributes' => array( |
461 | 461 | 'class' => 'cmb2_select field_type_select', |
@@ -463,51 +463,51 @@ discard block |
||
463 | 463 | 'type' => 'select', |
464 | 464 | 'show_option_none' => false, |
465 | 465 | 'options' => array( |
466 | - 'title' => 'title: ' . __( 'An arbitrary title field', 'cmb2-admin-extension' ) . ' *', |
|
467 | - 'text' => 'text: ' . __( 'Text', 'cmb2-admin-extension' ), |
|
468 | - 'text_small' => 'text_small: ' . __( 'Text Small', 'cmb2-admin-extension' ), |
|
469 | - 'text_medium' => 'text_medium: ' . __( 'Text Medium', 'cmb2-admin-extension' ), |
|
470 | - 'text_email' => 'text_email: ' . __( 'Email', 'cmb2-admin-extension' ), |
|
471 | - 'text_url' => 'text_url: ' . __( 'URL', 'cmb2-admin-extension' ), |
|
472 | - 'text_money' => 'text_money: ' . __( 'Money', 'cmb2-admin-extension' ), |
|
473 | - 'textarea' => 'textarea: ' . __( 'Text Area', 'cmb2-admin-extension' ), |
|
474 | - 'textarea_small' => 'textarea_small: ' . __( 'Text Area Small', 'cmb2-admin-extension' ), |
|
475 | - 'textarea_code' => 'textarea_code: ' . __( 'Text Area Code', 'cmb2-admin-extension' ), |
|
476 | - 'text_date' => 'text_date: ' . __( 'Date Picker', 'cmb2-admin-extension' ), |
|
477 | - 'text_time' => 'text_time: ' . __( 'Time picker', 'cmb2-admin-extension' ), |
|
478 | - 'select_timezone' => 'select_timezone: ' . __( 'Time zone dropdown', 'cmb2-admin-extension' ), |
|
479 | - 'text_date_timestamp' => 'text_date_timestamp: ' . __( 'Date Picker (UNIX timestamp)', 'cmb2-admin-extension' ), |
|
480 | - 'text_datetime_timestamp' => 'text_datetime_timestamp: ' . __( 'Text Date/Time Picker Combo (UNIX timestamp)', 'cmb2-admin-extension' ), |
|
481 | - 'text_datetime_timestamp_timezone' => 'text_datetime_timestamp_timezone: ' . __( 'Text Date/Time Picker/Time zone Combo (serialized DateTime object)', 'cmb2-admin-extension' ), |
|
482 | - 'color_picker' => 'colorpicker: ' . __( 'Color picker', 'cmb2-admin-extension' ), |
|
483 | - 'radio' => 'radio: ' . __( 'Radio Buttons', 'cmb2-admin-extension' ) . ' *', |
|
484 | - 'radio_inline' => 'radio_inline: ' . __( 'Radio Buttons Inline', 'cmb2-admin-extension' ) . ' *', |
|
485 | - 'taxonomy_radio' => 'taxonomy_radio: ' . __( 'Taxonomy Radio Buttons', 'cmb2-admin-extension' ) . ' *', |
|
486 | - 'taxonomy_radio_inline' => 'taxonomy_radio_inline: ' . __( 'Taxonomy Radio Buttons Inline', 'cmb2-admin-extension' ) . ' *', |
|
487 | - 'select' => 'select: ' . __( 'Select', 'cmb2-admin-extension' ), |
|
488 | - 'taxonomy_select' => 'taxonomy_select: ' . __( 'Taxonomy Select', 'cmb2-admin-extension' ) . ' *', |
|
489 | - 'checkbox' => 'checkbox: ' . __( 'Checkbox', 'cmb2-admin-extension' ) . ' *', |
|
490 | - 'multicheck' => 'multicheck: ' . __( 'Multiple Checkboxes', 'cmb2-admin-extension' ), |
|
491 | - 'multicheck_inline' => 'multicheck_inline: ' . __( 'Multiple Checkboxes Inline', 'cmb2-admin-extension' ), |
|
492 | - 'taxonomy_multicheck' => 'taxonomy_multicheck: ' . __( 'Taxonomy Multiple Checkboxes', 'cmb2-admin-extension' ) . ' *', |
|
493 | - 'taxonomy_multicheck_inline' => 'taxonomy_multicheck_inline: ' . __( 'Taxonomy Multiple Checkboxes Inline', 'cmb2-admin-extension' ) . ' *', |
|
494 | - 'wysiwyg' => 'wysiwyg: ' . __( '(TinyMCE)', 'cmb2-admin-extension' ) . ' *', |
|
495 | - 'file' => 'file: ' . __( 'Image/File upload', 'cmb2-admin-extension' ) . ' *†', |
|
496 | - 'file_list' => 'file_list: ' . __( 'Image/File list upload', 'cmb2-admin-extension' ), |
|
497 | - 'oembed' => 'oembed: ' . __( 'Converts oembed urls (instagram, twitter, youtube, etc. oEmbed in the Codex)', 'cmb2-admin-extension' ), |
|
466 | + 'title' => 'title: ' . __('An arbitrary title field', 'cmb2-admin-extension') . ' *', |
|
467 | + 'text' => 'text: ' . __('Text', 'cmb2-admin-extension'), |
|
468 | + 'text_small' => 'text_small: ' . __('Text Small', 'cmb2-admin-extension'), |
|
469 | + 'text_medium' => 'text_medium: ' . __('Text Medium', 'cmb2-admin-extension'), |
|
470 | + 'text_email' => 'text_email: ' . __('Email', 'cmb2-admin-extension'), |
|
471 | + 'text_url' => 'text_url: ' . __('URL', 'cmb2-admin-extension'), |
|
472 | + 'text_money' => 'text_money: ' . __('Money', 'cmb2-admin-extension'), |
|
473 | + 'textarea' => 'textarea: ' . __('Text Area', 'cmb2-admin-extension'), |
|
474 | + 'textarea_small' => 'textarea_small: ' . __('Text Area Small', 'cmb2-admin-extension'), |
|
475 | + 'textarea_code' => 'textarea_code: ' . __('Text Area Code', 'cmb2-admin-extension'), |
|
476 | + 'text_date' => 'text_date: ' . __('Date Picker', 'cmb2-admin-extension'), |
|
477 | + 'text_time' => 'text_time: ' . __('Time picker', 'cmb2-admin-extension'), |
|
478 | + 'select_timezone' => 'select_timezone: ' . __('Time zone dropdown', 'cmb2-admin-extension'), |
|
479 | + 'text_date_timestamp' => 'text_date_timestamp: ' . __('Date Picker (UNIX timestamp)', 'cmb2-admin-extension'), |
|
480 | + 'text_datetime_timestamp' => 'text_datetime_timestamp: ' . __('Text Date/Time Picker Combo (UNIX timestamp)', 'cmb2-admin-extension'), |
|
481 | + 'text_datetime_timestamp_timezone' => 'text_datetime_timestamp_timezone: ' . __('Text Date/Time Picker/Time zone Combo (serialized DateTime object)', 'cmb2-admin-extension'), |
|
482 | + 'color_picker' => 'colorpicker: ' . __('Color picker', 'cmb2-admin-extension'), |
|
483 | + 'radio' => 'radio: ' . __('Radio Buttons', 'cmb2-admin-extension') . ' *', |
|
484 | + 'radio_inline' => 'radio_inline: ' . __('Radio Buttons Inline', 'cmb2-admin-extension') . ' *', |
|
485 | + 'taxonomy_radio' => 'taxonomy_radio: ' . __('Taxonomy Radio Buttons', 'cmb2-admin-extension') . ' *', |
|
486 | + 'taxonomy_radio_inline' => 'taxonomy_radio_inline: ' . __('Taxonomy Radio Buttons Inline', 'cmb2-admin-extension') . ' *', |
|
487 | + 'select' => 'select: ' . __('Select', 'cmb2-admin-extension'), |
|
488 | + 'taxonomy_select' => 'taxonomy_select: ' . __('Taxonomy Select', 'cmb2-admin-extension') . ' *', |
|
489 | + 'checkbox' => 'checkbox: ' . __('Checkbox', 'cmb2-admin-extension') . ' *', |
|
490 | + 'multicheck' => 'multicheck: ' . __('Multiple Checkboxes', 'cmb2-admin-extension'), |
|
491 | + 'multicheck_inline' => 'multicheck_inline: ' . __('Multiple Checkboxes Inline', 'cmb2-admin-extension'), |
|
492 | + 'taxonomy_multicheck' => 'taxonomy_multicheck: ' . __('Taxonomy Multiple Checkboxes', 'cmb2-admin-extension') . ' *', |
|
493 | + 'taxonomy_multicheck_inline' => 'taxonomy_multicheck_inline: ' . __('Taxonomy Multiple Checkboxes Inline', 'cmb2-admin-extension') . ' *', |
|
494 | + 'wysiwyg' => 'wysiwyg: ' . __('(TinyMCE)', 'cmb2-admin-extension') . ' *', |
|
495 | + 'file' => 'file: ' . __('Image/File upload', 'cmb2-admin-extension') . ' *†', |
|
496 | + 'file_list' => 'file_list: ' . __('Image/File list upload', 'cmb2-admin-extension'), |
|
497 | + 'oembed' => 'oembed: ' . __('Converts oembed urls (instagram, twitter, youtube, etc. oEmbed in the Codex)', 'cmb2-admin-extension'), |
|
498 | 498 | ), |
499 | - ) ); |
|
499 | + )); |
|
500 | 500 | |
501 | - $cmb_group->add_group_field( $group_field_id, array( |
|
502 | - 'name' => __( 'Repeatable', 'cmb2-admin-extension' ), |
|
503 | - 'desc' => __( 'Check this box to make the field repeatable. Field types marked with a "*" are not repeatable.', 'cmb2-admin-extension' ), |
|
501 | + $cmb_group->add_group_field($group_field_id, array( |
|
502 | + 'name' => __('Repeatable', 'cmb2-admin-extension'), |
|
503 | + 'desc' => __('Check this box to make the field repeatable. Field types marked with a "*" are not repeatable.', 'cmb2-admin-extension'), |
|
504 | 504 | 'id' => $prefix . 'repeatable_checkbox', |
505 | 505 | 'type' => 'checkbox', |
506 | - ) ); |
|
506 | + )); |
|
507 | 507 | |
508 | - $cmb_group->add_group_field( $group_field_id, array( |
|
509 | - 'name' => __( 'Protocols', 'cmb2-admin-extension' ), |
|
510 | - 'desc' => __( 'Check the boxes for each allowed protocol. If you are unsure then do nothing and all protocols will be allowed.', 'cmb2-admin-extension' ), |
|
508 | + $cmb_group->add_group_field($group_field_id, array( |
|
509 | + 'name' => __('Protocols', 'cmb2-admin-extension'), |
|
510 | + 'desc' => __('Check the boxes for each allowed protocol. If you are unsure then do nothing and all protocols will be allowed.', 'cmb2-admin-extension'), |
|
511 | 511 | 'id' => $prefix . 'protocols_checkbox', |
512 | 512 | 'type' => 'multicheck_inline', |
513 | 513 | 'options' => array( |
@@ -523,74 +523,74 @@ discard block |
||
523 | 523 | 'feed' => 'feed', |
524 | 524 | 'telnet' => 'telnet', |
525 | 525 | ), |
526 | - ) ); |
|
526 | + )); |
|
527 | 527 | |
528 | - $cmb_group->add_group_field( $group_field_id, array( |
|
529 | - 'name' => __( 'Currency Symbol', 'cmb2-admin-extension' ), |
|
530 | - 'desc' => __( 'Replaces the default "$".', 'cmb2-admin-extension' ), |
|
528 | + $cmb_group->add_group_field($group_field_id, array( |
|
529 | + 'name' => __('Currency Symbol', 'cmb2-admin-extension'), |
|
530 | + 'desc' => __('Replaces the default "$".', 'cmb2-admin-extension'), |
|
531 | 531 | 'id' => $prefix . 'currency_text', |
532 | 532 | 'type' => 'text_small', |
533 | - ) ); |
|
533 | + )); |
|
534 | 534 | |
535 | - $cmb_group->add_group_field( $group_field_id, array( |
|
536 | - 'name' => __( 'Date Format', 'cmb2-admin-extension' ), |
|
537 | - 'desc' => __( 'Default:', 'cmb2-admin-extension' ) . ' "m/d/Y". ' . __( 'See <a target="_blank" href="http://php.net/manual/en/function.date.php">php.net/manual/en/function.date.php</a>.', 'cmb2-admin-extension' ), |
|
535 | + $cmb_group->add_group_field($group_field_id, array( |
|
536 | + 'name' => __('Date Format', 'cmb2-admin-extension'), |
|
537 | + 'desc' => __('Default:', 'cmb2-admin-extension') . ' "m/d/Y". ' . __('See <a target="_blank" href="http://php.net/manual/en/function.date.php">php.net/manual/en/function.date.php</a>.', 'cmb2-admin-extension'), |
|
538 | 538 | 'id' => $prefix . 'date_format', |
539 | 539 | 'type' => 'text_small', |
540 | - ) ); |
|
540 | + )); |
|
541 | 541 | |
542 | - $cmb_group->add_group_field( $group_field_id, array( |
|
543 | - 'name' => __( 'Time Format', 'cmb2-admin-extension' ), |
|
544 | - 'desc' => __( 'Default:', 'cmb2-admin-extension' ) . ' "h:i A". ' . __( 'See <a target="_blank" href="http://php.net/manual/en/function.date.php">php.net/manual/en/function.date.php</a>.', 'cmb2-admin-extension' ), |
|
542 | + $cmb_group->add_group_field($group_field_id, array( |
|
543 | + 'name' => __('Time Format', 'cmb2-admin-extension'), |
|
544 | + 'desc' => __('Default:', 'cmb2-admin-extension') . ' "h:i A". ' . __('See <a target="_blank" href="http://php.net/manual/en/function.date.php">php.net/manual/en/function.date.php</a>.', 'cmb2-admin-extension'), |
|
545 | 545 | 'id' => $prefix . 'time_format', |
546 | 546 | 'type' => 'text_small', |
547 | - ) ); |
|
547 | + )); |
|
548 | 548 | |
549 | - $cmb_group->add_group_field( $group_field_id, array( |
|
550 | - 'name' => __( 'Options', 'cmb2-admin-extension' ), |
|
551 | - 'desc' => __( 'If your field type requires manual options, please add one option per line. Type value then name seprated by a comma.<br>Example:<br>sml,Small<br>med,Medium<br>lrg,Large', 'cmb2-admin-extension' ), |
|
549 | + $cmb_group->add_group_field($group_field_id, array( |
|
550 | + 'name' => __('Options', 'cmb2-admin-extension'), |
|
551 | + 'desc' => __('If your field type requires manual options, please add one option per line. Type value then name seprated by a comma.<br>Example:<br>sml,Small<br>med,Medium<br>lrg,Large', 'cmb2-admin-extension'), |
|
552 | 552 | 'id' => $prefix . 'options_textarea', |
553 | 553 | 'type' => 'textarea_small', |
554 | - ) ); |
|
554 | + )); |
|
555 | 555 | |
556 | 556 | $tax_options = $this->tax_options(); |
557 | - reset( $tax_options ); |
|
558 | - $default_tax_options = key( $tax_options ); |
|
559 | - $cmb_group->add_group_field( $group_field_id, array( |
|
560 | - 'name' => __( 'Taxonomy Options', 'cmb2-admin-extension' ), |
|
557 | + reset($tax_options); |
|
558 | + $default_tax_options = key($tax_options); |
|
559 | + $cmb_group->add_group_field($group_field_id, array( |
|
560 | + 'name' => __('Taxonomy Options', 'cmb2-admin-extension'), |
|
561 | 561 | 'id' => $prefix . 'tax_options_radio_inline', |
562 | 562 | 'type' => 'radio_inline', |
563 | 563 | 'options' => $this->tax_options(), |
564 | 564 | 'default' => $default_tax_options, |
565 | - ) ); |
|
565 | + )); |
|
566 | 566 | |
567 | - $cmb_group->add_group_field( $group_field_id, array( |
|
568 | - 'name' => __( 'No Terms Text', 'cmb2-admin-extension' ), |
|
569 | - 'desc' => __( 'Enter text to change the text that is shown when no terms are found.', 'cmb2-admin-extension' ) . '</br>' . __( 'Default:', 'cmb2-admin-extension' ) . ' "' . __( 'No terms', 'cmb2-admin-extension' ) . '".', |
|
567 | + $cmb_group->add_group_field($group_field_id, array( |
|
568 | + 'name' => __('No Terms Text', 'cmb2-admin-extension'), |
|
569 | + 'desc' => __('Enter text to change the text that is shown when no terms are found.', 'cmb2-admin-extension') . '</br>' . __('Default:', 'cmb2-admin-extension') . ' "' . __('No terms', 'cmb2-admin-extension') . '".', |
|
570 | 570 | 'id' => $prefix . 'no_terms_text', |
571 | 571 | 'type' => 'text_small', |
572 | - ) ); |
|
572 | + )); |
|
573 | 573 | |
574 | - $cmb_group->add_group_field( $group_field_id, array( |
|
575 | - 'name' => __( 'Include a "none" option', 'cmb2-admin-extension' ), |
|
576 | - 'desc' => __( 'Check this box to include a "none" option with this field.', 'cmb2-admin-extension' ), |
|
574 | + $cmb_group->add_group_field($group_field_id, array( |
|
575 | + 'name' => __('Include a "none" option', 'cmb2-admin-extension'), |
|
576 | + 'desc' => __('Check this box to include a "none" option with this field.', 'cmb2-admin-extension'), |
|
577 | 577 | 'id' => $prefix . 'none_checkbox', |
578 | 578 | 'type' => 'checkbox', |
579 | - ) ); |
|
579 | + )); |
|
580 | 580 | |
581 | - $cmb_group->add_group_field( $group_field_id, array( |
|
582 | - 'name' => __( 'Disable select all', 'cmb2-admin-extension' ), |
|
583 | - 'desc' => __( 'Check this box to disable the select all button for this field.', 'cmb2-admin-extension' ), |
|
581 | + $cmb_group->add_group_field($group_field_id, array( |
|
582 | + 'name' => __('Disable select all', 'cmb2-admin-extension'), |
|
583 | + 'desc' => __('Check this box to disable the select all button for this field.', 'cmb2-admin-extension'), |
|
584 | 584 | 'id' => $prefix . 'select_all_checkbox', |
585 | 585 | 'type' => 'checkbox', |
586 | - ) ); |
|
586 | + )); |
|
587 | 587 | |
588 | - $cmb_group->add_group_field( $group_field_id, array( |
|
589 | - 'name' => __( 'Button Text', 'cmb2-admin-extension' ), |
|
590 | - 'desc' => __( 'Enter text to change the upload button text.', 'cmb2-admin-extension' ) . '</br>' . __( 'Default:', 'cmb2-admin-extension' ) . ' "' . __( 'Add or Upload File', 'cmb2-admin-extension' ) . '".', |
|
588 | + $cmb_group->add_group_field($group_field_id, array( |
|
589 | + 'name' => __('Button Text', 'cmb2-admin-extension'), |
|
590 | + 'desc' => __('Enter text to change the upload button text.', 'cmb2-admin-extension') . '</br>' . __('Default:', 'cmb2-admin-extension') . ' "' . __('Add or Upload File', 'cmb2-admin-extension') . '".', |
|
591 | 591 | 'id' => $prefix . 'add_upload_file_text', |
592 | 592 | 'type' => 'text_small', |
593 | - ) ); |
|
593 | + )); |
|
594 | 594 | } |
595 | 595 | } |
596 | 596 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @license GPL-2.0+ |
11 | 11 | */ |
12 | 12 | |
13 | -if ( ! class_exists( 'CMB2_Meta_Box_Settings' ) ) { |
|
13 | +if ( ! class_exists('CMB2_Meta_Box_Settings')) { |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Class CMB2_Meta_Box_Settings. |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function __construct() { |
57 | 57 | |
58 | - add_action( 'admin_init', array( $this, 'register_settings' ) ); |
|
59 | - add_action( 'admin_menu', array( $this, 'add_settings_page' ) ); |
|
60 | - add_action( 'cmb2_init', array( $this, 'init_cmb2_settings_page' ) ); |
|
58 | + add_action('admin_init', array($this, 'register_settings')); |
|
59 | + add_action('admin_menu', array($this, 'add_settings_page')); |
|
60 | + add_action('cmb2_init', array($this, 'init_cmb2_settings_page')); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function add_settings_page() { |
69 | 69 | |
70 | - if ( cmb2ae_metabox()->is_cmb2_allowed() ) { |
|
71 | - $this->settings_page = add_submenu_page( 'edit.php?post_type=meta_box', __( 'CMB2 Settings', 'cmb2-admin-extension' ), __( 'CMB2 Settings', 'cmb2-admin-extension' ), 'edit_posts', $this->settings_key, array( $this, 'settings_page' ) ); |
|
72 | - add_action( "admin_print_styles-{$this->settings_page}", array( 'CMB2_hookup', 'enqueue_cmb_css' ) ); |
|
70 | + if (cmb2ae_metabox()->is_cmb2_allowed()) { |
|
71 | + $this->settings_page = add_submenu_page('edit.php?post_type=meta_box', __('CMB2 Settings', 'cmb2-admin-extension'), __('CMB2 Settings', 'cmb2-admin-extension'), 'edit_posts', $this->settings_key, array($this, 'settings_page')); |
|
72 | + add_action("admin_print_styles-{$this->settings_page}", array('CMB2_hookup', 'enqueue_cmb_css')); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function register_settings() { |
81 | 81 | |
82 | - register_setting( $this->settings_key, $this->settings_key ); |
|
82 | + register_setting($this->settings_key, $this->settings_key); |
|
83 | 83 | |
84 | 84 | } |
85 | 85 | |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | public function settings_page() { |
92 | 92 | |
93 | 93 | ?> |
94 | - <div class="wrap cmb2-options-page <?php echo esc_attr( $this->settings_key ); ?>"> |
|
95 | - <h2><?php echo esc_html__( 'CMB2 Settings', 'cmb2-admin-extension' ); ?></h2> |
|
96 | - <?php cmb2_metabox_form( $this->settings_metabox_id, $this->settings_key, array( 'disable_styles' => false ) ); ?> |
|
94 | + <div class="wrap cmb2-options-page <?php echo esc_attr($this->settings_key); ?>"> |
|
95 | + <h2><?php echo esc_html__('CMB2 Settings', 'cmb2-admin-extension'); ?></h2> |
|
96 | + <?php cmb2_metabox_form($this->settings_metabox_id, $this->settings_key, array('disable_styles' => false)); ?> |
|
97 | 97 | </div> |
98 | 98 | <?php |
99 | 99 | |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | |
109 | 109 | $users = get_users(); |
110 | 110 | $user_options = array(); |
111 | - foreach ( $users as $user ) { |
|
111 | + foreach ($users as $user) { |
|
112 | 112 | |
113 | - if ( user_can( $user, 'update_plugins' ) || user_can( $user, 'install_plugins' ) || user_can( $user, 'delete_plugins' ) || user_can( $user, 'edit_theme_options' ) ) { |
|
114 | - $user_options[ $user->ID ] = $user->display_name; |
|
113 | + if (user_can($user, 'update_plugins') || user_can($user, 'install_plugins') || user_can($user, 'delete_plugins') || user_can($user, 'edit_theme_options')) { |
|
114 | + $user_options[$user->ID] = $user->display_name; |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
@@ -128,23 +128,23 @@ discard block |
||
128 | 128 | |
129 | 129 | $prefix = $this->prefix; |
130 | 130 | |
131 | - $cmb_settings = new_cmb2_box( array( |
|
131 | + $cmb_settings = new_cmb2_box(array( |
|
132 | 132 | 'id' => $this->settings_metabox_id, |
133 | 133 | 'hookup' => false, |
134 | 134 | 'show_on' => array( |
135 | 135 | 'key' => 'options-page', |
136 | - 'value' => array( $this->settings_key ), |
|
136 | + 'value' => array($this->settings_key), |
|
137 | 137 | ), |
138 | - ) ); |
|
138 | + )); |
|
139 | 139 | |
140 | - $cmb_settings->add_field( array( |
|
141 | - 'name' => __( 'Users', 'cmb2-admin-extension' ), |
|
142 | - 'desc' => __( 'Check the users to grant access to this plugin and the CMB2 plugin. Leave unchecked to grant access to all users.', 'cmb2-admin-extension' ), |
|
140 | + $cmb_settings->add_field(array( |
|
141 | + 'name' => __('Users', 'cmb2-admin-extension'), |
|
142 | + 'desc' => __('Check the users to grant access to this plugin and the CMB2 plugin. Leave unchecked to grant access to all users.', 'cmb2-admin-extension'), |
|
143 | 143 | 'id' => $prefix . 'user_multicheckbox', |
144 | 144 | 'type' => 'multicheck', |
145 | 145 | 'options' => $this->user_options(), |
146 | 146 | 'inline' => true, |
147 | - ) ); |
|
147 | + )); |
|
148 | 148 | |
149 | 149 | } |
150 | 150 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | /** |
43 | 43 | * Silence is golden; exit if accessed directly. |
44 | 44 | */ |
45 | -if ( ! defined( 'ABSPATH' ) ) { |
|
45 | +if ( ! defined('ABSPATH')) { |
|
46 | 46 | exit; |
47 | 47 | } |
48 | 48 | |
@@ -50,16 +50,16 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * Define plugin constant. |
52 | 52 | */ |
53 | -if ( ! defined( 'CMB2AE_CMB2_PLUGIN_FILE' ) ) { |
|
54 | - define( 'CMB2AE_CMB2_PLUGIN_FILE', 'cmb2/init.php' ); |
|
53 | +if ( ! defined('CMB2AE_CMB2_PLUGIN_FILE')) { |
|
54 | + define('CMB2AE_CMB2_PLUGIN_FILE', 'cmb2/init.php'); |
|
55 | 55 | } |
56 | 56 | |
57 | -if ( ! defined( 'CMB2AE_URI' ) ) { |
|
58 | - define( 'CMB2AE_URI', plugins_url( '', __FILE__ ) ); |
|
57 | +if ( ! defined('CMB2AE_URI')) { |
|
58 | + define('CMB2AE_URI', plugins_url('', __FILE__)); |
|
59 | 59 | } |
60 | 60 | |
61 | -if ( ! defined( 'CMB2AE_PATH' ) ) { |
|
62 | - define( 'CMB2AE_PATH', plugin_dir_path( __FILE__ ) ); |
|
61 | +if ( ! defined('CMB2AE_PATH')) { |
|
62 | + define('CMB2AE_PATH', plugin_dir_path(__FILE__)); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $this->check_for_cmb2(); |
93 | 93 | |
94 | - add_action( 'init', array( $this, 'load_textdomain' ), 9 ); |
|
94 | + add_action('init', array($this, 'load_textdomain'), 9); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public static function get_instance() { |
103 | 103 | // If the single instance hasn't been set, set it now. |
104 | - if ( null === self::$instance ) { |
|
104 | + if (null === self::$instance) { |
|
105 | 105 | self::$instance = new self(); |
106 | 106 | } |
107 | 107 | |
@@ -115,19 +115,19 @@ discard block |
||
115 | 115 | */ |
116 | 116 | private function check_for_cmb2() { |
117 | 117 | |
118 | - if ( defined( 'CMB2_LOADED' ) && CMB2_LOADED !== false ) { |
|
118 | + if (defined('CMB2_LOADED') && CMB2_LOADED !== false) { |
|
119 | 119 | |
120 | - require_once dirname( __FILE__ ) . '/includes/class-meta-box.php'; |
|
121 | - require_once dirname( __FILE__ ) . '/includes/class-meta-box-post-type.php'; |
|
122 | - require_once dirname( __FILE__ ) . '/includes/class-meta-box-settings.php'; |
|
120 | + require_once dirname(__FILE__) . '/includes/class-meta-box.php'; |
|
121 | + require_once dirname(__FILE__) . '/includes/class-meta-box-post-type.php'; |
|
122 | + require_once dirname(__FILE__) . '/includes/class-meta-box-settings.php'; |
|
123 | 123 | cmb2ae_metabox(); |
124 | 124 | return; |
125 | - } elseif ( file_exists( WP_PLUGIN_DIR . '/' . CMB2AE_CMB2_PLUGIN_FILE ) ) { |
|
125 | + } elseif (file_exists(WP_PLUGIN_DIR . '/' . CMB2AE_CMB2_PLUGIN_FILE)) { |
|
126 | 126 | |
127 | - add_action( 'admin_notices', array( $this, 'cmb2_not_activated' ) ); |
|
127 | + add_action('admin_notices', array($this, 'cmb2_not_activated')); |
|
128 | 128 | return; |
129 | 129 | } |
130 | - add_action( 'admin_notices', array( $this, 'missing_cmb2' ) ); |
|
130 | + add_action('admin_notices', array($this, 'missing_cmb2')); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -137,20 +137,20 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public function load_textdomain() { |
139 | 139 | |
140 | - $lang_path = plugin_basename( dirname( __FILE__ ) ) . '/languages'; |
|
141 | - $loaded = load_muplugin_textdomain( 'cmb2-admin-extension', $lang_path ); |
|
142 | - if ( strpos( __FILE__, basename( WPMU_PLUGIN_DIR ) ) === false ) { |
|
143 | - $loaded = load_plugin_textdomain( 'cmb2-admin-extension', false, $lang_path ); |
|
140 | + $lang_path = plugin_basename(dirname(__FILE__)) . '/languages'; |
|
141 | + $loaded = load_muplugin_textdomain('cmb2-admin-extension', $lang_path); |
|
142 | + if (strpos(__FILE__, basename(WPMU_PLUGIN_DIR)) === false) { |
|
143 | + $loaded = load_plugin_textdomain('cmb2-admin-extension', false, $lang_path); |
|
144 | 144 | } |
145 | 145 | |
146 | - if ( ! $loaded ) { |
|
147 | - $loaded = load_theme_textdomain( 'cmb2-admin-extension', get_stylesheet_directory() . '/languages' ); |
|
146 | + if ( ! $loaded) { |
|
147 | + $loaded = load_theme_textdomain('cmb2-admin-extension', get_stylesheet_directory() . '/languages'); |
|
148 | 148 | } |
149 | 149 | |
150 | - if ( ! $loaded ) { |
|
151 | - $locale = apply_filters( 'plugin_locale', get_locale(), 'cmb2-admin-extension' ); |
|
152 | - $mofile = dirname( __FILE__ ) . '/languages/cmb2-admin-extension-' . $locale . '.mo'; |
|
153 | - load_textdomain( 'cmb2-admin-extension', $mofile ); |
|
150 | + if ( ! $loaded) { |
|
151 | + $locale = apply_filters('plugin_locale', get_locale(), 'cmb2-admin-extension'); |
|
152 | + $mofile = dirname(__FILE__) . '/languages/cmb2-admin-extension-' . $locale . '.mo'; |
|
153 | + load_textdomain('cmb2-admin-extension', $mofile); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | <?php |
168 | 168 | printf( |
169 | 169 | /* translators: 1: link opener; 2: link closer. */ |
170 | - esc_html__( 'CMB2 Admin Extension depends on the last version of %1$s the CMB2 plugin %2$s to work!', 'cmb2-admin-extension' ), |
|
170 | + esc_html__('CMB2 Admin Extension depends on the last version of %1$s the CMB2 plugin %2$s to work!', 'cmb2-admin-extension'), |
|
171 | 171 | '<a href="https://wordpress.org/plugins/cmb2/">', |
172 | 172 | '</a>' |
173 | 173 | ); |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | <?php |
192 | 192 | printf( |
193 | 193 | /* translators: 1: link opener; 2: link closer. */ |
194 | - esc_html__( 'The CMB2 plugin is installed but has not been activated. Please %1$s activate %2$s it to use the CMB2 Admin Extension', 'cmb2-admin-extension' ), |
|
195 | - '<a href="' . esc_url( admin_url( 'plugins.php' ) ) . '">', |
|
194 | + esc_html__('The CMB2 plugin is installed but has not been activated. Please %1$s activate %2$s it to use the CMB2 Admin Extension', 'cmb2-admin-extension'), |
|
195 | + '<a href="' . esc_url(admin_url('plugins.php')) . '">', |
|
196 | 196 | '</a>' |
197 | 197 | ); |
198 | 198 | ?> |
@@ -203,9 +203,9 @@ discard block |
||
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
206 | -add_action( 'plugins_loaded', array( 'CMB2_Admin_Extension_Class', 'get_instance' ), 20 ); |
|
206 | +add_action('plugins_loaded', array('CMB2_Admin_Extension_Class', 'get_instance'), 20); |
|
207 | 207 | |
208 | -if ( ! function_exists( 'cmbf' ) ) { |
|
208 | +if ( ! function_exists('cmbf')) { |
|
209 | 209 | |
210 | 210 | /** |
211 | 211 | * This function needs documentation. |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | * @param int $id Post ID. |
216 | 216 | * @param string $field The meta key to retrieve. |
217 | 217 | */ |
218 | - function cmbf( $id, $field ) { |
|
218 | + function cmbf($id, $field) { |
|
219 | 219 | |
220 | - return get_post_meta( $id, $field, true ); |
|
220 | + return get_post_meta($id, $field, true); |
|
221 | 221 | } |
222 | 222 | } |