@@ -131,21 +131,21 @@ discard block |
||
131 | 131 | */ |
132 | 132 | public function __construct( $args ) { |
133 | 133 | |
134 | - if ( ! empty( $args['group_field'] ) ) { |
|
135 | - $this->group = $args['group_field']; |
|
134 | + if ( ! empty( $args[ 'group_field' ] ) ) { |
|
135 | + $this->group = $args[ 'group_field' ]; |
|
136 | 136 | $this->object_id = $this->group->object_id; |
137 | 137 | $this->object_type = $this->group->object_type; |
138 | 138 | $this->cmb_id = $this->group->cmb_id; |
139 | 139 | } else { |
140 | - $this->object_id = isset( $args['object_id'] ) && '_' !== $args['object_id'] ? $args['object_id'] : 0; |
|
141 | - $this->object_type = isset( $args['object_type'] ) ? $args['object_type'] : 'post'; |
|
140 | + $this->object_id = isset( $args[ 'object_id' ] ) && '_' !== $args[ 'object_id' ] ? $args[ 'object_id' ] : 0; |
|
141 | + $this->object_type = isset( $args[ 'object_type' ] ) ? $args[ 'object_type' ] : 'post'; |
|
142 | 142 | |
143 | - if ( isset( $args['cmb_id'] ) ) { |
|
144 | - $this->cmb_id = $args['cmb_id']; |
|
143 | + if ( isset( $args[ 'cmb_id' ] ) ) { |
|
144 | + $this->cmb_id = $args[ 'cmb_id' ]; |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
148 | - $this->args = $this->_set_field_defaults( $args['field_args'] ); |
|
148 | + $this->args = $this->_set_field_defaults( $args[ 'field_args' ] ); |
|
149 | 149 | |
150 | 150 | if ( $this->object_id ) { |
151 | 151 | $this->value = $this->get_data(); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | return call_user_func_array( array( $this, 'get_string' ), $arguments ); |
166 | 166 | } |
167 | 167 | |
168 | - $key = isset( $arguments[0] ) ? $arguments[0] : ''; |
|
168 | + $key = isset( $arguments[ 0 ] ) ? $arguments[ 0 ] : ''; |
|
169 | 169 | return $this->args( $name, $key ); |
170 | 170 | } |
171 | 171 | |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function get_data( $field_id = '', $args = array() ) { |
243 | 243 | if ( $field_id ) { |
244 | - $args['field_id'] = $field_id; |
|
244 | + $args[ 'field_id' ] = $field_id; |
|
245 | 245 | } elseif ( $this->group ) { |
246 | - $args['field_id'] = $this->group->id(); |
|
246 | + $args[ 'field_id' ] = $this->group->id(); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | $a = $this->data_args( $args ); |
@@ -284,13 +284,13 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @since 2.0.0 |
286 | 286 | */ |
287 | - $data = apply_filters( "cmb2_override_{$a['field_id']}_meta_value", $data, $this->object_id, $a, $this ); |
|
287 | + $data = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_value", $data, $this->object_id, $a, $this ); |
|
288 | 288 | |
289 | 289 | // If no override, get value normally. |
290 | 290 | if ( 'cmb2_field_no_override_val' === $data ) { |
291 | - $data = 'options-page' === $a['type'] |
|
292 | - ? cmb2_options( $a['id'] )->get( $a['field_id'] ) |
|
293 | - : get_metadata( $a['type'], $a['id'], $a['field_id'], ( $a['single'] || $a['repeat'] ) ); |
|
291 | + $data = 'options-page' === $a[ 'type' ] |
|
292 | + ? cmb2_options( $a[ 'id' ] )->get( $a[ 'field_id' ] ) |
|
293 | + : get_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], ( $a[ 'single' ] || $a[ 'repeat' ] ) ); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | if ( $this->group ) { |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | 'single' => $single, |
317 | 317 | ) ); |
318 | 318 | |
319 | - $a['value'] = $a['repeat'] ? array_values( $new_value ) : $new_value; |
|
319 | + $a[ 'value' ] = $a[ 'repeat' ] ? array_values( $new_value ) : $new_value; |
|
320 | 320 | |
321 | 321 | /** |
322 | 322 | * Filter whether to override saving of meta value. |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | * |
353 | 353 | * @since 2.0.0 |
354 | 354 | */ |
355 | - $override = apply_filters( "cmb2_override_{$a['field_id']}_meta_save", $override, $a, $this->args(), $this ); |
|
355 | + $override = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_save", $override, $a, $this->args(), $this ); |
|
356 | 356 | |
357 | 357 | // If override, return that. |
358 | 358 | if ( null !== $override ) { |
@@ -360,22 +360,22 @@ discard block |
||
360 | 360 | } |
361 | 361 | |
362 | 362 | // Options page handling (or temp data store). |
363 | - if ( 'options-page' === $a['type'] || empty( $a['id'] ) ) { |
|
364 | - return cmb2_options( $a['id'] )->update( $a['field_id'], $a['value'], false, $a['single'] ); |
|
363 | + if ( 'options-page' === $a[ 'type' ] || empty( $a[ 'id' ] ) ) { |
|
364 | + return cmb2_options( $a[ 'id' ] )->update( $a[ 'field_id' ], $a[ 'value' ], false, $a[ 'single' ] ); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | // Add metadata if not single. |
368 | - if ( ! $a['single'] ) { |
|
369 | - return add_metadata( $a['type'], $a['id'], $a['field_id'], $a['value'], false ); |
|
368 | + if ( ! $a[ 'single' ] ) { |
|
369 | + return add_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $a[ 'value' ], false ); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | // Delete meta if we have an empty array. |
373 | - if ( is_array( $a['value'] ) && empty( $a['value'] ) ) { |
|
374 | - return delete_metadata( $a['type'], $a['id'], $a['field_id'], $this->value ); |
|
373 | + if ( is_array( $a[ 'value' ] ) && empty( $a[ 'value' ] ) ) { |
|
374 | + return delete_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $this->value ); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | // Update metadata. |
378 | - return update_metadata( $a['type'], $a['id'], $a['field_id'], $a['value'] ); |
|
378 | + return update_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $a[ 'value' ] ); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | /** |
@@ -429,19 +429,19 @@ discard block |
||
429 | 429 | * @param array $field_args All field arguments |
430 | 430 | * @param CMB2_Field object $field This field object |
431 | 431 | */ |
432 | - $override = apply_filters( "cmb2_override_{$a['field_id']}_meta_remove", $override, $a, $this->args(), $this ); |
|
432 | + $override = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_remove", $override, $a, $this->args(), $this ); |
|
433 | 433 | |
434 | 434 | // If no override, remove as usual. |
435 | 435 | if ( null !== $override ) { |
436 | 436 | return $override; |
437 | 437 | } // End if. |
438 | 438 | // Option page handling. |
439 | - elseif ( 'options-page' === $a['type'] || empty( $a['id'] ) ) { |
|
440 | - return cmb2_options( $a['id'] )->remove( $a['field_id'] ); |
|
439 | + elseif ( 'options-page' === $a[ 'type' ] || empty( $a[ 'id' ] ) ) { |
|
440 | + return cmb2_options( $a[ 'id' ] )->remove( $a[ 'field_id' ] ); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | // Remove metadata. |
444 | - return delete_metadata( $a['type'], $a['id'], $a['field_id'], $old ); |
|
444 | + return delete_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $old ); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
@@ -999,7 +999,7 @@ discard block |
||
999 | 999 | |
1000 | 1000 | foreach ( $conditional_classes as $class => $condition ) { |
1001 | 1001 | if ( $condition ) { |
1002 | - $classes[] = $class; |
|
1002 | + $classes[ ] = $class; |
|
1003 | 1003 | } |
1004 | 1004 | } |
1005 | 1005 | |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | } |
1011 | 1011 | |
1012 | 1012 | if ( $added_classes ) { |
1013 | - $classes[] = esc_attr( $added_classes ); |
|
1013 | + $classes[ ] = esc_attr( $added_classes ); |
|
1014 | 1014 | } |
1015 | 1015 | |
1016 | 1016 | /** |
@@ -1162,10 +1162,10 @@ discard block |
||
1162 | 1162 | public function get_string( $text_key, $fallback ) { |
1163 | 1163 | // If null, populate with our field strings values. |
1164 | 1164 | if ( null === $this->strings ) { |
1165 | - $this->strings = (array) $this->args['text']; |
|
1165 | + $this->strings = (array) $this->args[ 'text' ]; |
|
1166 | 1166 | |
1167 | - if ( is_callable( $this->args['text_cb'] ) ) { |
|
1168 | - $strings = call_user_func( $this->args['text_cb'], $this ); |
|
1167 | + if ( is_callable( $this->args[ 'text_cb' ] ) ) { |
|
1168 | + $strings = call_user_func( $this->args[ 'text_cb' ], $this ); |
|
1169 | 1169 | |
1170 | 1170 | if ( $strings && is_array( $strings ) ) { |
1171 | 1171 | $this->strings += $strings; |
@@ -1211,10 +1211,10 @@ discard block |
||
1211 | 1211 | * @return array Array of options |
1212 | 1212 | */ |
1213 | 1213 | public function set_options() { |
1214 | - $this->field_options = (array) $this->args['options']; |
|
1214 | + $this->field_options = (array) $this->args[ 'options' ]; |
|
1215 | 1215 | |
1216 | - if ( is_callable( $this->args['options_cb'] ) ) { |
|
1217 | - $options = call_user_func( $this->args['options_cb'], $this ); |
|
1216 | + if ( is_callable( $this->args[ 'options_cb' ] ) ) { |
|
1217 | + $options = call_user_func( $this->args[ 'options_cb' ], $this ); |
|
1218 | 1218 | |
1219 | 1219 | if ( $options && is_array( $options ) ) { |
1220 | 1220 | $this->field_options = $options + $this->field_options; |
@@ -1232,7 +1232,7 @@ discard block |
||
1232 | 1232 | */ |
1233 | 1233 | public function add_js_dependencies( $dependencies = array() ) { |
1234 | 1234 | foreach ( (array) $dependencies as $dependency ) { |
1235 | - $this->args['js_dependencies'][ $dependency ] = $dependency; |
|
1235 | + $this->args[ 'js_dependencies' ][ $dependency ] = $dependency; |
|
1236 | 1236 | } |
1237 | 1237 | |
1238 | 1238 | CMB2_JS::add_dependencies( $dependencies ); |
@@ -1307,17 +1307,17 @@ discard block |
||
1307 | 1307 | * @return mixed Default field value |
1308 | 1308 | */ |
1309 | 1309 | public function get_default() { |
1310 | - $default = $this->args['default']; |
|
1310 | + $default = $this->args[ 'default' ]; |
|
1311 | 1311 | |
1312 | 1312 | if ( null !== $default ) { |
1313 | 1313 | return apply_filters( 'cmb2_default_filter', $default, $this ); |
1314 | 1314 | } |
1315 | 1315 | |
1316 | - $param = is_callable( $this->args['default_cb'] ) ? 'default_cb' : 'default'; |
|
1317 | - $default = $this->args['default'] = $this->get_param_callback_result( $param ); |
|
1316 | + $param = is_callable( $this->args[ 'default_cb' ] ) ? 'default_cb' : 'default'; |
|
1317 | + $default = $this->args[ 'default' ] = $this->get_param_callback_result( $param ); |
|
1318 | 1318 | |
1319 | 1319 | // Allow a filter override of the default value. |
1320 | - return apply_filters( 'cmb2_default_filter', $this->args['default'], $this ); |
|
1320 | + return apply_filters( 'cmb2_default_filter', $this->args[ 'default' ], $this ); |
|
1321 | 1321 | } |
1322 | 1322 | |
1323 | 1323 | /** |
@@ -1340,7 +1340,7 @@ discard block |
||
1340 | 1340 | * @param string $type Field type for the current field to allow for selective filtering. |
1341 | 1341 | * @param CMB2_Field object $field This field object. |
1342 | 1342 | */ |
1343 | - $defaults = apply_filters( 'cmb2_field_defaults', $defaults, $args['id'], $args['type'], $this ); |
|
1343 | + $defaults = apply_filters( 'cmb2_field_defaults', $defaults, $args[ 'id' ], $args[ 'type' ], $this ); |
|
1344 | 1344 | |
1345 | 1345 | // Set up blank or default values for empty ones. |
1346 | 1346 | $args = wp_parse_args( $args, $defaults ); |
@@ -1363,12 +1363,12 @@ discard block |
||
1363 | 1363 | */ |
1364 | 1364 | $args = $this->convert_deprecated_params( $args ); |
1365 | 1365 | |
1366 | - $args['repeatable'] = $args['repeatable'] && ! $this->repeatable_exception( $args['type'] ); |
|
1367 | - $args['inline'] = $args['inline'] || false !== stripos( $args['type'], '_inline' ); |
|
1368 | - $args['_id'] = $args['id']; |
|
1369 | - $args['_name'] = $args['id']; |
|
1366 | + $args[ 'repeatable' ] = $args[ 'repeatable' ] && ! $this->repeatable_exception( $args[ 'type' ] ); |
|
1367 | + $args[ 'inline' ] = $args[ 'inline' ] || false !== stripos( $args[ 'type' ], '_inline' ); |
|
1368 | + $args[ '_id' ] = $args[ 'id' ]; |
|
1369 | + $args[ '_name' ] = $args[ 'id' ]; |
|
1370 | 1370 | |
1371 | - if ( $method = $this->has_args_method( $args['type'] ) ) { |
|
1371 | + if ( $method = $this->has_args_method( $args[ 'type' ] ) ) { |
|
1372 | 1372 | $args = $this->{$method}( $args ); |
1373 | 1373 | } |
1374 | 1374 | |
@@ -1376,8 +1376,8 @@ discard block |
||
1376 | 1376 | $args = $this->set_group_sub_field_defaults( $args ); |
1377 | 1377 | } |
1378 | 1378 | |
1379 | - $args['has_supporting_data'] = in_array( |
|
1380 | - $args['type'], |
|
1379 | + $args[ 'has_supporting_data' ] = in_array( |
|
1380 | + $args[ 'type' ], |
|
1381 | 1381 | array( |
1382 | 1382 | // CMB2_Sanitize::_save_file_id_value()/CMB2_Sanitize::_get_group_file_value_array(). |
1383 | 1383 | 'file', |
@@ -1388,7 +1388,7 @@ discard block |
||
1388 | 1388 | ); |
1389 | 1389 | |
1390 | 1390 | // Repeatable fields require jQuery sortable library. |
1391 | - if ( ! empty( $args['repeatable'] ) ) { |
|
1391 | + if ( ! empty( $args[ 'repeatable' ] ) ) { |
|
1392 | 1392 | CMB2_JS::add_dependencies( 'jquery-ui-sortable' ); |
1393 | 1393 | } |
1394 | 1394 | |
@@ -1411,7 +1411,7 @@ discard block |
||
1411 | 1411 | * @return array Modified field config array. |
1412 | 1412 | */ |
1413 | 1413 | protected function set_field_defaults_group( $args ) { |
1414 | - $args['options'] = wp_parse_args( $args['options'], array( |
|
1414 | + $args[ 'options' ] = wp_parse_args( $args[ 'options' ], array( |
|
1415 | 1415 | 'add_button' => esc_html__( 'Add Group', 'cmb2' ), |
1416 | 1416 | 'remove_button' => esc_html__( 'Remove Group', 'cmb2' ), |
1417 | 1417 | 'remove_confirm' => '', |
@@ -1429,8 +1429,8 @@ discard block |
||
1429 | 1429 | * @return array Modified field config array. |
1430 | 1430 | */ |
1431 | 1431 | protected function set_field_defaults_wysiwyg( $args ) { |
1432 | - $args['id'] = strtolower( str_ireplace( '-', '_', $args['id'] ) ); |
|
1433 | - $args['options']['textarea_name'] = $args['_name']; |
|
1432 | + $args[ 'id' ] = strtolower( str_ireplace( '-', '_', $args[ 'id' ] ) ); |
|
1433 | + $args[ 'options' ][ 'textarea_name' ] = $args[ '_name' ]; |
|
1434 | 1434 | |
1435 | 1435 | return $args; |
1436 | 1436 | } |
@@ -1444,12 +1444,12 @@ discard block |
||
1444 | 1444 | * @return array Modified field config array. |
1445 | 1445 | */ |
1446 | 1446 | protected function set_field_defaults_all_or_nothing_types( $args ) { |
1447 | - $args['show_option_none'] = isset( $args['show_option_none'] ) ? $args['show_option_none'] : null; |
|
1448 | - $args['show_option_none'] = true === $args['show_option_none'] ? esc_html__( 'None', 'cmb2' ) : $args['show_option_none']; |
|
1447 | + $args[ 'show_option_none' ] = isset( $args[ 'show_option_none' ] ) ? $args[ 'show_option_none' ] : null; |
|
1448 | + $args[ 'show_option_none' ] = true === $args[ 'show_option_none' ] ? esc_html__( 'None', 'cmb2' ) : $args[ 'show_option_none' ]; |
|
1449 | 1449 | |
1450 | - if ( null === $args['show_option_none'] ) { |
|
1451 | - $off_by_default = in_array( $args['type'], array( 'select', 'radio', 'radio_inline' ), true ); |
|
1452 | - $args['show_option_none'] = $off_by_default ? false : esc_html__( 'None', 'cmb2' ); |
|
1450 | + if ( null === $args[ 'show_option_none' ] ) { |
|
1451 | + $off_by_default = in_array( $args[ 'type' ], array( 'select', 'radio', 'radio_inline' ), true ); |
|
1452 | + $args[ 'show_option_none' ] = $off_by_default ? false : esc_html__( 'None', 'cmb2' ); |
|
1453 | 1453 | } |
1454 | 1454 | |
1455 | 1455 | return $args; |
@@ -1464,8 +1464,8 @@ discard block |
||
1464 | 1464 | * @return array Modified field config array. |
1465 | 1465 | */ |
1466 | 1466 | protected function set_group_sub_field_defaults( $args ) { |
1467 | - $args['id'] = $this->group->args( 'id' ) . '_' . $this->group->index . '_' . $args['id']; |
|
1468 | - $args['_name'] = $this->group->args( 'id' ) . '[' . $this->group->index . '][' . $args['_name'] . ']'; |
|
1467 | + $args[ 'id' ] = $this->group->args( 'id' ) . '_' . $this->group->index . '_' . $args[ 'id' ]; |
|
1468 | + $args[ '_name' ] = $this->group->args( 'id' ) . '[' . $this->group->index . '][' . $args[ '_name' ] . ']'; |
|
1469 | 1469 | |
1470 | 1470 | return $args; |
1471 | 1471 | } |
@@ -1479,7 +1479,7 @@ discard block |
||
1479 | 1479 | * @return array Field defaults. |
1480 | 1480 | */ |
1481 | 1481 | protected function get_default_field_args( $args ) { |
1482 | - $type = isset( $args['type'] ) ? $args['type'] : ''; |
|
1482 | + $type = isset( $args[ 'type' ] ) ? $args[ 'type' ] : ''; |
|
1483 | 1483 | |
1484 | 1484 | return array( |
1485 | 1485 | 'type' => $type, |
@@ -1506,7 +1506,7 @@ discard block |
||
1506 | 1506 | 'save_field' => true, // Will not save if false. |
1507 | 1507 | 'date_format' => 'm\/d\/Y', |
1508 | 1508 | 'time_format' => 'h:i A', |
1509 | - 'description' => isset( $args['desc'] ) ? $args['desc'] : '', |
|
1509 | + 'description' => isset( $args[ 'desc' ] ) ? $args[ 'desc' ] : '', |
|
1510 | 1510 | 'preview_size' => 'file' === $type ? array( 350, 350 ) : array( 50, 50 ), |
1511 | 1511 | 'render_row_cb' => array( $this, 'render_field_callback' ), |
1512 | 1512 | 'display_cb' => array( $this, 'display_value_callback' ), |
@@ -1528,10 +1528,10 @@ discard block |
||
1528 | 1528 | protected function get_default_args( $field_args, $field_group = null ) { |
1529 | 1529 | $args = parent::get_default_args( array(), $this->group ); |
1530 | 1530 | |
1531 | - if ( isset( $field_args['field_args'] ) ) { |
|
1531 | + if ( isset( $field_args[ 'field_args' ] ) ) { |
|
1532 | 1532 | $args = wp_parse_args( $field_args, $args ); |
1533 | 1533 | } else { |
1534 | - $args['field_args'] = wp_parse_args( $field_args, $this->args ); |
|
1534 | + $args[ 'field_args' ] = wp_parse_args( $field_args, $this->args ); |
|
1535 | 1535 | } |
1536 | 1536 | |
1537 | 1537 | return $args; |
@@ -1575,41 +1575,41 @@ discard block |
||
1575 | 1575 | */ |
1576 | 1576 | protected function convert_deprecated_params( $args ) { |
1577 | 1577 | |
1578 | - if ( isset( $args['row_classes'] ) ) { |
|
1578 | + if ( isset( $args[ 'row_classes' ] ) ) { |
|
1579 | 1579 | |
1580 | 1580 | // We'll let this one be. |
1581 | 1581 | // $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_PARAM, 'row_classes', 'classes' ); |
1582 | 1582 | // row_classes param could be a callback. This is definitely deprecated. |
1583 | - if ( is_callable( $args['row_classes'] ) ) { |
|
1583 | + if ( is_callable( $args[ 'row_classes' ] ) ) { |
|
1584 | 1584 | |
1585 | 1585 | $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_CB_PARAM, 'row_classes', 'classes_cb' ); |
1586 | 1586 | |
1587 | - $args['classes_cb'] = $args['row_classes']; |
|
1588 | - $args['classes'] = null; |
|
1587 | + $args[ 'classes_cb' ] = $args[ 'row_classes' ]; |
|
1588 | + $args[ 'classes' ] = null; |
|
1589 | 1589 | } else { |
1590 | 1590 | |
1591 | - $args['classes'] = $args['row_classes']; |
|
1591 | + $args[ 'classes' ] = $args[ 'row_classes' ]; |
|
1592 | 1592 | } |
1593 | 1593 | |
1594 | - unset( $args['row_classes'] ); |
|
1594 | + unset( $args[ 'row_classes' ] ); |
|
1595 | 1595 | } |
1596 | 1596 | |
1597 | 1597 | // default param can be passed a callback as well. |
1598 | - if ( is_callable( $args['default'] ) ) { |
|
1598 | + if ( is_callable( $args[ 'default' ] ) ) { |
|
1599 | 1599 | |
1600 | 1600 | $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_CB_PARAM, 'default', 'default_cb' ); |
1601 | 1601 | |
1602 | - $args['default_cb'] = $args['default']; |
|
1603 | - $args['default'] = null; |
|
1602 | + $args[ 'default_cb' ] = $args[ 'default' ]; |
|
1603 | + $args[ 'default' ] = null; |
|
1604 | 1604 | } |
1605 | 1605 | |
1606 | 1606 | // options param can be passed a callback as well. |
1607 | - if ( is_callable( $args['options'] ) ) { |
|
1607 | + if ( is_callable( $args[ 'options' ] ) ) { |
|
1608 | 1608 | |
1609 | 1609 | $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_CB_PARAM, 'options', 'options_cb' ); |
1610 | 1610 | |
1611 | - $args['options_cb'] = $args['options']; |
|
1612 | - $args['options'] = array(); |
|
1611 | + $args[ 'options_cb' ] = $args[ 'options' ]; |
|
1612 | + $args[ 'options' ] = array(); |
|
1613 | 1613 | } |
1614 | 1614 | |
1615 | 1615 | return $args; |
@@ -13,35 +13,35 @@ discard block |
||
13 | 13 | |
14 | 14 | private static function get_files( $pattern, $flags = 0, $path = '' ) { |
15 | 15 | |
16 | - if ( ! $path && ( $dir = dirname( $pattern ) ) != '.' ) { |
|
16 | + if ( ! $path && ( $dir = dirname( $pattern ) ) != '.' ) { |
|
17 | 17 | |
18 | - if ($dir == '\\' || $dir == '/') { $dir = ''; } // End IF Statement |
|
18 | + if ($dir == '\\' || $dir == '/') { $dir = ''; } // End IF Statement |
|
19 | 19 | |
20 | - return self::get_files(basename( $pattern ), $flags, $dir . '/' ); |
|
20 | + return self::get_files(basename( $pattern ), $flags, $dir . '/' ); |
|
21 | 21 | |
22 | - } // End IF Statement |
|
23 | - $paths = glob( $path . '*', GLOB_ONLYDIR | GLOB_NOSORT ); |
|
24 | - $files = glob( $path . $pattern, $flags ); |
|
22 | + } // End IF Statement |
|
23 | + $paths = glob( $path . '*', GLOB_ONLYDIR | GLOB_NOSORT ); |
|
24 | + $files = glob( $path . $pattern, $flags ); |
|
25 | 25 | |
26 | - if ( is_array( $paths ) ) { |
|
27 | - foreach ( $paths as $p ) { |
|
28 | - $found_files = array(); |
|
29 | - $retrieved_files = (array) self::get_files( $pattern, $flags, $p . '/' ); |
|
30 | - foreach ( $retrieved_files as $file ) { |
|
31 | - if ( ! in_array( $file, self::$found_files ) ) |
|
32 | - $found_files[] = $file; |
|
33 | - } |
|
26 | + if ( is_array( $paths ) ) { |
|
27 | + foreach ( $paths as $p ) { |
|
28 | + $found_files = array(); |
|
29 | + $retrieved_files = (array) self::get_files( $pattern, $flags, $p . '/' ); |
|
30 | + foreach ( $retrieved_files as $file ) { |
|
31 | + if ( ! in_array( $file, self::$found_files ) ) |
|
32 | + $found_files[] = $file; |
|
33 | + } |
|
34 | 34 | |
35 | - self::$found_files = array_merge( self::$found_files, $found_files ); |
|
35 | + self::$found_files = array_merge( self::$found_files, $found_files ); |
|
36 | 36 | |
37 | - if ( is_array( $files ) && is_array( $found_files ) ) { |
|
38 | - $files = array_merge( $files, $found_files ); |
|
39 | - } |
|
37 | + if ( is_array( $files ) && is_array( $found_files ) ) { |
|
38 | + $files = array_merge( $files, $found_files ); |
|
39 | + } |
|
40 | 40 | |
41 | - } // End FOREACH Loop |
|
42 | - } |
|
43 | - return $files; |
|
44 | - } |
|
41 | + } // End FOREACH Loop |
|
42 | + } |
|
43 | + return $files; |
|
44 | + } |
|
45 | 45 | |
46 | 46 | private static function get_hook_link( $hook, $details = array() ) { |
47 | 47 | if ( ! empty( $details['class'] ) ) { |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | if ( isset( self::$custom_hooks_found[ $hook ] ) ) { |
161 | 161 | self::$custom_hooks_found[ $hook ]['file'][] = self::$current_file; |
162 | 162 | } else { |
163 | - self::$custom_hooks_found[ $hook ] = array( |
|
163 | + self::$custom_hooks_found[ $hook ] = array( |
|
164 | 164 | 'line' => $token[2], |
165 | 165 | 'class' => $current_class, |
166 | 166 | 'function' => $current_function, |
@@ -15,9 +15,9 @@ discard block |
||
15 | 15 | |
16 | 16 | if ( ! $path && ( $dir = dirname( $pattern ) ) != '.' ) { |
17 | 17 | |
18 | - if ($dir == '\\' || $dir == '/') { $dir = ''; } // End IF Statement |
|
18 | + if ( $dir == '\\' || $dir == '/' ) { $dir = ''; } // End IF Statement |
|
19 | 19 | |
20 | - return self::get_files(basename( $pattern ), $flags, $dir . '/' ); |
|
20 | + return self::get_files( basename( $pattern ), $flags, $dir . '/' ); |
|
21 | 21 | |
22 | 22 | } // End IF Statement |
23 | 23 | $paths = glob( $path . '*', GLOB_ONLYDIR | GLOB_NOSORT ); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | $retrieved_files = (array) self::get_files( $pattern, $flags, $p . '/' ); |
30 | 30 | foreach ( $retrieved_files as $file ) { |
31 | 31 | if ( ! in_array( $file, self::$found_files ) ) |
32 | - $found_files[] = $file; |
|
32 | + $found_files[ ] = $file; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | self::$found_files = array_merge( self::$found_files, $found_files ); |
@@ -44,16 +44,16 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | private static function get_hook_link( $hook, $details = array() ) { |
47 | - if ( ! empty( $details['class'] ) ) { |
|
48 | - $link = 'https://cmb2.io/api//source-class-' . $details['class'] . '.html#' . $details['line']; |
|
49 | - } elseif ( ! empty( $details['function'] ) ) { |
|
50 | - $link = 'https://cmb2.io/api//source-function-' . $details['function'] . '.html#' . $details['line']; |
|
47 | + if ( ! empty( $details[ 'class' ] ) ) { |
|
48 | + $link = 'https://cmb2.io/api//source-class-' . $details[ 'class' ] . '.html#' . $details[ 'line' ]; |
|
49 | + } elseif ( ! empty( $details[ 'function' ] ) ) { |
|
50 | + $link = 'https://cmb2.io/api//source-function-' . $details[ 'function' ] . '.html#' . $details[ 'line' ]; |
|
51 | 51 | } else { |
52 | 52 | $link = 'https://github.com/CMB2/CMB2/search?utf8=%E2%9C%93&q=' . $hook; |
53 | 53 | } |
54 | 54 | |
55 | 55 | if ( false !== strpos( $hook, '{' ) || false !== strpos( $hook, '$' ) ) { |
56 | - $hook = '"'. $hook .'"'; |
|
56 | + $hook = '"' . $hook . '"'; |
|
57 | 57 | } else { |
58 | 58 | $hook = "'$hook'"; |
59 | 59 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | public static function process_hooks() { |
65 | 65 | // If we have one, get the PHP files from it. |
66 | 66 | $class_files = self::get_files( '*.php', GLOB_MARK, dirname( __FILE__ ) . '/../includes/' ); |
67 | - $class_files[] = dirname( __FILE__ ) . '/../init.php'; |
|
67 | + $class_files[ ] = dirname( __FILE__ ) . '/../init.php'; |
|
68 | 68 | |
69 | 69 | self::$files_to_scan = array( |
70 | 70 | 'Hooks' => $class_files, |
@@ -91,29 +91,29 @@ discard block |
||
91 | 91 | continue; |
92 | 92 | } |
93 | 93 | |
94 | - $scanned[] = self::$current_file; |
|
94 | + $scanned[ ] = self::$current_file; |
|
95 | 95 | |
96 | 96 | foreach ( $tokens as $index => $token ) { |
97 | 97 | if ( is_array( $token ) ) { |
98 | - if ( $token[0] == T_CLASS ) { |
|
98 | + if ( $token[ 0 ] == T_CLASS ) { |
|
99 | 99 | $token_type = 'class'; |
100 | - } elseif ( $token[0] == T_FUNCTION ) { |
|
100 | + } elseif ( $token[ 0 ] == T_FUNCTION ) { |
|
101 | 101 | $token_type = 'function'; |
102 | - } elseif ( $token[1] === 'do_action' ) { |
|
102 | + } elseif ( $token[ 1 ] === 'do_action' ) { |
|
103 | 103 | $token_type = 'action'; |
104 | - } elseif ( $token[1] === 'apply_filters' ) { |
|
104 | + } elseif ( $token[ 1 ] === 'apply_filters' ) { |
|
105 | 105 | $token_type = 'filter'; |
106 | - } elseif ( $token_type && ! empty( trim( $token[1] ) ) ) { |
|
106 | + } elseif ( $token_type && ! empty( trim( $token[ 1 ] ) ) ) { |
|
107 | 107 | switch ( $token_type ) { |
108 | 108 | case 'class' : |
109 | - $current_class = $token[1]; |
|
109 | + $current_class = $token[ 1 ]; |
|
110 | 110 | break; |
111 | 111 | case 'function' : |
112 | - $current_function = $token[1]; |
|
112 | + $current_function = $token[ 1 ]; |
|
113 | 113 | break; |
114 | 114 | case 'filter' : |
115 | 115 | case 'action' : |
116 | - $hook = trim( $token[1], "'" ); |
|
116 | + $hook = trim( $token[ 1 ], "'" ); |
|
117 | 117 | $loop = 0; |
118 | 118 | |
119 | 119 | if ( '_' === substr( $hook, '-1', 1 ) ) { |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | $open = true; |
122 | 122 | // Keep adding to hook until we find a comma or colon |
123 | 123 | while ( 1 ) { |
124 | - $loop ++; |
|
125 | - $next_hook = trim( trim( is_string( $tokens[ $index + $loop ] ) ? $tokens[ $index + $loop ] : $tokens[ $index + $loop ][1], '"' ), "'" ); |
|
124 | + $loop++; |
|
125 | + $next_hook = trim( trim( is_string( $tokens[ $index + $loop ] ) ? $tokens[ $index + $loop ] : $tokens[ $index + $loop ][ 1 ], '"' ), "'" ); |
|
126 | 126 | |
127 | 127 | if ( in_array( $next_hook, array( '.', '{', '}', '"', "'", ' ' ) ) ) { |
128 | 128 | continue; |
@@ -158,10 +158,10 @@ discard block |
||
158 | 158 | } |
159 | 159 | |
160 | 160 | if ( isset( self::$custom_hooks_found[ $hook ] ) ) { |
161 | - self::$custom_hooks_found[ $hook ]['file'][] = self::$current_file; |
|
161 | + self::$custom_hooks_found[ $hook ][ 'file' ][ ] = self::$current_file; |
|
162 | 162 | } else { |
163 | 163 | self::$custom_hooks_found[ $hook ] = array( |
164 | - 'line' => $token[2], |
|
164 | + 'line' => $token[ 2 ], |
|
165 | 165 | 'class' => $current_class, |
166 | 166 | 'function' => $current_function, |
167 | 167 | 'file' => array( self::$current_file ), |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | foreach ( $actions as $hook => $details ) { |
197 | 197 | echo '<tr> |
198 | 198 | <td>' . self::get_hook_link( $hook, $details ) . '</td> |
199 | - <td>' . implode( ', ', array_unique( $details['file'] ) ) . '</td> |
|
199 | + <td>' . implode( ', ', array_unique( $details[ 'file' ] ) ) . '</td> |
|
200 | 200 | </tr>' . "\n"; |
201 | 201 | } |
202 | 202 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | foreach ( $filters as $hook => $details ) { |
209 | 209 | echo '<tr> |
210 | 210 | <td>' . self::get_hook_link( $hook, $details ) . '</td> |
211 | - <td>' . implode( ', ', array_unique( $details['file'] ) ) . '</td> |
|
211 | + <td>' . implode( ', ', array_unique( $details[ 'file' ] ) ) . '</td> |
|
212 | 212 | </tr>' . "\n"; |
213 | 213 | } |
214 | 214 | |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | if ( ( 'AND' == $operator && $matched == $count ) |
268 | 268 | || ( 'OR' == $operator && $matched > 0 ) |
269 | 269 | || ( 'NOT' == $operator && 0 == $matched ) ) { |
270 | - $filtered[$key] = $obj; |
|
270 | + $filtered[ $key ] = $obj; |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 |
@@ -28,8 +28,9 @@ discard block |
||
28 | 28 | $found_files = array(); |
29 | 29 | $retrieved_files = (array) self::get_files( $pattern, $flags, $p . '/' ); |
30 | 30 | foreach ( $retrieved_files as $file ) { |
31 | - if ( ! in_array( $file, self::$found_files ) ) |
|
32 | - $found_files[] = $file; |
|
31 | + if ( ! in_array( $file, self::$found_files ) ) { |
|
32 | + $found_files[] = $file; |
|
33 | + } |
|
33 | 34 | } |
34 | 35 | |
35 | 36 | self::$found_files = array_merge( self::$found_files, $found_files ); |
@@ -245,11 +246,13 @@ discard block |
||
245 | 246 | * @return array Array of found values. |
246 | 247 | */ |
247 | 248 | protected static function wp_list_filter( $list, $args = array(), $operator = 'AND' ) { |
248 | - if ( ! is_array( $list ) ) |
|
249 | - return array(); |
|
249 | + if ( ! is_array( $list ) ) { |
|
250 | + return array(); |
|
251 | + } |
|
250 | 252 | |
251 | - if ( empty( $args ) ) |
|
252 | - return $list; |
|
253 | + if ( empty( $args ) ) { |
|
254 | + return $list; |
|
255 | + } |
|
253 | 256 | |
254 | 257 | $operator = strtoupper( $operator ); |
255 | 258 | $count = count( $args ); |
@@ -260,8 +263,9 @@ discard block |
||
260 | 263 | |
261 | 264 | $matched = 0; |
262 | 265 | foreach ( $args as $m_key => $m_value ) { |
263 | - if ( array_key_exists( $m_key, $to_match ) && $m_value == $to_match[ $m_key ] ) |
|
264 | - $matched++; |
|
266 | + if ( array_key_exists( $m_key, $to_match ) && $m_value == $to_match[ $m_key ] ) { |
|
267 | + $matched++; |
|
268 | + } |
|
265 | 269 | } |
266 | 270 | |
267 | 271 | if ( ( 'AND' == $operator && $matched == $count ) |