@@ -6,107 +6,107 @@ |
||
6 | 6 | */ |
7 | 7 | class GravityView_Field_Transaction_Type extends GravityView_Field |
8 | 8 | { |
9 | - public $name = 'transaction_type'; |
|
10 | - |
|
11 | - public $is_searchable = true; |
|
12 | - |
|
13 | - public $is_numeric = true; |
|
14 | - |
|
15 | - public $search_operators = ['is', 'isnot', 'in', 'not in']; |
|
16 | - |
|
17 | - public $group = 'pricing'; |
|
18 | - |
|
19 | - public $_custom_merge_tag = 'transaction_type'; |
|
20 | - |
|
21 | - public $icon = 'dashicons-cart'; |
|
22 | - |
|
23 | - /** |
|
24 | - * @var int One-time payments are stored by Gravity Forms in the database as `1` |
|
25 | - */ |
|
26 | - const ONE_TIME_PAYMENT = 1; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var int Subscriptions are stored by Gravity Forms in the database as `2` |
|
30 | - */ |
|
31 | - const SUBSCRIPTION = 2; |
|
32 | - |
|
33 | - /** |
|
34 | - * GravityView_Field_Transaction_Type constructor. |
|
35 | - */ |
|
36 | - public function __construct() |
|
37 | - { |
|
38 | - $this->label = esc_html__('Transaction Type', 'gravityview'); |
|
39 | - $this->description = esc_html__('The type of the order: one-time payment or subscription', 'gravityview'); |
|
40 | - |
|
41 | - add_filter('gravityview_field_entry_value_'.$this->name.'_pre_link', [$this, 'get_content'], 10, 4); |
|
42 | - add_filter('gravityview/field/transaction_type/value', [$this, 'get_value'], 10); |
|
43 | - |
|
44 | - parent::__construct(); |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * Filter the value of the field. |
|
49 | - * |
|
50 | - * @todo Consider how to add to parent class |
|
51 | - * |
|
52 | - * @since 1.16 |
|
53 | - * |
|
54 | - * @param string $output HTML value output |
|
55 | - * @param array $entry The GF entry array |
|
56 | - * @param array $field_settings Settings for the particular GV field |
|
57 | - * @param array $field Current field being displayed |
|
58 | - * |
|
59 | - * @return string values for this field based on the numeric values used by Gravity Forms |
|
60 | - */ |
|
61 | - public function get_content($output, $entry = [], $field_settings = [], $field = []) |
|
62 | - { |
|
63 | - |
|
64 | - /** Overridden by a template. */ |
|
65 | - if (!empty($field['field_path'])) { |
|
66 | - return $output; |
|
67 | - } |
|
68 | - |
|
69 | - return $this->get_string_from_value($output); |
|
70 | - } |
|
71 | - |
|
72 | - /** |
|
73 | - * Filter the value of the field (future). |
|
74 | - * |
|
75 | - * @since 2.0 |
|
76 | - * |
|
77 | - * @param mixed $value The value in. |
|
78 | - * |
|
79 | - * @return mixed The value out. |
|
80 | - */ |
|
81 | - public function get_value($value) |
|
82 | - { |
|
83 | - return $this->get_string_from_value($value); |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * Get the string output based on the numeric value used by Gravity Forms. |
|
88 | - * |
|
89 | - * @since 1.16 |
|
90 | - * |
|
91 | - * @param int|string $value Number value for the field |
|
92 | - * |
|
93 | - * @return string Based on $value; `1`: "One-Time Payment"; `2`: "Subscription" |
|
94 | - */ |
|
95 | - private function get_string_from_value($value) |
|
96 | - { |
|
97 | - switch (intval($value)) { |
|
98 | - case self::ONE_TIME_PAYMENT: |
|
99 | - default: |
|
100 | - $return = __('One-Time Payment', 'gravityview'); |
|
101 | - break; |
|
102 | - |
|
103 | - case self::SUBSCRIPTION: |
|
104 | - $return = __('Subscription', 'gravityview'); |
|
105 | - break; |
|
106 | - } |
|
107 | - |
|
108 | - return $return; |
|
109 | - } |
|
9 | + public $name = 'transaction_type'; |
|
10 | + |
|
11 | + public $is_searchable = true; |
|
12 | + |
|
13 | + public $is_numeric = true; |
|
14 | + |
|
15 | + public $search_operators = ['is', 'isnot', 'in', 'not in']; |
|
16 | + |
|
17 | + public $group = 'pricing'; |
|
18 | + |
|
19 | + public $_custom_merge_tag = 'transaction_type'; |
|
20 | + |
|
21 | + public $icon = 'dashicons-cart'; |
|
22 | + |
|
23 | + /** |
|
24 | + * @var int One-time payments are stored by Gravity Forms in the database as `1` |
|
25 | + */ |
|
26 | + const ONE_TIME_PAYMENT = 1; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var int Subscriptions are stored by Gravity Forms in the database as `2` |
|
30 | + */ |
|
31 | + const SUBSCRIPTION = 2; |
|
32 | + |
|
33 | + /** |
|
34 | + * GravityView_Field_Transaction_Type constructor. |
|
35 | + */ |
|
36 | + public function __construct() |
|
37 | + { |
|
38 | + $this->label = esc_html__('Transaction Type', 'gravityview'); |
|
39 | + $this->description = esc_html__('The type of the order: one-time payment or subscription', 'gravityview'); |
|
40 | + |
|
41 | + add_filter('gravityview_field_entry_value_'.$this->name.'_pre_link', [$this, 'get_content'], 10, 4); |
|
42 | + add_filter('gravityview/field/transaction_type/value', [$this, 'get_value'], 10); |
|
43 | + |
|
44 | + parent::__construct(); |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * Filter the value of the field. |
|
49 | + * |
|
50 | + * @todo Consider how to add to parent class |
|
51 | + * |
|
52 | + * @since 1.16 |
|
53 | + * |
|
54 | + * @param string $output HTML value output |
|
55 | + * @param array $entry The GF entry array |
|
56 | + * @param array $field_settings Settings for the particular GV field |
|
57 | + * @param array $field Current field being displayed |
|
58 | + * |
|
59 | + * @return string values for this field based on the numeric values used by Gravity Forms |
|
60 | + */ |
|
61 | + public function get_content($output, $entry = [], $field_settings = [], $field = []) |
|
62 | + { |
|
63 | + |
|
64 | + /** Overridden by a template. */ |
|
65 | + if (!empty($field['field_path'])) { |
|
66 | + return $output; |
|
67 | + } |
|
68 | + |
|
69 | + return $this->get_string_from_value($output); |
|
70 | + } |
|
71 | + |
|
72 | + /** |
|
73 | + * Filter the value of the field (future). |
|
74 | + * |
|
75 | + * @since 2.0 |
|
76 | + * |
|
77 | + * @param mixed $value The value in. |
|
78 | + * |
|
79 | + * @return mixed The value out. |
|
80 | + */ |
|
81 | + public function get_value($value) |
|
82 | + { |
|
83 | + return $this->get_string_from_value($value); |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * Get the string output based on the numeric value used by Gravity Forms. |
|
88 | + * |
|
89 | + * @since 1.16 |
|
90 | + * |
|
91 | + * @param int|string $value Number value for the field |
|
92 | + * |
|
93 | + * @return string Based on $value; `1`: "One-Time Payment"; `2`: "Subscription" |
|
94 | + */ |
|
95 | + private function get_string_from_value($value) |
|
96 | + { |
|
97 | + switch (intval($value)) { |
|
98 | + case self::ONE_TIME_PAYMENT: |
|
99 | + default: |
|
100 | + $return = __('One-Time Payment', 'gravityview'); |
|
101 | + break; |
|
102 | + |
|
103 | + case self::SUBSCRIPTION: |
|
104 | + $return = __('Subscription', 'gravityview'); |
|
105 | + break; |
|
106 | + } |
|
107 | + |
|
108 | + return $return; |
|
109 | + } |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | new GravityView_Field_Transaction_Type(); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | public $is_numeric = true; |
14 | 14 | |
15 | - public $search_operators = ['is', 'isnot', 'in', 'not in']; |
|
15 | + public $search_operators = [ 'is', 'isnot', 'in', 'not in' ]; |
|
16 | 16 | |
17 | 17 | public $group = 'pricing'; |
18 | 18 | |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function __construct() |
37 | 37 | { |
38 | - $this->label = esc_html__('Transaction Type', 'gravityview'); |
|
39 | - $this->description = esc_html__('The type of the order: one-time payment or subscription', 'gravityview'); |
|
38 | + $this->label = esc_html__( 'Transaction Type', 'gravityview' ); |
|
39 | + $this->description = esc_html__( 'The type of the order: one-time payment or subscription', 'gravityview' ); |
|
40 | 40 | |
41 | - add_filter('gravityview_field_entry_value_'.$this->name.'_pre_link', [$this, 'get_content'], 10, 4); |
|
42 | - add_filter('gravityview/field/transaction_type/value', [$this, 'get_value'], 10); |
|
41 | + add_filter( 'gravityview_field_entry_value_' . $this->name . '_pre_link', [ $this, 'get_content' ], 10, 4 ); |
|
42 | + add_filter( 'gravityview/field/transaction_type/value', [ $this, 'get_value' ], 10 ); |
|
43 | 43 | |
44 | 44 | parent::__construct(); |
45 | 45 | } |
@@ -58,15 +58,15 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @return string values for this field based on the numeric values used by Gravity Forms |
60 | 60 | */ |
61 | - public function get_content($output, $entry = [], $field_settings = [], $field = []) |
|
61 | + public function get_content( $output, $entry = [ ], $field_settings = [ ], $field = [ ] ) |
|
62 | 62 | { |
63 | 63 | |
64 | 64 | /** Overridden by a template. */ |
65 | - if (!empty($field['field_path'])) { |
|
65 | + if ( ! empty( $field[ 'field_path' ] ) ) { |
|
66 | 66 | return $output; |
67 | 67 | } |
68 | 68 | |
69 | - return $this->get_string_from_value($output); |
|
69 | + return $this->get_string_from_value( $output ); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @return mixed The value out. |
80 | 80 | */ |
81 | - public function get_value($value) |
|
81 | + public function get_value( $value ) |
|
82 | 82 | { |
83 | - return $this->get_string_from_value($value); |
|
83 | + return $this->get_string_from_value( $value ); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -92,16 +92,16 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return string Based on $value; `1`: "One-Time Payment"; `2`: "Subscription" |
94 | 94 | */ |
95 | - private function get_string_from_value($value) |
|
95 | + private function get_string_from_value( $value ) |
|
96 | 96 | { |
97 | - switch (intval($value)) { |
|
97 | + switch ( intval( $value ) ) { |
|
98 | 98 | case self::ONE_TIME_PAYMENT: |
99 | 99 | default: |
100 | - $return = __('One-Time Payment', 'gravityview'); |
|
100 | + $return = __( 'One-Time Payment', 'gravityview' ); |
|
101 | 101 | break; |
102 | 102 | |
103 | 103 | case self::SUBSCRIPTION: |
104 | - $return = __('Subscription', 'gravityview'); |
|
104 | + $return = __( 'Subscription', 'gravityview' ); |
|
105 | 105 | break; |
106 | 106 | } |
107 | 107 |
@@ -4,8 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | * @since 1.16 |
6 | 6 | */ |
7 | -class GravityView_Field_Transaction_Type extends GravityView_Field |
|
8 | -{ |
|
7 | +class GravityView_Field_Transaction_Type extends GravityView_Field { |
|
9 | 8 | public $name = 'transaction_type'; |
10 | 9 | |
11 | 10 | public $is_searchable = true; |
@@ -33,8 +32,7 @@ discard block |
||
33 | 32 | /** |
34 | 33 | * GravityView_Field_Transaction_Type constructor. |
35 | 34 | */ |
36 | - public function __construct() |
|
37 | - { |
|
35 | + public function __construct() { |
|
38 | 36 | $this->label = esc_html__('Transaction Type', 'gravityview'); |
39 | 37 | $this->description = esc_html__('The type of the order: one-time payment or subscription', 'gravityview'); |
40 | 38 | |
@@ -58,8 +56,7 @@ discard block |
||
58 | 56 | * |
59 | 57 | * @return string values for this field based on the numeric values used by Gravity Forms |
60 | 58 | */ |
61 | - public function get_content($output, $entry = [], $field_settings = [], $field = []) |
|
62 | - { |
|
59 | + public function get_content($output, $entry = [], $field_settings = [], $field = []) { |
|
63 | 60 | |
64 | 61 | /** Overridden by a template. */ |
65 | 62 | if (!empty($field['field_path'])) { |
@@ -78,8 +75,7 @@ discard block |
||
78 | 75 | * |
79 | 76 | * @return mixed The value out. |
80 | 77 | */ |
81 | - public function get_value($value) |
|
82 | - { |
|
78 | + public function get_value($value) { |
|
83 | 79 | return $this->get_string_from_value($value); |
84 | 80 | } |
85 | 81 | |
@@ -92,8 +88,7 @@ discard block |
||
92 | 88 | * |
93 | 89 | * @return string Based on $value; `1`: "One-Time Payment"; `2`: "Subscription" |
94 | 90 | */ |
95 | - private function get_string_from_value($value) |
|
96 | - { |
|
91 | + private function get_string_from_value($value) { |
|
97 | 92 | switch (intval($value)) { |
98 | 93 | case self::ONE_TIME_PAYMENT: |
99 | 94 | default: |
@@ -8,58 +8,58 @@ |
||
8 | 8 | */ |
9 | 9 | class GravityView_Field_Textarea extends GravityView_Field |
10 | 10 | { |
11 | - public $name = 'textarea'; |
|
11 | + public $name = 'textarea'; |
|
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_Textarea'; |
|
17 | + public $_gf_field_class_name = 'GF_Field_Textarea'; |
|
18 | 18 | |
19 | - public $group = 'standard'; |
|
19 | + public $group = 'standard'; |
|
20 | 20 | |
21 | - public $icon = 'dashicons-editor-paragraph'; |
|
21 | + public $icon = 'dashicons-editor-paragraph'; |
|
22 | 22 | |
23 | - public function __construct() |
|
24 | - { |
|
25 | - $this->label = esc_html__('Paragraph Text', 'gravityview'); |
|
26 | - parent::__construct(); |
|
27 | - } |
|
23 | + public function __construct() |
|
24 | + { |
|
25 | + $this->label = esc_html__('Paragraph Text', 'gravityview'); |
|
26 | + parent::__construct(); |
|
27 | + } |
|
28 | 28 | |
29 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
30 | - { |
|
31 | - if ('edit' === $context) { |
|
32 | - return $field_options; |
|
33 | - } |
|
29 | + public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
30 | + { |
|
31 | + if ('edit' === $context) { |
|
32 | + return $field_options; |
|
33 | + } |
|
34 | 34 | |
35 | - unset($field_options['show_as_link']); |
|
35 | + unset($field_options['show_as_link']); |
|
36 | 36 | |
37 | - $field_options['trim_words'] = [ |
|
38 | - 'type' => 'number', |
|
39 | - 'merge_tags' => false, |
|
40 | - 'value' => null, |
|
41 | - 'label' => __('Maximum words shown', 'gravityview'), |
|
42 | - 'tooltip' => __('Enter the number of words to be shown. If specified it truncates the text. Leave it blank if you want to show the full text.', 'gravityview'), |
|
43 | - ]; |
|
37 | + $field_options['trim_words'] = [ |
|
38 | + 'type' => 'number', |
|
39 | + 'merge_tags' => false, |
|
40 | + 'value' => null, |
|
41 | + 'label' => __('Maximum words shown', 'gravityview'), |
|
42 | + 'tooltip' => __('Enter the number of words to be shown. If specified it truncates the text. Leave it blank if you want to show the full text.', 'gravityview'), |
|
43 | + ]; |
|
44 | 44 | |
45 | - $field_options['make_clickable'] = [ |
|
46 | - 'type' => 'checkbox', |
|
47 | - 'merge_tags' => false, |
|
48 | - 'value' => 0, |
|
49 | - 'label' => __('Convert text URLs to HTML links', 'gravityview'), |
|
50 | - 'tooltip' => __('Converts URI, www, FTP, and email addresses in HTML links', 'gravityview'), |
|
51 | - ]; |
|
45 | + $field_options['make_clickable'] = [ |
|
46 | + 'type' => 'checkbox', |
|
47 | + 'merge_tags' => false, |
|
48 | + 'value' => 0, |
|
49 | + 'label' => __('Convert text URLs to HTML links', 'gravityview'), |
|
50 | + 'tooltip' => __('Converts URI, www, FTP, and email addresses in HTML links', 'gravityview'), |
|
51 | + ]; |
|
52 | 52 | |
53 | - $field_options['allow_html'] = [ |
|
54 | - 'type' => 'checkbox', |
|
55 | - 'merge_tags' => false, |
|
56 | - 'value' => 1, |
|
57 | - 'label' => __('Display as HTML', 'gravityview'), |
|
58 | - 'tooltip' => esc_html__('If enabled, safe HTML will be displayed and unsafe or unrecognized HTML tags will be stripped. If disabled, the field value will be displayed as text.', 'gravityview'), |
|
59 | - ]; |
|
53 | + $field_options['allow_html'] = [ |
|
54 | + 'type' => 'checkbox', |
|
55 | + 'merge_tags' => false, |
|
56 | + 'value' => 1, |
|
57 | + 'label' => __('Display as HTML', 'gravityview'), |
|
58 | + 'tooltip' => esc_html__('If enabled, safe HTML will be displayed and unsafe or unrecognized HTML tags will be stripped. If disabled, the field value will be displayed as text.', 'gravityview'), |
|
59 | + ]; |
|
60 | 60 | |
61 | - return $field_options; |
|
62 | - } |
|
61 | + return $field_options; |
|
62 | + } |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | new GravityView_Field_Textarea(); |
@@ -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_Textarea'; |
18 | 18 | |
@@ -22,40 +22,40 @@ discard block |
||
22 | 22 | |
23 | 23 | public function __construct() |
24 | 24 | { |
25 | - $this->label = esc_html__('Paragraph Text', 'gravityview'); |
|
25 | + $this->label = esc_html__( 'Paragraph Text', '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 | - if ('edit' === $context) { |
|
31 | + if ( 'edit' === $context ) { |
|
32 | 32 | return $field_options; |
33 | 33 | } |
34 | 34 | |
35 | - unset($field_options['show_as_link']); |
|
35 | + unset( $field_options[ 'show_as_link' ] ); |
|
36 | 36 | |
37 | - $field_options['trim_words'] = [ |
|
37 | + $field_options[ 'trim_words' ] = [ |
|
38 | 38 | 'type' => 'number', |
39 | 39 | 'merge_tags' => false, |
40 | 40 | 'value' => null, |
41 | - 'label' => __('Maximum words shown', 'gravityview'), |
|
42 | - 'tooltip' => __('Enter the number of words to be shown. If specified it truncates the text. Leave it blank if you want to show the full text.', 'gravityview'), |
|
41 | + 'label' => __( 'Maximum words shown', 'gravityview' ), |
|
42 | + 'tooltip' => __( 'Enter the number of words to be shown. If specified it truncates the text. Leave it blank if you want to show the full text.', 'gravityview' ), |
|
43 | 43 | ]; |
44 | 44 | |
45 | - $field_options['make_clickable'] = [ |
|
45 | + $field_options[ 'make_clickable' ] = [ |
|
46 | 46 | 'type' => 'checkbox', |
47 | 47 | 'merge_tags' => false, |
48 | 48 | 'value' => 0, |
49 | - 'label' => __('Convert text URLs to HTML links', 'gravityview'), |
|
50 | - 'tooltip' => __('Converts URI, www, FTP, and email addresses in HTML links', 'gravityview'), |
|
49 | + 'label' => __( 'Convert text URLs to HTML links', 'gravityview' ), |
|
50 | + 'tooltip' => __( 'Converts URI, www, FTP, and email addresses in HTML links', 'gravityview' ), |
|
51 | 51 | ]; |
52 | 52 | |
53 | - $field_options['allow_html'] = [ |
|
53 | + $field_options[ 'allow_html' ] = [ |
|
54 | 54 | 'type' => 'checkbox', |
55 | 55 | 'merge_tags' => false, |
56 | 56 | 'value' => 1, |
57 | - 'label' => __('Display as HTML', 'gravityview'), |
|
58 | - 'tooltip' => esc_html__('If enabled, safe HTML will be displayed and unsafe or unrecognized HTML tags will be stripped. If disabled, the field value will be displayed as text.', 'gravityview'), |
|
57 | + 'label' => __( 'Display as HTML', 'gravityview' ), |
|
58 | + 'tooltip' => esc_html__( 'If enabled, safe HTML will be displayed and unsafe or unrecognized HTML tags will be stripped. If disabled, the field value will be displayed as text.', 'gravityview' ), |
|
59 | 59 | ]; |
60 | 60 | |
61 | 61 | return $field_options; |
@@ -6,8 +6,7 @@ discard block |
||
6 | 6 | /** |
7 | 7 | * Add custom options for textarea fields. |
8 | 8 | */ |
9 | -class GravityView_Field_Textarea extends GravityView_Field |
|
10 | -{ |
|
9 | +class GravityView_Field_Textarea extends GravityView_Field { |
|
11 | 10 | public $name = 'textarea'; |
12 | 11 | |
13 | 12 | public $is_searchable = true; |
@@ -20,14 +19,12 @@ discard block |
||
20 | 19 | |
21 | 20 | public $icon = 'dashicons-editor-paragraph'; |
22 | 21 | |
23 | - public function __construct() |
|
24 | - { |
|
22 | + public function __construct() { |
|
25 | 23 | $this->label = esc_html__('Paragraph Text', '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 | if ('edit' === $context) { |
32 | 29 | return $field_options; |
33 | 30 | } |
@@ -11,128 +11,128 @@ |
||
11 | 11 | */ |
12 | 12 | final class GravityView_Fields |
13 | 13 | { |
14 | - /* @var GravityView_Field[] */ |
|
15 | - protected static $_fields = []; |
|
14 | + /* @var GravityView_Field[] */ |
|
15 | + protected static $_fields = []; |
|
16 | 16 | |
17 | - /** |
|
18 | - * @param GravityView_Field $field Field to register |
|
19 | - * |
|
20 | - * @throws Exception If requirements aren't met |
|
21 | - * |
|
22 | - * @return void |
|
23 | - */ |
|
24 | - public static function register($field) |
|
25 | - { |
|
26 | - if (!is_subclass_of($field, 'GravityView_Field')) { |
|
27 | - throw new Exception('Must be a subclass of GravityView_Field'); |
|
28 | - } |
|
29 | - if (empty($field->name)) { |
|
30 | - throw new Exception('The name must be set'); |
|
31 | - } |
|
32 | - if (isset(self::$_fields[$field->name]) && !defined('DOING_GRAVITYVIEW_TESTS')) { |
|
33 | - throw new Exception('Field type already registered: '.$field->name); |
|
34 | - } |
|
35 | - self::$_fields[$field->name] = $field; |
|
36 | - } |
|
17 | + /** |
|
18 | + * @param GravityView_Field $field Field to register |
|
19 | + * |
|
20 | + * @throws Exception If requirements aren't met |
|
21 | + * |
|
22 | + * @return void |
|
23 | + */ |
|
24 | + public static function register($field) |
|
25 | + { |
|
26 | + if (!is_subclass_of($field, 'GravityView_Field')) { |
|
27 | + throw new Exception('Must be a subclass of GravityView_Field'); |
|
28 | + } |
|
29 | + if (empty($field->name)) { |
|
30 | + throw new Exception('The name must be set'); |
|
31 | + } |
|
32 | + if (isset(self::$_fields[$field->name]) && !defined('DOING_GRAVITYVIEW_TESTS')) { |
|
33 | + throw new Exception('Field type already registered: '.$field->name); |
|
34 | + } |
|
35 | + self::$_fields[$field->name] = $field; |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param array $properties |
|
40 | - * |
|
41 | - * @return GravityView_Field | bool |
|
42 | - */ |
|
43 | - public static function create($properties) |
|
44 | - { |
|
45 | - $type = isset($properties['type']) ? $properties['type'] : ''; |
|
46 | - $type = empty($properties['inputType']) ? $type : $properties['inputType']; |
|
47 | - if (empty($type) || !isset(self::$_fields[$type])) { |
|
48 | - return new GravityView_Field($properties); |
|
49 | - } |
|
50 | - $class = self::$_fields[$type]; |
|
51 | - $class_name = get_class($class); |
|
52 | - $field = new $class_name($properties); |
|
38 | + /** |
|
39 | + * @param array $properties |
|
40 | + * |
|
41 | + * @return GravityView_Field | bool |
|
42 | + */ |
|
43 | + public static function create($properties) |
|
44 | + { |
|
45 | + $type = isset($properties['type']) ? $properties['type'] : ''; |
|
46 | + $type = empty($properties['inputType']) ? $type : $properties['inputType']; |
|
47 | + if (empty($type) || !isset(self::$_fields[$type])) { |
|
48 | + return new GravityView_Field($properties); |
|
49 | + } |
|
50 | + $class = self::$_fields[$type]; |
|
51 | + $class_name = get_class($class); |
|
52 | + $field = new $class_name($properties); |
|
53 | 53 | |
54 | - return $field; |
|
55 | - } |
|
54 | + return $field; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Does the field exist (has it been registered)? |
|
59 | - * |
|
60 | - * @param string $field_name |
|
61 | - * |
|
62 | - * @return bool True: yes, it exists; False: nope |
|
63 | - */ |
|
64 | - public static function exists($field_name) |
|
65 | - { |
|
66 | - return isset(self::$_fields["{$field_name}"]); |
|
67 | - } |
|
57 | + /** |
|
58 | + * Does the field exist (has it been registered)? |
|
59 | + * |
|
60 | + * @param string $field_name |
|
61 | + * |
|
62 | + * @return bool True: yes, it exists; False: nope |
|
63 | + */ |
|
64 | + public static function exists($field_name) |
|
65 | + { |
|
66 | + return isset(self::$_fields["{$field_name}"]); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @param string $field_name |
|
71 | - * |
|
72 | - * @return GravityView_Field|false |
|
73 | - */ |
|
74 | - public static function get_instance($field_name) |
|
75 | - { |
|
76 | - return isset(self::$_fields[$field_name]) ? self::$_fields[$field_name] : false; |
|
77 | - } |
|
69 | + /** |
|
70 | + * @param string $field_name |
|
71 | + * |
|
72 | + * @return GravityView_Field|false |
|
73 | + */ |
|
74 | + public static function get_instance($field_name) |
|
75 | + { |
|
76 | + return isset(self::$_fields[$field_name]) ? self::$_fields[$field_name] : false; |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * Alias for get_instance(). |
|
81 | - * |
|
82 | - * @param $field_name |
|
83 | - * |
|
84 | - * @return GravityView_Field|false |
|
85 | - */ |
|
86 | - public static function get($field_name) |
|
87 | - { |
|
88 | - return self::get_instance($field_name); |
|
89 | - } |
|
79 | + /** |
|
80 | + * Alias for get_instance(). |
|
81 | + * |
|
82 | + * @param $field_name |
|
83 | + * |
|
84 | + * @return GravityView_Field|false |
|
85 | + */ |
|
86 | + public static function get($field_name) |
|
87 | + { |
|
88 | + return self::get_instance($field_name); |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * Alias for get_instance(). |
|
93 | - * |
|
94 | - * @param string|GF_Field $gf_field Gravity Forms field class or the class name type |
|
95 | - * |
|
96 | - * @return GravityView_Field|false Returns false if no matching fields found |
|
97 | - */ |
|
98 | - public static function get_associated_field($gf_field) |
|
99 | - { |
|
100 | - $field_type = is_a($gf_field, 'GF_Field') ? get_class($gf_field) : $gf_field; |
|
91 | + /** |
|
92 | + * Alias for get_instance(). |
|
93 | + * |
|
94 | + * @param string|GF_Field $gf_field Gravity Forms field class or the class name type |
|
95 | + * |
|
96 | + * @return GravityView_Field|false Returns false if no matching fields found |
|
97 | + */ |
|
98 | + public static function get_associated_field($gf_field) |
|
99 | + { |
|
100 | + $field_type = is_a($gf_field, 'GF_Field') ? get_class($gf_field) : $gf_field; |
|
101 | 101 | |
102 | - foreach (self::$_fields as $field) { |
|
103 | - if ($field_type === $field->_gf_field_class_name) { |
|
104 | - return $field; |
|
105 | - } |
|
106 | - } |
|
102 | + foreach (self::$_fields as $field) { |
|
103 | + if ($field_type === $field->_gf_field_class_name) { |
|
104 | + return $field; |
|
105 | + } |
|
106 | + } |
|
107 | 107 | |
108 | - return false; |
|
109 | - } |
|
108 | + return false; |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * Get all fields. |
|
113 | - * |
|
114 | - * @since 1.16 Added $group parameter |
|
115 | - * |
|
116 | - * @param string|array $groups Optional. If defined, fetch all fields in a group or array of groups. |
|
117 | - * |
|
118 | - * @return GravityView_Field[] |
|
119 | - */ |
|
120 | - public static function get_all($groups = '') |
|
121 | - { |
|
122 | - if ('' !== $groups) { |
|
123 | - $return_fields = self::$_fields; |
|
111 | + /** |
|
112 | + * Get all fields. |
|
113 | + * |
|
114 | + * @since 1.16 Added $group parameter |
|
115 | + * |
|
116 | + * @param string|array $groups Optional. If defined, fetch all fields in a group or array of groups. |
|
117 | + * |
|
118 | + * @return GravityView_Field[] |
|
119 | + */ |
|
120 | + public static function get_all($groups = '') |
|
121 | + { |
|
122 | + if ('' !== $groups) { |
|
123 | + $return_fields = self::$_fields; |
|
124 | 124 | |
125 | - $groups = (array) $groups; |
|
125 | + $groups = (array) $groups; |
|
126 | 126 | |
127 | - foreach ($return_fields as $key => $field) { |
|
128 | - if (!in_array($field->group, $groups, true)) { |
|
129 | - unset($return_fields[$key]); |
|
130 | - } |
|
131 | - } |
|
127 | + foreach ($return_fields as $key => $field) { |
|
128 | + if (!in_array($field->group, $groups, true)) { |
|
129 | + unset($return_fields[$key]); |
|
130 | + } |
|
131 | + } |
|
132 | 132 | |
133 | - return $return_fields; |
|
134 | - } else { |
|
135 | - return self::$_fields; |
|
136 | - } |
|
137 | - } |
|
133 | + return $return_fields; |
|
134 | + } else { |
|
135 | + return self::$_fields; |
|
136 | + } |
|
137 | + } |
|
138 | 138 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | final class GravityView_Fields |
13 | 13 | { |
14 | 14 | /* @var GravityView_Field[] */ |
15 | - protected static $_fields = []; |
|
15 | + protected static $_fields = [ ]; |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * @param GravityView_Field $field Field to register |
@@ -21,18 +21,18 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @return void |
23 | 23 | */ |
24 | - public static function register($field) |
|
24 | + public static function register( $field ) |
|
25 | 25 | { |
26 | - if (!is_subclass_of($field, 'GravityView_Field')) { |
|
27 | - throw new Exception('Must be a subclass of GravityView_Field'); |
|
26 | + if ( ! is_subclass_of( $field, 'GravityView_Field' ) ) { |
|
27 | + throw new Exception( 'Must be a subclass of GravityView_Field' ); |
|
28 | 28 | } |
29 | - if (empty($field->name)) { |
|
30 | - throw new Exception('The name must be set'); |
|
29 | + if ( empty( $field->name ) ) { |
|
30 | + throw new Exception( 'The name must be set' ); |
|
31 | 31 | } |
32 | - if (isset(self::$_fields[$field->name]) && !defined('DOING_GRAVITYVIEW_TESTS')) { |
|
33 | - throw new Exception('Field type already registered: '.$field->name); |
|
32 | + if ( isset( self::$_fields[ $field->name ] ) && ! defined( 'DOING_GRAVITYVIEW_TESTS' ) ) { |
|
33 | + throw new Exception( 'Field type already registered: ' . $field->name ); |
|
34 | 34 | } |
35 | - self::$_fields[$field->name] = $field; |
|
35 | + self::$_fields[ $field->name ] = $field; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -40,16 +40,16 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return GravityView_Field | bool |
42 | 42 | */ |
43 | - public static function create($properties) |
|
43 | + public static function create( $properties ) |
|
44 | 44 | { |
45 | - $type = isset($properties['type']) ? $properties['type'] : ''; |
|
46 | - $type = empty($properties['inputType']) ? $type : $properties['inputType']; |
|
47 | - if (empty($type) || !isset(self::$_fields[$type])) { |
|
48 | - return new GravityView_Field($properties); |
|
45 | + $type = isset( $properties[ 'type' ] ) ? $properties[ 'type' ] : ''; |
|
46 | + $type = empty( $properties[ 'inputType' ] ) ? $type : $properties[ 'inputType' ]; |
|
47 | + if ( empty( $type ) || ! isset( self::$_fields[ $type ] ) ) { |
|
48 | + return new GravityView_Field( $properties ); |
|
49 | 49 | } |
50 | - $class = self::$_fields[$type]; |
|
51 | - $class_name = get_class($class); |
|
52 | - $field = new $class_name($properties); |
|
50 | + $class = self::$_fields[ $type ]; |
|
51 | + $class_name = get_class( $class ); |
|
52 | + $field = new $class_name( $properties ); |
|
53 | 53 | |
54 | 54 | return $field; |
55 | 55 | } |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return bool True: yes, it exists; False: nope |
63 | 63 | */ |
64 | - public static function exists($field_name) |
|
64 | + public static function exists( $field_name ) |
|
65 | 65 | { |
66 | - return isset(self::$_fields["{$field_name}"]); |
|
66 | + return isset( self::$_fields[ "{$field_name}" ] ); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return GravityView_Field|false |
73 | 73 | */ |
74 | - public static function get_instance($field_name) |
|
74 | + public static function get_instance( $field_name ) |
|
75 | 75 | { |
76 | - return isset(self::$_fields[$field_name]) ? self::$_fields[$field_name] : false; |
|
76 | + return isset( self::$_fields[ $field_name ] ) ? self::$_fields[ $field_name ] : false; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @return GravityView_Field|false |
85 | 85 | */ |
86 | - public static function get($field_name) |
|
86 | + public static function get( $field_name ) |
|
87 | 87 | { |
88 | - return self::get_instance($field_name); |
|
88 | + return self::get_instance( $field_name ); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return GravityView_Field|false Returns false if no matching fields found |
97 | 97 | */ |
98 | - public static function get_associated_field($gf_field) |
|
98 | + public static function get_associated_field( $gf_field ) |
|
99 | 99 | { |
100 | - $field_type = is_a($gf_field, 'GF_Field') ? get_class($gf_field) : $gf_field; |
|
100 | + $field_type = is_a( $gf_field, 'GF_Field' ) ? get_class( $gf_field ) : $gf_field; |
|
101 | 101 | |
102 | - foreach (self::$_fields as $field) { |
|
103 | - if ($field_type === $field->_gf_field_class_name) { |
|
102 | + foreach ( self::$_fields as $field ) { |
|
103 | + if ( $field_type === $field->_gf_field_class_name ) { |
|
104 | 104 | return $field; |
105 | 105 | } |
106 | 106 | } |
@@ -117,16 +117,16 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @return GravityView_Field[] |
119 | 119 | */ |
120 | - public static function get_all($groups = '') |
|
120 | + public static function get_all( $groups = '' ) |
|
121 | 121 | { |
122 | - if ('' !== $groups) { |
|
122 | + if ( '' !== $groups ) { |
|
123 | 123 | $return_fields = self::$_fields; |
124 | 124 | |
125 | - $groups = (array) $groups; |
|
125 | + $groups = (array)$groups; |
|
126 | 126 | |
127 | - foreach ($return_fields as $key => $field) { |
|
128 | - if (!in_array($field->group, $groups, true)) { |
|
129 | - unset($return_fields[$key]); |
|
127 | + foreach ( $return_fields as $key => $field ) { |
|
128 | + if ( ! in_array( $field->group, $groups, true ) ) { |
|
129 | + unset( $return_fields[ $key ] ); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 |
@@ -9,8 +9,7 @@ discard block |
||
9 | 9 | * |
10 | 10 | * @see GF_Fields |
11 | 11 | */ |
12 | -final class GravityView_Fields |
|
13 | -{ |
|
12 | +final class GravityView_Fields { |
|
14 | 13 | /* @var GravityView_Field[] */ |
15 | 14 | protected static $_fields = []; |
16 | 15 | |
@@ -21,8 +20,7 @@ discard block |
||
21 | 20 | * |
22 | 21 | * @return void |
23 | 22 | */ |
24 | - public static function register($field) |
|
25 | - { |
|
23 | + public static function register($field) { |
|
26 | 24 | if (!is_subclass_of($field, 'GravityView_Field')) { |
27 | 25 | throw new Exception('Must be a subclass of GravityView_Field'); |
28 | 26 | } |
@@ -40,8 +38,7 @@ discard block |
||
40 | 38 | * |
41 | 39 | * @return GravityView_Field | bool |
42 | 40 | */ |
43 | - public static function create($properties) |
|
44 | - { |
|
41 | + public static function create($properties) { |
|
45 | 42 | $type = isset($properties['type']) ? $properties['type'] : ''; |
46 | 43 | $type = empty($properties['inputType']) ? $type : $properties['inputType']; |
47 | 44 | if (empty($type) || !isset(self::$_fields[$type])) { |
@@ -61,8 +58,7 @@ discard block |
||
61 | 58 | * |
62 | 59 | * @return bool True: yes, it exists; False: nope |
63 | 60 | */ |
64 | - public static function exists($field_name) |
|
65 | - { |
|
61 | + public static function exists($field_name) { |
|
66 | 62 | return isset(self::$_fields["{$field_name}"]); |
67 | 63 | } |
68 | 64 | |
@@ -71,8 +67,7 @@ discard block |
||
71 | 67 | * |
72 | 68 | * @return GravityView_Field|false |
73 | 69 | */ |
74 | - public static function get_instance($field_name) |
|
75 | - { |
|
70 | + public static function get_instance($field_name) { |
|
76 | 71 | return isset(self::$_fields[$field_name]) ? self::$_fields[$field_name] : false; |
77 | 72 | } |
78 | 73 | |
@@ -83,8 +78,7 @@ discard block |
||
83 | 78 | * |
84 | 79 | * @return GravityView_Field|false |
85 | 80 | */ |
86 | - public static function get($field_name) |
|
87 | - { |
|
81 | + public static function get($field_name) { |
|
88 | 82 | return self::get_instance($field_name); |
89 | 83 | } |
90 | 84 | |
@@ -95,8 +89,7 @@ discard block |
||
95 | 89 | * |
96 | 90 | * @return GravityView_Field|false Returns false if no matching fields found |
97 | 91 | */ |
98 | - public static function get_associated_field($gf_field) |
|
99 | - { |
|
92 | + public static function get_associated_field($gf_field) { |
|
100 | 93 | $field_type = is_a($gf_field, 'GF_Field') ? get_class($gf_field) : $gf_field; |
101 | 94 | |
102 | 95 | foreach (self::$_fields as $field) { |
@@ -117,8 +110,7 @@ discard block |
||
117 | 110 | * |
118 | 111 | * @return GravityView_Field[] |
119 | 112 | */ |
120 | - public static function get_all($groups = '') |
|
121 | - { |
|
113 | + public static function get_all($groups = '') { |
|
122 | 114 | if ('' !== $groups) { |
123 | 115 | $return_fields = self::$_fields; |
124 | 116 |
@@ -4,83 +4,83 @@ |
||
4 | 4 | */ |
5 | 5 | class GravityView_Field_Checkbox extends GravityView_Field |
6 | 6 | { |
7 | - public $name = 'checkbox'; |
|
7 | + public $name = 'checkbox'; |
|
8 | 8 | |
9 | - public $is_searchable = true; |
|
9 | + public $is_searchable = true; |
|
10 | 10 | |
11 | - /** |
|
12 | - * @see GFCommon::get_field_filter_settings Gravity Forms suggests checkboxes should just be "is" |
|
13 | - * |
|
14 | - * @var array |
|
15 | - */ |
|
16 | - public $search_operators = ['is', 'in', 'not in', 'isnot', 'contains']; |
|
11 | + /** |
|
12 | + * @see GFCommon::get_field_filter_settings Gravity Forms suggests checkboxes should just be "is" |
|
13 | + * |
|
14 | + * @var array |
|
15 | + */ |
|
16 | + public $search_operators = ['is', 'in', 'not in', 'isnot', 'contains']; |
|
17 | 17 | |
18 | - public $_gf_field_class_name = 'GF_Field_Checkbox'; |
|
18 | + public $_gf_field_class_name = 'GF_Field_Checkbox'; |
|
19 | 19 | |
20 | - public $group = 'standard'; |
|
20 | + public $group = 'standard'; |
|
21 | 21 | |
22 | - public $icon = 'dashicons-yes'; |
|
22 | + public $icon = 'dashicons-yes'; |
|
23 | 23 | |
24 | - public function __construct() |
|
25 | - { |
|
26 | - $this->label = esc_html__('Checkbox', 'gravityview'); |
|
27 | - parent::__construct(); |
|
28 | - } |
|
24 | + public function __construct() |
|
25 | + { |
|
26 | + $this->label = esc_html__('Checkbox', 'gravityview'); |
|
27 | + parent::__construct(); |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * Add `choice_display` setting to the field. |
|
32 | - * |
|
33 | - * @param array $field_options |
|
34 | - * @param string $template_id |
|
35 | - * @param string $field_id |
|
36 | - * @param string $context |
|
37 | - * @param string $input_type |
|
38 | - * |
|
39 | - * @since 1.17 |
|
40 | - * |
|
41 | - * @return array |
|
42 | - */ |
|
43 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
44 | - { |
|
30 | + /** |
|
31 | + * Add `choice_display` setting to the field. |
|
32 | + * |
|
33 | + * @param array $field_options |
|
34 | + * @param string $template_id |
|
35 | + * @param string $field_id |
|
36 | + * @param string $context |
|
37 | + * @param string $input_type |
|
38 | + * |
|
39 | + * @since 1.17 |
|
40 | + * |
|
41 | + * @return array |
|
42 | + */ |
|
43 | + public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
44 | + { |
|
45 | 45 | |
46 | - // Set the $_field_id var |
|
47 | - $field_options = parent::field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id); |
|
46 | + // Set the $_field_id var |
|
47 | + $field_options = parent::field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id); |
|
48 | 48 | |
49 | - // It's the parent field, not an input |
|
50 | - if (floor($field_id) === floatval($field_id)) { |
|
51 | - return $field_options; |
|
52 | - } |
|
49 | + // It's the parent field, not an input |
|
50 | + if (floor($field_id) === floatval($field_id)) { |
|
51 | + return $field_options; |
|
52 | + } |
|
53 | 53 | |
54 | - if ($this->is_choice_value_enabled()) { |
|
55 | - $desc = esc_html__('This input has a label and a value. What should be displayed?', 'gravityview'); |
|
56 | - $default = 'value'; |
|
57 | - $choices = [ |
|
58 | - 'tick' => __('A check mark, if the input is checked', 'gravityview'), |
|
59 | - 'value' => __('Value of the input', 'gravityview'), |
|
60 | - 'label' => __('Label of the input', 'gravityview'), |
|
61 | - ]; |
|
62 | - } else { |
|
63 | - $desc = ''; |
|
64 | - $default = 'tick'; |
|
65 | - $choices = [ |
|
66 | - 'tick' => __('A check mark, if the input is checked', 'gravityview'), |
|
67 | - 'label' => __('Label of the input', 'gravityview'), |
|
68 | - ]; |
|
69 | - } |
|
54 | + if ($this->is_choice_value_enabled()) { |
|
55 | + $desc = esc_html__('This input has a label and a value. What should be displayed?', 'gravityview'); |
|
56 | + $default = 'value'; |
|
57 | + $choices = [ |
|
58 | + 'tick' => __('A check mark, if the input is checked', 'gravityview'), |
|
59 | + 'value' => __('Value of the input', 'gravityview'), |
|
60 | + 'label' => __('Label of the input', 'gravityview'), |
|
61 | + ]; |
|
62 | + } else { |
|
63 | + $desc = ''; |
|
64 | + $default = 'tick'; |
|
65 | + $choices = [ |
|
66 | + 'tick' => __('A check mark, if the input is checked', 'gravityview'), |
|
67 | + 'label' => __('Label of the input', 'gravityview'), |
|
68 | + ]; |
|
69 | + } |
|
70 | 70 | |
71 | - $field_options['choice_display'] = [ |
|
72 | - 'type' => 'radio', |
|
73 | - 'class' => 'vertical', |
|
74 | - 'label' => __('What should be displayed:', 'gravityview'), |
|
75 | - 'value' => $default, |
|
76 | - 'desc' => $desc, |
|
77 | - 'choices' => $choices, |
|
78 | - 'group' => 'display', |
|
79 | - 'priority' => 100, |
|
80 | - ]; |
|
71 | + $field_options['choice_display'] = [ |
|
72 | + 'type' => 'radio', |
|
73 | + 'class' => 'vertical', |
|
74 | + 'label' => __('What should be displayed:', 'gravityview'), |
|
75 | + 'value' => $default, |
|
76 | + 'desc' => $desc, |
|
77 | + 'choices' => $choices, |
|
78 | + 'group' => 'display', |
|
79 | + 'priority' => 100, |
|
80 | + ]; |
|
81 | 81 | |
82 | - return $field_options; |
|
83 | - } |
|
82 | + return $field_options; |
|
83 | + } |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | new GravityView_Field_Checkbox(); |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * |
14 | 14 | * @var array |
15 | 15 | */ |
16 | - public $search_operators = ['is', 'in', 'not in', 'isnot', 'contains']; |
|
16 | + public $search_operators = [ 'is', 'in', 'not in', 'isnot', 'contains' ]; |
|
17 | 17 | |
18 | 18 | public $_gf_field_class_name = 'GF_Field_Checkbox'; |
19 | 19 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | public function __construct() |
25 | 25 | { |
26 | - $this->label = esc_html__('Checkbox', 'gravityview'); |
|
26 | + $this->label = esc_html__( 'Checkbox', 'gravityview' ); |
|
27 | 27 | parent::__construct(); |
28 | 28 | } |
29 | 29 | |
@@ -40,38 +40,38 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return array |
42 | 42 | */ |
43 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
43 | + public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) |
|
44 | 44 | { |
45 | 45 | |
46 | 46 | // Set the $_field_id var |
47 | - $field_options = parent::field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id); |
|
47 | + $field_options = parent::field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ); |
|
48 | 48 | |
49 | 49 | // It's the parent field, not an input |
50 | - if (floor($field_id) === floatval($field_id)) { |
|
50 | + if ( floor( $field_id ) === floatval( $field_id ) ) { |
|
51 | 51 | return $field_options; |
52 | 52 | } |
53 | 53 | |
54 | - if ($this->is_choice_value_enabled()) { |
|
55 | - $desc = esc_html__('This input has a label and a value. What should be displayed?', 'gravityview'); |
|
54 | + if ( $this->is_choice_value_enabled() ) { |
|
55 | + $desc = esc_html__( 'This input has a label and a value. What should be displayed?', 'gravityview' ); |
|
56 | 56 | $default = 'value'; |
57 | 57 | $choices = [ |
58 | - 'tick' => __('A check mark, if the input is checked', 'gravityview'), |
|
59 | - 'value' => __('Value of the input', 'gravityview'), |
|
60 | - 'label' => __('Label of the input', 'gravityview'), |
|
58 | + 'tick' => __( 'A check mark, if the input is checked', 'gravityview' ), |
|
59 | + 'value' => __( 'Value of the input', 'gravityview' ), |
|
60 | + 'label' => __( 'Label of the input', 'gravityview' ), |
|
61 | 61 | ]; |
62 | 62 | } else { |
63 | 63 | $desc = ''; |
64 | 64 | $default = 'tick'; |
65 | 65 | $choices = [ |
66 | - 'tick' => __('A check mark, if the input is checked', 'gravityview'), |
|
67 | - 'label' => __('Label of the input', 'gravityview'), |
|
66 | + 'tick' => __( 'A check mark, if the input is checked', 'gravityview' ), |
|
67 | + 'label' => __( 'Label of the input', 'gravityview' ), |
|
68 | 68 | ]; |
69 | 69 | } |
70 | 70 | |
71 | - $field_options['choice_display'] = [ |
|
71 | + $field_options[ 'choice_display' ] = [ |
|
72 | 72 | 'type' => 'radio', |
73 | 73 | 'class' => 'vertical', |
74 | - 'label' => __('What should be displayed:', 'gravityview'), |
|
74 | + 'label' => __( 'What should be displayed:', 'gravityview' ), |
|
75 | 75 | 'value' => $default, |
76 | 76 | 'desc' => $desc, |
77 | 77 | 'choices' => $choices, |
@@ -2,8 +2,7 @@ discard block |
||
2 | 2 | /** |
3 | 3 | * @file class-gravityview-field-checkbox.php |
4 | 4 | */ |
5 | -class GravityView_Field_Checkbox extends GravityView_Field |
|
6 | -{ |
|
5 | +class GravityView_Field_Checkbox extends GravityView_Field { |
|
7 | 6 | public $name = 'checkbox'; |
8 | 7 | |
9 | 8 | public $is_searchable = true; |
@@ -21,8 +20,7 @@ discard block |
||
21 | 20 | |
22 | 21 | public $icon = 'dashicons-yes'; |
23 | 22 | |
24 | - public function __construct() |
|
25 | - { |
|
23 | + public function __construct() { |
|
26 | 24 | $this->label = esc_html__('Checkbox', 'gravityview'); |
27 | 25 | parent::__construct(); |
28 | 26 | } |
@@ -40,8 +38,7 @@ discard block |
||
40 | 38 | * |
41 | 39 | * @return array |
42 | 40 | */ |
43 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
44 | - { |
|
41 | + public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) { |
|
45 | 42 | |
46 | 43 | // Set the $_field_id var |
47 | 44 | $field_options = parent::field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id); |
@@ -7,283 +7,283 @@ |
||
7 | 7 | */ |
8 | 8 | class GravityView_Field_Entry_Approval extends GravityView_Field |
9 | 9 | { |
10 | - public $name = 'entry_approval'; |
|
10 | + public $name = 'entry_approval'; |
|
11 | 11 | |
12 | - public $is_searchable = true; |
|
12 | + public $is_searchable = true; |
|
13 | 13 | |
14 | - public $search_operators = ['is', 'isnot']; |
|
14 | + public $search_operators = ['is', 'isnot']; |
|
15 | 15 | |
16 | - public $is_sortable = true; |
|
16 | + public $is_sortable = true; |
|
17 | 17 | |
18 | - public $is_numeric = true; |
|
18 | + public $is_numeric = true; |
|
19 | 19 | |
20 | - public $group = 'gravityview'; |
|
20 | + public $group = 'gravityview'; |
|
21 | 21 | |
22 | - public $contexts = ['single', 'multiple']; |
|
22 | + public $contexts = ['single', 'multiple']; |
|
23 | 23 | |
24 | - public $icon = 'dashicons-yes-alt'; |
|
24 | + public $icon = 'dashicons-yes-alt'; |
|
25 | 25 | |
26 | - public function __construct() |
|
27 | - { |
|
28 | - $this->label = esc_attr__('Approve Entries', 'gravityview'); |
|
29 | - |
|
30 | - $this->description = esc_attr__('Approve and reject entries from the View.', 'gravityview'); |
|
31 | - |
|
32 | - $this->add_hooks(); |
|
33 | - |
|
34 | - parent::__construct(); |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * Remove unused settings for the approval field. |
|
39 | - * |
|
40 | - * @since 1.19 |
|
41 | - * |
|
42 | - * @param array $field_options |
|
43 | - * @param string $template_id |
|
44 | - * @param string $field_id |
|
45 | - * @param string $context |
|
46 | - * @param string $input_type |
|
47 | - * |
|
48 | - * @return array |
|
49 | - */ |
|
50 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
51 | - { |
|
52 | - unset($field_options['only_loggedin']); |
|
53 | - |
|
54 | - unset($field_options['new_window']); |
|
55 | - |
|
56 | - unset($field_options['show_as_link']); |
|
57 | - |
|
58 | - return $field_options; |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * Add filters and actions for the field. |
|
63 | - * |
|
64 | - * @since 1.19 |
|
65 | - * |
|
66 | - * @return void |
|
67 | - */ |
|
68 | - private function add_hooks() |
|
69 | - { |
|
70 | - add_filter('gravityview_entry_default_fields', [$this, 'filter_gravityview_entry_default_field'], 10, 3); |
|
71 | - |
|
72 | - add_action('wp_enqueue_scripts', [$this, 'register_scripts_and_styles']); |
|
73 | - |
|
74 | - // Make sure scripts are registered for FSE themes |
|
75 | - add_action('gravityview/template/before', [$this, 'register_scripts_and_styles']); |
|
76 | - |
|
77 | - add_action('gravityview/field/approval/load_scripts', [$this, 'enqueue_and_localize_script']); |
|
78 | - |
|
79 | - add_action('gravityview_datatables_scripts_styles', [$this, 'enqueue_and_localize_script']); |
|
80 | - |
|
81 | - add_filter('gravityview_get_entries', [$this, 'modify_search_parameters'], 1000); |
|
82 | - |
|
83 | - add_filter('gravityview/field_output/html', [$this, 'maybe_prevent_field_render'], 10, 2); |
|
84 | - |
|
85 | - add_filter('gravityview/field/is_visible', [$this, 'maybe_not_visible'], 10, 2); |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * @filter `gravityview/template/field_label` Modify field label output |
|
90 | - * |
|
91 | - * @since 1.19 |
|
92 | - * |
|
93 | - * @param string $html Existing HTML output |
|
94 | - * @param array $args Arguments passed to the function |
|
95 | - * |
|
96 | - * @return string Empty string if user doesn't have the `gravityview_moderate_entries` cap; field HTML otherwise |
|
97 | - */ |
|
98 | - public function maybe_prevent_field_render($html, $args) |
|
99 | - { |
|
100 | - |
|
101 | - // If the field is `entry_approval` type but the user doesn't have the moderate entries cap, don't render. |
|
102 | - if ($this->name === \GV\Utils::get($args['field'], 'id') && !GVCommon::has_cap('gravityview_moderate_entries')) { |
|
103 | - return ''; |
|
104 | - } |
|
105 | - |
|
106 | - return $html; |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * Do not show this field if `gravityview_moderate_entries` capability is absent. |
|
111 | - * |
|
112 | - * @return bool Whether this field is visible or not. |
|
113 | - */ |
|
114 | - public function maybe_not_visible($visible, $field) |
|
115 | - { |
|
116 | - if ($this->name !== $field->ID) { |
|
117 | - return $visible; |
|
118 | - } |
|
119 | - |
|
120 | - return GVCommon::has_cap('gravityview_moderate_entries'); |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * Modify search to use `is_approved` meta key to sort, instead of `entry_approval`. |
|
125 | - * |
|
126 | - * @param array $parameters Search parameters used to generate GF search |
|
127 | - * |
|
128 | - * @return array Same parameters, but if sorting by `entry_approval`, changed to `is_approved` |
|
129 | - */ |
|
130 | - public function modify_search_parameters($parameters) |
|
131 | - { |
|
132 | - if ($this->name === \GV\Utils::get($parameters, 'sorting/key')) { |
|
133 | - $parameters['sorting']['key'] = 'is_approved'; |
|
134 | - } |
|
135 | - |
|
136 | - return $parameters; |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Register the field approval script and style. |
|
141 | - * |
|
142 | - * @since 1.19 |
|
143 | - * |
|
144 | - * @return void |
|
145 | - */ |
|
146 | - public function register_scripts_and_styles() |
|
147 | - { |
|
148 | - if (wp_script_is('gravityview-field-approval')) { |
|
149 | - return; |
|
150 | - } |
|
151 | - |
|
152 | - $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
153 | - |
|
154 | - wp_register_script('gravityview-field-approval', GRAVITYVIEW_URL.'assets/js/field-approval'.$script_debug.'.js', ['jquery'], GravityView_Plugin::version, true); |
|
155 | - |
|
156 | - wp_register_script('gravityview-field-approval-popper', GRAVITYVIEW_URL.'assets/lib/tippy/popper.min.js', [], GravityView_Plugin::version, true); |
|
157 | - wp_register_script('gravityview-field-approval-tippy', GRAVITYVIEW_URL.'assets/lib/tippy/tippy.min.js', [], GravityView_Plugin::version, true); |
|
158 | - wp_register_style('gravityview-field-approval-tippy', GRAVITYVIEW_URL.'assets/lib/tippy/tippy.css', [], GravityView_Plugin::version, 'screen'); |
|
159 | - |
|
160 | - $style_path = GRAVITYVIEW_DIR.'templates/css/field-approval.css'; |
|
161 | - |
|
162 | - if (class_exists('GravityView_View')) { |
|
163 | - /** |
|
164 | - * Override CSS file by placing in your theme's /gravityview/css/ sub-directory. |
|
165 | - */ |
|
166 | - $style_path = GravityView_View::getInstance()->locate_template('css/field-approval.css', false); |
|
167 | - } |
|
168 | - |
|
169 | - $style_url = plugins_url('css/field-approval.css', trailingslashit(dirname($style_path))); |
|
170 | - |
|
171 | - /** |
|
172 | - * @filter `gravityview/field/approval/css_url` URL to the Approval field CSS file. |
|
173 | - * |
|
174 | - * @since 1.19 |
|
175 | - * |
|
176 | - * @param string $style_url Override to use your own CSS file, or return empty string to disable loading. |
|
177 | - */ |
|
178 | - $style_url = apply_filters('gravityview/field/approval/css_url', $style_url); |
|
179 | - |
|
180 | - if (!empty($style_url)) { |
|
181 | - wp_register_style('gravityview-field-approval', $style_url, ['dashicons'], GravityView_Plugin::version, 'screen'); |
|
182 | - } |
|
183 | - |
|
184 | - unset($style_path, $style_url); |
|
185 | - } |
|
186 | - |
|
187 | - /** |
|
188 | - * Register the field approval script and output the localized text JS variables. |
|
189 | - * |
|
190 | - * @since 1.19 |
|
191 | - * |
|
192 | - * @return void |
|
193 | - */ |
|
194 | - public function enqueue_and_localize_script() |
|
195 | - { |
|
196 | - |
|
197 | - // The script is already registered and enqueued |
|
198 | - if (wp_script_is('gravityview-field-approval', 'enqueued')) { |
|
199 | - return; |
|
200 | - } |
|
201 | - |
|
202 | - wp_enqueue_style('gravityview-field-approval'); |
|
203 | - |
|
204 | - wp_enqueue_script('gravityview-field-approval'); |
|
205 | - wp_enqueue_script('gravityview-field-approval-tippy'); |
|
206 | - wp_enqueue_script('gravityview-field-approval-popper'); |
|
207 | - wp_enqueue_style('gravityview-field-approval-tippy'); |
|
208 | - |
|
209 | - wp_localize_script('gravityview-field-approval', 'gvApproval', [ |
|
210 | - 'ajaxurl' => admin_url('admin-ajax.php'), |
|
211 | - 'nonce' => wp_create_nonce('gravityview_entry_approval'), |
|
212 | - 'status' => GravityView_Entry_Approval_Status::get_all(), |
|
213 | - 'status_popover_template' => GravityView_Entry_Approval::get_popover_template(), |
|
214 | - 'status_popover_placement' => GravityView_Entry_Approval::get_popover_placement(), |
|
215 | - ]); |
|
216 | - } |
|
217 | - |
|
218 | - /** |
|
219 | - * Add Fields to the field list. |
|
220 | - * |
|
221 | - * @since 1.19 |
|
222 | - * |
|
223 | - * @param array $entry_default_fields Array of fields shown by default |
|
224 | - * @param string|array $form form_ID or form object |
|
225 | - * @param string $context Either 'single', 'directory', 'header', 'footer' |
|
226 | - * |
|
227 | - * @return array |
|
228 | - */ |
|
229 | - public function filter_gravityview_entry_default_field($entry_default_fields, $form, $context) |
|
230 | - { |
|
231 | - if (!isset($entry_default_fields["{$this->name}"]) && 'edit' !== $context) { |
|
232 | - $entry_default_fields["{$this->name}"] = [ |
|
233 | - 'label' => $this->label, |
|
234 | - 'desc' => $this->description, |
|
235 | - 'type' => $this->name, |
|
236 | - ]; |
|
237 | - } |
|
238 | - |
|
239 | - return $entry_default_fields; |
|
240 | - } |
|
241 | - |
|
242 | - /** |
|
243 | - * Get the anchor text for a link, based on the current status. |
|
244 | - * |
|
245 | - * @since 1.19 |
|
246 | - * |
|
247 | - * @uses GravityView_Entry_Approval_Status::get_string() |
|
248 | - * |
|
249 | - * @param string $approved_status Status string or key |
|
250 | - * |
|
251 | - * @return false|string False if string doesn't exist, otherwise the "label" for the status |
|
252 | - */ |
|
253 | - public static function get_anchor_text($approved_status = '') |
|
254 | - { |
|
255 | - return GravityView_Entry_Approval_Status::get_string($approved_status, 'label'); |
|
256 | - } |
|
257 | - |
|
258 | - /** |
|
259 | - * Get the title attribute for a link, based on the current status. |
|
260 | - * |
|
261 | - * @since 1.19 |
|
262 | - * |
|
263 | - * @uses GravityView_Entry_Approval_Status::get_string() |
|
264 | - * |
|
265 | - * @param int|string $approved_status Status string or key |
|
266 | - * |
|
267 | - * @return false|string |
|
268 | - */ |
|
269 | - public static function get_title_attr($approved_status) |
|
270 | - { |
|
271 | - return GravityView_Entry_Approval_Status::get_string($approved_status, 'title'); |
|
272 | - } |
|
273 | - |
|
274 | - /** |
|
275 | - * Get the CSS class for a link, based on the current status. |
|
276 | - * |
|
277 | - * @param int|string $approved_status Status string or key |
|
278 | - * |
|
279 | - * @return string CSS class, sanitized using esc_attr() |
|
280 | - */ |
|
281 | - public static function get_css_class($approved_status) |
|
282 | - { |
|
283 | - $approved_key = GravityView_Entry_Approval_Status::get_key($approved_status); |
|
284 | - |
|
285 | - return esc_attr("gv-approval-{$approved_key}"); |
|
286 | - } |
|
26 | + public function __construct() |
|
27 | + { |
|
28 | + $this->label = esc_attr__('Approve Entries', 'gravityview'); |
|
29 | + |
|
30 | + $this->description = esc_attr__('Approve and reject entries from the View.', 'gravityview'); |
|
31 | + |
|
32 | + $this->add_hooks(); |
|
33 | + |
|
34 | + parent::__construct(); |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * Remove unused settings for the approval field. |
|
39 | + * |
|
40 | + * @since 1.19 |
|
41 | + * |
|
42 | + * @param array $field_options |
|
43 | + * @param string $template_id |
|
44 | + * @param string $field_id |
|
45 | + * @param string $context |
|
46 | + * @param string $input_type |
|
47 | + * |
|
48 | + * @return array |
|
49 | + */ |
|
50 | + public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
51 | + { |
|
52 | + unset($field_options['only_loggedin']); |
|
53 | + |
|
54 | + unset($field_options['new_window']); |
|
55 | + |
|
56 | + unset($field_options['show_as_link']); |
|
57 | + |
|
58 | + return $field_options; |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * Add filters and actions for the field. |
|
63 | + * |
|
64 | + * @since 1.19 |
|
65 | + * |
|
66 | + * @return void |
|
67 | + */ |
|
68 | + private function add_hooks() |
|
69 | + { |
|
70 | + add_filter('gravityview_entry_default_fields', [$this, 'filter_gravityview_entry_default_field'], 10, 3); |
|
71 | + |
|
72 | + add_action('wp_enqueue_scripts', [$this, 'register_scripts_and_styles']); |
|
73 | + |
|
74 | + // Make sure scripts are registered for FSE themes |
|
75 | + add_action('gravityview/template/before', [$this, 'register_scripts_and_styles']); |
|
76 | + |
|
77 | + add_action('gravityview/field/approval/load_scripts', [$this, 'enqueue_and_localize_script']); |
|
78 | + |
|
79 | + add_action('gravityview_datatables_scripts_styles', [$this, 'enqueue_and_localize_script']); |
|
80 | + |
|
81 | + add_filter('gravityview_get_entries', [$this, 'modify_search_parameters'], 1000); |
|
82 | + |
|
83 | + add_filter('gravityview/field_output/html', [$this, 'maybe_prevent_field_render'], 10, 2); |
|
84 | + |
|
85 | + add_filter('gravityview/field/is_visible', [$this, 'maybe_not_visible'], 10, 2); |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * @filter `gravityview/template/field_label` Modify field label output |
|
90 | + * |
|
91 | + * @since 1.19 |
|
92 | + * |
|
93 | + * @param string $html Existing HTML output |
|
94 | + * @param array $args Arguments passed to the function |
|
95 | + * |
|
96 | + * @return string Empty string if user doesn't have the `gravityview_moderate_entries` cap; field HTML otherwise |
|
97 | + */ |
|
98 | + public function maybe_prevent_field_render($html, $args) |
|
99 | + { |
|
100 | + |
|
101 | + // If the field is `entry_approval` type but the user doesn't have the moderate entries cap, don't render. |
|
102 | + if ($this->name === \GV\Utils::get($args['field'], 'id') && !GVCommon::has_cap('gravityview_moderate_entries')) { |
|
103 | + return ''; |
|
104 | + } |
|
105 | + |
|
106 | + return $html; |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * Do not show this field if `gravityview_moderate_entries` capability is absent. |
|
111 | + * |
|
112 | + * @return bool Whether this field is visible or not. |
|
113 | + */ |
|
114 | + public function maybe_not_visible($visible, $field) |
|
115 | + { |
|
116 | + if ($this->name !== $field->ID) { |
|
117 | + return $visible; |
|
118 | + } |
|
119 | + |
|
120 | + return GVCommon::has_cap('gravityview_moderate_entries'); |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Modify search to use `is_approved` meta key to sort, instead of `entry_approval`. |
|
125 | + * |
|
126 | + * @param array $parameters Search parameters used to generate GF search |
|
127 | + * |
|
128 | + * @return array Same parameters, but if sorting by `entry_approval`, changed to `is_approved` |
|
129 | + */ |
|
130 | + public function modify_search_parameters($parameters) |
|
131 | + { |
|
132 | + if ($this->name === \GV\Utils::get($parameters, 'sorting/key')) { |
|
133 | + $parameters['sorting']['key'] = 'is_approved'; |
|
134 | + } |
|
135 | + |
|
136 | + return $parameters; |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Register the field approval script and style. |
|
141 | + * |
|
142 | + * @since 1.19 |
|
143 | + * |
|
144 | + * @return void |
|
145 | + */ |
|
146 | + public function register_scripts_and_styles() |
|
147 | + { |
|
148 | + if (wp_script_is('gravityview-field-approval')) { |
|
149 | + return; |
|
150 | + } |
|
151 | + |
|
152 | + $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
153 | + |
|
154 | + wp_register_script('gravityview-field-approval', GRAVITYVIEW_URL.'assets/js/field-approval'.$script_debug.'.js', ['jquery'], GravityView_Plugin::version, true); |
|
155 | + |
|
156 | + wp_register_script('gravityview-field-approval-popper', GRAVITYVIEW_URL.'assets/lib/tippy/popper.min.js', [], GravityView_Plugin::version, true); |
|
157 | + wp_register_script('gravityview-field-approval-tippy', GRAVITYVIEW_URL.'assets/lib/tippy/tippy.min.js', [], GravityView_Plugin::version, true); |
|
158 | + wp_register_style('gravityview-field-approval-tippy', GRAVITYVIEW_URL.'assets/lib/tippy/tippy.css', [], GravityView_Plugin::version, 'screen'); |
|
159 | + |
|
160 | + $style_path = GRAVITYVIEW_DIR.'templates/css/field-approval.css'; |
|
161 | + |
|
162 | + if (class_exists('GravityView_View')) { |
|
163 | + /** |
|
164 | + * Override CSS file by placing in your theme's /gravityview/css/ sub-directory. |
|
165 | + */ |
|
166 | + $style_path = GravityView_View::getInstance()->locate_template('css/field-approval.css', false); |
|
167 | + } |
|
168 | + |
|
169 | + $style_url = plugins_url('css/field-approval.css', trailingslashit(dirname($style_path))); |
|
170 | + |
|
171 | + /** |
|
172 | + * @filter `gravityview/field/approval/css_url` URL to the Approval field CSS file. |
|
173 | + * |
|
174 | + * @since 1.19 |
|
175 | + * |
|
176 | + * @param string $style_url Override to use your own CSS file, or return empty string to disable loading. |
|
177 | + */ |
|
178 | + $style_url = apply_filters('gravityview/field/approval/css_url', $style_url); |
|
179 | + |
|
180 | + if (!empty($style_url)) { |
|
181 | + wp_register_style('gravityview-field-approval', $style_url, ['dashicons'], GravityView_Plugin::version, 'screen'); |
|
182 | + } |
|
183 | + |
|
184 | + unset($style_path, $style_url); |
|
185 | + } |
|
186 | + |
|
187 | + /** |
|
188 | + * Register the field approval script and output the localized text JS variables. |
|
189 | + * |
|
190 | + * @since 1.19 |
|
191 | + * |
|
192 | + * @return void |
|
193 | + */ |
|
194 | + public function enqueue_and_localize_script() |
|
195 | + { |
|
196 | + |
|
197 | + // The script is already registered and enqueued |
|
198 | + if (wp_script_is('gravityview-field-approval', 'enqueued')) { |
|
199 | + return; |
|
200 | + } |
|
201 | + |
|
202 | + wp_enqueue_style('gravityview-field-approval'); |
|
203 | + |
|
204 | + wp_enqueue_script('gravityview-field-approval'); |
|
205 | + wp_enqueue_script('gravityview-field-approval-tippy'); |
|
206 | + wp_enqueue_script('gravityview-field-approval-popper'); |
|
207 | + wp_enqueue_style('gravityview-field-approval-tippy'); |
|
208 | + |
|
209 | + wp_localize_script('gravityview-field-approval', 'gvApproval', [ |
|
210 | + 'ajaxurl' => admin_url('admin-ajax.php'), |
|
211 | + 'nonce' => wp_create_nonce('gravityview_entry_approval'), |
|
212 | + 'status' => GravityView_Entry_Approval_Status::get_all(), |
|
213 | + 'status_popover_template' => GravityView_Entry_Approval::get_popover_template(), |
|
214 | + 'status_popover_placement' => GravityView_Entry_Approval::get_popover_placement(), |
|
215 | + ]); |
|
216 | + } |
|
217 | + |
|
218 | + /** |
|
219 | + * Add Fields to the field list. |
|
220 | + * |
|
221 | + * @since 1.19 |
|
222 | + * |
|
223 | + * @param array $entry_default_fields Array of fields shown by default |
|
224 | + * @param string|array $form form_ID or form object |
|
225 | + * @param string $context Either 'single', 'directory', 'header', 'footer' |
|
226 | + * |
|
227 | + * @return array |
|
228 | + */ |
|
229 | + public function filter_gravityview_entry_default_field($entry_default_fields, $form, $context) |
|
230 | + { |
|
231 | + if (!isset($entry_default_fields["{$this->name}"]) && 'edit' !== $context) { |
|
232 | + $entry_default_fields["{$this->name}"] = [ |
|
233 | + 'label' => $this->label, |
|
234 | + 'desc' => $this->description, |
|
235 | + 'type' => $this->name, |
|
236 | + ]; |
|
237 | + } |
|
238 | + |
|
239 | + return $entry_default_fields; |
|
240 | + } |
|
241 | + |
|
242 | + /** |
|
243 | + * Get the anchor text for a link, based on the current status. |
|
244 | + * |
|
245 | + * @since 1.19 |
|
246 | + * |
|
247 | + * @uses GravityView_Entry_Approval_Status::get_string() |
|
248 | + * |
|
249 | + * @param string $approved_status Status string or key |
|
250 | + * |
|
251 | + * @return false|string False if string doesn't exist, otherwise the "label" for the status |
|
252 | + */ |
|
253 | + public static function get_anchor_text($approved_status = '') |
|
254 | + { |
|
255 | + return GravityView_Entry_Approval_Status::get_string($approved_status, 'label'); |
|
256 | + } |
|
257 | + |
|
258 | + /** |
|
259 | + * Get the title attribute for a link, based on the current status. |
|
260 | + * |
|
261 | + * @since 1.19 |
|
262 | + * |
|
263 | + * @uses GravityView_Entry_Approval_Status::get_string() |
|
264 | + * |
|
265 | + * @param int|string $approved_status Status string or key |
|
266 | + * |
|
267 | + * @return false|string |
|
268 | + */ |
|
269 | + public static function get_title_attr($approved_status) |
|
270 | + { |
|
271 | + return GravityView_Entry_Approval_Status::get_string($approved_status, 'title'); |
|
272 | + } |
|
273 | + |
|
274 | + /** |
|
275 | + * Get the CSS class for a link, based on the current status. |
|
276 | + * |
|
277 | + * @param int|string $approved_status Status string or key |
|
278 | + * |
|
279 | + * @return string CSS class, sanitized using esc_attr() |
|
280 | + */ |
|
281 | + public static function get_css_class($approved_status) |
|
282 | + { |
|
283 | + $approved_key = GravityView_Entry_Approval_Status::get_key($approved_status); |
|
284 | + |
|
285 | + return esc_attr("gv-approval-{$approved_key}"); |
|
286 | + } |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | new GravityView_Field_Entry_Approval(); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | public $is_searchable = true; |
13 | 13 | |
14 | - public $search_operators = ['is', 'isnot']; |
|
14 | + public $search_operators = [ 'is', 'isnot' ]; |
|
15 | 15 | |
16 | 16 | public $is_sortable = true; |
17 | 17 | |
@@ -19,15 +19,15 @@ discard block |
||
19 | 19 | |
20 | 20 | public $group = 'gravityview'; |
21 | 21 | |
22 | - public $contexts = ['single', 'multiple']; |
|
22 | + public $contexts = [ 'single', 'multiple' ]; |
|
23 | 23 | |
24 | 24 | public $icon = 'dashicons-yes-alt'; |
25 | 25 | |
26 | 26 | public function __construct() |
27 | 27 | { |
28 | - $this->label = esc_attr__('Approve Entries', 'gravityview'); |
|
28 | + $this->label = esc_attr__( 'Approve Entries', 'gravityview' ); |
|
29 | 29 | |
30 | - $this->description = esc_attr__('Approve and reject entries from the View.', 'gravityview'); |
|
30 | + $this->description = esc_attr__( 'Approve and reject entries from the View.', 'gravityview' ); |
|
31 | 31 | |
32 | 32 | $this->add_hooks(); |
33 | 33 | |
@@ -47,13 +47,13 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @return array |
49 | 49 | */ |
50 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
50 | + public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) |
|
51 | 51 | { |
52 | - unset($field_options['only_loggedin']); |
|
52 | + unset( $field_options[ 'only_loggedin' ] ); |
|
53 | 53 | |
54 | - unset($field_options['new_window']); |
|
54 | + unset( $field_options[ 'new_window' ] ); |
|
55 | 55 | |
56 | - unset($field_options['show_as_link']); |
|
56 | + unset( $field_options[ 'show_as_link' ] ); |
|
57 | 57 | |
58 | 58 | return $field_options; |
59 | 59 | } |
@@ -67,22 +67,22 @@ discard block |
||
67 | 67 | */ |
68 | 68 | private function add_hooks() |
69 | 69 | { |
70 | - add_filter('gravityview_entry_default_fields', [$this, 'filter_gravityview_entry_default_field'], 10, 3); |
|
70 | + add_filter( 'gravityview_entry_default_fields', [ $this, 'filter_gravityview_entry_default_field' ], 10, 3 ); |
|
71 | 71 | |
72 | - add_action('wp_enqueue_scripts', [$this, 'register_scripts_and_styles']); |
|
72 | + add_action( 'wp_enqueue_scripts', [ $this, 'register_scripts_and_styles' ] ); |
|
73 | 73 | |
74 | 74 | // Make sure scripts are registered for FSE themes |
75 | - add_action('gravityview/template/before', [$this, 'register_scripts_and_styles']); |
|
75 | + add_action( 'gravityview/template/before', [ $this, 'register_scripts_and_styles' ] ); |
|
76 | 76 | |
77 | - add_action('gravityview/field/approval/load_scripts', [$this, 'enqueue_and_localize_script']); |
|
77 | + add_action( 'gravityview/field/approval/load_scripts', [ $this, 'enqueue_and_localize_script' ] ); |
|
78 | 78 | |
79 | - add_action('gravityview_datatables_scripts_styles', [$this, 'enqueue_and_localize_script']); |
|
79 | + add_action( 'gravityview_datatables_scripts_styles', [ $this, 'enqueue_and_localize_script' ] ); |
|
80 | 80 | |
81 | - add_filter('gravityview_get_entries', [$this, 'modify_search_parameters'], 1000); |
|
81 | + add_filter( 'gravityview_get_entries', [ $this, 'modify_search_parameters' ], 1000 ); |
|
82 | 82 | |
83 | - add_filter('gravityview/field_output/html', [$this, 'maybe_prevent_field_render'], 10, 2); |
|
83 | + add_filter( 'gravityview/field_output/html', [ $this, 'maybe_prevent_field_render' ], 10, 2 ); |
|
84 | 84 | |
85 | - add_filter('gravityview/field/is_visible', [$this, 'maybe_not_visible'], 10, 2); |
|
85 | + add_filter( 'gravityview/field/is_visible', [ $this, 'maybe_not_visible' ], 10, 2 ); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return string Empty string if user doesn't have the `gravityview_moderate_entries` cap; field HTML otherwise |
97 | 97 | */ |
98 | - public function maybe_prevent_field_render($html, $args) |
|
98 | + public function maybe_prevent_field_render( $html, $args ) |
|
99 | 99 | { |
100 | 100 | |
101 | 101 | // If the field is `entry_approval` type but the user doesn't have the moderate entries cap, don't render. |
102 | - if ($this->name === \GV\Utils::get($args['field'], 'id') && !GVCommon::has_cap('gravityview_moderate_entries')) { |
|
102 | + if ( $this->name === \GV\Utils::get( $args[ 'field' ], 'id' ) && ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
103 | 103 | return ''; |
104 | 104 | } |
105 | 105 | |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return bool Whether this field is visible or not. |
113 | 113 | */ |
114 | - public function maybe_not_visible($visible, $field) |
|
114 | + public function maybe_not_visible( $visible, $field ) |
|
115 | 115 | { |
116 | - if ($this->name !== $field->ID) { |
|
116 | + if ( $this->name !== $field->ID ) { |
|
117 | 117 | return $visible; |
118 | 118 | } |
119 | 119 | |
120 | - return GVCommon::has_cap('gravityview_moderate_entries'); |
|
120 | + return GVCommon::has_cap( 'gravityview_moderate_entries' ); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -127,10 +127,10 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @return array Same parameters, but if sorting by `entry_approval`, changed to `is_approved` |
129 | 129 | */ |
130 | - public function modify_search_parameters($parameters) |
|
130 | + public function modify_search_parameters( $parameters ) |
|
131 | 131 | { |
132 | - if ($this->name === \GV\Utils::get($parameters, 'sorting/key')) { |
|
133 | - $parameters['sorting']['key'] = 'is_approved'; |
|
132 | + if ( $this->name === \GV\Utils::get( $parameters, 'sorting/key' ) ) { |
|
133 | + $parameters[ 'sorting' ][ 'key' ] = 'is_approved'; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | return $parameters; |
@@ -145,28 +145,28 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public function register_scripts_and_styles() |
147 | 147 | { |
148 | - if (wp_script_is('gravityview-field-approval')) { |
|
148 | + if ( wp_script_is( 'gravityview-field-approval' ) ) { |
|
149 | 149 | return; |
150 | 150 | } |
151 | 151 | |
152 | - $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
152 | + $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
153 | 153 | |
154 | - wp_register_script('gravityview-field-approval', GRAVITYVIEW_URL.'assets/js/field-approval'.$script_debug.'.js', ['jquery'], GravityView_Plugin::version, true); |
|
154 | + wp_register_script( 'gravityview-field-approval', GRAVITYVIEW_URL . 'assets/js/field-approval' . $script_debug . '.js', [ 'jquery' ], GravityView_Plugin::version, true ); |
|
155 | 155 | |
156 | - wp_register_script('gravityview-field-approval-popper', GRAVITYVIEW_URL.'assets/lib/tippy/popper.min.js', [], GravityView_Plugin::version, true); |
|
157 | - wp_register_script('gravityview-field-approval-tippy', GRAVITYVIEW_URL.'assets/lib/tippy/tippy.min.js', [], GravityView_Plugin::version, true); |
|
158 | - wp_register_style('gravityview-field-approval-tippy', GRAVITYVIEW_URL.'assets/lib/tippy/tippy.css', [], GravityView_Plugin::version, 'screen'); |
|
156 | + wp_register_script( 'gravityview-field-approval-popper', GRAVITYVIEW_URL . 'assets/lib/tippy/popper.min.js', [ ], GravityView_Plugin::version, true ); |
|
157 | + wp_register_script( 'gravityview-field-approval-tippy', GRAVITYVIEW_URL . 'assets/lib/tippy/tippy.min.js', [ ], GravityView_Plugin::version, true ); |
|
158 | + wp_register_style( 'gravityview-field-approval-tippy', GRAVITYVIEW_URL . 'assets/lib/tippy/tippy.css', [ ], GravityView_Plugin::version, 'screen' ); |
|
159 | 159 | |
160 | - $style_path = GRAVITYVIEW_DIR.'templates/css/field-approval.css'; |
|
160 | + $style_path = GRAVITYVIEW_DIR . 'templates/css/field-approval.css'; |
|
161 | 161 | |
162 | - if (class_exists('GravityView_View')) { |
|
162 | + if ( class_exists( 'GravityView_View' ) ) { |
|
163 | 163 | /** |
164 | 164 | * Override CSS file by placing in your theme's /gravityview/css/ sub-directory. |
165 | 165 | */ |
166 | - $style_path = GravityView_View::getInstance()->locate_template('css/field-approval.css', false); |
|
166 | + $style_path = GravityView_View::getInstance()->locate_template( 'css/field-approval.css', false ); |
|
167 | 167 | } |
168 | 168 | |
169 | - $style_url = plugins_url('css/field-approval.css', trailingslashit(dirname($style_path))); |
|
169 | + $style_url = plugins_url( 'css/field-approval.css', trailingslashit( dirname( $style_path ) ) ); |
|
170 | 170 | |
171 | 171 | /** |
172 | 172 | * @filter `gravityview/field/approval/css_url` URL to the Approval field CSS file. |
@@ -175,13 +175,13 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @param string $style_url Override to use your own CSS file, or return empty string to disable loading. |
177 | 177 | */ |
178 | - $style_url = apply_filters('gravityview/field/approval/css_url', $style_url); |
|
178 | + $style_url = apply_filters( 'gravityview/field/approval/css_url', $style_url ); |
|
179 | 179 | |
180 | - if (!empty($style_url)) { |
|
181 | - wp_register_style('gravityview-field-approval', $style_url, ['dashicons'], GravityView_Plugin::version, 'screen'); |
|
180 | + if ( ! empty( $style_url ) ) { |
|
181 | + wp_register_style( 'gravityview-field-approval', $style_url, [ 'dashicons' ], GravityView_Plugin::version, 'screen' ); |
|
182 | 182 | } |
183 | 183 | |
184 | - unset($style_path, $style_url); |
|
184 | + unset( $style_path, $style_url ); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
@@ -195,24 +195,24 @@ discard block |
||
195 | 195 | { |
196 | 196 | |
197 | 197 | // The script is already registered and enqueued |
198 | - if (wp_script_is('gravityview-field-approval', 'enqueued')) { |
|
198 | + if ( wp_script_is( 'gravityview-field-approval', 'enqueued' ) ) { |
|
199 | 199 | return; |
200 | 200 | } |
201 | 201 | |
202 | - wp_enqueue_style('gravityview-field-approval'); |
|
202 | + wp_enqueue_style( 'gravityview-field-approval' ); |
|
203 | 203 | |
204 | - wp_enqueue_script('gravityview-field-approval'); |
|
205 | - wp_enqueue_script('gravityview-field-approval-tippy'); |
|
206 | - wp_enqueue_script('gravityview-field-approval-popper'); |
|
207 | - wp_enqueue_style('gravityview-field-approval-tippy'); |
|
204 | + wp_enqueue_script( 'gravityview-field-approval' ); |
|
205 | + wp_enqueue_script( 'gravityview-field-approval-tippy' ); |
|
206 | + wp_enqueue_script( 'gravityview-field-approval-popper' ); |
|
207 | + wp_enqueue_style( 'gravityview-field-approval-tippy' ); |
|
208 | 208 | |
209 | - wp_localize_script('gravityview-field-approval', 'gvApproval', [ |
|
210 | - 'ajaxurl' => admin_url('admin-ajax.php'), |
|
211 | - 'nonce' => wp_create_nonce('gravityview_entry_approval'), |
|
209 | + wp_localize_script( 'gravityview-field-approval', 'gvApproval', [ |
|
210 | + 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
|
211 | + 'nonce' => wp_create_nonce( 'gravityview_entry_approval' ), |
|
212 | 212 | 'status' => GravityView_Entry_Approval_Status::get_all(), |
213 | 213 | 'status_popover_template' => GravityView_Entry_Approval::get_popover_template(), |
214 | 214 | 'status_popover_placement' => GravityView_Entry_Approval::get_popover_placement(), |
215 | - ]); |
|
215 | + ] ); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -226,10 +226,10 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @return array |
228 | 228 | */ |
229 | - public function filter_gravityview_entry_default_field($entry_default_fields, $form, $context) |
|
229 | + public function filter_gravityview_entry_default_field( $entry_default_fields, $form, $context ) |
|
230 | 230 | { |
231 | - if (!isset($entry_default_fields["{$this->name}"]) && 'edit' !== $context) { |
|
232 | - $entry_default_fields["{$this->name}"] = [ |
|
231 | + if ( ! isset( $entry_default_fields[ "{$this->name}" ] ) && 'edit' !== $context ) { |
|
232 | + $entry_default_fields[ "{$this->name}" ] = [ |
|
233 | 233 | 'label' => $this->label, |
234 | 234 | 'desc' => $this->description, |
235 | 235 | 'type' => $this->name, |
@@ -250,9 +250,9 @@ discard block |
||
250 | 250 | * |
251 | 251 | * @return false|string False if string doesn't exist, otherwise the "label" for the status |
252 | 252 | */ |
253 | - public static function get_anchor_text($approved_status = '') |
|
253 | + public static function get_anchor_text( $approved_status = '' ) |
|
254 | 254 | { |
255 | - return GravityView_Entry_Approval_Status::get_string($approved_status, 'label'); |
|
255 | + return GravityView_Entry_Approval_Status::get_string( $approved_status, 'label' ); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -266,9 +266,9 @@ discard block |
||
266 | 266 | * |
267 | 267 | * @return false|string |
268 | 268 | */ |
269 | - public static function get_title_attr($approved_status) |
|
269 | + public static function get_title_attr( $approved_status ) |
|
270 | 270 | { |
271 | - return GravityView_Entry_Approval_Status::get_string($approved_status, 'title'); |
|
271 | + return GravityView_Entry_Approval_Status::get_string( $approved_status, 'title' ); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -278,11 +278,11 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @return string CSS class, sanitized using esc_attr() |
280 | 280 | */ |
281 | - public static function get_css_class($approved_status) |
|
281 | + public static function get_css_class( $approved_status ) |
|
282 | 282 | { |
283 | - $approved_key = GravityView_Entry_Approval_Status::get_key($approved_status); |
|
283 | + $approved_key = GravityView_Entry_Approval_Status::get_key( $approved_status ); |
|
284 | 284 | |
285 | - return esc_attr("gv-approval-{$approved_key}"); |
|
285 | + return esc_attr( "gv-approval-{$approved_key}" ); |
|
286 | 286 | } |
287 | 287 | } |
288 | 288 |
@@ -5,8 +5,7 @@ discard block |
||
5 | 5 | * |
6 | 6 | * @since 1.19 |
7 | 7 | */ |
8 | -class GravityView_Field_Entry_Approval extends GravityView_Field |
|
9 | -{ |
|
8 | +class GravityView_Field_Entry_Approval extends GravityView_Field { |
|
10 | 9 | public $name = 'entry_approval'; |
11 | 10 | |
12 | 11 | public $is_searchable = true; |
@@ -23,8 +22,7 @@ discard block |
||
23 | 22 | |
24 | 23 | public $icon = 'dashicons-yes-alt'; |
25 | 24 | |
26 | - public function __construct() |
|
27 | - { |
|
25 | + public function __construct() { |
|
28 | 26 | $this->label = esc_attr__('Approve Entries', 'gravityview'); |
29 | 27 | |
30 | 28 | $this->description = esc_attr__('Approve and reject entries from the View.', 'gravityview'); |
@@ -47,8 +45,7 @@ discard block |
||
47 | 45 | * |
48 | 46 | * @return array |
49 | 47 | */ |
50 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
51 | - { |
|
48 | + public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) { |
|
52 | 49 | unset($field_options['only_loggedin']); |
53 | 50 | |
54 | 51 | unset($field_options['new_window']); |
@@ -65,8 +62,7 @@ discard block |
||
65 | 62 | * |
66 | 63 | * @return void |
67 | 64 | */ |
68 | - private function add_hooks() |
|
69 | - { |
|
65 | + private function add_hooks() { |
|
70 | 66 | add_filter('gravityview_entry_default_fields', [$this, 'filter_gravityview_entry_default_field'], 10, 3); |
71 | 67 | |
72 | 68 | add_action('wp_enqueue_scripts', [$this, 'register_scripts_and_styles']); |
@@ -95,8 +91,7 @@ discard block |
||
95 | 91 | * |
96 | 92 | * @return string Empty string if user doesn't have the `gravityview_moderate_entries` cap; field HTML otherwise |
97 | 93 | */ |
98 | - public function maybe_prevent_field_render($html, $args) |
|
99 | - { |
|
94 | + public function maybe_prevent_field_render($html, $args) { |
|
100 | 95 | |
101 | 96 | // If the field is `entry_approval` type but the user doesn't have the moderate entries cap, don't render. |
102 | 97 | if ($this->name === \GV\Utils::get($args['field'], 'id') && !GVCommon::has_cap('gravityview_moderate_entries')) { |
@@ -111,8 +106,7 @@ discard block |
||
111 | 106 | * |
112 | 107 | * @return bool Whether this field is visible or not. |
113 | 108 | */ |
114 | - public function maybe_not_visible($visible, $field) |
|
115 | - { |
|
109 | + public function maybe_not_visible($visible, $field) { |
|
116 | 110 | if ($this->name !== $field->ID) { |
117 | 111 | return $visible; |
118 | 112 | } |
@@ -127,8 +121,7 @@ discard block |
||
127 | 121 | * |
128 | 122 | * @return array Same parameters, but if sorting by `entry_approval`, changed to `is_approved` |
129 | 123 | */ |
130 | - public function modify_search_parameters($parameters) |
|
131 | - { |
|
124 | + public function modify_search_parameters($parameters) { |
|
132 | 125 | if ($this->name === \GV\Utils::get($parameters, 'sorting/key')) { |
133 | 126 | $parameters['sorting']['key'] = 'is_approved'; |
134 | 127 | } |
@@ -143,8 +136,7 @@ discard block |
||
143 | 136 | * |
144 | 137 | * @return void |
145 | 138 | */ |
146 | - public function register_scripts_and_styles() |
|
147 | - { |
|
139 | + public function register_scripts_and_styles() { |
|
148 | 140 | if (wp_script_is('gravityview-field-approval')) { |
149 | 141 | return; |
150 | 142 | } |
@@ -191,8 +183,7 @@ discard block |
||
191 | 183 | * |
192 | 184 | * @return void |
193 | 185 | */ |
194 | - public function enqueue_and_localize_script() |
|
195 | - { |
|
186 | + public function enqueue_and_localize_script() { |
|
196 | 187 | |
197 | 188 | // The script is already registered and enqueued |
198 | 189 | if (wp_script_is('gravityview-field-approval', 'enqueued')) { |
@@ -226,8 +217,7 @@ discard block |
||
226 | 217 | * |
227 | 218 | * @return array |
228 | 219 | */ |
229 | - public function filter_gravityview_entry_default_field($entry_default_fields, $form, $context) |
|
230 | - { |
|
220 | + public function filter_gravityview_entry_default_field($entry_default_fields, $form, $context) { |
|
231 | 221 | if (!isset($entry_default_fields["{$this->name}"]) && 'edit' !== $context) { |
232 | 222 | $entry_default_fields["{$this->name}"] = [ |
233 | 223 | 'label' => $this->label, |
@@ -250,8 +240,7 @@ discard block |
||
250 | 240 | * |
251 | 241 | * @return false|string False if string doesn't exist, otherwise the "label" for the status |
252 | 242 | */ |
253 | - public static function get_anchor_text($approved_status = '') |
|
254 | - { |
|
243 | + public static function get_anchor_text($approved_status = '') { |
|
255 | 244 | return GravityView_Entry_Approval_Status::get_string($approved_status, 'label'); |
256 | 245 | } |
257 | 246 | |
@@ -266,8 +255,7 @@ discard block |
||
266 | 255 | * |
267 | 256 | * @return false|string |
268 | 257 | */ |
269 | - public static function get_title_attr($approved_status) |
|
270 | - { |
|
258 | + public static function get_title_attr($approved_status) { |
|
271 | 259 | return GravityView_Entry_Approval_Status::get_string($approved_status, 'title'); |
272 | 260 | } |
273 | 261 | |
@@ -278,8 +266,7 @@ discard block |
||
278 | 266 | * |
279 | 267 | * @return string CSS class, sanitized using esc_attr() |
280 | 268 | */ |
281 | - public static function get_css_class($approved_status) |
|
282 | - { |
|
269 | + public static function get_css_class($approved_status) { |
|
283 | 270 | $approved_key = GravityView_Entry_Approval_Status::get_key($approved_status); |
284 | 271 | |
285 | 272 | return esc_attr("gv-approval-{$approved_key}"); |
@@ -8,38 +8,38 @@ |
||
8 | 8 | */ |
9 | 9 | class GravityView_Field_Post_Tags extends GravityView_Field |
10 | 10 | { |
11 | - public $name = 'post_tags'; |
|
11 | + public $name = 'post_tags'; |
|
12 | 12 | |
13 | - public $is_searchable = true; |
|
13 | + public $is_searchable = true; |
|
14 | 14 | |
15 | - public $search_operators = ['is', 'in', 'not in', 'isnot', 'contains']; |
|
15 | + public $search_operators = ['is', 'in', 'not in', 'isnot', 'contains']; |
|
16 | 16 | |
17 | - public $_gf_field_class_name = 'GF_Field_Post_Tags'; |
|
17 | + public $_gf_field_class_name = 'GF_Field_Post_Tags'; |
|
18 | 18 | |
19 | - public $group = 'post'; |
|
19 | + public $group = 'post'; |
|
20 | 20 | |
21 | - public $icon = 'dashicons-tag'; |
|
21 | + public $icon = 'dashicons-tag'; |
|
22 | 22 | |
23 | - public function __construct() |
|
24 | - { |
|
25 | - $this->label = esc_html__('Post Tags', 'gravityview'); |
|
26 | - parent::__construct(); |
|
27 | - } |
|
23 | + public function __construct() |
|
24 | + { |
|
25 | + $this->label = esc_html__('Post Tags', 'gravityview'); |
|
26 | + parent::__construct(); |
|
27 | + } |
|
28 | 28 | |
29 | - public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
30 | - { |
|
31 | - if ('edit' === $context) { |
|
32 | - return $field_options; |
|
33 | - } |
|
29 | + public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) |
|
30 | + { |
|
31 | + if ('edit' === $context) { |
|
32 | + return $field_options; |
|
33 | + } |
|
34 | 34 | |
35 | - $this->add_field_support('dynamic_data', $field_options); |
|
36 | - $this->add_field_support('link_to_term', $field_options); |
|
37 | - $this->add_field_support('new_window', $field_options); |
|
35 | + $this->add_field_support('dynamic_data', $field_options); |
|
36 | + $this->add_field_support('link_to_term', $field_options); |
|
37 | + $this->add_field_support('new_window', $field_options); |
|
38 | 38 | |
39 | - $field_options['new_window']['requires'] = 'link_to_term'; |
|
39 | + $field_options['new_window']['requires'] = 'link_to_term'; |
|
40 | 40 | |
41 | - return $field_options; |
|
42 | - } |
|
41 | + return $field_options; |
|
42 | + } |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | new GravityView_Field_Post_Tags(); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | public $is_searchable = true; |
14 | 14 | |
15 | - public $search_operators = ['is', 'in', 'not in', 'isnot', 'contains']; |
|
15 | + public $search_operators = [ 'is', 'in', 'not in', 'isnot', 'contains' ]; |
|
16 | 16 | |
17 | 17 | public $_gf_field_class_name = 'GF_Field_Post_Tags'; |
18 | 18 | |
@@ -22,21 +22,21 @@ discard block |
||
22 | 22 | |
23 | 23 | public function __construct() |
24 | 24 | { |
25 | - $this->label = esc_html__('Post Tags', 'gravityview'); |
|
25 | + $this->label = esc_html__( 'Post Tags', '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 | - if ('edit' === $context) { |
|
31 | + if ( 'edit' === $context ) { |
|
32 | 32 | return $field_options; |
33 | 33 | } |
34 | 34 | |
35 | - $this->add_field_support('dynamic_data', $field_options); |
|
36 | - $this->add_field_support('link_to_term', $field_options); |
|
37 | - $this->add_field_support('new_window', $field_options); |
|
35 | + $this->add_field_support( 'dynamic_data', $field_options ); |
|
36 | + $this->add_field_support( 'link_to_term', $field_options ); |
|
37 | + $this->add_field_support( 'new_window', $field_options ); |
|
38 | 38 | |
39 | - $field_options['new_window']['requires'] = 'link_to_term'; |
|
39 | + $field_options[ 'new_window' ][ 'requires' ] = 'link_to_term'; |
|
40 | 40 | |
41 | 41 | return $field_options; |
42 | 42 | } |
@@ -6,8 +6,7 @@ discard block |
||
6 | 6 | /** |
7 | 7 | * Add custom options for date fields. |
8 | 8 | */ |
9 | -class GravityView_Field_Post_Tags extends GravityView_Field |
|
10 | -{ |
|
9 | +class GravityView_Field_Post_Tags extends GravityView_Field { |
|
11 | 10 | public $name = 'post_tags'; |
12 | 11 | |
13 | 12 | public $is_searchable = true; |
@@ -20,14 +19,12 @@ discard block |
||
20 | 19 | |
21 | 20 | public $icon = 'dashicons-tag'; |
22 | 21 | |
23 | - public function __construct() |
|
24 | - { |
|
22 | + public function __construct() { |
|
25 | 23 | $this->label = esc_html__('Post Tags', '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 | if ('edit' === $context) { |
32 | 29 | return $field_options; |
33 | 30 | } |
@@ -6,24 +6,24 @@ |
||
6 | 6 | */ |
7 | 7 | class GravityView_Field_IP extends GravityView_Field |
8 | 8 | { |
9 | - public $name = 'ip'; |
|
9 | + public $name = 'ip'; |
|
10 | 10 | |
11 | - public $is_searchable = true; |
|
11 | + public $is_searchable = true; |
|
12 | 12 | |
13 | - public $search_operators = ['is', 'isnot', 'contains']; |
|
13 | + public $search_operators = ['is', 'isnot', 'contains']; |
|
14 | 14 | |
15 | - public $group = 'meta'; |
|
15 | + public $group = 'meta'; |
|
16 | 16 | |
17 | - public $icon = 'dashicons-laptop'; |
|
17 | + public $icon = 'dashicons-laptop'; |
|
18 | 18 | |
19 | - public $is_numeric = true; |
|
19 | + public $is_numeric = true; |
|
20 | 20 | |
21 | - public function __construct() |
|
22 | - { |
|
23 | - $this->label = __('User IP', 'gravityview'); |
|
24 | - $this->description = __('The IP Address of the user who created the entry.', 'gravityview'); |
|
25 | - parent::__construct(); |
|
26 | - } |
|
21 | + public function __construct() |
|
22 | + { |
|
23 | + $this->label = __('User IP', 'gravityview'); |
|
24 | + $this->description = __('The IP Address of the user who created the entry.', 'gravityview'); |
|
25 | + parent::__construct(); |
|
26 | + } |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | new GravityView_Field_IP(); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | public $is_searchable = true; |
12 | 12 | |
13 | - public $search_operators = ['is', 'isnot', 'contains']; |
|
13 | + public $search_operators = [ 'is', 'isnot', 'contains' ]; |
|
14 | 14 | |
15 | 15 | public $group = 'meta'; |
16 | 16 | |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | |
21 | 21 | public function __construct() |
22 | 22 | { |
23 | - $this->label = __('User IP', 'gravityview'); |
|
24 | - $this->description = __('The IP Address of the user who created the entry.', 'gravityview'); |
|
23 | + $this->label = __( 'User IP', 'gravityview' ); |
|
24 | + $this->description = __( 'The IP Address of the user who created the entry.', 'gravityview' ); |
|
25 | 25 | parent::__construct(); |
26 | 26 | } |
27 | 27 | } |
@@ -4,8 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | * @since 2.10 |
6 | 6 | */ |
7 | -class GravityView_Field_IP extends GravityView_Field |
|
8 | -{ |
|
7 | +class GravityView_Field_IP extends GravityView_Field { |
|
9 | 8 | public $name = 'ip'; |
10 | 9 | |
11 | 10 | public $is_searchable = true; |
@@ -18,8 +17,7 @@ discard block |
||
18 | 17 | |
19 | 18 | public $is_numeric = true; |
20 | 19 | |
21 | - public function __construct() |
|
22 | - { |
|
20 | + public function __construct() { |
|
23 | 21 | $this->label = __('User IP', 'gravityview'); |
24 | 22 | $this->description = __('The IP Address of the user who created the entry.', 'gravityview'); |
25 | 23 | parent::__construct(); |
@@ -6,176 +6,176 @@ |
||
6 | 6 | */ |
7 | 7 | class GravityView_Field_Workflow_Step extends GravityView_Field |
8 | 8 | { |
9 | - public $name = 'workflow_step'; |
|
10 | - |
|
11 | - public $group = 'add-ons'; |
|
12 | - |
|
13 | - public $icon = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMS43IDExLjIiPjxwYXRoIGQ9Ik0xNC43IDUuOWwtNy00Yy0xLjItLjctMi41LS44LTMuNy0uMy0xLjcuNy0yLjYgMS45LTIuNyAzLjYtLjEgMS41LjQgMi43IDEuNCAzLjcgMS4xIDEuMSAyLjYgMS40IDQuMy45LjIgMCAuNS0uMiAxLjEtLjQuMi0uMS4zLS4xLjQtLjEuMyAwIC41LjEuNi40LjEuMyAwIC41LS4zLjctMS4yLjctMi40LjktMy44LjgtMS4zLS4yLTIuNS0uNy0zLjQtMS42Qy41IDguNS0uMSA3LjEgMCA1LjVjLjEtMi40IDEuMi00IDMuMy01QzQuNS0uMSA1LjgtLjIgNy4yLjJjLjIuMS42LjIgMS4yLjZsNyAzLjkuNC0uNi44IDIuMS0yLjIuMy4zLS42em0tNy44LS41bDcgNGMxLjIuNyAyLjUuOCAzLjcuMyAxLjctLjcgMi42LTEuOSAyLjgtMy42LjEtMS40LS40LTIuNi0xLjUtMy43cy0yLjUtMS40LTQuMy0xYy0uNC4xLS44LjMtMS4xLjRsLS40LjFjLS4zIDAtLjUtLjEtLjYtLjQtLjEtLjMgMC0uNS4zLS43IDEuMS0uNyAyLjQtLjkgMy44LS44IDEuNC4yIDIuNS43IDMuNCAxLjcgMS4yIDEuMiAxLjcgMi41IDEuNiA0LjEtLjEgMi4zLTEuMiA0LTMuMyA1LTEuNC42LTIuNy42LTMuOS4yLS4zLS4xLS43LS4zLTEuMS0uNWwtNy0zLjktLjQuNUw1LjEgNWwyLjItLjMtLjQuN3oiLz48L3N2Zz4='; |
|
14 | - |
|
15 | - public function __construct() |
|
16 | - { |
|
17 | - $this->label = esc_html__('Workflow Step', 'gravityview'); |
|
18 | - $this->default_search_label = $this->label; |
|
19 | - |
|
20 | - $this->add_hooks(); |
|
21 | - |
|
22 | - parent::__construct(); |
|
23 | - } |
|
24 | - |
|
25 | - public function add_hooks() |
|
26 | - { |
|
27 | - add_filter('gravityview_search_field_label', [$this, 'modify_gravityview_search_field_step_label'], 10, 3); |
|
28 | - |
|
29 | - add_filter('gravityview_widget_search_filters', [$this, 'modify_frontend_search_fields'], 10, 3); |
|
30 | - |
|
31 | - add_filter('gravityview_field_entry_value_workflow_step', [$this, 'modify_entry_value_workflow_step'], 10, 4); |
|
32 | - } |
|
33 | - |
|
34 | - /** |
|
35 | - * Get the value of the Workflow Step based on the `workflow_step` entry meta int value. |
|
36 | - * |
|
37 | - * @uses Gravity_Flow_API::get_current_step |
|
38 | - * |
|
39 | - * @param string $output HTML value output |
|
40 | - * @param array $entry The GF entry array |
|
41 | - * @param array $field_settings Settings for the particular GV field |
|
42 | - * @param array $field Current field being displayed |
|
43 | - * |
|
44 | - * @since 1.17 |
|
45 | - * |
|
46 | - * @return string If Gravity Flow not found, or entry not processed yet, returns initial value. Otherwise, returns name of workflow step. |
|
47 | - */ |
|
48 | - public function modify_entry_value_workflow_step($output, $entry, $field_settings, $field) |
|
49 | - { |
|
50 | - |
|
51 | - // If not set, the entry hasn't started a workflow |
|
52 | - $has_workflow_step = isset($entry['workflow_step']); |
|
53 | - |
|
54 | - if ($has_workflow_step) { |
|
55 | - $GFlow = new Gravity_Flow_API($entry['form_id']); |
|
56 | - |
|
57 | - if ($current_step = $GFlow->get_current_step($entry)) { |
|
58 | - $output = esc_html($current_step->get_name()); |
|
59 | - } else { |
|
60 | - $output = esc_html__('Workflow Complete', 'gravityview'); |
|
61 | - } |
|
62 | - |
|
63 | - unset($GFlow); |
|
64 | - } |
|
65 | - |
|
66 | - return $output; |
|
67 | - } |
|
68 | - |
|
69 | - /** |
|
70 | - * Get the Workflow Step ID from a search field key. |
|
71 | - * |
|
72 | - * @param string $key Search field key, in the following format: `workflow_step_status_[number]` |
|
73 | - * |
|
74 | - * @return bool|int The ID of the workflow step. False if not a workflow step field key. |
|
75 | - */ |
|
76 | - private function get_step_id_from_key($key) |
|
77 | - { |
|
78 | - $workflow_step_id = false; |
|
79 | - |
|
80 | - preg_match('/workflow_step_status_(\d+)/', $key, $matches); |
|
81 | - |
|
82 | - if (!empty($matches)) { |
|
83 | - $workflow_step_id = intval($matches[1]); |
|
84 | - } |
|
85 | - |
|
86 | - return $workflow_step_id; |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * @since 1.17.3 |
|
91 | - * |
|
92 | - * @param string $label Existing label text, sanitized. |
|
93 | - * @param null|GF_Field $gf_field If search field is connected to a Gravity Forms field, the field object. |
|
94 | - * @param array $field Array with the following keys: `field` ID of the meta key or field ID to be searched, `input` the type of search input to be shown, `label` the existing label. Same as $label parameter. |
|
95 | - * |
|
96 | - * @return string If showing a search field for a Step, show the step label. |
|
97 | - */ |
|
98 | - public function modify_gravityview_search_field_step_label($label = '', $gf_field = null, $field = []) |
|
99 | - { |
|
100 | - $return = $label; |
|
101 | - |
|
102 | - if ('' === $label && $workflow_step_id = $this->get_step_id_from_key($field['field'])) { |
|
103 | - $step = $this->get_workflow_step($workflow_step_id); |
|
104 | - |
|
105 | - $return = esc_html($step->get_label()); |
|
106 | - } |
|
107 | - |
|
108 | - return $return; |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Get a Gravity_Flow_Step object from the step ID. |
|
113 | - * |
|
114 | - * @since 1.17.3 |
|
115 | - * |
|
116 | - * @uses GravityView_View::getFormId() to get the current form being searched |
|
117 | - * @uses Gravity_Flow_API::get_step() |
|
118 | - * |
|
119 | - * @param int $workflow_step_id ID of the step |
|
120 | - * |
|
121 | - * @return bool|Gravity_Flow_Step |
|
122 | - */ |
|
123 | - public function get_workflow_step($workflow_step_id = 0) |
|
124 | - { |
|
125 | - $form_id = GravityView_View::getInstance()->getFormId(); |
|
126 | - |
|
127 | - $GFlow = new Gravity_Flow_API($form_id); |
|
128 | - |
|
129 | - $workflow_step = $GFlow->get_step($workflow_step_id); |
|
130 | - |
|
131 | - if (!$GFlow || !$workflow_step) { |
|
132 | - return false; |
|
133 | - } |
|
134 | - |
|
135 | - return $workflow_step; |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * Set the search field choices to the Steps available for the current form. |
|
140 | - * |
|
141 | - * @since 1.17.3 |
|
142 | - * |
|
143 | - * @param array $search_fields |
|
144 | - * @param GravityView_Widget_Search $widget |
|
145 | - * @param array $widget_args |
|
146 | - * |
|
147 | - * @return array |
|
148 | - */ |
|
149 | - public function modify_frontend_search_fields($search_fields = [], GravityView_Widget_Search $widget = null, $widget_args = []) |
|
150 | - { |
|
151 | - foreach ($search_fields as &$search_field) { |
|
152 | - if ($this->name === $search_field['key']) { |
|
153 | - $form_id = GravityView_View::getInstance()->getFormId(); |
|
154 | - |
|
155 | - $workflow_steps = gravity_flow()->get_steps($form_id); |
|
156 | - |
|
157 | - $choices = []; |
|
158 | - |
|
159 | - foreach ($workflow_steps as $step) { |
|
160 | - $choices[] = [ |
|
161 | - 'text' => $step->get_name(), |
|
162 | - 'value' => $step->get_id(), |
|
163 | - ]; |
|
164 | - } |
|
165 | - |
|
166 | - $search_field['choices'] = $choices; |
|
167 | - } |
|
168 | - |
|
169 | - // Workflow Step Statuses |
|
170 | - elseif ($workflow_step_id = $this->get_step_id_from_key($search_field['key'])) { |
|
171 | - $status_key = sprintf('workflow_step_status_%d', $workflow_step_id); |
|
172 | - |
|
173 | - $search_field['choices'] = GravityView_Plugin_Hooks_Gravity_Flow::get_status_options(null, $status_key); |
|
174 | - } |
|
175 | - } |
|
176 | - |
|
177 | - return $search_fields; |
|
178 | - } |
|
9 | + public $name = 'workflow_step'; |
|
10 | + |
|
11 | + public $group = 'add-ons'; |
|
12 | + |
|
13 | + public $icon = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMS43IDExLjIiPjxwYXRoIGQ9Ik0xNC43IDUuOWwtNy00Yy0xLjItLjctMi41LS44LTMuNy0uMy0xLjcuNy0yLjYgMS45LTIuNyAzLjYtLjEgMS41LjQgMi43IDEuNCAzLjcgMS4xIDEuMSAyLjYgMS40IDQuMy45LjIgMCAuNS0uMiAxLjEtLjQuMi0uMS4zLS4xLjQtLjEuMyAwIC41LjEuNi40LjEuMyAwIC41LS4zLjctMS4yLjctMi40LjktMy44LjgtMS4zLS4yLTIuNS0uNy0zLjQtMS42Qy41IDguNS0uMSA3LjEgMCA1LjVjLjEtMi40IDEuMi00IDMuMy01QzQuNS0uMSA1LjgtLjIgNy4yLjJjLjIuMS42LjIgMS4yLjZsNyAzLjkuNC0uNi44IDIuMS0yLjIuMy4zLS42em0tNy44LS41bDcgNGMxLjIuNyAyLjUuOCAzLjcuMyAxLjctLjcgMi42LTEuOSAyLjgtMy42LjEtMS40LS40LTIuNi0xLjUtMy43cy0yLjUtMS40LTQuMy0xYy0uNC4xLS44LjMtMS4xLjRsLS40LjFjLS4zIDAtLjUtLjEtLjYtLjQtLjEtLjMgMC0uNS4zLS43IDEuMS0uNyAyLjQtLjkgMy44LS44IDEuNC4yIDIuNS43IDMuNCAxLjcgMS4yIDEuMiAxLjcgMi41IDEuNiA0LjEtLjEgMi4zLTEuMiA0LTMuMyA1LTEuNC42LTIuNy42LTMuOS4yLS4zLS4xLS43LS4zLTEuMS0uNWwtNy0zLjktLjQuNUw1LjEgNWwyLjItLjMtLjQuN3oiLz48L3N2Zz4='; |
|
14 | + |
|
15 | + public function __construct() |
|
16 | + { |
|
17 | + $this->label = esc_html__('Workflow Step', 'gravityview'); |
|
18 | + $this->default_search_label = $this->label; |
|
19 | + |
|
20 | + $this->add_hooks(); |
|
21 | + |
|
22 | + parent::__construct(); |
|
23 | + } |
|
24 | + |
|
25 | + public function add_hooks() |
|
26 | + { |
|
27 | + add_filter('gravityview_search_field_label', [$this, 'modify_gravityview_search_field_step_label'], 10, 3); |
|
28 | + |
|
29 | + add_filter('gravityview_widget_search_filters', [$this, 'modify_frontend_search_fields'], 10, 3); |
|
30 | + |
|
31 | + add_filter('gravityview_field_entry_value_workflow_step', [$this, 'modify_entry_value_workflow_step'], 10, 4); |
|
32 | + } |
|
33 | + |
|
34 | + /** |
|
35 | + * Get the value of the Workflow Step based on the `workflow_step` entry meta int value. |
|
36 | + * |
|
37 | + * @uses Gravity_Flow_API::get_current_step |
|
38 | + * |
|
39 | + * @param string $output HTML value output |
|
40 | + * @param array $entry The GF entry array |
|
41 | + * @param array $field_settings Settings for the particular GV field |
|
42 | + * @param array $field Current field being displayed |
|
43 | + * |
|
44 | + * @since 1.17 |
|
45 | + * |
|
46 | + * @return string If Gravity Flow not found, or entry not processed yet, returns initial value. Otherwise, returns name of workflow step. |
|
47 | + */ |
|
48 | + public function modify_entry_value_workflow_step($output, $entry, $field_settings, $field) |
|
49 | + { |
|
50 | + |
|
51 | + // If not set, the entry hasn't started a workflow |
|
52 | + $has_workflow_step = isset($entry['workflow_step']); |
|
53 | + |
|
54 | + if ($has_workflow_step) { |
|
55 | + $GFlow = new Gravity_Flow_API($entry['form_id']); |
|
56 | + |
|
57 | + if ($current_step = $GFlow->get_current_step($entry)) { |
|
58 | + $output = esc_html($current_step->get_name()); |
|
59 | + } else { |
|
60 | + $output = esc_html__('Workflow Complete', 'gravityview'); |
|
61 | + } |
|
62 | + |
|
63 | + unset($GFlow); |
|
64 | + } |
|
65 | + |
|
66 | + return $output; |
|
67 | + } |
|
68 | + |
|
69 | + /** |
|
70 | + * Get the Workflow Step ID from a search field key. |
|
71 | + * |
|
72 | + * @param string $key Search field key, in the following format: `workflow_step_status_[number]` |
|
73 | + * |
|
74 | + * @return bool|int The ID of the workflow step. False if not a workflow step field key. |
|
75 | + */ |
|
76 | + private function get_step_id_from_key($key) |
|
77 | + { |
|
78 | + $workflow_step_id = false; |
|
79 | + |
|
80 | + preg_match('/workflow_step_status_(\d+)/', $key, $matches); |
|
81 | + |
|
82 | + if (!empty($matches)) { |
|
83 | + $workflow_step_id = intval($matches[1]); |
|
84 | + } |
|
85 | + |
|
86 | + return $workflow_step_id; |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * @since 1.17.3 |
|
91 | + * |
|
92 | + * @param string $label Existing label text, sanitized. |
|
93 | + * @param null|GF_Field $gf_field If search field is connected to a Gravity Forms field, the field object. |
|
94 | + * @param array $field Array with the following keys: `field` ID of the meta key or field ID to be searched, `input` the type of search input to be shown, `label` the existing label. Same as $label parameter. |
|
95 | + * |
|
96 | + * @return string If showing a search field for a Step, show the step label. |
|
97 | + */ |
|
98 | + public function modify_gravityview_search_field_step_label($label = '', $gf_field = null, $field = []) |
|
99 | + { |
|
100 | + $return = $label; |
|
101 | + |
|
102 | + if ('' === $label && $workflow_step_id = $this->get_step_id_from_key($field['field'])) { |
|
103 | + $step = $this->get_workflow_step($workflow_step_id); |
|
104 | + |
|
105 | + $return = esc_html($step->get_label()); |
|
106 | + } |
|
107 | + |
|
108 | + return $return; |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Get a Gravity_Flow_Step object from the step ID. |
|
113 | + * |
|
114 | + * @since 1.17.3 |
|
115 | + * |
|
116 | + * @uses GravityView_View::getFormId() to get the current form being searched |
|
117 | + * @uses Gravity_Flow_API::get_step() |
|
118 | + * |
|
119 | + * @param int $workflow_step_id ID of the step |
|
120 | + * |
|
121 | + * @return bool|Gravity_Flow_Step |
|
122 | + */ |
|
123 | + public function get_workflow_step($workflow_step_id = 0) |
|
124 | + { |
|
125 | + $form_id = GravityView_View::getInstance()->getFormId(); |
|
126 | + |
|
127 | + $GFlow = new Gravity_Flow_API($form_id); |
|
128 | + |
|
129 | + $workflow_step = $GFlow->get_step($workflow_step_id); |
|
130 | + |
|
131 | + if (!$GFlow || !$workflow_step) { |
|
132 | + return false; |
|
133 | + } |
|
134 | + |
|
135 | + return $workflow_step; |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * Set the search field choices to the Steps available for the current form. |
|
140 | + * |
|
141 | + * @since 1.17.3 |
|
142 | + * |
|
143 | + * @param array $search_fields |
|
144 | + * @param GravityView_Widget_Search $widget |
|
145 | + * @param array $widget_args |
|
146 | + * |
|
147 | + * @return array |
|
148 | + */ |
|
149 | + public function modify_frontend_search_fields($search_fields = [], GravityView_Widget_Search $widget = null, $widget_args = []) |
|
150 | + { |
|
151 | + foreach ($search_fields as &$search_field) { |
|
152 | + if ($this->name === $search_field['key']) { |
|
153 | + $form_id = GravityView_View::getInstance()->getFormId(); |
|
154 | + |
|
155 | + $workflow_steps = gravity_flow()->get_steps($form_id); |
|
156 | + |
|
157 | + $choices = []; |
|
158 | + |
|
159 | + foreach ($workflow_steps as $step) { |
|
160 | + $choices[] = [ |
|
161 | + 'text' => $step->get_name(), |
|
162 | + 'value' => $step->get_id(), |
|
163 | + ]; |
|
164 | + } |
|
165 | + |
|
166 | + $search_field['choices'] = $choices; |
|
167 | + } |
|
168 | + |
|
169 | + // Workflow Step Statuses |
|
170 | + elseif ($workflow_step_id = $this->get_step_id_from_key($search_field['key'])) { |
|
171 | + $status_key = sprintf('workflow_step_status_%d', $workflow_step_id); |
|
172 | + |
|
173 | + $search_field['choices'] = GravityView_Plugin_Hooks_Gravity_Flow::get_status_options(null, $status_key); |
|
174 | + } |
|
175 | + } |
|
176 | + |
|
177 | + return $search_fields; |
|
178 | + } |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | new GravityView_Field_Workflow_Step(); |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | public function __construct() |
16 | 16 | { |
17 | - $this->label = esc_html__('Workflow Step', 'gravityview'); |
|
17 | + $this->label = esc_html__( 'Workflow Step', 'gravityview' ); |
|
18 | 18 | $this->default_search_label = $this->label; |
19 | 19 | |
20 | 20 | $this->add_hooks(); |
@@ -24,11 +24,11 @@ discard block |
||
24 | 24 | |
25 | 25 | public function add_hooks() |
26 | 26 | { |
27 | - add_filter('gravityview_search_field_label', [$this, 'modify_gravityview_search_field_step_label'], 10, 3); |
|
27 | + add_filter( 'gravityview_search_field_label', [ $this, 'modify_gravityview_search_field_step_label' ], 10, 3 ); |
|
28 | 28 | |
29 | - add_filter('gravityview_widget_search_filters', [$this, 'modify_frontend_search_fields'], 10, 3); |
|
29 | + add_filter( 'gravityview_widget_search_filters', [ $this, 'modify_frontend_search_fields' ], 10, 3 ); |
|
30 | 30 | |
31 | - add_filter('gravityview_field_entry_value_workflow_step', [$this, 'modify_entry_value_workflow_step'], 10, 4); |
|
31 | + add_filter( 'gravityview_field_entry_value_workflow_step', [ $this, 'modify_entry_value_workflow_step' ], 10, 4 ); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -45,22 +45,22 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @return string If Gravity Flow not found, or entry not processed yet, returns initial value. Otherwise, returns name of workflow step. |
47 | 47 | */ |
48 | - public function modify_entry_value_workflow_step($output, $entry, $field_settings, $field) |
|
48 | + public function modify_entry_value_workflow_step( $output, $entry, $field_settings, $field ) |
|
49 | 49 | { |
50 | 50 | |
51 | 51 | // If not set, the entry hasn't started a workflow |
52 | - $has_workflow_step = isset($entry['workflow_step']); |
|
52 | + $has_workflow_step = isset( $entry[ 'workflow_step' ] ); |
|
53 | 53 | |
54 | - if ($has_workflow_step) { |
|
55 | - $GFlow = new Gravity_Flow_API($entry['form_id']); |
|
54 | + if ( $has_workflow_step ) { |
|
55 | + $GFlow = new Gravity_Flow_API( $entry[ 'form_id' ] ); |
|
56 | 56 | |
57 | - if ($current_step = $GFlow->get_current_step($entry)) { |
|
58 | - $output = esc_html($current_step->get_name()); |
|
57 | + if ( $current_step = $GFlow->get_current_step( $entry ) ) { |
|
58 | + $output = esc_html( $current_step->get_name() ); |
|
59 | 59 | } else { |
60 | - $output = esc_html__('Workflow Complete', 'gravityview'); |
|
60 | + $output = esc_html__( 'Workflow Complete', 'gravityview' ); |
|
61 | 61 | } |
62 | 62 | |
63 | - unset($GFlow); |
|
63 | + unset( $GFlow ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | return $output; |
@@ -73,14 +73,14 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return bool|int The ID of the workflow step. False if not a workflow step field key. |
75 | 75 | */ |
76 | - private function get_step_id_from_key($key) |
|
76 | + private function get_step_id_from_key( $key ) |
|
77 | 77 | { |
78 | 78 | $workflow_step_id = false; |
79 | 79 | |
80 | - preg_match('/workflow_step_status_(\d+)/', $key, $matches); |
|
80 | + preg_match( '/workflow_step_status_(\d+)/', $key, $matches ); |
|
81 | 81 | |
82 | - if (!empty($matches)) { |
|
83 | - $workflow_step_id = intval($matches[1]); |
|
82 | + if ( ! empty( $matches ) ) { |
|
83 | + $workflow_step_id = intval( $matches[ 1 ] ); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | return $workflow_step_id; |
@@ -95,14 +95,14 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return string If showing a search field for a Step, show the step label. |
97 | 97 | */ |
98 | - public function modify_gravityview_search_field_step_label($label = '', $gf_field = null, $field = []) |
|
98 | + public function modify_gravityview_search_field_step_label( $label = '', $gf_field = null, $field = [ ] ) |
|
99 | 99 | { |
100 | 100 | $return = $label; |
101 | 101 | |
102 | - if ('' === $label && $workflow_step_id = $this->get_step_id_from_key($field['field'])) { |
|
103 | - $step = $this->get_workflow_step($workflow_step_id); |
|
102 | + if ( '' === $label && $workflow_step_id = $this->get_step_id_from_key( $field[ 'field' ] ) ) { |
|
103 | + $step = $this->get_workflow_step( $workflow_step_id ); |
|
104 | 104 | |
105 | - $return = esc_html($step->get_label()); |
|
105 | + $return = esc_html( $step->get_label() ); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | return $return; |
@@ -120,15 +120,15 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return bool|Gravity_Flow_Step |
122 | 122 | */ |
123 | - public function get_workflow_step($workflow_step_id = 0) |
|
123 | + public function get_workflow_step( $workflow_step_id = 0 ) |
|
124 | 124 | { |
125 | 125 | $form_id = GravityView_View::getInstance()->getFormId(); |
126 | 126 | |
127 | - $GFlow = new Gravity_Flow_API($form_id); |
|
127 | + $GFlow = new Gravity_Flow_API( $form_id ); |
|
128 | 128 | |
129 | - $workflow_step = $GFlow->get_step($workflow_step_id); |
|
129 | + $workflow_step = $GFlow->get_step( $workflow_step_id ); |
|
130 | 130 | |
131 | - if (!$GFlow || !$workflow_step) { |
|
131 | + if ( ! $GFlow || ! $workflow_step ) { |
|
132 | 132 | return false; |
133 | 133 | } |
134 | 134 | |
@@ -146,31 +146,31 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return array |
148 | 148 | */ |
149 | - public function modify_frontend_search_fields($search_fields = [], GravityView_Widget_Search $widget = null, $widget_args = []) |
|
149 | + public function modify_frontend_search_fields( $search_fields = [ ], GravityView_Widget_Search $widget = null, $widget_args = [ ] ) |
|
150 | 150 | { |
151 | - foreach ($search_fields as &$search_field) { |
|
152 | - if ($this->name === $search_field['key']) { |
|
151 | + foreach ( $search_fields as &$search_field ) { |
|
152 | + if ( $this->name === $search_field[ 'key' ] ) { |
|
153 | 153 | $form_id = GravityView_View::getInstance()->getFormId(); |
154 | 154 | |
155 | - $workflow_steps = gravity_flow()->get_steps($form_id); |
|
155 | + $workflow_steps = gravity_flow()->get_steps( $form_id ); |
|
156 | 156 | |
157 | - $choices = []; |
|
157 | + $choices = [ ]; |
|
158 | 158 | |
159 | - foreach ($workflow_steps as $step) { |
|
160 | - $choices[] = [ |
|
159 | + foreach ( $workflow_steps as $step ) { |
|
160 | + $choices[ ] = [ |
|
161 | 161 | 'text' => $step->get_name(), |
162 | 162 | 'value' => $step->get_id(), |
163 | 163 | ]; |
164 | 164 | } |
165 | 165 | |
166 | - $search_field['choices'] = $choices; |
|
166 | + $search_field[ 'choices' ] = $choices; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | // Workflow Step Statuses |
170 | - elseif ($workflow_step_id = $this->get_step_id_from_key($search_field['key'])) { |
|
171 | - $status_key = sprintf('workflow_step_status_%d', $workflow_step_id); |
|
170 | + elseif ( $workflow_step_id = $this->get_step_id_from_key( $search_field[ 'key' ] ) ) { |
|
171 | + $status_key = sprintf( 'workflow_step_status_%d', $workflow_step_id ); |
|
172 | 172 | |
173 | - $search_field['choices'] = GravityView_Plugin_Hooks_Gravity_Flow::get_status_options(null, $status_key); |
|
173 | + $search_field[ 'choices' ] = GravityView_Plugin_Hooks_Gravity_Flow::get_status_options( null, $status_key ); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 |
@@ -4,16 +4,14 @@ discard block |
||
4 | 4 | * |
5 | 5 | * @since 1.17.2 |
6 | 6 | */ |
7 | -class GravityView_Field_Workflow_Step extends GravityView_Field |
|
8 | -{ |
|
7 | +class GravityView_Field_Workflow_Step extends GravityView_Field { |
|
9 | 8 | public $name = 'workflow_step'; |
10 | 9 | |
11 | 10 | public $group = 'add-ons'; |
12 | 11 | |
13 | 12 | public $icon = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMS43IDExLjIiPjxwYXRoIGQ9Ik0xNC43IDUuOWwtNy00Yy0xLjItLjctMi41LS44LTMuNy0uMy0xLjcuNy0yLjYgMS45LTIuNyAzLjYtLjEgMS41LjQgMi43IDEuNCAzLjcgMS4xIDEuMSAyLjYgMS40IDQuMy45LjIgMCAuNS0uMiAxLjEtLjQuMi0uMS4zLS4xLjQtLjEuMyAwIC41LjEuNi40LjEuMyAwIC41LS4zLjctMS4yLjctMi40LjktMy44LjgtMS4zLS4yLTIuNS0uNy0zLjQtMS42Qy41IDguNS0uMSA3LjEgMCA1LjVjLjEtMi40IDEuMi00IDMuMy01QzQuNS0uMSA1LjgtLjIgNy4yLjJjLjIuMS42LjIgMS4yLjZsNyAzLjkuNC0uNi44IDIuMS0yLjIuMy4zLS42em0tNy44LS41bDcgNGMxLjIuNyAyLjUuOCAzLjcuMyAxLjctLjcgMi42LTEuOSAyLjgtMy42LjEtMS40LS40LTIuNi0xLjUtMy43cy0yLjUtMS40LTQuMy0xYy0uNC4xLS44LjMtMS4xLjRsLS40LjFjLS4zIDAtLjUtLjEtLjYtLjQtLjEtLjMgMC0uNS4zLS43IDEuMS0uNyAyLjQtLjkgMy44LS44IDEuNC4yIDIuNS43IDMuNCAxLjcgMS4yIDEuMiAxLjcgMi41IDEuNiA0LjEtLjEgMi4zLTEuMiA0LTMuMyA1LTEuNC42LTIuNy42LTMuOS4yLS4zLS4xLS43LS4zLTEuMS0uNWwtNy0zLjktLjQuNUw1LjEgNWwyLjItLjMtLjQuN3oiLz48L3N2Zz4='; |
14 | 13 | |
15 | - public function __construct() |
|
16 | - { |
|
14 | + public function __construct() { |
|
17 | 15 | $this->label = esc_html__('Workflow Step', 'gravityview'); |
18 | 16 | $this->default_search_label = $this->label; |
19 | 17 | |
@@ -22,8 +20,7 @@ discard block |
||
22 | 20 | parent::__construct(); |
23 | 21 | } |
24 | 22 | |
25 | - public function add_hooks() |
|
26 | - { |
|
23 | + public function add_hooks() { |
|
27 | 24 | add_filter('gravityview_search_field_label', [$this, 'modify_gravityview_search_field_step_label'], 10, 3); |
28 | 25 | |
29 | 26 | add_filter('gravityview_widget_search_filters', [$this, 'modify_frontend_search_fields'], 10, 3); |
@@ -45,8 +42,7 @@ discard block |
||
45 | 42 | * |
46 | 43 | * @return string If Gravity Flow not found, or entry not processed yet, returns initial value. Otherwise, returns name of workflow step. |
47 | 44 | */ |
48 | - public function modify_entry_value_workflow_step($output, $entry, $field_settings, $field) |
|
49 | - { |
|
45 | + public function modify_entry_value_workflow_step($output, $entry, $field_settings, $field) { |
|
50 | 46 | |
51 | 47 | // If not set, the entry hasn't started a workflow |
52 | 48 | $has_workflow_step = isset($entry['workflow_step']); |
@@ -73,8 +69,7 @@ discard block |
||
73 | 69 | * |
74 | 70 | * @return bool|int The ID of the workflow step. False if not a workflow step field key. |
75 | 71 | */ |
76 | - private function get_step_id_from_key($key) |
|
77 | - { |
|
72 | + private function get_step_id_from_key($key) { |
|
78 | 73 | $workflow_step_id = false; |
79 | 74 | |
80 | 75 | preg_match('/workflow_step_status_(\d+)/', $key, $matches); |
@@ -95,8 +90,7 @@ discard block |
||
95 | 90 | * |
96 | 91 | * @return string If showing a search field for a Step, show the step label. |
97 | 92 | */ |
98 | - public function modify_gravityview_search_field_step_label($label = '', $gf_field = null, $field = []) |
|
99 | - { |
|
93 | + public function modify_gravityview_search_field_step_label($label = '', $gf_field = null, $field = []) { |
|
100 | 94 | $return = $label; |
101 | 95 | |
102 | 96 | if ('' === $label && $workflow_step_id = $this->get_step_id_from_key($field['field'])) { |
@@ -120,8 +114,7 @@ discard block |
||
120 | 114 | * |
121 | 115 | * @return bool|Gravity_Flow_Step |
122 | 116 | */ |
123 | - public function get_workflow_step($workflow_step_id = 0) |
|
124 | - { |
|
117 | + public function get_workflow_step($workflow_step_id = 0) { |
|
125 | 118 | $form_id = GravityView_View::getInstance()->getFormId(); |
126 | 119 | |
127 | 120 | $GFlow = new Gravity_Flow_API($form_id); |
@@ -146,8 +139,7 @@ discard block |
||
146 | 139 | * |
147 | 140 | * @return array |
148 | 141 | */ |
149 | - public function modify_frontend_search_fields($search_fields = [], GravityView_Widget_Search $widget = null, $widget_args = []) |
|
150 | - { |
|
142 | + public function modify_frontend_search_fields($search_fields = [], GravityView_Widget_Search $widget = null, $widget_args = []) { |
|
151 | 143 | foreach ($search_fields as &$search_field) { |
152 | 144 | if ($this->name === $search_field['key']) { |
153 | 145 | $form_id = GravityView_View::getInstance()->getFormId(); |
@@ -4,21 +4,21 @@ |
||
4 | 4 | */ |
5 | 5 | class GravityView_Field_CreditCard extends GravityView_Field |
6 | 6 | { |
7 | - public $name = 'creditcard'; |
|
7 | + public $name = 'creditcard'; |
|
8 | 8 | |
9 | - public $is_searchable = false; |
|
9 | + public $is_searchable = false; |
|
10 | 10 | |
11 | - public $_gf_field_class_name = 'GF_Field_CreditCard'; |
|
11 | + public $_gf_field_class_name = 'GF_Field_CreditCard'; |
|
12 | 12 | |
13 | - public $group = 'payment'; |
|
13 | + public $group = 'payment'; |
|
14 | 14 | |
15 | - public $icon = 'dashicons-cart'; |
|
15 | + public $icon = 'dashicons-cart'; |
|
16 | 16 | |
17 | - public function __construct() |
|
18 | - { |
|
19 | - $this->label = esc_html__('Credit Card', 'gravityview'); |
|
20 | - parent::__construct(); |
|
21 | - } |
|
17 | + public function __construct() |
|
18 | + { |
|
19 | + $this->label = esc_html__('Credit Card', 'gravityview'); |
|
20 | + parent::__construct(); |
|
21 | + } |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | new GravityView_Field_CreditCard(); |
@@ -16,7 +16,7 @@ |
||
16 | 16 | |
17 | 17 | public function __construct() |
18 | 18 | { |
19 | - $this->label = esc_html__('Credit Card', 'gravityview'); |
|
19 | + $this->label = esc_html__( 'Credit Card', 'gravityview' ); |
|
20 | 20 | parent::__construct(); |
21 | 21 | } |
22 | 22 | } |
@@ -2,8 +2,7 @@ discard block |
||
2 | 2 | /** |
3 | 3 | * @file class-gravityview-field-creditcard.php |
4 | 4 | */ |
5 | -class GravityView_Field_CreditCard extends GravityView_Field |
|
6 | -{ |
|
5 | +class GravityView_Field_CreditCard extends GravityView_Field { |
|
7 | 6 | public $name = 'creditcard'; |
8 | 7 | |
9 | 8 | public $is_searchable = false; |
@@ -14,8 +13,7 @@ discard block |
||
14 | 13 | |
15 | 14 | public $icon = 'dashicons-cart'; |
16 | 15 | |
17 | - public function __construct() |
|
18 | - { |
|
16 | + public function __construct() { |
|
19 | 17 | $this->label = esc_html__('Credit Card', 'gravityview'); |
20 | 18 | parent::__construct(); |
21 | 19 | } |