@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('No direct script access allowed'); |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -35,150 +35,150 @@ discard block |
||
35 | 35 | abstract class EE_Form_Section_Validatable extends EE_Form_Section_Base |
36 | 36 | { |
37 | 37 | |
38 | - /** |
|
39 | - * Array of validation errors in this section. Does not contain validation errors in subsections, however. |
|
40 | - * Those are stored individually on each subsection. |
|
41 | - * |
|
42 | - * @var EE_Validation_Error[] |
|
43 | - */ |
|
44 | - protected $_validation_errors = array(); |
|
45 | - |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * Errors on this form section. Note: EE_Form_Section_Proper |
|
50 | - * has another function for getting all errors in this form section and subsections |
|
51 | - * called get_validation_errors_accumulated |
|
52 | - * |
|
53 | - * @return EE_Validation_Error[] |
|
54 | - */ |
|
55 | - public function get_validation_errors() |
|
56 | - { |
|
57 | - return $this->_validation_errors; |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * returns a ul html element with all the validation errors in it. |
|
64 | - * If we want this to be customizable, we may decide to create a strategy for displaying it. |
|
65 | - * |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function get_validation_error_string() |
|
69 | - { |
|
70 | - $validation_error_messages = array(); |
|
71 | - if ($this->get_validation_errors()) { |
|
72 | - foreach ($this->get_validation_errors() as $validation_error) { |
|
73 | - if ($validation_error instanceof EE_Validation_Error) { |
|
74 | - $validation_error_messages[] = $validation_error->getMessage(); |
|
75 | - } |
|
76 | - } |
|
77 | - } |
|
78 | - return implode(", ", $validation_error_messages); |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * Performs validation on this form section (and subsections). Should be called after _normalize() |
|
85 | - * |
|
86 | - * @return boolean of whether or not the form section is valid |
|
87 | - */ |
|
88 | - abstract protected function _validate(); |
|
89 | - |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * Checks if this field has any validation errors |
|
94 | - * |
|
95 | - * @return boolean |
|
96 | - */ |
|
97 | - public function is_valid() |
|
98 | - { |
|
99 | - if (count($this->_validation_errors)) { |
|
100 | - return false; |
|
101 | - } else { |
|
102 | - return true; |
|
103 | - } |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * Sanitizes input for this form section |
|
110 | - * |
|
111 | - * @param array $req_data is the full request data like $_POST |
|
112 | - * @return boolean of whether a normalization error occurred |
|
113 | - */ |
|
114 | - abstract protected function _normalize($req_data); |
|
115 | - |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * Creates a validation error from the arguments provided, and adds it to the form section's list. |
|
120 | - * If such an EE_Validation_Error object is passed in as the first arg, simply sets this as its form section, and |
|
121 | - * adds it to the list of validation errors of errors |
|
122 | - * |
|
123 | - * @param mixed $message_or_object internationalized string describing the validation error; or it could be a |
|
124 | - * proper EE_Validation_Error object |
|
125 | - * @param string $error_code a short key which can be used to uniquely identify the error |
|
126 | - * @param Exception $previous_exception if there was an exception that caused the error, that exception |
|
127 | - * @return void |
|
128 | - */ |
|
129 | - public function add_validation_error($message_or_object, $error_code = null, $previous_exception = null) |
|
130 | - { |
|
131 | - if ($message_or_object instanceof EE_Validation_Error) { |
|
132 | - $validation_error = $message_or_object; |
|
133 | - $validation_error->set_form_section($this); |
|
134 | - } else { |
|
135 | - $validation_error = new EE_Validation_Error($message_or_object, $error_code, $this, $previous_exception); |
|
136 | - } |
|
137 | - $this->_validation_errors[] = $validation_error; |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * When generating the JS for the jquery validation rules like<br> |
|
144 | - * <code>$( "#myform" ).validate({ |
|
145 | - * rules: { |
|
146 | - * password: "required", |
|
147 | - * password_again: { |
|
148 | - * equalTo: "#password" |
|
149 | - * } |
|
150 | - * } |
|
151 | - * });</code> |
|
152 | - * gets the sections like |
|
153 | - * <br><code>password: "required", |
|
154 | - * password_again: { |
|
155 | - * equalTo: "#password" |
|
156 | - * }</code> |
|
157 | - * except we leave it as a PHP object, and leave wp_localize_script to |
|
158 | - * turn it into a JSON object which can be used by the js |
|
159 | - * |
|
160 | - * @return array |
|
161 | - */ |
|
162 | - abstract public function get_jquery_validation_rules(); |
|
163 | - |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * Checks if this form section's data is present in the req data specified |
|
168 | - * |
|
169 | - * @param array $req_data usually $_POST, if null that's what's used |
|
170 | - * @return boolean |
|
171 | - */ |
|
172 | - abstract public function form_data_present_in($req_data = null); |
|
173 | - |
|
174 | - |
|
175 | - |
|
176 | - /** |
|
177 | - * Removes teh sensitive data from this form section (usually done after |
|
178 | - * utilizing the data business function, but before saving it somewhere. Eg, |
|
179 | - * may remove a password from the form after verifying it was correct) |
|
180 | - * |
|
181 | - * @return void |
|
182 | - */ |
|
183 | - abstract public function clean_sensitive_data(); |
|
38 | + /** |
|
39 | + * Array of validation errors in this section. Does not contain validation errors in subsections, however. |
|
40 | + * Those are stored individually on each subsection. |
|
41 | + * |
|
42 | + * @var EE_Validation_Error[] |
|
43 | + */ |
|
44 | + protected $_validation_errors = array(); |
|
45 | + |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * Errors on this form section. Note: EE_Form_Section_Proper |
|
50 | + * has another function for getting all errors in this form section and subsections |
|
51 | + * called get_validation_errors_accumulated |
|
52 | + * |
|
53 | + * @return EE_Validation_Error[] |
|
54 | + */ |
|
55 | + public function get_validation_errors() |
|
56 | + { |
|
57 | + return $this->_validation_errors; |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * returns a ul html element with all the validation errors in it. |
|
64 | + * If we want this to be customizable, we may decide to create a strategy for displaying it. |
|
65 | + * |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function get_validation_error_string() |
|
69 | + { |
|
70 | + $validation_error_messages = array(); |
|
71 | + if ($this->get_validation_errors()) { |
|
72 | + foreach ($this->get_validation_errors() as $validation_error) { |
|
73 | + if ($validation_error instanceof EE_Validation_Error) { |
|
74 | + $validation_error_messages[] = $validation_error->getMessage(); |
|
75 | + } |
|
76 | + } |
|
77 | + } |
|
78 | + return implode(", ", $validation_error_messages); |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * Performs validation on this form section (and subsections). Should be called after _normalize() |
|
85 | + * |
|
86 | + * @return boolean of whether or not the form section is valid |
|
87 | + */ |
|
88 | + abstract protected function _validate(); |
|
89 | + |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * Checks if this field has any validation errors |
|
94 | + * |
|
95 | + * @return boolean |
|
96 | + */ |
|
97 | + public function is_valid() |
|
98 | + { |
|
99 | + if (count($this->_validation_errors)) { |
|
100 | + return false; |
|
101 | + } else { |
|
102 | + return true; |
|
103 | + } |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * Sanitizes input for this form section |
|
110 | + * |
|
111 | + * @param array $req_data is the full request data like $_POST |
|
112 | + * @return boolean of whether a normalization error occurred |
|
113 | + */ |
|
114 | + abstract protected function _normalize($req_data); |
|
115 | + |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * Creates a validation error from the arguments provided, and adds it to the form section's list. |
|
120 | + * If such an EE_Validation_Error object is passed in as the first arg, simply sets this as its form section, and |
|
121 | + * adds it to the list of validation errors of errors |
|
122 | + * |
|
123 | + * @param mixed $message_or_object internationalized string describing the validation error; or it could be a |
|
124 | + * proper EE_Validation_Error object |
|
125 | + * @param string $error_code a short key which can be used to uniquely identify the error |
|
126 | + * @param Exception $previous_exception if there was an exception that caused the error, that exception |
|
127 | + * @return void |
|
128 | + */ |
|
129 | + public function add_validation_error($message_or_object, $error_code = null, $previous_exception = null) |
|
130 | + { |
|
131 | + if ($message_or_object instanceof EE_Validation_Error) { |
|
132 | + $validation_error = $message_or_object; |
|
133 | + $validation_error->set_form_section($this); |
|
134 | + } else { |
|
135 | + $validation_error = new EE_Validation_Error($message_or_object, $error_code, $this, $previous_exception); |
|
136 | + } |
|
137 | + $this->_validation_errors[] = $validation_error; |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * When generating the JS for the jquery validation rules like<br> |
|
144 | + * <code>$( "#myform" ).validate({ |
|
145 | + * rules: { |
|
146 | + * password: "required", |
|
147 | + * password_again: { |
|
148 | + * equalTo: "#password" |
|
149 | + * } |
|
150 | + * } |
|
151 | + * });</code> |
|
152 | + * gets the sections like |
|
153 | + * <br><code>password: "required", |
|
154 | + * password_again: { |
|
155 | + * equalTo: "#password" |
|
156 | + * }</code> |
|
157 | + * except we leave it as a PHP object, and leave wp_localize_script to |
|
158 | + * turn it into a JSON object which can be used by the js |
|
159 | + * |
|
160 | + * @return array |
|
161 | + */ |
|
162 | + abstract public function get_jquery_validation_rules(); |
|
163 | + |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * Checks if this form section's data is present in the req data specified |
|
168 | + * |
|
169 | + * @param array $req_data usually $_POST, if null that's what's used |
|
170 | + * @return boolean |
|
171 | + */ |
|
172 | + abstract public function form_data_present_in($req_data = null); |
|
173 | + |
|
174 | + |
|
175 | + |
|
176 | + /** |
|
177 | + * Removes teh sensitive data from this form section (usually done after |
|
178 | + * utilizing the data business function, but before saving it somewhere. Eg, |
|
179 | + * may remove a password from the form after verifying it was correct) |
|
180 | + * |
|
181 | + * @return void |
|
182 | + */ |
|
183 | + abstract public function clean_sensitive_data(); |
|
184 | 184 | } |
185 | 185 | \ No newline at end of file |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | } |
5 | 5 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | 4 | |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function __construct($input_args = array()) |
181 | 181 | { |
182 | - $input_args = (array)apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this); |
|
182 | + $input_args = (array) apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this); |
|
183 | 183 | // the following properties must be cast as arrays |
184 | 184 | if (isset($input_args['validation_strategies'])) { |
185 | - foreach ((array)$input_args['validation_strategies'] as $validation_strategy) { |
|
185 | + foreach ((array) $input_args['validation_strategies'] as $validation_strategy) { |
|
186 | 186 | if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
187 | 187 | $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; |
188 | 188 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | // loop thru incoming options |
193 | 193 | foreach ($input_args as $key => $value) { |
194 | 194 | // add underscore to $key to match property names |
195 | - $_key = '_' . $key; |
|
195 | + $_key = '_'.$key; |
|
196 | 196 | if (property_exists($this, $_key)) { |
197 | 197 | $this->{$_key} = $value; |
198 | 198 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | foreach ($this->_validation_strategies as $validation_strategy) { |
209 | 209 | $validation_strategy->_construct_finalize($this); |
210 | 210 | } |
211 | - if (! $this->_normalization_strategy) { |
|
211 | + if ( ! $this->_normalization_strategy) { |
|
212 | 212 | $this->_normalization_strategy = new EE_Text_Normalization(); |
213 | 213 | } |
214 | 214 | $this->_normalization_strategy->_construct_finalize($this); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | if (isset($input_args['default'])) { |
217 | 217 | $this->set_default($input_args['default']); |
218 | 218 | } |
219 | - if (! $this->_sensitive_data_removal_strategy) { |
|
219 | + if ( ! $this->_sensitive_data_removal_strategy) { |
|
220 | 220 | $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal(); |
221 | 221 | } |
222 | 222 | $this->_sensitive_data_removal_strategy->_construct_finalize($this); |
@@ -233,10 +233,10 @@ discard block |
||
233 | 233 | */ |
234 | 234 | protected function _set_default_html_name_if_empty() |
235 | 235 | { |
236 | - if (! $this->_html_name) { |
|
236 | + if ( ! $this->_html_name) { |
|
237 | 237 | $this->_html_name = $this->name(); |
238 | 238 | if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
239 | - $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
|
239 | + $this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]"; |
|
240 | 240 | } |
241 | 241 | } |
242 | 242 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | protected function _get_display_strategy() |
269 | 269 | { |
270 | 270 | $this->ensure_construct_finalized_called(); |
271 | - if (! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) { |
|
271 | + if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) { |
|
272 | 272 | throw new EE_Error( |
273 | 273 | sprintf( |
274 | 274 | __( |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | */ |
497 | 497 | public function html_other_attributes() |
498 | 498 | { |
499 | - return ! empty($this->_html_other_attributes) ? ' ' . $this->_html_other_attributes : ''; |
|
499 | + return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : ''; |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | */ |
641 | 641 | public function html_label_id() |
642 | 642 | { |
643 | - return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id . '-lbl'; |
|
643 | + return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id.'-lbl'; |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | $validation_strategy->get_jquery_validation_rule_array() |
791 | 791 | ); |
792 | 792 | } |
793 | - if (! empty($jquery_validation_rules)) { |
|
793 | + if ( ! empty($jquery_validation_rules)) { |
|
794 | 794 | foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) { |
795 | 795 | $jquery_validation_js[$html_id_with_pound_sign] = $jquery_validation_rules; |
796 | 796 | } |
@@ -975,7 +975,7 @@ discard block |
||
975 | 975 | $button_css_attributes .= ''; |
976 | 976 | } |
977 | 977 | $this->_button_css_attributes .= ! empty($other_attributes) |
978 | - ? $button_css_attributes . ' ' . $other_attributes |
|
978 | + ? $button_css_attributes.' '.$other_attributes |
|
979 | 979 | : $button_css_attributes; |
980 | 980 | } |
981 | 981 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -16,1130 +16,1130 @@ discard block |
||
16 | 16 | abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * the input's name attribute |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - protected $_html_name; |
|
25 | - |
|
26 | - /** |
|
27 | - * id for the html label tag |
|
28 | - * |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - protected $_html_label_id; |
|
32 | - |
|
33 | - /** |
|
34 | - * class for teh html label tag |
|
35 | - * |
|
36 | - * @var string |
|
37 | - */ |
|
38 | - protected $_html_label_class; |
|
39 | - |
|
40 | - /** |
|
41 | - * any additional html attributes that you may want to add |
|
42 | - * |
|
43 | - * @var string |
|
44 | - */ |
|
45 | - protected $_html_other_attributes; |
|
46 | - |
|
47 | - /** |
|
48 | - * style for teh html label tag |
|
49 | - * |
|
50 | - * @var string |
|
51 | - */ |
|
52 | - protected $_html_label_style; |
|
53 | - |
|
54 | - /** |
|
55 | - * text to be placed in the html label |
|
56 | - * |
|
57 | - * @var string |
|
58 | - */ |
|
59 | - protected $_html_label_text; |
|
60 | - |
|
61 | - /** |
|
62 | - * the full html label. If used, all other html_label_* properties are invalid |
|
63 | - * |
|
64 | - * @var string |
|
65 | - */ |
|
66 | - protected $_html_label; |
|
67 | - |
|
68 | - /** |
|
69 | - * HTML to use for help text (normally placed below form input), in a span which normally |
|
70 | - * has a class of 'description' |
|
71 | - * |
|
72 | - * @var string |
|
73 | - */ |
|
74 | - protected $_html_help_text; |
|
75 | - |
|
76 | - /** |
|
77 | - * CSS classes for displaying the help span |
|
78 | - * |
|
79 | - * @var string |
|
80 | - */ |
|
81 | - protected $_html_help_class = 'description'; |
|
82 | - |
|
83 | - /** |
|
84 | - * CSS to put in the style attribute on the help span |
|
85 | - * |
|
86 | - * @var string |
|
87 | - */ |
|
88 | - protected $_html_help_style; |
|
89 | - |
|
90 | - /** |
|
91 | - * Stores whether or not this input's response is required. |
|
92 | - * Because certain styling elements may also want to know that this |
|
93 | - * input is required etc. |
|
94 | - * |
|
95 | - * @var boolean |
|
96 | - */ |
|
97 | - protected $_required; |
|
98 | - |
|
99 | - /** |
|
100 | - * css class added to required inputs |
|
101 | - * |
|
102 | - * @var string |
|
103 | - */ |
|
104 | - protected $_required_css_class = 'ee-required'; |
|
105 | - |
|
106 | - /** |
|
107 | - * css styles applied to button type inputs |
|
108 | - * |
|
109 | - * @var string |
|
110 | - */ |
|
111 | - protected $_button_css_attributes; |
|
112 | - |
|
113 | - /** |
|
114 | - * The raw data submitted for this, like in the $_POST super global. |
|
115 | - * Generally unsafe for usage in client code |
|
116 | - * |
|
117 | - * @var mixed string or array |
|
118 | - */ |
|
119 | - protected $_raw_value; |
|
120 | - |
|
121 | - /** |
|
122 | - * Value normalized according to the input's normalization strategy. |
|
123 | - * The normalization strategy dictates whether this is a string, int, float, |
|
124 | - * boolean, or array of any of those. |
|
125 | - * |
|
126 | - * @var mixed |
|
127 | - */ |
|
128 | - protected $_normalized_value; |
|
129 | - |
|
130 | - /** |
|
131 | - * Strategy used for displaying this field. |
|
132 | - * Child classes must use _get_display_strategy to access it. |
|
133 | - * |
|
134 | - * @var EE_Display_Strategy_Base |
|
135 | - */ |
|
136 | - private $_display_strategy; |
|
137 | - |
|
138 | - /** |
|
139 | - * Gets all the validation strategies used on this field |
|
140 | - * |
|
141 | - * @var EE_Validation_Strategy_Base[] |
|
142 | - */ |
|
143 | - private $_validation_strategies = array(); |
|
144 | - |
|
145 | - /** |
|
146 | - * The normalization strategy for this field |
|
147 | - * |
|
148 | - * @var EE_Normalization_Strategy_Base |
|
149 | - */ |
|
150 | - private $_normalization_strategy; |
|
151 | - |
|
152 | - /** |
|
153 | - * Strategy for removing sensitive data after we're done with the form input |
|
154 | - * |
|
155 | - * @var EE_Sensitive_Data_Removal_Base |
|
156 | - */ |
|
157 | - protected $_sensitive_data_removal_strategy; |
|
158 | - |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * @param array $input_args { |
|
163 | - * @type string $html_name the html name for the input |
|
164 | - * @type string $html_label_id the id attribute to give to the html label tag |
|
165 | - * @type string $html_label_class the class attribute to give to the html label tag |
|
166 | - * @type string $html_label_style the style attribute to give ot teh label tag |
|
167 | - * @type string $html_label_text the text to put in the label tag |
|
168 | - * @type string $html_label the full html label. If used, |
|
169 | - * all other html_label_* args are invalid |
|
170 | - * @type string $html_help_text text to put in help element |
|
171 | - * @type string $html_help_style style attribute to give to teh help element |
|
172 | - * @type string $html_help_class class attribute to give to the help element |
|
173 | - * @type string $default default value NORMALIZED (eg, if providing the default |
|
174 | - * for a Yes_No_Input, you should provide TRUE or FALSE, not '1' or '0') |
|
175 | - * @type EE_Display_Strategy_Base $display strategy |
|
176 | - * @type EE_Normalization_Strategy_Base $normalization_strategy |
|
177 | - * @type EE_Validation_Strategy_Base[] $validation_strategies |
|
178 | - * } |
|
179 | - */ |
|
180 | - public function __construct($input_args = array()) |
|
181 | - { |
|
182 | - $input_args = (array)apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this); |
|
183 | - // the following properties must be cast as arrays |
|
184 | - if (isset($input_args['validation_strategies'])) { |
|
185 | - foreach ((array)$input_args['validation_strategies'] as $validation_strategy) { |
|
186 | - if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
187 | - $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; |
|
188 | - } |
|
189 | - } |
|
190 | - unset($input_args['validation_strategies']); |
|
191 | - } |
|
192 | - // loop thru incoming options |
|
193 | - foreach ($input_args as $key => $value) { |
|
194 | - // add underscore to $key to match property names |
|
195 | - $_key = '_' . $key; |
|
196 | - if (property_exists($this, $_key)) { |
|
197 | - $this->{$_key} = $value; |
|
198 | - } |
|
199 | - } |
|
200 | - // ensure that "required" is set correctly |
|
201 | - $this->set_required( |
|
202 | - $this->_required, isset($input_args['required_validation_error_message']) |
|
203 | - ? $input_args['required_validation_error_message'] |
|
204 | - : null |
|
205 | - ); |
|
206 | - //$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE; |
|
207 | - $this->_display_strategy->_construct_finalize($this); |
|
208 | - foreach ($this->_validation_strategies as $validation_strategy) { |
|
209 | - $validation_strategy->_construct_finalize($this); |
|
210 | - } |
|
211 | - if (! $this->_normalization_strategy) { |
|
212 | - $this->_normalization_strategy = new EE_Text_Normalization(); |
|
213 | - } |
|
214 | - $this->_normalization_strategy->_construct_finalize($this); |
|
215 | - //at least we can use the normalization strategy to populate the default |
|
216 | - if (isset($input_args['default'])) { |
|
217 | - $this->set_default($input_args['default']); |
|
218 | - } |
|
219 | - if (! $this->_sensitive_data_removal_strategy) { |
|
220 | - $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal(); |
|
221 | - } |
|
222 | - $this->_sensitive_data_removal_strategy->_construct_finalize($this); |
|
223 | - parent::__construct($input_args); |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - |
|
228 | - /** |
|
229 | - * Sets the html_name to its default value, if none was specified in teh constructor. |
|
230 | - * Calculation involves using the name and the parent's html_name |
|
231 | - * |
|
232 | - * @throws \EE_Error |
|
233 | - */ |
|
234 | - protected function _set_default_html_name_if_empty() |
|
235 | - { |
|
236 | - if (! $this->_html_name) { |
|
237 | - $this->_html_name = $this->name(); |
|
238 | - if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
239 | - $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
|
240 | - } |
|
241 | - } |
|
242 | - } |
|
243 | - |
|
244 | - |
|
245 | - |
|
246 | - /** |
|
247 | - * @param $parent_form_section |
|
248 | - * @param $name |
|
249 | - * @throws \EE_Error |
|
250 | - */ |
|
251 | - public function _construct_finalize($parent_form_section, $name) |
|
252 | - { |
|
253 | - parent::_construct_finalize($parent_form_section, $name); |
|
254 | - if ($this->_html_label === null && $this->_html_label_text === null) { |
|
255 | - $this->_html_label_text = ucwords(str_replace("_", " ", $name)); |
|
256 | - } |
|
257 | - do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name); |
|
258 | - } |
|
259 | - |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * Returns the strategy for displaying this form input. If none is set, throws an exception. |
|
264 | - * |
|
265 | - * @return EE_Display_Strategy_Base |
|
266 | - * @throws EE_Error |
|
267 | - */ |
|
268 | - protected function _get_display_strategy() |
|
269 | - { |
|
270 | - $this->ensure_construct_finalized_called(); |
|
271 | - if (! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) { |
|
272 | - throw new EE_Error( |
|
273 | - sprintf( |
|
274 | - __( |
|
275 | - "Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", |
|
276 | - "event_espresso" |
|
277 | - ), |
|
278 | - $this->html_name(), |
|
279 | - $this->html_id() |
|
280 | - ) |
|
281 | - ); |
|
282 | - } else { |
|
283 | - return $this->_display_strategy; |
|
284 | - } |
|
285 | - } |
|
286 | - |
|
287 | - |
|
288 | - |
|
289 | - /** |
|
290 | - * Sets the display strategy. |
|
291 | - * |
|
292 | - * @param EE_Display_Strategy_Base $strategy |
|
293 | - */ |
|
294 | - protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) |
|
295 | - { |
|
296 | - $this->_display_strategy = $strategy; |
|
297 | - } |
|
298 | - |
|
299 | - |
|
300 | - |
|
301 | - /** |
|
302 | - * Sets the sanitization strategy |
|
303 | - * |
|
304 | - * @param EE_Normalization_Strategy_Base $strategy |
|
305 | - */ |
|
306 | - protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) |
|
307 | - { |
|
308 | - $this->_normalization_strategy = $strategy; |
|
309 | - } |
|
310 | - |
|
311 | - |
|
312 | - |
|
313 | - /** |
|
314 | - * Gets sensitive_data_removal_strategy |
|
315 | - * |
|
316 | - * @return EE_Sensitive_Data_Removal_Base |
|
317 | - */ |
|
318 | - public function get_sensitive_data_removal_strategy() |
|
319 | - { |
|
320 | - return $this->_sensitive_data_removal_strategy; |
|
321 | - } |
|
322 | - |
|
323 | - |
|
324 | - |
|
325 | - /** |
|
326 | - * Sets sensitive_data_removal_strategy |
|
327 | - * |
|
328 | - * @param EE_Sensitive_Data_Removal_Base $sensitive_data_removal_strategy |
|
329 | - * @return boolean |
|
330 | - */ |
|
331 | - public function set_sensitive_data_removal_strategy($sensitive_data_removal_strategy) |
|
332 | - { |
|
333 | - $this->_sensitive_data_removal_strategy = $sensitive_data_removal_strategy; |
|
334 | - } |
|
335 | - |
|
336 | - |
|
337 | - |
|
338 | - /** |
|
339 | - * Gets the display strategy for this input |
|
340 | - * |
|
341 | - * @return EE_Display_Strategy_Base |
|
342 | - */ |
|
343 | - public function get_display_strategy() |
|
344 | - { |
|
345 | - return $this->_display_strategy; |
|
346 | - } |
|
347 | - |
|
348 | - |
|
349 | - |
|
350 | - /** |
|
351 | - * Overwrites the display strategy |
|
352 | - * |
|
353 | - * @param EE_Display_Strategy_Base $display_strategy |
|
354 | - */ |
|
355 | - public function set_display_strategy($display_strategy) |
|
356 | - { |
|
357 | - $this->_display_strategy = $display_strategy; |
|
358 | - $this->_display_strategy->_construct_finalize($this); |
|
359 | - } |
|
360 | - |
|
361 | - |
|
362 | - |
|
363 | - /** |
|
364 | - * Gets the normalization strategy set on this input |
|
365 | - * |
|
366 | - * @return EE_Normalization_Strategy_Base |
|
367 | - */ |
|
368 | - public function get_normalization_strategy() |
|
369 | - { |
|
370 | - return $this->_normalization_strategy; |
|
371 | - } |
|
372 | - |
|
373 | - |
|
374 | - |
|
375 | - /** |
|
376 | - * Overwrites the normalization strategy |
|
377 | - * |
|
378 | - * @param EE_Normalization_Strategy_Base $normalization_strategy |
|
379 | - */ |
|
380 | - public function set_normalization_strategy($normalization_strategy) |
|
381 | - { |
|
382 | - $this->_normalization_strategy = $normalization_strategy; |
|
383 | - $this->_normalization_strategy->_construct_finalize($this); |
|
384 | - } |
|
385 | - |
|
386 | - |
|
387 | - |
|
388 | - /** |
|
389 | - * Returns all teh validation strategies which apply to this field, numerically indexed |
|
390 | - * |
|
391 | - * @return EE_Validation_Strategy_Base[] |
|
392 | - */ |
|
393 | - public function get_validation_strategies() |
|
394 | - { |
|
395 | - return $this->_validation_strategies; |
|
396 | - } |
|
397 | - |
|
398 | - |
|
399 | - |
|
400 | - /** |
|
401 | - * Adds this strategy to the field so it will be used in both JS validation and server-side validation |
|
402 | - * |
|
403 | - * @param EE_Validation_Strategy_Base $validation_strategy |
|
404 | - * @return void |
|
405 | - */ |
|
406 | - protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) |
|
407 | - { |
|
408 | - $validation_strategy->_construct_finalize($this); |
|
409 | - $this->_validation_strategies[] = $validation_strategy; |
|
410 | - } |
|
411 | - |
|
412 | - |
|
413 | - |
|
414 | - /** |
|
415 | - * Adds a new validation strategy onto the form input |
|
416 | - * |
|
417 | - * @param EE_Validation_Strategy_Base $validation_strategy |
|
418 | - * @return void |
|
419 | - */ |
|
420 | - public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) |
|
421 | - { |
|
422 | - $this->_add_validation_strategy($validation_strategy); |
|
423 | - } |
|
424 | - |
|
425 | - |
|
426 | - |
|
427 | - /** |
|
428 | - * The classname of the validation strategy to remove |
|
429 | - * |
|
430 | - * @param string $validation_strategy_classname |
|
431 | - */ |
|
432 | - public function remove_validation_strategy($validation_strategy_classname) |
|
433 | - { |
|
434 | - foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
435 | - if ( |
|
436 | - $validation_strategy instanceof $validation_strategy_classname |
|
437 | - || is_subclass_of($validation_strategy, $validation_strategy_classname) |
|
438 | - ) { |
|
439 | - unset($this->_validation_strategies[$key]); |
|
440 | - } |
|
441 | - } |
|
442 | - } |
|
443 | - |
|
444 | - |
|
445 | - |
|
446 | - /** |
|
447 | - * returns true if input employs any of the validation strategy defined by the supplied array of classnames |
|
448 | - * |
|
449 | - * @param array $validation_strategy_classnames |
|
450 | - * @return bool |
|
451 | - */ |
|
452 | - public function has_validation_strategy($validation_strategy_classnames) |
|
453 | - { |
|
454 | - $validation_strategy_classnames = is_array($validation_strategy_classnames) |
|
455 | - ? $validation_strategy_classnames |
|
456 | - : array($validation_strategy_classnames); |
|
457 | - foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
458 | - if (in_array($key, $validation_strategy_classnames)) { |
|
459 | - return true; |
|
460 | - } |
|
461 | - } |
|
462 | - return false; |
|
463 | - } |
|
464 | - |
|
465 | - |
|
466 | - |
|
467 | - /** |
|
468 | - * Gets the HTML |
|
469 | - * |
|
470 | - * @return string |
|
471 | - */ |
|
472 | - public function get_html() |
|
473 | - { |
|
474 | - return $this->_parent_section->get_html_for_input($this); |
|
475 | - } |
|
476 | - |
|
477 | - |
|
478 | - |
|
479 | - /** |
|
480 | - * Gets the HTML for the input itself (no label or errors) according to the |
|
481 | - * input's display strategy |
|
482 | - * Makes sure the JS and CSS are enqueued for it |
|
483 | - * |
|
484 | - * @return string |
|
485 | - * @throws \EE_Error |
|
486 | - */ |
|
487 | - public function get_html_for_input() |
|
488 | - { |
|
489 | - return $this->_form_html_filter |
|
490 | - ? $this->_form_html_filter->filterHtml( |
|
491 | - $this->_get_display_strategy()->display(), |
|
492 | - $this |
|
493 | - ) |
|
494 | - : $this->_get_display_strategy()->display(); |
|
495 | - } |
|
496 | - |
|
497 | - |
|
498 | - |
|
499 | - /** |
|
500 | - * @return string |
|
501 | - */ |
|
502 | - public function html_other_attributes() |
|
503 | - { |
|
504 | - return ! empty($this->_html_other_attributes) ? ' ' . $this->_html_other_attributes : ''; |
|
505 | - } |
|
506 | - |
|
507 | - |
|
508 | - |
|
509 | - /** |
|
510 | - * @param string $html_other_attributes |
|
511 | - */ |
|
512 | - public function set_html_other_attributes($html_other_attributes) |
|
513 | - { |
|
514 | - $this->_html_other_attributes = $html_other_attributes; |
|
515 | - } |
|
516 | - |
|
517 | - |
|
518 | - |
|
519 | - /** |
|
520 | - * Gets the HTML for displaying the label for this form input |
|
521 | - * according to the form section's layout strategy |
|
522 | - * |
|
523 | - * @return string |
|
524 | - */ |
|
525 | - public function get_html_for_label() |
|
526 | - { |
|
527 | - return $this->_parent_section->get_layout_strategy()->display_label($this); |
|
528 | - } |
|
529 | - |
|
530 | - |
|
531 | - |
|
532 | - /** |
|
533 | - * Gets the HTML for displaying the errors section for this form input |
|
534 | - * according to the form section's layout strategy |
|
535 | - * |
|
536 | - * @return string |
|
537 | - */ |
|
538 | - public function get_html_for_errors() |
|
539 | - { |
|
540 | - return $this->_parent_section->get_layout_strategy()->display_errors($this); |
|
541 | - } |
|
542 | - |
|
543 | - |
|
544 | - |
|
545 | - /** |
|
546 | - * Gets the HTML for displaying the help text for this form input |
|
547 | - * according to the form section's layout strategy |
|
548 | - * |
|
549 | - * @return string |
|
550 | - */ |
|
551 | - public function get_html_for_help() |
|
552 | - { |
|
553 | - return $this->_parent_section->get_layout_strategy()->display_help_text($this); |
|
554 | - } |
|
555 | - |
|
556 | - |
|
557 | - |
|
558 | - /** |
|
559 | - * Validates the input's sanitized value (assumes _sanitize() has already been called) |
|
560 | - * and returns whether or not the form input's submitted value is value |
|
561 | - * |
|
562 | - * @return boolean |
|
563 | - */ |
|
564 | - protected function _validate() |
|
565 | - { |
|
566 | - foreach ($this->_validation_strategies as $validation_strategy) { |
|
567 | - if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
568 | - try { |
|
569 | - $validation_strategy->validate($this->normalized_value()); |
|
570 | - } catch (EE_Validation_Error $e) { |
|
571 | - $this->add_validation_error($e); |
|
572 | - } |
|
573 | - } |
|
574 | - } |
|
575 | - if ($this->get_validation_errors()) { |
|
576 | - return false; |
|
577 | - } else { |
|
578 | - return true; |
|
579 | - } |
|
580 | - } |
|
581 | - |
|
582 | - |
|
583 | - |
|
584 | - /** |
|
585 | - * Performs basic sanitization on this value. But what sanitization can be performed anyways? |
|
586 | - * This value MIGHT be allowed to have tags, so we can't really remove them. |
|
587 | - * |
|
588 | - * @param string $value |
|
589 | - * @return null|string |
|
590 | - */ |
|
591 | - private function _sanitize($value) |
|
592 | - { |
|
593 | - return $value !== null ? stripslashes(html_entity_decode(trim($value))) : null; |
|
594 | - } |
|
595 | - |
|
596 | - |
|
597 | - |
|
598 | - /** |
|
599 | - * Picks out the form value that relates to this form input, |
|
600 | - * and stores it as the sanitized value on the form input, and sets the normalized value. |
|
601 | - * Returns whether or not any validation errors occurred |
|
602 | - * |
|
603 | - * @param array $req_data like $_POST |
|
604 | - * @return boolean whether or not there was an error |
|
605 | - * @throws \EE_Error |
|
606 | - */ |
|
607 | - protected function _normalize($req_data) |
|
608 | - { |
|
609 | - //any existing validation errors don't apply so clear them |
|
610 | - $this->_validation_errors = array(); |
|
611 | - try { |
|
612 | - $raw_input = $this->find_form_data_for_this_section($req_data); |
|
613 | - //super simple sanitization for now |
|
614 | - if (is_array($raw_input)) { |
|
615 | - $raw_value = array(); |
|
616 | - foreach ($raw_input as $key => $value) { |
|
617 | - $raw_value[$key] = $this->_sanitize($value); |
|
618 | - } |
|
619 | - $this->_set_raw_value($raw_value); |
|
620 | - } else { |
|
621 | - $this->_set_raw_value($this->_sanitize($raw_input)); |
|
622 | - } |
|
623 | - //we want to mostly leave the input alone in case we need to re-display it to the user |
|
624 | - $this->_set_normalized_value($this->_normalization_strategy->normalize($this->raw_value())); |
|
625 | - } catch (EE_Validation_Error $e) { |
|
626 | - $this->add_validation_error($e); |
|
627 | - } |
|
628 | - } |
|
629 | - |
|
630 | - |
|
631 | - |
|
632 | - /** |
|
633 | - * @return string |
|
634 | - */ |
|
635 | - public function html_name() |
|
636 | - { |
|
637 | - $this->_set_default_html_name_if_empty(); |
|
638 | - return $this->_html_name; |
|
639 | - } |
|
640 | - |
|
641 | - |
|
642 | - |
|
643 | - /** |
|
644 | - * @return string |
|
645 | - */ |
|
646 | - public function html_label_id() |
|
647 | - { |
|
648 | - return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id . '-lbl'; |
|
649 | - } |
|
650 | - |
|
651 | - |
|
652 | - |
|
653 | - /** |
|
654 | - * @return string |
|
655 | - */ |
|
656 | - public function html_label_class() |
|
657 | - { |
|
658 | - return $this->_html_label_class; |
|
659 | - } |
|
660 | - |
|
661 | - |
|
662 | - |
|
663 | - /** |
|
664 | - * @return string |
|
665 | - */ |
|
666 | - public function html_label_style() |
|
667 | - { |
|
668 | - return $this->_html_label_style; |
|
669 | - } |
|
670 | - |
|
671 | - |
|
672 | - |
|
673 | - /** |
|
674 | - * @return string |
|
675 | - */ |
|
676 | - public function html_label_text() |
|
677 | - { |
|
678 | - return $this->_html_label_text; |
|
679 | - } |
|
680 | - |
|
681 | - |
|
682 | - |
|
683 | - /** |
|
684 | - * @return string |
|
685 | - */ |
|
686 | - public function html_help_text() |
|
687 | - { |
|
688 | - return $this->_html_help_text; |
|
689 | - } |
|
690 | - |
|
691 | - |
|
692 | - |
|
693 | - /** |
|
694 | - * @return string |
|
695 | - */ |
|
696 | - public function html_help_class() |
|
697 | - { |
|
698 | - return $this->_html_help_class; |
|
699 | - } |
|
700 | - |
|
701 | - |
|
702 | - |
|
703 | - /** |
|
704 | - * @return string |
|
705 | - */ |
|
706 | - public function html_help_style() |
|
707 | - { |
|
708 | - return $this->_html_style; |
|
709 | - } |
|
710 | - |
|
711 | - |
|
712 | - |
|
713 | - /** |
|
714 | - * returns the raw, UNSAFE, input, almost exactly as the user submitted it. |
|
715 | - * Please note that almost all client code should instead use the normalized_value; |
|
716 | - * or possibly raw_value_in_form (which prepares the string for displaying in an HTML attribute on a tag, |
|
717 | - * mostly by escaping quotes) |
|
718 | - * Note, we do not store the exact original value sent in the user's request because |
|
719 | - * it may have malicious content, and we MIGHT want to store the form input in a transient or something... |
|
720 | - * in which case, we would have stored the malicious content to our database. |
|
721 | - * |
|
722 | - * @return string |
|
723 | - */ |
|
724 | - public function raw_value() |
|
725 | - { |
|
726 | - return $this->_raw_value; |
|
727 | - } |
|
728 | - |
|
729 | - |
|
730 | - |
|
731 | - /** |
|
732 | - * Returns a string safe to usage in form inputs when displaying, because |
|
733 | - * it escapes all html entities |
|
734 | - * |
|
735 | - * @return string |
|
736 | - */ |
|
737 | - public function raw_value_in_form() |
|
738 | - { |
|
739 | - return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8'); |
|
740 | - } |
|
741 | - |
|
742 | - |
|
743 | - |
|
744 | - /** |
|
745 | - * returns the value after it's been sanitized, and then converted into it's proper type |
|
746 | - * in PHP. Eg, a string, an int, an array, |
|
747 | - * |
|
748 | - * @return mixed |
|
749 | - */ |
|
750 | - public function normalized_value() |
|
751 | - { |
|
752 | - return $this->_normalized_value; |
|
753 | - } |
|
754 | - |
|
755 | - |
|
756 | - |
|
757 | - /** |
|
758 | - * Returns the normalized value is a presentable way. By default this is just |
|
759 | - * the normalized value by itself, but it can be overridden for when that's not |
|
760 | - * the best thing to display |
|
761 | - * |
|
762 | - * @return string |
|
763 | - */ |
|
764 | - public function pretty_value() |
|
765 | - { |
|
766 | - return $this->_normalized_value; |
|
767 | - } |
|
768 | - |
|
769 | - |
|
770 | - |
|
771 | - /** |
|
772 | - * When generating the JS for the jquery validation rules like<br> |
|
773 | - * <code>$( "#myform" ).validate({ |
|
774 | - * rules: { |
|
775 | - * password: "required", |
|
776 | - * password_again: { |
|
777 | - * equalTo: "#password" |
|
778 | - * } |
|
779 | - * } |
|
780 | - * });</code> |
|
781 | - * if this field had the name 'password_again', it should return |
|
782 | - * <br><code>password_again: { |
|
783 | - * equalTo: "#password" |
|
784 | - * }</code> |
|
785 | - * |
|
786 | - * @return array |
|
787 | - */ |
|
788 | - public function get_jquery_validation_rules() |
|
789 | - { |
|
790 | - $jquery_validation_js = array(); |
|
791 | - $jquery_validation_rules = array(); |
|
792 | - foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
793 | - $jquery_validation_rules = array_replace_recursive( |
|
794 | - $jquery_validation_rules, |
|
795 | - $validation_strategy->get_jquery_validation_rule_array() |
|
796 | - ); |
|
797 | - } |
|
798 | - if (! empty($jquery_validation_rules)) { |
|
799 | - foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) { |
|
800 | - $jquery_validation_js[$html_id_with_pound_sign] = $jquery_validation_rules; |
|
801 | - } |
|
802 | - } |
|
803 | - return $jquery_validation_js; |
|
804 | - } |
|
805 | - |
|
806 | - |
|
807 | - |
|
808 | - /** |
|
809 | - * Sets the input's default value for use in displaying in the form. Note: value should be |
|
810 | - * normalized (Eg, if providing a default of ra Yes_NO_Input you would provide TRUE or FALSE, not '1' or '0') |
|
811 | - * |
|
812 | - * @param mixed $value |
|
813 | - * @return void |
|
814 | - */ |
|
815 | - public function set_default($value) |
|
816 | - { |
|
817 | - $this->_set_normalized_value($value); |
|
818 | - $this->_set_raw_value($value); |
|
819 | - } |
|
820 | - |
|
821 | - |
|
822 | - |
|
823 | - /** |
|
824 | - * Sets the normalized value on this input |
|
825 | - * |
|
826 | - * @param mixed $value |
|
827 | - */ |
|
828 | - protected function _set_normalized_value($value) |
|
829 | - { |
|
830 | - $this->_normalized_value = $value; |
|
831 | - } |
|
832 | - |
|
833 | - |
|
834 | - |
|
835 | - /** |
|
836 | - * Sets the raw value on this input (ie, exactly as the user submitted it) |
|
837 | - * |
|
838 | - * @param mixed $value |
|
839 | - */ |
|
840 | - protected function _set_raw_value($value) |
|
841 | - { |
|
842 | - $this->_raw_value = $this->_normalization_strategy->unnormalize($value); |
|
843 | - } |
|
844 | - |
|
845 | - |
|
846 | - |
|
847 | - /** |
|
848 | - * Sets the HTML label text after it has already been defined |
|
849 | - * |
|
850 | - * @param string $label |
|
851 | - * @return void |
|
852 | - */ |
|
853 | - public function set_html_label_text($label) |
|
854 | - { |
|
855 | - $this->_html_label_text = $label; |
|
856 | - } |
|
857 | - |
|
858 | - |
|
859 | - |
|
860 | - /** |
|
861 | - * Sets whether or not this field is required, and adjusts the validation strategy. |
|
862 | - * If you want to use the EE_Conditionally_Required_Validation_Strategy, |
|
863 | - * please add it as a validation strategy using add_validation_strategy as normal |
|
864 | - * |
|
865 | - * @param boolean $required boolean |
|
866 | - * @param null $required_text |
|
867 | - */ |
|
868 | - public function set_required($required = true, $required_text = null) |
|
869 | - { |
|
870 | - $required = filter_var($required, FILTER_VALIDATE_BOOLEAN); |
|
871 | - //whether $required is a string or a boolean, we want to add a required validation strategy |
|
872 | - if ($required) { |
|
873 | - $this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text)); |
|
874 | - } else { |
|
875 | - $this->remove_validation_strategy('EE_Required_Validation_Strategy'); |
|
876 | - } |
|
877 | - $this->_required = $required; |
|
878 | - } |
|
879 | - |
|
880 | - |
|
881 | - |
|
882 | - /** |
|
883 | - * Returns whether or not this field is required |
|
884 | - * |
|
885 | - * @return boolean |
|
886 | - */ |
|
887 | - public function required() |
|
888 | - { |
|
889 | - return $this->_required; |
|
890 | - } |
|
891 | - |
|
892 | - |
|
893 | - |
|
894 | - /** |
|
895 | - * @param string $required_css_class |
|
896 | - */ |
|
897 | - public function set_required_css_class($required_css_class) |
|
898 | - { |
|
899 | - $this->_required_css_class = $required_css_class; |
|
900 | - } |
|
901 | - |
|
902 | - |
|
903 | - |
|
904 | - /** |
|
905 | - * @return string |
|
906 | - */ |
|
907 | - public function required_css_class() |
|
908 | - { |
|
909 | - return $this->_required_css_class; |
|
910 | - } |
|
911 | - |
|
912 | - |
|
913 | - |
|
914 | - /** |
|
915 | - * Sets the help text, in case |
|
916 | - * |
|
917 | - * @param string $text |
|
918 | - */ |
|
919 | - public function set_html_help_text($text) |
|
920 | - { |
|
921 | - $this->_html_help_text = $text; |
|
922 | - } |
|
923 | - |
|
924 | - |
|
925 | - |
|
926 | - /** |
|
927 | - * Uses the sensitive data removal strategy to remove the sensitive data from this |
|
928 | - * input. If there is any kind of sensitive data removal on this input, we clear |
|
929 | - * out the raw value completely |
|
930 | - * |
|
931 | - * @return void |
|
932 | - */ |
|
933 | - public function clean_sensitive_data() |
|
934 | - { |
|
935 | - //if we do ANY kind of sensitive data removal on this, then just clear out the raw value |
|
936 | - //if we need more logic than this we'll make a strategy for it |
|
937 | - if ($this->_sensitive_data_removal_strategy |
|
938 | - && ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal |
|
939 | - ) { |
|
940 | - $this->_set_raw_value(null); |
|
941 | - } |
|
942 | - //and clean the normalized value according to the appropriate strategy |
|
943 | - $this->_set_normalized_value( |
|
944 | - $this->get_sensitive_data_removal_strategy()->remove_sensitive_data( |
|
945 | - $this->_normalized_value |
|
946 | - ) |
|
947 | - ); |
|
948 | - } |
|
949 | - |
|
950 | - |
|
951 | - |
|
952 | - /** |
|
953 | - * @param bool $primary |
|
954 | - * @param string $button_size |
|
955 | - * @param string $other_attributes |
|
956 | - */ |
|
957 | - public function set_button_css_attributes($primary = true, $button_size = '', $other_attributes = '') |
|
958 | - { |
|
959 | - $button_css_attributes = 'button'; |
|
960 | - $button_css_attributes .= $primary === true ? ' button-primary' : ' button-secondary'; |
|
961 | - switch ($button_size) { |
|
962 | - case 'xs' : |
|
963 | - case 'extra-small' : |
|
964 | - $button_css_attributes .= ' button-xs'; |
|
965 | - break; |
|
966 | - case 'sm' : |
|
967 | - case 'small' : |
|
968 | - $button_css_attributes .= ' button-sm'; |
|
969 | - break; |
|
970 | - case 'lg' : |
|
971 | - case 'large' : |
|
972 | - $button_css_attributes .= ' button-lg'; |
|
973 | - break; |
|
974 | - case 'block' : |
|
975 | - $button_css_attributes .= ' button-block'; |
|
976 | - break; |
|
977 | - case 'md' : |
|
978 | - case 'medium' : |
|
979 | - default : |
|
980 | - $button_css_attributes .= ''; |
|
981 | - } |
|
982 | - $this->_button_css_attributes .= ! empty($other_attributes) |
|
983 | - ? $button_css_attributes . ' ' . $other_attributes |
|
984 | - : $button_css_attributes; |
|
985 | - } |
|
986 | - |
|
987 | - |
|
988 | - |
|
989 | - /** |
|
990 | - * @return string |
|
991 | - */ |
|
992 | - public function button_css_attributes() |
|
993 | - { |
|
994 | - if (empty($this->_button_css_attributes)) { |
|
995 | - $this->set_button_css_attributes(); |
|
996 | - } |
|
997 | - return $this->_button_css_attributes; |
|
998 | - } |
|
999 | - |
|
1000 | - |
|
1001 | - |
|
1002 | - /** |
|
1003 | - * find_form_data_for_this_section |
|
1004 | - * using this section's name and its parents, finds the value of the form data that corresponds to it. |
|
1005 | - * For example, if this form section's HTML name is my_form[subform][form_input_1], |
|
1006 | - * then it's value should be in $_REQUEST at $_REQUEST['my_form']['subform']['form_input_1']. |
|
1007 | - * (If that doesn't exist, we also check for this subsection's name |
|
1008 | - * at the TOP LEVEL of the request data. Eg $_REQUEST['form_input_1'].) |
|
1009 | - * This function finds its value in the form. |
|
1010 | - * |
|
1011 | - * @param array $req_data |
|
1012 | - * @return mixed whatever the raw value of this form section is in the request data |
|
1013 | - * @throws \EE_Error |
|
1014 | - */ |
|
1015 | - public function find_form_data_for_this_section($req_data) |
|
1016 | - { |
|
1017 | - // break up the html name by "[]" |
|
1018 | - if (strpos($this->html_name(), '[') !== false) { |
|
1019 | - $before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '[')); |
|
1020 | - } else { |
|
1021 | - $before_any_brackets = $this->html_name(); |
|
1022 | - } |
|
1023 | - // grab all of the segments |
|
1024 | - preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches); |
|
1025 | - if (isset($matches[1]) && is_array($matches[1])) { |
|
1026 | - $name_parts = $matches[1]; |
|
1027 | - array_unshift($name_parts, $before_any_brackets); |
|
1028 | - } else { |
|
1029 | - $name_parts = array($before_any_brackets); |
|
1030 | - } |
|
1031 | - // now get the value for the input |
|
1032 | - $value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data); |
|
1033 | - // check if this thing's name is at the TOP level of the request data |
|
1034 | - if ($value === null && isset($req_data[$this->name()])) { |
|
1035 | - $value = $req_data[$this->name()]; |
|
1036 | - } |
|
1037 | - return $value; |
|
1038 | - } |
|
1039 | - |
|
1040 | - |
|
1041 | - |
|
1042 | - /** |
|
1043 | - * @param array $html_name_parts |
|
1044 | - * @param array $req_data |
|
1045 | - * @return array | NULL |
|
1046 | - */ |
|
1047 | - public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) |
|
1048 | - { |
|
1049 | - $first_part_to_consider = array_shift($html_name_parts); |
|
1050 | - if (isset($req_data[$first_part_to_consider])) { |
|
1051 | - if (empty($html_name_parts)) { |
|
1052 | - return $req_data[$first_part_to_consider]; |
|
1053 | - } else { |
|
1054 | - return $this->_find_form_data_for_this_section_using_name_parts( |
|
1055 | - $html_name_parts, |
|
1056 | - $req_data[$first_part_to_consider] |
|
1057 | - ); |
|
1058 | - } |
|
1059 | - } else { |
|
1060 | - return null; |
|
1061 | - } |
|
1062 | - } |
|
1063 | - |
|
1064 | - |
|
1065 | - |
|
1066 | - /** |
|
1067 | - * Checks if this form input's data is in the request data |
|
1068 | - * |
|
1069 | - * @param array $req_data like $_POST |
|
1070 | - * @return boolean |
|
1071 | - * @throws \EE_Error |
|
1072 | - */ |
|
1073 | - public function form_data_present_in($req_data = null) |
|
1074 | - { |
|
1075 | - if ($req_data === null) { |
|
1076 | - $req_data = $_POST; |
|
1077 | - } |
|
1078 | - $checked_value = $this->find_form_data_for_this_section($req_data); |
|
1079 | - if ($checked_value !== null) { |
|
1080 | - return true; |
|
1081 | - } else { |
|
1082 | - return false; |
|
1083 | - } |
|
1084 | - } |
|
1085 | - |
|
1086 | - |
|
1087 | - |
|
1088 | - /** |
|
1089 | - * Overrides parent to add js data from validation and display strategies |
|
1090 | - * |
|
1091 | - * @param array $form_other_js_data |
|
1092 | - * @return array |
|
1093 | - */ |
|
1094 | - public function get_other_js_data($form_other_js_data = array()) |
|
1095 | - { |
|
1096 | - $form_other_js_data = $this->get_other_js_data_from_strategies($form_other_js_data); |
|
1097 | - return $form_other_js_data; |
|
1098 | - } |
|
1099 | - |
|
1100 | - |
|
1101 | - |
|
1102 | - /** |
|
1103 | - * Gets other JS data for localization from this input's strategies, like |
|
1104 | - * the validation strategies and the display strategy |
|
1105 | - * |
|
1106 | - * @param array $form_other_js_data |
|
1107 | - * @return array |
|
1108 | - */ |
|
1109 | - public function get_other_js_data_from_strategies($form_other_js_data = array()) |
|
1110 | - { |
|
1111 | - $form_other_js_data = $this->get_display_strategy()->get_other_js_data($form_other_js_data); |
|
1112 | - foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
1113 | - $form_other_js_data = $validation_strategy->get_other_js_data($form_other_js_data); |
|
1114 | - } |
|
1115 | - return $form_other_js_data; |
|
1116 | - } |
|
1117 | - |
|
1118 | - |
|
1119 | - |
|
1120 | - /** |
|
1121 | - * Override parent because we want to give our strategies an opportunity to enqueue some js and css |
|
1122 | - * |
|
1123 | - * @return void |
|
1124 | - */ |
|
1125 | - public function enqueue_js() |
|
1126 | - { |
|
1127 | - //ask our display strategy and validation strategies if they have js to enqueue |
|
1128 | - $this->enqueue_js_from_strategies(); |
|
1129 | - } |
|
1130 | - |
|
1131 | - |
|
1132 | - |
|
1133 | - /** |
|
1134 | - * Tells strategies when its ok to enqueue their js and css |
|
1135 | - * |
|
1136 | - * @return void |
|
1137 | - */ |
|
1138 | - public function enqueue_js_from_strategies() |
|
1139 | - { |
|
1140 | - $this->get_display_strategy()->enqueue_js(); |
|
1141 | - foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
1142 | - $validation_strategy->enqueue_js(); |
|
1143 | - } |
|
1144 | - } |
|
19 | + /** |
|
20 | + * the input's name attribute |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + protected $_html_name; |
|
25 | + |
|
26 | + /** |
|
27 | + * id for the html label tag |
|
28 | + * |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + protected $_html_label_id; |
|
32 | + |
|
33 | + /** |
|
34 | + * class for teh html label tag |
|
35 | + * |
|
36 | + * @var string |
|
37 | + */ |
|
38 | + protected $_html_label_class; |
|
39 | + |
|
40 | + /** |
|
41 | + * any additional html attributes that you may want to add |
|
42 | + * |
|
43 | + * @var string |
|
44 | + */ |
|
45 | + protected $_html_other_attributes; |
|
46 | + |
|
47 | + /** |
|
48 | + * style for teh html label tag |
|
49 | + * |
|
50 | + * @var string |
|
51 | + */ |
|
52 | + protected $_html_label_style; |
|
53 | + |
|
54 | + /** |
|
55 | + * text to be placed in the html label |
|
56 | + * |
|
57 | + * @var string |
|
58 | + */ |
|
59 | + protected $_html_label_text; |
|
60 | + |
|
61 | + /** |
|
62 | + * the full html label. If used, all other html_label_* properties are invalid |
|
63 | + * |
|
64 | + * @var string |
|
65 | + */ |
|
66 | + protected $_html_label; |
|
67 | + |
|
68 | + /** |
|
69 | + * HTML to use for help text (normally placed below form input), in a span which normally |
|
70 | + * has a class of 'description' |
|
71 | + * |
|
72 | + * @var string |
|
73 | + */ |
|
74 | + protected $_html_help_text; |
|
75 | + |
|
76 | + /** |
|
77 | + * CSS classes for displaying the help span |
|
78 | + * |
|
79 | + * @var string |
|
80 | + */ |
|
81 | + protected $_html_help_class = 'description'; |
|
82 | + |
|
83 | + /** |
|
84 | + * CSS to put in the style attribute on the help span |
|
85 | + * |
|
86 | + * @var string |
|
87 | + */ |
|
88 | + protected $_html_help_style; |
|
89 | + |
|
90 | + /** |
|
91 | + * Stores whether or not this input's response is required. |
|
92 | + * Because certain styling elements may also want to know that this |
|
93 | + * input is required etc. |
|
94 | + * |
|
95 | + * @var boolean |
|
96 | + */ |
|
97 | + protected $_required; |
|
98 | + |
|
99 | + /** |
|
100 | + * css class added to required inputs |
|
101 | + * |
|
102 | + * @var string |
|
103 | + */ |
|
104 | + protected $_required_css_class = 'ee-required'; |
|
105 | + |
|
106 | + /** |
|
107 | + * css styles applied to button type inputs |
|
108 | + * |
|
109 | + * @var string |
|
110 | + */ |
|
111 | + protected $_button_css_attributes; |
|
112 | + |
|
113 | + /** |
|
114 | + * The raw data submitted for this, like in the $_POST super global. |
|
115 | + * Generally unsafe for usage in client code |
|
116 | + * |
|
117 | + * @var mixed string or array |
|
118 | + */ |
|
119 | + protected $_raw_value; |
|
120 | + |
|
121 | + /** |
|
122 | + * Value normalized according to the input's normalization strategy. |
|
123 | + * The normalization strategy dictates whether this is a string, int, float, |
|
124 | + * boolean, or array of any of those. |
|
125 | + * |
|
126 | + * @var mixed |
|
127 | + */ |
|
128 | + protected $_normalized_value; |
|
129 | + |
|
130 | + /** |
|
131 | + * Strategy used for displaying this field. |
|
132 | + * Child classes must use _get_display_strategy to access it. |
|
133 | + * |
|
134 | + * @var EE_Display_Strategy_Base |
|
135 | + */ |
|
136 | + private $_display_strategy; |
|
137 | + |
|
138 | + /** |
|
139 | + * Gets all the validation strategies used on this field |
|
140 | + * |
|
141 | + * @var EE_Validation_Strategy_Base[] |
|
142 | + */ |
|
143 | + private $_validation_strategies = array(); |
|
144 | + |
|
145 | + /** |
|
146 | + * The normalization strategy for this field |
|
147 | + * |
|
148 | + * @var EE_Normalization_Strategy_Base |
|
149 | + */ |
|
150 | + private $_normalization_strategy; |
|
151 | + |
|
152 | + /** |
|
153 | + * Strategy for removing sensitive data after we're done with the form input |
|
154 | + * |
|
155 | + * @var EE_Sensitive_Data_Removal_Base |
|
156 | + */ |
|
157 | + protected $_sensitive_data_removal_strategy; |
|
158 | + |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * @param array $input_args { |
|
163 | + * @type string $html_name the html name for the input |
|
164 | + * @type string $html_label_id the id attribute to give to the html label tag |
|
165 | + * @type string $html_label_class the class attribute to give to the html label tag |
|
166 | + * @type string $html_label_style the style attribute to give ot teh label tag |
|
167 | + * @type string $html_label_text the text to put in the label tag |
|
168 | + * @type string $html_label the full html label. If used, |
|
169 | + * all other html_label_* args are invalid |
|
170 | + * @type string $html_help_text text to put in help element |
|
171 | + * @type string $html_help_style style attribute to give to teh help element |
|
172 | + * @type string $html_help_class class attribute to give to the help element |
|
173 | + * @type string $default default value NORMALIZED (eg, if providing the default |
|
174 | + * for a Yes_No_Input, you should provide TRUE or FALSE, not '1' or '0') |
|
175 | + * @type EE_Display_Strategy_Base $display strategy |
|
176 | + * @type EE_Normalization_Strategy_Base $normalization_strategy |
|
177 | + * @type EE_Validation_Strategy_Base[] $validation_strategies |
|
178 | + * } |
|
179 | + */ |
|
180 | + public function __construct($input_args = array()) |
|
181 | + { |
|
182 | + $input_args = (array)apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this); |
|
183 | + // the following properties must be cast as arrays |
|
184 | + if (isset($input_args['validation_strategies'])) { |
|
185 | + foreach ((array)$input_args['validation_strategies'] as $validation_strategy) { |
|
186 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
187 | + $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; |
|
188 | + } |
|
189 | + } |
|
190 | + unset($input_args['validation_strategies']); |
|
191 | + } |
|
192 | + // loop thru incoming options |
|
193 | + foreach ($input_args as $key => $value) { |
|
194 | + // add underscore to $key to match property names |
|
195 | + $_key = '_' . $key; |
|
196 | + if (property_exists($this, $_key)) { |
|
197 | + $this->{$_key} = $value; |
|
198 | + } |
|
199 | + } |
|
200 | + // ensure that "required" is set correctly |
|
201 | + $this->set_required( |
|
202 | + $this->_required, isset($input_args['required_validation_error_message']) |
|
203 | + ? $input_args['required_validation_error_message'] |
|
204 | + : null |
|
205 | + ); |
|
206 | + //$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE; |
|
207 | + $this->_display_strategy->_construct_finalize($this); |
|
208 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
209 | + $validation_strategy->_construct_finalize($this); |
|
210 | + } |
|
211 | + if (! $this->_normalization_strategy) { |
|
212 | + $this->_normalization_strategy = new EE_Text_Normalization(); |
|
213 | + } |
|
214 | + $this->_normalization_strategy->_construct_finalize($this); |
|
215 | + //at least we can use the normalization strategy to populate the default |
|
216 | + if (isset($input_args['default'])) { |
|
217 | + $this->set_default($input_args['default']); |
|
218 | + } |
|
219 | + if (! $this->_sensitive_data_removal_strategy) { |
|
220 | + $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal(); |
|
221 | + } |
|
222 | + $this->_sensitive_data_removal_strategy->_construct_finalize($this); |
|
223 | + parent::__construct($input_args); |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + |
|
228 | + /** |
|
229 | + * Sets the html_name to its default value, if none was specified in teh constructor. |
|
230 | + * Calculation involves using the name and the parent's html_name |
|
231 | + * |
|
232 | + * @throws \EE_Error |
|
233 | + */ |
|
234 | + protected function _set_default_html_name_if_empty() |
|
235 | + { |
|
236 | + if (! $this->_html_name) { |
|
237 | + $this->_html_name = $this->name(); |
|
238 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
239 | + $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
|
240 | + } |
|
241 | + } |
|
242 | + } |
|
243 | + |
|
244 | + |
|
245 | + |
|
246 | + /** |
|
247 | + * @param $parent_form_section |
|
248 | + * @param $name |
|
249 | + * @throws \EE_Error |
|
250 | + */ |
|
251 | + public function _construct_finalize($parent_form_section, $name) |
|
252 | + { |
|
253 | + parent::_construct_finalize($parent_form_section, $name); |
|
254 | + if ($this->_html_label === null && $this->_html_label_text === null) { |
|
255 | + $this->_html_label_text = ucwords(str_replace("_", " ", $name)); |
|
256 | + } |
|
257 | + do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name); |
|
258 | + } |
|
259 | + |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * Returns the strategy for displaying this form input. If none is set, throws an exception. |
|
264 | + * |
|
265 | + * @return EE_Display_Strategy_Base |
|
266 | + * @throws EE_Error |
|
267 | + */ |
|
268 | + protected function _get_display_strategy() |
|
269 | + { |
|
270 | + $this->ensure_construct_finalized_called(); |
|
271 | + if (! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) { |
|
272 | + throw new EE_Error( |
|
273 | + sprintf( |
|
274 | + __( |
|
275 | + "Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", |
|
276 | + "event_espresso" |
|
277 | + ), |
|
278 | + $this->html_name(), |
|
279 | + $this->html_id() |
|
280 | + ) |
|
281 | + ); |
|
282 | + } else { |
|
283 | + return $this->_display_strategy; |
|
284 | + } |
|
285 | + } |
|
286 | + |
|
287 | + |
|
288 | + |
|
289 | + /** |
|
290 | + * Sets the display strategy. |
|
291 | + * |
|
292 | + * @param EE_Display_Strategy_Base $strategy |
|
293 | + */ |
|
294 | + protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) |
|
295 | + { |
|
296 | + $this->_display_strategy = $strategy; |
|
297 | + } |
|
298 | + |
|
299 | + |
|
300 | + |
|
301 | + /** |
|
302 | + * Sets the sanitization strategy |
|
303 | + * |
|
304 | + * @param EE_Normalization_Strategy_Base $strategy |
|
305 | + */ |
|
306 | + protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) |
|
307 | + { |
|
308 | + $this->_normalization_strategy = $strategy; |
|
309 | + } |
|
310 | + |
|
311 | + |
|
312 | + |
|
313 | + /** |
|
314 | + * Gets sensitive_data_removal_strategy |
|
315 | + * |
|
316 | + * @return EE_Sensitive_Data_Removal_Base |
|
317 | + */ |
|
318 | + public function get_sensitive_data_removal_strategy() |
|
319 | + { |
|
320 | + return $this->_sensitive_data_removal_strategy; |
|
321 | + } |
|
322 | + |
|
323 | + |
|
324 | + |
|
325 | + /** |
|
326 | + * Sets sensitive_data_removal_strategy |
|
327 | + * |
|
328 | + * @param EE_Sensitive_Data_Removal_Base $sensitive_data_removal_strategy |
|
329 | + * @return boolean |
|
330 | + */ |
|
331 | + public function set_sensitive_data_removal_strategy($sensitive_data_removal_strategy) |
|
332 | + { |
|
333 | + $this->_sensitive_data_removal_strategy = $sensitive_data_removal_strategy; |
|
334 | + } |
|
335 | + |
|
336 | + |
|
337 | + |
|
338 | + /** |
|
339 | + * Gets the display strategy for this input |
|
340 | + * |
|
341 | + * @return EE_Display_Strategy_Base |
|
342 | + */ |
|
343 | + public function get_display_strategy() |
|
344 | + { |
|
345 | + return $this->_display_strategy; |
|
346 | + } |
|
347 | + |
|
348 | + |
|
349 | + |
|
350 | + /** |
|
351 | + * Overwrites the display strategy |
|
352 | + * |
|
353 | + * @param EE_Display_Strategy_Base $display_strategy |
|
354 | + */ |
|
355 | + public function set_display_strategy($display_strategy) |
|
356 | + { |
|
357 | + $this->_display_strategy = $display_strategy; |
|
358 | + $this->_display_strategy->_construct_finalize($this); |
|
359 | + } |
|
360 | + |
|
361 | + |
|
362 | + |
|
363 | + /** |
|
364 | + * Gets the normalization strategy set on this input |
|
365 | + * |
|
366 | + * @return EE_Normalization_Strategy_Base |
|
367 | + */ |
|
368 | + public function get_normalization_strategy() |
|
369 | + { |
|
370 | + return $this->_normalization_strategy; |
|
371 | + } |
|
372 | + |
|
373 | + |
|
374 | + |
|
375 | + /** |
|
376 | + * Overwrites the normalization strategy |
|
377 | + * |
|
378 | + * @param EE_Normalization_Strategy_Base $normalization_strategy |
|
379 | + */ |
|
380 | + public function set_normalization_strategy($normalization_strategy) |
|
381 | + { |
|
382 | + $this->_normalization_strategy = $normalization_strategy; |
|
383 | + $this->_normalization_strategy->_construct_finalize($this); |
|
384 | + } |
|
385 | + |
|
386 | + |
|
387 | + |
|
388 | + /** |
|
389 | + * Returns all teh validation strategies which apply to this field, numerically indexed |
|
390 | + * |
|
391 | + * @return EE_Validation_Strategy_Base[] |
|
392 | + */ |
|
393 | + public function get_validation_strategies() |
|
394 | + { |
|
395 | + return $this->_validation_strategies; |
|
396 | + } |
|
397 | + |
|
398 | + |
|
399 | + |
|
400 | + /** |
|
401 | + * Adds this strategy to the field so it will be used in both JS validation and server-side validation |
|
402 | + * |
|
403 | + * @param EE_Validation_Strategy_Base $validation_strategy |
|
404 | + * @return void |
|
405 | + */ |
|
406 | + protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) |
|
407 | + { |
|
408 | + $validation_strategy->_construct_finalize($this); |
|
409 | + $this->_validation_strategies[] = $validation_strategy; |
|
410 | + } |
|
411 | + |
|
412 | + |
|
413 | + |
|
414 | + /** |
|
415 | + * Adds a new validation strategy onto the form input |
|
416 | + * |
|
417 | + * @param EE_Validation_Strategy_Base $validation_strategy |
|
418 | + * @return void |
|
419 | + */ |
|
420 | + public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) |
|
421 | + { |
|
422 | + $this->_add_validation_strategy($validation_strategy); |
|
423 | + } |
|
424 | + |
|
425 | + |
|
426 | + |
|
427 | + /** |
|
428 | + * The classname of the validation strategy to remove |
|
429 | + * |
|
430 | + * @param string $validation_strategy_classname |
|
431 | + */ |
|
432 | + public function remove_validation_strategy($validation_strategy_classname) |
|
433 | + { |
|
434 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
435 | + if ( |
|
436 | + $validation_strategy instanceof $validation_strategy_classname |
|
437 | + || is_subclass_of($validation_strategy, $validation_strategy_classname) |
|
438 | + ) { |
|
439 | + unset($this->_validation_strategies[$key]); |
|
440 | + } |
|
441 | + } |
|
442 | + } |
|
443 | + |
|
444 | + |
|
445 | + |
|
446 | + /** |
|
447 | + * returns true if input employs any of the validation strategy defined by the supplied array of classnames |
|
448 | + * |
|
449 | + * @param array $validation_strategy_classnames |
|
450 | + * @return bool |
|
451 | + */ |
|
452 | + public function has_validation_strategy($validation_strategy_classnames) |
|
453 | + { |
|
454 | + $validation_strategy_classnames = is_array($validation_strategy_classnames) |
|
455 | + ? $validation_strategy_classnames |
|
456 | + : array($validation_strategy_classnames); |
|
457 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
458 | + if (in_array($key, $validation_strategy_classnames)) { |
|
459 | + return true; |
|
460 | + } |
|
461 | + } |
|
462 | + return false; |
|
463 | + } |
|
464 | + |
|
465 | + |
|
466 | + |
|
467 | + /** |
|
468 | + * Gets the HTML |
|
469 | + * |
|
470 | + * @return string |
|
471 | + */ |
|
472 | + public function get_html() |
|
473 | + { |
|
474 | + return $this->_parent_section->get_html_for_input($this); |
|
475 | + } |
|
476 | + |
|
477 | + |
|
478 | + |
|
479 | + /** |
|
480 | + * Gets the HTML for the input itself (no label or errors) according to the |
|
481 | + * input's display strategy |
|
482 | + * Makes sure the JS and CSS are enqueued for it |
|
483 | + * |
|
484 | + * @return string |
|
485 | + * @throws \EE_Error |
|
486 | + */ |
|
487 | + public function get_html_for_input() |
|
488 | + { |
|
489 | + return $this->_form_html_filter |
|
490 | + ? $this->_form_html_filter->filterHtml( |
|
491 | + $this->_get_display_strategy()->display(), |
|
492 | + $this |
|
493 | + ) |
|
494 | + : $this->_get_display_strategy()->display(); |
|
495 | + } |
|
496 | + |
|
497 | + |
|
498 | + |
|
499 | + /** |
|
500 | + * @return string |
|
501 | + */ |
|
502 | + public function html_other_attributes() |
|
503 | + { |
|
504 | + return ! empty($this->_html_other_attributes) ? ' ' . $this->_html_other_attributes : ''; |
|
505 | + } |
|
506 | + |
|
507 | + |
|
508 | + |
|
509 | + /** |
|
510 | + * @param string $html_other_attributes |
|
511 | + */ |
|
512 | + public function set_html_other_attributes($html_other_attributes) |
|
513 | + { |
|
514 | + $this->_html_other_attributes = $html_other_attributes; |
|
515 | + } |
|
516 | + |
|
517 | + |
|
518 | + |
|
519 | + /** |
|
520 | + * Gets the HTML for displaying the label for this form input |
|
521 | + * according to the form section's layout strategy |
|
522 | + * |
|
523 | + * @return string |
|
524 | + */ |
|
525 | + public function get_html_for_label() |
|
526 | + { |
|
527 | + return $this->_parent_section->get_layout_strategy()->display_label($this); |
|
528 | + } |
|
529 | + |
|
530 | + |
|
531 | + |
|
532 | + /** |
|
533 | + * Gets the HTML for displaying the errors section for this form input |
|
534 | + * according to the form section's layout strategy |
|
535 | + * |
|
536 | + * @return string |
|
537 | + */ |
|
538 | + public function get_html_for_errors() |
|
539 | + { |
|
540 | + return $this->_parent_section->get_layout_strategy()->display_errors($this); |
|
541 | + } |
|
542 | + |
|
543 | + |
|
544 | + |
|
545 | + /** |
|
546 | + * Gets the HTML for displaying the help text for this form input |
|
547 | + * according to the form section's layout strategy |
|
548 | + * |
|
549 | + * @return string |
|
550 | + */ |
|
551 | + public function get_html_for_help() |
|
552 | + { |
|
553 | + return $this->_parent_section->get_layout_strategy()->display_help_text($this); |
|
554 | + } |
|
555 | + |
|
556 | + |
|
557 | + |
|
558 | + /** |
|
559 | + * Validates the input's sanitized value (assumes _sanitize() has already been called) |
|
560 | + * and returns whether or not the form input's submitted value is value |
|
561 | + * |
|
562 | + * @return boolean |
|
563 | + */ |
|
564 | + protected function _validate() |
|
565 | + { |
|
566 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
567 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
568 | + try { |
|
569 | + $validation_strategy->validate($this->normalized_value()); |
|
570 | + } catch (EE_Validation_Error $e) { |
|
571 | + $this->add_validation_error($e); |
|
572 | + } |
|
573 | + } |
|
574 | + } |
|
575 | + if ($this->get_validation_errors()) { |
|
576 | + return false; |
|
577 | + } else { |
|
578 | + return true; |
|
579 | + } |
|
580 | + } |
|
581 | + |
|
582 | + |
|
583 | + |
|
584 | + /** |
|
585 | + * Performs basic sanitization on this value. But what sanitization can be performed anyways? |
|
586 | + * This value MIGHT be allowed to have tags, so we can't really remove them. |
|
587 | + * |
|
588 | + * @param string $value |
|
589 | + * @return null|string |
|
590 | + */ |
|
591 | + private function _sanitize($value) |
|
592 | + { |
|
593 | + return $value !== null ? stripslashes(html_entity_decode(trim($value))) : null; |
|
594 | + } |
|
595 | + |
|
596 | + |
|
597 | + |
|
598 | + /** |
|
599 | + * Picks out the form value that relates to this form input, |
|
600 | + * and stores it as the sanitized value on the form input, and sets the normalized value. |
|
601 | + * Returns whether or not any validation errors occurred |
|
602 | + * |
|
603 | + * @param array $req_data like $_POST |
|
604 | + * @return boolean whether or not there was an error |
|
605 | + * @throws \EE_Error |
|
606 | + */ |
|
607 | + protected function _normalize($req_data) |
|
608 | + { |
|
609 | + //any existing validation errors don't apply so clear them |
|
610 | + $this->_validation_errors = array(); |
|
611 | + try { |
|
612 | + $raw_input = $this->find_form_data_for_this_section($req_data); |
|
613 | + //super simple sanitization for now |
|
614 | + if (is_array($raw_input)) { |
|
615 | + $raw_value = array(); |
|
616 | + foreach ($raw_input as $key => $value) { |
|
617 | + $raw_value[$key] = $this->_sanitize($value); |
|
618 | + } |
|
619 | + $this->_set_raw_value($raw_value); |
|
620 | + } else { |
|
621 | + $this->_set_raw_value($this->_sanitize($raw_input)); |
|
622 | + } |
|
623 | + //we want to mostly leave the input alone in case we need to re-display it to the user |
|
624 | + $this->_set_normalized_value($this->_normalization_strategy->normalize($this->raw_value())); |
|
625 | + } catch (EE_Validation_Error $e) { |
|
626 | + $this->add_validation_error($e); |
|
627 | + } |
|
628 | + } |
|
629 | + |
|
630 | + |
|
631 | + |
|
632 | + /** |
|
633 | + * @return string |
|
634 | + */ |
|
635 | + public function html_name() |
|
636 | + { |
|
637 | + $this->_set_default_html_name_if_empty(); |
|
638 | + return $this->_html_name; |
|
639 | + } |
|
640 | + |
|
641 | + |
|
642 | + |
|
643 | + /** |
|
644 | + * @return string |
|
645 | + */ |
|
646 | + public function html_label_id() |
|
647 | + { |
|
648 | + return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id . '-lbl'; |
|
649 | + } |
|
650 | + |
|
651 | + |
|
652 | + |
|
653 | + /** |
|
654 | + * @return string |
|
655 | + */ |
|
656 | + public function html_label_class() |
|
657 | + { |
|
658 | + return $this->_html_label_class; |
|
659 | + } |
|
660 | + |
|
661 | + |
|
662 | + |
|
663 | + /** |
|
664 | + * @return string |
|
665 | + */ |
|
666 | + public function html_label_style() |
|
667 | + { |
|
668 | + return $this->_html_label_style; |
|
669 | + } |
|
670 | + |
|
671 | + |
|
672 | + |
|
673 | + /** |
|
674 | + * @return string |
|
675 | + */ |
|
676 | + public function html_label_text() |
|
677 | + { |
|
678 | + return $this->_html_label_text; |
|
679 | + } |
|
680 | + |
|
681 | + |
|
682 | + |
|
683 | + /** |
|
684 | + * @return string |
|
685 | + */ |
|
686 | + public function html_help_text() |
|
687 | + { |
|
688 | + return $this->_html_help_text; |
|
689 | + } |
|
690 | + |
|
691 | + |
|
692 | + |
|
693 | + /** |
|
694 | + * @return string |
|
695 | + */ |
|
696 | + public function html_help_class() |
|
697 | + { |
|
698 | + return $this->_html_help_class; |
|
699 | + } |
|
700 | + |
|
701 | + |
|
702 | + |
|
703 | + /** |
|
704 | + * @return string |
|
705 | + */ |
|
706 | + public function html_help_style() |
|
707 | + { |
|
708 | + return $this->_html_style; |
|
709 | + } |
|
710 | + |
|
711 | + |
|
712 | + |
|
713 | + /** |
|
714 | + * returns the raw, UNSAFE, input, almost exactly as the user submitted it. |
|
715 | + * Please note that almost all client code should instead use the normalized_value; |
|
716 | + * or possibly raw_value_in_form (which prepares the string for displaying in an HTML attribute on a tag, |
|
717 | + * mostly by escaping quotes) |
|
718 | + * Note, we do not store the exact original value sent in the user's request because |
|
719 | + * it may have malicious content, and we MIGHT want to store the form input in a transient or something... |
|
720 | + * in which case, we would have stored the malicious content to our database. |
|
721 | + * |
|
722 | + * @return string |
|
723 | + */ |
|
724 | + public function raw_value() |
|
725 | + { |
|
726 | + return $this->_raw_value; |
|
727 | + } |
|
728 | + |
|
729 | + |
|
730 | + |
|
731 | + /** |
|
732 | + * Returns a string safe to usage in form inputs when displaying, because |
|
733 | + * it escapes all html entities |
|
734 | + * |
|
735 | + * @return string |
|
736 | + */ |
|
737 | + public function raw_value_in_form() |
|
738 | + { |
|
739 | + return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8'); |
|
740 | + } |
|
741 | + |
|
742 | + |
|
743 | + |
|
744 | + /** |
|
745 | + * returns the value after it's been sanitized, and then converted into it's proper type |
|
746 | + * in PHP. Eg, a string, an int, an array, |
|
747 | + * |
|
748 | + * @return mixed |
|
749 | + */ |
|
750 | + public function normalized_value() |
|
751 | + { |
|
752 | + return $this->_normalized_value; |
|
753 | + } |
|
754 | + |
|
755 | + |
|
756 | + |
|
757 | + /** |
|
758 | + * Returns the normalized value is a presentable way. By default this is just |
|
759 | + * the normalized value by itself, but it can be overridden for when that's not |
|
760 | + * the best thing to display |
|
761 | + * |
|
762 | + * @return string |
|
763 | + */ |
|
764 | + public function pretty_value() |
|
765 | + { |
|
766 | + return $this->_normalized_value; |
|
767 | + } |
|
768 | + |
|
769 | + |
|
770 | + |
|
771 | + /** |
|
772 | + * When generating the JS for the jquery validation rules like<br> |
|
773 | + * <code>$( "#myform" ).validate({ |
|
774 | + * rules: { |
|
775 | + * password: "required", |
|
776 | + * password_again: { |
|
777 | + * equalTo: "#password" |
|
778 | + * } |
|
779 | + * } |
|
780 | + * });</code> |
|
781 | + * if this field had the name 'password_again', it should return |
|
782 | + * <br><code>password_again: { |
|
783 | + * equalTo: "#password" |
|
784 | + * }</code> |
|
785 | + * |
|
786 | + * @return array |
|
787 | + */ |
|
788 | + public function get_jquery_validation_rules() |
|
789 | + { |
|
790 | + $jquery_validation_js = array(); |
|
791 | + $jquery_validation_rules = array(); |
|
792 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
793 | + $jquery_validation_rules = array_replace_recursive( |
|
794 | + $jquery_validation_rules, |
|
795 | + $validation_strategy->get_jquery_validation_rule_array() |
|
796 | + ); |
|
797 | + } |
|
798 | + if (! empty($jquery_validation_rules)) { |
|
799 | + foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) { |
|
800 | + $jquery_validation_js[$html_id_with_pound_sign] = $jquery_validation_rules; |
|
801 | + } |
|
802 | + } |
|
803 | + return $jquery_validation_js; |
|
804 | + } |
|
805 | + |
|
806 | + |
|
807 | + |
|
808 | + /** |
|
809 | + * Sets the input's default value for use in displaying in the form. Note: value should be |
|
810 | + * normalized (Eg, if providing a default of ra Yes_NO_Input you would provide TRUE or FALSE, not '1' or '0') |
|
811 | + * |
|
812 | + * @param mixed $value |
|
813 | + * @return void |
|
814 | + */ |
|
815 | + public function set_default($value) |
|
816 | + { |
|
817 | + $this->_set_normalized_value($value); |
|
818 | + $this->_set_raw_value($value); |
|
819 | + } |
|
820 | + |
|
821 | + |
|
822 | + |
|
823 | + /** |
|
824 | + * Sets the normalized value on this input |
|
825 | + * |
|
826 | + * @param mixed $value |
|
827 | + */ |
|
828 | + protected function _set_normalized_value($value) |
|
829 | + { |
|
830 | + $this->_normalized_value = $value; |
|
831 | + } |
|
832 | + |
|
833 | + |
|
834 | + |
|
835 | + /** |
|
836 | + * Sets the raw value on this input (ie, exactly as the user submitted it) |
|
837 | + * |
|
838 | + * @param mixed $value |
|
839 | + */ |
|
840 | + protected function _set_raw_value($value) |
|
841 | + { |
|
842 | + $this->_raw_value = $this->_normalization_strategy->unnormalize($value); |
|
843 | + } |
|
844 | + |
|
845 | + |
|
846 | + |
|
847 | + /** |
|
848 | + * Sets the HTML label text after it has already been defined |
|
849 | + * |
|
850 | + * @param string $label |
|
851 | + * @return void |
|
852 | + */ |
|
853 | + public function set_html_label_text($label) |
|
854 | + { |
|
855 | + $this->_html_label_text = $label; |
|
856 | + } |
|
857 | + |
|
858 | + |
|
859 | + |
|
860 | + /** |
|
861 | + * Sets whether or not this field is required, and adjusts the validation strategy. |
|
862 | + * If you want to use the EE_Conditionally_Required_Validation_Strategy, |
|
863 | + * please add it as a validation strategy using add_validation_strategy as normal |
|
864 | + * |
|
865 | + * @param boolean $required boolean |
|
866 | + * @param null $required_text |
|
867 | + */ |
|
868 | + public function set_required($required = true, $required_text = null) |
|
869 | + { |
|
870 | + $required = filter_var($required, FILTER_VALIDATE_BOOLEAN); |
|
871 | + //whether $required is a string or a boolean, we want to add a required validation strategy |
|
872 | + if ($required) { |
|
873 | + $this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text)); |
|
874 | + } else { |
|
875 | + $this->remove_validation_strategy('EE_Required_Validation_Strategy'); |
|
876 | + } |
|
877 | + $this->_required = $required; |
|
878 | + } |
|
879 | + |
|
880 | + |
|
881 | + |
|
882 | + /** |
|
883 | + * Returns whether or not this field is required |
|
884 | + * |
|
885 | + * @return boolean |
|
886 | + */ |
|
887 | + public function required() |
|
888 | + { |
|
889 | + return $this->_required; |
|
890 | + } |
|
891 | + |
|
892 | + |
|
893 | + |
|
894 | + /** |
|
895 | + * @param string $required_css_class |
|
896 | + */ |
|
897 | + public function set_required_css_class($required_css_class) |
|
898 | + { |
|
899 | + $this->_required_css_class = $required_css_class; |
|
900 | + } |
|
901 | + |
|
902 | + |
|
903 | + |
|
904 | + /** |
|
905 | + * @return string |
|
906 | + */ |
|
907 | + public function required_css_class() |
|
908 | + { |
|
909 | + return $this->_required_css_class; |
|
910 | + } |
|
911 | + |
|
912 | + |
|
913 | + |
|
914 | + /** |
|
915 | + * Sets the help text, in case |
|
916 | + * |
|
917 | + * @param string $text |
|
918 | + */ |
|
919 | + public function set_html_help_text($text) |
|
920 | + { |
|
921 | + $this->_html_help_text = $text; |
|
922 | + } |
|
923 | + |
|
924 | + |
|
925 | + |
|
926 | + /** |
|
927 | + * Uses the sensitive data removal strategy to remove the sensitive data from this |
|
928 | + * input. If there is any kind of sensitive data removal on this input, we clear |
|
929 | + * out the raw value completely |
|
930 | + * |
|
931 | + * @return void |
|
932 | + */ |
|
933 | + public function clean_sensitive_data() |
|
934 | + { |
|
935 | + //if we do ANY kind of sensitive data removal on this, then just clear out the raw value |
|
936 | + //if we need more logic than this we'll make a strategy for it |
|
937 | + if ($this->_sensitive_data_removal_strategy |
|
938 | + && ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal |
|
939 | + ) { |
|
940 | + $this->_set_raw_value(null); |
|
941 | + } |
|
942 | + //and clean the normalized value according to the appropriate strategy |
|
943 | + $this->_set_normalized_value( |
|
944 | + $this->get_sensitive_data_removal_strategy()->remove_sensitive_data( |
|
945 | + $this->_normalized_value |
|
946 | + ) |
|
947 | + ); |
|
948 | + } |
|
949 | + |
|
950 | + |
|
951 | + |
|
952 | + /** |
|
953 | + * @param bool $primary |
|
954 | + * @param string $button_size |
|
955 | + * @param string $other_attributes |
|
956 | + */ |
|
957 | + public function set_button_css_attributes($primary = true, $button_size = '', $other_attributes = '') |
|
958 | + { |
|
959 | + $button_css_attributes = 'button'; |
|
960 | + $button_css_attributes .= $primary === true ? ' button-primary' : ' button-secondary'; |
|
961 | + switch ($button_size) { |
|
962 | + case 'xs' : |
|
963 | + case 'extra-small' : |
|
964 | + $button_css_attributes .= ' button-xs'; |
|
965 | + break; |
|
966 | + case 'sm' : |
|
967 | + case 'small' : |
|
968 | + $button_css_attributes .= ' button-sm'; |
|
969 | + break; |
|
970 | + case 'lg' : |
|
971 | + case 'large' : |
|
972 | + $button_css_attributes .= ' button-lg'; |
|
973 | + break; |
|
974 | + case 'block' : |
|
975 | + $button_css_attributes .= ' button-block'; |
|
976 | + break; |
|
977 | + case 'md' : |
|
978 | + case 'medium' : |
|
979 | + default : |
|
980 | + $button_css_attributes .= ''; |
|
981 | + } |
|
982 | + $this->_button_css_attributes .= ! empty($other_attributes) |
|
983 | + ? $button_css_attributes . ' ' . $other_attributes |
|
984 | + : $button_css_attributes; |
|
985 | + } |
|
986 | + |
|
987 | + |
|
988 | + |
|
989 | + /** |
|
990 | + * @return string |
|
991 | + */ |
|
992 | + public function button_css_attributes() |
|
993 | + { |
|
994 | + if (empty($this->_button_css_attributes)) { |
|
995 | + $this->set_button_css_attributes(); |
|
996 | + } |
|
997 | + return $this->_button_css_attributes; |
|
998 | + } |
|
999 | + |
|
1000 | + |
|
1001 | + |
|
1002 | + /** |
|
1003 | + * find_form_data_for_this_section |
|
1004 | + * using this section's name and its parents, finds the value of the form data that corresponds to it. |
|
1005 | + * For example, if this form section's HTML name is my_form[subform][form_input_1], |
|
1006 | + * then it's value should be in $_REQUEST at $_REQUEST['my_form']['subform']['form_input_1']. |
|
1007 | + * (If that doesn't exist, we also check for this subsection's name |
|
1008 | + * at the TOP LEVEL of the request data. Eg $_REQUEST['form_input_1'].) |
|
1009 | + * This function finds its value in the form. |
|
1010 | + * |
|
1011 | + * @param array $req_data |
|
1012 | + * @return mixed whatever the raw value of this form section is in the request data |
|
1013 | + * @throws \EE_Error |
|
1014 | + */ |
|
1015 | + public function find_form_data_for_this_section($req_data) |
|
1016 | + { |
|
1017 | + // break up the html name by "[]" |
|
1018 | + if (strpos($this->html_name(), '[') !== false) { |
|
1019 | + $before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '[')); |
|
1020 | + } else { |
|
1021 | + $before_any_brackets = $this->html_name(); |
|
1022 | + } |
|
1023 | + // grab all of the segments |
|
1024 | + preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches); |
|
1025 | + if (isset($matches[1]) && is_array($matches[1])) { |
|
1026 | + $name_parts = $matches[1]; |
|
1027 | + array_unshift($name_parts, $before_any_brackets); |
|
1028 | + } else { |
|
1029 | + $name_parts = array($before_any_brackets); |
|
1030 | + } |
|
1031 | + // now get the value for the input |
|
1032 | + $value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data); |
|
1033 | + // check if this thing's name is at the TOP level of the request data |
|
1034 | + if ($value === null && isset($req_data[$this->name()])) { |
|
1035 | + $value = $req_data[$this->name()]; |
|
1036 | + } |
|
1037 | + return $value; |
|
1038 | + } |
|
1039 | + |
|
1040 | + |
|
1041 | + |
|
1042 | + /** |
|
1043 | + * @param array $html_name_parts |
|
1044 | + * @param array $req_data |
|
1045 | + * @return array | NULL |
|
1046 | + */ |
|
1047 | + public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) |
|
1048 | + { |
|
1049 | + $first_part_to_consider = array_shift($html_name_parts); |
|
1050 | + if (isset($req_data[$first_part_to_consider])) { |
|
1051 | + if (empty($html_name_parts)) { |
|
1052 | + return $req_data[$first_part_to_consider]; |
|
1053 | + } else { |
|
1054 | + return $this->_find_form_data_for_this_section_using_name_parts( |
|
1055 | + $html_name_parts, |
|
1056 | + $req_data[$first_part_to_consider] |
|
1057 | + ); |
|
1058 | + } |
|
1059 | + } else { |
|
1060 | + return null; |
|
1061 | + } |
|
1062 | + } |
|
1063 | + |
|
1064 | + |
|
1065 | + |
|
1066 | + /** |
|
1067 | + * Checks if this form input's data is in the request data |
|
1068 | + * |
|
1069 | + * @param array $req_data like $_POST |
|
1070 | + * @return boolean |
|
1071 | + * @throws \EE_Error |
|
1072 | + */ |
|
1073 | + public function form_data_present_in($req_data = null) |
|
1074 | + { |
|
1075 | + if ($req_data === null) { |
|
1076 | + $req_data = $_POST; |
|
1077 | + } |
|
1078 | + $checked_value = $this->find_form_data_for_this_section($req_data); |
|
1079 | + if ($checked_value !== null) { |
|
1080 | + return true; |
|
1081 | + } else { |
|
1082 | + return false; |
|
1083 | + } |
|
1084 | + } |
|
1085 | + |
|
1086 | + |
|
1087 | + |
|
1088 | + /** |
|
1089 | + * Overrides parent to add js data from validation and display strategies |
|
1090 | + * |
|
1091 | + * @param array $form_other_js_data |
|
1092 | + * @return array |
|
1093 | + */ |
|
1094 | + public function get_other_js_data($form_other_js_data = array()) |
|
1095 | + { |
|
1096 | + $form_other_js_data = $this->get_other_js_data_from_strategies($form_other_js_data); |
|
1097 | + return $form_other_js_data; |
|
1098 | + } |
|
1099 | + |
|
1100 | + |
|
1101 | + |
|
1102 | + /** |
|
1103 | + * Gets other JS data for localization from this input's strategies, like |
|
1104 | + * the validation strategies and the display strategy |
|
1105 | + * |
|
1106 | + * @param array $form_other_js_data |
|
1107 | + * @return array |
|
1108 | + */ |
|
1109 | + public function get_other_js_data_from_strategies($form_other_js_data = array()) |
|
1110 | + { |
|
1111 | + $form_other_js_data = $this->get_display_strategy()->get_other_js_data($form_other_js_data); |
|
1112 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
1113 | + $form_other_js_data = $validation_strategy->get_other_js_data($form_other_js_data); |
|
1114 | + } |
|
1115 | + return $form_other_js_data; |
|
1116 | + } |
|
1117 | + |
|
1118 | + |
|
1119 | + |
|
1120 | + /** |
|
1121 | + * Override parent because we want to give our strategies an opportunity to enqueue some js and css |
|
1122 | + * |
|
1123 | + * @return void |
|
1124 | + */ |
|
1125 | + public function enqueue_js() |
|
1126 | + { |
|
1127 | + //ask our display strategy and validation strategies if they have js to enqueue |
|
1128 | + $this->enqueue_js_from_strategies(); |
|
1129 | + } |
|
1130 | + |
|
1131 | + |
|
1132 | + |
|
1133 | + /** |
|
1134 | + * Tells strategies when its ok to enqueue their js and css |
|
1135 | + * |
|
1136 | + * @return void |
|
1137 | + */ |
|
1138 | + public function enqueue_js_from_strategies() |
|
1139 | + { |
|
1140 | + $this->get_display_strategy()->enqueue_js(); |
|
1141 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
1142 | + $validation_strategy->enqueue_js(); |
|
1143 | + } |
|
1144 | + } |
|
1145 | 1145 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | |
250 | 250 | /** |
251 | 251 | * @access public |
252 | - * @return string |
|
252 | + * @return boolean |
|
253 | 253 | */ |
254 | 254 | public static function is_iframe() { |
255 | 255 | return \EED_Events_Archive::$iframe; |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | * display_description |
723 | 723 | * |
724 | 724 | * @access public |
725 | - * @param $value |
|
725 | + * @param integer $value |
|
726 | 726 | * @return bool |
727 | 727 | */ |
728 | 728 | public static function display_description( $value ) { |
@@ -37,19 +37,19 @@ discard block |
||
37 | 37 | */ |
38 | 38 | protected static $using_get_the_excerpt = false; |
39 | 39 | |
40 | - /** |
|
41 | - * Used to flag when the event list is being called from an external iframe. |
|
42 | - * |
|
43 | - * @var bool $iframe |
|
44 | - */ |
|
45 | - protected static $iframe = false; |
|
46 | - |
|
47 | - /** |
|
40 | + /** |
|
41 | + * Used to flag when the event list is being called from an external iframe. |
|
42 | + * |
|
43 | + * @var bool $iframe |
|
44 | + */ |
|
45 | + protected static $iframe = false; |
|
46 | + |
|
47 | + /** |
|
48 | 48 | * @var \EventEspresso\core\libraries\iframe_display\EventListIframeEmbedButton $_iframe_embed_button |
49 | 49 | */ |
50 | 50 | private static $_iframe_embed_button; |
51 | 51 | |
52 | - /** |
|
52 | + /** |
|
53 | 53 | * @type EE_Template_Part_Manager $template_parts |
54 | 54 | */ |
55 | 55 | protected $template_parts; |
@@ -233,36 +233,36 @@ discard block |
||
233 | 233 | |
234 | 234 | |
235 | 235 | |
236 | - /** |
|
237 | - * @access public |
|
238 | - * @return void |
|
239 | - * @throws \EE_Error |
|
240 | - * @throws \DomainException |
|
241 | - */ |
|
236 | + /** |
|
237 | + * @access public |
|
238 | + * @return void |
|
239 | + * @throws \EE_Error |
|
240 | + * @throws \DomainException |
|
241 | + */ |
|
242 | 242 | public function event_list_iframe() { |
243 | - \EED_Events_Archive::$iframe = true; |
|
243 | + \EED_Events_Archive::$iframe = true; |
|
244 | 244 | $event_list_iframe = new EventsArchiveIframe( $this ); |
245 | 245 | $event_list_iframe->display(); |
246 | 246 | } |
247 | 247 | |
248 | 248 | |
249 | 249 | |
250 | - /** |
|
251 | - * @access public |
|
252 | - * @return string |
|
253 | - */ |
|
250 | + /** |
|
251 | + * @access public |
|
252 | + * @return string |
|
253 | + */ |
|
254 | 254 | public static function is_iframe() { |
255 | - return \EED_Events_Archive::$iframe; |
|
255 | + return \EED_Events_Archive::$iframe; |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | |
259 | 259 | |
260 | - /** |
|
261 | - * @access public |
|
262 | - * @return string |
|
263 | - */ |
|
260 | + /** |
|
261 | + * @access public |
|
262 | + * @return string |
|
263 | + */ |
|
264 | 264 | public static function link_target() { |
265 | - return \EED_Events_Archive::$iframe ? ' target="_blank"' : ''; |
|
265 | + return \EED_Events_Archive::$iframe ? ' target="_blank"' : ''; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | * @return void |
601 | 601 | */ |
602 | 602 | public function load_event_list_assets() { |
603 | - do_action( 'AHEE__EED_Events_Archive__before_load_assets' ); |
|
603 | + do_action( 'AHEE__EED_Events_Archive__before_load_assets' ); |
|
604 | 604 | add_filter( 'FHEE_load_EE_Session', '__return_true' ); |
605 | 605 | add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
606 | 606 | add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 ); |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | use EventEspresso\core\libraries\iframe_display\EventListIframeEmbedButton; |
4 | 4 | use EventEspresso\modules\events_archive\EventsArchiveIframe; |
5 | 5 | |
6 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
6 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
7 | 7 | /** |
8 | 8 | * Event Espresso |
9 | 9 | * |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @return EED_Events_Archive |
61 | 61 | */ |
62 | 62 | public static function instance() { |
63 | - return parent::get_instance( __CLASS__ ); |
|
63 | + return parent::get_instance(__CLASS__); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | * @return void |
73 | 73 | */ |
74 | 74 | public static function set_hooks() { |
75 | - EE_Config::register_route( EE_Registry::instance()->CFG->core->event_cpt_slug, 'Events_Archive', 'run' ); |
|
76 | - EE_Config::register_route( 'event_list', 'Events_Archive', 'event_list' ); |
|
77 | - EE_Config::register_route( 'iframe', 'Events_Archive', 'event_list_iframe', 'event_list' ); |
|
78 | - add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 ); |
|
75 | + EE_Config::register_route(EE_Registry::instance()->CFG->core->event_cpt_slug, 'Events_Archive', 'run'); |
|
76 | + EE_Config::register_route('event_list', 'Events_Archive', 'event_list'); |
|
77 | + EE_Config::register_route('iframe', 'Events_Archive', 'event_list_iframe', 'event_list'); |
|
78 | + add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | * @return void |
86 | 86 | */ |
87 | 87 | public static function set_hooks_admin() { |
88 | - add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 ); |
|
88 | + add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
89 | 89 | // hook into the end of the \EE_Admin_Page::_load_page_dependencies() |
90 | 90 | // to load assets for "espresso_events" page on the "default" route (action) |
91 | 91 | add_action( |
92 | 92 | 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__default', |
93 | - array( 'EED_Events_Archive', 'event_list_iframe_embed_button' ), |
|
93 | + array('EED_Events_Archive', 'event_list_iframe_embed_button'), |
|
94 | 94 | 10 |
95 | 95 | ); |
96 | 96 | } |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * @return void |
106 | 106 | */ |
107 | 107 | public static function set_definitions() { |
108 | - define( 'EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
109 | - define( 'EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
108 | + define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
109 | + define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | /** |
115 | 115 | * set up EE_Events_Archive_Config |
116 | 116 | */ |
117 | - protected function set_config(){ |
|
118 | - $this->set_config_section( 'template_settings' ); |
|
119 | - $this->set_config_class( 'EE_Events_Archive_Config' ); |
|
120 | - $this->set_config_name( 'EED_Events_Archive' ); |
|
117 | + protected function set_config() { |
|
118 | + $this->set_config_section('template_settings'); |
|
119 | + $this->set_config_class('EE_Events_Archive_Config'); |
|
120 | + $this->set_config_name('EED_Events_Archive'); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @return EventListIframeEmbedButton |
127 | 127 | */ |
128 | 128 | public static function get_iframe_embed_button() { |
129 | - if ( ! self::$_iframe_embed_button instanceof EventListIframeEmbedButton ) { |
|
129 | + if ( ! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) { |
|
130 | 130 | self::$_iframe_embed_button = new EventListIframeEmbedButton(); |
131 | 131 | } |
132 | 132 | return self::$_iframe_embed_button; |
@@ -152,35 +152,35 @@ discard block |
||
152 | 152 | * @param \EE_Events_Archive_Config $config |
153 | 153 | * @return \EE_Template_Part_Manager |
154 | 154 | */ |
155 | - public function initialize_template_parts( EE_Events_Archive_Config $config = null ) { |
|
155 | + public function initialize_template_parts(EE_Events_Archive_Config $config = null) { |
|
156 | 156 | $config = $config instanceof EE_Events_Archive_Config ? $config : $this->config(); |
157 | 157 | EEH_Autoloader::instance()->register_template_part_autoloaders(); |
158 | 158 | $template_parts = new EE_Template_Part_Manager(); |
159 | 159 | $template_parts->add_template_part( |
160 | 160 | 'tickets', |
161 | - __( 'Ticket Selector', 'event_espresso' ), |
|
161 | + __('Ticket Selector', 'event_espresso'), |
|
162 | 162 | 'content-espresso_events-tickets.php', |
163 | 163 | $config->display_order_tickets |
164 | 164 | ); |
165 | 165 | $template_parts->add_template_part( |
166 | 166 | 'datetimes', |
167 | - __( 'Dates and Times', 'event_espresso' ), |
|
167 | + __('Dates and Times', 'event_espresso'), |
|
168 | 168 | 'content-espresso_events-datetimes.php', |
169 | 169 | $config->display_order_datetimes |
170 | 170 | ); |
171 | 171 | $template_parts->add_template_part( |
172 | 172 | 'event', |
173 | - __( 'Event Description', 'event_espresso' ), |
|
173 | + __('Event Description', 'event_espresso'), |
|
174 | 174 | 'content-espresso_events-details.php', |
175 | 175 | $config->display_order_event |
176 | 176 | ); |
177 | 177 | $template_parts->add_template_part( |
178 | 178 | 'venue', |
179 | - __( 'Venue Information', 'event_espresso' ), |
|
179 | + __('Venue Information', 'event_espresso'), |
|
180 | 180 | 'content-espresso_events-venues.php', |
181 | 181 | $config->display_order_venue |
182 | 182 | ); |
183 | - do_action( 'AHEE__EED_Event_Archive__initialize_template_parts', $template_parts ); |
|
183 | + do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts); |
|
184 | 184 | return $template_parts; |
185 | 185 | } |
186 | 186 | |
@@ -193,8 +193,8 @@ discard block |
||
193 | 193 | * @param WP $WP |
194 | 194 | * @return void |
195 | 195 | */ |
196 | - public function run( $WP ) { |
|
197 | - do_action( 'AHEE__EED_Events_Archive__before_run' ); |
|
196 | + public function run($WP) { |
|
197 | + do_action('AHEE__EED_Events_Archive__before_run'); |
|
198 | 198 | // ensure valid EE_Events_Archive_Config() object exists |
199 | 199 | $this->set_config(); |
200 | 200 | /** @type EE_Events_Archive_Config $config */ |
@@ -206,14 +206,14 @@ discard block |
||
206 | 206 | EEH_Event_Query::add_query_filters(); |
207 | 207 | // set params that will get used by the filters |
208 | 208 | EEH_Event_Query::set_query_params( |
209 | - '', // month |
|
210 | - '', // category |
|
211 | - $config->display_expired_events, // show_expired |
|
212 | - 'start_date', // orderby |
|
209 | + '', // month |
|
210 | + '', // category |
|
211 | + $config->display_expired_events, // show_expired |
|
212 | + 'start_date', // orderby |
|
213 | 213 | 'ASC' // sort |
214 | 214 | ); |
215 | 215 | // check what template is loaded |
216 | - add_filter( 'template_include', array( $this, 'template_include' ), 999, 1 ); |
|
216 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function event_list_iframe() { |
243 | 243 | \EED_Events_Archive::$iframe = true; |
244 | - $event_list_iframe = new EventsArchiveIframe( $this ); |
|
244 | + $event_list_iframe = new EventsArchiveIframe($this); |
|
245 | 245 | $event_list_iframe->display(); |
246 | 246 | } |
247 | 247 | |
@@ -279,32 +279,32 @@ discard block |
||
279 | 279 | * @param string $template |
280 | 280 | * @return string |
281 | 281 | */ |
282 | - public function template_include( $template = '' ) { |
|
282 | + public function template_include($template = '') { |
|
283 | 283 | // don't add content filter for dedicated EE child themes or private posts |
284 | - if ( ! EEH_Template::is_espresso_theme() ) { |
|
284 | + if ( ! EEH_Template::is_espresso_theme()) { |
|
285 | 285 | /** @type EE_Events_Archive_Config $config */ |
286 | 286 | $config = $this->config(); |
287 | 287 | // add status banner ? |
288 | - if ( $config->display_status_banner ) { |
|
289 | - add_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 100, 2 ); |
|
288 | + if ($config->display_status_banner) { |
|
289 | + add_filter('the_title', array('EED_Events_Archive', 'the_title'), 100, 2); |
|
290 | 290 | } |
291 | 291 | // if NOT a custom template |
292 | 292 | if ( |
293 | - EE_Registry::instance()->load_core( 'Front_Controller', array(), false, true )->get_selected_template() != 'archive-espresso_events.php' |
|
294 | - || apply_filters( 'FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', FALSE ) |
|
293 | + EE_Registry::instance()->load_core('Front_Controller', array(), false, true)->get_selected_template() != 'archive-espresso_events.php' |
|
294 | + || apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', FALSE) |
|
295 | 295 | ) { |
296 | 296 | // don't display entry meta because the existing theme will take care of that |
297 | - add_filter( 'FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true' ); |
|
297 | + add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true'); |
|
298 | 298 | // load functions.php file for the theme (loaded by WP if using child theme) |
299 | 299 | EEH_Template::load_espresso_theme_functions(); |
300 | 300 | // because we don't know if the theme is using the_excerpt() |
301 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
|
301 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 100, 1); |
|
302 | 302 | // or the_content |
303 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
|
303 | + add_filter('the_content', array('EED_Events_Archive', 'event_details'), 100, 1); |
|
304 | 304 | // and just in case they are running get_the_excerpt() which DESTROYS things |
305 | - add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
|
305 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
306 | 306 | // don't display entry meta because the existing theme will take care of that |
307 | - add_filter( 'FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false' ); |
|
307 | + add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
308 | 308 | } |
309 | 309 | } |
310 | 310 | return $template; |
@@ -319,17 +319,17 @@ discard block |
||
319 | 319 | * @param string $excerpt |
320 | 320 | * @return string |
321 | 321 | */ |
322 | - public static function get_the_excerpt( $excerpt = '' ) { |
|
323 | - if ( post_password_required() ) { |
|
322 | + public static function get_the_excerpt($excerpt = '') { |
|
323 | + if (post_password_required()) { |
|
324 | 324 | return $excerpt; |
325 | 325 | } |
326 | - if ( apply_filters( 'FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false ) ) { |
|
327 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
328 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
329 | - $excerpt = EED_Events_Archive::event_details( $excerpt ); |
|
326 | + if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) { |
|
327 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 100); |
|
328 | + remove_filter('the_content', array('EED_Events_Archive', 'event_details'), 100); |
|
329 | + $excerpt = EED_Events_Archive::event_details($excerpt); |
|
330 | 330 | } else { |
331 | 331 | EED_Events_Archive::$using_get_the_excerpt = true; |
332 | - add_filter( 'wp_trim_excerpt', array( 'EED_Events_Archive', 'end_get_the_excerpt' ), 999, 1 ); |
|
332 | + add_filter('wp_trim_excerpt', array('EED_Events_Archive', 'end_get_the_excerpt'), 999, 1); |
|
333 | 333 | } |
334 | 334 | return $excerpt; |
335 | 335 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @param string $text |
344 | 344 | * @return string |
345 | 345 | */ |
346 | - public static function end_get_the_excerpt( $text = '' ) { |
|
346 | + public static function end_get_the_excerpt($text = '') { |
|
347 | 347 | EED_Events_Archive::$using_get_the_excerpt = false; |
348 | 348 | return $text; |
349 | 349 | } |
@@ -358,10 +358,10 @@ discard block |
||
358 | 358 | * @param string $id |
359 | 359 | * @return string |
360 | 360 | */ |
361 | - public static function the_title( $title = '', $id = '' ) { |
|
361 | + public static function the_title($title = '', $id = '') { |
|
362 | 362 | global $post; |
363 | - if ( $post instanceof WP_Post ) { |
|
364 | - return in_the_loop() && $post->ID == $id ? espresso_event_status_banner( $post->ID ) . $title : $title; |
|
363 | + if ($post instanceof WP_Post) { |
|
364 | + return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID).$title : $title; |
|
365 | 365 | } |
366 | 366 | return $title; |
367 | 367 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * @param string $content |
376 | 376 | * @return string |
377 | 377 | */ |
378 | - public static function event_details( $content ) { |
|
378 | + public static function event_details($content) { |
|
379 | 379 | global $post; |
380 | 380 | static $current_post_ID = 0; |
381 | 381 | if ( |
@@ -384,8 +384,8 @@ discard block |
||
384 | 384 | && ! EED_Events_Archive::$using_get_the_excerpt |
385 | 385 | && ! post_password_required() |
386 | 386 | && ( |
387 | - apply_filters( 'FHEE__EES_Espresso_Events__process_shortcode__true', false ) |
|
388 | - || ! apply_filters( 'FHEE__content_espresso_events__template_loaded', false ) |
|
387 | + apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false) |
|
388 | + || ! apply_filters('FHEE__content_espresso_events__template_loaded', false) |
|
389 | 389 | ) |
390 | 390 | ) { |
391 | 391 | // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
@@ -394,8 +394,8 @@ discard block |
||
394 | 394 | // We want to allow those plugins to still do their thing and have access to our content, but depending on |
395 | 395 | // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
396 | 396 | // so the following allows this filter to be applied multiple times, but only once for real |
397 | - $current_post_ID = did_action( 'loop_start' ) ? $post->ID : 0; |
|
398 | - if ( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order ) { |
|
397 | + $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
398 | + if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) { |
|
399 | 399 | $content = \EED_Events_Archive::use_sortable_display_order(); |
400 | 400 | } else { |
401 | 401 | $content = \EED_Events_Archive::use_filterable_display_order(); |
@@ -414,20 +414,20 @@ discard block |
||
414 | 414 | */ |
415 | 415 | protected static function use_sortable_display_order() { |
416 | 416 | // no further password checks required atm |
417 | - add_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' ); |
|
417 | + add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true'); |
|
418 | 418 | // we need to first remove this callback from being applied to the_content() or the_excerpt() (otherwise it will recurse and blow up the interweb) |
419 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
420 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
421 | - remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
|
419 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 100); |
|
420 | + remove_filter('the_content', array('EED_Events_Archive', 'event_details'), 100); |
|
421 | + remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
422 | 422 | // now add additional content depending on whether event is using the_excerpt() or the_content() |
423 | 423 | EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts(); |
424 | - $content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
|
425 | - $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters( $content ); |
|
424 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
425 | + $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content); |
|
426 | 426 | // re-add our main filters (or else the next event won't have them) |
427 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
|
428 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
|
429 | - add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
|
430 | - remove_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' ); |
|
427 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 100, 1); |
|
428 | + add_filter('the_content', array('EED_Events_Archive', 'event_details'), 100, 1); |
|
429 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
430 | + remove_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true'); |
|
431 | 431 | return $content; |
432 | 432 | } |
433 | 433 | |
@@ -442,22 +442,22 @@ discard block |
||
442 | 442 | protected static function use_filterable_display_order() { |
443 | 443 | // we need to first remove this callback from being applied to the_content() |
444 | 444 | // (otherwise it will recurse and blow up the interweb) |
445 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
446 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
447 | - remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
|
445 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 100); |
|
446 | + remove_filter('the_content', array('EED_Events_Archive', 'event_details'), 100); |
|
447 | + remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
448 | 448 | //now add additional content depending on whether event is using the_excerpt() or the_content() |
449 | 449 | EED_Events_Archive::_add_additional_excerpt_filters(); |
450 | 450 | EED_Events_Archive::_add_additional_content_filters(); |
451 | - do_action( 'AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters' ); |
|
451 | + do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters'); |
|
452 | 452 | // now load our template |
453 | - $content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
|
453 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
454 | 454 | // re-add our main filters (or else the next event won't have them) |
455 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
|
456 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
|
457 | - add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
|
455 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 100, 1); |
|
456 | + add_filter('the_content', array('EED_Events_Archive', 'event_details'), 100, 1); |
|
457 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
458 | 458 | // but remove the other filters so that they don't get applied to the next post |
459 | 459 | EED_Events_Archive::_remove_additional_events_archive_filters(); |
460 | - do_action( 'AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters' ); |
|
460 | + do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters'); |
|
461 | 461 | // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
462 | 462 | //return ! empty( $template ) ? $template : $content; |
463 | 463 | return $content; |
@@ -472,11 +472,11 @@ discard block |
||
472 | 472 | * @param string $content |
473 | 473 | * @return string |
474 | 474 | */ |
475 | - public static function event_datetimes( $content ) { |
|
476 | - if ( post_password_required() ) { |
|
475 | + public static function event_datetimes($content) { |
|
476 | + if (post_password_required()) { |
|
477 | 477 | return $content; |
478 | 478 | } |
479 | - return EEH_Template::locate_template( 'content-espresso_events-datetimes.php' ) . $content; |
|
479 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content; |
|
480 | 480 | } |
481 | 481 | |
482 | 482 | /** |
@@ -486,11 +486,11 @@ discard block |
||
486 | 486 | * @param string $content |
487 | 487 | * @return string |
488 | 488 | */ |
489 | - public static function event_tickets( $content ) { |
|
490 | - if ( post_password_required() ) { |
|
489 | + public static function event_tickets($content) { |
|
490 | + if (post_password_required()) { |
|
491 | 491 | return $content; |
492 | 492 | } |
493 | - return EEH_Template::locate_template( 'content-espresso_events-tickets.php' ) . $content; |
|
493 | + return EEH_Template::locate_template('content-espresso_events-tickets.php').$content; |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | |
@@ -502,8 +502,8 @@ discard block |
||
502 | 502 | * @param string $content |
503 | 503 | * @return string |
504 | 504 | */ |
505 | - public static function event_venue( $content ) { |
|
506 | - return EED_Events_Archive::event_venues( $content ); |
|
505 | + public static function event_venue($content) { |
|
506 | + return EED_Events_Archive::event_venues($content); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | /** |
@@ -513,11 +513,11 @@ discard block |
||
513 | 513 | * @param string $content |
514 | 514 | * @return string |
515 | 515 | */ |
516 | - public static function event_venues( $content ) { |
|
517 | - if ( post_password_required() ) { |
|
516 | + public static function event_venues($content) { |
|
517 | + if (post_password_required()) { |
|
518 | 518 | return $content; |
519 | 519 | } |
520 | - return $content . EEH_Template::locate_template( 'content-espresso_events-venues.php' ); |
|
520 | + return $content.EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | |
@@ -529,9 +529,9 @@ discard block |
||
529 | 529 | * @return void |
530 | 530 | */ |
531 | 531 | private static function _add_additional_excerpt_filters() { |
532 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_datetimes' ), 110, 1 ); |
|
533 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_tickets' ), 120, 1 ); |
|
534 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_venues' ), 130, 1 ); |
|
532 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_datetimes'), 110, 1); |
|
533 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_tickets'), 120, 1); |
|
534 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_venues'), 130, 1); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | |
@@ -543,9 +543,9 @@ discard block |
||
543 | 543 | * @return void |
544 | 544 | */ |
545 | 545 | private static function _add_additional_content_filters() { |
546 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_datetimes' ), 110, 1 ); |
|
547 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_tickets' ), 120, 1 ); |
|
548 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_venues' ), 130, 1 ); |
|
546 | + add_filter('the_content', array('EED_Events_Archive', 'event_datetimes'), 110, 1); |
|
547 | + add_filter('the_content', array('EED_Events_Archive', 'event_tickets'), 120, 1); |
|
548 | + add_filter('the_content', array('EED_Events_Archive', 'event_venues'), 130, 1); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | |
@@ -557,12 +557,12 @@ discard block |
||
557 | 557 | * @return void |
558 | 558 | */ |
559 | 559 | private static function _remove_additional_events_archive_filters() { |
560 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_datetimes' ), 110 ); |
|
561 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_tickets' ), 120 ); |
|
562 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_venues' ), 130 ); |
|
563 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_datetimes' ), 110 ); |
|
564 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_tickets' ), 120 ); |
|
565 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_venues' ), 130 ); |
|
560 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_datetimes'), 110); |
|
561 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_tickets'), 120); |
|
562 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_venues'), 130); |
|
563 | + remove_filter('the_content', array('EED_Events_Archive', 'event_datetimes'), 110); |
|
564 | + remove_filter('the_content', array('EED_Events_Archive', 'event_tickets'), 120); |
|
565 | + remove_filter('the_content', array('EED_Events_Archive', 'event_venues'), 130); |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | |
@@ -575,17 +575,17 @@ discard block |
||
575 | 575 | */ |
576 | 576 | public static function remove_all_events_archive_filters() { |
577 | 577 | //remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
578 | - remove_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 100 ); |
|
579 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
580 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_datetimes' ), 110 ); |
|
581 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_tickets' ), 120 ); |
|
582 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_venues' ), 130 ); |
|
583 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
584 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_datetimes' ), 110 ); |
|
585 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_tickets' ), 120 ); |
|
586 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_venues' ), 130 ); |
|
578 | + remove_filter('the_title', array('EED_Events_Archive', 'the_title'), 100); |
|
579 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 100); |
|
580 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_datetimes'), 110); |
|
581 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_tickets'), 120); |
|
582 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_venues'), 130); |
|
583 | + remove_filter('the_content', array('EED_Events_Archive', 'event_details'), 100); |
|
584 | + remove_filter('the_content', array('EED_Events_Archive', 'event_datetimes'), 110); |
|
585 | + remove_filter('the_content', array('EED_Events_Archive', 'event_tickets'), 120); |
|
586 | + remove_filter('the_content', array('EED_Events_Archive', 'event_venues'), 130); |
|
587 | 587 | // don't display entry meta because the existing theme will take care of that |
588 | - remove_filter( 'FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false' ); |
|
588 | + remove_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | |
@@ -600,12 +600,12 @@ discard block |
||
600 | 600 | * @return void |
601 | 601 | */ |
602 | 602 | public function load_event_list_assets() { |
603 | - do_action( 'AHEE__EED_Events_Archive__before_load_assets' ); |
|
604 | - add_filter( 'FHEE_load_EE_Session', '__return_true' ); |
|
605 | - add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
|
606 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 ); |
|
607 | - if ( EE_Registry::instance()->CFG->map_settings->use_google_maps ) { |
|
608 | - add_action('wp_enqueue_scripts', array( 'EEH_Maps', 'espresso_google_map_js' ), 11 ); |
|
603 | + do_action('AHEE__EED_Events_Archive__before_load_assets'); |
|
604 | + add_filter('FHEE_load_EE_Session', '__return_true'); |
|
605 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
606 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
607 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
608 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
609 | 609 | } |
610 | 610 | } |
611 | 611 | |
@@ -622,13 +622,13 @@ discard block |
||
622 | 622 | */ |
623 | 623 | public function wp_enqueue_scripts() { |
624 | 624 | // get some style |
625 | - if ( apply_filters( 'FHEE_enable_default_espresso_css', FALSE ) ) { |
|
625 | + if (apply_filters('FHEE_enable_default_espresso_css', FALSE)) { |
|
626 | 626 | // first check uploads folder |
627 | - if ( EEH_File::is_readable( get_stylesheet_directory() . $this->theme . DS . 'style.css' )) { |
|
628 | - wp_register_style( $this->theme, get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' )); |
|
627 | + if (EEH_File::is_readable(get_stylesheet_directory().$this->theme.DS.'style.css')) { |
|
628 | + wp_register_style($this->theme, get_stylesheet_directory_uri().$this->theme.DS.'style.css', array('dashicons', 'espresso_default')); |
|
629 | 629 | } else { |
630 | 630 | } |
631 | - wp_enqueue_style( $this->theme ); |
|
631 | + wp_enqueue_style($this->theme); |
|
632 | 632 | |
633 | 633 | } |
634 | 634 | } |
@@ -646,8 +646,8 @@ discard block |
||
646 | 646 | */ |
647 | 647 | public static function template_settings_form() { |
648 | 648 | $template_settings = EE_Registry::instance()->CFG->template_settings; |
649 | - $template_settings->EED_Events_Archive = isset( $template_settings->EED_Events_Archive ) ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config(); |
|
650 | - $template_settings->EED_Events_Archive = apply_filters( 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', $template_settings->EED_Events_Archive ); |
|
649 | + $template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive) ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config(); |
|
650 | + $template_settings->EED_Events_Archive = apply_filters('FHEE__EED_Events_Archive__template_settings_form__event_list_config', $template_settings->EED_Events_Archive); |
|
651 | 651 | $events_archive_settings = array( |
652 | 652 | 'display_status_banner' => 0, |
653 | 653 | 'display_description' => 1, |
@@ -656,8 +656,8 @@ discard block |
||
656 | 656 | 'display_venue' => 0, |
657 | 657 | 'display_expired_events' => 0 |
658 | 658 | ); |
659 | - $events_archive_settings = array_merge( $events_archive_settings, (array)$template_settings->EED_Events_Archive ); |
|
660 | - EEH_Template::display_template( EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', $events_archive_settings ); |
|
659 | + $events_archive_settings = array_merge($events_archive_settings, (array) $template_settings->EED_Events_Archive); |
|
660 | + EEH_Template::display_template(EVENTS_ARCHIVE_TEMPLATES_PATH.'admin-event-list-settings.template.php', $events_archive_settings); |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | |
@@ -673,16 +673,16 @@ discard block |
||
673 | 673 | * @param EE_Request_Handler $REQ |
674 | 674 | * @return EE_Template_Config |
675 | 675 | */ |
676 | - public static function update_template_settings( $CFG, $REQ ) { |
|
676 | + public static function update_template_settings($CFG, $REQ) { |
|
677 | 677 | $CFG->EED_Events_Archive = new EE_Events_Archive_Config(); |
678 | 678 | // unless we are resetting the config... |
679 | - if ( ! isset( $REQ['EED_Events_Archive_reset_event_list_settings'] ) || absint( $REQ['EED_Events_Archive_reset_event_list_settings'] ) !== 1 ) { |
|
680 | - $CFG->EED_Events_Archive->display_status_banner = isset( $REQ['EED_Events_Archive_display_status_banner'] ) ? absint( $REQ['EED_Events_Archive_display_status_banner'] ) : 0; |
|
681 | - $CFG->EED_Events_Archive->display_description = isset( $REQ['EED_Events_Archive_display_description'] ) ? absint( $REQ['EED_Events_Archive_display_description'] ) : 1; |
|
682 | - $CFG->EED_Events_Archive->display_ticket_selector = isset( $REQ['EED_Events_Archive_display_ticket_selector'] ) ? absint( $REQ['EED_Events_Archive_display_ticket_selector'] ) : 0; |
|
683 | - $CFG->EED_Events_Archive->display_datetimes = isset( $REQ['EED_Events_Archive_display_datetimes'] ) ? absint( $REQ['EED_Events_Archive_display_datetimes'] ) : 1; |
|
684 | - $CFG->EED_Events_Archive->display_venue = isset( $REQ['EED_Events_Archive_display_venue'] ) ? absint( $REQ['EED_Events_Archive_display_venue'] ) : 0; |
|
685 | - $CFG->EED_Events_Archive->display_expired_events = isset( $REQ['EED_Events_Archive_display_expired_events'] ) ? absint( $REQ['EED_Events_Archive_display_expired_events'] ) : 0; } |
|
679 | + if ( ! isset($REQ['EED_Events_Archive_reset_event_list_settings']) || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1) { |
|
680 | + $CFG->EED_Events_Archive->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) ? absint($REQ['EED_Events_Archive_display_status_banner']) : 0; |
|
681 | + $CFG->EED_Events_Archive->display_description = isset($REQ['EED_Events_Archive_display_description']) ? absint($REQ['EED_Events_Archive_display_description']) : 1; |
|
682 | + $CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) ? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0; |
|
683 | + $CFG->EED_Events_Archive->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint($REQ['EED_Events_Archive_display_datetimes']) : 1; |
|
684 | + $CFG->EED_Events_Archive->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint($REQ['EED_Events_Archive_display_venue']) : 0; |
|
685 | + $CFG->EED_Events_Archive->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) ? absint($REQ['EED_Events_Archive_display_expired_events']) : 0; } |
|
686 | 686 | return $CFG; |
687 | 687 | } |
688 | 688 | |
@@ -695,10 +695,10 @@ discard block |
||
695 | 695 | * @param string $extra_class |
696 | 696 | * @return string |
697 | 697 | */ |
698 | - public static function event_list_css( $extra_class = '' ) { |
|
699 | - $event_list_css = ! empty( $extra_class ) ? array( $extra_class ) : array(); |
|
698 | + public static function event_list_css($extra_class = '') { |
|
699 | + $event_list_css = ! empty($extra_class) ? array($extra_class) : array(); |
|
700 | 700 | $event_list_css[] = 'espresso-event-list-event'; |
701 | - return implode( ' ', $event_list_css ); |
|
701 | + return implode(' ', $event_list_css); |
|
702 | 702 | } |
703 | 703 | |
704 | 704 | |
@@ -725,9 +725,9 @@ discard block |
||
725 | 725 | * @param $value |
726 | 726 | * @return bool |
727 | 727 | */ |
728 | - public static function display_description( $value ) { |
|
728 | + public static function display_description($value) { |
|
729 | 729 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
730 | - $display_description= isset( $config->display_description ) ? $config->display_description : 1; |
|
730 | + $display_description = isset($config->display_description) ? $config->display_description : 1; |
|
731 | 731 | return $display_description === $value ? TRUE : FALSE; |
732 | 732 | } |
733 | 733 | |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | */ |
741 | 741 | public static function display_ticket_selector() { |
742 | 742 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
743 | - return isset( $config->display_ticket_selector ) && $config->display_ticket_selector ? TRUE : FALSE; |
|
743 | + return isset($config->display_ticket_selector) && $config->display_ticket_selector ? TRUE : FALSE; |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | */ |
754 | 754 | public static function display_venue() { |
755 | 755 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
756 | - return isset( $config->display_venue ) && $config->display_venue && EEH_Venue_View::venue_name() ? TRUE : FALSE; |
|
756 | + return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name() ? TRUE : FALSE; |
|
757 | 757 | } |
758 | 758 | |
759 | 759 | |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | */ |
766 | 766 | public static function display_datetimes() { |
767 | 767 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
768 | - return isset( $config->display_datetimes ) && $config->display_datetimes ? TRUE : FALSE; |
|
768 | + return isset($config->display_datetimes) && $config->display_datetimes ? TRUE : FALSE; |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | * @return string |
781 | 781 | */ |
782 | 782 | public static function event_list_title() { |
783 | - return apply_filters( 'FHEE__archive_espresso_events_template__upcoming_events_h1', __( 'Upcoming Events', 'event_espresso' )); |
|
783 | + return apply_filters('FHEE__archive_espresso_events_template__upcoming_events_h1', __('Upcoming Events', 'event_espresso')); |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | |
@@ -789,11 +789,11 @@ discard block |
||
789 | 789 | /** |
790 | 790 | * @since 4.4.0 |
791 | 791 | */ |
792 | - public static function _doing_it_wrong_notice( $function = '' ) { |
|
792 | + public static function _doing_it_wrong_notice($function = '') { |
|
793 | 793 | EE_Error::doing_it_wrong( |
794 | 794 | __FUNCTION__, |
795 | 795 | sprintf( |
796 | - __( 'EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso' ), |
|
796 | + __('EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso'), |
|
797 | 797 | $function, |
798 | 798 | '<br />', |
799 | 799 | '4.6.0' |
@@ -815,89 +815,89 @@ discard block |
||
815 | 815 | * @deprecated |
816 | 816 | * @since 4.4.0 |
817 | 817 | */ |
818 | - public function posts_fields( $SQL, WP_Query $wp_query ) { |
|
819 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
820 | - return EEH_Event_Query::posts_fields( $SQL, $wp_query ); |
|
818 | + public function posts_fields($SQL, WP_Query $wp_query) { |
|
819 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
820 | + return EEH_Event_Query::posts_fields($SQL, $wp_query); |
|
821 | 821 | } |
822 | 822 | /** |
823 | 823 | * @deprecated |
824 | 824 | * @since 4.4.0 |
825 | 825 | */ |
826 | - public static function posts_fields_sql_for_orderby( $orderby_params = array() ) { |
|
827 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
828 | - return EEH_Event_Query::posts_fields_sql_for_orderby( $orderby_params ); |
|
826 | + public static function posts_fields_sql_for_orderby($orderby_params = array()) { |
|
827 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
828 | + return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params); |
|
829 | 829 | } |
830 | 830 | /** |
831 | 831 | * @deprecated |
832 | 832 | * @since 4.4.0 |
833 | 833 | */ |
834 | - public function posts_join( $SQL, WP_Query $wp_query ) { |
|
835 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
836 | - return EEH_Event_Query::posts_join( $SQL, $wp_query ); |
|
834 | + public function posts_join($SQL, WP_Query $wp_query) { |
|
835 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
836 | + return EEH_Event_Query::posts_join($SQL, $wp_query); |
|
837 | 837 | } |
838 | 838 | /** |
839 | 839 | * @deprecated |
840 | 840 | * @since 4.4.0 |
841 | 841 | */ |
842 | - public static function posts_join_sql_for_terms( $join_terms = NULL ) { |
|
843 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
844 | - return EEH_Event_Query::posts_join_sql_for_terms( $join_terms ); |
|
842 | + public static function posts_join_sql_for_terms($join_terms = NULL) { |
|
843 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
844 | + return EEH_Event_Query::posts_join_sql_for_terms($join_terms); |
|
845 | 845 | } |
846 | 846 | /** |
847 | 847 | * @deprecated |
848 | 848 | * @since 4.4.0 |
849 | 849 | */ |
850 | - public static function posts_join_for_orderby( $orderby_params = array() ) { |
|
851 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
852 | - return EEH_Event_Query::posts_join_for_orderby( $orderby_params ); |
|
850 | + public static function posts_join_for_orderby($orderby_params = array()) { |
|
851 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
852 | + return EEH_Event_Query::posts_join_for_orderby($orderby_params); |
|
853 | 853 | } |
854 | 854 | /** |
855 | 855 | * @deprecated |
856 | 856 | * @since 4.4.0 |
857 | 857 | */ |
858 | - public function posts_where( $SQL, WP_Query $wp_query ) { |
|
859 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
860 | - return EEH_Event_Query::posts_where( $SQL, $wp_query ); |
|
858 | + public function posts_where($SQL, WP_Query $wp_query) { |
|
859 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
860 | + return EEH_Event_Query::posts_where($SQL, $wp_query); |
|
861 | 861 | } |
862 | 862 | /** |
863 | 863 | * @deprecated |
864 | 864 | * @since 4.4.0 |
865 | 865 | */ |
866 | - public static function posts_where_sql_for_show_expired( $show_expired = FALSE ) { |
|
867 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
868 | - return EEH_Event_Query::posts_where_sql_for_show_expired( $show_expired ); |
|
866 | + public static function posts_where_sql_for_show_expired($show_expired = FALSE) { |
|
867 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
868 | + return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired); |
|
869 | 869 | } |
870 | 870 | /** |
871 | 871 | * @deprecated |
872 | 872 | * @since 4.4.0 |
873 | 873 | */ |
874 | - public static function posts_where_sql_for_event_category_slug( $event_category_slug = NULL ) { |
|
875 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
876 | - return EEH_Event_Query::posts_where_sql_for_event_category_slug( $event_category_slug ); |
|
874 | + public static function posts_where_sql_for_event_category_slug($event_category_slug = NULL) { |
|
875 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
876 | + return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug); |
|
877 | 877 | } |
878 | 878 | /** |
879 | 879 | * @deprecated |
880 | 880 | * @since 4.4.0 |
881 | 881 | */ |
882 | - public static function posts_where_sql_for_event_list_month( $month = NULL ) { |
|
883 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
884 | - return EEH_Event_Query::posts_where_sql_for_event_list_month( $month ); |
|
882 | + public static function posts_where_sql_for_event_list_month($month = NULL) { |
|
883 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
884 | + return EEH_Event_Query::posts_where_sql_for_event_list_month($month); |
|
885 | 885 | } |
886 | 886 | /** |
887 | 887 | * @deprecated |
888 | 888 | * @since 4.4.0 |
889 | 889 | */ |
890 | - public function posts_orderby( $SQL, WP_Query $wp_query ) { |
|
891 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
892 | - return EEH_Event_Query::posts_orderby( $SQL, $wp_query ); |
|
890 | + public function posts_orderby($SQL, WP_Query $wp_query) { |
|
891 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
892 | + return EEH_Event_Query::posts_orderby($SQL, $wp_query); |
|
893 | 893 | } |
894 | 894 | /** |
895 | 895 | * @deprecated |
896 | 896 | * @since 4.4.0 |
897 | 897 | */ |
898 | - public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) { |
|
899 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
900 | - return EEH_Event_Query::posts_orderby_sql( $orderby_params, $sort ); |
|
898 | + public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') { |
|
899 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
900 | + return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort); |
|
901 | 901 | } |
902 | 902 | |
903 | 903 | |
@@ -928,8 +928,8 @@ discard block |
||
928 | 928 | * @param string $extra_class |
929 | 929 | * @return string |
930 | 930 | */ |
931 | -function espresso_event_list_css( $extra_class = '' ) { |
|
932 | - return EED_Events_Archive::event_list_css( $extra_class ); |
|
931 | +function espresso_event_list_css($extra_class = '') { |
|
932 | + return EED_Events_Archive::event_list_css($extra_class); |
|
933 | 933 | } |
934 | 934 | |
935 | 935 | /** |
@@ -943,14 +943,14 @@ discard block |
||
943 | 943 | * @return bool |
944 | 944 | */ |
945 | 945 | function espresso_display_full_description_in_event_list() { |
946 | - return EED_Events_Archive::display_description( 2 ); |
|
946 | + return EED_Events_Archive::display_description(2); |
|
947 | 947 | } |
948 | 948 | |
949 | 949 | /** |
950 | 950 | * @return bool |
951 | 951 | */ |
952 | 952 | function espresso_display_excerpt_in_event_list() { |
953 | - return EED_Events_Archive::display_description( 1 ); |
|
953 | + return EED_Events_Archive::display_description(1); |
|
954 | 954 | } |
955 | 955 | |
956 | 956 | /** |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | namespace EventEspresso\modules\ticket_selector; |
3 | 3 | |
4 | 4 | if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
5 | - exit( 'No direct script access allowed' ); |
|
5 | + exit( 'No direct script access allowed' ); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -19,678 +19,678 @@ discard block |
||
19 | 19 | class DisplayTicketSelector |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * event that ticket selector is being generated for |
|
24 | - * |
|
25 | - * @access protected |
|
26 | - * @var \EE_Event $event |
|
27 | - */ |
|
28 | - protected $event; |
|
29 | - |
|
30 | - /** |
|
31 | - * Used to flag when the ticket selector is being called from an external iframe. |
|
32 | - * |
|
33 | - * @var bool $iframe |
|
34 | - */ |
|
35 | - protected $iframe = false; |
|
36 | - |
|
37 | - /** |
|
38 | - * max attendees that can register for event at one time |
|
39 | - * |
|
40 | - * @var int $max_attendees |
|
41 | - */ |
|
42 | - private $max_attendees = EE_INF; |
|
43 | - |
|
44 | - /** |
|
45 | - *@var string $date_format |
|
46 | - */ |
|
47 | - private $date_format = ''; |
|
48 | - |
|
49 | - /** |
|
50 | - *@var string $time_format |
|
51 | - */ |
|
52 | - private $time_format = ''; |
|
53 | - |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * DisplayTicketSelector constructor. |
|
58 | - */ |
|
59 | - public function __construct() |
|
60 | - { |
|
61 | - $this->date_format = apply_filters( |
|
62 | - 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', |
|
63 | - get_option('date_format') |
|
64 | - ); |
|
65 | - $this->time_format = apply_filters( |
|
66 | - 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', |
|
67 | - get_option('time_format') |
|
68 | - ); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * @param boolean $iframe |
|
75 | - */ |
|
76 | - public function setIframe( $iframe = true ) |
|
77 | - { |
|
78 | - $this->iframe = filter_var( $iframe, FILTER_VALIDATE_BOOLEAN ); |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * finds and sets the \EE_Event object for use throughout class |
|
85 | - * |
|
86 | - * @param mixed $event |
|
87 | - * @return bool |
|
88 | - */ |
|
89 | - protected function setEvent( $event = null ) |
|
90 | - { |
|
91 | - if ( $event === null ) { |
|
92 | - global $post; |
|
93 | - $event = $post; |
|
94 | - } |
|
95 | - if ( $event instanceof \EE_Event ) { |
|
96 | - $this->event = $event; |
|
97 | - } else if ( $event instanceof \WP_Post ) { |
|
98 | - if ( isset( $event->EE_Event ) && $event->EE_Event instanceof \EE_Event ) { |
|
99 | - $this->event = $event->EE_Event; |
|
100 | - } else if ( $event->post_type === 'espresso_events' ) { |
|
101 | - $event->EE_Event = \EEM_Event::instance()->instantiate_class_from_post_object( $event ); |
|
102 | - $this->event = $event->EE_Event; |
|
103 | - } |
|
104 | - } else { |
|
105 | - $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' ); |
|
106 | - $dev_msg = $user_msg . __( |
|
107 | - 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', |
|
108 | - 'event_espresso' |
|
109 | - ); |
|
110 | - \EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
111 | - return false; |
|
112 | - } |
|
113 | - return true; |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * @return int |
|
120 | - */ |
|
121 | - public function getMaxAttendees() |
|
122 | - { |
|
123 | - return $this->max_attendees; |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * @param int $max_attendees |
|
130 | - */ |
|
131 | - public function setMaxAttendees($max_attendees) |
|
132 | - { |
|
133 | - $this->max_attendees = absint( |
|
134 | - apply_filters( |
|
135 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', |
|
136 | - $max_attendees |
|
137 | - ) |
|
138 | - ); |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * creates buttons for selecting number of attendees for an event |
|
145 | - * |
|
146 | - * @param \WP_Post|int $event |
|
147 | - * @param bool $view_details |
|
148 | - * @return string |
|
149 | - * @throws \EE_Error |
|
150 | - */ |
|
151 | - public function display( $event = null, $view_details = false ) |
|
152 | - { |
|
153 | - // reset filter for displaying submit button |
|
154 | - remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
155 | - // poke and prod incoming event till it tells us what it is |
|
156 | - if ( ! $this->setEvent( $event ) ) { |
|
157 | - return false; |
|
158 | - } |
|
159 | - // begin gathering template arguments by getting event status |
|
160 | - $template_args = array( 'event_status' => $this->event->get_active_status() ); |
|
161 | - if ( $this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details) ) { |
|
162 | - return ! is_single() ? $this->displayViewDetailsButton() : ''; |
|
163 | - } |
|
164 | - // filter the maximum qty that can appear in the Ticket Selector qty dropdowns |
|
165 | - $this->setMaxAttendees($this->event->additional_limit()); |
|
166 | - if ($this->getMaxAttendees() < 1) { |
|
167 | - return $this->ticketSalesClosedMessage(); |
|
168 | - } |
|
169 | - // is the event expired ? |
|
170 | - $template_args['event_is_expired'] = $this->event->is_expired(); |
|
171 | - if ( $template_args[ 'event_is_expired' ] ) { |
|
172 | - return $this->expiredEventMessage(); |
|
173 | - } |
|
174 | - // get all tickets for this event ordered by the datetime |
|
175 | - $tickets = $this->getTickets(); |
|
176 | - if (count($tickets) < 1) { |
|
177 | - return $this->noTicketAvailableMessage(); |
|
178 | - } |
|
179 | - if (\EED_Events_Archive::is_iframe()){ |
|
180 | - $this->setIframe(); |
|
181 | - } |
|
182 | - // redirecting to another site for registration ?? |
|
183 | - $external_url = (string) $this->event->external_url(); |
|
184 | - // if redirecting to another site for registration, then we don't load the TS |
|
185 | - $ticket_selector = $external_url |
|
186 | - ? $this->externalEventRegistration() |
|
187 | - : $this->loadTicketSelector($tickets,$template_args); |
|
188 | - // now set up the form (but not for the admin) |
|
189 | - $ticket_selector = ! is_admin() |
|
190 | - ? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector |
|
191 | - : $ticket_selector; |
|
192 | - // submit button and form close tag |
|
193 | - $ticket_selector .= ! is_admin() ? $this->displaySubmitButton($external_url) : ''; |
|
194 | - return $ticket_selector; |
|
195 | - } |
|
196 | - |
|
197 | - |
|
198 | - |
|
199 | - /** |
|
200 | - * displayTicketSelector |
|
201 | - * examines the event properties and determines whether a Ticket Selector should be displayed |
|
202 | - * |
|
203 | - * @param \WP_Post|int $event |
|
204 | - * @param string $_event_active_status |
|
205 | - * @param bool $view_details |
|
206 | - * @return bool |
|
207 | - * @throws \EE_Error |
|
208 | - */ |
|
209 | - protected function activeEventAndShowTicketSelector($event, $_event_active_status, $view_details) |
|
210 | - { |
|
211 | - $event_post = $this->event instanceof \EE_Event ? $this->event->ID() : $event; |
|
212 | - return ! is_admin() |
|
213 | - && ( |
|
214 | - ! $this->event->display_ticket_selector() |
|
215 | - || $view_details |
|
216 | - || post_password_required($event_post) |
|
217 | - || ( |
|
218 | - $_event_active_status !== \EE_Datetime::active |
|
219 | - && $_event_active_status !== \EE_Datetime::upcoming |
|
220 | - && $_event_active_status !== \EE_Datetime::sold_out |
|
221 | - && ! ( |
|
222 | - $_event_active_status === \EE_Datetime::inactive |
|
223 | - && is_user_logged_in() |
|
224 | - ) |
|
225 | - ) |
|
226 | - ); |
|
227 | - } |
|
228 | - |
|
229 | - |
|
230 | - |
|
231 | - /** |
|
232 | - * noTicketAvailableMessage |
|
233 | - * notice displayed if event is expired |
|
234 | - * |
|
235 | - * @return string |
|
236 | - * @throws \EE_Error |
|
237 | - */ |
|
238 | - protected function expiredEventMessage() |
|
239 | - { |
|
240 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__( |
|
241 | - 'We\'re sorry, but all tickets sales have ended because the event is expired.', |
|
242 | - 'event_espresso' |
|
243 | - ) . '</span></div>'; |
|
244 | - } |
|
245 | - |
|
246 | - |
|
247 | - |
|
248 | - /** |
|
249 | - * noTicketAvailableMessage |
|
250 | - * notice displayed if event has no more tickets available |
|
251 | - * |
|
252 | - * @return string |
|
253 | - * @throws \EE_Error |
|
254 | - */ |
|
255 | - protected function noTicketAvailableMessage() |
|
256 | - { |
|
257 | - $no_ticket_available_msg = esc_html__( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ); |
|
258 | - if (current_user_can('edit_post', $this->event->ID())) { |
|
259 | - $no_ticket_available_msg .= sprintf( |
|
260 | - esc_html__( |
|
261 | - '%1$sNote to Event Admin:%2$sNo tickets were found for this event. This effectively turns off ticket sales. Please ensure that at least one ticket is available for if you want people to be able to register.%3$s(click to edit this event)%4$s', |
|
262 | - 'event_espresso' |
|
263 | - ), |
|
264 | - '<div class="ee-attention" style="text-align: left;"><b>', |
|
265 | - '</b><br />', |
|
266 | - '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">', |
|
267 | - '</a></span></div>' |
|
268 | - ); |
|
269 | - } |
|
270 | - return ' |
|
22 | + /** |
|
23 | + * event that ticket selector is being generated for |
|
24 | + * |
|
25 | + * @access protected |
|
26 | + * @var \EE_Event $event |
|
27 | + */ |
|
28 | + protected $event; |
|
29 | + |
|
30 | + /** |
|
31 | + * Used to flag when the ticket selector is being called from an external iframe. |
|
32 | + * |
|
33 | + * @var bool $iframe |
|
34 | + */ |
|
35 | + protected $iframe = false; |
|
36 | + |
|
37 | + /** |
|
38 | + * max attendees that can register for event at one time |
|
39 | + * |
|
40 | + * @var int $max_attendees |
|
41 | + */ |
|
42 | + private $max_attendees = EE_INF; |
|
43 | + |
|
44 | + /** |
|
45 | + *@var string $date_format |
|
46 | + */ |
|
47 | + private $date_format = ''; |
|
48 | + |
|
49 | + /** |
|
50 | + *@var string $time_format |
|
51 | + */ |
|
52 | + private $time_format = ''; |
|
53 | + |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * DisplayTicketSelector constructor. |
|
58 | + */ |
|
59 | + public function __construct() |
|
60 | + { |
|
61 | + $this->date_format = apply_filters( |
|
62 | + 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', |
|
63 | + get_option('date_format') |
|
64 | + ); |
|
65 | + $this->time_format = apply_filters( |
|
66 | + 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', |
|
67 | + get_option('time_format') |
|
68 | + ); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * @param boolean $iframe |
|
75 | + */ |
|
76 | + public function setIframe( $iframe = true ) |
|
77 | + { |
|
78 | + $this->iframe = filter_var( $iframe, FILTER_VALIDATE_BOOLEAN ); |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * finds and sets the \EE_Event object for use throughout class |
|
85 | + * |
|
86 | + * @param mixed $event |
|
87 | + * @return bool |
|
88 | + */ |
|
89 | + protected function setEvent( $event = null ) |
|
90 | + { |
|
91 | + if ( $event === null ) { |
|
92 | + global $post; |
|
93 | + $event = $post; |
|
94 | + } |
|
95 | + if ( $event instanceof \EE_Event ) { |
|
96 | + $this->event = $event; |
|
97 | + } else if ( $event instanceof \WP_Post ) { |
|
98 | + if ( isset( $event->EE_Event ) && $event->EE_Event instanceof \EE_Event ) { |
|
99 | + $this->event = $event->EE_Event; |
|
100 | + } else if ( $event->post_type === 'espresso_events' ) { |
|
101 | + $event->EE_Event = \EEM_Event::instance()->instantiate_class_from_post_object( $event ); |
|
102 | + $this->event = $event->EE_Event; |
|
103 | + } |
|
104 | + } else { |
|
105 | + $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' ); |
|
106 | + $dev_msg = $user_msg . __( |
|
107 | + 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', |
|
108 | + 'event_espresso' |
|
109 | + ); |
|
110 | + \EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
111 | + return false; |
|
112 | + } |
|
113 | + return true; |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * @return int |
|
120 | + */ |
|
121 | + public function getMaxAttendees() |
|
122 | + { |
|
123 | + return $this->max_attendees; |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * @param int $max_attendees |
|
130 | + */ |
|
131 | + public function setMaxAttendees($max_attendees) |
|
132 | + { |
|
133 | + $this->max_attendees = absint( |
|
134 | + apply_filters( |
|
135 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', |
|
136 | + $max_attendees |
|
137 | + ) |
|
138 | + ); |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * creates buttons for selecting number of attendees for an event |
|
145 | + * |
|
146 | + * @param \WP_Post|int $event |
|
147 | + * @param bool $view_details |
|
148 | + * @return string |
|
149 | + * @throws \EE_Error |
|
150 | + */ |
|
151 | + public function display( $event = null, $view_details = false ) |
|
152 | + { |
|
153 | + // reset filter for displaying submit button |
|
154 | + remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
155 | + // poke and prod incoming event till it tells us what it is |
|
156 | + if ( ! $this->setEvent( $event ) ) { |
|
157 | + return false; |
|
158 | + } |
|
159 | + // begin gathering template arguments by getting event status |
|
160 | + $template_args = array( 'event_status' => $this->event->get_active_status() ); |
|
161 | + if ( $this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details) ) { |
|
162 | + return ! is_single() ? $this->displayViewDetailsButton() : ''; |
|
163 | + } |
|
164 | + // filter the maximum qty that can appear in the Ticket Selector qty dropdowns |
|
165 | + $this->setMaxAttendees($this->event->additional_limit()); |
|
166 | + if ($this->getMaxAttendees() < 1) { |
|
167 | + return $this->ticketSalesClosedMessage(); |
|
168 | + } |
|
169 | + // is the event expired ? |
|
170 | + $template_args['event_is_expired'] = $this->event->is_expired(); |
|
171 | + if ( $template_args[ 'event_is_expired' ] ) { |
|
172 | + return $this->expiredEventMessage(); |
|
173 | + } |
|
174 | + // get all tickets for this event ordered by the datetime |
|
175 | + $tickets = $this->getTickets(); |
|
176 | + if (count($tickets) < 1) { |
|
177 | + return $this->noTicketAvailableMessage(); |
|
178 | + } |
|
179 | + if (\EED_Events_Archive::is_iframe()){ |
|
180 | + $this->setIframe(); |
|
181 | + } |
|
182 | + // redirecting to another site for registration ?? |
|
183 | + $external_url = (string) $this->event->external_url(); |
|
184 | + // if redirecting to another site for registration, then we don't load the TS |
|
185 | + $ticket_selector = $external_url |
|
186 | + ? $this->externalEventRegistration() |
|
187 | + : $this->loadTicketSelector($tickets,$template_args); |
|
188 | + // now set up the form (but not for the admin) |
|
189 | + $ticket_selector = ! is_admin() |
|
190 | + ? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector |
|
191 | + : $ticket_selector; |
|
192 | + // submit button and form close tag |
|
193 | + $ticket_selector .= ! is_admin() ? $this->displaySubmitButton($external_url) : ''; |
|
194 | + return $ticket_selector; |
|
195 | + } |
|
196 | + |
|
197 | + |
|
198 | + |
|
199 | + /** |
|
200 | + * displayTicketSelector |
|
201 | + * examines the event properties and determines whether a Ticket Selector should be displayed |
|
202 | + * |
|
203 | + * @param \WP_Post|int $event |
|
204 | + * @param string $_event_active_status |
|
205 | + * @param bool $view_details |
|
206 | + * @return bool |
|
207 | + * @throws \EE_Error |
|
208 | + */ |
|
209 | + protected function activeEventAndShowTicketSelector($event, $_event_active_status, $view_details) |
|
210 | + { |
|
211 | + $event_post = $this->event instanceof \EE_Event ? $this->event->ID() : $event; |
|
212 | + return ! is_admin() |
|
213 | + && ( |
|
214 | + ! $this->event->display_ticket_selector() |
|
215 | + || $view_details |
|
216 | + || post_password_required($event_post) |
|
217 | + || ( |
|
218 | + $_event_active_status !== \EE_Datetime::active |
|
219 | + && $_event_active_status !== \EE_Datetime::upcoming |
|
220 | + && $_event_active_status !== \EE_Datetime::sold_out |
|
221 | + && ! ( |
|
222 | + $_event_active_status === \EE_Datetime::inactive |
|
223 | + && is_user_logged_in() |
|
224 | + ) |
|
225 | + ) |
|
226 | + ); |
|
227 | + } |
|
228 | + |
|
229 | + |
|
230 | + |
|
231 | + /** |
|
232 | + * noTicketAvailableMessage |
|
233 | + * notice displayed if event is expired |
|
234 | + * |
|
235 | + * @return string |
|
236 | + * @throws \EE_Error |
|
237 | + */ |
|
238 | + protected function expiredEventMessage() |
|
239 | + { |
|
240 | + return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__( |
|
241 | + 'We\'re sorry, but all tickets sales have ended because the event is expired.', |
|
242 | + 'event_espresso' |
|
243 | + ) . '</span></div>'; |
|
244 | + } |
|
245 | + |
|
246 | + |
|
247 | + |
|
248 | + /** |
|
249 | + * noTicketAvailableMessage |
|
250 | + * notice displayed if event has no more tickets available |
|
251 | + * |
|
252 | + * @return string |
|
253 | + * @throws \EE_Error |
|
254 | + */ |
|
255 | + protected function noTicketAvailableMessage() |
|
256 | + { |
|
257 | + $no_ticket_available_msg = esc_html__( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ); |
|
258 | + if (current_user_can('edit_post', $this->event->ID())) { |
|
259 | + $no_ticket_available_msg .= sprintf( |
|
260 | + esc_html__( |
|
261 | + '%1$sNote to Event Admin:%2$sNo tickets were found for this event. This effectively turns off ticket sales. Please ensure that at least one ticket is available for if you want people to be able to register.%3$s(click to edit this event)%4$s', |
|
262 | + 'event_espresso' |
|
263 | + ), |
|
264 | + '<div class="ee-attention" style="text-align: left;"><b>', |
|
265 | + '</b><br />', |
|
266 | + '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">', |
|
267 | + '</a></span></div>' |
|
268 | + ); |
|
269 | + } |
|
270 | + return ' |
|
271 | 271 | <div class="ee-event-expired-notice"> |
272 | 272 | <span class="important-notice">' . $no_ticket_available_msg . '</span> |
273 | 273 | </div>'; |
274 | - } |
|
275 | - |
|
276 | - |
|
277 | - |
|
278 | - /** |
|
279 | - * ticketSalesClosed |
|
280 | - * notice displayed if event ticket sales are turned off |
|
281 | - * |
|
282 | - * @return string |
|
283 | - * @throws \EE_Error |
|
284 | - */ |
|
285 | - protected function ticketSalesClosedMessage() |
|
286 | - { |
|
287 | - $sales_closed_msg = esc_html__( |
|
288 | - 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', |
|
289 | - 'event_espresso' |
|
290 | - ); |
|
291 | - if (current_user_can('edit_post', $this->event->ID())) { |
|
292 | - $sales_closed_msg .= sprintf( |
|
293 | - esc_html__( |
|
294 | - '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', |
|
295 | - 'event_espresso' |
|
296 | - ), |
|
297 | - '<div class="ee-attention" style="text-align: left;"><b>', |
|
298 | - '</b><br />', |
|
299 | - '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">', |
|
300 | - '</a></span></div>' |
|
301 | - ); |
|
302 | - } |
|
303 | - return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
|
304 | - } |
|
305 | - |
|
306 | - |
|
307 | - |
|
308 | - /** |
|
309 | - * getTickets |
|
310 | - * |
|
311 | - * @return \EE_Base_Class[]|\EE_Ticket[] |
|
312 | - * @throws \EE_Error |
|
313 | - */ |
|
314 | - protected function getTickets() |
|
315 | - { |
|
316 | - $ticket_query_args = array( |
|
317 | - array('Datetime.EVT_ID' => $this->event->ID()), |
|
318 | - 'order_by' => array( |
|
319 | - 'TKT_order' => 'ASC', |
|
320 | - 'TKT_required' => 'DESC', |
|
321 | - 'TKT_start_date' => 'ASC', |
|
322 | - 'TKT_end_date' => 'ASC', |
|
323 | - 'Datetime.DTT_EVT_start' => 'DESC', |
|
324 | - ), |
|
325 | - ); |
|
326 | - if ( ! \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) { |
|
327 | - //use the correct applicable time query depending on what version of core is being run. |
|
328 | - $current_time = method_exists('EEM_Datetime', 'current_time_for_query') |
|
329 | - ? time() |
|
330 | - : current_time('timestamp'); |
|
331 | - $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time); |
|
332 | - } |
|
333 | - return \EEM_Ticket::instance()->get_all($ticket_query_args); |
|
334 | - } |
|
335 | - |
|
336 | - |
|
337 | - |
|
338 | - /** |
|
339 | - * loadTicketSelector |
|
340 | - * begins to assemble template arguments |
|
341 | - * and decides whether to load a "simple" ticket selector, or the standard |
|
342 | - * |
|
343 | - * @param \EE_Ticket[] $tickets |
|
344 | - * @param array $template_args |
|
345 | - * @return string |
|
346 | - * @throws \EE_Error |
|
347 | - */ |
|
348 | - protected function loadTicketSelector(array $tickets, array $template_args) |
|
349 | - { |
|
350 | - $template_args['event'] = $this->event; |
|
351 | - $template_args['EVT_ID'] = $this->event->ID(); |
|
352 | - $template_args['event_is_expired'] = $this->event->is_expired(); |
|
353 | - $template_args['max_atndz'] = $this->getMaxAttendees(); |
|
354 | - $template_args['date_format'] = $this->date_format; |
|
355 | - $template_args['time_format'] = $this->time_format; |
|
356 | - /** |
|
357 | - * Filters the anchor ID used when redirecting to the Ticket Selector if no quantity selected |
|
358 | - * |
|
359 | - * @since 4.9.13 |
|
360 | - * @param string '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to |
|
361 | - * @param int $EVT_ID The Event ID |
|
362 | - */ |
|
363 | - $template_args['anchor_id'] = apply_filters( |
|
364 | - 'FHEE__EE_Ticket_Selector__redirect_anchor_id', |
|
365 | - '#tkt-slctr-tbl-' . $this->event->ID(), |
|
366 | - $this->event->ID() |
|
367 | - ); |
|
368 | - $template_args['tickets'] = $tickets; |
|
369 | - $template_args['ticket_count'] = count($tickets); |
|
370 | - $ticket_selector = $this->simpleTicketSelector( $tickets, $template_args); |
|
371 | - return $ticket_selector instanceof TicketSelectorSimple |
|
372 | - ? $ticket_selector |
|
373 | - : new TicketSelectorStandard( |
|
374 | - $this->event, |
|
375 | - $tickets, |
|
376 | - $this->getMaxAttendees(), |
|
377 | - $template_args, |
|
378 | - $this->date_format, |
|
379 | - $this->time_format |
|
380 | - ); |
|
381 | - } |
|
382 | - |
|
383 | - |
|
384 | - |
|
385 | - /** |
|
386 | - * simpleTicketSelector |
|
387 | - * there's one ticket, and max attendees is set to one, |
|
388 | - * so if the event is free, then this is a "simple" ticket selector |
|
389 | - * a.k.a. "Dude Where's my Ticket Selector?" |
|
390 | - * |
|
391 | - * @param \EE_Ticket[] $tickets |
|
392 | - * @param array $template_args |
|
393 | - * @return string |
|
394 | - * @throws \EE_Error |
|
395 | - */ |
|
396 | - protected function simpleTicketSelector($tickets, array $template_args) |
|
397 | - { |
|
398 | - // if there is only ONE ticket with a max qty of ONE |
|
399 | - if (count($tickets) > 1 || $this->getMaxAttendees() !== 1) { |
|
400 | - return ''; |
|
401 | - } |
|
402 | - /** @var \EE_Ticket $ticket */ |
|
403 | - $ticket = reset($tickets); |
|
404 | - // if the ticket is free... then not much need for the ticket selector |
|
405 | - if ( |
|
406 | - apply_filters( |
|
407 | - 'FHEE__ticket_selector_chart_template__hide_ticket_selector', |
|
408 | - $ticket->is_free(), |
|
409 | - $this->event->ID() |
|
410 | - ) |
|
411 | - ) { |
|
412 | - return new TicketSelectorSimple( |
|
413 | - $this->event, |
|
414 | - $ticket, |
|
415 | - $this->getMaxAttendees(), |
|
416 | - $template_args |
|
417 | - ); |
|
418 | - } |
|
419 | - return ''; |
|
420 | - } |
|
421 | - |
|
422 | - |
|
423 | - |
|
424 | - /** |
|
425 | - * externalEventRegistration |
|
426 | - * |
|
427 | - * @return string |
|
428 | - */ |
|
429 | - public function externalEventRegistration() |
|
430 | - { |
|
431 | - // if not we still need to trigger the display of the submit button |
|
432 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
433 | - //display notice to admin that registration is external |
|
434 | - return is_admin() |
|
435 | - ? esc_html__( |
|
436 | - 'Registration is at an external URL for this event.', |
|
437 | - 'event_espresso' |
|
438 | - ) |
|
439 | - : ''; |
|
440 | - } |
|
441 | - |
|
442 | - |
|
443 | - |
|
444 | - /** |
|
445 | - * formOpen |
|
446 | - * |
|
447 | - * @param int $ID |
|
448 | - * @param string $external_url |
|
449 | - * @return string |
|
450 | - */ |
|
451 | - public function formOpen( $ID = 0, $external_url = '' ) |
|
452 | - { |
|
453 | - // if redirecting, we don't need any anything else |
|
454 | - if ( $external_url ) { |
|
455 | - $html = '<form method="GET" action="' . \EEH_URL::refactor_url($external_url) . '"'; |
|
456 | - // open link in new window ? |
|
457 | - $html .= apply_filters( |
|
458 | - 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank', |
|
459 | - \EED_Events_Archive::is_iframe() |
|
460 | - ) |
|
461 | - ? ' target="_blank"' |
|
462 | - : ''; |
|
463 | - $html .= '>'; |
|
464 | - $query_args = \EEH_URL::get_query_string( $external_url ); |
|
465 | - foreach ( (array)$query_args as $query_arg => $value ) { |
|
466 | - $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; |
|
467 | - } |
|
468 | - return $html; |
|
469 | - } |
|
470 | - // if there is no submit button, then don't start building a form |
|
471 | - // because the "View Details" button will build its own form |
|
472 | - if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) { |
|
473 | - return ''; |
|
474 | - } |
|
475 | - $checkout_url = \EEH_Event_View::event_link_url( $ID ); |
|
476 | - if ( ! $checkout_url ) { |
|
477 | - \EE_Error::add_error( |
|
478 | - esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ), |
|
479 | - __FILE__, |
|
480 | - __FUNCTION__, |
|
481 | - __LINE__ |
|
482 | - ); |
|
483 | - } |
|
484 | - // set no cache headers and constants |
|
485 | - \EE_System::do_not_cache(); |
|
486 | - $extra_params = $this->iframe ? ' target="_blank"' : ''; |
|
487 | - $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>'; |
|
488 | - $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, true, false ); |
|
489 | - $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; |
|
490 | - $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event ); |
|
491 | - return $html; |
|
492 | - } |
|
493 | - |
|
494 | - |
|
495 | - |
|
496 | - /** |
|
497 | - * displaySubmitButton |
|
498 | - * |
|
499 | - * @param string $external_url |
|
500 | - * @return string |
|
501 | - * @throws \EE_Error |
|
502 | - */ |
|
503 | - public function displaySubmitButton($external_url = '') |
|
504 | - { |
|
505 | - $html = ''; |
|
506 | - if ( ! is_admin()) { |
|
507 | - // standard TS displayed with submit button, ie: "Register Now" |
|
508 | - if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) { |
|
509 | - $html .= $this->displayRegisterNowButton(); |
|
510 | - $html .= empty($external_url) |
|
511 | - ? $this->ticketSelectorEndDiv() |
|
512 | - : $this->clearTicketSelector(); |
|
513 | - $html .= '<br/>' . $this->formClose(); |
|
514 | - } else if ($this->getMaxAttendees() === 1) { |
|
515 | - // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1) |
|
516 | - if ($this->event->is_sold_out()) { |
|
517 | - // then instead of a View Details or Submit button, just display a "Sold Out" message |
|
518 | - $html .= apply_filters( |
|
519 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg', |
|
520 | - sprintf( |
|
521 | - __( |
|
522 | - '%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s', |
|
523 | - 'event_espresso' |
|
524 | - ), |
|
525 | - '<p class="no-ticket-selector-msg clear-float">', |
|
526 | - $this->event->name(), |
|
527 | - '</p>', |
|
528 | - '<br />' |
|
529 | - ), |
|
530 | - $this->event |
|
531 | - ); |
|
532 | - if ( |
|
533 | - apply_filters( |
|
534 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button', |
|
535 | - false, |
|
536 | - $this->event |
|
537 | - ) |
|
538 | - ) { |
|
539 | - $html .= $this->displayRegisterNowButton(); |
|
540 | - } |
|
541 | - // sold out DWMTS event, no TS, no submit or view details button, but has additional content |
|
542 | - $html .= $this->ticketSelectorEndDiv(); |
|
543 | - } else if ( |
|
544 | - apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false) |
|
545 | - && ! is_single() |
|
546 | - ) { |
|
547 | - // this is a "Dude Where's my Ticket Selector?" (DWMTS) type event, |
|
548 | - // but no tickets are available, so display event's "View Details" button. |
|
549 | - // it is being viewed via somewhere other than a single post |
|
550 | - $html .= $this->displayViewDetailsButton(true); |
|
551 | - } |
|
552 | - } else if (is_archive()) { |
|
553 | - // event list, no tickets available so display event's "View Details" button |
|
554 | - $html .= $this->ticketSelectorEndDiv(); |
|
555 | - $html .= $this->displayViewDetailsButton(); |
|
556 | - } else { |
|
557 | - if ( |
|
558 | - apply_filters( |
|
559 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button', |
|
560 | - false, |
|
561 | - $this->event |
|
562 | - ) |
|
563 | - ) { |
|
564 | - $html .= $this->displayRegisterNowButton(); |
|
565 | - } |
|
566 | - // no submit or view details button, and no additional content |
|
567 | - $html .= $this->ticketSelectorEndDiv(); |
|
568 | - } |
|
569 | - if ( ! $this->iframe && ! is_archive()) { |
|
570 | - $html .= \EEH_Template::powered_by_event_espresso('', '', array('utm_content' => 'ticket_selector')); |
|
571 | - } |
|
572 | - } |
|
573 | - return $html; |
|
574 | - } |
|
575 | - |
|
576 | - |
|
577 | - |
|
578 | - /** |
|
579 | - * @return string |
|
580 | - * @throws \EE_Error |
|
581 | - */ |
|
582 | - public function displayRegisterNowButton() |
|
583 | - { |
|
584 | - $btn_text = apply_filters( |
|
585 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text', |
|
586 | - __('Register Now', 'event_espresso'), |
|
587 | - $this->event |
|
588 | - ); |
|
589 | - $external_url = $this->event->external_url(); |
|
590 | - $html = \EEH_HTML::div( |
|
591 | - '', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap' |
|
592 | - ); |
|
593 | - $html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"'; |
|
594 | - $html .= ' class="ticket-selector-submit-btn '; |
|
595 | - $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"'; |
|
596 | - $html .= ' type="submit" value="' . $btn_text . '" />'; |
|
597 | - $html .= \EEH_HTML::divx(); |
|
598 | - $html .= apply_filters( |
|
599 | - 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', |
|
600 | - '', |
|
601 | - $this->event |
|
602 | - ); |
|
603 | - return $html; |
|
604 | - } |
|
605 | - |
|
606 | - |
|
607 | - /** |
|
608 | - * displayViewDetailsButton |
|
609 | - * |
|
610 | - * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event |
|
611 | - * (ie: $_max_atndz === 1) where there are no available tickets, |
|
612 | - * either because they are sold out, expired, or not yet on sale. |
|
613 | - * In this case, we need to close the form BEFORE adding any closing divs |
|
614 | - * @return string |
|
615 | - * @throws \EE_Error |
|
616 | - */ |
|
617 | - public function displayViewDetailsButton( $DWMTS = false ) |
|
618 | - { |
|
619 | - if ( ! $this->event->get_permalink() ) { |
|
620 | - \EE_Error::add_error( |
|
621 | - esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ), |
|
622 | - __FILE__, __FUNCTION__, __LINE__ |
|
623 | - ); |
|
624 | - } |
|
625 | - $view_details_btn = '<form method="POST" action="'; |
|
626 | - $view_details_btn .= apply_filters( |
|
627 | - 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_url', |
|
628 | - $this->event->get_permalink(), |
|
629 | - $this->event |
|
630 | - ); |
|
631 | - $view_details_btn .= '"'; |
|
632 | - // open link in new window ? |
|
633 | - $view_details_btn .= apply_filters( |
|
634 | - 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displayViewDetailsButton__url_target_blank', |
|
635 | - \EED_Events_Archive::is_iframe() |
|
636 | - ) |
|
637 | - ? ' target="_blank"' |
|
638 | - : ''; |
|
639 | - $view_details_btn .='>'; |
|
640 | - $btn_text = apply_filters( |
|
641 | - 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', |
|
642 | - esc_html__('View Details', 'event_espresso'), |
|
643 | - $this->event |
|
644 | - ); |
|
645 | - $view_details_btn .= '<input id="ticket-selector-submit-' |
|
646 | - . $this->event->ID() |
|
647 | - . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' |
|
648 | - . $btn_text |
|
649 | - . '" />'; |
|
650 | - $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event ); |
|
651 | - if ($DWMTS) { |
|
652 | - $view_details_btn .= $this->formClose(); |
|
653 | - $view_details_btn .= $this->ticketSelectorEndDiv(); |
|
654 | - $view_details_btn .= '<br/>'; |
|
655 | - } else { |
|
656 | - $view_details_btn .= $this->clearTicketSelector(); |
|
657 | - $view_details_btn .= '<br/>'; |
|
658 | - $view_details_btn .= $this->formClose(); |
|
659 | - } |
|
660 | - return $view_details_btn; |
|
661 | - } |
|
662 | - |
|
663 | - |
|
664 | - |
|
665 | - /** |
|
666 | - * @return string |
|
667 | - */ |
|
668 | - public function ticketSelectorEndDiv() |
|
669 | - { |
|
670 | - return '<div class="clear"></div></div>'; |
|
671 | - } |
|
672 | - |
|
673 | - |
|
674 | - |
|
675 | - /** |
|
676 | - * @return string |
|
677 | - */ |
|
678 | - public function clearTicketSelector() |
|
679 | - { |
|
680 | - // standard TS displayed, appears after a "Register Now" or "view Details" button |
|
681 | - return '<div class="clear"></div>'; |
|
682 | - } |
|
683 | - |
|
684 | - |
|
685 | - |
|
686 | - /** |
|
687 | - * @access public |
|
688 | - * @return string |
|
689 | - */ |
|
690 | - public function formClose() |
|
691 | - { |
|
692 | - return '</form>'; |
|
693 | - } |
|
274 | + } |
|
275 | + |
|
276 | + |
|
277 | + |
|
278 | + /** |
|
279 | + * ticketSalesClosed |
|
280 | + * notice displayed if event ticket sales are turned off |
|
281 | + * |
|
282 | + * @return string |
|
283 | + * @throws \EE_Error |
|
284 | + */ |
|
285 | + protected function ticketSalesClosedMessage() |
|
286 | + { |
|
287 | + $sales_closed_msg = esc_html__( |
|
288 | + 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', |
|
289 | + 'event_espresso' |
|
290 | + ); |
|
291 | + if (current_user_can('edit_post', $this->event->ID())) { |
|
292 | + $sales_closed_msg .= sprintf( |
|
293 | + esc_html__( |
|
294 | + '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', |
|
295 | + 'event_espresso' |
|
296 | + ), |
|
297 | + '<div class="ee-attention" style="text-align: left;"><b>', |
|
298 | + '</b><br />', |
|
299 | + '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">', |
|
300 | + '</a></span></div>' |
|
301 | + ); |
|
302 | + } |
|
303 | + return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
|
304 | + } |
|
305 | + |
|
306 | + |
|
307 | + |
|
308 | + /** |
|
309 | + * getTickets |
|
310 | + * |
|
311 | + * @return \EE_Base_Class[]|\EE_Ticket[] |
|
312 | + * @throws \EE_Error |
|
313 | + */ |
|
314 | + protected function getTickets() |
|
315 | + { |
|
316 | + $ticket_query_args = array( |
|
317 | + array('Datetime.EVT_ID' => $this->event->ID()), |
|
318 | + 'order_by' => array( |
|
319 | + 'TKT_order' => 'ASC', |
|
320 | + 'TKT_required' => 'DESC', |
|
321 | + 'TKT_start_date' => 'ASC', |
|
322 | + 'TKT_end_date' => 'ASC', |
|
323 | + 'Datetime.DTT_EVT_start' => 'DESC', |
|
324 | + ), |
|
325 | + ); |
|
326 | + if ( ! \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) { |
|
327 | + //use the correct applicable time query depending on what version of core is being run. |
|
328 | + $current_time = method_exists('EEM_Datetime', 'current_time_for_query') |
|
329 | + ? time() |
|
330 | + : current_time('timestamp'); |
|
331 | + $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time); |
|
332 | + } |
|
333 | + return \EEM_Ticket::instance()->get_all($ticket_query_args); |
|
334 | + } |
|
335 | + |
|
336 | + |
|
337 | + |
|
338 | + /** |
|
339 | + * loadTicketSelector |
|
340 | + * begins to assemble template arguments |
|
341 | + * and decides whether to load a "simple" ticket selector, or the standard |
|
342 | + * |
|
343 | + * @param \EE_Ticket[] $tickets |
|
344 | + * @param array $template_args |
|
345 | + * @return string |
|
346 | + * @throws \EE_Error |
|
347 | + */ |
|
348 | + protected function loadTicketSelector(array $tickets, array $template_args) |
|
349 | + { |
|
350 | + $template_args['event'] = $this->event; |
|
351 | + $template_args['EVT_ID'] = $this->event->ID(); |
|
352 | + $template_args['event_is_expired'] = $this->event->is_expired(); |
|
353 | + $template_args['max_atndz'] = $this->getMaxAttendees(); |
|
354 | + $template_args['date_format'] = $this->date_format; |
|
355 | + $template_args['time_format'] = $this->time_format; |
|
356 | + /** |
|
357 | + * Filters the anchor ID used when redirecting to the Ticket Selector if no quantity selected |
|
358 | + * |
|
359 | + * @since 4.9.13 |
|
360 | + * @param string '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to |
|
361 | + * @param int $EVT_ID The Event ID |
|
362 | + */ |
|
363 | + $template_args['anchor_id'] = apply_filters( |
|
364 | + 'FHEE__EE_Ticket_Selector__redirect_anchor_id', |
|
365 | + '#tkt-slctr-tbl-' . $this->event->ID(), |
|
366 | + $this->event->ID() |
|
367 | + ); |
|
368 | + $template_args['tickets'] = $tickets; |
|
369 | + $template_args['ticket_count'] = count($tickets); |
|
370 | + $ticket_selector = $this->simpleTicketSelector( $tickets, $template_args); |
|
371 | + return $ticket_selector instanceof TicketSelectorSimple |
|
372 | + ? $ticket_selector |
|
373 | + : new TicketSelectorStandard( |
|
374 | + $this->event, |
|
375 | + $tickets, |
|
376 | + $this->getMaxAttendees(), |
|
377 | + $template_args, |
|
378 | + $this->date_format, |
|
379 | + $this->time_format |
|
380 | + ); |
|
381 | + } |
|
382 | + |
|
383 | + |
|
384 | + |
|
385 | + /** |
|
386 | + * simpleTicketSelector |
|
387 | + * there's one ticket, and max attendees is set to one, |
|
388 | + * so if the event is free, then this is a "simple" ticket selector |
|
389 | + * a.k.a. "Dude Where's my Ticket Selector?" |
|
390 | + * |
|
391 | + * @param \EE_Ticket[] $tickets |
|
392 | + * @param array $template_args |
|
393 | + * @return string |
|
394 | + * @throws \EE_Error |
|
395 | + */ |
|
396 | + protected function simpleTicketSelector($tickets, array $template_args) |
|
397 | + { |
|
398 | + // if there is only ONE ticket with a max qty of ONE |
|
399 | + if (count($tickets) > 1 || $this->getMaxAttendees() !== 1) { |
|
400 | + return ''; |
|
401 | + } |
|
402 | + /** @var \EE_Ticket $ticket */ |
|
403 | + $ticket = reset($tickets); |
|
404 | + // if the ticket is free... then not much need for the ticket selector |
|
405 | + if ( |
|
406 | + apply_filters( |
|
407 | + 'FHEE__ticket_selector_chart_template__hide_ticket_selector', |
|
408 | + $ticket->is_free(), |
|
409 | + $this->event->ID() |
|
410 | + ) |
|
411 | + ) { |
|
412 | + return new TicketSelectorSimple( |
|
413 | + $this->event, |
|
414 | + $ticket, |
|
415 | + $this->getMaxAttendees(), |
|
416 | + $template_args |
|
417 | + ); |
|
418 | + } |
|
419 | + return ''; |
|
420 | + } |
|
421 | + |
|
422 | + |
|
423 | + |
|
424 | + /** |
|
425 | + * externalEventRegistration |
|
426 | + * |
|
427 | + * @return string |
|
428 | + */ |
|
429 | + public function externalEventRegistration() |
|
430 | + { |
|
431 | + // if not we still need to trigger the display of the submit button |
|
432 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
433 | + //display notice to admin that registration is external |
|
434 | + return is_admin() |
|
435 | + ? esc_html__( |
|
436 | + 'Registration is at an external URL for this event.', |
|
437 | + 'event_espresso' |
|
438 | + ) |
|
439 | + : ''; |
|
440 | + } |
|
441 | + |
|
442 | + |
|
443 | + |
|
444 | + /** |
|
445 | + * formOpen |
|
446 | + * |
|
447 | + * @param int $ID |
|
448 | + * @param string $external_url |
|
449 | + * @return string |
|
450 | + */ |
|
451 | + public function formOpen( $ID = 0, $external_url = '' ) |
|
452 | + { |
|
453 | + // if redirecting, we don't need any anything else |
|
454 | + if ( $external_url ) { |
|
455 | + $html = '<form method="GET" action="' . \EEH_URL::refactor_url($external_url) . '"'; |
|
456 | + // open link in new window ? |
|
457 | + $html .= apply_filters( |
|
458 | + 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank', |
|
459 | + \EED_Events_Archive::is_iframe() |
|
460 | + ) |
|
461 | + ? ' target="_blank"' |
|
462 | + : ''; |
|
463 | + $html .= '>'; |
|
464 | + $query_args = \EEH_URL::get_query_string( $external_url ); |
|
465 | + foreach ( (array)$query_args as $query_arg => $value ) { |
|
466 | + $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; |
|
467 | + } |
|
468 | + return $html; |
|
469 | + } |
|
470 | + // if there is no submit button, then don't start building a form |
|
471 | + // because the "View Details" button will build its own form |
|
472 | + if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) { |
|
473 | + return ''; |
|
474 | + } |
|
475 | + $checkout_url = \EEH_Event_View::event_link_url( $ID ); |
|
476 | + if ( ! $checkout_url ) { |
|
477 | + \EE_Error::add_error( |
|
478 | + esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ), |
|
479 | + __FILE__, |
|
480 | + __FUNCTION__, |
|
481 | + __LINE__ |
|
482 | + ); |
|
483 | + } |
|
484 | + // set no cache headers and constants |
|
485 | + \EE_System::do_not_cache(); |
|
486 | + $extra_params = $this->iframe ? ' target="_blank"' : ''; |
|
487 | + $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>'; |
|
488 | + $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, true, false ); |
|
489 | + $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; |
|
490 | + $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event ); |
|
491 | + return $html; |
|
492 | + } |
|
493 | + |
|
494 | + |
|
495 | + |
|
496 | + /** |
|
497 | + * displaySubmitButton |
|
498 | + * |
|
499 | + * @param string $external_url |
|
500 | + * @return string |
|
501 | + * @throws \EE_Error |
|
502 | + */ |
|
503 | + public function displaySubmitButton($external_url = '') |
|
504 | + { |
|
505 | + $html = ''; |
|
506 | + if ( ! is_admin()) { |
|
507 | + // standard TS displayed with submit button, ie: "Register Now" |
|
508 | + if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) { |
|
509 | + $html .= $this->displayRegisterNowButton(); |
|
510 | + $html .= empty($external_url) |
|
511 | + ? $this->ticketSelectorEndDiv() |
|
512 | + : $this->clearTicketSelector(); |
|
513 | + $html .= '<br/>' . $this->formClose(); |
|
514 | + } else if ($this->getMaxAttendees() === 1) { |
|
515 | + // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1) |
|
516 | + if ($this->event->is_sold_out()) { |
|
517 | + // then instead of a View Details or Submit button, just display a "Sold Out" message |
|
518 | + $html .= apply_filters( |
|
519 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg', |
|
520 | + sprintf( |
|
521 | + __( |
|
522 | + '%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s', |
|
523 | + 'event_espresso' |
|
524 | + ), |
|
525 | + '<p class="no-ticket-selector-msg clear-float">', |
|
526 | + $this->event->name(), |
|
527 | + '</p>', |
|
528 | + '<br />' |
|
529 | + ), |
|
530 | + $this->event |
|
531 | + ); |
|
532 | + if ( |
|
533 | + apply_filters( |
|
534 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button', |
|
535 | + false, |
|
536 | + $this->event |
|
537 | + ) |
|
538 | + ) { |
|
539 | + $html .= $this->displayRegisterNowButton(); |
|
540 | + } |
|
541 | + // sold out DWMTS event, no TS, no submit or view details button, but has additional content |
|
542 | + $html .= $this->ticketSelectorEndDiv(); |
|
543 | + } else if ( |
|
544 | + apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false) |
|
545 | + && ! is_single() |
|
546 | + ) { |
|
547 | + // this is a "Dude Where's my Ticket Selector?" (DWMTS) type event, |
|
548 | + // but no tickets are available, so display event's "View Details" button. |
|
549 | + // it is being viewed via somewhere other than a single post |
|
550 | + $html .= $this->displayViewDetailsButton(true); |
|
551 | + } |
|
552 | + } else if (is_archive()) { |
|
553 | + // event list, no tickets available so display event's "View Details" button |
|
554 | + $html .= $this->ticketSelectorEndDiv(); |
|
555 | + $html .= $this->displayViewDetailsButton(); |
|
556 | + } else { |
|
557 | + if ( |
|
558 | + apply_filters( |
|
559 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button', |
|
560 | + false, |
|
561 | + $this->event |
|
562 | + ) |
|
563 | + ) { |
|
564 | + $html .= $this->displayRegisterNowButton(); |
|
565 | + } |
|
566 | + // no submit or view details button, and no additional content |
|
567 | + $html .= $this->ticketSelectorEndDiv(); |
|
568 | + } |
|
569 | + if ( ! $this->iframe && ! is_archive()) { |
|
570 | + $html .= \EEH_Template::powered_by_event_espresso('', '', array('utm_content' => 'ticket_selector')); |
|
571 | + } |
|
572 | + } |
|
573 | + return $html; |
|
574 | + } |
|
575 | + |
|
576 | + |
|
577 | + |
|
578 | + /** |
|
579 | + * @return string |
|
580 | + * @throws \EE_Error |
|
581 | + */ |
|
582 | + public function displayRegisterNowButton() |
|
583 | + { |
|
584 | + $btn_text = apply_filters( |
|
585 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text', |
|
586 | + __('Register Now', 'event_espresso'), |
|
587 | + $this->event |
|
588 | + ); |
|
589 | + $external_url = $this->event->external_url(); |
|
590 | + $html = \EEH_HTML::div( |
|
591 | + '', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap' |
|
592 | + ); |
|
593 | + $html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"'; |
|
594 | + $html .= ' class="ticket-selector-submit-btn '; |
|
595 | + $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"'; |
|
596 | + $html .= ' type="submit" value="' . $btn_text . '" />'; |
|
597 | + $html .= \EEH_HTML::divx(); |
|
598 | + $html .= apply_filters( |
|
599 | + 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', |
|
600 | + '', |
|
601 | + $this->event |
|
602 | + ); |
|
603 | + return $html; |
|
604 | + } |
|
605 | + |
|
606 | + |
|
607 | + /** |
|
608 | + * displayViewDetailsButton |
|
609 | + * |
|
610 | + * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event |
|
611 | + * (ie: $_max_atndz === 1) where there are no available tickets, |
|
612 | + * either because they are sold out, expired, or not yet on sale. |
|
613 | + * In this case, we need to close the form BEFORE adding any closing divs |
|
614 | + * @return string |
|
615 | + * @throws \EE_Error |
|
616 | + */ |
|
617 | + public function displayViewDetailsButton( $DWMTS = false ) |
|
618 | + { |
|
619 | + if ( ! $this->event->get_permalink() ) { |
|
620 | + \EE_Error::add_error( |
|
621 | + esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ), |
|
622 | + __FILE__, __FUNCTION__, __LINE__ |
|
623 | + ); |
|
624 | + } |
|
625 | + $view_details_btn = '<form method="POST" action="'; |
|
626 | + $view_details_btn .= apply_filters( |
|
627 | + 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_url', |
|
628 | + $this->event->get_permalink(), |
|
629 | + $this->event |
|
630 | + ); |
|
631 | + $view_details_btn .= '"'; |
|
632 | + // open link in new window ? |
|
633 | + $view_details_btn .= apply_filters( |
|
634 | + 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displayViewDetailsButton__url_target_blank', |
|
635 | + \EED_Events_Archive::is_iframe() |
|
636 | + ) |
|
637 | + ? ' target="_blank"' |
|
638 | + : ''; |
|
639 | + $view_details_btn .='>'; |
|
640 | + $btn_text = apply_filters( |
|
641 | + 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', |
|
642 | + esc_html__('View Details', 'event_espresso'), |
|
643 | + $this->event |
|
644 | + ); |
|
645 | + $view_details_btn .= '<input id="ticket-selector-submit-' |
|
646 | + . $this->event->ID() |
|
647 | + . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' |
|
648 | + . $btn_text |
|
649 | + . '" />'; |
|
650 | + $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event ); |
|
651 | + if ($DWMTS) { |
|
652 | + $view_details_btn .= $this->formClose(); |
|
653 | + $view_details_btn .= $this->ticketSelectorEndDiv(); |
|
654 | + $view_details_btn .= '<br/>'; |
|
655 | + } else { |
|
656 | + $view_details_btn .= $this->clearTicketSelector(); |
|
657 | + $view_details_btn .= '<br/>'; |
|
658 | + $view_details_btn .= $this->formClose(); |
|
659 | + } |
|
660 | + return $view_details_btn; |
|
661 | + } |
|
662 | + |
|
663 | + |
|
664 | + |
|
665 | + /** |
|
666 | + * @return string |
|
667 | + */ |
|
668 | + public function ticketSelectorEndDiv() |
|
669 | + { |
|
670 | + return '<div class="clear"></div></div>'; |
|
671 | + } |
|
672 | + |
|
673 | + |
|
674 | + |
|
675 | + /** |
|
676 | + * @return string |
|
677 | + */ |
|
678 | + public function clearTicketSelector() |
|
679 | + { |
|
680 | + // standard TS displayed, appears after a "Register Now" or "view Details" button |
|
681 | + return '<div class="clear"></div>'; |
|
682 | + } |
|
683 | + |
|
684 | + |
|
685 | + |
|
686 | + /** |
|
687 | + * @access public |
|
688 | + * @return string |
|
689 | + */ |
|
690 | + public function formClose() |
|
691 | + { |
|
692 | + return '</form>'; |
|
693 | + } |
|
694 | 694 | |
695 | 695 | |
696 | 696 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\modules\ticket_selector; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | /** |
74 | 74 | * @param boolean $iframe |
75 | 75 | */ |
76 | - public function setIframe( $iframe = true ) |
|
76 | + public function setIframe($iframe = true) |
|
77 | 77 | { |
78 | - $this->iframe = filter_var( $iframe, FILTER_VALIDATE_BOOLEAN ); |
|
78 | + $this->iframe = filter_var($iframe, FILTER_VALIDATE_BOOLEAN); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -86,28 +86,28 @@ discard block |
||
86 | 86 | * @param mixed $event |
87 | 87 | * @return bool |
88 | 88 | */ |
89 | - protected function setEvent( $event = null ) |
|
89 | + protected function setEvent($event = null) |
|
90 | 90 | { |
91 | - if ( $event === null ) { |
|
91 | + if ($event === null) { |
|
92 | 92 | global $post; |
93 | 93 | $event = $post; |
94 | 94 | } |
95 | - if ( $event instanceof \EE_Event ) { |
|
95 | + if ($event instanceof \EE_Event) { |
|
96 | 96 | $this->event = $event; |
97 | - } else if ( $event instanceof \WP_Post ) { |
|
98 | - if ( isset( $event->EE_Event ) && $event->EE_Event instanceof \EE_Event ) { |
|
97 | + } else if ($event instanceof \WP_Post) { |
|
98 | + if (isset($event->EE_Event) && $event->EE_Event instanceof \EE_Event) { |
|
99 | 99 | $this->event = $event->EE_Event; |
100 | - } else if ( $event->post_type === 'espresso_events' ) { |
|
101 | - $event->EE_Event = \EEM_Event::instance()->instantiate_class_from_post_object( $event ); |
|
100 | + } else if ($event->post_type === 'espresso_events') { |
|
101 | + $event->EE_Event = \EEM_Event::instance()->instantiate_class_from_post_object($event); |
|
102 | 102 | $this->event = $event->EE_Event; |
103 | 103 | } |
104 | 104 | } else { |
105 | - $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' ); |
|
106 | - $dev_msg = $user_msg . __( |
|
105 | + $user_msg = __('No Event object or an invalid Event object was supplied.', 'event_espresso'); |
|
106 | + $dev_msg = $user_msg.__( |
|
107 | 107 | 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', |
108 | 108 | 'event_espresso' |
109 | 109 | ); |
110 | - \EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
110 | + \EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
111 | 111 | return false; |
112 | 112 | } |
113 | 113 | return true; |
@@ -148,17 +148,17 @@ discard block |
||
148 | 148 | * @return string |
149 | 149 | * @throws \EE_Error |
150 | 150 | */ |
151 | - public function display( $event = null, $view_details = false ) |
|
151 | + public function display($event = null, $view_details = false) |
|
152 | 152 | { |
153 | 153 | // reset filter for displaying submit button |
154 | - remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
154 | + remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
155 | 155 | // poke and prod incoming event till it tells us what it is |
156 | - if ( ! $this->setEvent( $event ) ) { |
|
156 | + if ( ! $this->setEvent($event)) { |
|
157 | 157 | return false; |
158 | 158 | } |
159 | 159 | // begin gathering template arguments by getting event status |
160 | - $template_args = array( 'event_status' => $this->event->get_active_status() ); |
|
161 | - if ( $this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details) ) { |
|
160 | + $template_args = array('event_status' => $this->event->get_active_status()); |
|
161 | + if ($this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details)) { |
|
162 | 162 | return ! is_single() ? $this->displayViewDetailsButton() : ''; |
163 | 163 | } |
164 | 164 | // filter the maximum qty that can appear in the Ticket Selector qty dropdowns |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | } |
169 | 169 | // is the event expired ? |
170 | 170 | $template_args['event_is_expired'] = $this->event->is_expired(); |
171 | - if ( $template_args[ 'event_is_expired' ] ) { |
|
171 | + if ($template_args['event_is_expired']) { |
|
172 | 172 | return $this->expiredEventMessage(); |
173 | 173 | } |
174 | 174 | // get all tickets for this event ordered by the datetime |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | if (count($tickets) < 1) { |
177 | 177 | return $this->noTicketAvailableMessage(); |
178 | 178 | } |
179 | - if (\EED_Events_Archive::is_iframe()){ |
|
179 | + if (\EED_Events_Archive::is_iframe()) { |
|
180 | 180 | $this->setIframe(); |
181 | 181 | } |
182 | 182 | // redirecting to another site for registration ?? |
@@ -184,10 +184,10 @@ discard block |
||
184 | 184 | // if redirecting to another site for registration, then we don't load the TS |
185 | 185 | $ticket_selector = $external_url |
186 | 186 | ? $this->externalEventRegistration() |
187 | - : $this->loadTicketSelector($tickets,$template_args); |
|
187 | + : $this->loadTicketSelector($tickets, $template_args); |
|
188 | 188 | // now set up the form (but not for the admin) |
189 | 189 | $ticket_selector = ! is_admin() |
190 | - ? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector |
|
190 | + ? $this->formOpen($this->event->ID(), $external_url).$ticket_selector |
|
191 | 191 | : $ticket_selector; |
192 | 192 | // submit button and form close tag |
193 | 193 | $ticket_selector .= ! is_admin() ? $this->displaySubmitButton($external_url) : ''; |
@@ -237,10 +237,10 @@ discard block |
||
237 | 237 | */ |
238 | 238 | protected function expiredEventMessage() |
239 | 239 | { |
240 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__( |
|
240 | + return '<div class="ee-event-expired-notice"><span class="important-notice">'.esc_html__( |
|
241 | 241 | 'We\'re sorry, but all tickets sales have ended because the event is expired.', |
242 | 242 | 'event_espresso' |
243 | - ) . '</span></div>'; |
|
243 | + ).'</span></div>'; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | */ |
255 | 255 | protected function noTicketAvailableMessage() |
256 | 256 | { |
257 | - $no_ticket_available_msg = esc_html__( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ); |
|
257 | + $no_ticket_available_msg = esc_html__('We\'re sorry, but all ticket sales have ended.', 'event_espresso'); |
|
258 | 258 | if (current_user_can('edit_post', $this->event->ID())) { |
259 | 259 | $no_ticket_available_msg .= sprintf( |
260 | 260 | esc_html__( |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | } |
270 | 270 | return ' |
271 | 271 | <div class="ee-event-expired-notice"> |
272 | - <span class="important-notice">' . $no_ticket_available_msg . '</span> |
|
272 | + <span class="important-notice">' . $no_ticket_available_msg.'</span> |
|
273 | 273 | </div>'; |
274 | 274 | } |
275 | 275 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | '</a></span></div>' |
301 | 301 | ); |
302 | 302 | } |
303 | - return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
|
303 | + return '<p><span class="important-notice">'.$sales_closed_msg.'</span></p>'; |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | |
@@ -362,12 +362,12 @@ discard block |
||
362 | 362 | */ |
363 | 363 | $template_args['anchor_id'] = apply_filters( |
364 | 364 | 'FHEE__EE_Ticket_Selector__redirect_anchor_id', |
365 | - '#tkt-slctr-tbl-' . $this->event->ID(), |
|
365 | + '#tkt-slctr-tbl-'.$this->event->ID(), |
|
366 | 366 | $this->event->ID() |
367 | 367 | ); |
368 | 368 | $template_args['tickets'] = $tickets; |
369 | 369 | $template_args['ticket_count'] = count($tickets); |
370 | - $ticket_selector = $this->simpleTicketSelector( $tickets, $template_args); |
|
370 | + $ticket_selector = $this->simpleTicketSelector($tickets, $template_args); |
|
371 | 371 | return $ticket_selector instanceof TicketSelectorSimple |
372 | 372 | ? $ticket_selector |
373 | 373 | : new TicketSelectorStandard( |
@@ -448,11 +448,11 @@ discard block |
||
448 | 448 | * @param string $external_url |
449 | 449 | * @return string |
450 | 450 | */ |
451 | - public function formOpen( $ID = 0, $external_url = '' ) |
|
451 | + public function formOpen($ID = 0, $external_url = '') |
|
452 | 452 | { |
453 | 453 | // if redirecting, we don't need any anything else |
454 | - if ( $external_url ) { |
|
455 | - $html = '<form method="GET" action="' . \EEH_URL::refactor_url($external_url) . '"'; |
|
454 | + if ($external_url) { |
|
455 | + $html = '<form method="GET" action="'.\EEH_URL::refactor_url($external_url).'"'; |
|
456 | 456 | // open link in new window ? |
457 | 457 | $html .= apply_filters( |
458 | 458 | 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank', |
@@ -461,21 +461,21 @@ discard block |
||
461 | 461 | ? ' target="_blank"' |
462 | 462 | : ''; |
463 | 463 | $html .= '>'; |
464 | - $query_args = \EEH_URL::get_query_string( $external_url ); |
|
465 | - foreach ( (array)$query_args as $query_arg => $value ) { |
|
466 | - $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; |
|
464 | + $query_args = \EEH_URL::get_query_string($external_url); |
|
465 | + foreach ((array) $query_args as $query_arg => $value) { |
|
466 | + $html .= '<input type="hidden" name="'.$query_arg.'" value="'.$value.'">'; |
|
467 | 467 | } |
468 | 468 | return $html; |
469 | 469 | } |
470 | 470 | // if there is no submit button, then don't start building a form |
471 | 471 | // because the "View Details" button will build its own form |
472 | - if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) { |
|
472 | + if ( ! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) { |
|
473 | 473 | return ''; |
474 | 474 | } |
475 | - $checkout_url = \EEH_Event_View::event_link_url( $ID ); |
|
476 | - if ( ! $checkout_url ) { |
|
475 | + $checkout_url = \EEH_Event_View::event_link_url($ID); |
|
476 | + if ( ! $checkout_url) { |
|
477 | 477 | \EE_Error::add_error( |
478 | - esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ), |
|
478 | + esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), |
|
479 | 479 | __FILE__, |
480 | 480 | __FUNCTION__, |
481 | 481 | __LINE__ |
@@ -484,10 +484,10 @@ discard block |
||
484 | 484 | // set no cache headers and constants |
485 | 485 | \EE_System::do_not_cache(); |
486 | 486 | $extra_params = $this->iframe ? ' target="_blank"' : ''; |
487 | - $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>'; |
|
488 | - $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, true, false ); |
|
487 | + $html = '<form method="POST" action="'.$checkout_url.'"'.$extra_params.'>'; |
|
488 | + $html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce_'.$ID, true, false); |
|
489 | 489 | $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; |
490 | - $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event ); |
|
490 | + $html = apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event); |
|
491 | 491 | return $html; |
492 | 492 | } |
493 | 493 | |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | $html .= empty($external_url) |
511 | 511 | ? $this->ticketSelectorEndDiv() |
512 | 512 | : $this->clearTicketSelector(); |
513 | - $html .= '<br/>' . $this->formClose(); |
|
513 | + $html .= '<br/>'.$this->formClose(); |
|
514 | 514 | } else if ($this->getMaxAttendees() === 1) { |
515 | 515 | // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1) |
516 | 516 | if ($this->event->is_sold_out()) { |
@@ -588,12 +588,12 @@ discard block |
||
588 | 588 | ); |
589 | 589 | $external_url = $this->event->external_url(); |
590 | 590 | $html = \EEH_HTML::div( |
591 | - '', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap' |
|
591 | + '', 'ticket-selector-submit-'.$this->event->ID().'-btn-wrap', 'ticket-selector-submit-btn-wrap' |
|
592 | 592 | ); |
593 | - $html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"'; |
|
593 | + $html .= '<input id="ticket-selector-submit-'.$this->event->ID().'-btn"'; |
|
594 | 594 | $html .= ' class="ticket-selector-submit-btn '; |
595 | 595 | $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"'; |
596 | - $html .= ' type="submit" value="' . $btn_text . '" />'; |
|
596 | + $html .= ' type="submit" value="'.$btn_text.'" />'; |
|
597 | 597 | $html .= \EEH_HTML::divx(); |
598 | 598 | $html .= apply_filters( |
599 | 599 | 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', |
@@ -614,11 +614,11 @@ discard block |
||
614 | 614 | * @return string |
615 | 615 | * @throws \EE_Error |
616 | 616 | */ |
617 | - public function displayViewDetailsButton( $DWMTS = false ) |
|
617 | + public function displayViewDetailsButton($DWMTS = false) |
|
618 | 618 | { |
619 | - if ( ! $this->event->get_permalink() ) { |
|
619 | + if ( ! $this->event->get_permalink()) { |
|
620 | 620 | \EE_Error::add_error( |
621 | - esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ), |
|
621 | + esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), |
|
622 | 622 | __FILE__, __FUNCTION__, __LINE__ |
623 | 623 | ); |
624 | 624 | } |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | ) |
637 | 637 | ? ' target="_blank"' |
638 | 638 | : ''; |
639 | - $view_details_btn .='>'; |
|
639 | + $view_details_btn .= '>'; |
|
640 | 640 | $btn_text = apply_filters( |
641 | 641 | 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', |
642 | 642 | esc_html__('View Details', 'event_espresso'), |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' |
648 | 648 | . $btn_text |
649 | 649 | . '" />'; |
650 | - $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event ); |
|
650 | + $view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event); |
|
651 | 651 | if ($DWMTS) { |
652 | 652 | $view_details_btn .= $this->formClose(); |
653 | 653 | $view_details_btn .= $this->ticketSelectorEndDiv(); |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | ?> |
22 | 22 | <div id="tkt-slctr-tbl-wrap-dv-<?php echo $EVT_ID; ?>" class="tkt-slctr-tbl-wrap-dv"> |
23 | 23 | |
24 | - <?php do_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', $event ); ?> |
|
24 | + <?php do_action('AHEE__ticket_selector_chart__template__before_ticket_selector', $event); ?> |
|
25 | 25 | <?php echo $datetime_selector; ?> |
26 | 26 | |
27 | 27 | <table id="tkt-slctr-tbl-<?php echo $EVT_ID; ?>" class="tkt-slctr-tbl"> |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | ); |
37 | 37 | ?> |
38 | 38 | </th> |
39 | - <?php if ( apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE ) ) { ?> |
|
39 | + <?php if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE)) { ?> |
|
40 | 40 | <th scope="col" class="ee-ticket-selector-ticket-price-th cntr"> |
41 | 41 | <?php |
42 | 42 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | echo apply_filters( |
51 | 51 | 'FHEE__ticket_selector_chart_template__table_header_price', |
52 | - esc_html__( 'Price', 'event_espresso' ), |
|
52 | + esc_html__('Price', 'event_espresso'), |
|
53 | 53 | $EVT_ID |
54 | 54 | ); |
55 | 55 | ?> |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | echo apply_filters( |
69 | 69 | 'FHEE__ticket_selector_chart_template__table_header_qty', |
70 | - esc_html__( 'Qty', 'event_espresso' ), |
|
70 | + esc_html__('Qty', 'event_espresso'), |
|
71 | 71 | $EVT_ID |
72 | 72 | ); |
73 | 73 | ?> |
@@ -75,17 +75,17 @@ discard block |
||
75 | 75 | </tr> |
76 | 76 | </thead> |
77 | 77 | <tbody> |
78 | - <?php echo $ticket_row_html;?> |
|
78 | + <?php echo $ticket_row_html; ?> |
|
79 | 79 | </tbody> |
80 | 80 | </table> |
81 | 81 | <?php |
82 | - if ( $taxable_tickets && apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', true ) ) { |
|
83 | - if ( $prices_displayed_including_taxes ) { |
|
84 | - $ticket_price_includes_taxes = esc_html__( '* price includes taxes', 'event_espresso' ); |
|
82 | + if ($taxable_tickets && apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
83 | + if ($prices_displayed_including_taxes) { |
|
84 | + $ticket_price_includes_taxes = esc_html__('* price includes taxes', 'event_espresso'); |
|
85 | 85 | } else { |
86 | - $ticket_price_includes_taxes = esc_html__( '* price does not include taxes', 'event_espresso' ); |
|
86 | + $ticket_price_includes_taxes = esc_html__('* price does not include taxes', 'event_espresso'); |
|
87 | 87 | } |
88 | - echo '<p class="small-text lt-grey-text" style="text-align:right; margin: -1em 0 1em;">' . $ticket_price_includes_taxes . '</p>'; |
|
88 | + echo '<p class="small-text lt-grey-text" style="text-align:right; margin: -1em 0 1em;">'.$ticket_price_includes_taxes.'</p>'; |
|
89 | 89 | } |
90 | 90 | ?> |
91 | 91 | |
@@ -93,13 +93,13 @@ discard block |
||
93 | 93 | |
94 | 94 | |
95 | 95 | <?php |
96 | -if ( $max_atndz > 0 ) { |
|
96 | +if ($max_atndz > 0) { |
|
97 | 97 | echo apply_filters( |
98 | 98 | 'FHEE__ticket_selector_chart_template__maximum_tickets_purchased_footnote', |
99 | 99 | esc_html('') |
100 | 100 | ); |
101 | 101 | } |
102 | -if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) { |
|
103 | - add_filter( 'FHEE__EE_Ticket_Selector__no_ticket_selector_submit', '__return_true' ); |
|
102 | +if ( ! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) { |
|
103 | + add_filter('FHEE__EE_Ticket_Selector__no_ticket_selector_submit', '__return_true'); |
|
104 | 104 | } |
105 | -do_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event ); |
|
106 | 105 | \ No newline at end of file |
106 | +do_action('AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event); |
|
107 | 107 | \ No newline at end of file |
@@ -16,115 +16,115 @@ |
||
16 | 16 | abstract class TicketSelector |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var \EE_Event $event |
|
21 | - */ |
|
22 | - protected $event; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var \EE_Ticket[] $tickets |
|
26 | - */ |
|
27 | - protected $tickets; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var int max_attendees |
|
31 | - */ |
|
32 | - protected $max_attendees; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var array $template_args |
|
36 | - */ |
|
37 | - protected $template_args; |
|
38 | - |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * TicketSelectorSimple constructor. |
|
43 | - * |
|
44 | - * @param \EE_Event $event |
|
45 | - * @param \EE_Ticket[] $tickets |
|
46 | - * @param int $max_attendees |
|
47 | - * @param array $template_args |
|
48 | - * @throws \EE_Error |
|
49 | - */ |
|
50 | - public function __construct(\EE_Event $event, array $tickets, $max_attendees, array $template_args) |
|
51 | - { |
|
52 | - $this->event = $event; |
|
53 | - $this->tickets = $tickets; |
|
54 | - $this->max_attendees = $max_attendees; |
|
55 | - $this->template_args = $template_args; |
|
56 | - $this->template_args['hidden_inputs'] = $this->getHiddenInputs(); |
|
57 | - $this->addTemplateArgs(); |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * sets any and all template args that are required for this Ticket Selector |
|
64 | - * |
|
65 | - * @return void |
|
66 | - */ |
|
67 | - abstract protected function addTemplateArgs(); |
|
68 | - |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * loadTicketSelectorTemplate |
|
73 | - * |
|
74 | - * @return string |
|
75 | - */ |
|
76 | - protected function loadTicketSelectorTemplate() |
|
77 | - { |
|
78 | - try { |
|
79 | - return \EEH_Template::locate_template( |
|
80 | - apply_filters( |
|
81 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', |
|
82 | - $this->template_args['template_path'], |
|
83 | - $this->event |
|
84 | - ), |
|
85 | - $this->template_args |
|
86 | - ); |
|
87 | - } catch (\Exception $e) { |
|
88 | - \EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
89 | - } |
|
90 | - return ''; |
|
91 | - } |
|
92 | - |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * The __toString method allows a class to decide how it will react when it is converted to a string. |
|
97 | - * |
|
98 | - * @return string |
|
99 | - * @link http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring |
|
100 | - */ |
|
101 | - public function __toString() |
|
102 | - { |
|
103 | - return $this->loadTicketSelectorTemplate(); |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * getHiddenInputs |
|
111 | - * |
|
112 | - * @return string |
|
113 | - * @throws \EE_Error |
|
114 | - */ |
|
115 | - public function getHiddenInputs() |
|
116 | - { |
|
117 | - // $rows = count($this->tickets); |
|
118 | - $html = '<input type="hidden" name="noheader" value="true"/>'; |
|
119 | - $html .= '<input type="hidden" name="tkt-slctr-return-url-' . $this->event->ID() . '"'; |
|
120 | - $html .= ' value="' . \EEH_URL::current_url() . $this->template_args['anchor_id'] . '"/>'; |
|
121 | - $html .= '<input type="hidden" name="tkt-slctr-rows-' . $this->event->ID(); |
|
122 | - $html .= '" value="' . count($this->tickets) . '"/>'; |
|
123 | - $html .= '<input type="hidden" name="tkt-slctr-max-atndz-' . $this->event->ID(); |
|
124 | - $html .= '" value="' . $this->template_args['max_atndz'] . '"/>'; |
|
125 | - $html .= '<input type="hidden" name="tkt-slctr-event-id" value="' . $this->event->ID() . '"/>'; |
|
126 | - return $html; |
|
127 | - } |
|
19 | + /** |
|
20 | + * @var \EE_Event $event |
|
21 | + */ |
|
22 | + protected $event; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var \EE_Ticket[] $tickets |
|
26 | + */ |
|
27 | + protected $tickets; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var int max_attendees |
|
31 | + */ |
|
32 | + protected $max_attendees; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var array $template_args |
|
36 | + */ |
|
37 | + protected $template_args; |
|
38 | + |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * TicketSelectorSimple constructor. |
|
43 | + * |
|
44 | + * @param \EE_Event $event |
|
45 | + * @param \EE_Ticket[] $tickets |
|
46 | + * @param int $max_attendees |
|
47 | + * @param array $template_args |
|
48 | + * @throws \EE_Error |
|
49 | + */ |
|
50 | + public function __construct(\EE_Event $event, array $tickets, $max_attendees, array $template_args) |
|
51 | + { |
|
52 | + $this->event = $event; |
|
53 | + $this->tickets = $tickets; |
|
54 | + $this->max_attendees = $max_attendees; |
|
55 | + $this->template_args = $template_args; |
|
56 | + $this->template_args['hidden_inputs'] = $this->getHiddenInputs(); |
|
57 | + $this->addTemplateArgs(); |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * sets any and all template args that are required for this Ticket Selector |
|
64 | + * |
|
65 | + * @return void |
|
66 | + */ |
|
67 | + abstract protected function addTemplateArgs(); |
|
68 | + |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * loadTicketSelectorTemplate |
|
73 | + * |
|
74 | + * @return string |
|
75 | + */ |
|
76 | + protected function loadTicketSelectorTemplate() |
|
77 | + { |
|
78 | + try { |
|
79 | + return \EEH_Template::locate_template( |
|
80 | + apply_filters( |
|
81 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', |
|
82 | + $this->template_args['template_path'], |
|
83 | + $this->event |
|
84 | + ), |
|
85 | + $this->template_args |
|
86 | + ); |
|
87 | + } catch (\Exception $e) { |
|
88 | + \EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
89 | + } |
|
90 | + return ''; |
|
91 | + } |
|
92 | + |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * The __toString method allows a class to decide how it will react when it is converted to a string. |
|
97 | + * |
|
98 | + * @return string |
|
99 | + * @link http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring |
|
100 | + */ |
|
101 | + public function __toString() |
|
102 | + { |
|
103 | + return $this->loadTicketSelectorTemplate(); |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * getHiddenInputs |
|
111 | + * |
|
112 | + * @return string |
|
113 | + * @throws \EE_Error |
|
114 | + */ |
|
115 | + public function getHiddenInputs() |
|
116 | + { |
|
117 | + // $rows = count($this->tickets); |
|
118 | + $html = '<input type="hidden" name="noheader" value="true"/>'; |
|
119 | + $html .= '<input type="hidden" name="tkt-slctr-return-url-' . $this->event->ID() . '"'; |
|
120 | + $html .= ' value="' . \EEH_URL::current_url() . $this->template_args['anchor_id'] . '"/>'; |
|
121 | + $html .= '<input type="hidden" name="tkt-slctr-rows-' . $this->event->ID(); |
|
122 | + $html .= '" value="' . count($this->tickets) . '"/>'; |
|
123 | + $html .= '<input type="hidden" name="tkt-slctr-max-atndz-' . $this->event->ID(); |
|
124 | + $html .= '" value="' . $this->template_args['max_atndz'] . '"/>'; |
|
125 | + $html .= '<input type="hidden" name="tkt-slctr-event-id" value="' . $this->event->ID() . '"/>'; |
|
126 | + return $html; |
|
127 | + } |
|
128 | 128 | |
129 | 129 | } |
130 | 130 | // End of file TicketSelector.php |
@@ -116,13 +116,13 @@ |
||
116 | 116 | { |
117 | 117 | // $rows = count($this->tickets); |
118 | 118 | $html = '<input type="hidden" name="noheader" value="true"/>'; |
119 | - $html .= '<input type="hidden" name="tkt-slctr-return-url-' . $this->event->ID() . '"'; |
|
120 | - $html .= ' value="' . \EEH_URL::current_url() . $this->template_args['anchor_id'] . '"/>'; |
|
121 | - $html .= '<input type="hidden" name="tkt-slctr-rows-' . $this->event->ID(); |
|
122 | - $html .= '" value="' . count($this->tickets) . '"/>'; |
|
123 | - $html .= '<input type="hidden" name="tkt-slctr-max-atndz-' . $this->event->ID(); |
|
124 | - $html .= '" value="' . $this->template_args['max_atndz'] . '"/>'; |
|
125 | - $html .= '<input type="hidden" name="tkt-slctr-event-id" value="' . $this->event->ID() . '"/>'; |
|
119 | + $html .= '<input type="hidden" name="tkt-slctr-return-url-'.$this->event->ID().'"'; |
|
120 | + $html .= ' value="'.\EEH_URL::current_url().$this->template_args['anchor_id'].'"/>'; |
|
121 | + $html .= '<input type="hidden" name="tkt-slctr-rows-'.$this->event->ID(); |
|
122 | + $html .= '" value="'.count($this->tickets).'"/>'; |
|
123 | + $html .= '<input type="hidden" name="tkt-slctr-max-atndz-'.$this->event->ID(); |
|
124 | + $html .= '" value="'.$this->template_args['max_atndz'].'"/>'; |
|
125 | + $html .= '<input type="hidden" name="tkt-slctr-event-id" value="'.$this->event->ID().'"/>'; |
|
126 | 126 | return $html; |
127 | 127 | } |
128 | 128 |
@@ -36,7 +36,7 @@ |
||
36 | 36 | |
37 | 37 | /** |
38 | 38 | * Taken from https://gist.github.com/jaywilliams/119517 |
39 | - * @param $string |
|
39 | + * @param string $string |
|
40 | 40 | * @return string |
41 | 41 | */ |
42 | 42 | protected function convertAscii($string) |
@@ -1,8 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\services\formatters; |
3 | 3 | |
4 | -use EventEspresso\core\exceptions\InvalidDataTypeException; |
|
5 | - |
|
6 | 4 | defined('EVENT_ESPRESSO_VERSION') || exit; |
7 | 5 | |
8 | 6 |
@@ -18,60 +18,60 @@ |
||
18 | 18 | class AsciiOnly extends FormatterBase |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * Removes all non Ascii characters from string |
|
23 | - * |
|
24 | - * @param string|int|float $input anything easily cast into a string |
|
25 | - * @return string |
|
26 | - */ |
|
27 | - public function format($input) |
|
28 | - { |
|
29 | - //in case an int or float etc was passed in |
|
30 | - $input = (string)$input; |
|
31 | - $input = $this->convertAscii($input); |
|
32 | - return $input; |
|
33 | - } |
|
21 | + /** |
|
22 | + * Removes all non Ascii characters from string |
|
23 | + * |
|
24 | + * @param string|int|float $input anything easily cast into a string |
|
25 | + * @return string |
|
26 | + */ |
|
27 | + public function format($input) |
|
28 | + { |
|
29 | + //in case an int or float etc was passed in |
|
30 | + $input = (string)$input; |
|
31 | + $input = $this->convertAscii($input); |
|
32 | + return $input; |
|
33 | + } |
|
34 | 34 | |
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * Taken from https://gist.github.com/jaywilliams/119517 |
|
39 | - * @param $string |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - protected function convertAscii($string) |
|
43 | - { |
|
44 | - // Replace Single Curly Quotes |
|
45 | - $search[] = chr(226).chr(128).chr(152); |
|
46 | - $replace[] = "'"; |
|
47 | - $search[] = chr(226).chr(128).chr(153); |
|
48 | - $replace[] = "'"; |
|
49 | - // Replace Smart Double Curly Quotes |
|
50 | - $search[] = chr(226).chr(128).chr(156); |
|
51 | - $replace[] = '"'; |
|
52 | - $search[] = chr(226).chr(128).chr(157); |
|
53 | - $replace[] = '"'; |
|
54 | - // Replace En Dash |
|
55 | - $search[] = chr(226).chr(128).chr(147); |
|
56 | - $replace[] = '--'; |
|
57 | - // Replace Em Dash |
|
58 | - $search[] = chr(226).chr(128).chr(148); |
|
59 | - $replace[] = '---'; |
|
60 | - // Replace Bullet |
|
61 | - $search[] = chr(226).chr(128).chr(162); |
|
62 | - $replace[] = '*'; |
|
63 | - // Replace Middle Dot |
|
64 | - $search[] = chr(194).chr(183); |
|
65 | - $replace[] = '*'; |
|
66 | - // Replace Ellipsis with three consecutive dots |
|
67 | - $search[] = chr(226).chr(128).chr(166); |
|
68 | - $replace[] = '...'; |
|
69 | - // Apply Replacements |
|
70 | - $string = str_replace($search, $replace, $string); |
|
71 | - // Remove any non-ASCII Characters |
|
72 | - $string = preg_replace("/[^\x01-\x7F]/","", $string); |
|
73 | - return $string; |
|
74 | - } |
|
37 | + /** |
|
38 | + * Taken from https://gist.github.com/jaywilliams/119517 |
|
39 | + * @param $string |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + protected function convertAscii($string) |
|
43 | + { |
|
44 | + // Replace Single Curly Quotes |
|
45 | + $search[] = chr(226).chr(128).chr(152); |
|
46 | + $replace[] = "'"; |
|
47 | + $search[] = chr(226).chr(128).chr(153); |
|
48 | + $replace[] = "'"; |
|
49 | + // Replace Smart Double Curly Quotes |
|
50 | + $search[] = chr(226).chr(128).chr(156); |
|
51 | + $replace[] = '"'; |
|
52 | + $search[] = chr(226).chr(128).chr(157); |
|
53 | + $replace[] = '"'; |
|
54 | + // Replace En Dash |
|
55 | + $search[] = chr(226).chr(128).chr(147); |
|
56 | + $replace[] = '--'; |
|
57 | + // Replace Em Dash |
|
58 | + $search[] = chr(226).chr(128).chr(148); |
|
59 | + $replace[] = '---'; |
|
60 | + // Replace Bullet |
|
61 | + $search[] = chr(226).chr(128).chr(162); |
|
62 | + $replace[] = '*'; |
|
63 | + // Replace Middle Dot |
|
64 | + $search[] = chr(194).chr(183); |
|
65 | + $replace[] = '*'; |
|
66 | + // Replace Ellipsis with three consecutive dots |
|
67 | + $search[] = chr(226).chr(128).chr(166); |
|
68 | + $replace[] = '...'; |
|
69 | + // Apply Replacements |
|
70 | + $string = str_replace($search, $replace, $string); |
|
71 | + // Remove any non-ASCII Characters |
|
72 | + $string = preg_replace("/[^\x01-\x7F]/","", $string); |
|
73 | + return $string; |
|
74 | + } |
|
75 | 75 | } |
76 | 76 | // End of file EmojiRemoval.php |
77 | 77 | // Location: core\services\formatters/EmojiRemoval.php |
78 | 78 | \ No newline at end of file |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | public function format($input) |
28 | 28 | { |
29 | 29 | //in case an int or float etc was passed in |
30 | - $input = (string)$input; |
|
30 | + $input = (string) $input; |
|
31 | 31 | $input = $this->convertAscii($input); |
32 | 32 | return $input; |
33 | 33 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | // Apply Replacements |
70 | 70 | $string = str_replace($search, $replace, $string); |
71 | 71 | // Remove any non-ASCII Characters |
72 | - $string = preg_replace("/[^\x01-\x7F]/","", $string); |
|
72 | + $string = preg_replace("/[^\x01-\x7F]/", "", $string); |
|
73 | 73 | return $string; |
74 | 74 | } |
75 | 75 | } |
@@ -18,28 +18,28 @@ |
||
18 | 18 | class LeaveAlone extends FormatterBase |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * Removes the emojis from the inputted string |
|
23 | - * |
|
24 | - * @param string|int|float $input anything easily cast into a string |
|
25 | - * @return string |
|
26 | - * @throws InvalidDataTypeException if $input is not a string |
|
27 | - */ |
|
28 | - public function format($input) |
|
29 | - { |
|
30 | - return $input; |
|
31 | - } |
|
21 | + /** |
|
22 | + * Removes the emojis from the inputted string |
|
23 | + * |
|
24 | + * @param string|int|float $input anything easily cast into a string |
|
25 | + * @return string |
|
26 | + * @throws InvalidDataTypeException if $input is not a string |
|
27 | + */ |
|
28 | + public function format($input) |
|
29 | + { |
|
30 | + return $input; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Just returns the inputted $input array |
|
35 | - * |
|
36 | - * @param array $input |
|
37 | - * @return array |
|
38 | - */ |
|
39 | - public function formatArray($input) |
|
40 | - { |
|
41 | - return $input; |
|
42 | - } |
|
33 | + /** |
|
34 | + * Just returns the inputted $input array |
|
35 | + * |
|
36 | + * @param array $input |
|
37 | + * @return array |
|
38 | + */ |
|
39 | + public function formatArray($input) |
|
40 | + { |
|
41 | + return $input; |
|
42 | + } |
|
43 | 43 | } |
44 | 44 | // End of file LeaveAlonel.php |
45 | 45 | // Location: core\services\formatters/LeaveAlonel.php |
46 | 46 | \ No newline at end of file |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | * Gets all the attendees for this transaction (handy for use with EE_Attendee's get_registrations_for_event function |
428 | 428 | * for getting attendees and how many registrations they each have for an event) |
429 | 429 | * |
430 | - * @return mixed EE_Attendee[] by default, int if $output is set to 'COUNT' |
|
430 | + * @return EE_Base_Class[] EE_Attendee[] by default, int if $output is set to 'COUNT' |
|
431 | 431 | * @throws \EE_Error |
432 | 432 | */ |
433 | 433 | public function attendees() { |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | |
465 | 465 | /** |
466 | 466 | * Gets all payments which have not been approved |
467 | - * @return \EEI_Payment[] |
|
467 | + * @return EE_Base_Class[] |
|
468 | 468 | * @throws EE_Error if a model is misconfigured somehow |
469 | 469 | */ |
470 | 470 | public function pending_payments() |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | * Gets all the extra meta info on this payment |
710 | 710 | * |
711 | 711 | * @param array $query_params like EEM_Base::get_all |
712 | - * @return EE_Extra_Meta |
|
712 | + * @return EE_Base_Class[] |
|
713 | 713 | * @throws \EE_Error |
714 | 714 | */ |
715 | 715 | public function extra_meta( $query_params = array() ) { |
@@ -886,7 +886,7 @@ discard block |
||
886 | 886 | * Sets PMD_ID |
887 | 887 | * |
888 | 888 | * @param int $PMD_ID |
889 | - * @return boolean |
|
889 | + * @return boolean|null |
|
890 | 890 | * @throws \EE_Error |
891 | 891 | */ |
892 | 892 | public function set_payment_method_ID($PMD_ID) { |
@@ -462,29 +462,29 @@ |
||
462 | 462 | |
463 | 463 | |
464 | 464 | |
465 | - /** |
|
466 | - * Gets all payments which have not been approved |
|
467 | - * @return \EEI_Payment[] |
|
468 | - * @throws EE_Error if a model is misconfigured somehow |
|
469 | - */ |
|
465 | + /** |
|
466 | + * Gets all payments which have not been approved |
|
467 | + * @return \EEI_Payment[] |
|
468 | + * @throws EE_Error if a model is misconfigured somehow |
|
469 | + */ |
|
470 | 470 | public function pending_payments() |
471 | - { |
|
472 | - return $this->get_many_related( |
|
473 | - 'Payment', |
|
474 | - array( |
|
475 | - array( |
|
476 | - 'STS_ID' => EEM_Payment::status_id_pending |
|
477 | - ), |
|
478 | - 'order_by' => array( |
|
479 | - 'PAY_timestamp' => 'DESC' |
|
480 | - ) |
|
481 | - ) |
|
482 | - ); |
|
483 | - } |
|
484 | - |
|
485 | - |
|
486 | - |
|
487 | - /** |
|
471 | + { |
|
472 | + return $this->get_many_related( |
|
473 | + 'Payment', |
|
474 | + array( |
|
475 | + array( |
|
476 | + 'STS_ID' => EEM_Payment::status_id_pending |
|
477 | + ), |
|
478 | + 'order_by' => array( |
|
479 | + 'PAY_timestamp' => 'DESC' |
|
480 | + ) |
|
481 | + ) |
|
482 | + ); |
|
483 | + } |
|
484 | + |
|
485 | + |
|
486 | + |
|
487 | + /** |
|
488 | 488 | * echoes $this->pretty_status() |
489 | 489 | * |
490 | 490 | * @param bool $show_icons |