@@ -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 ( null === self::$instance ) { |
|
| 69 | + if (null === self::$instance) { |
|
| 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( 'manage_options' ) ) { |
|
| 86 | + if (empty($cmb2_settings) || current_user_can('manage_options')) { |
|
| 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 ( 'meta_box' === $screen->post_type ) { |
|
| 124 | + if ('meta_box' === $screen->post_type) { |
|
| 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( false !== $this->field['_cmb2_field_type_select'], $arg_value[0] ) && isset( $this->field[ $arg_value[2] ] ) && '' !== $this->field[ $arg_value[2] ] ) { |
|
| 219 | + if (strpos(false !== $this->field['_cmb2_field_type_select'], $arg_value[0]) && 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_type === $field['_cmb2_field_type_select'] && ( ! empty( $field[ $field_key ] ) && '' !== $field[ $field_key ] ) ); |
|
| 260 | + return ($field_type === $field['_cmb2_field_type_select'] && ( ! empty($field[$field_key]) && '' !== $field[$field_key])); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
@@ -268,7 +268,7 @@ 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 | 273 | $field = wp_parse_args( |
| 274 | 274 | $field, |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | ); |
| 284 | 284 | |
| 285 | 285 | $this->field = $field; |
| 286 | - $field_id = '_' . strtolower( str_replace( ' ', '_', $field['_cmb2_name_text'] ) ); |
|
| 286 | + $field_id = '_' . strtolower(str_replace(' ', '_', $field['_cmb2_name_text'])); |
|
| 287 | 287 | |
| 288 | 288 | $this->field_args = array( |
| 289 | 289 | 'name' => $field['_cmb2_name_text'], |
@@ -293,41 +293,41 @@ discard block |
||
| 293 | 293 | ); |
| 294 | 294 | |
| 295 | 295 | $field_options = $field['_cmb2_options_textarea']; |
| 296 | - if ( $field_options ) { |
|
| 297 | - $this->add_option_arg( $field_options ); |
|
| 296 | + if ($field_options) { |
|
| 297 | + $this->add_option_arg($field_options); |
|
| 298 | 298 | } |
| 299 | 299 | $should_add_strpos = array( |
| 300 | - array( 'tax', 'taxonomy', '_cmb2_tax_options_radio_inline' ), |
|
| 301 | - array( 'tax', array( 'options', 'no_terms_text' ), '_cmb2_no_terms_text' ), |
|
| 302 | - array( 'multicheck', 'select_all_button', '_cmb2_select_all_checkbox' ), |
|
| 300 | + array('tax', 'taxonomy', '_cmb2_tax_options_radio_inline'), |
|
| 301 | + array('tax', array('options', 'no_terms_text'), '_cmb2_no_terms_text'), |
|
| 302 | + array('multicheck', 'select_all_button', '_cmb2_select_all_checkbox'), |
|
| 303 | 303 | ); |
| 304 | - foreach ( $should_add_strpos as $arg_value ) { |
|
| 305 | - $this->add_strpos_arg( $arg_value ); |
|
| 304 | + foreach ($should_add_strpos as $arg_value) { |
|
| 305 | + $this->add_strpos_arg($arg_value); |
|
| 306 | 306 | } |
| 307 | - if ( 'on' === $field['_cmb2_repeatable_checkbox'] && $this->is_repeatable( $field['_cmb2_field_type_select'] ) ) { |
|
| 307 | + if ('on' === $field['_cmb2_repeatable_checkbox'] && $this->is_repeatable($field['_cmb2_field_type_select'])) { |
|
| 308 | 308 | $this->field_args['repeatable'] = true; |
| 309 | 309 | } |
| 310 | - if ( 'on' === $field['_cmb2_none_checkbox'] && $this->has_options( $field['_cmb2_field_type_select'] ) ) { |
|
| 310 | + if ('on' === $field['_cmb2_none_checkbox'] && $this->has_options($field['_cmb2_field_type_select'])) { |
|
| 311 | 311 | $this->field_args['show_option_none'] = true; |
| 312 | 312 | } |
| 313 | 313 | $should_add = array( |
| 314 | - 'text_url' => array( 'protocols', '_cmb2_protocols_checkbox' ), |
|
| 315 | - 'text_money' => array( 'before_field', '_cmb2_currency_text' ), |
|
| 316 | - 'text_time' => array( 'time_format', '_cmb2_time_format' ), |
|
| 317 | - 'text_datetime_timestamp_timezone' => array( 'time_format', '_cmb2_time_format', 'timezone_meta_key', '_cmb2_time_zone_key_select' ), |
|
| 318 | - 'text_datetime_timestamp' => array( 'time_format', '_cmb2_time_format' ), |
|
| 319 | - 'text_date' => array( 'date_format', '_cmb2_date_format' ), |
|
| 320 | - 'text_date_timestamp' => array( 'date_format', '_cmb2_date_format' ), |
|
| 321 | - 'select_timezone' => array( 'timezone_meta_key', '_cmb2_time_zone_key_select' ), |
|
| 314 | + 'text_url' => array('protocols', '_cmb2_protocols_checkbox'), |
|
| 315 | + 'text_money' => array('before_field', '_cmb2_currency_text'), |
|
| 316 | + 'text_time' => array('time_format', '_cmb2_time_format'), |
|
| 317 | + 'text_datetime_timestamp_timezone' => array('time_format', '_cmb2_time_format', 'timezone_meta_key', '_cmb2_time_zone_key_select'), |
|
| 318 | + 'text_datetime_timestamp' => array('time_format', '_cmb2_time_format'), |
|
| 319 | + 'text_date' => array('date_format', '_cmb2_date_format'), |
|
| 320 | + 'text_date_timestamp' => array('date_format', '_cmb2_date_format'), |
|
| 321 | + 'select_timezone' => array('timezone_meta_key', '_cmb2_time_zone_key_select'), |
|
| 322 | 322 | ); |
| 323 | - foreach ( $should_add as $arg => $value ) { |
|
| 324 | - $this->add_arg( $arg, $value ); |
|
| 323 | + foreach ($should_add as $arg => $value) { |
|
| 324 | + $this->add_arg($arg, $value); |
|
| 325 | 325 | } |
| 326 | - if ( $group_field_id ) { |
|
| 327 | - $metabox->add_group_field( $group_field_id, $this->field_args ); |
|
| 326 | + if ($group_field_id) { |
|
| 327 | + $metabox->add_group_field($group_field_id, $this->field_args); |
|
| 328 | 328 | return; |
| 329 | 329 | } |
| 330 | - $metabox->add_field( $this->field_args ); |
|
| 330 | + $metabox->add_field($this->field_args); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | /** |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | * @since 0.2.0 |
| 337 | 337 | * @param string $meta Sting value of checkbox on. |
| 338 | 338 | */ |
| 339 | - public function string_to_bool( $meta ) { |
|
| 339 | + public function string_to_bool($meta) { |
|
| 340 | 340 | |
| 341 | 341 | return 'on' === $meta ? true : false; |
| 342 | 342 | } |
@@ -347,25 +347,25 @@ discard block |
||
| 347 | 347 | * @since 0.2.0 |
| 348 | 348 | * @param object $user_meta_box Post object. |
| 349 | 349 | */ |
| 350 | - public function get_meta_data( $user_meta_box ) { |
|
| 350 | + public function get_meta_data($user_meta_box) { |
|
| 351 | 351 | |
| 352 | 352 | $prefix = $this->prefix; |
| 353 | 353 | $metabox_id = $user_meta_box->ID; |
| 354 | 354 | |
| 355 | - $meta_data['title'] = get_the_title( $metabox_id ); |
|
| 356 | - $meta_data['id'] = str_replace( '-', '_', $user_meta_box->post_name ); |
|
| 357 | - $meta_data['post_type'] = cmbf( $metabox_id, $prefix . 'post_type_multicheckbox' ); |
|
| 358 | - $meta_data['post_id_text'] = cmbf( $metabox_id, $prefix . 'post_id_text' ); |
|
| 359 | - $meta_data['context'] = cmbf( $metabox_id, $prefix . 'context_radio' ); |
|
| 360 | - $meta_data['priority'] = cmbf( $metabox_id, $prefix . 'priority_radio' ); |
|
| 361 | - $meta_data['show_names'] = $this->string_to_bool( cmbf( $metabox_id, $prefix . 'show_names' ) ); |
|
| 362 | - $meta_data['disable_styles'] = $this->string_to_bool( cmbf( $metabox_id, $prefix . 'disable_styles' ) ); |
|
| 363 | - $meta_data['closed'] = $this->string_to_bool( cmbf( $metabox_id, $prefix . 'closed' ) ); |
|
| 364 | - $meta_data['repeatable'] = $this->string_to_bool( cmbf( $metabox_id, $prefix . 'repeatable_group' ) ); |
|
| 365 | - $meta_data['group_desc'] = cmbf( $metabox_id, $prefix . 'group_description' ); |
|
| 366 | - $entry_name = cmbf( $metabox_id, $prefix . 'entry_name' ); |
|
| 355 | + $meta_data['title'] = get_the_title($metabox_id); |
|
| 356 | + $meta_data['id'] = str_replace('-', '_', $user_meta_box->post_name); |
|
| 357 | + $meta_data['post_type'] = cmbf($metabox_id, $prefix . 'post_type_multicheckbox'); |
|
| 358 | + $meta_data['post_id_text'] = cmbf($metabox_id, $prefix . 'post_id_text'); |
|
| 359 | + $meta_data['context'] = cmbf($metabox_id, $prefix . 'context_radio'); |
|
| 360 | + $meta_data['priority'] = cmbf($metabox_id, $prefix . 'priority_radio'); |
|
| 361 | + $meta_data['show_names'] = $this->string_to_bool(cmbf($metabox_id, $prefix . 'show_names')); |
|
| 362 | + $meta_data['disable_styles'] = $this->string_to_bool(cmbf($metabox_id, $prefix . 'disable_styles')); |
|
| 363 | + $meta_data['closed'] = $this->string_to_bool(cmbf($metabox_id, $prefix . 'closed')); |
|
| 364 | + $meta_data['repeatable'] = $this->string_to_bool(cmbf($metabox_id, $prefix . 'repeatable_group')); |
|
| 365 | + $meta_data['group_desc'] = cmbf($metabox_id, $prefix . 'group_description'); |
|
| 366 | + $entry_name = cmbf($metabox_id, $prefix . 'entry_name'); |
|
| 367 | 367 | $meta_data['entry_name'] = $entry_name ? $entry_name : 'Entry'; |
| 368 | - $meta_data['fields'] = cmbf( $metabox_id, $prefix . 'custom_field' ); |
|
| 368 | + $meta_data['fields'] = cmbf($metabox_id, $prefix . 'custom_field'); |
|
| 369 | 369 | |
| 370 | 370 | return $meta_data; |
| 371 | 371 | } |
@@ -384,11 +384,11 @@ discard block |
||
| 384 | 384 | 'suppress_filters' => false, |
| 385 | 385 | ); |
| 386 | 386 | |
| 387 | - $user_meta_boxes = new WP_Query( $args ); |
|
| 387 | + $user_meta_boxes = new WP_Query($args); |
|
| 388 | 388 | |
| 389 | - foreach ( $user_meta_boxes->posts as $user_meta_box ) { |
|
| 389 | + foreach ($user_meta_boxes->posts as $user_meta_box) { |
|
| 390 | 390 | |
| 391 | - $meta_data = $this->get_meta_data( $user_meta_box ); |
|
| 391 | + $meta_data = $this->get_meta_data($user_meta_box); |
|
| 392 | 392 | /** |
| 393 | 393 | * Initiate the metabox. |
| 394 | 394 | */ |
@@ -402,17 +402,17 @@ discard block |
||
| 402 | 402 | 'cmb_styles' => $meta_data['disable_styles'], |
| 403 | 403 | 'closed' => $meta_data['closed'], |
| 404 | 404 | ); |
| 405 | - if ( '' !== $meta_data['post_id_text'] ) { |
|
| 405 | + if ('' !== $meta_data['post_id_text']) { |
|
| 406 | 406 | |
| 407 | 407 | $new_cmb2_args['show_on'] = array( |
| 408 | 408 | 'key' => 'id', |
| 409 | - 'value' => explode( ',', $meta_data['post_id_text'] ), |
|
| 409 | + 'value' => explode(',', $meta_data['post_id_text']), |
|
| 410 | 410 | ); |
| 411 | 411 | } |
| 412 | - ${ 'cmb_' . $meta_data['id'] } = new_cmb2_box( $new_cmb2_args ); |
|
| 412 | + ${ 'cmb_' . $meta_data['id'] } = new_cmb2_box($new_cmb2_args); |
|
| 413 | 413 | $meta_box = ${ 'cmb_' . $meta_data['id'] }; |
| 414 | 414 | $group_field_id = false; |
| 415 | - if ( $meta_data['repeatable'] ) { |
|
| 415 | + if ($meta_data['repeatable']) { |
|
| 416 | 416 | |
| 417 | 417 | $group_field_id = ${ 'cmb_' . $meta_data['id'] }->add_field( |
| 418 | 418 | array( |
@@ -420,17 +420,17 @@ discard block |
||
| 420 | 420 | 'type' => 'group', |
| 421 | 421 | 'description' => $meta_data['group_desc'], |
| 422 | 422 | 'options' => array( |
| 423 | - 'group_title' => $meta_data['entry_name'] . __( ' {#}', 'cmb2' ), |
|
| 424 | - 'add_button' => __( 'Add Another ', 'cmb2' ) . $meta_data['entry_name'], |
|
| 425 | - 'remove_button' => __( 'Remove ', 'cmb2' ) . $meta_data['entry_name'], |
|
| 423 | + 'group_title' => $meta_data['entry_name'] . __(' {#}', 'cmb2'), |
|
| 424 | + 'add_button' => __('Add Another ', 'cmb2') . $meta_data['entry_name'], |
|
| 425 | + 'remove_button' => __('Remove ', 'cmb2') . $meta_data['entry_name'], |
|
| 426 | 426 | 'sortable' => true, |
| 427 | 427 | ), |
| 428 | 428 | ) |
| 429 | 429 | ); |
| 430 | 430 | } |
| 431 | - foreach ( $meta_data['fields'] as $field ) { |
|
| 431 | + foreach ($meta_data['fields'] as $field) { |
|
| 432 | 432 | |
| 433 | - $this->add_field( $field, $meta_box, $group_field_id ); |
|
| 433 | + $this->add_field($field, $meta_box, $group_field_id); |
|
| 434 | 434 | } |
| 435 | 435 | } |
| 436 | 436 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * @return CMB2_Meta_Box The main instance of the CMB2_Meta_Box class. |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | -if ( ! function_exists( 'cmb2ae_metabox' ) ) { |
|
| 26 | +if ( ! function_exists('cmb2ae_metabox')) { |
|
| 27 | 27 | /** |
| 28 | 28 | * Main instance of CMB2_Meta_Box. |
| 29 | 29 | * |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | -if ( ! function_exists( 'cmbf' ) ) { |
|
| 38 | +if ( ! function_exists('cmbf')) { |
|
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * This function needs documentation. |
@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | * @param int $id Post ID. |
| 46 | 46 | * @param string $field The meta key to retrieve. |
| 47 | 47 | */ |
| 48 | - function cmbf( $id, $field ) { |
|
| 48 | + function cmbf($id, $field) { |
|
| 49 | 49 | |
| 50 | - return get_post_meta( $id, $field, true ); |
|
| 50 | + return get_post_meta($id, $field, true); |
|
| 51 | 51 | } |
| 52 | 52 | } |
@@ -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,30 +57,30 @@ 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 | 'hierarchical' => false, |
| 82 | 82 | 'rewrite' => true, |
| 83 | - 'supports' => array( 'title' ), |
|
| 83 | + 'supports' => array('title'), |
|
| 84 | 84 | 'public' => true, |
| 85 | 85 | 'menu_position' => 100, |
| 86 | 86 | 'menu_icon' => 'dashicons-feedback', |
@@ -96,13 +96,13 @@ discard block |
||
| 96 | 96 | $args['show_ui'] = false; |
| 97 | 97 | $args['show_in_menu'] = false; |
| 98 | 98 | |
| 99 | - if ( $this->is_cmb2_allowed() ) { |
|
| 99 | + if ($this->is_cmb2_allowed()) { |
|
| 100 | 100 | |
| 101 | 101 | $args['show_ui'] = true; |
| 102 | 102 | $args['show_in_menu'] = true; |
| 103 | 103 | |
| 104 | 104 | } |
| 105 | - register_post_type( 'meta_box', $args ); |
|
| 105 | + register_post_type('meta_box', $args); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | public function remove_meta_box_slugdiv() { |
| 114 | 114 | |
| 115 | - remove_meta_box( 'slugdiv', 'page', 'normal' ); |
|
| 115 | + remove_meta_box('slugdiv', 'page', 'normal'); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | global $post; |
| 126 | 126 | |
| 127 | - if ( isset( $post->post_type ) && 'meta_box' === $post->post_type ) { |
|
| 127 | + if (isset($post->post_type) && 'meta_box' === $post->post_type) { |
|
| 128 | 128 | |
| 129 | 129 | echo '<style type="text/css"> #edit-slug-box, #minor-publishing { display: none; }</style>'; |
| 130 | 130 | |
@@ -139,17 +139,17 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | private function is_cmb2_allowed() { |
| 141 | 141 | |
| 142 | - $cmb2_settings = get_option( '_cmb2_settings' ); |
|
| 142 | + $cmb2_settings = get_option('_cmb2_settings'); |
|
| 143 | 143 | |
| 144 | - if ( empty( $cmb2_settings ) ) { |
|
| 144 | + if (empty($cmb2_settings)) { |
|
| 145 | 145 | // No settings saved. |
| 146 | 146 | return true; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | $current_user = wp_get_current_user(); |
| 150 | - $allowed_users = isset( $cmb2_settings['_cmb2_user_multicheckbox'] ) ? $cmb2_settings['_cmb2_user_multicheckbox'] : array(); |
|
| 150 | + $allowed_users = isset($cmb2_settings['_cmb2_user_multicheckbox']) ? $cmb2_settings['_cmb2_user_multicheckbox'] : array(); |
|
| 151 | 151 | |
| 152 | - if ( empty( $allowed_users ) || in_array( $current_user->ID, $allowed_users, true ) ) { |
|
| 152 | + if (empty($allowed_users) || in_array($current_user->ID, $allowed_users, true)) { |
|
| 153 | 153 | |
| 154 | 154 | return true; |
| 155 | 155 | |
@@ -167,10 +167,10 @@ discard block |
||
| 167 | 167 | * @param array $field_classes CSS Classes. |
| 168 | 168 | * @param string $classes CSS Classes to add. |
| 169 | 169 | */ |
| 170 | - public function conditionally_add_class( $field_id, $field_classes, $classes ) { |
|
| 170 | + public function conditionally_add_class($field_id, $field_classes, $classes) { |
|
| 171 | 171 | |
| 172 | - foreach ( $field_classes as $field => $class ) { |
|
| 173 | - if ( strpos( $field_id, $field ) !== false ) { |
|
| 172 | + foreach ($field_classes as $field => $class) { |
|
| 173 | + if (strpos($field_id, $field) !== false) { |
|
| 174 | 174 | return $classes . ' ' . $class; |
| 175 | 175 | } |
| 176 | 176 | } |
@@ -186,10 +186,10 @@ discard block |
||
| 186 | 186 | * @param array $classes CSS Classes. |
| 187 | 187 | * @param object $field CMB2 Field object. |
| 188 | 188 | */ |
| 189 | - public function show_hide_classes( $classes, $field ) { |
|
| 189 | + public function show_hide_classes($classes, $field) { |
|
| 190 | 190 | |
| 191 | 191 | $screen = get_current_screen(); |
| 192 | - if ( 'meta_box' === $screen->post_type ) { |
|
| 192 | + if ('meta_box' === $screen->post_type) { |
|
| 193 | 193 | $field_classes = array( |
| 194 | 194 | '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', |
| 195 | 195 | 'protocols_checkbox' => 'cmb_hide_field text_url', |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | 'default_value_text' => 'default_value', |
| 207 | 207 | ); |
| 208 | 208 | |
| 209 | - $classes = $this->conditionally_add_class( $field->args['_id'], $field_classes, $classes ); |
|
| 209 | + $classes = $this->conditionally_add_class($field->args['_id'], $field_classes, $classes); |
|
| 210 | 210 | } |
| 211 | 211 | return $classes; |
| 212 | 212 | } |
@@ -218,11 +218,11 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | public function tax_options() { |
| 220 | 220 | |
| 221 | - $taxonomies = get_taxonomies( array( 'public' => true ), 'objects' ); |
|
| 221 | + $taxonomies = get_taxonomies(array('public' => true), 'objects'); |
|
| 222 | 222 | $tax_options = array(); |
| 223 | - foreach ( $taxonomies as $taxonomy ) { |
|
| 223 | + foreach ($taxonomies as $taxonomy) { |
|
| 224 | 224 | |
| 225 | - $tax_options[ $taxonomy->name ] = $taxonomy->labels->name; |
|
| 225 | + $tax_options[$taxonomy->name] = $taxonomy->labels->name; |
|
| 226 | 226 | |
| 227 | 227 | } |
| 228 | 228 | return $tax_options; |
@@ -236,12 +236,12 @@ discard block |
||
| 236 | 236 | public function init_meta_box_settings() { |
| 237 | 237 | |
| 238 | 238 | $prefix = $this->prefix; |
| 239 | - $post_type_objects = get_post_types( '', 'object' ); |
|
| 239 | + $post_type_objects = get_post_types('', 'object'); |
|
| 240 | 240 | $post_types = array(); |
| 241 | 241 | |
| 242 | - foreach ( $post_type_objects as $post_type_object ) { |
|
| 243 | - if ( true === $post_type_object->show_ui && 'meta_box' !== $post_type_object->name ) { |
|
| 244 | - $post_types[ $post_type_object->name ] = $post_type_object->label; |
|
| 242 | + foreach ($post_type_objects as $post_type_object) { |
|
| 243 | + if (true === $post_type_object->show_ui && 'meta_box' !== $post_type_object->name) { |
|
| 244 | + $post_types[$post_type_object->name] = $post_type_object->label; |
|
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | |
@@ -251,8 +251,8 @@ discard block |
||
| 251 | 251 | $cmb = new_cmb2_box( |
| 252 | 252 | array( |
| 253 | 253 | 'id' => 'metabox_settings', |
| 254 | - 'title' => __( 'Metabox Settings', 'cmb2-admin-extension' ), |
|
| 255 | - 'object_types' => array( 'meta_box' ), // Post type. |
|
| 254 | + 'title' => __('Metabox Settings', 'cmb2-admin-extension'), |
|
| 255 | + 'object_types' => array('meta_box'), // Post type. |
|
| 256 | 256 | 'context' => 'side', |
| 257 | 257 | 'priority' => 'low', |
| 258 | 258 | 'show_names' => true, |
@@ -261,8 +261,8 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | $cmb->add_field( |
| 263 | 263 | array( |
| 264 | - 'name' => __( 'Post Types', 'cmb2-admin-extension' ), |
|
| 265 | - 'desc' => __( 'Check the post types that you want to add this meta box to.', 'cmb2-admin-extension' ), |
|
| 264 | + 'name' => __('Post Types', 'cmb2-admin-extension'), |
|
| 265 | + 'desc' => __('Check the post types that you want to add this meta box to.', 'cmb2-admin-extension'), |
|
| 266 | 266 | 'id' => $prefix . 'post_type_multicheckbox', |
| 267 | 267 | 'type' => 'multicheck', |
| 268 | 268 | 'options' => $post_types, |
@@ -272,8 +272,8 @@ discard block |
||
| 272 | 272 | |
| 273 | 273 | $cmb->add_field( |
| 274 | 274 | array( |
| 275 | - 'name' => __( 'Post IDs', 'cmb2-admin-extension' ), |
|
| 276 | - '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 | + 'name' => __('Post IDs', 'cmb2-admin-extension'), |
|
| 276 | + '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'), |
|
| 277 | 277 | 'id' => $prefix . 'post_id_text', |
| 278 | 278 | 'type' => 'text', |
| 279 | 279 | 'inline' => true, |
@@ -282,16 +282,16 @@ discard block |
||
| 282 | 282 | |
| 283 | 283 | $cmb->add_field( |
| 284 | 284 | array( |
| 285 | - 'name' => __( 'Priority', 'cmb2-admin-extension' ), |
|
| 286 | - 'desc' => __( 'This is to control what order your meta box appears in.', 'cmb2-admin-extension' ), |
|
| 285 | + 'name' => __('Priority', 'cmb2-admin-extension'), |
|
| 286 | + 'desc' => __('This is to control what order your meta box appears in.', 'cmb2-admin-extension'), |
|
| 287 | 287 | 'id' => $prefix . 'priority_radio', |
| 288 | 288 | 'type' => 'radio', |
| 289 | 289 | 'default' => 'high', |
| 290 | 290 | 'options' => array( |
| 291 | - 'high' => __( 'High', 'cmb2-admin-extension' ), |
|
| 292 | - 'core' => __( 'Core', 'cmb2-admin-extension' ), |
|
| 293 | - 'default' => __( 'Default', 'cmb2-admin-extension' ), |
|
| 294 | - 'low' => __( 'Low', 'cmb2-admin-extension' ), |
|
| 291 | + 'high' => __('High', 'cmb2-admin-extension'), |
|
| 292 | + 'core' => __('Core', 'cmb2-admin-extension'), |
|
| 293 | + 'default' => __('Default', 'cmb2-admin-extension'), |
|
| 294 | + 'low' => __('Low', 'cmb2-admin-extension'), |
|
| 295 | 295 | ), |
| 296 | 296 | 'inline' => true, |
| 297 | 297 | ) |
@@ -299,15 +299,15 @@ discard block |
||
| 299 | 299 | |
| 300 | 300 | $cmb->add_field( |
| 301 | 301 | array( |
| 302 | - 'name' => __( 'Context', 'cmb2-admin-extension' ), |
|
| 303 | - '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' ), |
|
| 302 | + 'name' => __('Context', 'cmb2-admin-extension'), |
|
| 303 | + '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'), |
|
| 304 | 304 | 'id' => $prefix . 'context_radio', |
| 305 | 305 | 'type' => 'radio', |
| 306 | 306 | 'default' => 'advanced', |
| 307 | 307 | 'options' => array( |
| 308 | - 'advanced' => __( 'Advanced', 'cmb2-admin-extension' ), |
|
| 309 | - 'normal' => __( 'Normal', 'cmb2-admin-extension' ), |
|
| 310 | - 'side' => __( 'Side', 'cmb2-admin-extension' ), |
|
| 308 | + 'advanced' => __('Advanced', 'cmb2-admin-extension'), |
|
| 309 | + 'normal' => __('Normal', 'cmb2-admin-extension'), |
|
| 310 | + 'side' => __('Side', 'cmb2-admin-extension'), |
|
| 311 | 311 | ), |
| 312 | 312 | 'inline' => true, |
| 313 | 313 | ) |
@@ -315,8 +315,8 @@ discard block |
||
| 315 | 315 | |
| 316 | 316 | $cmb->add_field( |
| 317 | 317 | array( |
| 318 | - 'name' => __( 'Show Names', 'cmb2-admin-extension' ), |
|
| 319 | - 'desc' => __( 'Show field names on the left', 'cmb2-admin-extension' ), |
|
| 318 | + 'name' => __('Show Names', 'cmb2-admin-extension'), |
|
| 319 | + 'desc' => __('Show field names on the left', 'cmb2-admin-extension'), |
|
| 320 | 320 | 'id' => $prefix . 'show_names', |
| 321 | 321 | 'type' => 'checkbox', |
| 322 | 322 | 'default' => 'on', |
@@ -325,8 +325,8 @@ discard block |
||
| 325 | 325 | |
| 326 | 326 | $cmb->add_field( |
| 327 | 327 | array( |
| 328 | - 'name' => __( 'Disable CMB2 Styles', 'cmb2-admin-extension' ), |
|
| 329 | - 'desc' => __( 'Check to disable the CMB stylesheet', 'cmb2-admin-extension' ), |
|
| 328 | + 'name' => __('Disable CMB2 Styles', 'cmb2-admin-extension'), |
|
| 329 | + 'desc' => __('Check to disable the CMB stylesheet', 'cmb2-admin-extension'), |
|
| 330 | 330 | 'id' => $prefix . 'disable_styles', |
| 331 | 331 | 'type' => 'checkbox', |
| 332 | 332 | ) |
@@ -334,8 +334,8 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | $cmb->add_field( |
| 336 | 336 | array( |
| 337 | - 'name' => __( 'Closed by Default', 'cmb2-admin-extension' ), |
|
| 338 | - 'desc' => __( 'Check to keep the metabox closed by default', 'cmb2-admin-extension' ), |
|
| 337 | + 'name' => __('Closed by Default', 'cmb2-admin-extension'), |
|
| 338 | + 'desc' => __('Check to keep the metabox closed by default', 'cmb2-admin-extension'), |
|
| 339 | 339 | 'id' => $prefix . 'closed', |
| 340 | 340 | 'type' => 'checkbox', |
| 341 | 341 | ) |
@@ -343,8 +343,8 @@ discard block |
||
| 343 | 343 | |
| 344 | 344 | $cmb->add_field( |
| 345 | 345 | array( |
| 346 | - 'name' => __( 'Repeatable Group', 'cmb2-admin-extension' ), |
|
| 347 | - 'desc' => __( 'Add these fields to a repeatable group.', 'cmb2-admin-extension' ), |
|
| 346 | + 'name' => __('Repeatable Group', 'cmb2-admin-extension'), |
|
| 347 | + 'desc' => __('Add these fields to a repeatable group.', 'cmb2-admin-extension'), |
|
| 348 | 348 | 'id' => $prefix . 'repeatable_group', |
| 349 | 349 | 'type' => 'checkbox', |
| 350 | 350 | ) |
@@ -352,8 +352,8 @@ discard block |
||
| 352 | 352 | |
| 353 | 353 | $cmb->add_field( |
| 354 | 354 | array( |
| 355 | - 'name' => __( 'Description', 'cmb2-admin-extension' ), |
|
| 356 | - 'desc' => __( 'Short description for the repeatable group.', 'cmb2-admin-extension' ), |
|
| 355 | + 'name' => __('Description', 'cmb2-admin-extension'), |
|
| 356 | + 'desc' => __('Short description for the repeatable group.', 'cmb2-admin-extension'), |
|
| 357 | 357 | 'id' => $prefix . 'group_description', |
| 358 | 358 | 'type' => 'textarea_small', |
| 359 | 359 | ) |
@@ -361,8 +361,8 @@ discard block |
||
| 361 | 361 | |
| 362 | 362 | $cmb->add_field( |
| 363 | 363 | array( |
| 364 | - 'name' => __( 'Entry Name', 'cmb2-admin-extension' ), |
|
| 365 | - 'desc' => __( 'Text to be used as entry name for each row (i.e. Entry 1). Defaults to the word "Entry".', 'cmb2-admin-extension' ), |
|
| 364 | + 'name' => __('Entry Name', 'cmb2-admin-extension'), |
|
| 365 | + 'desc' => __('Text to be used as entry name for each row (i.e. Entry 1). Defaults to the word "Entry".', 'cmb2-admin-extension'), |
|
| 366 | 366 | 'id' => $prefix . 'entry_name', |
| 367 | 367 | 'type' => 'text', |
| 368 | 368 | 'inline' => true, |
@@ -413,8 +413,8 @@ discard block |
||
| 413 | 413 | $cmb_group = new_cmb2_box( |
| 414 | 414 | array( |
| 415 | 415 | 'id' => $prefix . 'custom_fields', |
| 416 | - 'title' => __( 'Custom Field Settings', 'cmb2-admin-extension' ), |
|
| 417 | - 'object_types' => array( 'meta_box' ), |
|
| 416 | + 'title' => __('Custom Field Settings', 'cmb2-admin-extension'), |
|
| 417 | + 'object_types' => array('meta_box'), |
|
| 418 | 418 | ) |
| 419 | 419 | ); |
| 420 | 420 | |
@@ -422,11 +422,11 @@ discard block |
||
| 422 | 422 | array( |
| 423 | 423 | 'id' => $prefix . 'custom_field', |
| 424 | 424 | 'type' => 'group', |
| 425 | - 'description' => __( 'Add the custom fields that you want to display with in this meta box.', 'cmb2-admin-extension' ), |
|
| 425 | + 'description' => __('Add the custom fields that you want to display with in this meta box.', 'cmb2-admin-extension'), |
|
| 426 | 426 | 'options' => array( |
| 427 | - 'group_title' => __( 'Field {#}', 'cmb2-admin-extension' ), |
|
| 428 | - 'add_button' => __( 'Add Another Field', 'cmb2-admin-extension' ), |
|
| 429 | - 'remove_button' => __( 'Remove Field', 'cmb2-admin-extension' ), |
|
| 427 | + 'group_title' => __('Field {#}', 'cmb2-admin-extension'), |
|
| 428 | + 'add_button' => __('Add Another Field', 'cmb2-admin-extension'), |
|
| 429 | + 'remove_button' => __('Remove Field', 'cmb2-admin-extension'), |
|
| 430 | 430 | 'sortable' => true, // Beta. |
| 431 | 431 | ), |
| 432 | 432 | ) |
@@ -435,8 +435,8 @@ discard block |
||
| 435 | 435 | $cmb_group->add_group_field( |
| 436 | 436 | $group_field_id, |
| 437 | 437 | array( |
| 438 | - 'name' => __( 'Name', 'cmb2-admin-extension' ), |
|
| 439 | - 'desc' => __( 'Add a field name.', 'cmb2-admin-extension' ), |
|
| 438 | + 'name' => __('Name', 'cmb2-admin-extension'), |
|
| 439 | + 'desc' => __('Add a field name.', 'cmb2-admin-extension'), |
|
| 440 | 440 | 'id' => $prefix . 'name_text', |
| 441 | 441 | 'type' => 'text', |
| 442 | 442 | 'attributes' => array( |
@@ -483,8 +483,8 @@ discard block |
||
| 483 | 483 | $cmb_group->add_group_field( |
| 484 | 484 | $group_field_id, |
| 485 | 485 | array( |
| 486 | - 'name' => __( 'Description', 'cmb2-admin-extension' ), |
|
| 487 | - 'desc' => __( 'Add a field description.', 'cmb2-admin-extension' ), |
|
| 486 | + 'name' => __('Description', 'cmb2-admin-extension'), |
|
| 487 | + 'desc' => __('Add a field description.', 'cmb2-admin-extension'), |
|
| 488 | 488 | 'id' => $prefix . 'decription_textarea', |
| 489 | 489 | 'type' => 'textarea_small', |
| 490 | 490 | ) |
@@ -493,8 +493,8 @@ discard block |
||
| 493 | 493 | $cmb_group->add_group_field( |
| 494 | 494 | $group_field_id, |
| 495 | 495 | array( |
| 496 | - 'name' => __( 'Field Type', 'cmb2-admin-extension' ), |
|
| 497 | - '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' ), |
|
| 496 | + 'name' => __('Field Type', 'cmb2-admin-extension'), |
|
| 497 | + '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'), |
|
| 498 | 498 | 'id' => $prefix . 'field_type_select', |
| 499 | 499 | 'attributes' => array( |
| 500 | 500 | 'class' => 'cmb2_select field_type_select', |
@@ -502,38 +502,38 @@ discard block |
||
| 502 | 502 | 'type' => 'select', |
| 503 | 503 | 'show_option_none' => false, |
| 504 | 504 | 'options' => array( |
| 505 | - 'title' => 'title: ' . __( 'An arbitrary title field', 'cmb2-admin-extension' ) . ' *', |
|
| 506 | - 'text' => 'text: ' . __( 'Text', 'cmb2-admin-extension' ), |
|
| 507 | - 'text_small' => 'text_small: ' . __( 'Text Small', 'cmb2-admin-extension' ), |
|
| 508 | - 'text_medium' => 'text_medium: ' . __( 'Text Medium', 'cmb2-admin-extension' ), |
|
| 509 | - 'text_email' => 'text_email: ' . __( 'Email', 'cmb2-admin-extension' ), |
|
| 510 | - 'text_url' => 'text_url: ' . __( 'URL', 'cmb2-admin-extension' ), |
|
| 511 | - 'text_money' => 'text_money: ' . __( 'Money', 'cmb2-admin-extension' ), |
|
| 512 | - 'textarea' => 'textarea: ' . __( 'Text Area', 'cmb2-admin-extension' ), |
|
| 513 | - 'textarea_small' => 'textarea_small: ' . __( 'Text Area Small', 'cmb2-admin-extension' ), |
|
| 514 | - 'textarea_code' => 'textarea_code: ' . __( 'Text Area Code', 'cmb2-admin-extension' ), |
|
| 515 | - 'text_date' => 'text_date: ' . __( 'Date Picker', 'cmb2-admin-extension' ), |
|
| 516 | - 'text_time' => 'text_time: ' . __( 'Time picker', 'cmb2-admin-extension' ), |
|
| 517 | - 'select_timezone' => 'select_timezone: ' . __( 'Time zone dropdown', 'cmb2-admin-extension' ), |
|
| 518 | - 'text_date_timestamp' => 'text_date_timestamp: ' . __( 'Date Picker (UNIX timestamp)', 'cmb2-admin-extension' ), |
|
| 519 | - 'text_datetime_timestamp' => 'text_datetime_timestamp: ' . __( 'Text Date/Time Picker Combo (UNIX timestamp)', 'cmb2-admin-extension' ), |
|
| 520 | - 'text_datetime_timestamp_timezone' => 'text_datetime_timestamp_timezone: ' . __( 'Text Date/Time Picker/Time zone Combo (serialized DateTime object)', 'cmb2-admin-extension' ), |
|
| 521 | - 'color_picker' => 'colorpicker: ' . __( 'Color picker', 'cmb2-admin-extension' ), |
|
| 522 | - 'radio' => 'radio: ' . __( 'Radio Buttons', 'cmb2-admin-extension' ) . ' *', |
|
| 523 | - 'radio_inline' => 'radio_inline: ' . __( 'Radio Buttons Inline', 'cmb2-admin-extension' ) . ' *', |
|
| 524 | - 'taxonomy_radio' => 'taxonomy_radio: ' . __( 'Taxonomy Radio Buttons', 'cmb2-admin-extension' ) . ' *', |
|
| 525 | - 'taxonomy_radio_inline' => 'taxonomy_radio_inline: ' . __( 'Taxonomy Radio Buttons Inline', 'cmb2-admin-extension' ) . ' *', |
|
| 526 | - 'select' => 'select: ' . __( 'Select', 'cmb2-admin-extension' ), |
|
| 527 | - 'taxonomy_select' => 'taxonomy_select: ' . __( 'Taxonomy Select', 'cmb2-admin-extension' ) . ' *', |
|
| 528 | - 'checkbox' => 'checkbox: ' . __( 'Checkbox', 'cmb2-admin-extension' ) . ' *', |
|
| 529 | - 'multicheck' => 'multicheck: ' . __( 'Multiple Checkboxes', 'cmb2-admin-extension' ), |
|
| 530 | - 'multicheck_inline' => 'multicheck_inline: ' . __( 'Multiple Checkboxes Inline', 'cmb2-admin-extension' ), |
|
| 531 | - 'taxonomy_multicheck' => 'taxonomy_multicheck: ' . __( 'Taxonomy Multiple Checkboxes', 'cmb2-admin-extension' ) . ' *', |
|
| 532 | - 'taxonomy_multicheck_inline' => 'taxonomy_multicheck_inline: ' . __( 'Taxonomy Multiple Checkboxes Inline', 'cmb2-admin-extension' ) . ' *', |
|
| 533 | - 'wysiwyg' => 'wysiwyg: ' . __( '(TinyMCE)', 'cmb2-admin-extension' ) . ' *', |
|
| 534 | - 'file' => 'file: ' . __( 'Image/File upload', 'cmb2-admin-extension' ) . ' *†', |
|
| 535 | - 'file_list' => 'file_list: ' . __( 'Image/File list upload', 'cmb2-admin-extension' ), |
|
| 536 | - 'oembed' => 'oembed: ' . __( 'Converts oembed urls (instagram, twitter, youtube, etc. oEmbed in the Codex)', 'cmb2-admin-extension' ), |
|
| 505 | + 'title' => 'title: ' . __('An arbitrary title field', 'cmb2-admin-extension') . ' *', |
|
| 506 | + 'text' => 'text: ' . __('Text', 'cmb2-admin-extension'), |
|
| 507 | + 'text_small' => 'text_small: ' . __('Text Small', 'cmb2-admin-extension'), |
|
| 508 | + 'text_medium' => 'text_medium: ' . __('Text Medium', 'cmb2-admin-extension'), |
|
| 509 | + 'text_email' => 'text_email: ' . __('Email', 'cmb2-admin-extension'), |
|
| 510 | + 'text_url' => 'text_url: ' . __('URL', 'cmb2-admin-extension'), |
|
| 511 | + 'text_money' => 'text_money: ' . __('Money', 'cmb2-admin-extension'), |
|
| 512 | + 'textarea' => 'textarea: ' . __('Text Area', 'cmb2-admin-extension'), |
|
| 513 | + 'textarea_small' => 'textarea_small: ' . __('Text Area Small', 'cmb2-admin-extension'), |
|
| 514 | + 'textarea_code' => 'textarea_code: ' . __('Text Area Code', 'cmb2-admin-extension'), |
|
| 515 | + 'text_date' => 'text_date: ' . __('Date Picker', 'cmb2-admin-extension'), |
|
| 516 | + 'text_time' => 'text_time: ' . __('Time picker', 'cmb2-admin-extension'), |
|
| 517 | + 'select_timezone' => 'select_timezone: ' . __('Time zone dropdown', 'cmb2-admin-extension'), |
|
| 518 | + 'text_date_timestamp' => 'text_date_timestamp: ' . __('Date Picker (UNIX timestamp)', 'cmb2-admin-extension'), |
|
| 519 | + 'text_datetime_timestamp' => 'text_datetime_timestamp: ' . __('Text Date/Time Picker Combo (UNIX timestamp)', 'cmb2-admin-extension'), |
|
| 520 | + 'text_datetime_timestamp_timezone' => 'text_datetime_timestamp_timezone: ' . __('Text Date/Time Picker/Time zone Combo (serialized DateTime object)', 'cmb2-admin-extension'), |
|
| 521 | + 'color_picker' => 'colorpicker: ' . __('Color picker', 'cmb2-admin-extension'), |
|
| 522 | + 'radio' => 'radio: ' . __('Radio Buttons', 'cmb2-admin-extension') . ' *', |
|
| 523 | + 'radio_inline' => 'radio_inline: ' . __('Radio Buttons Inline', 'cmb2-admin-extension') . ' *', |
|
| 524 | + 'taxonomy_radio' => 'taxonomy_radio: ' . __('Taxonomy Radio Buttons', 'cmb2-admin-extension') . ' *', |
|
| 525 | + 'taxonomy_radio_inline' => 'taxonomy_radio_inline: ' . __('Taxonomy Radio Buttons Inline', 'cmb2-admin-extension') . ' *', |
|
| 526 | + 'select' => 'select: ' . __('Select', 'cmb2-admin-extension'), |
|
| 527 | + 'taxonomy_select' => 'taxonomy_select: ' . __('Taxonomy Select', 'cmb2-admin-extension') . ' *', |
|
| 528 | + 'checkbox' => 'checkbox: ' . __('Checkbox', 'cmb2-admin-extension') . ' *', |
|
| 529 | + 'multicheck' => 'multicheck: ' . __('Multiple Checkboxes', 'cmb2-admin-extension'), |
|
| 530 | + 'multicheck_inline' => 'multicheck_inline: ' . __('Multiple Checkboxes Inline', 'cmb2-admin-extension'), |
|
| 531 | + 'taxonomy_multicheck' => 'taxonomy_multicheck: ' . __('Taxonomy Multiple Checkboxes', 'cmb2-admin-extension') . ' *', |
|
| 532 | + 'taxonomy_multicheck_inline' => 'taxonomy_multicheck_inline: ' . __('Taxonomy Multiple Checkboxes Inline', 'cmb2-admin-extension') . ' *', |
|
| 533 | + 'wysiwyg' => 'wysiwyg: ' . __('(TinyMCE)', 'cmb2-admin-extension') . ' *', |
|
| 534 | + 'file' => 'file: ' . __('Image/File upload', 'cmb2-admin-extension') . ' *†', |
|
| 535 | + 'file_list' => 'file_list: ' . __('Image/File list upload', 'cmb2-admin-extension'), |
|
| 536 | + 'oembed' => 'oembed: ' . __('Converts oembed urls (instagram, twitter, youtube, etc. oEmbed in the Codex)', 'cmb2-admin-extension'), |
|
| 537 | 537 | ), |
| 538 | 538 | ) |
| 539 | 539 | ); |
@@ -541,8 +541,8 @@ discard block |
||
| 541 | 541 | $cmb_group->add_group_field( |
| 542 | 542 | $group_field_id, |
| 543 | 543 | array( |
| 544 | - 'name' => __( 'Repeatable', 'cmb2-admin-extension' ), |
|
| 545 | - 'desc' => __( 'Check this box to make the field repeatable. Field types marked with a "*" are not repeatable.', 'cmb2-admin-extension' ), |
|
| 544 | + 'name' => __('Repeatable', 'cmb2-admin-extension'), |
|
| 545 | + 'desc' => __('Check this box to make the field repeatable. Field types marked with a "*" are not repeatable.', 'cmb2-admin-extension'), |
|
| 546 | 546 | 'id' => $prefix . 'repeatable_checkbox', |
| 547 | 547 | 'type' => 'checkbox', |
| 548 | 548 | ) |
@@ -551,8 +551,8 @@ discard block |
||
| 551 | 551 | $cmb_group->add_group_field( |
| 552 | 552 | $group_field_id, |
| 553 | 553 | array( |
| 554 | - 'name' => __( 'Protocols', 'cmb2-admin-extension' ), |
|
| 555 | - 'desc' => __( 'Check the boxes for each allowed protocol. If you are unsure then do nothing and all protocols will be allowed.', 'cmb2-admin-extension' ), |
|
| 554 | + 'name' => __('Protocols', 'cmb2-admin-extension'), |
|
| 555 | + 'desc' => __('Check the boxes for each allowed protocol. If you are unsure then do nothing and all protocols will be allowed.', 'cmb2-admin-extension'), |
|
| 556 | 556 | 'id' => $prefix . 'protocols_checkbox', |
| 557 | 557 | 'type' => 'multicheck_inline', |
| 558 | 558 | 'options' => array( |
@@ -574,8 +574,8 @@ discard block |
||
| 574 | 574 | $cmb_group->add_group_field( |
| 575 | 575 | $group_field_id, |
| 576 | 576 | array( |
| 577 | - 'name' => __( 'Currency Symbol', 'cmb2-admin-extension' ), |
|
| 578 | - 'desc' => __( 'Replaces the default "$".', 'cmb2-admin-extension' ), |
|
| 577 | + 'name' => __('Currency Symbol', 'cmb2-admin-extension'), |
|
| 578 | + 'desc' => __('Replaces the default "$".', 'cmb2-admin-extension'), |
|
| 579 | 579 | 'id' => $prefix . 'currency_text', |
| 580 | 580 | 'type' => 'text_small', |
| 581 | 581 | ) |
@@ -584,8 +584,8 @@ discard block |
||
| 584 | 584 | $cmb_group->add_group_field( |
| 585 | 585 | $group_field_id, |
| 586 | 586 | array( |
| 587 | - 'name' => __( 'Date Format', 'cmb2-admin-extension' ), |
|
| 588 | - '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' ), |
|
| 587 | + 'name' => __('Date Format', 'cmb2-admin-extension'), |
|
| 588 | + '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'), |
|
| 589 | 589 | 'id' => $prefix . 'date_format', |
| 590 | 590 | 'type' => 'text_small', |
| 591 | 591 | ) |
@@ -594,8 +594,8 @@ discard block |
||
| 594 | 594 | $cmb_group->add_group_field( |
| 595 | 595 | $group_field_id, |
| 596 | 596 | array( |
| 597 | - 'name' => __( 'Time Format', 'cmb2-admin-extension' ), |
|
| 598 | - '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' ), |
|
| 597 | + 'name' => __('Time Format', 'cmb2-admin-extension'), |
|
| 598 | + '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'), |
|
| 599 | 599 | 'id' => $prefix . 'time_format', |
| 600 | 600 | 'type' => 'text_small', |
| 601 | 601 | ) |
@@ -604,20 +604,20 @@ discard block |
||
| 604 | 604 | $cmb_group->add_group_field( |
| 605 | 605 | $group_field_id, |
| 606 | 606 | array( |
| 607 | - 'name' => __( 'Options', 'cmb2-admin-extension' ), |
|
| 608 | - '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' ), |
|
| 607 | + 'name' => __('Options', 'cmb2-admin-extension'), |
|
| 608 | + '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'), |
|
| 609 | 609 | 'id' => $prefix . 'options_textarea', |
| 610 | 610 | 'type' => 'textarea_small', |
| 611 | 611 | ) |
| 612 | 612 | ); |
| 613 | 613 | |
| 614 | 614 | $tax_options = $this->tax_options(); |
| 615 | - reset( $tax_options ); |
|
| 616 | - $default_tax_options = key( $tax_options ); |
|
| 615 | + reset($tax_options); |
|
| 616 | + $default_tax_options = key($tax_options); |
|
| 617 | 617 | $cmb_group->add_group_field( |
| 618 | 618 | $group_field_id, |
| 619 | 619 | array( |
| 620 | - 'name' => __( 'Taxonomy Options', 'cmb2-admin-extension' ), |
|
| 620 | + 'name' => __('Taxonomy Options', 'cmb2-admin-extension'), |
|
| 621 | 621 | 'id' => $prefix . 'tax_options_radio_inline', |
| 622 | 622 | 'type' => 'radio_inline', |
| 623 | 623 | 'options' => $this->tax_options(), |
@@ -628,8 +628,8 @@ discard block |
||
| 628 | 628 | $cmb_group->add_group_field( |
| 629 | 629 | $group_field_id, |
| 630 | 630 | array( |
| 631 | - 'name' => __( 'No Terms Text', 'cmb2-admin-extension' ), |
|
| 632 | - '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' ) . '".', |
|
| 631 | + 'name' => __('No Terms Text', 'cmb2-admin-extension'), |
|
| 632 | + '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') . '".', |
|
| 633 | 633 | 'id' => $prefix . 'no_terms_text', |
| 634 | 634 | 'type' => 'text_small', |
| 635 | 635 | ) |
@@ -638,8 +638,8 @@ discard block |
||
| 638 | 638 | $cmb_group->add_group_field( |
| 639 | 639 | $group_field_id, |
| 640 | 640 | array( |
| 641 | - 'name' => __( 'Include a "none" option', 'cmb2-admin-extension' ), |
|
| 642 | - 'desc' => __( 'Check this box to include a "none" option with this field.', 'cmb2-admin-extension' ), |
|
| 641 | + 'name' => __('Include a "none" option', 'cmb2-admin-extension'), |
|
| 642 | + 'desc' => __('Check this box to include a "none" option with this field.', 'cmb2-admin-extension'), |
|
| 643 | 643 | 'id' => $prefix . 'none_checkbox', |
| 644 | 644 | 'type' => 'checkbox', |
| 645 | 645 | ) |
@@ -648,8 +648,8 @@ discard block |
||
| 648 | 648 | $cmb_group->add_group_field( |
| 649 | 649 | $group_field_id, |
| 650 | 650 | array( |
| 651 | - 'name' => __( 'Disable select all', 'cmb2-admin-extension' ), |
|
| 652 | - 'desc' => __( 'Check this box to disable the select all button for this field.', 'cmb2-admin-extension' ), |
|
| 651 | + 'name' => __('Disable select all', 'cmb2-admin-extension'), |
|
| 652 | + 'desc' => __('Check this box to disable the select all button for this field.', 'cmb2-admin-extension'), |
|
| 653 | 653 | 'id' => $prefix . 'select_all_checkbox', |
| 654 | 654 | 'type' => 'checkbox', |
| 655 | 655 | ) |
@@ -658,8 +658,8 @@ discard block |
||
| 658 | 658 | $cmb_group->add_group_field( |
| 659 | 659 | $group_field_id, |
| 660 | 660 | array( |
| 661 | - 'name' => __( 'Button Text', 'cmb2-admin-extension' ), |
|
| 662 | - 'desc' => __( 'Enter text to change the upload button text.', 'cmb2-admin-extension' ) . '</br>' . __( 'Default:', 'cmb2-admin-extension' ) . ' "' . __( 'Add or Upload File', 'cmb2-admin-extension' ) . '".', |
|
| 661 | + 'name' => __('Button Text', 'cmb2-admin-extension'), |
|
| 662 | + 'desc' => __('Enter text to change the upload button text.', 'cmb2-admin-extension') . '</br>' . __('Default:', 'cmb2-admin-extension') . ' "' . __('Add or Upload File', 'cmb2-admin-extension') . '".', |
|
| 663 | 663 | 'id' => $prefix . 'add_upload_file_text', |
| 664 | 664 | 'type' => 'text_small', |
| 665 | 665 | ) |
@@ -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 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function register_settings() { |
| 80 | 80 | |
| 81 | - register_setting( $this->settings_key, $this->settings_key ); |
|
| 81 | + register_setting($this->settings_key, $this->settings_key); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -89,9 +89,9 @@ discard block |
||
| 89 | 89 | public function settings_page() { |
| 90 | 90 | |
| 91 | 91 | ?> |
| 92 | - <div class="wrap cmb2-options-page <?php echo esc_attr( $this->settings_key ); ?>"> |
|
| 93 | - <h2><?php echo esc_html__( 'CMB2 Settings', 'cmb2-admin-extension' ); ?></h2> |
|
| 94 | - <?php cmb2_metabox_form( $this->settings_metabox_id, $this->settings_key, array( 'disable_styles' => false ) ); ?> |
|
| 92 | + <div class="wrap cmb2-options-page <?php echo esc_attr($this->settings_key); ?>"> |
|
| 93 | + <h2><?php echo esc_html__('CMB2 Settings', 'cmb2-admin-extension'); ?></h2> |
|
| 94 | + <?php cmb2_metabox_form($this->settings_metabox_id, $this->settings_key, array('disable_styles' => false)); ?> |
|
| 95 | 95 | </div> |
| 96 | 96 | <?php |
| 97 | 97 | } |
@@ -105,10 +105,10 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | $users = get_users(); |
| 107 | 107 | $user_options = array(); |
| 108 | - foreach ( $users as $user ) { |
|
| 108 | + foreach ($users as $user) { |
|
| 109 | 109 | |
| 110 | - if ( user_can( $user, 'update_plugins' ) || user_can( $user, 'install_plugins' ) || user_can( $user, 'delete_plugins' ) || user_can( $user, 'edit_theme_options' ) ) { |
|
| 111 | - $user_options[ $user->ID ] = $user->display_name; |
|
| 110 | + if (user_can($user, 'update_plugins') || user_can($user, 'install_plugins') || user_can($user, 'delete_plugins') || user_can($user, 'edit_theme_options')) { |
|
| 111 | + $user_options[$user->ID] = $user->display_name; |
|
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | |
@@ -131,15 +131,15 @@ discard block |
||
| 131 | 131 | 'hookup' => false, |
| 132 | 132 | 'show_on' => array( |
| 133 | 133 | 'key' => 'options-page', |
| 134 | - 'value' => array( $this->settings_key ), |
|
| 134 | + 'value' => array($this->settings_key), |
|
| 135 | 135 | ), |
| 136 | 136 | ) |
| 137 | 137 | ); |
| 138 | 138 | |
| 139 | 139 | $cmb_settings->add_field( |
| 140 | 140 | 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' ), |
|
| 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(), |
@@ -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 | /** |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | public static function get_instance() { |
| 103 | 103 | // If the single instance hasn't been set, set it now. |
| 104 | 104 | require_once __DIR__ . '/includes/functions.php'; |
| 105 | - if ( null === self::$instance ) { |
|
| 105 | + if (null === self::$instance) { |
|
| 106 | 106 | self::$instance = new self(); |
| 107 | 107 | } |
| 108 | 108 | |
@@ -116,19 +116,19 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | private function check_for_cmb2() { |
| 118 | 118 | |
| 119 | - if ( defined( 'CMB2_LOADED' ) && CMB2_LOADED !== false ) { |
|
| 119 | + if (defined('CMB2_LOADED') && CMB2_LOADED !== false) { |
|
| 120 | 120 | |
| 121 | 121 | require_once __DIR__ . '/includes/class-meta-box.php'; |
| 122 | 122 | require_once __DIR__ . '/includes/class-meta-box-post-type.php'; |
| 123 | 123 | require_once __DIR__ . '/includes/class-meta-box-settings.php'; |
| 124 | 124 | cmb2ae_metabox(); |
| 125 | 125 | return; |
| 126 | - } elseif ( file_exists( WP_PLUGIN_DIR . '/' . CMB2AE_CMB2_PLUGIN_FILE ) ) { |
|
| 126 | + } elseif (file_exists(WP_PLUGIN_DIR . '/' . CMB2AE_CMB2_PLUGIN_FILE)) { |
|
| 127 | 127 | |
| 128 | - add_action( 'admin_notices', array( $this, 'cmb2_not_activated' ) ); |
|
| 128 | + add_action('admin_notices', array($this, 'cmb2_not_activated')); |
|
| 129 | 129 | return; |
| 130 | 130 | } |
| 131 | - add_action( 'admin_notices', array( $this, 'missing_cmb2' ) ); |
|
| 131 | + add_action('admin_notices', array($this, 'missing_cmb2')); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -138,20 +138,20 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | public function load_textdomain() { |
| 140 | 140 | |
| 141 | - $lang_path = plugin_basename( __DIR__ ) . '/languages'; |
|
| 142 | - $loaded = load_muplugin_textdomain( 'cmb2-admin-extension', $lang_path ); |
|
| 143 | - if ( strpos( __FILE__, basename( WPMU_PLUGIN_DIR ) ) === false ) { |
|
| 144 | - $loaded = load_plugin_textdomain( 'cmb2-admin-extension', false, $lang_path ); |
|
| 141 | + $lang_path = plugin_basename(__DIR__) . '/languages'; |
|
| 142 | + $loaded = load_muplugin_textdomain('cmb2-admin-extension', $lang_path); |
|
| 143 | + if (strpos(__FILE__, basename(WPMU_PLUGIN_DIR)) === false) { |
|
| 144 | + $loaded = load_plugin_textdomain('cmb2-admin-extension', false, $lang_path); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - if ( ! $loaded ) { |
|
| 148 | - $loaded = load_theme_textdomain( 'cmb2-admin-extension', get_stylesheet_directory() . '/languages' ); |
|
| 147 | + if ( ! $loaded) { |
|
| 148 | + $loaded = load_theme_textdomain('cmb2-admin-extension', get_stylesheet_directory() . '/languages'); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - if ( ! $loaded ) { |
|
| 152 | - $locale = apply_filters( 'plugin_locale', get_locale(), 'cmb2-admin-extension' ); |
|
| 151 | + if ( ! $loaded) { |
|
| 152 | + $locale = apply_filters('plugin_locale', get_locale(), 'cmb2-admin-extension'); |
|
| 153 | 153 | $mofile = __DIR__ . '/languages/cmb2-admin-extension-' . $locale . '.mo'; |
| 154 | - load_textdomain( 'cmb2-admin-extension', $mofile ); |
|
| 154 | + load_textdomain('cmb2-admin-extension', $mofile); |
|
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | <?php |
| 169 | 169 | printf( |
| 170 | 170 | /* translators: 1: link opener; 2: link closer. */ |
| 171 | - esc_html__( 'CMB2 Admin Extension depends on the last version of %1$s the CMB2 plugin %2$s to work!', 'cmb2-admin-extension' ), |
|
| 171 | + esc_html__('CMB2 Admin Extension depends on the last version of %1$s the CMB2 plugin %2$s to work!', 'cmb2-admin-extension'), |
|
| 172 | 172 | '<a href="https://wordpress.org/plugins/cmb2/">', |
| 173 | 173 | '</a>' |
| 174 | 174 | ); |
@@ -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 | ?> |
@@ -202,4 +202,4 @@ discard block |
||
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | -add_action( 'plugins_loaded', array( 'CMB2_Admin_Extension_Class', 'get_instance' ), 20 ); |
|
| 205 | +add_action('plugins_loaded', array('CMB2_Admin_Extension_Class', 'get_instance'), 20); |
|