|
@@ -66,7 +66,7 @@ discard block |
|
|
block discarded – undo |
|
66
|
66
|
); |
|
67
|
67
|
|
|
68
|
68
|
// Return options to be used with table/DataTables |
|
69
|
|
- $field_options['table'] = array( |
|
|
69
|
+ $field_options[ 'table' ] = array( |
|
70
|
70
|
'width' => array( |
|
71
|
71
|
'type' => 'number', |
|
72
|
72
|
'label' => __( 'Percent Width', 'gravityview' ), |
|
@@ -138,8 +138,8 @@ discard block |
|
|
block discarded – undo |
|
138
|
138
|
'manage_options' => __( 'Administrator', 'gravityview' ), |
|
139
|
139
|
); |
|
140
|
140
|
|
|
141
|
|
- if( is_multisite() ) { |
|
142
|
|
- $select_cap_choices['manage_network'] = __('Multisite Super Admin', 'gravityview' ); |
|
|
141
|
+ if ( is_multisite() ) { |
|
|
142
|
+ $select_cap_choices[ 'manage_network' ] = __( 'Multisite Super Admin', 'gravityview' ); |
|
143
|
143
|
} |
|
144
|
144
|
|
|
145
|
145
|
/** |
|
@@ -152,7 +152,7 @@ discard block |
|
|
block discarded – undo |
|
152
|
152
|
* @param string $context Optional. What context are we in? Example: `single` or `directory` |
|
153
|
153
|
* @param string $input_type Optional. (textarea, list, select, etc.) |
|
154
|
154
|
*/ |
|
155
|
|
- $select_cap_choices = apply_filters('gravityview_field_visibility_caps', $select_cap_choices, $template_id, $field_id, $context, $input_type ); |
|
|
155
|
+ $select_cap_choices = apply_filters( 'gravityview_field_visibility_caps', $select_cap_choices, $template_id, $field_id, $context, $input_type ); |
|
156
|
156
|
|
|
157
|
157
|
return $select_cap_choices; |
|
158
|
158
|
} |
|
@@ -210,7 +210,7 @@ discard block |
|
|
block discarded – undo |
|
210
|
210
|
|
|
211
|
211
|
$value = isset( $current[ $key ] ) ? $current[ $key ] : null; |
|
212
|
212
|
|
|
213
|
|
- $option['id'] = isset( $option['id'] ) ? $option['id'] : $name_prefix . '[' . $key . ']'; |
|
|
213
|
+ $option[ 'id' ] = isset( $option[ 'id' ] ) ? $option[ 'id' ] : $name_prefix . '[' . $key . ']'; |
|
214
|
214
|
|
|
215
|
215
|
$field_output = self::render_field_option( $name_prefix . '[' . $key . ']', $option, $value ); |
|
216
|
216
|
|
|
@@ -219,7 +219,7 @@ discard block |
|
|
block discarded – undo |
|
219
|
219
|
continue; |
|
220
|
220
|
} |
|
221
|
221
|
|
|
222
|
|
- switch ( $option['type'] ) { |
|
|
222
|
+ switch ( $option[ 'type' ] ) { |
|
223
|
223
|
// Hide hidden fields |
|
224
|
224
|
case 'hidden': |
|
225
|
225
|
$output .= '<div class="gv-setting-container gv-setting-container-' . esc_attr( $key ) . ' screen-reader-text">' . $field_output . '</div>'; |
|
@@ -270,17 +270,17 @@ discard block |
|
|
block discarded – undo |
|
270
|
270
|
* @deprecated setting index 'default' was replaced by 'value' |
|
271
|
271
|
* @see GravityView_FieldType::get_field_defaults |
|
272
|
272
|
*/ |
|
273
|
|
- if( !empty( $option['default'] ) && empty( $option['value'] ) ) { |
|
274
|
|
- $option['value'] = $option['default']; |
|
275
|
|
- _deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[value] instead of [default] when defining the setting '. $name .' details' ); |
|
|
273
|
+ if ( ! empty( $option[ 'default' ] ) && empty( $option[ 'value' ] ) ) { |
|
|
274
|
+ $option[ 'value' ] = $option[ 'default' ]; |
|
|
275
|
+ _deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[value] instead of [default] when defining the setting ' . $name . ' details' ); |
|
276
|
276
|
} |
|
277
|
277
|
|
|
278
|
278
|
// prepare to render option field type |
|
279
|
|
- if( isset( $option['type'] ) ) { |
|
|
279
|
+ if ( isset( $option[ 'type' ] ) ) { |
|
280
|
280
|
|
|
281
|
281
|
$type_class = self::load_type_class( $option ); |
|
282
|
282
|
|
|
283
|
|
- if( class_exists( $type_class ) ) { |
|
|
283
|
+ if ( class_exists( $type_class ) ) { |
|
284
|
284
|
|
|
285
|
285
|
/** @var GravityView_FieldType $render_type */ |
|
286
|
286
|
$render_type = new $type_class( $name, $option, $curr_value ); |
|
@@ -297,7 +297,7 @@ discard block |
|
|
block discarded – undo |
|
297
|
297
|
* @param[in,out] string $output field class name |
|
298
|
298
|
* @param[in] array $option option field data |
|
299
|
299
|
*/ |
|
300
|
|
- $output = apply_filters( "gravityview/option/output/{$option['type']}" , $output, $option ); |
|
|
300
|
+ $output = apply_filters( "gravityview/option/output/{$option[ 'type' ]}", $output, $option ); |
|
301
|
301
|
} |
|
302
|
302
|
|
|
303
|
303
|
} // isset option[type] |
|
@@ -332,27 +332,27 @@ discard block |
|
|
block discarded – undo |
|
332
|
332
|
* @deprecated setting index 'name' was replaced by 'label' |
|
333
|
333
|
* @see GravityView_FieldType::get_field_defaults |
|
334
|
334
|
*/ |
|
335
|
|
- if( isset( $setting['name'] ) && empty( $setting['label'] ) ) { |
|
336
|
|
- $setting['label'] = $setting['name']; |
|
337
|
|
- _deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[label] instead of [name] when defining the setting '. $key .' details' ); |
|
|
335
|
+ if ( isset( $setting[ 'name' ] ) && empty( $setting[ 'label' ] ) ) { |
|
|
336
|
+ $setting[ 'label' ] = $setting[ 'name' ]; |
|
|
337
|
+ _deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[label] instead of [name] when defining the setting ' . $key . ' details' ); |
|
338
|
338
|
} |
|
339
|
339
|
|
|
340
|
340
|
$name = esc_attr( sprintf( $name, $key ) ); |
|
341
|
|
- $setting['id'] = esc_attr( sprintf( $id, $key ) ); |
|
342
|
|
- $setting['tooltip'] = 'gv_' . $key; |
|
|
341
|
+ $setting[ 'id' ] = esc_attr( sprintf( $id, $key ) ); |
|
|
342
|
+ $setting[ 'tooltip' ] = 'gv_' . $key; |
|
343
|
343
|
|
|
344
|
344
|
// Use default if current setting isn't set. |
|
345
|
|
- $curr_value = isset( $current_settings[ $key ] ) ? $current_settings[ $key ] : $setting['value']; |
|
|
345
|
+ $curr_value = isset( $current_settings[ $key ] ) ? $current_settings[ $key ] : $setting[ 'value' ]; |
|
346
|
346
|
|
|
347
|
347
|
// default setting type = text |
|
348
|
|
- $setting['type'] = empty( $setting['type'] ) ? 'text' : $setting['type']; |
|
|
348
|
+ $setting[ 'type' ] = empty( $setting[ 'type' ] ) ? 'text' : $setting[ 'type' ]; |
|
349
|
349
|
|
|
350
|
350
|
// merge tags |
|
351
|
|
- if( !isset( $setting['merge_tags'] ) ) { |
|
352
|
|
- if( $setting['type'] === 'text' ) { |
|
353
|
|
- $setting['merge_tags'] = true; |
|
|
351
|
+ if ( ! isset( $setting[ 'merge_tags' ] ) ) { |
|
|
352
|
+ if ( $setting[ 'type' ] === 'text' ) { |
|
|
353
|
+ $setting[ 'merge_tags' ] = true; |
|
354
|
354
|
} else { |
|
355
|
|
- $setting['merge_tags'] = false; |
|
|
355
|
+ $setting[ 'merge_tags' ] = false; |
|
356
|
356
|
} |
|
357
|
357
|
} |
|
358
|
358
|
|
|
@@ -360,7 +360,7 @@ discard block |
|
|
block discarded – undo |
|
360
|
360
|
|
|
361
|
361
|
// render the setting |
|
362
|
362
|
$type_class = self::load_type_class( $setting ); |
|
363
|
|
- if( class_exists( $type_class ) ) { |
|
|
363
|
+ if ( class_exists( $type_class ) ) { |
|
364
|
364
|
/** @var GravityView_FieldType $render_type */ |
|
365
|
365
|
$render_type = new $type_class( $name, $setting, $curr_value ); |
|
366
|
366
|
ob_start(); |
|
@@ -369,21 +369,21 @@ discard block |
|
|
block discarded – undo |
|
369
|
369
|
} |
|
370
|
370
|
|
|
371
|
371
|
// Check if setting is specific for a template |
|
372
|
|
- if( !empty( $setting['show_in_template'] ) ) { |
|
373
|
|
- if( !is_array( $setting['show_in_template'] ) ) { |
|
374
|
|
- $setting['show_in_template'] = array( $setting['show_in_template'] ); |
|
|
372
|
+ if ( ! empty( $setting[ 'show_in_template' ] ) ) { |
|
|
373
|
+ if ( ! is_array( $setting[ 'show_in_template' ] ) ) { |
|
|
374
|
+ $setting[ 'show_in_template' ] = array( $setting[ 'show_in_template' ] ); |
|
375
|
375
|
} |
|
376
|
|
- $show_if = ' data-show-if="'. implode( ' ', $setting['show_in_template'] ).'"'; |
|
|
376
|
+ $show_if = ' data-show-if="' . implode( ' ', $setting[ 'show_in_template' ] ) . '"'; |
|
377
|
377
|
} else { |
|
378
|
378
|
$show_if = ''; |
|
379
|
379
|
} |
|
380
|
380
|
|
|
381
|
|
- if( ! empty( $setting['requires'] ) ) { |
|
382
|
|
- $show_if .= sprintf( ' data-requires="%s"', $setting['requires'] ); |
|
|
381
|
+ if ( ! empty( $setting[ 'requires' ] ) ) { |
|
|
382
|
+ $show_if .= sprintf( ' data-requires="%s"', $setting[ 'requires' ] ); |
|
383
|
383
|
} |
|
384
|
384
|
|
|
385
|
385
|
// output |
|
386
|
|
- echo '<tr valign="top" '. $show_if .'>' . $output . '</tr>'; |
|
|
386
|
+ echo '<tr valign="top" ' . $show_if . '>' . $output . '</tr>'; |
|
387
|
387
|
|
|
388
|
388
|
} |
|
389
|
389
|
|
|
@@ -395,7 +395,7 @@ discard block |
|
|
block discarded – undo |
|
395
|
395
|
*/ |
|
396
|
396
|
public static function load_type_class( $field = NULL ) { |
|
397
|
397
|
|
|
398
|
|
- if( empty( $field['type'] ) ) { |
|
|
398
|
+ if ( empty( $field[ 'type' ] ) ) { |
|
399
|
399
|
return NULL; |
|
400
|
400
|
} |
|
401
|
401
|
|
|
@@ -404,19 +404,19 @@ discard block |
|
|
block discarded – undo |
|
404
|
404
|
* @param string $class_suffix field class suffix; `GravityView_FieldType_{$class_suffix}` |
|
405
|
405
|
* @param array $field field data |
|
406
|
406
|
*/ |
|
407
|
|
- $type_class = apply_filters( "gravityview/setting/class/{$field['type']}", 'GravityView_FieldType_' . $field['type'], $field ); |
|
|
407
|
+ $type_class = apply_filters( "gravityview/setting/class/{$field[ 'type' ]}", 'GravityView_FieldType_' . $field[ 'type' ], $field ); |
|
408
|
408
|
|
|
409
|
|
- if( !class_exists( $type_class ) ) { |
|
|
409
|
+ if ( ! class_exists( $type_class ) ) { |
|
410
|
410
|
|
|
411
|
411
|
/** |
|
412
|
412
|
* @filter `gravityview/setting/class_file/{field_type}` |
|
413
|
413
|
* @param string $field_type_include_path field class file path |
|
414
|
414
|
* @param array $field field data |
|
415
|
415
|
*/ |
|
416
|
|
- $class_file = apply_filters( "gravityview/setting/class_file/{$field['type']}", GRAVITYVIEW_DIR . "includes/admin/field-types/type_{$field['type']}.php", $field ); |
|
|
416
|
+ $class_file = apply_filters( "gravityview/setting/class_file/{$field[ 'type' ]}", GRAVITYVIEW_DIR . "includes/admin/field-types/type_{$field[ 'type' ]}.php", $field ); |
|
417
|
417
|
|
|
418
|
|
- if( $class_file ) { |
|
419
|
|
- if( file_exists( $class_file ) ) { |
|
|
418
|
+ if ( $class_file ) { |
|
|
419
|
+ if ( file_exists( $class_file ) ) { |
|
420
|
420
|
require_once( $class_file ); |
|
421
|
421
|
} |
|
422
|
422
|
} |
|
@@ -441,8 +441,8 @@ discard block |
|
|
block discarded – undo |
|
441
|
441
|
|
|
442
|
442
|
_deprecated_function( __METHOD__, '1.2', 'GravityView_FieldType_checkbox::render_input' ); |
|
443
|
443
|
|
|
444
|
|
- $output = '<input name="'. esc_attr( $name ) .'" type="hidden" value="0">'; |
|
445
|
|
- $output .= '<input name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" type="checkbox" value="1" '. checked( $current, '1', false ) .' >'; |
|
|
444
|
+ $output = '<input name="' . esc_attr( $name ) . '" type="hidden" value="0">'; |
|
|
445
|
+ $output .= '<input name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" type="checkbox" value="1" ' . checked( $current, '1', false ) . ' >'; |
|
446
|
446
|
|
|
447
|
447
|
return $output; |
|
448
|
448
|
} |
|
@@ -462,22 +462,22 @@ discard block |
|
|
block discarded – undo |
|
462
|
462
|
_deprecated_function( __METHOD__, '1.2', 'GravityView_FieldType_text::render_input' ); |
|
463
|
463
|
|
|
464
|
464
|
// Show the merge tags if the field is a list view |
|
465
|
|
- $is_list = ( preg_match( '/_list-/ism', $name )); |
|
|
465
|
+ $is_list = ( preg_match( '/_list-/ism', $name ) ); |
|
466
|
466
|
|
|
467
|
467
|
// Or is a single entry view |
|
468
|
|
- $is_single = ( preg_match( '/single_/ism', $name )); |
|
|
468
|
+ $is_single = ( preg_match( '/single_/ism', $name ) ); |
|
469
|
469
|
$show = ( $is_single || $is_list ); |
|
470
|
470
|
|
|
471
|
471
|
$class = ''; |
|
472
|
472
|
// and $add_merge_tags is not false |
|
473
|
|
- if( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
|
473
|
+ if ( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
474
|
474
|
$class = 'merge-tag-support mt-position-right mt-hide_all_fields '; |
|
475
|
475
|
} |
|
476
|
476
|
|
|
477
|
|
- $class .= !empty( $args['class'] ) ? $args['class'] : 'widefat'; |
|
478
|
|
- $type = !empty( $args['type'] ) ? $args['type'] : 'text'; |
|
|
477
|
+ $class .= ! empty( $args[ 'class' ] ) ? $args[ 'class' ] : 'widefat'; |
|
|
478
|
+ $type = ! empty( $args[ 'type' ] ) ? $args[ 'type' ] : 'text'; |
|
479
|
479
|
|
|
480
|
|
- return '<input name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" type="'.esc_attr($type).'" value="'. esc_attr( $current ) .'" class="'.esc_attr( $class ).'">'; |
|
|
480
|
+ return '<input name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" type="' . esc_attr( $type ) . '" value="' . esc_attr( $current ) . '" class="' . esc_attr( $class ) . '">'; |
|
481
|
481
|
} |
|
482
|
482
|
|
|
483
|
483
|
/** |
|
@@ -494,21 +494,21 @@ discard block |
|
|
block discarded – undo |
|
494
|
494
|
_deprecated_function( __METHOD__, '1.2', 'GravityView_FieldType_textarea::render_input' ); |
|
495
|
495
|
|
|
496
|
496
|
// Show the merge tags if the field is a list view |
|
497
|
|
- $is_list = ( preg_match( '/_list-/ism', $name )); |
|
|
497
|
+ $is_list = ( preg_match( '/_list-/ism', $name ) ); |
|
498
|
498
|
|
|
499
|
499
|
// Or is a single entry view |
|
500
|
|
- $is_single = ( preg_match( '/single_/ism', $name )); |
|
|
500
|
+ $is_single = ( preg_match( '/single_/ism', $name ) ); |
|
501
|
501
|
$show = ( $is_single || $is_list ); |
|
502
|
502
|
|
|
503
|
503
|
$class = ''; |
|
504
|
504
|
// and $add_merge_tags is not false |
|
505
|
|
- if( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
|
505
|
+ if ( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
506
|
506
|
$class = 'merge-tag-support mt-position-right mt-hide_all_fields '; |
|
507
|
507
|
} |
|
508
|
508
|
|
|
509
|
|
- $class .= !empty( $args['class'] ) ? 'widefat '.$args['class'] : 'widefat'; |
|
|
509
|
+ $class .= ! empty( $args[ 'class' ] ) ? 'widefat ' . $args[ 'class' ] : 'widefat'; |
|
510
|
510
|
|
|
511
|
|
- return '<textarea name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" class="'.esc_attr( $class ).'">'. esc_textarea( $current ) .'</textarea>'; |
|
|
511
|
+ return '<textarea name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" class="' . esc_attr( $class ) . '">' . esc_textarea( $current ) . '</textarea>'; |
|
512
|
512
|
} |
|
513
|
513
|
|
|
514
|
514
|
/** |
|
@@ -524,9 +524,9 @@ discard block |
|
|
block discarded – undo |
|
524
|
524
|
|
|
525
|
525
|
_deprecated_function( __METHOD__, '1.2', 'GravityView_FieldType_select::render_input' ); |
|
526
|
526
|
|
|
527
|
|
- $output = '<select name="'. $name .'" id="'. $id .'">'; |
|
528
|
|
- foreach( $choices as $value => $label ) { |
|
529
|
|
- $output .= '<option value="'. esc_attr( $value ) .'" '. selected( $value, $current, false ) .'>'. esc_html( $label ) .'</option>'; |
|
|
527
|
+ $output = '<select name="' . $name . '" id="' . $id . '">'; |
|
|
528
|
+ foreach ( $choices as $value => $label ) { |
|
|
529
|
+ $output .= '<option value="' . esc_attr( $value ) . '" ' . selected( $value, $current, false ) . '>' . esc_html( $label ) . '</option>'; |
|
530
|
530
|
} |
|
531
|
531
|
$output .= '</select>'; |
|
532
|
532
|
|