@@ -10,116 +10,116 @@ |
||
10 | 10 | */ |
11 | 11 | class GravityView_Field_Consent extends GravityView_Field |
12 | 12 | { |
13 | - public $name = 'consent'; |
|
14 | - |
|
15 | - public $is_searchable = true; |
|
16 | - |
|
17 | - public $search_operators = ['is', 'isnot']; |
|
18 | - |
|
19 | - public $_gf_field_class_name = 'GF_Field_Consent'; |
|
20 | - |
|
21 | - public $group = 'standard'; |
|
22 | - |
|
23 | - public $icon = 'dashicons-text-page'; |
|
24 | - |
|
25 | - public function __construct() |
|
26 | - { |
|
27 | - $this->label = esc_html__('Consent', 'gravityview'); |
|
28 | - |
|
29 | - parent::__construct(); |
|
30 | - |
|
31 | - add_filter('gravityview/template/field/consent/output', [$this, 'field_output'], 10, 2); |
|
32 | - } |
|
33 | - |
|
34 | - /** |
|
35 | - * Returns the value of the consent field based on the field settings. |
|
36 | - * |
|
37 | - * @param string $output Existing default $display_value for the field |
|
38 | - * @param \GV\Template_Context $context |
|
39 | - * |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public function field_output($output, $context) |
|
43 | - { |
|
44 | - $configuration = $context->field->as_configuration(); |
|
45 | - |
|
46 | - /** @var GF_Field_Consent $consent_field */ |
|
47 | - $consent_field = $context->field->field; |
|
48 | - |
|
49 | - switch (\GV\Utils::get($configuration, 'choice_display')) { |
|
50 | - case 'tick': |
|
51 | - return $consent_field->checked_indicator_markup; |
|
52 | - case 'label': |
|
53 | - |
|
54 | - $revision_id = absint(trim($context->value[$context->field->ID.'.3'])); |
|
55 | - |
|
56 | - // Gravity Forms performs a DB query for consent output. Let's reduce queries |
|
57 | - // and cache each version we find. |
|
58 | - static $_consent_field_cache = []; |
|
59 | - $_cache_key = "{$consent_field->formId}_{$consent_field->ID}_{$revision_id}"; |
|
60 | - |
|
61 | - // We have a cache hit! |
|
62 | - if (!empty($_consent_field_cache[$_cache_key])) { |
|
63 | - return $_consent_field_cache[$_cache_key]; |
|
64 | - } |
|
65 | - |
|
66 | - $description = $consent_field->get_field_description_from_revision($revision_id); |
|
67 | - |
|
68 | - // There was no "description" value set when submitted. Use the checkbox value instead. |
|
69 | - if (!$description) { |
|
70 | - $description = $consent_field->checkboxLabel; |
|
71 | - } |
|
72 | - |
|
73 | - $_consent_field_cache[$_cache_key] = $description; |
|
74 | - |
|
75 | - return $description; |
|
76 | - } |
|
77 | - |
|
78 | - return $output; |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * Add `choice_display` setting to the field. |
|
83 | - * |
|
84 | - * @param array $field_options |
|
85 | - * @param string $template_id |
|
86 | - * @param string $field_id |
|
87 | - * @param string $context |
|
88 | - * @param string $input_type |
|
89 | - * |
|
90 | - * @since 1.17 |
|
91 | - * |
|
92 | - * @return array |
|
93 | - */ |
|
94 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
95 | - { |
|
96 | - |
|
97 | - // Set the $_field_id var |
|
98 | - $field_options = parent::field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id); |
|
99 | - |
|
100 | - if (floor($field_id) !== floatval($field_id)) { |
|
101 | - $default = 'tick'; |
|
102 | - } else { |
|
103 | - $default = 'both'; |
|
104 | - } |
|
105 | - |
|
106 | - $field_options['choice_display'] = [ |
|
107 | - 'type' => 'radio', |
|
108 | - 'class' => 'vertical', |
|
109 | - 'label' => __('What should be displayed:', 'gravityview'), |
|
110 | - 'value' => $default, |
|
111 | - 'desc' => '', |
|
112 | - 'choices' => [ |
|
113 | - 'both' => __('Consent image with description', 'gravityview'), |
|
114 | - 'tick' => __('Consent image', 'gravityview'), |
|
115 | - 'label' => __('Consent description', 'gravityview'), |
|
116 | - ], |
|
117 | - 'priorty' => 100, |
|
118 | - 'group' => 'display', |
|
119 | - ]; |
|
120 | - |
|
121 | - return $field_options; |
|
122 | - } |
|
13 | + public $name = 'consent'; |
|
14 | + |
|
15 | + public $is_searchable = true; |
|
16 | + |
|
17 | + public $search_operators = ['is', 'isnot']; |
|
18 | + |
|
19 | + public $_gf_field_class_name = 'GF_Field_Consent'; |
|
20 | + |
|
21 | + public $group = 'standard'; |
|
22 | + |
|
23 | + public $icon = 'dashicons-text-page'; |
|
24 | + |
|
25 | + public function __construct() |
|
26 | + { |
|
27 | + $this->label = esc_html__('Consent', 'gravityview'); |
|
28 | + |
|
29 | + parent::__construct(); |
|
30 | + |
|
31 | + add_filter('gravityview/template/field/consent/output', [$this, 'field_output'], 10, 2); |
|
32 | + } |
|
33 | + |
|
34 | + /** |
|
35 | + * Returns the value of the consent field based on the field settings. |
|
36 | + * |
|
37 | + * @param string $output Existing default $display_value for the field |
|
38 | + * @param \GV\Template_Context $context |
|
39 | + * |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public function field_output($output, $context) |
|
43 | + { |
|
44 | + $configuration = $context->field->as_configuration(); |
|
45 | + |
|
46 | + /** @var GF_Field_Consent $consent_field */ |
|
47 | + $consent_field = $context->field->field; |
|
48 | + |
|
49 | + switch (\GV\Utils::get($configuration, 'choice_display')) { |
|
50 | + case 'tick': |
|
51 | + return $consent_field->checked_indicator_markup; |
|
52 | + case 'label': |
|
53 | + |
|
54 | + $revision_id = absint(trim($context->value[$context->field->ID.'.3'])); |
|
55 | + |
|
56 | + // Gravity Forms performs a DB query for consent output. Let's reduce queries |
|
57 | + // and cache each version we find. |
|
58 | + static $_consent_field_cache = []; |
|
59 | + $_cache_key = "{$consent_field->formId}_{$consent_field->ID}_{$revision_id}"; |
|
60 | + |
|
61 | + // We have a cache hit! |
|
62 | + if (!empty($_consent_field_cache[$_cache_key])) { |
|
63 | + return $_consent_field_cache[$_cache_key]; |
|
64 | + } |
|
65 | + |
|
66 | + $description = $consent_field->get_field_description_from_revision($revision_id); |
|
67 | + |
|
68 | + // There was no "description" value set when submitted. Use the checkbox value instead. |
|
69 | + if (!$description) { |
|
70 | + $description = $consent_field->checkboxLabel; |
|
71 | + } |
|
72 | + |
|
73 | + $_consent_field_cache[$_cache_key] = $description; |
|
74 | + |
|
75 | + return $description; |
|
76 | + } |
|
77 | + |
|
78 | + return $output; |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * Add `choice_display` setting to the field. |
|
83 | + * |
|
84 | + * @param array $field_options |
|
85 | + * @param string $template_id |
|
86 | + * @param string $field_id |
|
87 | + * @param string $context |
|
88 | + * @param string $input_type |
|
89 | + * |
|
90 | + * @since 1.17 |
|
91 | + * |
|
92 | + * @return array |
|
93 | + */ |
|
94 | + public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
95 | + { |
|
96 | + |
|
97 | + // Set the $_field_id var |
|
98 | + $field_options = parent::field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id); |
|
99 | + |
|
100 | + if (floor($field_id) !== floatval($field_id)) { |
|
101 | + $default = 'tick'; |
|
102 | + } else { |
|
103 | + $default = 'both'; |
|
104 | + } |
|
105 | + |
|
106 | + $field_options['choice_display'] = [ |
|
107 | + 'type' => 'radio', |
|
108 | + 'class' => 'vertical', |
|
109 | + 'label' => __('What should be displayed:', 'gravityview'), |
|
110 | + 'value' => $default, |
|
111 | + 'desc' => '', |
|
112 | + 'choices' => [ |
|
113 | + 'both' => __('Consent image with description', 'gravityview'), |
|
114 | + 'tick' => __('Consent image', 'gravityview'), |
|
115 | + 'label' => __('Consent description', 'gravityview'), |
|
116 | + ], |
|
117 | + 'priorty' => 100, |
|
118 | + 'group' => 'display', |
|
119 | + ]; |
|
120 | + |
|
121 | + return $field_options; |
|
122 | + } |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | new GravityView_Field_Consent(); |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | public $is_searchable = true; |
16 | 16 | |
17 | - public $search_operators = ['is', 'isnot']; |
|
17 | + public $search_operators = [ 'is', 'isnot' ]; |
|
18 | 18 | |
19 | 19 | public $_gf_field_class_name = 'GF_Field_Consent'; |
20 | 20 | |
@@ -24,11 +24,11 @@ discard block |
||
24 | 24 | |
25 | 25 | public function __construct() |
26 | 26 | { |
27 | - $this->label = esc_html__('Consent', 'gravityview'); |
|
27 | + $this->label = esc_html__( 'Consent', 'gravityview' ); |
|
28 | 28 | |
29 | 29 | parent::__construct(); |
30 | 30 | |
31 | - add_filter('gravityview/template/field/consent/output', [$this, 'field_output'], 10, 2); |
|
31 | + add_filter( 'gravityview/template/field/consent/output', [ $this, 'field_output' ], 10, 2 ); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -39,38 +39,38 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @return string |
41 | 41 | */ |
42 | - public function field_output($output, $context) |
|
42 | + public function field_output( $output, $context ) |
|
43 | 43 | { |
44 | 44 | $configuration = $context->field->as_configuration(); |
45 | 45 | |
46 | 46 | /** @var GF_Field_Consent $consent_field */ |
47 | 47 | $consent_field = $context->field->field; |
48 | 48 | |
49 | - switch (\GV\Utils::get($configuration, 'choice_display')) { |
|
49 | + switch ( \GV\Utils::get( $configuration, 'choice_display' ) ) { |
|
50 | 50 | case 'tick': |
51 | 51 | return $consent_field->checked_indicator_markup; |
52 | 52 | case 'label': |
53 | 53 | |
54 | - $revision_id = absint(trim($context->value[$context->field->ID.'.3'])); |
|
54 | + $revision_id = absint( trim( $context->value[ $context->field->ID . '.3' ] ) ); |
|
55 | 55 | |
56 | 56 | // Gravity Forms performs a DB query for consent output. Let's reduce queries |
57 | 57 | // and cache each version we find. |
58 | - static $_consent_field_cache = []; |
|
58 | + static $_consent_field_cache = [ ]; |
|
59 | 59 | $_cache_key = "{$consent_field->formId}_{$consent_field->ID}_{$revision_id}"; |
60 | 60 | |
61 | 61 | // We have a cache hit! |
62 | - if (!empty($_consent_field_cache[$_cache_key])) { |
|
63 | - return $_consent_field_cache[$_cache_key]; |
|
62 | + if ( ! empty( $_consent_field_cache[ $_cache_key ] ) ) { |
|
63 | + return $_consent_field_cache[ $_cache_key ]; |
|
64 | 64 | } |
65 | 65 | |
66 | - $description = $consent_field->get_field_description_from_revision($revision_id); |
|
66 | + $description = $consent_field->get_field_description_from_revision( $revision_id ); |
|
67 | 67 | |
68 | 68 | // There was no "description" value set when submitted. Use the checkbox value instead. |
69 | - if (!$description) { |
|
69 | + if ( ! $description ) { |
|
70 | 70 | $description = $consent_field->checkboxLabel; |
71 | 71 | } |
72 | 72 | |
73 | - $_consent_field_cache[$_cache_key] = $description; |
|
73 | + $_consent_field_cache[ $_cache_key ] = $description; |
|
74 | 74 | |
75 | 75 | return $description; |
76 | 76 | } |
@@ -91,28 +91,28 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @return array |
93 | 93 | */ |
94 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
94 | + public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) |
|
95 | 95 | { |
96 | 96 | |
97 | 97 | // Set the $_field_id var |
98 | - $field_options = parent::field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id); |
|
98 | + $field_options = parent::field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ); |
|
99 | 99 | |
100 | - if (floor($field_id) !== floatval($field_id)) { |
|
100 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
101 | 101 | $default = 'tick'; |
102 | 102 | } else { |
103 | 103 | $default = 'both'; |
104 | 104 | } |
105 | 105 | |
106 | - $field_options['choice_display'] = [ |
|
106 | + $field_options[ 'choice_display' ] = [ |
|
107 | 107 | 'type' => 'radio', |
108 | 108 | 'class' => 'vertical', |
109 | - 'label' => __('What should be displayed:', 'gravityview'), |
|
109 | + 'label' => __( 'What should be displayed:', 'gravityview' ), |
|
110 | 110 | 'value' => $default, |
111 | 111 | 'desc' => '', |
112 | 112 | 'choices' => [ |
113 | - 'both' => __('Consent image with description', 'gravityview'), |
|
114 | - 'tick' => __('Consent image', 'gravityview'), |
|
115 | - 'label' => __('Consent description', 'gravityview'), |
|
113 | + 'both' => __( 'Consent image with description', 'gravityview' ), |
|
114 | + 'tick' => __( 'Consent image', 'gravityview' ), |
|
115 | + 'label' => __( 'Consent description', 'gravityview' ), |
|
116 | 116 | ], |
117 | 117 | 'priorty' => 100, |
118 | 118 | 'group' => 'display', |
@@ -8,8 +8,7 @@ discard block |
||
8 | 8 | /** |
9 | 9 | * @since 2.10 |
10 | 10 | */ |
11 | -class GravityView_Field_Consent extends GravityView_Field |
|
12 | -{ |
|
11 | +class GravityView_Field_Consent extends GravityView_Field { |
|
13 | 12 | public $name = 'consent'; |
14 | 13 | |
15 | 14 | public $is_searchable = true; |
@@ -22,8 +21,7 @@ discard block |
||
22 | 21 | |
23 | 22 | public $icon = 'dashicons-text-page'; |
24 | 23 | |
25 | - public function __construct() |
|
26 | - { |
|
24 | + public function __construct() { |
|
27 | 25 | $this->label = esc_html__('Consent', 'gravityview'); |
28 | 26 | |
29 | 27 | parent::__construct(); |
@@ -39,8 +37,7 @@ discard block |
||
39 | 37 | * |
40 | 38 | * @return string |
41 | 39 | */ |
42 | - public function field_output($output, $context) |
|
43 | - { |
|
40 | + public function field_output($output, $context) { |
|
44 | 41 | $configuration = $context->field->as_configuration(); |
45 | 42 | |
46 | 43 | /** @var GF_Field_Consent $consent_field */ |
@@ -91,8 +88,7 @@ discard block |
||
91 | 88 | * |
92 | 89 | * @return array |
93 | 90 | */ |
94 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
95 | - { |
|
91 | + public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) { |
|
96 | 92 | |
97 | 93 | // Set the $_field_id var |
98 | 94 | $field_options = parent::field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id); |
@@ -12,46 +12,46 @@ |
||
12 | 12 | */ |
13 | 13 | class GravityView_Field_Number extends GravityView_Field |
14 | 14 | { |
15 | - public $name = 'number'; |
|
16 | - |
|
17 | - public $is_searchable = true; |
|
18 | - |
|
19 | - public $search_operators = ['is', 'isnot', 'greater_than', 'less_than']; |
|
20 | - |
|
21 | - /** @see GF_Field_Number */ |
|
22 | - public $_gf_field_class_name = 'GF_Field_Number'; |
|
23 | - |
|
24 | - public $group = 'standard'; |
|
25 | - |
|
26 | - public $icon = 'dashicons-editor-ol'; |
|
27 | - |
|
28 | - public function __construct() |
|
29 | - { |
|
30 | - $this->label = esc_html__('Number', 'gravityview'); |
|
31 | - parent::__construct(); |
|
32 | - } |
|
33 | - |
|
34 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
35 | - { |
|
36 | - $field_options['number_format'] = [ |
|
37 | - 'type' => 'checkbox', |
|
38 | - 'label' => __('Format number?', 'gravityview'), |
|
39 | - 'desc' => __('Display numbers with thousands separators.', 'gravityview'), |
|
40 | - 'value' => false, |
|
41 | - 'group' => 'field', |
|
42 | - ]; |
|
43 | - |
|
44 | - $field_options['decimals'] = [ |
|
45 | - 'type' => 'number', |
|
46 | - 'label' => __('Decimals', 'gravityview'), |
|
47 | - 'desc' => __('Precision of the number of decimal places. Leave blank to use existing precision.', 'gravityview'), |
|
48 | - 'value' => '', |
|
49 | - 'merge_tags' => false, |
|
50 | - 'group' => 'field', |
|
51 | - ]; |
|
52 | - |
|
53 | - return $field_options; |
|
54 | - } |
|
15 | + public $name = 'number'; |
|
16 | + |
|
17 | + public $is_searchable = true; |
|
18 | + |
|
19 | + public $search_operators = ['is', 'isnot', 'greater_than', 'less_than']; |
|
20 | + |
|
21 | + /** @see GF_Field_Number */ |
|
22 | + public $_gf_field_class_name = 'GF_Field_Number'; |
|
23 | + |
|
24 | + public $group = 'standard'; |
|
25 | + |
|
26 | + public $icon = 'dashicons-editor-ol'; |
|
27 | + |
|
28 | + public function __construct() |
|
29 | + { |
|
30 | + $this->label = esc_html__('Number', 'gravityview'); |
|
31 | + parent::__construct(); |
|
32 | + } |
|
33 | + |
|
34 | + public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
35 | + { |
|
36 | + $field_options['number_format'] = [ |
|
37 | + 'type' => 'checkbox', |
|
38 | + 'label' => __('Format number?', 'gravityview'), |
|
39 | + 'desc' => __('Display numbers with thousands separators.', 'gravityview'), |
|
40 | + 'value' => false, |
|
41 | + 'group' => 'field', |
|
42 | + ]; |
|
43 | + |
|
44 | + $field_options['decimals'] = [ |
|
45 | + 'type' => 'number', |
|
46 | + 'label' => __('Decimals', 'gravityview'), |
|
47 | + 'desc' => __('Precision of the number of decimal places. Leave blank to use existing precision.', 'gravityview'), |
|
48 | + 'value' => '', |
|
49 | + 'merge_tags' => false, |
|
50 | + 'group' => 'field', |
|
51 | + ]; |
|
52 | + |
|
53 | + return $field_options; |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | new GravityView_Field_Number(); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | |
17 | 17 | public $is_searchable = true; |
18 | 18 | |
19 | - public $search_operators = ['is', 'isnot', 'greater_than', 'less_than']; |
|
19 | + public $search_operators = [ 'is', 'isnot', 'greater_than', 'less_than' ]; |
|
20 | 20 | |
21 | 21 | /** @see GF_Field_Number */ |
22 | 22 | public $_gf_field_class_name = 'GF_Field_Number'; |
@@ -27,24 +27,24 @@ discard block |
||
27 | 27 | |
28 | 28 | public function __construct() |
29 | 29 | { |
30 | - $this->label = esc_html__('Number', 'gravityview'); |
|
30 | + $this->label = esc_html__( 'Number', 'gravityview' ); |
|
31 | 31 | parent::__construct(); |
32 | 32 | } |
33 | 33 | |
34 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
34 | + public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) |
|
35 | 35 | { |
36 | - $field_options['number_format'] = [ |
|
36 | + $field_options[ 'number_format' ] = [ |
|
37 | 37 | 'type' => 'checkbox', |
38 | - 'label' => __('Format number?', 'gravityview'), |
|
39 | - 'desc' => __('Display numbers with thousands separators.', 'gravityview'), |
|
38 | + 'label' => __( 'Format number?', 'gravityview' ), |
|
39 | + 'desc' => __( 'Display numbers with thousands separators.', 'gravityview' ), |
|
40 | 40 | 'value' => false, |
41 | 41 | 'group' => 'field', |
42 | 42 | ]; |
43 | 43 | |
44 | - $field_options['decimals'] = [ |
|
44 | + $field_options[ 'decimals' ] = [ |
|
45 | 45 | 'type' => 'number', |
46 | - 'label' => __('Decimals', 'gravityview'), |
|
47 | - 'desc' => __('Precision of the number of decimal places. Leave blank to use existing precision.', 'gravityview'), |
|
46 | + 'label' => __( 'Decimals', 'gravityview' ), |
|
47 | + 'desc' => __( 'Precision of the number of decimal places. Leave blank to use existing precision.', 'gravityview' ), |
|
48 | 48 | 'value' => '', |
49 | 49 | 'merge_tags' => false, |
50 | 50 | 'group' => 'field', |
@@ -10,8 +10,7 @@ discard block |
||
10 | 10 | * |
11 | 11 | * @since 1.13 |
12 | 12 | */ |
13 | -class GravityView_Field_Number extends GravityView_Field |
|
14 | -{ |
|
13 | +class GravityView_Field_Number extends GravityView_Field { |
|
15 | 14 | public $name = 'number'; |
16 | 15 | |
17 | 16 | public $is_searchable = true; |
@@ -25,14 +24,12 @@ discard block |
||
25 | 24 | |
26 | 25 | public $icon = 'dashicons-editor-ol'; |
27 | 26 | |
28 | - public function __construct() |
|
29 | - { |
|
27 | + public function __construct() { |
|
30 | 28 | $this->label = esc_html__('Number', 'gravityview'); |
31 | 29 | parent::__construct(); |
32 | 30 | } |
33 | 31 | |
34 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
35 | - { |
|
32 | + public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) { |
|
36 | 33 | $field_options['number_format'] = [ |
37 | 34 | 'type' => 'checkbox', |
38 | 35 | 'label' => __('Format number?', 'gravityview'), |
@@ -4,55 +4,55 @@ |
||
4 | 4 | */ |
5 | 5 | class GravityView_Field_Phone extends GravityView_Field |
6 | 6 | { |
7 | - public $name = 'phone'; |
|
8 | - |
|
9 | - public $is_searchable = true; |
|
10 | - |
|
11 | - public $search_operators = ['is', 'isnot', 'contains', 'starts_with', 'ends_with']; |
|
12 | - |
|
13 | - /** @see GF_Field_Phone */ |
|
14 | - public $_gf_field_class_name = 'GF_Field_Phone'; |
|
15 | - |
|
16 | - public $group = 'advanced'; |
|
17 | - |
|
18 | - public $icon = 'dashicons-smartphone'; |
|
19 | - |
|
20 | - public function __construct() |
|
21 | - { |
|
22 | - $this->label = esc_html__('Phone', 'gravityview'); |
|
23 | - parent::__construct(); |
|
24 | - } |
|
25 | - |
|
26 | - /** |
|
27 | - * Add option to link phone number. |
|
28 | - * |
|
29 | - * @since 1.17 |
|
30 | - * |
|
31 | - * @param array $field_options |
|
32 | - * @param string $template_id |
|
33 | - * @param string $field_id |
|
34 | - * @param string $context |
|
35 | - * @param string $input_type |
|
36 | - * |
|
37 | - * @return array |
|
38 | - */ |
|
39 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
40 | - { |
|
41 | - if ('edit' === $context) { |
|
42 | - return $field_options; |
|
43 | - } |
|
44 | - |
|
45 | - $field_options['link_phone'] = [ |
|
46 | - 'type' => 'checkbox', |
|
47 | - 'label' => __('Make Phone Number Clickable', 'gravityview'), |
|
48 | - 'desc' => __('Allow dialing a number by clicking it?', 'gravityview'), |
|
49 | - 'value' => true, |
|
50 | - 'group' => 'display', |
|
51 | - 'priority' => 100, |
|
52 | - ]; |
|
53 | - |
|
54 | - return $field_options; |
|
55 | - } |
|
7 | + public $name = 'phone'; |
|
8 | + |
|
9 | + public $is_searchable = true; |
|
10 | + |
|
11 | + public $search_operators = ['is', 'isnot', 'contains', 'starts_with', 'ends_with']; |
|
12 | + |
|
13 | + /** @see GF_Field_Phone */ |
|
14 | + public $_gf_field_class_name = 'GF_Field_Phone'; |
|
15 | + |
|
16 | + public $group = 'advanced'; |
|
17 | + |
|
18 | + public $icon = 'dashicons-smartphone'; |
|
19 | + |
|
20 | + public function __construct() |
|
21 | + { |
|
22 | + $this->label = esc_html__('Phone', 'gravityview'); |
|
23 | + parent::__construct(); |
|
24 | + } |
|
25 | + |
|
26 | + /** |
|
27 | + * Add option to link phone number. |
|
28 | + * |
|
29 | + * @since 1.17 |
|
30 | + * |
|
31 | + * @param array $field_options |
|
32 | + * @param string $template_id |
|
33 | + * @param string $field_id |
|
34 | + * @param string $context |
|
35 | + * @param string $input_type |
|
36 | + * |
|
37 | + * @return array |
|
38 | + */ |
|
39 | + public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
40 | + { |
|
41 | + if ('edit' === $context) { |
|
42 | + return $field_options; |
|
43 | + } |
|
44 | + |
|
45 | + $field_options['link_phone'] = [ |
|
46 | + 'type' => 'checkbox', |
|
47 | + 'label' => __('Make Phone Number Clickable', 'gravityview'), |
|
48 | + 'desc' => __('Allow dialing a number by clicking it?', 'gravityview'), |
|
49 | + 'value' => true, |
|
50 | + 'group' => 'display', |
|
51 | + 'priority' => 100, |
|
52 | + ]; |
|
53 | + |
|
54 | + return $field_options; |
|
55 | + } |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | new GravityView_Field_Phone(); |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | public $is_searchable = true; |
10 | 10 | |
11 | - public $search_operators = ['is', 'isnot', 'contains', 'starts_with', 'ends_with']; |
|
11 | + public $search_operators = [ 'is', 'isnot', 'contains', 'starts_with', 'ends_with' ]; |
|
12 | 12 | |
13 | 13 | /** @see GF_Field_Phone */ |
14 | 14 | public $_gf_field_class_name = 'GF_Field_Phone'; |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | public function __construct() |
21 | 21 | { |
22 | - $this->label = esc_html__('Phone', 'gravityview'); |
|
22 | + $this->label = esc_html__( 'Phone', 'gravityview' ); |
|
23 | 23 | parent::__construct(); |
24 | 24 | } |
25 | 25 | |
@@ -36,16 +36,16 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @return array |
38 | 38 | */ |
39 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
39 | + public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) |
|
40 | 40 | { |
41 | - if ('edit' === $context) { |
|
41 | + if ( 'edit' === $context ) { |
|
42 | 42 | return $field_options; |
43 | 43 | } |
44 | 44 | |
45 | - $field_options['link_phone'] = [ |
|
45 | + $field_options[ 'link_phone' ] = [ |
|
46 | 46 | 'type' => 'checkbox', |
47 | - 'label' => __('Make Phone Number Clickable', 'gravityview'), |
|
48 | - 'desc' => __('Allow dialing a number by clicking it?', 'gravityview'), |
|
47 | + 'label' => __( 'Make Phone Number Clickable', 'gravityview' ), |
|
48 | + 'desc' => __( 'Allow dialing a number by clicking it?', 'gravityview' ), |
|
49 | 49 | 'value' => true, |
50 | 50 | 'group' => 'display', |
51 | 51 | 'priority' => 100, |
@@ -2,8 +2,7 @@ discard block |
||
2 | 2 | /** |
3 | 3 | * @file class-gravityview-field-phone.php |
4 | 4 | */ |
5 | -class GravityView_Field_Phone extends GravityView_Field |
|
6 | -{ |
|
5 | +class GravityView_Field_Phone extends GravityView_Field { |
|
7 | 6 | public $name = 'phone'; |
8 | 7 | |
9 | 8 | public $is_searchable = true; |
@@ -17,8 +16,7 @@ discard block |
||
17 | 16 | |
18 | 17 | public $icon = 'dashicons-smartphone'; |
19 | 18 | |
20 | - public function __construct() |
|
21 | - { |
|
19 | + public function __construct() { |
|
22 | 20 | $this->label = esc_html__('Phone', 'gravityview'); |
23 | 21 | parent::__construct(); |
24 | 22 | } |
@@ -36,8 +34,7 @@ discard block |
||
36 | 34 | * |
37 | 35 | * @return array |
38 | 36 | */ |
39 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
40 | - { |
|
37 | + public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) { |
|
41 | 38 | if ('edit' === $context) { |
42 | 39 | return $field_options; |
43 | 40 | } |
@@ -4,194 +4,194 @@ |
||
4 | 4 | */ |
5 | 5 | class GravityView_Field_Is_Approved extends GravityView_Field |
6 | 6 | { |
7 | - public $name = 'is_approved'; |
|
8 | - |
|
9 | - public $search_operators = ['is', 'isnot']; |
|
10 | - |
|
11 | - public $contexts = ['single', 'multiple']; |
|
12 | - |
|
13 | - public $group = 'meta'; |
|
14 | - |
|
15 | - public $is_sortable = true; |
|
16 | - |
|
17 | - public $is_numeric = true; |
|
18 | - |
|
19 | - public $is_searchable = true; |
|
20 | - |
|
21 | - /** |
|
22 | - * @var string Approval status is stored in entry meta under this key |
|
23 | - * |
|
24 | - * @since 1.18 |
|
25 | - */ |
|
26 | - public $entry_meta_key = 'is_approved'; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var bool Don't add to the "columns to display" list; GravityView adds our own approval column |
|
30 | - * |
|
31 | - * @since 1.18 |
|
32 | - */ |
|
33 | - public $entry_meta_is_default_column = false; |
|
34 | - |
|
35 | - public $_custom_merge_tag = 'approval_status'; |
|
36 | - |
|
37 | - public $icon = 'dashicons-yes-alt'; |
|
38 | - |
|
39 | - public function __construct() |
|
40 | - { |
|
41 | - $this->label = esc_html__('Approval Status', 'gravityview'); |
|
42 | - $this->description = esc_html__('Display the entry\'s current approval status.', 'gravityview'); |
|
43 | - $this->default_search_label = __('Approval:', 'gravityview'); |
|
44 | - |
|
45 | - $this->add_hooks(); |
|
46 | - |
|
47 | - parent::__construct(); |
|
48 | - } |
|
49 | - |
|
50 | - private function add_hooks() |
|
51 | - { |
|
52 | - add_filter('gravityview_entry_default_fields', [$this, 'add_default_field'], 10, 3); |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * Convert entry approval status value to label in the field output. Uses labels from the field setting. |
|
57 | - * |
|
58 | - * @since 2.10 |
|
59 | - * |
|
60 | - * @param string $approval_status Status to pass to {@see GravityView_Entry_Approval_Status::maybe_convert_status} |
|
61 | - * @param bool $html Whether to return HTML or plaintext string value |
|
62 | - * |
|
63 | - * @return string The field setting label for the current status. Uses defaults, if not configured. |
|
64 | - */ |
|
65 | - public static function get_output($approval_status = '', $field_settings = [], $html = false) |
|
66 | - { |
|
67 | - $status = GravityView_Entry_Approval_Status::maybe_convert_status($approval_status); |
|
68 | - $status_key = GravityView_Entry_Approval_Status::get_key($status); |
|
69 | - |
|
70 | - // "approved_label", "unapproved_label", "disapproved_label" setting keys |
|
71 | - $field_setting_key = sprintf('%s_label', $status_key); |
|
72 | - |
|
73 | - $default_label = GravityView_Entry_Approval_Status::get_label($status); |
|
74 | - |
|
75 | - $value = \GV\Utils::get($field_settings, $field_setting_key, $default_label); |
|
76 | - if (empty($value)) { |
|
77 | - $value = $default_label; |
|
78 | - } |
|
79 | - |
|
80 | - if (!$html) { |
|
81 | - return $value; |
|
82 | - } |
|
83 | - |
|
84 | - return sprintf('<span class="gv-approval-%s">%s</span>', esc_attr($status_key), $value); |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * @filter `gravityview_entry_default_fields` |
|
89 | - * |
|
90 | - * @param array $entry_default_fields Array of fields shown by default |
|
91 | - * @param string|array $form form_ID or form object |
|
92 | - * @param string $zone Either 'single', 'directory', 'header', 'footer' |
|
93 | - * |
|
94 | - * @return array |
|
95 | - */ |
|
96 | - public function add_default_field($entry_default_fields, $form, $zone) |
|
97 | - { |
|
98 | - if ('edit' !== $zone) { |
|
99 | - $entry_default_fields[$this->name] = [ |
|
100 | - 'label' => $this->label, |
|
101 | - 'desc' => $this->description, |
|
102 | - 'type' => $this->name, |
|
103 | - ]; |
|
104 | - } |
|
105 | - |
|
106 | - return $entry_default_fields; |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * Add custom merge tags to merge tag options. |
|
111 | - * |
|
112 | - * @since 1.16 |
|
113 | - * |
|
114 | - * @param array $form GF Form array |
|
115 | - * @param GF_Field[] $fields Array of fields in the form |
|
116 | - * |
|
117 | - * @return array Modified merge tags |
|
118 | - */ |
|
119 | - protected function custom_merge_tags($form = [], $fields = []) |
|
120 | - { |
|
121 | - $merge_tags = [ |
|
122 | - [ |
|
123 | - 'label' => __('Approval Status', 'gravityview'), |
|
124 | - 'tag' => '{approval_status}', |
|
125 | - ], |
|
126 | - ]; |
|
127 | - |
|
128 | - return $merge_tags; |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * Display the approval status of an entry. |
|
133 | - * |
|
134 | - * @see https://docs.gravityview.co/article/389-approvalstatus-merge-tag Read how to use the `{approval_status}` merge tag |
|
135 | - * @since 1.18 |
|
136 | - * |
|
137 | - * @param array $matches Array of Merge Tag matches found in text by preg_match_all |
|
138 | - * @param string $text Text to replace |
|
139 | - * @param array $form Gravity Forms form array |
|
140 | - * @param array $entry Entry array |
|
141 | - * @param bool $url_encode Whether to URL-encode output |
|
142 | - * @param bool $esc_html Whether to apply `esc_html()` to output |
|
143 | - * |
|
144 | - * @return string Text, with user variables replaced, if they existed |
|
145 | - */ |
|
146 | - public function replace_merge_tag($matches = [], $text = '', $form = [], $entry = [], $url_encode = false, $esc_html = false) |
|
147 | - { |
|
148 | - $return = $text; |
|
149 | - |
|
150 | - /** |
|
151 | - * @var array $match { |
|
152 | - * @var string $match[0] Full matched merge tag ("{gv_approval}") |
|
153 | - * @var string $match[1] Modifier ("value", "label", or empty string) |
|
154 | - * } |
|
155 | - */ |
|
156 | - foreach ($matches as $match) { |
|
157 | - if (empty($entry)) { |
|
158 | - gravityview()->log->error('No entry data available. Returning empty string.'); |
|
159 | - $replacement = ''; |
|
160 | - } else { |
|
161 | - $replacement = GravityView_Entry_Approval::get_entry_status($entry, $match[1]); |
|
162 | - } |
|
163 | - |
|
164 | - $return = str_replace($match[0], $replacement, $return); |
|
165 | - } |
|
166 | - |
|
167 | - return $return; |
|
168 | - } |
|
169 | - |
|
170 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
171 | - { |
|
172 | - $field_options['approved_label'] = [ |
|
173 | - 'type' => 'text', |
|
174 | - 'label' => __('Approved Label', 'gravityview'), |
|
175 | - 'desc' => __('If the entry is approved, display this value', 'gravityview'), |
|
176 | - 'placeholder' => GravityView_Entry_Approval_Status::get_label('approved'), |
|
177 | - ]; |
|
178 | - |
|
179 | - $field_options['disapproved_label'] = [ |
|
180 | - 'type' => 'text', |
|
181 | - 'label' => __('Disapproved Label', 'gravityview'), |
|
182 | - 'desc' => __('If the entry is not approved, display this value', 'gravityview'), |
|
183 | - 'placeholder' => GravityView_Entry_Approval_Status::get_label('disapproved'), |
|
184 | - ]; |
|
185 | - |
|
186 | - $field_options['unapproved_label'] = [ |
|
187 | - 'type' => 'text', |
|
188 | - 'label' => __('Unapproved Label', 'gravityview'), |
|
189 | - 'desc' => __('If the entry has not yet been approved or disapproved, display this value', 'gravityview'), |
|
190 | - 'placeholder' => GravityView_Entry_Approval_Status::get_label('unapproved'), |
|
191 | - ]; |
|
192 | - |
|
193 | - return $field_options; |
|
194 | - } |
|
7 | + public $name = 'is_approved'; |
|
8 | + |
|
9 | + public $search_operators = ['is', 'isnot']; |
|
10 | + |
|
11 | + public $contexts = ['single', 'multiple']; |
|
12 | + |
|
13 | + public $group = 'meta'; |
|
14 | + |
|
15 | + public $is_sortable = true; |
|
16 | + |
|
17 | + public $is_numeric = true; |
|
18 | + |
|
19 | + public $is_searchable = true; |
|
20 | + |
|
21 | + /** |
|
22 | + * @var string Approval status is stored in entry meta under this key |
|
23 | + * |
|
24 | + * @since 1.18 |
|
25 | + */ |
|
26 | + public $entry_meta_key = 'is_approved'; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var bool Don't add to the "columns to display" list; GravityView adds our own approval column |
|
30 | + * |
|
31 | + * @since 1.18 |
|
32 | + */ |
|
33 | + public $entry_meta_is_default_column = false; |
|
34 | + |
|
35 | + public $_custom_merge_tag = 'approval_status'; |
|
36 | + |
|
37 | + public $icon = 'dashicons-yes-alt'; |
|
38 | + |
|
39 | + public function __construct() |
|
40 | + { |
|
41 | + $this->label = esc_html__('Approval Status', 'gravityview'); |
|
42 | + $this->description = esc_html__('Display the entry\'s current approval status.', 'gravityview'); |
|
43 | + $this->default_search_label = __('Approval:', 'gravityview'); |
|
44 | + |
|
45 | + $this->add_hooks(); |
|
46 | + |
|
47 | + parent::__construct(); |
|
48 | + } |
|
49 | + |
|
50 | + private function add_hooks() |
|
51 | + { |
|
52 | + add_filter('gravityview_entry_default_fields', [$this, 'add_default_field'], 10, 3); |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * Convert entry approval status value to label in the field output. Uses labels from the field setting. |
|
57 | + * |
|
58 | + * @since 2.10 |
|
59 | + * |
|
60 | + * @param string $approval_status Status to pass to {@see GravityView_Entry_Approval_Status::maybe_convert_status} |
|
61 | + * @param bool $html Whether to return HTML or plaintext string value |
|
62 | + * |
|
63 | + * @return string The field setting label for the current status. Uses defaults, if not configured. |
|
64 | + */ |
|
65 | + public static function get_output($approval_status = '', $field_settings = [], $html = false) |
|
66 | + { |
|
67 | + $status = GravityView_Entry_Approval_Status::maybe_convert_status($approval_status); |
|
68 | + $status_key = GravityView_Entry_Approval_Status::get_key($status); |
|
69 | + |
|
70 | + // "approved_label", "unapproved_label", "disapproved_label" setting keys |
|
71 | + $field_setting_key = sprintf('%s_label', $status_key); |
|
72 | + |
|
73 | + $default_label = GravityView_Entry_Approval_Status::get_label($status); |
|
74 | + |
|
75 | + $value = \GV\Utils::get($field_settings, $field_setting_key, $default_label); |
|
76 | + if (empty($value)) { |
|
77 | + $value = $default_label; |
|
78 | + } |
|
79 | + |
|
80 | + if (!$html) { |
|
81 | + return $value; |
|
82 | + } |
|
83 | + |
|
84 | + return sprintf('<span class="gv-approval-%s">%s</span>', esc_attr($status_key), $value); |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * @filter `gravityview_entry_default_fields` |
|
89 | + * |
|
90 | + * @param array $entry_default_fields Array of fields shown by default |
|
91 | + * @param string|array $form form_ID or form object |
|
92 | + * @param string $zone Either 'single', 'directory', 'header', 'footer' |
|
93 | + * |
|
94 | + * @return array |
|
95 | + */ |
|
96 | + public function add_default_field($entry_default_fields, $form, $zone) |
|
97 | + { |
|
98 | + if ('edit' !== $zone) { |
|
99 | + $entry_default_fields[$this->name] = [ |
|
100 | + 'label' => $this->label, |
|
101 | + 'desc' => $this->description, |
|
102 | + 'type' => $this->name, |
|
103 | + ]; |
|
104 | + } |
|
105 | + |
|
106 | + return $entry_default_fields; |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * Add custom merge tags to merge tag options. |
|
111 | + * |
|
112 | + * @since 1.16 |
|
113 | + * |
|
114 | + * @param array $form GF Form array |
|
115 | + * @param GF_Field[] $fields Array of fields in the form |
|
116 | + * |
|
117 | + * @return array Modified merge tags |
|
118 | + */ |
|
119 | + protected function custom_merge_tags($form = [], $fields = []) |
|
120 | + { |
|
121 | + $merge_tags = [ |
|
122 | + [ |
|
123 | + 'label' => __('Approval Status', 'gravityview'), |
|
124 | + 'tag' => '{approval_status}', |
|
125 | + ], |
|
126 | + ]; |
|
127 | + |
|
128 | + return $merge_tags; |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * Display the approval status of an entry. |
|
133 | + * |
|
134 | + * @see https://docs.gravityview.co/article/389-approvalstatus-merge-tag Read how to use the `{approval_status}` merge tag |
|
135 | + * @since 1.18 |
|
136 | + * |
|
137 | + * @param array $matches Array of Merge Tag matches found in text by preg_match_all |
|
138 | + * @param string $text Text to replace |
|
139 | + * @param array $form Gravity Forms form array |
|
140 | + * @param array $entry Entry array |
|
141 | + * @param bool $url_encode Whether to URL-encode output |
|
142 | + * @param bool $esc_html Whether to apply `esc_html()` to output |
|
143 | + * |
|
144 | + * @return string Text, with user variables replaced, if they existed |
|
145 | + */ |
|
146 | + public function replace_merge_tag($matches = [], $text = '', $form = [], $entry = [], $url_encode = false, $esc_html = false) |
|
147 | + { |
|
148 | + $return = $text; |
|
149 | + |
|
150 | + /** |
|
151 | + * @var array $match { |
|
152 | + * @var string $match[0] Full matched merge tag ("{gv_approval}") |
|
153 | + * @var string $match[1] Modifier ("value", "label", or empty string) |
|
154 | + * } |
|
155 | + */ |
|
156 | + foreach ($matches as $match) { |
|
157 | + if (empty($entry)) { |
|
158 | + gravityview()->log->error('No entry data available. Returning empty string.'); |
|
159 | + $replacement = ''; |
|
160 | + } else { |
|
161 | + $replacement = GravityView_Entry_Approval::get_entry_status($entry, $match[1]); |
|
162 | + } |
|
163 | + |
|
164 | + $return = str_replace($match[0], $replacement, $return); |
|
165 | + } |
|
166 | + |
|
167 | + return $return; |
|
168 | + } |
|
169 | + |
|
170 | + public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
171 | + { |
|
172 | + $field_options['approved_label'] = [ |
|
173 | + 'type' => 'text', |
|
174 | + 'label' => __('Approved Label', 'gravityview'), |
|
175 | + 'desc' => __('If the entry is approved, display this value', 'gravityview'), |
|
176 | + 'placeholder' => GravityView_Entry_Approval_Status::get_label('approved'), |
|
177 | + ]; |
|
178 | + |
|
179 | + $field_options['disapproved_label'] = [ |
|
180 | + 'type' => 'text', |
|
181 | + 'label' => __('Disapproved Label', 'gravityview'), |
|
182 | + 'desc' => __('If the entry is not approved, display this value', 'gravityview'), |
|
183 | + 'placeholder' => GravityView_Entry_Approval_Status::get_label('disapproved'), |
|
184 | + ]; |
|
185 | + |
|
186 | + $field_options['unapproved_label'] = [ |
|
187 | + 'type' => 'text', |
|
188 | + 'label' => __('Unapproved Label', 'gravityview'), |
|
189 | + 'desc' => __('If the entry has not yet been approved or disapproved, display this value', 'gravityview'), |
|
190 | + 'placeholder' => GravityView_Entry_Approval_Status::get_label('unapproved'), |
|
191 | + ]; |
|
192 | + |
|
193 | + return $field_options; |
|
194 | + } |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | new GravityView_Field_Is_Approved(); |
@@ -6,9 +6,9 @@ discard block |
||
6 | 6 | { |
7 | 7 | public $name = 'is_approved'; |
8 | 8 | |
9 | - public $search_operators = ['is', 'isnot']; |
|
9 | + public $search_operators = [ 'is', 'isnot' ]; |
|
10 | 10 | |
11 | - public $contexts = ['single', 'multiple']; |
|
11 | + public $contexts = [ 'single', 'multiple' ]; |
|
12 | 12 | |
13 | 13 | public $group = 'meta'; |
14 | 14 | |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | |
39 | 39 | public function __construct() |
40 | 40 | { |
41 | - $this->label = esc_html__('Approval Status', 'gravityview'); |
|
42 | - $this->description = esc_html__('Display the entry\'s current approval status.', 'gravityview'); |
|
43 | - $this->default_search_label = __('Approval:', 'gravityview'); |
|
41 | + $this->label = esc_html__( 'Approval Status', 'gravityview' ); |
|
42 | + $this->description = esc_html__( 'Display the entry\'s current approval status.', 'gravityview' ); |
|
43 | + $this->default_search_label = __( 'Approval:', 'gravityview' ); |
|
44 | 44 | |
45 | 45 | $this->add_hooks(); |
46 | 46 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | private function add_hooks() |
51 | 51 | { |
52 | - add_filter('gravityview_entry_default_fields', [$this, 'add_default_field'], 10, 3); |
|
52 | + add_filter( 'gravityview_entry_default_fields', [ $this, 'add_default_field' ], 10, 3 ); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -62,26 +62,26 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return string The field setting label for the current status. Uses defaults, if not configured. |
64 | 64 | */ |
65 | - public static function get_output($approval_status = '', $field_settings = [], $html = false) |
|
65 | + public static function get_output( $approval_status = '', $field_settings = [ ], $html = false ) |
|
66 | 66 | { |
67 | - $status = GravityView_Entry_Approval_Status::maybe_convert_status($approval_status); |
|
68 | - $status_key = GravityView_Entry_Approval_Status::get_key($status); |
|
67 | + $status = GravityView_Entry_Approval_Status::maybe_convert_status( $approval_status ); |
|
68 | + $status_key = GravityView_Entry_Approval_Status::get_key( $status ); |
|
69 | 69 | |
70 | 70 | // "approved_label", "unapproved_label", "disapproved_label" setting keys |
71 | - $field_setting_key = sprintf('%s_label', $status_key); |
|
71 | + $field_setting_key = sprintf( '%s_label', $status_key ); |
|
72 | 72 | |
73 | - $default_label = GravityView_Entry_Approval_Status::get_label($status); |
|
73 | + $default_label = GravityView_Entry_Approval_Status::get_label( $status ); |
|
74 | 74 | |
75 | - $value = \GV\Utils::get($field_settings, $field_setting_key, $default_label); |
|
76 | - if (empty($value)) { |
|
75 | + $value = \GV\Utils::get( $field_settings, $field_setting_key, $default_label ); |
|
76 | + if ( empty( $value ) ) { |
|
77 | 77 | $value = $default_label; |
78 | 78 | } |
79 | 79 | |
80 | - if (!$html) { |
|
80 | + if ( ! $html ) { |
|
81 | 81 | return $value; |
82 | 82 | } |
83 | 83 | |
84 | - return sprintf('<span class="gv-approval-%s">%s</span>', esc_attr($status_key), $value); |
|
84 | + return sprintf( '<span class="gv-approval-%s">%s</span>', esc_attr( $status_key ), $value ); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @return array |
95 | 95 | */ |
96 | - public function add_default_field($entry_default_fields, $form, $zone) |
|
96 | + public function add_default_field( $entry_default_fields, $form, $zone ) |
|
97 | 97 | { |
98 | - if ('edit' !== $zone) { |
|
99 | - $entry_default_fields[$this->name] = [ |
|
98 | + if ( 'edit' !== $zone ) { |
|
99 | + $entry_default_fields[ $this->name ] = [ |
|
100 | 100 | 'label' => $this->label, |
101 | 101 | 'desc' => $this->description, |
102 | 102 | 'type' => $this->name, |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @return array Modified merge tags |
118 | 118 | */ |
119 | - protected function custom_merge_tags($form = [], $fields = []) |
|
119 | + protected function custom_merge_tags( $form = [ ], $fields = [ ] ) |
|
120 | 120 | { |
121 | 121 | $merge_tags = [ |
122 | 122 | [ |
123 | - 'label' => __('Approval Status', 'gravityview'), |
|
123 | + 'label' => __( 'Approval Status', 'gravityview' ), |
|
124 | 124 | 'tag' => '{approval_status}', |
125 | 125 | ], |
126 | 126 | ]; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @return string Text, with user variables replaced, if they existed |
145 | 145 | */ |
146 | - public function replace_merge_tag($matches = [], $text = '', $form = [], $entry = [], $url_encode = false, $esc_html = false) |
|
146 | + public function replace_merge_tag( $matches = [ ], $text = '', $form = [ ], $entry = [ ], $url_encode = false, $esc_html = false ) |
|
147 | 147 | { |
148 | 148 | $return = $text; |
149 | 149 | |
@@ -153,41 +153,41 @@ discard block |
||
153 | 153 | * @var string $match[1] Modifier ("value", "label", or empty string) |
154 | 154 | * } |
155 | 155 | */ |
156 | - foreach ($matches as $match) { |
|
157 | - if (empty($entry)) { |
|
158 | - gravityview()->log->error('No entry data available. Returning empty string.'); |
|
156 | + foreach ( $matches as $match ) { |
|
157 | + if ( empty( $entry ) ) { |
|
158 | + gravityview()->log->error( 'No entry data available. Returning empty string.' ); |
|
159 | 159 | $replacement = ''; |
160 | 160 | } else { |
161 | - $replacement = GravityView_Entry_Approval::get_entry_status($entry, $match[1]); |
|
161 | + $replacement = GravityView_Entry_Approval::get_entry_status( $entry, $match[ 1 ] ); |
|
162 | 162 | } |
163 | 163 | |
164 | - $return = str_replace($match[0], $replacement, $return); |
|
164 | + $return = str_replace( $match[ 0 ], $replacement, $return ); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | return $return; |
168 | 168 | } |
169 | 169 | |
170 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
170 | + public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) |
|
171 | 171 | { |
172 | - $field_options['approved_label'] = [ |
|
172 | + $field_options[ 'approved_label' ] = [ |
|
173 | 173 | 'type' => 'text', |
174 | - 'label' => __('Approved Label', 'gravityview'), |
|
175 | - 'desc' => __('If the entry is approved, display this value', 'gravityview'), |
|
176 | - 'placeholder' => GravityView_Entry_Approval_Status::get_label('approved'), |
|
174 | + 'label' => __( 'Approved Label', 'gravityview' ), |
|
175 | + 'desc' => __( 'If the entry is approved, display this value', 'gravityview' ), |
|
176 | + 'placeholder' => GravityView_Entry_Approval_Status::get_label( 'approved' ), |
|
177 | 177 | ]; |
178 | 178 | |
179 | - $field_options['disapproved_label'] = [ |
|
179 | + $field_options[ 'disapproved_label' ] = [ |
|
180 | 180 | 'type' => 'text', |
181 | - 'label' => __('Disapproved Label', 'gravityview'), |
|
182 | - 'desc' => __('If the entry is not approved, display this value', 'gravityview'), |
|
183 | - 'placeholder' => GravityView_Entry_Approval_Status::get_label('disapproved'), |
|
181 | + 'label' => __( 'Disapproved Label', 'gravityview' ), |
|
182 | + 'desc' => __( 'If the entry is not approved, display this value', 'gravityview' ), |
|
183 | + 'placeholder' => GravityView_Entry_Approval_Status::get_label( 'disapproved' ), |
|
184 | 184 | ]; |
185 | 185 | |
186 | - $field_options['unapproved_label'] = [ |
|
186 | + $field_options[ 'unapproved_label' ] = [ |
|
187 | 187 | 'type' => 'text', |
188 | - 'label' => __('Unapproved Label', 'gravityview'), |
|
189 | - 'desc' => __('If the entry has not yet been approved or disapproved, display this value', 'gravityview'), |
|
190 | - 'placeholder' => GravityView_Entry_Approval_Status::get_label('unapproved'), |
|
188 | + 'label' => __( 'Unapproved Label', 'gravityview' ), |
|
189 | + 'desc' => __( 'If the entry has not yet been approved or disapproved, display this value', 'gravityview' ), |
|
190 | + 'placeholder' => GravityView_Entry_Approval_Status::get_label( 'unapproved' ), |
|
191 | 191 | ]; |
192 | 192 | |
193 | 193 | return $field_options; |
@@ -2,8 +2,7 @@ discard block |
||
2 | 2 | /** |
3 | 3 | * @file class-gravityview-field-is-approved.php |
4 | 4 | */ |
5 | -class GravityView_Field_Is_Approved extends GravityView_Field |
|
6 | -{ |
|
5 | +class GravityView_Field_Is_Approved extends GravityView_Field { |
|
7 | 6 | public $name = 'is_approved'; |
8 | 7 | |
9 | 8 | public $search_operators = ['is', 'isnot']; |
@@ -36,8 +35,7 @@ discard block |
||
36 | 35 | |
37 | 36 | public $icon = 'dashicons-yes-alt'; |
38 | 37 | |
39 | - public function __construct() |
|
40 | - { |
|
38 | + public function __construct() { |
|
41 | 39 | $this->label = esc_html__('Approval Status', 'gravityview'); |
42 | 40 | $this->description = esc_html__('Display the entry\'s current approval status.', 'gravityview'); |
43 | 41 | $this->default_search_label = __('Approval:', 'gravityview'); |
@@ -47,8 +45,7 @@ discard block |
||
47 | 45 | parent::__construct(); |
48 | 46 | } |
49 | 47 | |
50 | - private function add_hooks() |
|
51 | - { |
|
48 | + private function add_hooks() { |
|
52 | 49 | add_filter('gravityview_entry_default_fields', [$this, 'add_default_field'], 10, 3); |
53 | 50 | } |
54 | 51 | |
@@ -62,8 +59,7 @@ discard block |
||
62 | 59 | * |
63 | 60 | * @return string The field setting label for the current status. Uses defaults, if not configured. |
64 | 61 | */ |
65 | - public static function get_output($approval_status = '', $field_settings = [], $html = false) |
|
66 | - { |
|
62 | + public static function get_output($approval_status = '', $field_settings = [], $html = false) { |
|
67 | 63 | $status = GravityView_Entry_Approval_Status::maybe_convert_status($approval_status); |
68 | 64 | $status_key = GravityView_Entry_Approval_Status::get_key($status); |
69 | 65 | |
@@ -93,8 +89,7 @@ discard block |
||
93 | 89 | * |
94 | 90 | * @return array |
95 | 91 | */ |
96 | - public function add_default_field($entry_default_fields, $form, $zone) |
|
97 | - { |
|
92 | + public function add_default_field($entry_default_fields, $form, $zone) { |
|
98 | 93 | if ('edit' !== $zone) { |
99 | 94 | $entry_default_fields[$this->name] = [ |
100 | 95 | 'label' => $this->label, |
@@ -116,8 +111,7 @@ discard block |
||
116 | 111 | * |
117 | 112 | * @return array Modified merge tags |
118 | 113 | */ |
119 | - protected function custom_merge_tags($form = [], $fields = []) |
|
120 | - { |
|
114 | + protected function custom_merge_tags($form = [], $fields = []) { |
|
121 | 115 | $merge_tags = [ |
122 | 116 | [ |
123 | 117 | 'label' => __('Approval Status', 'gravityview'), |
@@ -143,8 +137,7 @@ discard block |
||
143 | 137 | * |
144 | 138 | * @return string Text, with user variables replaced, if they existed |
145 | 139 | */ |
146 | - public function replace_merge_tag($matches = [], $text = '', $form = [], $entry = [], $url_encode = false, $esc_html = false) |
|
147 | - { |
|
140 | + public function replace_merge_tag($matches = [], $text = '', $form = [], $entry = [], $url_encode = false, $esc_html = false) { |
|
148 | 141 | $return = $text; |
149 | 142 | |
150 | 143 | /** |
@@ -167,8 +160,7 @@ discard block |
||
167 | 160 | return $return; |
168 | 161 | } |
169 | 162 | |
170 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
171 | - { |
|
163 | + public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) { |
|
172 | 164 | $field_options['approved_label'] = [ |
173 | 165 | 'type' => 'text', |
174 | 166 | 'label' => __('Approved Label', 'gravityview'), |
@@ -4,59 +4,59 @@ |
||
4 | 4 | */ |
5 | 5 | class GravityView_Field_Radio extends GravityView_Field |
6 | 6 | { |
7 | - public $name = 'radio'; |
|
8 | - |
|
9 | - public $is_searchable = true; |
|
10 | - |
|
11 | - public $search_operators = ['is', 'in', 'not in', 'isnot', 'contains']; |
|
12 | - |
|
13 | - public $_gf_field_class_name = 'GF_Field_Radio'; |
|
14 | - |
|
15 | - public $group = 'standard'; |
|
16 | - |
|
17 | - public $icon = 'dashicons-marker'; |
|
18 | - |
|
19 | - public function __construct() |
|
20 | - { |
|
21 | - $this->label = esc_html__('Radio Buttons', 'gravityview'); |
|
22 | - parent::__construct(); |
|
23 | - } |
|
24 | - |
|
25 | - /** |
|
26 | - * Add `choice_display` setting to the field. |
|
27 | - * |
|
28 | - * @param array $field_options |
|
29 | - * @param string $template_id |
|
30 | - * @param string $field_id |
|
31 | - * @param string $context |
|
32 | - * @param string $input_type |
|
33 | - * |
|
34 | - * @since 1.17 |
|
35 | - * |
|
36 | - * @return array |
|
37 | - */ |
|
38 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
39 | - { |
|
40 | - |
|
41 | - // Set the $_field_id var |
|
42 | - $field_options = parent::field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id); |
|
43 | - |
|
44 | - if ($this->is_choice_value_enabled()) { |
|
45 | - $field_options['choice_display'] = [ |
|
46 | - 'type' => 'radio', |
|
47 | - 'value' => 'value', |
|
48 | - 'label' => __('What should be displayed:', 'gravityview'), |
|
49 | - 'desc' => __('This input has a label and a value. What should be displayed?', 'gravityview'), |
|
50 | - 'choices' => [ |
|
51 | - 'value' => __('Value of the input', 'gravityview'), |
|
52 | - 'label' => __('Label of the input', 'gravityview'), |
|
53 | - ], |
|
54 | - 'group' => 'display', |
|
55 | - ]; |
|
56 | - } |
|
57 | - |
|
58 | - return $field_options; |
|
59 | - } |
|
7 | + public $name = 'radio'; |
|
8 | + |
|
9 | + public $is_searchable = true; |
|
10 | + |
|
11 | + public $search_operators = ['is', 'in', 'not in', 'isnot', 'contains']; |
|
12 | + |
|
13 | + public $_gf_field_class_name = 'GF_Field_Radio'; |
|
14 | + |
|
15 | + public $group = 'standard'; |
|
16 | + |
|
17 | + public $icon = 'dashicons-marker'; |
|
18 | + |
|
19 | + public function __construct() |
|
20 | + { |
|
21 | + $this->label = esc_html__('Radio Buttons', 'gravityview'); |
|
22 | + parent::__construct(); |
|
23 | + } |
|
24 | + |
|
25 | + /** |
|
26 | + * Add `choice_display` setting to the field. |
|
27 | + * |
|
28 | + * @param array $field_options |
|
29 | + * @param string $template_id |
|
30 | + * @param string $field_id |
|
31 | + * @param string $context |
|
32 | + * @param string $input_type |
|
33 | + * |
|
34 | + * @since 1.17 |
|
35 | + * |
|
36 | + * @return array |
|
37 | + */ |
|
38 | + public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
39 | + { |
|
40 | + |
|
41 | + // Set the $_field_id var |
|
42 | + $field_options = parent::field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id); |
|
43 | + |
|
44 | + if ($this->is_choice_value_enabled()) { |
|
45 | + $field_options['choice_display'] = [ |
|
46 | + 'type' => 'radio', |
|
47 | + 'value' => 'value', |
|
48 | + 'label' => __('What should be displayed:', 'gravityview'), |
|
49 | + 'desc' => __('This input has a label and a value. What should be displayed?', 'gravityview'), |
|
50 | + 'choices' => [ |
|
51 | + 'value' => __('Value of the input', 'gravityview'), |
|
52 | + 'label' => __('Label of the input', 'gravityview'), |
|
53 | + ], |
|
54 | + 'group' => 'display', |
|
55 | + ]; |
|
56 | + } |
|
57 | + |
|
58 | + return $field_options; |
|
59 | + } |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | new GravityView_Field_Radio(); |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | public $is_searchable = true; |
10 | 10 | |
11 | - public $search_operators = ['is', 'in', 'not in', 'isnot', 'contains']; |
|
11 | + public $search_operators = [ 'is', 'in', 'not in', 'isnot', 'contains' ]; |
|
12 | 12 | |
13 | 13 | public $_gf_field_class_name = 'GF_Field_Radio'; |
14 | 14 | |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | public function __construct() |
20 | 20 | { |
21 | - $this->label = esc_html__('Radio Buttons', 'gravityview'); |
|
21 | + $this->label = esc_html__( 'Radio Buttons', 'gravityview' ); |
|
22 | 22 | parent::__construct(); |
23 | 23 | } |
24 | 24 | |
@@ -35,21 +35,21 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return array |
37 | 37 | */ |
38 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
38 | + public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) |
|
39 | 39 | { |
40 | 40 | |
41 | 41 | // Set the $_field_id var |
42 | - $field_options = parent::field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id); |
|
42 | + $field_options = parent::field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ); |
|
43 | 43 | |
44 | - if ($this->is_choice_value_enabled()) { |
|
45 | - $field_options['choice_display'] = [ |
|
44 | + if ( $this->is_choice_value_enabled() ) { |
|
45 | + $field_options[ 'choice_display' ] = [ |
|
46 | 46 | 'type' => 'radio', |
47 | 47 | 'value' => 'value', |
48 | - 'label' => __('What should be displayed:', 'gravityview'), |
|
49 | - 'desc' => __('This input has a label and a value. What should be displayed?', 'gravityview'), |
|
48 | + 'label' => __( 'What should be displayed:', 'gravityview' ), |
|
49 | + 'desc' => __( 'This input has a label and a value. What should be displayed?', 'gravityview' ), |
|
50 | 50 | 'choices' => [ |
51 | - 'value' => __('Value of the input', 'gravityview'), |
|
52 | - 'label' => __('Label of the input', 'gravityview'), |
|
51 | + 'value' => __( 'Value of the input', 'gravityview' ), |
|
52 | + 'label' => __( 'Label of the input', 'gravityview' ), |
|
53 | 53 | ], |
54 | 54 | 'group' => 'display', |
55 | 55 | ]; |
@@ -2,8 +2,7 @@ discard block |
||
2 | 2 | /** |
3 | 3 | * @file class-gravityview-field-radio.php |
4 | 4 | */ |
5 | -class GravityView_Field_Radio extends GravityView_Field |
|
6 | -{ |
|
5 | +class GravityView_Field_Radio extends GravityView_Field { |
|
7 | 6 | public $name = 'radio'; |
8 | 7 | |
9 | 8 | public $is_searchable = true; |
@@ -16,8 +15,7 @@ discard block |
||
16 | 15 | |
17 | 16 | public $icon = 'dashicons-marker'; |
18 | 17 | |
19 | - public function __construct() |
|
20 | - { |
|
18 | + public function __construct() { |
|
21 | 19 | $this->label = esc_html__('Radio Buttons', 'gravityview'); |
22 | 20 | parent::__construct(); |
23 | 21 | } |
@@ -35,8 +33,7 @@ discard block |
||
35 | 33 | * |
36 | 34 | * @return array |
37 | 35 | */ |
38 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
39 | - { |
|
36 | + public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) { |
|
40 | 37 | |
41 | 38 | // Set the $_field_id var |
42 | 39 | $field_options = parent::field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id); |
@@ -8,85 +8,85 @@ |
||
8 | 8 | */ |
9 | 9 | class GravityView_Field_Entry_Link extends GravityView_Field |
10 | 10 | { |
11 | - public $name = 'entry_link'; |
|
12 | - |
|
13 | - public $contexts = ['multiple']; |
|
14 | - |
|
15 | - /** |
|
16 | - * @var bool |
|
17 | - * |
|
18 | - * @since 1.15.3 |
|
19 | - */ |
|
20 | - public $is_sortable = false; |
|
21 | - |
|
22 | - /** |
|
23 | - * @var bool |
|
24 | - * |
|
25 | - * @since 1.15.3 |
|
26 | - */ |
|
27 | - public $is_searchable = false; |
|
28 | - |
|
29 | - public $group = 'gravityview'; |
|
30 | - |
|
31 | - public $icon = 'dashicons-media-default'; |
|
32 | - |
|
33 | - public function __construct() |
|
34 | - { |
|
35 | - $this->label = esc_html__('Link to Single Entry', 'gravityview'); |
|
36 | - $this->description = esc_html__('A dedicated link to the single entry with customizable text.', 'gravityview'); |
|
37 | - parent::__construct(); |
|
38 | - } |
|
39 | - |
|
40 | - /** |
|
41 | - * Add as a default field, outside those set in the Gravity Form form. |
|
42 | - * |
|
43 | - * @since 2.10 Moved here from GravityView_Admin_Views::get_entry_default_fields |
|
44 | - * |
|
45 | - * @param array $entry_default_fields Existing fields |
|
46 | - * @param string|array $form form_ID or form object |
|
47 | - * @param string $zone Either 'single', 'directory', 'edit', 'header', 'footer' |
|
48 | - * |
|
49 | - * @return array |
|
50 | - */ |
|
51 | - public function add_default_field($entry_default_fields, $form = [], $zone = '') |
|
52 | - { |
|
53 | - if ('directory' !== $zone) { |
|
54 | - return $entry_default_fields; |
|
55 | - } |
|
56 | - |
|
57 | - $entry_default_fields[$this->name] = [ |
|
58 | - 'label' => $this->label, |
|
59 | - 'type' => $this->name, |
|
60 | - 'desc' => $this->description, |
|
61 | - 'icon' => $this->icon, |
|
62 | - ]; |
|
63 | - |
|
64 | - return $entry_default_fields; |
|
65 | - } |
|
66 | - |
|
67 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
68 | - { |
|
69 | - |
|
70 | - // Always a link! |
|
71 | - unset($field_options['show_as_link'], $field_options['search_filter']); |
|
72 | - |
|
73 | - if ('edit' === $context) { |
|
74 | - return $field_options; |
|
75 | - } |
|
76 | - |
|
77 | - $add_options = []; |
|
78 | - $add_options['entry_link_text'] = [ |
|
79 | - 'type' => 'text', |
|
80 | - 'label' => __('Link Text:', 'gravityview'), |
|
81 | - 'desc' => null, |
|
82 | - 'value' => __('View Details', 'gravityview'), |
|
83 | - 'merge_tags' => true, |
|
84 | - ]; |
|
85 | - |
|
86 | - $this->add_field_support('new_window', $field_options); |
|
87 | - |
|
88 | - return $add_options + $field_options; |
|
89 | - } |
|
11 | + public $name = 'entry_link'; |
|
12 | + |
|
13 | + public $contexts = ['multiple']; |
|
14 | + |
|
15 | + /** |
|
16 | + * @var bool |
|
17 | + * |
|
18 | + * @since 1.15.3 |
|
19 | + */ |
|
20 | + public $is_sortable = false; |
|
21 | + |
|
22 | + /** |
|
23 | + * @var bool |
|
24 | + * |
|
25 | + * @since 1.15.3 |
|
26 | + */ |
|
27 | + public $is_searchable = false; |
|
28 | + |
|
29 | + public $group = 'gravityview'; |
|
30 | + |
|
31 | + public $icon = 'dashicons-media-default'; |
|
32 | + |
|
33 | + public function __construct() |
|
34 | + { |
|
35 | + $this->label = esc_html__('Link to Single Entry', 'gravityview'); |
|
36 | + $this->description = esc_html__('A dedicated link to the single entry with customizable text.', 'gravityview'); |
|
37 | + parent::__construct(); |
|
38 | + } |
|
39 | + |
|
40 | + /** |
|
41 | + * Add as a default field, outside those set in the Gravity Form form. |
|
42 | + * |
|
43 | + * @since 2.10 Moved here from GravityView_Admin_Views::get_entry_default_fields |
|
44 | + * |
|
45 | + * @param array $entry_default_fields Existing fields |
|
46 | + * @param string|array $form form_ID or form object |
|
47 | + * @param string $zone Either 'single', 'directory', 'edit', 'header', 'footer' |
|
48 | + * |
|
49 | + * @return array |
|
50 | + */ |
|
51 | + public function add_default_field($entry_default_fields, $form = [], $zone = '') |
|
52 | + { |
|
53 | + if ('directory' !== $zone) { |
|
54 | + return $entry_default_fields; |
|
55 | + } |
|
56 | + |
|
57 | + $entry_default_fields[$this->name] = [ |
|
58 | + 'label' => $this->label, |
|
59 | + 'type' => $this->name, |
|
60 | + 'desc' => $this->description, |
|
61 | + 'icon' => $this->icon, |
|
62 | + ]; |
|
63 | + |
|
64 | + return $entry_default_fields; |
|
65 | + } |
|
66 | + |
|
67 | + public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
68 | + { |
|
69 | + |
|
70 | + // Always a link! |
|
71 | + unset($field_options['show_as_link'], $field_options['search_filter']); |
|
72 | + |
|
73 | + if ('edit' === $context) { |
|
74 | + return $field_options; |
|
75 | + } |
|
76 | + |
|
77 | + $add_options = []; |
|
78 | + $add_options['entry_link_text'] = [ |
|
79 | + 'type' => 'text', |
|
80 | + 'label' => __('Link Text:', 'gravityview'), |
|
81 | + 'desc' => null, |
|
82 | + 'value' => __('View Details', 'gravityview'), |
|
83 | + 'merge_tags' => true, |
|
84 | + ]; |
|
85 | + |
|
86 | + $this->add_field_support('new_window', $field_options); |
|
87 | + |
|
88 | + return $add_options + $field_options; |
|
89 | + } |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | new GravityView_Field_Entry_Link(); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | { |
11 | 11 | public $name = 'entry_link'; |
12 | 12 | |
13 | - public $contexts = ['multiple']; |
|
13 | + public $contexts = [ 'multiple' ]; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * @var bool |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | |
33 | 33 | public function __construct() |
34 | 34 | { |
35 | - $this->label = esc_html__('Link to Single Entry', 'gravityview'); |
|
36 | - $this->description = esc_html__('A dedicated link to the single entry with customizable text.', 'gravityview'); |
|
35 | + $this->label = esc_html__( 'Link to Single Entry', 'gravityview' ); |
|
36 | + $this->description = esc_html__( 'A dedicated link to the single entry with customizable text.', 'gravityview' ); |
|
37 | 37 | parent::__construct(); |
38 | 38 | } |
39 | 39 | |
@@ -48,13 +48,13 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return array |
50 | 50 | */ |
51 | - public function add_default_field($entry_default_fields, $form = [], $zone = '') |
|
51 | + public function add_default_field( $entry_default_fields, $form = [ ], $zone = '' ) |
|
52 | 52 | { |
53 | - if ('directory' !== $zone) { |
|
53 | + if ( 'directory' !== $zone ) { |
|
54 | 54 | return $entry_default_fields; |
55 | 55 | } |
56 | 56 | |
57 | - $entry_default_fields[$this->name] = [ |
|
57 | + $entry_default_fields[ $this->name ] = [ |
|
58 | 58 | 'label' => $this->label, |
59 | 59 | 'type' => $this->name, |
60 | 60 | 'desc' => $this->description, |
@@ -64,26 +64,26 @@ discard block |
||
64 | 64 | return $entry_default_fields; |
65 | 65 | } |
66 | 66 | |
67 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
67 | + public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) |
|
68 | 68 | { |
69 | 69 | |
70 | 70 | // Always a link! |
71 | - unset($field_options['show_as_link'], $field_options['search_filter']); |
|
71 | + unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ] ); |
|
72 | 72 | |
73 | - if ('edit' === $context) { |
|
73 | + if ( 'edit' === $context ) { |
|
74 | 74 | return $field_options; |
75 | 75 | } |
76 | 76 | |
77 | - $add_options = []; |
|
78 | - $add_options['entry_link_text'] = [ |
|
77 | + $add_options = [ ]; |
|
78 | + $add_options[ 'entry_link_text' ] = [ |
|
79 | 79 | 'type' => 'text', |
80 | - 'label' => __('Link Text:', 'gravityview'), |
|
80 | + 'label' => __( 'Link Text:', 'gravityview' ), |
|
81 | 81 | 'desc' => null, |
82 | - 'value' => __('View Details', 'gravityview'), |
|
82 | + 'value' => __( 'View Details', 'gravityview' ), |
|
83 | 83 | 'merge_tags' => true, |
84 | 84 | ]; |
85 | 85 | |
86 | - $this->add_field_support('new_window', $field_options); |
|
86 | + $this->add_field_support( 'new_window', $field_options ); |
|
87 | 87 | |
88 | 88 | return $add_options + $field_options; |
89 | 89 | } |
@@ -6,8 +6,7 @@ discard block |
||
6 | 6 | /** |
7 | 7 | * Add custom options for entry_link fields. |
8 | 8 | */ |
9 | -class GravityView_Field_Entry_Link extends GravityView_Field |
|
10 | -{ |
|
9 | +class GravityView_Field_Entry_Link extends GravityView_Field { |
|
11 | 10 | public $name = 'entry_link'; |
12 | 11 | |
13 | 12 | public $contexts = ['multiple']; |
@@ -30,8 +29,7 @@ discard block |
||
30 | 29 | |
31 | 30 | public $icon = 'dashicons-media-default'; |
32 | 31 | |
33 | - public function __construct() |
|
34 | - { |
|
32 | + public function __construct() { |
|
35 | 33 | $this->label = esc_html__('Link to Single Entry', 'gravityview'); |
36 | 34 | $this->description = esc_html__('A dedicated link to the single entry with customizable text.', 'gravityview'); |
37 | 35 | parent::__construct(); |
@@ -48,8 +46,7 @@ discard block |
||
48 | 46 | * |
49 | 47 | * @return array |
50 | 48 | */ |
51 | - public function add_default_field($entry_default_fields, $form = [], $zone = '') |
|
52 | - { |
|
49 | + public function add_default_field($entry_default_fields, $form = [], $zone = '') { |
|
53 | 50 | if ('directory' !== $zone) { |
54 | 51 | return $entry_default_fields; |
55 | 52 | } |
@@ -64,8 +61,7 @@ discard block |
||
64 | 61 | return $entry_default_fields; |
65 | 62 | } |
66 | 63 | |
67 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
68 | - { |
|
64 | + public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) { |
|
69 | 65 | |
70 | 66 | // Always a link! |
71 | 67 | unset($field_options['show_as_link'], $field_options['search_filter']); |
@@ -8,324 +8,324 @@ |
||
8 | 8 | */ |
9 | 9 | class GravityView_Field_Time extends GravityView_Field |
10 | 10 | { |
11 | - public $name = 'time'; |
|
12 | - |
|
13 | - public $is_searchable = true; |
|
14 | - |
|
15 | - public $search_operators = ['is', 'isnot', 'greater_than', 'less_than']; |
|
16 | - |
|
17 | - /** @see GF_Field_Time */ |
|
18 | - public $_gf_field_class_name = 'GF_Field_Time'; |
|
19 | - |
|
20 | - public $group = 'advanced'; |
|
21 | - |
|
22 | - public $icon = 'dashicons-clock'; |
|
23 | - |
|
24 | - /** |
|
25 | - * @internal Do not define. This is overridden by the class using a filter. |
|
26 | - * |
|
27 | - * @todo Fix using variable for time field |
|
28 | - */ |
|
29 | - public $is_numeric; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var string The part of the Gravity Forms query that's modified to enable sorting by time. `value` gets replaced. |
|
33 | - * |
|
34 | - * @since 1.14 |
|
35 | - */ |
|
36 | - const GF_SORTING_SQL = 'SELECT 0 as query, lead_id as id, value'; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var string Used to implode and explode the custom sort key for query modification. |
|
40 | - * |
|
41 | - * @since 1.14 |
|
42 | - */ |
|
43 | - private $_sort_divider = '|:time:|'; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var string Used to store the time format for the field ("12" or "24") so it can be used in the query filter |
|
47 | - * |
|
48 | - * @since 1.14 |
|
49 | - */ |
|
50 | - private $_time_format = null; |
|
51 | - |
|
52 | - /** |
|
53 | - * @var string Used to store the date format for the field, based on the input being displayed, so it can be used in the query filter |
|
54 | - * |
|
55 | - * @since 1.14 |
|
56 | - */ |
|
57 | - private $_date_format = null; |
|
58 | - |
|
59 | - /** |
|
60 | - * GravityView_Field_Time constructor. |
|
61 | - */ |
|
62 | - public function __construct() |
|
63 | - { |
|
64 | - $this->label = esc_html__('Time', 'gravityview'); |
|
65 | - |
|
66 | - parent::__construct(); |
|
67 | - |
|
68 | - add_filter('gravityview/sorting/time', [$this, 'modify_sort_id'], 10, 2); |
|
69 | - |
|
70 | - add_filter('gravityview_search_criteria', [$this, '_maybe_filter_gravity_forms_query'], 10, 4); |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * Modify the sort key for the time field so it can be parsed by the query filter. |
|
75 | - * |
|
76 | - * @see _modify_query_sort_by_time_hack |
|
77 | - * @since 1.14 |
|
78 | - * |
|
79 | - * @param string $sort_field_id Existing sort field ID (like "5") |
|
80 | - * @param int $form_id Gravity Forms Form ID being sorted |
|
81 | - * |
|
82 | - * @return string Modified sort key imploded with $_sort_divider, like `5|:time:|12|:time:|h:i A` |
|
83 | - */ |
|
84 | - public function modify_sort_id($sort_field_id, $form_id) |
|
85 | - { |
|
86 | - $time_format = self::_get_time_format_for_field($sort_field_id, $form_id); |
|
87 | - |
|
88 | - $date_format = self::date_format($time_format, $sort_field_id); |
|
89 | - |
|
90 | - // Should look something like `5|:time:|12|:time:|h:i A` |
|
91 | - $new_sort_field_id = implode($this->_sort_divider, [$sort_field_id, $time_format, $date_format]); |
|
92 | - |
|
93 | - return $new_sort_field_id; |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * If the sorting key matches the key set in modify_sort_id(), then modify the Gravity Forms query SQL. |
|
98 | - * |
|
99 | - * @since 1.14 |
|
100 | - * @see modify_sort_id() |
|
101 | - * |
|
102 | - * @param array $criteria Search criteria used by GravityView |
|
103 | - * @param array $form_ids Forms to search |
|
104 | - * @param int $view_id ID of the view being used to search |
|
105 | - * |
|
106 | - * @return array $criteria If a match, the sorting will be updated to set `is_numeric` to true and make sure the field ID is an int |
|
107 | - */ |
|
108 | - public function _maybe_filter_gravity_forms_query($criteria, $form_ids, $view_id) |
|
109 | - { |
|
110 | - |
|
111 | - // If the search is not being sorted, return early |
|
112 | - if (empty($criteria['sorting']['key'])) { |
|
113 | - return $criteria; |
|
114 | - } |
|
115 | - |
|
116 | - $pieces = explode($this->_sort_divider, $criteria['sorting']['key']); |
|
117 | - |
|
118 | - /** |
|
119 | - * If the sort key does not match the key set in modify_sort_id(), do not modify the Gravity Forms query SQL. |
|
120 | - * |
|
121 | - * @see modify_sort_id() |
|
122 | - */ |
|
123 | - if (empty($pieces[1])) { |
|
124 | - return $criteria; |
|
125 | - } |
|
126 | - |
|
127 | - // Pass these to the _modify_query_sort_by_time_hack() method |
|
128 | - $this->_time_format = $pieces[1]; |
|
129 | - $this->_date_format = $pieces[2]; |
|
130 | - |
|
131 | - // Remove fake input IDs (5.1 doesn't exist. Use 5) |
|
132 | - $criteria['sorting']['key'] = floor($pieces[0]); |
|
133 | - |
|
134 | - /** |
|
135 | - * Make sure sorting is numeric (# of seconds). IMPORTANT. |
|
136 | - * |
|
137 | - * @see GVCommon::is_field_numeric() is_numeric should also be set here |
|
138 | - */ |
|
139 | - $criteria['sorting']['is_numeric'] = true; |
|
140 | - |
|
141 | - // Modify the Gravity Forms WP Query |
|
142 | - add_filter('query', [$this, '_modify_query_sort_by_time_hack']); |
|
143 | - |
|
144 | - return $criteria; |
|
145 | - } |
|
146 | - |
|
147 | - /** |
|
148 | - * Modify Gravity Forms query SQL to convert times to numbers |
|
149 | - * Gravity Forms couldn't sort by time...until NOW. |
|
150 | - * |
|
151 | - * @since 1.14 |
|
152 | - * |
|
153 | - * @param string $query MySQL query |
|
154 | - * |
|
155 | - * @return string Modified query, if the query matches the expected Gravity Forms SQL string used for sorting time fields. Otherwise, original query. |
|
156 | - */ |
|
157 | - public function _modify_query_sort_by_time_hack($query) |
|
158 | - { |
|
159 | - |
|
160 | - /** |
|
161 | - * If this is a Gravity Forms entry selection sorting query, generated by sort_by_field_query(), |
|
162 | - * then we want to modify the query. |
|
163 | - * |
|
164 | - * @see GFFormsModel::sort_by_field_query() |
|
165 | - */ |
|
166 | - if (strpos($query, self::GF_SORTING_SQL) > 0) { |
|
167 | - if ($this->_time_format === '24') { |
|
168 | - $sql_str_to_date = "STR_TO_DATE( `value`, '%H:%i' )"; |
|
169 | - } else { |
|
170 | - $sql_str_to_date = "STR_TO_DATE( `value`, '%h:%i %p' )"; |
|
171 | - } |
|
172 | - |
|
173 | - switch ($this->_date_format) { |
|
174 | - case 'h': |
|
175 | - case 'H': |
|
176 | - $modification = "TIME_FORMAT( {$sql_str_to_date}, '%H' )"; |
|
177 | - break; |
|
178 | - case 'i': |
|
179 | - $modification = "TIME_FORMAT( {$sql_str_to_date}, '%i' )"; |
|
180 | - break; |
|
181 | - case 'H:i': |
|
182 | - case 'h:i A': |
|
183 | - default: |
|
184 | - $modification = "TIME_TO_SEC( {$sql_str_to_date} )"; |
|
185 | - } |
|
186 | - |
|
187 | - /** |
|
188 | - * Convert the time (12:30 pm) to the MySQL `TIME_TO_SEC()` value for that time (45000) |
|
189 | - * This way, Gravity Forms is able to sort numerically. |
|
190 | - */ |
|
191 | - $replacement_query = str_replace('value', "{$modification} as value", self::GF_SORTING_SQL); |
|
192 | - |
|
193 | - /** |
|
194 | - * Replace it in the main query. |
|
195 | - */ |
|
196 | - $query = str_replace(self::GF_SORTING_SQL, $replacement_query, $query); |
|
197 | - |
|
198 | - /** |
|
199 | - * REMOVE the Gravity Forms WP Query modifications! |
|
200 | - */ |
|
201 | - remove_filter('query', [$this, '_modify_query_sort_by_time_hack']); |
|
202 | - } |
|
203 | - |
|
204 | - return $query; |
|
205 | - } |
|
206 | - |
|
207 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
208 | - { |
|
209 | - |
|
210 | - // Set variables |
|
211 | - parent::field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id); |
|
212 | - |
|
213 | - if ('edit' === $context) { |
|
214 | - return $field_options; |
|
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * Set default date format based on field ID and Form ID. |
|
219 | - */ |
|
220 | - add_filter('gravityview_date_format', [$this, '_filter_date_display_date_format']); |
|
221 | - |
|
222 | - $this->add_field_support('date_display', $field_options); |
|
223 | - |
|
224 | - remove_filter('gravityview_date_format', [$this, '_filter_date_display_date_format']); |
|
225 | - |
|
226 | - return $field_options; |
|
227 | - } |
|
228 | - |
|
229 | - /** |
|
230 | - * Return the field's time format by fetching the form ID and checking the field settings. |
|
231 | - * |
|
232 | - * @since 1.14 |
|
233 | - * |
|
234 | - * @return string Either "12" or "24". "12" is default. |
|
235 | - */ |
|
236 | - private function _get_time_format() |
|
237 | - { |
|
238 | - global $post; |
|
239 | - |
|
240 | - $current_form = isset($_POST['form_id']) ? intval($_POST['form_id']) : gravityview_get_form_id($post->ID); |
|
241 | - |
|
242 | - return self::_get_time_format_for_field($this->_field_id, $current_form); |
|
243 | - } |
|
244 | - |
|
245 | - /** |
|
246 | - * Return the field's time format by fetching the form ID and checking the field settings. |
|
247 | - * |
|
248 | - * @since 1.14 |
|
249 | - * |
|
250 | - * @param string $field_id ID for Gravity Forms time field |
|
251 | - * @param int $form_id ID for Gravity Forms form |
|
252 | - * |
|
253 | - * @return string Either "12" or "24". "12" is default. |
|
254 | - */ |
|
255 | - public static function _get_time_format_for_field($field_id, $form_id = 0) |
|
256 | - { |
|
257 | - |
|
258 | - // GF defaults to 12, so should we. |
|
259 | - $time_format = '12'; |
|
260 | - |
|
261 | - if ($form_id) { |
|
262 | - $form = GFAPI::get_form($form_id); |
|
263 | - |
|
264 | - if ($form) { |
|
265 | - $field = GFFormsModel::get_field($form, floor($field_id)); |
|
266 | - if ($field && $field instanceof GF_Field_Time) { |
|
267 | - $field->sanitize_settings(); // Make sure time is set |
|
268 | - $time_format = $field->timeFormat; |
|
269 | - } |
|
270 | - } |
|
271 | - } |
|
272 | - |
|
273 | - return $time_format; |
|
274 | - } |
|
275 | - |
|
276 | - /** |
|
277 | - * Modify the default PHP date formats used by the time field based on the field IDs and the field settings. |
|
278 | - * |
|
279 | - * @since 1.14 |
|
280 | - * |
|
281 | - * @return string PHP date() format text to to display the correctly formatted time value for the newly created field |
|
282 | - */ |
|
283 | - public function _filter_date_display_date_format() |
|
284 | - { |
|
285 | - $time_format = $this->_get_time_format(); |
|
286 | - $field_id = $this->_field_id; |
|
287 | - |
|
288 | - return self::date_format($time_format, $field_id); |
|
289 | - } |
|
290 | - |
|
291 | - /** |
|
292 | - * Get the default date format for a field based on the field ID and the time format setting. |
|
293 | - * |
|
294 | - * @since 1.14 |
|
295 | - * |
|
296 | - * @param string $time_format The time format ("12" or "24"). Default: "12" {@since 1.14} |
|
297 | - * @param int $field_id The ID of the field. Used to figure out full time/hours/minutes/am/pm {@since 1.14} |
|
298 | - * |
|
299 | - * @return string PHP date format for the time |
|
300 | - */ |
|
301 | - public static function date_format($time_format = '12', $field_id = 0) |
|
302 | - { |
|
303 | - $field_input_id = gravityview_get_input_id_from_id($field_id); |
|
304 | - |
|
305 | - $default = 'h:i A'; |
|
306 | - |
|
307 | - // This doesn't take into account 24-hour |
|
308 | - switch ($field_input_id) { |
|
309 | - // Hours |
|
310 | - case 1: |
|
311 | - return ($time_format === '12') ? 'h' : 'H'; |
|
312 | - break; |
|
313 | - // Minutes |
|
314 | - case 2: |
|
315 | - return 'i'; |
|
316 | - break; |
|
317 | - // AM/PM |
|
318 | - case 3: |
|
319 | - return 'A'; |
|
320 | - break; |
|
321 | - // Full time field |
|
322 | - case 0: |
|
323 | - return ($time_format === '12') ? $default : 'H:i'; |
|
324 | - break; |
|
325 | - } |
|
326 | - |
|
327 | - return $default; |
|
328 | - } |
|
11 | + public $name = 'time'; |
|
12 | + |
|
13 | + public $is_searchable = true; |
|
14 | + |
|
15 | + public $search_operators = ['is', 'isnot', 'greater_than', 'less_than']; |
|
16 | + |
|
17 | + /** @see GF_Field_Time */ |
|
18 | + public $_gf_field_class_name = 'GF_Field_Time'; |
|
19 | + |
|
20 | + public $group = 'advanced'; |
|
21 | + |
|
22 | + public $icon = 'dashicons-clock'; |
|
23 | + |
|
24 | + /** |
|
25 | + * @internal Do not define. This is overridden by the class using a filter. |
|
26 | + * |
|
27 | + * @todo Fix using variable for time field |
|
28 | + */ |
|
29 | + public $is_numeric; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var string The part of the Gravity Forms query that's modified to enable sorting by time. `value` gets replaced. |
|
33 | + * |
|
34 | + * @since 1.14 |
|
35 | + */ |
|
36 | + const GF_SORTING_SQL = 'SELECT 0 as query, lead_id as id, value'; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var string Used to implode and explode the custom sort key for query modification. |
|
40 | + * |
|
41 | + * @since 1.14 |
|
42 | + */ |
|
43 | + private $_sort_divider = '|:time:|'; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var string Used to store the time format for the field ("12" or "24") so it can be used in the query filter |
|
47 | + * |
|
48 | + * @since 1.14 |
|
49 | + */ |
|
50 | + private $_time_format = null; |
|
51 | + |
|
52 | + /** |
|
53 | + * @var string Used to store the date format for the field, based on the input being displayed, so it can be used in the query filter |
|
54 | + * |
|
55 | + * @since 1.14 |
|
56 | + */ |
|
57 | + private $_date_format = null; |
|
58 | + |
|
59 | + /** |
|
60 | + * GravityView_Field_Time constructor. |
|
61 | + */ |
|
62 | + public function __construct() |
|
63 | + { |
|
64 | + $this->label = esc_html__('Time', 'gravityview'); |
|
65 | + |
|
66 | + parent::__construct(); |
|
67 | + |
|
68 | + add_filter('gravityview/sorting/time', [$this, 'modify_sort_id'], 10, 2); |
|
69 | + |
|
70 | + add_filter('gravityview_search_criteria', [$this, '_maybe_filter_gravity_forms_query'], 10, 4); |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * Modify the sort key for the time field so it can be parsed by the query filter. |
|
75 | + * |
|
76 | + * @see _modify_query_sort_by_time_hack |
|
77 | + * @since 1.14 |
|
78 | + * |
|
79 | + * @param string $sort_field_id Existing sort field ID (like "5") |
|
80 | + * @param int $form_id Gravity Forms Form ID being sorted |
|
81 | + * |
|
82 | + * @return string Modified sort key imploded with $_sort_divider, like `5|:time:|12|:time:|h:i A` |
|
83 | + */ |
|
84 | + public function modify_sort_id($sort_field_id, $form_id) |
|
85 | + { |
|
86 | + $time_format = self::_get_time_format_for_field($sort_field_id, $form_id); |
|
87 | + |
|
88 | + $date_format = self::date_format($time_format, $sort_field_id); |
|
89 | + |
|
90 | + // Should look something like `5|:time:|12|:time:|h:i A` |
|
91 | + $new_sort_field_id = implode($this->_sort_divider, [$sort_field_id, $time_format, $date_format]); |
|
92 | + |
|
93 | + return $new_sort_field_id; |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * If the sorting key matches the key set in modify_sort_id(), then modify the Gravity Forms query SQL. |
|
98 | + * |
|
99 | + * @since 1.14 |
|
100 | + * @see modify_sort_id() |
|
101 | + * |
|
102 | + * @param array $criteria Search criteria used by GravityView |
|
103 | + * @param array $form_ids Forms to search |
|
104 | + * @param int $view_id ID of the view being used to search |
|
105 | + * |
|
106 | + * @return array $criteria If a match, the sorting will be updated to set `is_numeric` to true and make sure the field ID is an int |
|
107 | + */ |
|
108 | + public function _maybe_filter_gravity_forms_query($criteria, $form_ids, $view_id) |
|
109 | + { |
|
110 | + |
|
111 | + // If the search is not being sorted, return early |
|
112 | + if (empty($criteria['sorting']['key'])) { |
|
113 | + return $criteria; |
|
114 | + } |
|
115 | + |
|
116 | + $pieces = explode($this->_sort_divider, $criteria['sorting']['key']); |
|
117 | + |
|
118 | + /** |
|
119 | + * If the sort key does not match the key set in modify_sort_id(), do not modify the Gravity Forms query SQL. |
|
120 | + * |
|
121 | + * @see modify_sort_id() |
|
122 | + */ |
|
123 | + if (empty($pieces[1])) { |
|
124 | + return $criteria; |
|
125 | + } |
|
126 | + |
|
127 | + // Pass these to the _modify_query_sort_by_time_hack() method |
|
128 | + $this->_time_format = $pieces[1]; |
|
129 | + $this->_date_format = $pieces[2]; |
|
130 | + |
|
131 | + // Remove fake input IDs (5.1 doesn't exist. Use 5) |
|
132 | + $criteria['sorting']['key'] = floor($pieces[0]); |
|
133 | + |
|
134 | + /** |
|
135 | + * Make sure sorting is numeric (# of seconds). IMPORTANT. |
|
136 | + * |
|
137 | + * @see GVCommon::is_field_numeric() is_numeric should also be set here |
|
138 | + */ |
|
139 | + $criteria['sorting']['is_numeric'] = true; |
|
140 | + |
|
141 | + // Modify the Gravity Forms WP Query |
|
142 | + add_filter('query', [$this, '_modify_query_sort_by_time_hack']); |
|
143 | + |
|
144 | + return $criteria; |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * Modify Gravity Forms query SQL to convert times to numbers |
|
149 | + * Gravity Forms couldn't sort by time...until NOW. |
|
150 | + * |
|
151 | + * @since 1.14 |
|
152 | + * |
|
153 | + * @param string $query MySQL query |
|
154 | + * |
|
155 | + * @return string Modified query, if the query matches the expected Gravity Forms SQL string used for sorting time fields. Otherwise, original query. |
|
156 | + */ |
|
157 | + public function _modify_query_sort_by_time_hack($query) |
|
158 | + { |
|
159 | + |
|
160 | + /** |
|
161 | + * If this is a Gravity Forms entry selection sorting query, generated by sort_by_field_query(), |
|
162 | + * then we want to modify the query. |
|
163 | + * |
|
164 | + * @see GFFormsModel::sort_by_field_query() |
|
165 | + */ |
|
166 | + if (strpos($query, self::GF_SORTING_SQL) > 0) { |
|
167 | + if ($this->_time_format === '24') { |
|
168 | + $sql_str_to_date = "STR_TO_DATE( `value`, '%H:%i' )"; |
|
169 | + } else { |
|
170 | + $sql_str_to_date = "STR_TO_DATE( `value`, '%h:%i %p' )"; |
|
171 | + } |
|
172 | + |
|
173 | + switch ($this->_date_format) { |
|
174 | + case 'h': |
|
175 | + case 'H': |
|
176 | + $modification = "TIME_FORMAT( {$sql_str_to_date}, '%H' )"; |
|
177 | + break; |
|
178 | + case 'i': |
|
179 | + $modification = "TIME_FORMAT( {$sql_str_to_date}, '%i' )"; |
|
180 | + break; |
|
181 | + case 'H:i': |
|
182 | + case 'h:i A': |
|
183 | + default: |
|
184 | + $modification = "TIME_TO_SEC( {$sql_str_to_date} )"; |
|
185 | + } |
|
186 | + |
|
187 | + /** |
|
188 | + * Convert the time (12:30 pm) to the MySQL `TIME_TO_SEC()` value for that time (45000) |
|
189 | + * This way, Gravity Forms is able to sort numerically. |
|
190 | + */ |
|
191 | + $replacement_query = str_replace('value', "{$modification} as value", self::GF_SORTING_SQL); |
|
192 | + |
|
193 | + /** |
|
194 | + * Replace it in the main query. |
|
195 | + */ |
|
196 | + $query = str_replace(self::GF_SORTING_SQL, $replacement_query, $query); |
|
197 | + |
|
198 | + /** |
|
199 | + * REMOVE the Gravity Forms WP Query modifications! |
|
200 | + */ |
|
201 | + remove_filter('query', [$this, '_modify_query_sort_by_time_hack']); |
|
202 | + } |
|
203 | + |
|
204 | + return $query; |
|
205 | + } |
|
206 | + |
|
207 | + public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
208 | + { |
|
209 | + |
|
210 | + // Set variables |
|
211 | + parent::field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id); |
|
212 | + |
|
213 | + if ('edit' === $context) { |
|
214 | + return $field_options; |
|
215 | + } |
|
216 | + |
|
217 | + /** |
|
218 | + * Set default date format based on field ID and Form ID. |
|
219 | + */ |
|
220 | + add_filter('gravityview_date_format', [$this, '_filter_date_display_date_format']); |
|
221 | + |
|
222 | + $this->add_field_support('date_display', $field_options); |
|
223 | + |
|
224 | + remove_filter('gravityview_date_format', [$this, '_filter_date_display_date_format']); |
|
225 | + |
|
226 | + return $field_options; |
|
227 | + } |
|
228 | + |
|
229 | + /** |
|
230 | + * Return the field's time format by fetching the form ID and checking the field settings. |
|
231 | + * |
|
232 | + * @since 1.14 |
|
233 | + * |
|
234 | + * @return string Either "12" or "24". "12" is default. |
|
235 | + */ |
|
236 | + private function _get_time_format() |
|
237 | + { |
|
238 | + global $post; |
|
239 | + |
|
240 | + $current_form = isset($_POST['form_id']) ? intval($_POST['form_id']) : gravityview_get_form_id($post->ID); |
|
241 | + |
|
242 | + return self::_get_time_format_for_field($this->_field_id, $current_form); |
|
243 | + } |
|
244 | + |
|
245 | + /** |
|
246 | + * Return the field's time format by fetching the form ID and checking the field settings. |
|
247 | + * |
|
248 | + * @since 1.14 |
|
249 | + * |
|
250 | + * @param string $field_id ID for Gravity Forms time field |
|
251 | + * @param int $form_id ID for Gravity Forms form |
|
252 | + * |
|
253 | + * @return string Either "12" or "24". "12" is default. |
|
254 | + */ |
|
255 | + public static function _get_time_format_for_field($field_id, $form_id = 0) |
|
256 | + { |
|
257 | + |
|
258 | + // GF defaults to 12, so should we. |
|
259 | + $time_format = '12'; |
|
260 | + |
|
261 | + if ($form_id) { |
|
262 | + $form = GFAPI::get_form($form_id); |
|
263 | + |
|
264 | + if ($form) { |
|
265 | + $field = GFFormsModel::get_field($form, floor($field_id)); |
|
266 | + if ($field && $field instanceof GF_Field_Time) { |
|
267 | + $field->sanitize_settings(); // Make sure time is set |
|
268 | + $time_format = $field->timeFormat; |
|
269 | + } |
|
270 | + } |
|
271 | + } |
|
272 | + |
|
273 | + return $time_format; |
|
274 | + } |
|
275 | + |
|
276 | + /** |
|
277 | + * Modify the default PHP date formats used by the time field based on the field IDs and the field settings. |
|
278 | + * |
|
279 | + * @since 1.14 |
|
280 | + * |
|
281 | + * @return string PHP date() format text to to display the correctly formatted time value for the newly created field |
|
282 | + */ |
|
283 | + public function _filter_date_display_date_format() |
|
284 | + { |
|
285 | + $time_format = $this->_get_time_format(); |
|
286 | + $field_id = $this->_field_id; |
|
287 | + |
|
288 | + return self::date_format($time_format, $field_id); |
|
289 | + } |
|
290 | + |
|
291 | + /** |
|
292 | + * Get the default date format for a field based on the field ID and the time format setting. |
|
293 | + * |
|
294 | + * @since 1.14 |
|
295 | + * |
|
296 | + * @param string $time_format The time format ("12" or "24"). Default: "12" {@since 1.14} |
|
297 | + * @param int $field_id The ID of the field. Used to figure out full time/hours/minutes/am/pm {@since 1.14} |
|
298 | + * |
|
299 | + * @return string PHP date format for the time |
|
300 | + */ |
|
301 | + public static function date_format($time_format = '12', $field_id = 0) |
|
302 | + { |
|
303 | + $field_input_id = gravityview_get_input_id_from_id($field_id); |
|
304 | + |
|
305 | + $default = 'h:i A'; |
|
306 | + |
|
307 | + // This doesn't take into account 24-hour |
|
308 | + switch ($field_input_id) { |
|
309 | + // Hours |
|
310 | + case 1: |
|
311 | + return ($time_format === '12') ? 'h' : 'H'; |
|
312 | + break; |
|
313 | + // Minutes |
|
314 | + case 2: |
|
315 | + return 'i'; |
|
316 | + break; |
|
317 | + // AM/PM |
|
318 | + case 3: |
|
319 | + return 'A'; |
|
320 | + break; |
|
321 | + // Full time field |
|
322 | + case 0: |
|
323 | + return ($time_format === '12') ? $default : 'H:i'; |
|
324 | + break; |
|
325 | + } |
|
326 | + |
|
327 | + return $default; |
|
328 | + } |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | new GravityView_Field_Time(); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | public $is_searchable = true; |
14 | 14 | |
15 | - public $search_operators = ['is', 'isnot', 'greater_than', 'less_than']; |
|
15 | + public $search_operators = [ 'is', 'isnot', 'greater_than', 'less_than' ]; |
|
16 | 16 | |
17 | 17 | /** @see GF_Field_Time */ |
18 | 18 | public $_gf_field_class_name = 'GF_Field_Time'; |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function __construct() |
63 | 63 | { |
64 | - $this->label = esc_html__('Time', 'gravityview'); |
|
64 | + $this->label = esc_html__( 'Time', 'gravityview' ); |
|
65 | 65 | |
66 | 66 | parent::__construct(); |
67 | 67 | |
68 | - add_filter('gravityview/sorting/time', [$this, 'modify_sort_id'], 10, 2); |
|
68 | + add_filter( 'gravityview/sorting/time', [ $this, 'modify_sort_id' ], 10, 2 ); |
|
69 | 69 | |
70 | - add_filter('gravityview_search_criteria', [$this, '_maybe_filter_gravity_forms_query'], 10, 4); |
|
70 | + add_filter( 'gravityview_search_criteria', [ $this, '_maybe_filter_gravity_forms_query' ], 10, 4 ); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -81,14 +81,14 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return string Modified sort key imploded with $_sort_divider, like `5|:time:|12|:time:|h:i A` |
83 | 83 | */ |
84 | - public function modify_sort_id($sort_field_id, $form_id) |
|
84 | + public function modify_sort_id( $sort_field_id, $form_id ) |
|
85 | 85 | { |
86 | - $time_format = self::_get_time_format_for_field($sort_field_id, $form_id); |
|
86 | + $time_format = self::_get_time_format_for_field( $sort_field_id, $form_id ); |
|
87 | 87 | |
88 | - $date_format = self::date_format($time_format, $sort_field_id); |
|
88 | + $date_format = self::date_format( $time_format, $sort_field_id ); |
|
89 | 89 | |
90 | 90 | // Should look something like `5|:time:|12|:time:|h:i A` |
91 | - $new_sort_field_id = implode($this->_sort_divider, [$sort_field_id, $time_format, $date_format]); |
|
91 | + $new_sort_field_id = implode( $this->_sort_divider, [ $sort_field_id, $time_format, $date_format ] ); |
|
92 | 92 | |
93 | 93 | return $new_sort_field_id; |
94 | 94 | } |
@@ -105,41 +105,41 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return array $criteria If a match, the sorting will be updated to set `is_numeric` to true and make sure the field ID is an int |
107 | 107 | */ |
108 | - public function _maybe_filter_gravity_forms_query($criteria, $form_ids, $view_id) |
|
108 | + public function _maybe_filter_gravity_forms_query( $criteria, $form_ids, $view_id ) |
|
109 | 109 | { |
110 | 110 | |
111 | 111 | // If the search is not being sorted, return early |
112 | - if (empty($criteria['sorting']['key'])) { |
|
112 | + if ( empty( $criteria[ 'sorting' ][ 'key' ] ) ) { |
|
113 | 113 | return $criteria; |
114 | 114 | } |
115 | 115 | |
116 | - $pieces = explode($this->_sort_divider, $criteria['sorting']['key']); |
|
116 | + $pieces = explode( $this->_sort_divider, $criteria[ 'sorting' ][ 'key' ] ); |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * If the sort key does not match the key set in modify_sort_id(), do not modify the Gravity Forms query SQL. |
120 | 120 | * |
121 | 121 | * @see modify_sort_id() |
122 | 122 | */ |
123 | - if (empty($pieces[1])) { |
|
123 | + if ( empty( $pieces[ 1 ] ) ) { |
|
124 | 124 | return $criteria; |
125 | 125 | } |
126 | 126 | |
127 | 127 | // Pass these to the _modify_query_sort_by_time_hack() method |
128 | - $this->_time_format = $pieces[1]; |
|
129 | - $this->_date_format = $pieces[2]; |
|
128 | + $this->_time_format = $pieces[ 1 ]; |
|
129 | + $this->_date_format = $pieces[ 2 ]; |
|
130 | 130 | |
131 | 131 | // Remove fake input IDs (5.1 doesn't exist. Use 5) |
132 | - $criteria['sorting']['key'] = floor($pieces[0]); |
|
132 | + $criteria[ 'sorting' ][ 'key' ] = floor( $pieces[ 0 ] ); |
|
133 | 133 | |
134 | 134 | /** |
135 | 135 | * Make sure sorting is numeric (# of seconds). IMPORTANT. |
136 | 136 | * |
137 | 137 | * @see GVCommon::is_field_numeric() is_numeric should also be set here |
138 | 138 | */ |
139 | - $criteria['sorting']['is_numeric'] = true; |
|
139 | + $criteria[ 'sorting' ][ 'is_numeric' ] = true; |
|
140 | 140 | |
141 | 141 | // Modify the Gravity Forms WP Query |
142 | - add_filter('query', [$this, '_modify_query_sort_by_time_hack']); |
|
142 | + add_filter( 'query', [ $this, '_modify_query_sort_by_time_hack' ] ); |
|
143 | 143 | |
144 | 144 | return $criteria; |
145 | 145 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * |
155 | 155 | * @return string Modified query, if the query matches the expected Gravity Forms SQL string used for sorting time fields. Otherwise, original query. |
156 | 156 | */ |
157 | - public function _modify_query_sort_by_time_hack($query) |
|
157 | + public function _modify_query_sort_by_time_hack( $query ) |
|
158 | 158 | { |
159 | 159 | |
160 | 160 | /** |
@@ -163,14 +163,14 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @see GFFormsModel::sort_by_field_query() |
165 | 165 | */ |
166 | - if (strpos($query, self::GF_SORTING_SQL) > 0) { |
|
167 | - if ($this->_time_format === '24') { |
|
166 | + if ( strpos( $query, self::GF_SORTING_SQL ) > 0 ) { |
|
167 | + if ( $this->_time_format === '24' ) { |
|
168 | 168 | $sql_str_to_date = "STR_TO_DATE( `value`, '%H:%i' )"; |
169 | 169 | } else { |
170 | 170 | $sql_str_to_date = "STR_TO_DATE( `value`, '%h:%i %p' )"; |
171 | 171 | } |
172 | 172 | |
173 | - switch ($this->_date_format) { |
|
173 | + switch ( $this->_date_format ) { |
|
174 | 174 | case 'h': |
175 | 175 | case 'H': |
176 | 176 | $modification = "TIME_FORMAT( {$sql_str_to_date}, '%H' )"; |
@@ -188,40 +188,40 @@ discard block |
||
188 | 188 | * Convert the time (12:30 pm) to the MySQL `TIME_TO_SEC()` value for that time (45000) |
189 | 189 | * This way, Gravity Forms is able to sort numerically. |
190 | 190 | */ |
191 | - $replacement_query = str_replace('value', "{$modification} as value", self::GF_SORTING_SQL); |
|
191 | + $replacement_query = str_replace( 'value', "{$modification} as value", self::GF_SORTING_SQL ); |
|
192 | 192 | |
193 | 193 | /** |
194 | 194 | * Replace it in the main query. |
195 | 195 | */ |
196 | - $query = str_replace(self::GF_SORTING_SQL, $replacement_query, $query); |
|
196 | + $query = str_replace( self::GF_SORTING_SQL, $replacement_query, $query ); |
|
197 | 197 | |
198 | 198 | /** |
199 | 199 | * REMOVE the Gravity Forms WP Query modifications! |
200 | 200 | */ |
201 | - remove_filter('query', [$this, '_modify_query_sort_by_time_hack']); |
|
201 | + remove_filter( 'query', [ $this, '_modify_query_sort_by_time_hack' ] ); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | return $query; |
205 | 205 | } |
206 | 206 | |
207 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
207 | + public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) |
|
208 | 208 | { |
209 | 209 | |
210 | 210 | // Set variables |
211 | - parent::field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id); |
|
211 | + parent::field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ); |
|
212 | 212 | |
213 | - if ('edit' === $context) { |
|
213 | + if ( 'edit' === $context ) { |
|
214 | 214 | return $field_options; |
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
218 | 218 | * Set default date format based on field ID and Form ID. |
219 | 219 | */ |
220 | - add_filter('gravityview_date_format', [$this, '_filter_date_display_date_format']); |
|
220 | + add_filter( 'gravityview_date_format', [ $this, '_filter_date_display_date_format' ] ); |
|
221 | 221 | |
222 | - $this->add_field_support('date_display', $field_options); |
|
222 | + $this->add_field_support( 'date_display', $field_options ); |
|
223 | 223 | |
224 | - remove_filter('gravityview_date_format', [$this, '_filter_date_display_date_format']); |
|
224 | + remove_filter( 'gravityview_date_format', [ $this, '_filter_date_display_date_format' ] ); |
|
225 | 225 | |
226 | 226 | return $field_options; |
227 | 227 | } |
@@ -237,9 +237,9 @@ discard block |
||
237 | 237 | { |
238 | 238 | global $post; |
239 | 239 | |
240 | - $current_form = isset($_POST['form_id']) ? intval($_POST['form_id']) : gravityview_get_form_id($post->ID); |
|
240 | + $current_form = isset( $_POST[ 'form_id' ] ) ? intval( $_POST[ 'form_id' ] ) : gravityview_get_form_id( $post->ID ); |
|
241 | 241 | |
242 | - return self::_get_time_format_for_field($this->_field_id, $current_form); |
|
242 | + return self::_get_time_format_for_field( $this->_field_id, $current_form ); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
@@ -252,18 +252,18 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @return string Either "12" or "24". "12" is default. |
254 | 254 | */ |
255 | - public static function _get_time_format_for_field($field_id, $form_id = 0) |
|
255 | + public static function _get_time_format_for_field( $field_id, $form_id = 0 ) |
|
256 | 256 | { |
257 | 257 | |
258 | 258 | // GF defaults to 12, so should we. |
259 | 259 | $time_format = '12'; |
260 | 260 | |
261 | - if ($form_id) { |
|
262 | - $form = GFAPI::get_form($form_id); |
|
261 | + if ( $form_id ) { |
|
262 | + $form = GFAPI::get_form( $form_id ); |
|
263 | 263 | |
264 | - if ($form) { |
|
265 | - $field = GFFormsModel::get_field($form, floor($field_id)); |
|
266 | - if ($field && $field instanceof GF_Field_Time) { |
|
264 | + if ( $form ) { |
|
265 | + $field = GFFormsModel::get_field( $form, floor( $field_id ) ); |
|
266 | + if ( $field && $field instanceof GF_Field_Time ) { |
|
267 | 267 | $field->sanitize_settings(); // Make sure time is set |
268 | 268 | $time_format = $field->timeFormat; |
269 | 269 | } |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | $time_format = $this->_get_time_format(); |
286 | 286 | $field_id = $this->_field_id; |
287 | 287 | |
288 | - return self::date_format($time_format, $field_id); |
|
288 | + return self::date_format( $time_format, $field_id ); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
@@ -298,17 +298,17 @@ discard block |
||
298 | 298 | * |
299 | 299 | * @return string PHP date format for the time |
300 | 300 | */ |
301 | - public static function date_format($time_format = '12', $field_id = 0) |
|
301 | + public static function date_format( $time_format = '12', $field_id = 0 ) |
|
302 | 302 | { |
303 | - $field_input_id = gravityview_get_input_id_from_id($field_id); |
|
303 | + $field_input_id = gravityview_get_input_id_from_id( $field_id ); |
|
304 | 304 | |
305 | 305 | $default = 'h:i A'; |
306 | 306 | |
307 | 307 | // This doesn't take into account 24-hour |
308 | - switch ($field_input_id) { |
|
308 | + switch ( $field_input_id ) { |
|
309 | 309 | // Hours |
310 | 310 | case 1: |
311 | - return ($time_format === '12') ? 'h' : 'H'; |
|
311 | + return ( $time_format === '12' ) ? 'h' : 'H'; |
|
312 | 312 | break; |
313 | 313 | // Minutes |
314 | 314 | case 2: |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | break; |
321 | 321 | // Full time field |
322 | 322 | case 0: |
323 | - return ($time_format === '12') ? $default : 'H:i'; |
|
323 | + return ( $time_format === '12' ) ? $default : 'H:i'; |
|
324 | 324 | break; |
325 | 325 | } |
326 | 326 |
@@ -6,8 +6,7 @@ discard block |
||
6 | 6 | /** |
7 | 7 | * Add custom options for date fields. |
8 | 8 | */ |
9 | -class GravityView_Field_Time extends GravityView_Field |
|
10 | -{ |
|
9 | +class GravityView_Field_Time extends GravityView_Field { |
|
11 | 10 | public $name = 'time'; |
12 | 11 | |
13 | 12 | public $is_searchable = true; |
@@ -59,8 +58,7 @@ discard block |
||
59 | 58 | /** |
60 | 59 | * GravityView_Field_Time constructor. |
61 | 60 | */ |
62 | - public function __construct() |
|
63 | - { |
|
61 | + public function __construct() { |
|
64 | 62 | $this->label = esc_html__('Time', 'gravityview'); |
65 | 63 | |
66 | 64 | parent::__construct(); |
@@ -81,8 +79,7 @@ discard block |
||
81 | 79 | * |
82 | 80 | * @return string Modified sort key imploded with $_sort_divider, like `5|:time:|12|:time:|h:i A` |
83 | 81 | */ |
84 | - public function modify_sort_id($sort_field_id, $form_id) |
|
85 | - { |
|
82 | + public function modify_sort_id($sort_field_id, $form_id) { |
|
86 | 83 | $time_format = self::_get_time_format_for_field($sort_field_id, $form_id); |
87 | 84 | |
88 | 85 | $date_format = self::date_format($time_format, $sort_field_id); |
@@ -105,8 +102,7 @@ discard block |
||
105 | 102 | * |
106 | 103 | * @return array $criteria If a match, the sorting will be updated to set `is_numeric` to true and make sure the field ID is an int |
107 | 104 | */ |
108 | - public function _maybe_filter_gravity_forms_query($criteria, $form_ids, $view_id) |
|
109 | - { |
|
105 | + public function _maybe_filter_gravity_forms_query($criteria, $form_ids, $view_id) { |
|
110 | 106 | |
111 | 107 | // If the search is not being sorted, return early |
112 | 108 | if (empty($criteria['sorting']['key'])) { |
@@ -154,8 +150,7 @@ discard block |
||
154 | 150 | * |
155 | 151 | * @return string Modified query, if the query matches the expected Gravity Forms SQL string used for sorting time fields. Otherwise, original query. |
156 | 152 | */ |
157 | - public function _modify_query_sort_by_time_hack($query) |
|
158 | - { |
|
153 | + public function _modify_query_sort_by_time_hack($query) { |
|
159 | 154 | |
160 | 155 | /** |
161 | 156 | * If this is a Gravity Forms entry selection sorting query, generated by sort_by_field_query(), |
@@ -204,8 +199,7 @@ discard block |
||
204 | 199 | return $query; |
205 | 200 | } |
206 | 201 | |
207 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
208 | - { |
|
202 | + public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) { |
|
209 | 203 | |
210 | 204 | // Set variables |
211 | 205 | parent::field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id); |
@@ -233,8 +227,7 @@ discard block |
||
233 | 227 | * |
234 | 228 | * @return string Either "12" or "24". "12" is default. |
235 | 229 | */ |
236 | - private function _get_time_format() |
|
237 | - { |
|
230 | + private function _get_time_format() { |
|
238 | 231 | global $post; |
239 | 232 | |
240 | 233 | $current_form = isset($_POST['form_id']) ? intval($_POST['form_id']) : gravityview_get_form_id($post->ID); |
@@ -252,8 +245,7 @@ discard block |
||
252 | 245 | * |
253 | 246 | * @return string Either "12" or "24". "12" is default. |
254 | 247 | */ |
255 | - public static function _get_time_format_for_field($field_id, $form_id = 0) |
|
256 | - { |
|
248 | + public static function _get_time_format_for_field($field_id, $form_id = 0) { |
|
257 | 249 | |
258 | 250 | // GF defaults to 12, so should we. |
259 | 251 | $time_format = '12'; |
@@ -280,8 +272,7 @@ discard block |
||
280 | 272 | * |
281 | 273 | * @return string PHP date() format text to to display the correctly formatted time value for the newly created field |
282 | 274 | */ |
283 | - public function _filter_date_display_date_format() |
|
284 | - { |
|
275 | + public function _filter_date_display_date_format() { |
|
285 | 276 | $time_format = $this->_get_time_format(); |
286 | 277 | $field_id = $this->_field_id; |
287 | 278 | |
@@ -298,8 +289,7 @@ discard block |
||
298 | 289 | * |
299 | 290 | * @return string PHP date format for the time |
300 | 291 | */ |
301 | - public static function date_format($time_format = '12', $field_id = 0) |
|
302 | - { |
|
292 | + public static function date_format($time_format = '12', $field_id = 0) { |
|
303 | 293 | $field_input_id = gravityview_get_input_id_from_id($field_id); |
304 | 294 | |
305 | 295 | $default = 'h:i A'; |
@@ -8,73 +8,73 @@ |
||
8 | 8 | */ |
9 | 9 | class GravityView_Field_Email extends GravityView_Field |
10 | 10 | { |
11 | - public $name = 'email'; |
|
11 | + public $name = 'email'; |
|
12 | 12 | |
13 | - public $is_searchable = true; |
|
13 | + public $is_searchable = true; |
|
14 | 14 | |
15 | - public $search_operators = ['is', 'isnot', 'contains', 'starts_with', 'ends_with']; |
|
15 | + public $search_operators = ['is', 'isnot', 'contains', 'starts_with', 'ends_with']; |
|
16 | 16 | |
17 | - public $_gf_field_class_name = 'GF_Field_Email'; |
|
17 | + public $_gf_field_class_name = 'GF_Field_Email'; |
|
18 | 18 | |
19 | - public $group = 'advanced'; |
|
19 | + public $group = 'advanced'; |
|
20 | 20 | |
21 | - public $icon = 'dashicons-email'; |
|
21 | + public $icon = 'dashicons-email'; |
|
22 | 22 | |
23 | - public function __construct() |
|
24 | - { |
|
25 | - $this->label = esc_html__('Email', 'gravityview'); |
|
26 | - parent::__construct(); |
|
27 | - } |
|
23 | + public function __construct() |
|
24 | + { |
|
25 | + $this->label = esc_html__('Email', 'gravityview'); |
|
26 | + parent::__construct(); |
|
27 | + } |
|
28 | 28 | |
29 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
30 | - { |
|
29 | + public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
30 | + { |
|
31 | 31 | |
32 | - // It makes no sense to use this as the link. |
|
33 | - unset($field_options['show_as_link']); |
|
32 | + // It makes no sense to use this as the link. |
|
33 | + unset($field_options['show_as_link']); |
|
34 | 34 | |
35 | - if ('edit' === $context) { |
|
36 | - return $field_options; |
|
37 | - } |
|
35 | + if ('edit' === $context) { |
|
36 | + return $field_options; |
|
37 | + } |
|
38 | 38 | |
39 | - $email_options = [ |
|
40 | - 'emailmailto' => [ |
|
41 | - 'type' => 'checkbox', |
|
42 | - 'value' => true, |
|
43 | - 'label' => __('Link the Email Address', 'gravityview'), |
|
44 | - 'desc' => __('Clicking the link will generate a new email.', 'gravityview'), |
|
45 | - 'group' => 'field', |
|
46 | - ], |
|
47 | - 'emailsubject' => [ |
|
48 | - 'type' => 'text', |
|
49 | - 'label' => __('Email Subject', 'gravityview'), |
|
50 | - 'value' => '', |
|
51 | - 'desc' => __('Set the default email subject line.', 'gravityview'), |
|
52 | - 'merge_tags' => 'force', |
|
53 | - 'requires' => 'emailmailto', |
|
54 | - 'group' => 'field', |
|
55 | - ], |
|
56 | - 'emailbody' => [ |
|
57 | - 'type' => 'textarea', |
|
58 | - 'label' => __('Email Body', 'gravityview'), |
|
59 | - 'value' => '', |
|
60 | - 'desc' => __('Set the default email content.', 'gravityview'), |
|
61 | - 'merge_tags' => 'force', |
|
62 | - 'class' => 'widefat code', |
|
63 | - 'requires' => 'emailmailto', |
|
64 | - 'group' => 'field', |
|
65 | - ], |
|
66 | - 'emailencrypt' => [ |
|
67 | - 'type' => 'checkbox', |
|
68 | - 'value' => true, |
|
69 | - 'label' => __('Encrypt Email Address', 'gravityview'), |
|
70 | - 'desc' => __('Make it harder for spammers to get email addresses from your entries. Email addresses will not be visible with Javascript disabled.', 'gravityview'), |
|
71 | - 'group' => 'advanced', |
|
72 | - 'priority' => 100, |
|
73 | - ], |
|
74 | - ]; |
|
39 | + $email_options = [ |
|
40 | + 'emailmailto' => [ |
|
41 | + 'type' => 'checkbox', |
|
42 | + 'value' => true, |
|
43 | + 'label' => __('Link the Email Address', 'gravityview'), |
|
44 | + 'desc' => __('Clicking the link will generate a new email.', 'gravityview'), |
|
45 | + 'group' => 'field', |
|
46 | + ], |
|
47 | + 'emailsubject' => [ |
|
48 | + 'type' => 'text', |
|
49 | + 'label' => __('Email Subject', 'gravityview'), |
|
50 | + 'value' => '', |
|
51 | + 'desc' => __('Set the default email subject line.', 'gravityview'), |
|
52 | + 'merge_tags' => 'force', |
|
53 | + 'requires' => 'emailmailto', |
|
54 | + 'group' => 'field', |
|
55 | + ], |
|
56 | + 'emailbody' => [ |
|
57 | + 'type' => 'textarea', |
|
58 | + 'label' => __('Email Body', 'gravityview'), |
|
59 | + 'value' => '', |
|
60 | + 'desc' => __('Set the default email content.', 'gravityview'), |
|
61 | + 'merge_tags' => 'force', |
|
62 | + 'class' => 'widefat code', |
|
63 | + 'requires' => 'emailmailto', |
|
64 | + 'group' => 'field', |
|
65 | + ], |
|
66 | + 'emailencrypt' => [ |
|
67 | + 'type' => 'checkbox', |
|
68 | + 'value' => true, |
|
69 | + 'label' => __('Encrypt Email Address', 'gravityview'), |
|
70 | + 'desc' => __('Make it harder for spammers to get email addresses from your entries. Email addresses will not be visible with Javascript disabled.', 'gravityview'), |
|
71 | + 'group' => 'advanced', |
|
72 | + 'priority' => 100, |
|
73 | + ], |
|
74 | + ]; |
|
75 | 75 | |
76 | - return $email_options + $field_options; |
|
77 | - } |
|
76 | + return $email_options + $field_options; |
|
77 | + } |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | new GravityView_Field_Email(); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | public $is_searchable = true; |
14 | 14 | |
15 | - public $search_operators = ['is', 'isnot', 'contains', 'starts_with', 'ends_with']; |
|
15 | + public $search_operators = [ 'is', 'isnot', 'contains', 'starts_with', 'ends_with' ]; |
|
16 | 16 | |
17 | 17 | public $_gf_field_class_name = 'GF_Field_Email'; |
18 | 18 | |
@@ -22,17 +22,17 @@ discard block |
||
22 | 22 | |
23 | 23 | public function __construct() |
24 | 24 | { |
25 | - $this->label = esc_html__('Email', 'gravityview'); |
|
25 | + $this->label = esc_html__( 'Email', 'gravityview' ); |
|
26 | 26 | parent::__construct(); |
27 | 27 | } |
28 | 28 | |
29 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
29 | + public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) |
|
30 | 30 | { |
31 | 31 | |
32 | 32 | // It makes no sense to use this as the link. |
33 | - unset($field_options['show_as_link']); |
|
33 | + unset( $field_options[ 'show_as_link' ] ); |
|
34 | 34 | |
35 | - if ('edit' === $context) { |
|
35 | + if ( 'edit' === $context ) { |
|
36 | 36 | return $field_options; |
37 | 37 | } |
38 | 38 | |
@@ -40,24 +40,24 @@ discard block |
||
40 | 40 | 'emailmailto' => [ |
41 | 41 | 'type' => 'checkbox', |
42 | 42 | 'value' => true, |
43 | - 'label' => __('Link the Email Address', 'gravityview'), |
|
44 | - 'desc' => __('Clicking the link will generate a new email.', 'gravityview'), |
|
43 | + 'label' => __( 'Link the Email Address', 'gravityview' ), |
|
44 | + 'desc' => __( 'Clicking the link will generate a new email.', 'gravityview' ), |
|
45 | 45 | 'group' => 'field', |
46 | 46 | ], |
47 | 47 | 'emailsubject' => [ |
48 | 48 | 'type' => 'text', |
49 | - 'label' => __('Email Subject', 'gravityview'), |
|
49 | + 'label' => __( 'Email Subject', 'gravityview' ), |
|
50 | 50 | 'value' => '', |
51 | - 'desc' => __('Set the default email subject line.', 'gravityview'), |
|
51 | + 'desc' => __( 'Set the default email subject line.', 'gravityview' ), |
|
52 | 52 | 'merge_tags' => 'force', |
53 | 53 | 'requires' => 'emailmailto', |
54 | 54 | 'group' => 'field', |
55 | 55 | ], |
56 | 56 | 'emailbody' => [ |
57 | 57 | 'type' => 'textarea', |
58 | - 'label' => __('Email Body', 'gravityview'), |
|
58 | + 'label' => __( 'Email Body', 'gravityview' ), |
|
59 | 59 | 'value' => '', |
60 | - 'desc' => __('Set the default email content.', 'gravityview'), |
|
60 | + 'desc' => __( 'Set the default email content.', 'gravityview' ), |
|
61 | 61 | 'merge_tags' => 'force', |
62 | 62 | 'class' => 'widefat code', |
63 | 63 | 'requires' => 'emailmailto', |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | 'emailencrypt' => [ |
67 | 67 | 'type' => 'checkbox', |
68 | 68 | 'value' => true, |
69 | - 'label' => __('Encrypt Email Address', 'gravityview'), |
|
70 | - 'desc' => __('Make it harder for spammers to get email addresses from your entries. Email addresses will not be visible with Javascript disabled.', 'gravityview'), |
|
69 | + 'label' => __( 'Encrypt Email Address', 'gravityview' ), |
|
70 | + 'desc' => __( 'Make it harder for spammers to get email addresses from your entries. Email addresses will not be visible with Javascript disabled.', 'gravityview' ), |
|
71 | 71 | 'group' => 'advanced', |
72 | 72 | 'priority' => 100, |
73 | 73 | ], |
@@ -6,8 +6,7 @@ discard block |
||
6 | 6 | /** |
7 | 7 | * Add custom options for email fields. |
8 | 8 | */ |
9 | -class GravityView_Field_Email extends GravityView_Field |
|
10 | -{ |
|
9 | +class GravityView_Field_Email extends GravityView_Field { |
|
11 | 10 | public $name = 'email'; |
12 | 11 | |
13 | 12 | public $is_searchable = true; |
@@ -20,14 +19,12 @@ discard block |
||
20 | 19 | |
21 | 20 | public $icon = 'dashicons-email'; |
22 | 21 | |
23 | - public function __construct() |
|
24 | - { |
|
22 | + public function __construct() { |
|
25 | 23 | $this->label = esc_html__('Email', 'gravityview'); |
26 | 24 | parent::__construct(); |
27 | 25 | } |
28 | 26 | |
29 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
30 | - { |
|
27 | + public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) { |
|
31 | 28 | |
32 | 29 | // It makes no sense to use this as the link. |
33 | 30 | unset($field_options['show_as_link']); |
@@ -6,54 +6,54 @@ |
||
6 | 6 | */ |
7 | 7 | class GravityView_Field_Payment_Date extends GravityView_Field_Date_Created |
8 | 8 | { |
9 | - public $name = 'payment_date'; |
|
10 | - |
|
11 | - public $is_searchable = true; |
|
12 | - |
|
13 | - public $search_operators = ['less_than', 'greater_than', 'is', 'isnot']; |
|
14 | - |
|
15 | - public $group = 'pricing'; |
|
16 | - |
|
17 | - public $_custom_merge_tag = 'payment_date'; |
|
18 | - |
|
19 | - public $icon = 'dashicons-cart'; |
|
20 | - |
|
21 | - /** |
|
22 | - * GravityView_Field_Date_Created constructor. |
|
23 | - */ |
|
24 | - public function __construct() |
|
25 | - { |
|
26 | - |
|
27 | - // Constructor before the variables because the class extends Date_Created |
|
28 | - parent::__construct(); |
|
29 | - |
|
30 | - $this->label = esc_html__('Payment Date', 'gravityview'); |
|
31 | - $this->description = esc_html__('The date the payment was received.', 'gravityview'); |
|
32 | - |
|
33 | - add_filter('gravityview/field/payment_date/value', [$this, 'get_value'], 10, 6); |
|
34 | - } |
|
35 | - |
|
36 | - /** |
|
37 | - * Filter the value of the field, future. |
|
38 | - * |
|
39 | - * @since 2.0 |
|
40 | - * |
|
41 | - * @param mixed $value The value of the field. |
|
42 | - * @param \GV\Field $field The field as seen by future. |
|
43 | - * @param \GV\View $view The view requested in. |
|
44 | - * @param \GV\Source $source The data source (form). |
|
45 | - * @param \GV\Entry $entry The entry. |
|
46 | - * @param \GV\Request $request The request context. |
|
47 | - * |
|
48 | - * @return mixed $value The filtered value. |
|
49 | - */ |
|
50 | - public function get_value($value, $field, $view, $source, $entry, $request) |
|
51 | - { |
|
52 | - /** Supply the raw value instead whatever may have been filtered before. */ |
|
53 | - $raw_value = empty($entry[$this->name]) ? null : $entry[$this->name]; |
|
54 | - |
|
55 | - return $this->get_content($value, $entry->as_entry(), $field->as_configuration(), ['value' => $raw_value]); |
|
56 | - } |
|
9 | + public $name = 'payment_date'; |
|
10 | + |
|
11 | + public $is_searchable = true; |
|
12 | + |
|
13 | + public $search_operators = ['less_than', 'greater_than', 'is', 'isnot']; |
|
14 | + |
|
15 | + public $group = 'pricing'; |
|
16 | + |
|
17 | + public $_custom_merge_tag = 'payment_date'; |
|
18 | + |
|
19 | + public $icon = 'dashicons-cart'; |
|
20 | + |
|
21 | + /** |
|
22 | + * GravityView_Field_Date_Created constructor. |
|
23 | + */ |
|
24 | + public function __construct() |
|
25 | + { |
|
26 | + |
|
27 | + // Constructor before the variables because the class extends Date_Created |
|
28 | + parent::__construct(); |
|
29 | + |
|
30 | + $this->label = esc_html__('Payment Date', 'gravityview'); |
|
31 | + $this->description = esc_html__('The date the payment was received.', 'gravityview'); |
|
32 | + |
|
33 | + add_filter('gravityview/field/payment_date/value', [$this, 'get_value'], 10, 6); |
|
34 | + } |
|
35 | + |
|
36 | + /** |
|
37 | + * Filter the value of the field, future. |
|
38 | + * |
|
39 | + * @since 2.0 |
|
40 | + * |
|
41 | + * @param mixed $value The value of the field. |
|
42 | + * @param \GV\Field $field The field as seen by future. |
|
43 | + * @param \GV\View $view The view requested in. |
|
44 | + * @param \GV\Source $source The data source (form). |
|
45 | + * @param \GV\Entry $entry The entry. |
|
46 | + * @param \GV\Request $request The request context. |
|
47 | + * |
|
48 | + * @return mixed $value The filtered value. |
|
49 | + */ |
|
50 | + public function get_value($value, $field, $view, $source, $entry, $request) |
|
51 | + { |
|
52 | + /** Supply the raw value instead whatever may have been filtered before. */ |
|
53 | + $raw_value = empty($entry[$this->name]) ? null : $entry[$this->name]; |
|
54 | + |
|
55 | + return $this->get_content($value, $entry->as_entry(), $field->as_configuration(), ['value' => $raw_value]); |
|
56 | + } |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | new GravityView_Field_Payment_Date(); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | public $is_searchable = true; |
12 | 12 | |
13 | - public $search_operators = ['less_than', 'greater_than', 'is', 'isnot']; |
|
13 | + public $search_operators = [ 'less_than', 'greater_than', 'is', 'isnot' ]; |
|
14 | 14 | |
15 | 15 | public $group = 'pricing'; |
16 | 16 | |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | // Constructor before the variables because the class extends Date_Created |
28 | 28 | parent::__construct(); |
29 | 29 | |
30 | - $this->label = esc_html__('Payment Date', 'gravityview'); |
|
31 | - $this->description = esc_html__('The date the payment was received.', 'gravityview'); |
|
30 | + $this->label = esc_html__( 'Payment Date', 'gravityview' ); |
|
31 | + $this->description = esc_html__( 'The date the payment was received.', 'gravityview' ); |
|
32 | 32 | |
33 | - add_filter('gravityview/field/payment_date/value', [$this, 'get_value'], 10, 6); |
|
33 | + add_filter( 'gravityview/field/payment_date/value', [ $this, 'get_value' ], 10, 6 ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @return mixed $value The filtered value. |
49 | 49 | */ |
50 | - public function get_value($value, $field, $view, $source, $entry, $request) |
|
50 | + public function get_value( $value, $field, $view, $source, $entry, $request ) |
|
51 | 51 | { |
52 | 52 | /** Supply the raw value instead whatever may have been filtered before. */ |
53 | - $raw_value = empty($entry[$this->name]) ? null : $entry[$this->name]; |
|
53 | + $raw_value = empty( $entry[ $this->name ] ) ? null : $entry[ $this->name ]; |
|
54 | 54 | |
55 | - return $this->get_content($value, $entry->as_entry(), $field->as_configuration(), ['value' => $raw_value]); |
|
55 | + return $this->get_content( $value, $entry->as_entry(), $field->as_configuration(), [ 'value' => $raw_value ] ); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 |
@@ -4,8 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | * @since 1.16 |
6 | 6 | */ |
7 | -class GravityView_Field_Payment_Date extends GravityView_Field_Date_Created |
|
8 | -{ |
|
7 | +class GravityView_Field_Payment_Date extends GravityView_Field_Date_Created { |
|
9 | 8 | public $name = 'payment_date'; |
10 | 9 | |
11 | 10 | public $is_searchable = true; |
@@ -21,8 +20,7 @@ discard block |
||
21 | 20 | /** |
22 | 21 | * GravityView_Field_Date_Created constructor. |
23 | 22 | */ |
24 | - public function __construct() |
|
25 | - { |
|
23 | + public function __construct() { |
|
26 | 24 | |
27 | 25 | // Constructor before the variables because the class extends Date_Created |
28 | 26 | parent::__construct(); |
@@ -47,8 +45,7 @@ discard block |
||
47 | 45 | * |
48 | 46 | * @return mixed $value The filtered value. |
49 | 47 | */ |
50 | - public function get_value($value, $field, $view, $source, $entry, $request) |
|
51 | - { |
|
48 | + public function get_value($value, $field, $view, $source, $entry, $request) { |
|
52 | 49 | /** Supply the raw value instead whatever may have been filtered before. */ |
53 | 50 | $raw_value = empty($entry[$this->name]) ? null : $entry[$this->name]; |
54 | 51 |