@@ -10,84 +10,84 @@ |
||
10 | 10 | */ |
11 | 11 | class EE_Select_Display_Strategy extends EE_Display_Strategy_Base |
12 | 12 | { |
13 | - /** |
|
14 | - * @return string of html to display the field |
|
15 | - * @throws EE_Error |
|
16 | - */ |
|
17 | - public function display(): string |
|
18 | - { |
|
19 | - if (! $this->_input instanceof EE_Form_Input_With_Options_Base) { |
|
20 | - throw new EE_Error( |
|
21 | - esc_html__( |
|
22 | - 'Cannot use Select Display Strategy with an input that doesn\'t have options', |
|
23 | - 'event_espresso' |
|
24 | - ) |
|
25 | - ); |
|
26 | - } |
|
13 | + /** |
|
14 | + * @return string of html to display the field |
|
15 | + * @throws EE_Error |
|
16 | + */ |
|
17 | + public function display(): string |
|
18 | + { |
|
19 | + if (! $this->_input instanceof EE_Form_Input_With_Options_Base) { |
|
20 | + throw new EE_Error( |
|
21 | + esc_html__( |
|
22 | + 'Cannot use Select Display Strategy with an input that doesn\'t have options', |
|
23 | + 'event_espresso' |
|
24 | + ) |
|
25 | + ); |
|
26 | + } |
|
27 | 27 | |
28 | - $html = EEH_HTML::nl(0, 'select'); |
|
29 | - $html .= '<select'; |
|
30 | - $html .= $this->_attributes_string( |
|
31 | - $this->_standard_attributes_array() |
|
32 | - ); |
|
33 | - $html .= $this->dataAttributesString($this->_input->dataAttributes()); |
|
34 | - $html .= '>'; |
|
28 | + $html = EEH_HTML::nl(0, 'select'); |
|
29 | + $html .= '<select'; |
|
30 | + $html .= $this->_attributes_string( |
|
31 | + $this->_standard_attributes_array() |
|
32 | + ); |
|
33 | + $html .= $this->dataAttributesString($this->_input->dataAttributes()); |
|
34 | + $html .= '>'; |
|
35 | 35 | |
36 | - if (EEH_Array::is_multi_dimensional_array($this->_input->options())) { |
|
37 | - EEH_HTML::indent(1, 'optgroup'); |
|
38 | - foreach ($this->_input->options() as $opt_group_label => $opt_group) { |
|
39 | - if (! empty($opt_group_label)) { |
|
40 | - $html .= EEH_HTML::nl(0, 'optgroup') . '<optgroup label="' . esc_attr($opt_group_label) . '">'; |
|
41 | - } |
|
42 | - EEH_HTML::indent(1, 'option'); |
|
43 | - $html .= $this->_display_options($opt_group); |
|
44 | - EEH_HTML::indent(-1, 'option'); |
|
45 | - if (! empty($opt_group_label)) { |
|
46 | - $html .= EEH_HTML::nl(0, 'optgroup') . '</optgroup>'; |
|
47 | - } |
|
48 | - } |
|
49 | - EEH_HTML::indent(-1, 'optgroup'); |
|
50 | - } else { |
|
51 | - $html .= $this->_display_options($this->_input->options()); |
|
52 | - } |
|
36 | + if (EEH_Array::is_multi_dimensional_array($this->_input->options())) { |
|
37 | + EEH_HTML::indent(1, 'optgroup'); |
|
38 | + foreach ($this->_input->options() as $opt_group_label => $opt_group) { |
|
39 | + if (! empty($opt_group_label)) { |
|
40 | + $html .= EEH_HTML::nl(0, 'optgroup') . '<optgroup label="' . esc_attr($opt_group_label) . '">'; |
|
41 | + } |
|
42 | + EEH_HTML::indent(1, 'option'); |
|
43 | + $html .= $this->_display_options($opt_group); |
|
44 | + EEH_HTML::indent(-1, 'option'); |
|
45 | + if (! empty($opt_group_label)) { |
|
46 | + $html .= EEH_HTML::nl(0, 'optgroup') . '</optgroup>'; |
|
47 | + } |
|
48 | + } |
|
49 | + EEH_HTML::indent(-1, 'optgroup'); |
|
50 | + } else { |
|
51 | + $html .= $this->_display_options($this->_input->options()); |
|
52 | + } |
|
53 | 53 | |
54 | - $html .= EEH_HTML::nl(0, 'select') . '</select>'; |
|
55 | - return $html; |
|
56 | - } |
|
54 | + $html .= EEH_HTML::nl(0, 'select') . '</select>'; |
|
55 | + return $html; |
|
56 | + } |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * Displays a flat list of options as option tags |
|
61 | - * |
|
62 | - * @param array $options |
|
63 | - * @return string |
|
64 | - */ |
|
65 | - protected function _display_options(array $options): string |
|
66 | - { |
|
67 | - $html = ''; |
|
68 | - EEH_HTML::indent(1, 'option'); |
|
69 | - foreach ($options as $value => $display_text) { |
|
70 | - // even if this input uses EE_Text_Normalization if one of the array keys is a numeric string, like "123", |
|
71 | - // PHP will have converted it to a PHP integer (eg 123). So we need to make sure it's a string |
|
72 | - $value = $this->_input->get_normalization_strategy()->unnormalize_one($value); |
|
73 | - $selected = $this->_check_if_option_selected($value) ? ' selected' : ''; |
|
74 | - $value = esc_attr($value); |
|
75 | - $html .= EEH_HTML::nl(0, 'option'); |
|
76 | - $html .= "<option value=\"$value\"$selected>$display_text</option>"; |
|
77 | - } |
|
78 | - EEH_HTML::indent(-1, 'option'); |
|
79 | - return $html; |
|
80 | - } |
|
59 | + /** |
|
60 | + * Displays a flat list of options as option tags |
|
61 | + * |
|
62 | + * @param array $options |
|
63 | + * @return string |
|
64 | + */ |
|
65 | + protected function _display_options(array $options): string |
|
66 | + { |
|
67 | + $html = ''; |
|
68 | + EEH_HTML::indent(1, 'option'); |
|
69 | + foreach ($options as $value => $display_text) { |
|
70 | + // even if this input uses EE_Text_Normalization if one of the array keys is a numeric string, like "123", |
|
71 | + // PHP will have converted it to a PHP integer (eg 123). So we need to make sure it's a string |
|
72 | + $value = $this->_input->get_normalization_strategy()->unnormalize_one($value); |
|
73 | + $selected = $this->_check_if_option_selected($value) ? ' selected' : ''; |
|
74 | + $value = esc_attr($value); |
|
75 | + $html .= EEH_HTML::nl(0, 'option'); |
|
76 | + $html .= "<option value=\"$value\"$selected>$display_text</option>"; |
|
77 | + } |
|
78 | + EEH_HTML::indent(-1, 'option'); |
|
79 | + return $html; |
|
80 | + } |
|
81 | 81 | |
82 | 82 | |
83 | - /** |
|
84 | - * Checks if that value is the one selected |
|
85 | - * |
|
86 | - * @param string|int $option_value unnormalized value option (string). How it will appear in the HTML. |
|
87 | - * @return bool |
|
88 | - */ |
|
89 | - protected function _check_if_option_selected($option_value): bool |
|
90 | - { |
|
91 | - return $option_value === $this->_input->raw_value(); |
|
92 | - } |
|
83 | + /** |
|
84 | + * Checks if that value is the one selected |
|
85 | + * |
|
86 | + * @param string|int $option_value unnormalized value option (string). How it will appear in the HTML. |
|
87 | + * @return bool |
|
88 | + */ |
|
89 | + protected function _check_if_option_selected($option_value): bool |
|
90 | + { |
|
91 | + return $option_value === $this->_input->raw_value(); |
|
92 | + } |
|
93 | 93 | } |
@@ -2,45 +2,45 @@ |
||
2 | 2 | |
3 | 3 | class EE_Text_Area_Display_Strategy extends EE_Display_Strategy_Base |
4 | 4 | { |
5 | - /** |
|
6 | - * @return string of html to display the field |
|
7 | - * @throws EE_Error |
|
8 | - */ |
|
9 | - public function display(): string |
|
10 | - { |
|
11 | - $input = $this->_input; |
|
12 | - $raw_value = maybe_serialize((string) $input->raw_value()); |
|
13 | - if ($input instanceof EE_Text_Area_Input) { |
|
14 | - $rows = $input->get_rows(); |
|
15 | - $cols = $input->get_cols(); |
|
16 | - } else { |
|
17 | - $rows = 4; |
|
18 | - $cols = 20; |
|
19 | - } |
|
20 | - $html = '<textarea'; |
|
21 | - $html .= ' id="' . $input->html_id() . '"'; |
|
22 | - $html .= ' name="' . $input->html_name() . '"'; |
|
23 | - $html .= ' class="' . $input->html_class() . '"'; |
|
24 | - $html .= ' style="' . $input->html_style() . '"'; |
|
25 | - $html .= $input->other_html_attributes(); |
|
26 | - $html .= ' rows= "' . $rows . '" cols="' . $cols . '"'; |
|
27 | - $html .= $this->dataAttributesString($this->_input->dataAttributes()); |
|
28 | - $html .= '>'; |
|
29 | - $html .= esc_textarea($raw_value); |
|
30 | - $html .= '</textarea>'; |
|
31 | - foreach ($this->_input->get_validation_strategies() as $validation_strategy) { |
|
32 | - if ( |
|
33 | - $validation_strategy instanceof EE_Simple_HTML_Validation_Strategy |
|
34 | - || $validation_strategy instanceof EE_Full_HTML_Validation_Strategy |
|
35 | - ) { |
|
36 | - $html .= sprintf( |
|
37 | - esc_html__('%1$s(allowed tags: %2$s)%3$s', 'event_espresso'), |
|
38 | - '<p class="ee-question-desc description">', |
|
39 | - $validation_strategy->get_list_of_allowed_tags(), |
|
40 | - '</p>' |
|
41 | - ); |
|
42 | - } |
|
43 | - } |
|
44 | - return $html; |
|
45 | - } |
|
5 | + /** |
|
6 | + * @return string of html to display the field |
|
7 | + * @throws EE_Error |
|
8 | + */ |
|
9 | + public function display(): string |
|
10 | + { |
|
11 | + $input = $this->_input; |
|
12 | + $raw_value = maybe_serialize((string) $input->raw_value()); |
|
13 | + if ($input instanceof EE_Text_Area_Input) { |
|
14 | + $rows = $input->get_rows(); |
|
15 | + $cols = $input->get_cols(); |
|
16 | + } else { |
|
17 | + $rows = 4; |
|
18 | + $cols = 20; |
|
19 | + } |
|
20 | + $html = '<textarea'; |
|
21 | + $html .= ' id="' . $input->html_id() . '"'; |
|
22 | + $html .= ' name="' . $input->html_name() . '"'; |
|
23 | + $html .= ' class="' . $input->html_class() . '"'; |
|
24 | + $html .= ' style="' . $input->html_style() . '"'; |
|
25 | + $html .= $input->other_html_attributes(); |
|
26 | + $html .= ' rows= "' . $rows . '" cols="' . $cols . '"'; |
|
27 | + $html .= $this->dataAttributesString($this->_input->dataAttributes()); |
|
28 | + $html .= '>'; |
|
29 | + $html .= esc_textarea($raw_value); |
|
30 | + $html .= '</textarea>'; |
|
31 | + foreach ($this->_input->get_validation_strategies() as $validation_strategy) { |
|
32 | + if ( |
|
33 | + $validation_strategy instanceof EE_Simple_HTML_Validation_Strategy |
|
34 | + || $validation_strategy instanceof EE_Full_HTML_Validation_Strategy |
|
35 | + ) { |
|
36 | + $html .= sprintf( |
|
37 | + esc_html__('%1$s(allowed tags: %2$s)%3$s', 'event_espresso'), |
|
38 | + '<p class="ee-question-desc description">', |
|
39 | + $validation_strategy->get_list_of_allowed_tags(), |
|
40 | + '</p>' |
|
41 | + ); |
|
42 | + } |
|
43 | + } |
|
44 | + return $html; |
|
45 | + } |
|
46 | 46 | } |
@@ -18,12 +18,12 @@ |
||
18 | 18 | $cols = 20; |
19 | 19 | } |
20 | 20 | $html = '<textarea'; |
21 | - $html .= ' id="' . $input->html_id() . '"'; |
|
22 | - $html .= ' name="' . $input->html_name() . '"'; |
|
23 | - $html .= ' class="' . $input->html_class() . '"'; |
|
24 | - $html .= ' style="' . $input->html_style() . '"'; |
|
21 | + $html .= ' id="'.$input->html_id().'"'; |
|
22 | + $html .= ' name="'.$input->html_name().'"'; |
|
23 | + $html .= ' class="'.$input->html_class().'"'; |
|
24 | + $html .= ' style="'.$input->html_style().'"'; |
|
25 | 25 | $html .= $input->other_html_attributes(); |
26 | - $html .= ' rows= "' . $rows . '" cols="' . $cols . '"'; |
|
26 | + $html .= ' rows= "'.$rows.'" cols="'.$cols.'"'; |
|
27 | 27 | $html .= $this->dataAttributesString($this->_input->dataAttributes()); |
28 | 28 | $html .= '>'; |
29 | 29 | $html .= esc_textarea($raw_value); |
@@ -10,100 +10,100 @@ |
||
10 | 10 | */ |
11 | 11 | class EE_Admin_File_Uploader_Display_Strategy extends EE_Display_Strategy_Base |
12 | 12 | { |
13 | - /** |
|
14 | - * Its important this media only get enqueued AFTER init, but before the footer... where the |
|
15 | - * rest of our forms JS gets enqueued. Otherwise the JS gets enqueued fine, and loaded on the page fine, |
|
16 | - * but when you upload an image it gets uploaded fine to the server, but it doesn't display and reports an error |
|
17 | - * (also it doesn't show any of the currently existing media in the modal window that pops up when you click the |
|
18 | - * button to select media). Besides that, no special consideration should be required to make the media uploader |
|
19 | - * appear, besides having this input displayed. |
|
20 | - * |
|
21 | - * @deprecated. enqueue_js should be called automatically now |
|
22 | - */ |
|
23 | - public static function enqueue_scripts() |
|
24 | - { |
|
25 | - EE_Error::doing_it_wrong( |
|
26 | - __FUNCTION__, |
|
27 | - esc_html__( |
|
28 | - 'EE_Admin_File_Uploader_Display_Strategy::enqueue_scripts() no longer needs to be called in order to display the admin uploader input correctly. This is handled now by EE_Admin_File_Uploader_Display_Strategy::enqueue_js() which is called automatically when enqueueing JS and CSS for the form', |
|
29 | - 'event_espresso' |
|
30 | - ), |
|
31 | - '4.9.8.rc.015' |
|
32 | - ); |
|
33 | - wp_enqueue_media(); |
|
34 | - wp_enqueue_script('media-upload'); |
|
35 | - wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL . 'scripts/ee-media-uploader.js'); |
|
36 | - } |
|
13 | + /** |
|
14 | + * Its important this media only get enqueued AFTER init, but before the footer... where the |
|
15 | + * rest of our forms JS gets enqueued. Otherwise the JS gets enqueued fine, and loaded on the page fine, |
|
16 | + * but when you upload an image it gets uploaded fine to the server, but it doesn't display and reports an error |
|
17 | + * (also it doesn't show any of the currently existing media in the modal window that pops up when you click the |
|
18 | + * button to select media). Besides that, no special consideration should be required to make the media uploader |
|
19 | + * appear, besides having this input displayed. |
|
20 | + * |
|
21 | + * @deprecated. enqueue_js should be called automatically now |
|
22 | + */ |
|
23 | + public static function enqueue_scripts() |
|
24 | + { |
|
25 | + EE_Error::doing_it_wrong( |
|
26 | + __FUNCTION__, |
|
27 | + esc_html__( |
|
28 | + 'EE_Admin_File_Uploader_Display_Strategy::enqueue_scripts() no longer needs to be called in order to display the admin uploader input correctly. This is handled now by EE_Admin_File_Uploader_Display_Strategy::enqueue_js() which is called automatically when enqueueing JS and CSS for the form', |
|
29 | + 'event_espresso' |
|
30 | + ), |
|
31 | + '4.9.8.rc.015' |
|
32 | + ); |
|
33 | + wp_enqueue_media(); |
|
34 | + wp_enqueue_script('media-upload'); |
|
35 | + wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL . 'scripts/ee-media-uploader.js'); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Enqueues the JS and CSS needed to display this input |
|
41 | - */ |
|
42 | - public function enqueue_js() |
|
43 | - { |
|
44 | - wp_enqueue_media(); |
|
45 | - wp_enqueue_script('media-upload'); |
|
46 | - wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL . 'scripts/ee-media-uploader.js'); |
|
47 | - parent::enqueue_js(); |
|
48 | - } |
|
39 | + /** |
|
40 | + * Enqueues the JS and CSS needed to display this input |
|
41 | + */ |
|
42 | + public function enqueue_js() |
|
43 | + { |
|
44 | + wp_enqueue_media(); |
|
45 | + wp_enqueue_script('media-upload'); |
|
46 | + wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL . 'scripts/ee-media-uploader.js'); |
|
47 | + parent::enqueue_js(); |
|
48 | + } |
|
49 | 49 | |
50 | 50 | |
51 | - /** |
|
52 | - * @return string of html to display the field |
|
53 | - * @throws EE_Error |
|
54 | - */ |
|
51 | + /** |
|
52 | + * @return string of html to display the field |
|
53 | + * @throws EE_Error |
|
54 | + */ |
|
55 | 55 | |
56 | - public function display(): string |
|
57 | - { |
|
58 | - // the actual input |
|
59 | - $input = '<input type="text" size="34" '; |
|
60 | - $input .= 'name="' . $this->_input->html_name() . '" '; |
|
61 | - $input .= $this->_input->html_class() !== '' |
|
62 | - ? 'class="large-text ee_media_url ' . $this->_input->html_class() . '" ' |
|
63 | - : 'class="large-text ee_media_url" '; |
|
64 | - $input .= 'value="' . $this->_input->raw_value_in_form() . '" '; |
|
65 | - $input .= $this->_input->other_html_attributes(); |
|
66 | - $input .= $this->dataAttributesString($this->_input->dataAttributes()); |
|
67 | - $input .= '>'; |
|
68 | - // image uploader |
|
69 | - $uploader = EEH_HTML::link( |
|
70 | - '#', |
|
71 | - '<span class="dashicons dashicons-format-image"></span>', |
|
72 | - esc_html__('click to add an image', 'event_espresso'), |
|
73 | - '', |
|
74 | - 'ee_media_upload button button--secondary button--icon-only' |
|
75 | - ); |
|
76 | - // only attempt to show the image if it at least exists |
|
77 | - $image = $this->_input->raw_value() && $this->src_exists($this->_input->raw_value()) |
|
78 | - ? EEH_HTML::br() . EEH_HTML::img( |
|
79 | - $this->_input->raw_value(), |
|
80 | - esc_html__('logo', 'event_espresso'), |
|
81 | - '', |
|
82 | - 'ee_media_image' |
|
83 | - ) |
|
84 | - : ''; |
|
85 | - // html string |
|
86 | - return EEH_HTML::div( |
|
87 | - $input . $uploader, |
|
88 | - '', |
|
89 | - 'ee_media_uploader_area' |
|
90 | - ) . $image; |
|
91 | - } |
|
56 | + public function display(): string |
|
57 | + { |
|
58 | + // the actual input |
|
59 | + $input = '<input type="text" size="34" '; |
|
60 | + $input .= 'name="' . $this->_input->html_name() . '" '; |
|
61 | + $input .= $this->_input->html_class() !== '' |
|
62 | + ? 'class="large-text ee_media_url ' . $this->_input->html_class() . '" ' |
|
63 | + : 'class="large-text ee_media_url" '; |
|
64 | + $input .= 'value="' . $this->_input->raw_value_in_form() . '" '; |
|
65 | + $input .= $this->_input->other_html_attributes(); |
|
66 | + $input .= $this->dataAttributesString($this->_input->dataAttributes()); |
|
67 | + $input .= '>'; |
|
68 | + // image uploader |
|
69 | + $uploader = EEH_HTML::link( |
|
70 | + '#', |
|
71 | + '<span class="dashicons dashicons-format-image"></span>', |
|
72 | + esc_html__('click to add an image', 'event_espresso'), |
|
73 | + '', |
|
74 | + 'ee_media_upload button button--secondary button--icon-only' |
|
75 | + ); |
|
76 | + // only attempt to show the image if it at least exists |
|
77 | + $image = $this->_input->raw_value() && $this->src_exists($this->_input->raw_value()) |
|
78 | + ? EEH_HTML::br() . EEH_HTML::img( |
|
79 | + $this->_input->raw_value(), |
|
80 | + esc_html__('logo', 'event_espresso'), |
|
81 | + '', |
|
82 | + 'ee_media_image' |
|
83 | + ) |
|
84 | + : ''; |
|
85 | + // html string |
|
86 | + return EEH_HTML::div( |
|
87 | + $input . $uploader, |
|
88 | + '', |
|
89 | + 'ee_media_uploader_area' |
|
90 | + ) . $image; |
|
91 | + } |
|
92 | 92 | |
93 | 93 | |
94 | - /** |
|
95 | - * Asserts an image actually exists as quickly as possible by sending a HEAD |
|
96 | - * request |
|
97 | - * |
|
98 | - * @param string $src |
|
99 | - * @return boolean |
|
100 | - */ |
|
101 | - protected function src_exists(string $src): bool |
|
102 | - { |
|
103 | - $results = wp_remote_head($src); |
|
104 | - if (is_array($results) && ! $results instanceof WP_Error) { |
|
105 | - return strpos($results['headers']['content-type'], "image") !== false; |
|
106 | - } |
|
107 | - return false; |
|
108 | - } |
|
94 | + /** |
|
95 | + * Asserts an image actually exists as quickly as possible by sending a HEAD |
|
96 | + * request |
|
97 | + * |
|
98 | + * @param string $src |
|
99 | + * @return boolean |
|
100 | + */ |
|
101 | + protected function src_exists(string $src): bool |
|
102 | + { |
|
103 | + $results = wp_remote_head($src); |
|
104 | + if (is_array($results) && ! $results instanceof WP_Error) { |
|
105 | + return strpos($results['headers']['content-type'], "image") !== false; |
|
106 | + } |
|
107 | + return false; |
|
108 | + } |
|
109 | 109 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | ); |
33 | 33 | wp_enqueue_media(); |
34 | 34 | wp_enqueue_script('media-upload'); |
35 | - wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL . 'scripts/ee-media-uploader.js'); |
|
35 | + wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL.'scripts/ee-media-uploader.js'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | { |
44 | 44 | wp_enqueue_media(); |
45 | 45 | wp_enqueue_script('media-upload'); |
46 | - wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL . 'scripts/ee-media-uploader.js'); |
|
46 | + wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL.'scripts/ee-media-uploader.js'); |
|
47 | 47 | parent::enqueue_js(); |
48 | 48 | } |
49 | 49 | |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | { |
58 | 58 | // the actual input |
59 | 59 | $input = '<input type="text" size="34" '; |
60 | - $input .= 'name="' . $this->_input->html_name() . '" '; |
|
60 | + $input .= 'name="'.$this->_input->html_name().'" '; |
|
61 | 61 | $input .= $this->_input->html_class() !== '' |
62 | - ? 'class="large-text ee_media_url ' . $this->_input->html_class() . '" ' |
|
62 | + ? 'class="large-text ee_media_url '.$this->_input->html_class().'" ' |
|
63 | 63 | : 'class="large-text ee_media_url" '; |
64 | - $input .= 'value="' . $this->_input->raw_value_in_form() . '" '; |
|
64 | + $input .= 'value="'.$this->_input->raw_value_in_form().'" '; |
|
65 | 65 | $input .= $this->_input->other_html_attributes(); |
66 | 66 | $input .= $this->dataAttributesString($this->_input->dataAttributes()); |
67 | 67 | $input .= '>'; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | ); |
76 | 76 | // only attempt to show the image if it at least exists |
77 | 77 | $image = $this->_input->raw_value() && $this->src_exists($this->_input->raw_value()) |
78 | - ? EEH_HTML::br() . EEH_HTML::img( |
|
78 | + ? EEH_HTML::br().EEH_HTML::img( |
|
79 | 79 | $this->_input->raw_value(), |
80 | 80 | esc_html__('logo', 'event_espresso'), |
81 | 81 | '', |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | : ''; |
85 | 85 | // html string |
86 | 86 | return EEH_HTML::div( |
87 | - $input . $uploader, |
|
87 | + $input.$uploader, |
|
88 | 88 | '', |
89 | 89 | 'ee_media_uploader_area' |
90 | - ) . $image; |
|
90 | + ).$image; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 |
@@ -9,32 +9,32 @@ |
||
9 | 9 | */ |
10 | 10 | class EE_Button_Display_Strategy extends EE_Display_Strategy_Base |
11 | 11 | { |
12 | - /** |
|
13 | - * @return string of html to display the input |
|
14 | - * @throws EE_Error |
|
15 | - */ |
|
16 | - public function display(): string |
|
17 | - { |
|
18 | - $default_value = $this->_input->get_default(); |
|
19 | - if ($this->_input->get_normalization_strategy() instanceof EE_Normalization_Strategy_Base) { |
|
20 | - $default_value = $this->_input->get_normalization_strategy()->unnormalize($default_value); |
|
21 | - } |
|
22 | - $html = $this->_opening_tag('button'); |
|
23 | - $html .= $this->_attributes_string( |
|
24 | - array_merge( |
|
25 | - $this->_standard_attributes_array(), |
|
26 | - array( |
|
27 | - 'value' => $default_value, |
|
28 | - ) |
|
29 | - ) |
|
30 | - ); |
|
31 | - $html .= $this->dataAttributesString($this->_input->dataAttributes()); |
|
32 | - $html .= '>'; |
|
33 | - $button_content = $this->_input instanceof EE_Button_Input |
|
34 | - ? $this->_input->button_content() |
|
35 | - : $this->_input->get_default(); |
|
36 | - $html .= $button_content; |
|
37 | - $html .= $this->_closing_tag(); |
|
38 | - return $html; |
|
39 | - } |
|
12 | + /** |
|
13 | + * @return string of html to display the input |
|
14 | + * @throws EE_Error |
|
15 | + */ |
|
16 | + public function display(): string |
|
17 | + { |
|
18 | + $default_value = $this->_input->get_default(); |
|
19 | + if ($this->_input->get_normalization_strategy() instanceof EE_Normalization_Strategy_Base) { |
|
20 | + $default_value = $this->_input->get_normalization_strategy()->unnormalize($default_value); |
|
21 | + } |
|
22 | + $html = $this->_opening_tag('button'); |
|
23 | + $html .= $this->_attributes_string( |
|
24 | + array_merge( |
|
25 | + $this->_standard_attributes_array(), |
|
26 | + array( |
|
27 | + 'value' => $default_value, |
|
28 | + ) |
|
29 | + ) |
|
30 | + ); |
|
31 | + $html .= $this->dataAttributesString($this->_input->dataAttributes()); |
|
32 | + $html .= '>'; |
|
33 | + $button_content = $this->_input instanceof EE_Button_Input |
|
34 | + ? $this->_input->button_content() |
|
35 | + : $this->_input->get_default(); |
|
36 | + $html .= $button_content; |
|
37 | + $html .= $this->_closing_tag(); |
|
38 | + return $html; |
|
39 | + } |
|
40 | 40 | } |
@@ -10,115 +10,115 @@ |
||
10 | 10 | */ |
11 | 11 | class EE_Number_Input_Display_Strategy extends EE_Display_Strategy_Base |
12 | 12 | { |
13 | - /** |
|
14 | - * minimum value for number field |
|
15 | - * |
|
16 | - * @var int|null $min |
|
17 | - */ |
|
18 | - protected $min; |
|
13 | + /** |
|
14 | + * minimum value for number field |
|
15 | + * |
|
16 | + * @var int|null $min |
|
17 | + */ |
|
18 | + protected $min; |
|
19 | 19 | |
20 | - /** |
|
21 | - * maximum value for number field |
|
22 | - * |
|
23 | - * @var int|null $max |
|
24 | - */ |
|
25 | - protected $max; |
|
20 | + /** |
|
21 | + * maximum value for number field |
|
22 | + * |
|
23 | + * @var int|null $max |
|
24 | + */ |
|
25 | + protected $max; |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * This is used to set the "step" attribute for the html5 number input. |
|
30 | - * Controls the increments on the input when incrementing or decrementing the value. |
|
31 | - * Note: Although the step attribute allows for the string "any" to be used, Firefox and Chrome will interpret that |
|
32 | - * to increment by 1. So although "any" is accepted as a value, it is converted to 1. |
|
33 | - * |
|
34 | - * @var float |
|
35 | - */ |
|
36 | - protected $step; |
|
28 | + /** |
|
29 | + * This is used to set the "step" attribute for the html5 number input. |
|
30 | + * Controls the increments on the input when incrementing or decrementing the value. |
|
31 | + * Note: Although the step attribute allows for the string "any" to be used, Firefox and Chrome will interpret that |
|
32 | + * to increment by 1. So although "any" is accepted as a value, it is converted to 1. |
|
33 | + * |
|
34 | + * @var float |
|
35 | + */ |
|
36 | + protected $step; |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * EE_Number_Input_Display_Strategy constructor. |
|
41 | - * Null is the default value for the incoming arguments because 0 is a valid value. So we use null |
|
42 | - * to indicate NOT setting this attribute. |
|
43 | - * |
|
44 | - * @param int|float|null $min |
|
45 | - * @param int|float|null $max |
|
46 | - * @param int|string|null $step |
|
47 | - * @throws InvalidArgumentException |
|
48 | - */ |
|
49 | - public function __construct($min = null, $max = null, $step = null) |
|
50 | - { |
|
51 | - parent::__construct(); |
|
52 | - $this->min = is_numeric($min) || $min === null |
|
53 | - ? $min |
|
54 | - : $this->throwValidationException('min', $min); |
|
55 | - $this->max = is_numeric($max) || $max === null |
|
56 | - ? $max |
|
57 | - : $this->throwValidationException('max', $max); |
|
58 | - $step = $step === 'any' |
|
59 | - ? 1 |
|
60 | - : $step; |
|
61 | - $this->step = is_numeric($step) || $step === null |
|
62 | - ? $step |
|
63 | - : $this->throwValidationException('step', $step); |
|
64 | - } |
|
39 | + /** |
|
40 | + * EE_Number_Input_Display_Strategy constructor. |
|
41 | + * Null is the default value for the incoming arguments because 0 is a valid value. So we use null |
|
42 | + * to indicate NOT setting this attribute. |
|
43 | + * |
|
44 | + * @param int|float|null $min |
|
45 | + * @param int|float|null $max |
|
46 | + * @param int|string|null $step |
|
47 | + * @throws InvalidArgumentException |
|
48 | + */ |
|
49 | + public function __construct($min = null, $max = null, $step = null) |
|
50 | + { |
|
51 | + parent::__construct(); |
|
52 | + $this->min = is_numeric($min) || $min === null |
|
53 | + ? $min |
|
54 | + : $this->throwValidationException('min', $min); |
|
55 | + $this->max = is_numeric($max) || $max === null |
|
56 | + ? $max |
|
57 | + : $this->throwValidationException('max', $max); |
|
58 | + $step = $step === 'any' |
|
59 | + ? 1 |
|
60 | + : $step; |
|
61 | + $this->step = is_numeric($step) || $step === null |
|
62 | + ? $step |
|
63 | + : $this->throwValidationException('step', $step); |
|
64 | + } |
|
65 | 65 | |
66 | 66 | |
67 | - private function throwValidationException($argument_label, $argument_value) |
|
68 | - { |
|
69 | - throw new InvalidArgumentException( |
|
70 | - sprintf( |
|
71 | - esc_html__( |
|
72 | - 'The %1$s parameter value for %2$s must be numeric or null, %3$s was passed into the constructor.', |
|
73 | - 'event_espresso' |
|
74 | - ), |
|
75 | - $argument_label, |
|
76 | - __CLASS__, |
|
77 | - $argument_value |
|
78 | - ) |
|
79 | - ); |
|
80 | - } |
|
67 | + private function throwValidationException($argument_label, $argument_value) |
|
68 | + { |
|
69 | + throw new InvalidArgumentException( |
|
70 | + sprintf( |
|
71 | + esc_html__( |
|
72 | + 'The %1$s parameter value for %2$s must be numeric or null, %3$s was passed into the constructor.', |
|
73 | + 'event_espresso' |
|
74 | + ), |
|
75 | + $argument_label, |
|
76 | + __CLASS__, |
|
77 | + $argument_value |
|
78 | + ) |
|
79 | + ); |
|
80 | + } |
|
81 | 81 | |
82 | 82 | |
83 | - /** |
|
84 | - * @return string of html to display the field |
|
85 | - * @throws EE_Error |
|
86 | - */ |
|
87 | - public function display(): string |
|
88 | - { |
|
89 | - $input = $this->_opening_tag('input'); |
|
90 | - $input .= $this->_attributes_string( |
|
91 | - array_merge( |
|
92 | - $this->_standard_attributes_array(), |
|
93 | - $this->getNumberInputAttributes() |
|
94 | - ) |
|
95 | - ); |
|
96 | - $input .= $this->dataAttributesString($this->_input->dataAttributes()); |
|
97 | - $input .= $this->_close_tag(); |
|
98 | - return $input; |
|
99 | - } |
|
83 | + /** |
|
84 | + * @return string of html to display the field |
|
85 | + * @throws EE_Error |
|
86 | + */ |
|
87 | + public function display(): string |
|
88 | + { |
|
89 | + $input = $this->_opening_tag('input'); |
|
90 | + $input .= $this->_attributes_string( |
|
91 | + array_merge( |
|
92 | + $this->_standard_attributes_array(), |
|
93 | + $this->getNumberInputAttributes() |
|
94 | + ) |
|
95 | + ); |
|
96 | + $input .= $this->dataAttributesString($this->_input->dataAttributes()); |
|
97 | + $input .= $this->_close_tag(); |
|
98 | + return $input; |
|
99 | + } |
|
100 | 100 | |
101 | 101 | |
102 | - /** |
|
103 | - * Return the attributes specific to this display strategy |
|
104 | - * |
|
105 | - * @return array |
|
106 | - */ |
|
107 | - private function getNumberInputAttributes(): array |
|
108 | - { |
|
109 | - $attributes = [ |
|
110 | - 'type' => 'number', |
|
111 | - 'value' => $this->_input->raw_value_in_form(), |
|
112 | - ]; |
|
113 | - if ($this->min !== null) { |
|
114 | - $attributes['min'] = $this->min; |
|
115 | - } |
|
116 | - if ($this->max !== null) { |
|
117 | - $attributes['max'] = $this->max; |
|
118 | - } |
|
119 | - if ($this->step !== null) { |
|
120 | - $attributes['step'] = $this->step; |
|
121 | - } |
|
122 | - return $attributes; |
|
123 | - } |
|
102 | + /** |
|
103 | + * Return the attributes specific to this display strategy |
|
104 | + * |
|
105 | + * @return array |
|
106 | + */ |
|
107 | + private function getNumberInputAttributes(): array |
|
108 | + { |
|
109 | + $attributes = [ |
|
110 | + 'type' => 'number', |
|
111 | + 'value' => $this->_input->raw_value_in_form(), |
|
112 | + ]; |
|
113 | + if ($this->min !== null) { |
|
114 | + $attributes['min'] = $this->min; |
|
115 | + } |
|
116 | + if ($this->max !== null) { |
|
117 | + $attributes['max'] = $this->max; |
|
118 | + } |
|
119 | + if ($this->step !== null) { |
|
120 | + $attributes['step'] = $this->step; |
|
121 | + } |
|
122 | + return $attributes; |
|
123 | + } |
|
124 | 124 | } |
@@ -13,62 +13,62 @@ |
||
13 | 13 | */ |
14 | 14 | class EE_Full_HTML_Validation_Strategy extends EE_Validation_Strategy_Base |
15 | 15 | { |
16 | - /** |
|
17 | - * @param null $validation_error_message |
|
18 | - */ |
|
19 | - public function __construct($validation_error_message = null) |
|
20 | - { |
|
21 | - if (! $validation_error_message) { |
|
22 | - $validation_error_message = sprintf( |
|
23 | - esc_html__('Only the following HTML tags are allowed:%1$s%2$s', "event_espresso"), |
|
24 | - '<br />', |
|
25 | - $this->get_list_of_allowed_tags() |
|
26 | - ); |
|
27 | - } |
|
28 | - parent::__construct($validation_error_message); |
|
29 | - } |
|
16 | + /** |
|
17 | + * @param null $validation_error_message |
|
18 | + */ |
|
19 | + public function __construct($validation_error_message = null) |
|
20 | + { |
|
21 | + if (! $validation_error_message) { |
|
22 | + $validation_error_message = sprintf( |
|
23 | + esc_html__('Only the following HTML tags are allowed:%1$s%2$s', "event_espresso"), |
|
24 | + '<br />', |
|
25 | + $this->get_list_of_allowed_tags() |
|
26 | + ); |
|
27 | + } |
|
28 | + parent::__construct($validation_error_message); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * get_list_of_allowed_tags |
|
34 | - * |
|
35 | - * generates and returns a string that lists the top-level HTML tags that are allowable for this input |
|
36 | - * |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - public function get_list_of_allowed_tags(): string |
|
40 | - { |
|
41 | - $tags_we_allow = $this->getAllowedTags(); |
|
42 | - ksort($tags_we_allow); |
|
43 | - return implode(', ', array_keys($tags_we_allow)); |
|
44 | - } |
|
32 | + /** |
|
33 | + * get_list_of_allowed_tags |
|
34 | + * |
|
35 | + * generates and returns a string that lists the top-level HTML tags that are allowable for this input |
|
36 | + * |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + public function get_list_of_allowed_tags(): string |
|
40 | + { |
|
41 | + $tags_we_allow = $this->getAllowedTags(); |
|
42 | + ksort($tags_we_allow); |
|
43 | + return implode(', ', array_keys($tags_we_allow)); |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * Returns an array whose keys are allowed tags and values are an array of allowed attributes |
|
49 | - * |
|
50 | - * @return array |
|
51 | - */ |
|
52 | - protected function getAllowedTags(): array |
|
53 | - { |
|
54 | - global $allowedposttags; |
|
55 | - return array_merge_recursive( |
|
56 | - $allowedposttags, |
|
57 | - EEH_HTML::get_simple_tags() |
|
58 | - ); |
|
59 | - } |
|
47 | + /** |
|
48 | + * Returns an array whose keys are allowed tags and values are an array of allowed attributes |
|
49 | + * |
|
50 | + * @return array |
|
51 | + */ |
|
52 | + protected function getAllowedTags(): array |
|
53 | + { |
|
54 | + global $allowedposttags; |
|
55 | + return array_merge_recursive( |
|
56 | + $allowedposttags, |
|
57 | + EEH_HTML::get_simple_tags() |
|
58 | + ); |
|
59 | + } |
|
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * @param mixed $normalized_value |
|
64 | - * @throws EE_Validation_Error |
|
65 | - */ |
|
66 | - public function validate($normalized_value) |
|
67 | - { |
|
68 | - parent::validate($normalized_value); |
|
69 | - $normalized_value_sans_tags = wp_kses((string) $normalized_value, $this->getAllowedTags()); |
|
70 | - if (strlen((string) $normalized_value) > strlen($normalized_value_sans_tags)) { |
|
71 | - throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags'); |
|
72 | - } |
|
73 | - } |
|
62 | + /** |
|
63 | + * @param mixed $normalized_value |
|
64 | + * @throws EE_Validation_Error |
|
65 | + */ |
|
66 | + public function validate($normalized_value) |
|
67 | + { |
|
68 | + parent::validate($normalized_value); |
|
69 | + $normalized_value_sans_tags = wp_kses((string) $normalized_value, $this->getAllowedTags()); |
|
70 | + if (strlen((string) $normalized_value) > strlen($normalized_value_sans_tags)) { |
|
71 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags'); |
|
72 | + } |
|
73 | + } |
|
74 | 74 | } |
@@ -14,81 +14,81 @@ |
||
14 | 14 | */ |
15 | 15 | class EE_URL_Validation_Strategy extends EE_Validation_Strategy_Base |
16 | 16 | { |
17 | - /** |
|
18 | - * @var bool whether we should check if the file exists or not |
|
19 | - */ |
|
20 | - protected bool $check_file_exists; |
|
17 | + /** |
|
18 | + * @var bool whether we should check if the file exists or not |
|
19 | + */ |
|
20 | + protected bool $check_file_exists; |
|
21 | 21 | |
22 | - protected URLValidator $url_validator; |
|
22 | + protected URLValidator $url_validator; |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * @param string|null $validation_error_message |
|
27 | - * @param bool $check_file_exists |
|
28 | - * @param URLValidator|null $url_validator |
|
29 | - */ |
|
30 | - public function __construct( |
|
31 | - ?string $validation_error_message = '', |
|
32 | - bool $check_file_exists = false, |
|
33 | - ?URLValidator $url_validator = null |
|
34 | - ) { |
|
35 | - $this->check_file_exists = $check_file_exists; |
|
36 | - if (! $url_validator instanceof URLValidator) { |
|
37 | - $url_validator = LoaderFactory::getLoader()->getShared(URLValidator::class); |
|
38 | - } |
|
39 | - $this->url_validator = $url_validator; |
|
40 | - if (! $validation_error_message) { |
|
41 | - $validation_error_message = esc_html__( |
|
42 | - 'Please enter a valid URL. Eg https://eventespresso.com', |
|
43 | - 'event_espresso' |
|
44 | - ); |
|
45 | - } |
|
46 | - parent::__construct($validation_error_message); |
|
47 | - } |
|
25 | + /** |
|
26 | + * @param string|null $validation_error_message |
|
27 | + * @param bool $check_file_exists |
|
28 | + * @param URLValidator|null $url_validator |
|
29 | + */ |
|
30 | + public function __construct( |
|
31 | + ?string $validation_error_message = '', |
|
32 | + bool $check_file_exists = false, |
|
33 | + ?URLValidator $url_validator = null |
|
34 | + ) { |
|
35 | + $this->check_file_exists = $check_file_exists; |
|
36 | + if (! $url_validator instanceof URLValidator) { |
|
37 | + $url_validator = LoaderFactory::getLoader()->getShared(URLValidator::class); |
|
38 | + } |
|
39 | + $this->url_validator = $url_validator; |
|
40 | + if (! $validation_error_message) { |
|
41 | + $validation_error_message = esc_html__( |
|
42 | + 'Please enter a valid URL. Eg https://eventespresso.com', |
|
43 | + 'event_espresso' |
|
44 | + ); |
|
45 | + } |
|
46 | + parent::__construct($validation_error_message); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * just checks the field isn't blank |
|
52 | - * |
|
53 | - * @param $normalized_value |
|
54 | - * @return void |
|
55 | - * @throws EE_Validation_Error |
|
56 | - */ |
|
57 | - public function validate($normalized_value) |
|
58 | - { |
|
59 | - if ($normalized_value) { |
|
60 | - if (! $this->url_validator->isValid($normalized_value)) { |
|
61 | - throw new EE_Validation_Error($this->get_validation_error_message(), 'invalid_url'); |
|
62 | - } |
|
63 | - if ( |
|
64 | - apply_filters( |
|
65 | - 'FHEE__EE_URL_Validation_Strategy__validate__check_remote_file_exists', |
|
66 | - $this->check_file_exists, |
|
67 | - $this->_input |
|
68 | - ) |
|
69 | - ) { |
|
70 | - if ( |
|
71 | - ! EEH_URL::remote_file_exists( |
|
72 | - $normalized_value, |
|
73 | - [ |
|
74 | - 'sslverify' => Manager::verifySSL(), |
|
75 | - 'limit_response_size' => 4095, |
|
76 | - // we don't really care for a full response, but we do want headers at least. |
|
77 | - // Let's just ask for a one block |
|
78 | - ] |
|
79 | - ) |
|
80 | - ) { |
|
81 | - throw new EE_Validation_Error( |
|
82 | - esc_html__("That URL seems to be broken. Please enter a valid URL", "event_espresso") |
|
83 | - ); |
|
84 | - } |
|
85 | - } |
|
86 | - } |
|
87 | - } |
|
50 | + /** |
|
51 | + * just checks the field isn't blank |
|
52 | + * |
|
53 | + * @param $normalized_value |
|
54 | + * @return void |
|
55 | + * @throws EE_Validation_Error |
|
56 | + */ |
|
57 | + public function validate($normalized_value) |
|
58 | + { |
|
59 | + if ($normalized_value) { |
|
60 | + if (! $this->url_validator->isValid($normalized_value)) { |
|
61 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'invalid_url'); |
|
62 | + } |
|
63 | + if ( |
|
64 | + apply_filters( |
|
65 | + 'FHEE__EE_URL_Validation_Strategy__validate__check_remote_file_exists', |
|
66 | + $this->check_file_exists, |
|
67 | + $this->_input |
|
68 | + ) |
|
69 | + ) { |
|
70 | + if ( |
|
71 | + ! EEH_URL::remote_file_exists( |
|
72 | + $normalized_value, |
|
73 | + [ |
|
74 | + 'sslverify' => Manager::verifySSL(), |
|
75 | + 'limit_response_size' => 4095, |
|
76 | + // we don't really care for a full response, but we do want headers at least. |
|
77 | + // Let's just ask for a one block |
|
78 | + ] |
|
79 | + ) |
|
80 | + ) { |
|
81 | + throw new EE_Validation_Error( |
|
82 | + esc_html__("That URL seems to be broken. Please enter a valid URL", "event_espresso") |
|
83 | + ); |
|
84 | + } |
|
85 | + } |
|
86 | + } |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | - public function get_jquery_validation_rule_array(): array |
|
91 | - { |
|
92 | - return ['validUrl' => true, 'messages' => ['validUrl' => $this->get_validation_error_message()]]; |
|
93 | - } |
|
90 | + public function get_jquery_validation_rule_array(): array |
|
91 | + { |
|
92 | + return ['validUrl' => true, 'messages' => ['validUrl' => $this->get_validation_error_message()]]; |
|
93 | + } |
|
94 | 94 | } |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | ?URLValidator $url_validator = null |
34 | 34 | ) { |
35 | 35 | $this->check_file_exists = $check_file_exists; |
36 | - if (! $url_validator instanceof URLValidator) { |
|
36 | + if ( ! $url_validator instanceof URLValidator) { |
|
37 | 37 | $url_validator = LoaderFactory::getLoader()->getShared(URLValidator::class); |
38 | 38 | } |
39 | 39 | $this->url_validator = $url_validator; |
40 | - if (! $validation_error_message) { |
|
40 | + if ( ! $validation_error_message) { |
|
41 | 41 | $validation_error_message = esc_html__( |
42 | 42 | 'Please enter a valid URL. Eg https://eventespresso.com', |
43 | 43 | 'event_espresso' |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | public function validate($normalized_value) |
58 | 58 | { |
59 | 59 | if ($normalized_value) { |
60 | - if (! $this->url_validator->isValid($normalized_value)) { |
|
60 | + if ( ! $this->url_validator->isValid($normalized_value)) { |
|
61 | 61 | throw new EE_Validation_Error($this->get_validation_error_message(), 'invalid_url'); |
62 | 62 | } |
63 | 63 | if ( |
@@ -13,58 +13,58 @@ |
||
13 | 13 | */ |
14 | 14 | class EE_Simple_HTML_Validation_Strategy extends EE_Validation_Strategy_Base |
15 | 15 | { |
16 | - /** |
|
17 | - * @param null $validation_error_message |
|
18 | - */ |
|
19 | - public function __construct($validation_error_message = null) |
|
20 | - { |
|
21 | - if (! $validation_error_message) { |
|
22 | - $allowedtags = $this->_get_allowed_tags(); |
|
23 | - $validation_error_message = |
|
24 | - sprintf( |
|
25 | - esc_html__("Only simple HTML tags are allowed. Eg, %s", "event_espresso"), |
|
26 | - implode(",", array_keys($allowedtags)) |
|
27 | - ); |
|
28 | - } |
|
29 | - parent::__construct($validation_error_message); |
|
30 | - } |
|
16 | + /** |
|
17 | + * @param null $validation_error_message |
|
18 | + */ |
|
19 | + public function __construct($validation_error_message = null) |
|
20 | + { |
|
21 | + if (! $validation_error_message) { |
|
22 | + $allowedtags = $this->_get_allowed_tags(); |
|
23 | + $validation_error_message = |
|
24 | + sprintf( |
|
25 | + esc_html__("Only simple HTML tags are allowed. Eg, %s", "event_espresso"), |
|
26 | + implode(",", array_keys($allowedtags)) |
|
27 | + ); |
|
28 | + } |
|
29 | + parent::__construct($validation_error_message); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * get tags allowed |
|
35 | - */ |
|
36 | - protected function _get_allowed_tags(): array |
|
37 | - { |
|
38 | - return EEH_HTML::get_simple_tags(); |
|
39 | - } |
|
33 | + /** |
|
34 | + * get tags allowed |
|
35 | + */ |
|
36 | + protected function _get_allowed_tags(): array |
|
37 | + { |
|
38 | + return EEH_HTML::get_simple_tags(); |
|
39 | + } |
|
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * add_more_tags |
|
44 | - * |
|
45 | - * generates and returns a string that lists the top-level HTML tags that are allowable for this input |
|
46 | - * |
|
47 | - * @return string |
|
48 | - */ |
|
49 | - public function get_list_of_allowed_tags(): string |
|
50 | - { |
|
51 | - $allowed_tags = $this->_get_allowed_tags(); |
|
52 | - ksort($allowed_tags); |
|
53 | - return implode(', ', array_keys($allowed_tags)); |
|
54 | - } |
|
42 | + /** |
|
43 | + * add_more_tags |
|
44 | + * |
|
45 | + * generates and returns a string that lists the top-level HTML tags that are allowable for this input |
|
46 | + * |
|
47 | + * @return string |
|
48 | + */ |
|
49 | + public function get_list_of_allowed_tags(): string |
|
50 | + { |
|
51 | + $allowed_tags = $this->_get_allowed_tags(); |
|
52 | + ksort($allowed_tags); |
|
53 | + return implode(', ', array_keys($allowed_tags)); |
|
54 | + } |
|
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * @param mixed $normalized_value |
|
59 | - * @throws EE_Validation_Error |
|
60 | - */ |
|
61 | - public function validate($normalized_value) |
|
62 | - { |
|
63 | - $allowedtags = $this->_get_allowed_tags(); |
|
64 | - parent::validate($normalized_value); |
|
65 | - $normalized_value_sans_tags = wp_kses((string) $normalized_value, $allowedtags); |
|
66 | - if (strlen((string) $normalized_value) > strlen($normalized_value_sans_tags)) { |
|
67 | - throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags'); |
|
68 | - } |
|
69 | - } |
|
57 | + /** |
|
58 | + * @param mixed $normalized_value |
|
59 | + * @throws EE_Validation_Error |
|
60 | + */ |
|
61 | + public function validate($normalized_value) |
|
62 | + { |
|
63 | + $allowedtags = $this->_get_allowed_tags(); |
|
64 | + parent::validate($normalized_value); |
|
65 | + $normalized_value_sans_tags = wp_kses((string) $normalized_value, $allowedtags); |
|
66 | + if (strlen((string) $normalized_value) > strlen($normalized_value_sans_tags)) { |
|
67 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags'); |
|
68 | + } |
|
69 | + } |
|
70 | 70 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | */ |
19 | 19 | public function __construct($validation_error_message = null) |
20 | 20 | { |
21 | - if (! $validation_error_message) { |
|
21 | + if ( ! $validation_error_message) { |
|
22 | 22 | $allowedtags = $this->_get_allowed_tags(); |
23 | 23 | $validation_error_message = |
24 | 24 | sprintf( |
@@ -10,21 +10,21 @@ |
||
10 | 10 | */ |
11 | 11 | class EE_Integer_Input extends EE_Form_Input_Base |
12 | 12 | { |
13 | - /** |
|
14 | - * @param array $input_settings |
|
15 | - */ |
|
16 | - public function __construct($input_settings = []) |
|
17 | - { |
|
18 | - $this->_set_display_strategy( |
|
19 | - new EE_Number_Input_Display_Strategy( |
|
20 | - $input_settings['min_value'] ?? null, |
|
21 | - $input_settings['max_value'] ?? null |
|
22 | - ) |
|
23 | - ); |
|
24 | - $this->_set_normalization_strategy(new EE_Int_Normalization()); |
|
25 | - $this->_add_validation_strategy( |
|
26 | - new EE_Int_Validation_Strategy($input_settings['validation_error_message'] ?? null) |
|
27 | - ); |
|
28 | - parent::__construct($input_settings); |
|
29 | - } |
|
13 | + /** |
|
14 | + * @param array $input_settings |
|
15 | + */ |
|
16 | + public function __construct($input_settings = []) |
|
17 | + { |
|
18 | + $this->_set_display_strategy( |
|
19 | + new EE_Number_Input_Display_Strategy( |
|
20 | + $input_settings['min_value'] ?? null, |
|
21 | + $input_settings['max_value'] ?? null |
|
22 | + ) |
|
23 | + ); |
|
24 | + $this->_set_normalization_strategy(new EE_Int_Normalization()); |
|
25 | + $this->_add_validation_strategy( |
|
26 | + new EE_Int_Validation_Strategy($input_settings['validation_error_message'] ?? null) |
|
27 | + ); |
|
28 | + parent::__construct($input_settings); |
|
29 | + } |
|
30 | 30 | } |