@@ -1,7 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | +} |
|
5 | 6 | |
6 | 7 | /** |
7 | 8 | * EE_Messages_Validator class |
@@ -121,13 +122,14 @@ discard block |
||
121 | 122 | */ |
122 | 123 | public function __construct( $fields, $context ) { |
123 | 124 | //check that _m_name and _mt_name have been set by child class otherwise we get out. |
124 | - if ( empty($this->_m_name ) || empty( $this->_mt_name) ) |
|
125 | - throw new EE_Error( |
|
125 | + if ( empty($this->_m_name ) || empty( $this->_mt_name) ) { |
|
126 | + throw new EE_Error( |
|
126 | 127 | __( |
127 | 128 | 'EE_Messages_Validator child classes MUST set the $_m_name and $_mt_name property. Check that the child class is doing this', |
128 | 129 | 'event_espresso' |
129 | 130 | ) |
130 | 131 | ); |
132 | + } |
|
131 | 133 | $this->_fields = $fields; |
132 | 134 | $this->_context = $context; |
133 | 135 | |
@@ -228,8 +230,10 @@ discard block |
||
228 | 230 | $groups_per_field = array(); |
229 | 231 | |
230 | 232 | foreach ( $msgr_validator as $field => $config ) { |
231 | - if ( empty($config) || !isset($config['shortcodes']) ) |
|
232 | - continue; //Nothing to see here. |
|
233 | + if ( empty($config) || !isset($config['shortcodes']) ) { |
|
234 | + continue; |
|
235 | + } |
|
236 | + //Nothing to see here. |
|
233 | 237 | $groups_per_field[$field] = array_intersect( $config['shortcodes'], $mt_codes ); |
234 | 238 | $shortcode_groups = array_merge( $config[ 'shortcodes'], $shortcode_groups ); |
235 | 239 | } |
@@ -268,8 +272,9 @@ discard block |
||
268 | 272 | $required = isset($config['required']) |
269 | 273 | ? array_intersect($config['required'], array_keys($mt_codes)) |
270 | 274 | : true; |
271 | - if ( empty($required) ) |
|
272 | - continue; |
|
275 | + if ( empty($required) ) { |
|
276 | + continue; |
|
277 | + } |
|
273 | 278 | |
274 | 279 | //If we have an override then we use it to indicate the codes we want. |
275 | 280 | if ( isset( $this->_valid_shortcodes_modifier[$context][$field] ) ) { |
@@ -310,8 +315,9 @@ discard block |
||
310 | 315 | $specific_excludes = $this->get_specific_shortcode_excludes(); |
311 | 316 | if ( isset( $specific_excludes[$field] ) ) { |
312 | 317 | foreach( $specific_excludes[$field] as $sex ) { |
313 | - if ( isset( $this->_validators[$field]['shortcodes'][$sex] ) ) |
|
314 | - unset( $this->_validators[$field]['shortcodes'][$sex] ); |
|
318 | + if ( isset( $this->_validators[$field]['shortcodes'][$sex] ) ) { |
|
319 | + unset( $this->_validators[$field]['shortcodes'][$sex] ); |
|
320 | + } |
|
315 | 321 | } |
316 | 322 | } |
317 | 323 | |
@@ -385,10 +391,13 @@ discard block |
||
385 | 391 | //get the translated field label! |
386 | 392 | //first check if it's in the main fields list |
387 | 393 | if ( isset( $template_fields[$field] ) ) { |
388 | - if ( empty( $template_fields[$field] ) ) |
|
389 | - $field_label = $field; //most likely the field is found in the 'extra' array. |
|
390 | - else |
|
391 | - $field_label = $template_fields[$field]['label']; |
|
394 | + if ( empty( $template_fields[$field] ) ) { |
|
395 | + $field_label = $field; |
|
396 | + } |
|
397 | + //most likely the field is found in the 'extra' array. |
|
398 | + else { |
|
399 | + $field_label = $template_fields[$field]['label']; |
|
400 | + } |
|
392 | 401 | } |
393 | 402 | |
394 | 403 | // if field label is empty OR is equal to the current field |
@@ -402,8 +411,9 @@ discard block |
||
402 | 411 | |
403 | 412 | // if we've got a 'main' secondary field, let's see if that matches what field we're on |
404 | 413 | // which means it contains the label for this field. |
405 | - if ( $name == 'main' && $main_field == $field_label ) |
|
406 | - $field_label = $values['label']; |
|
414 | + if ( $name == 'main' && $main_field == $field_label ) { |
|
415 | + $field_label = $values['label']; |
|
416 | + } |
|
407 | 417 | } |
408 | 418 | } |
409 | 419 | } |
@@ -439,8 +449,8 @@ discard block |
||
439 | 449 | if ( isset( $this->_validators[$field]['type'] ) && !empty( $this->_validators[$field]['type'] ) ) { |
440 | 450 | switch ( $this->_validators[$field]['type'] ) { |
441 | 451 | case 'number' : |
442 | - if ( !is_numeric($value) ) |
|
443 | - $err_msg .= sprintf( |
|
452 | + if ( !is_numeric($value) ) { |
|
453 | + $err_msg .= sprintf( |
|
444 | 454 | __( |
445 | 455 | '%3$sThe %1$s field is supposed to be a number. The value given (%2$s) is not. Please double-check and make sure the field contains a number%4$s', |
446 | 456 | 'event_espresso' |
@@ -450,11 +460,12 @@ discard block |
||
450 | 460 | '<p>', |
451 | 461 | '</p >' |
452 | 462 | ); |
463 | + } |
|
453 | 464 | break; |
454 | 465 | case 'email' : |
455 | 466 | $valid_email = $this->_validate_email($value); |
456 | - if ( !$valid_email ) |
|
457 | - $err_msg .= htmlentities( |
|
467 | + if ( !$valid_email ) { |
|
468 | + $err_msg .= htmlentities( |
|
458 | 469 | sprintf( |
459 | 470 | __( |
460 | 471 | 'The %1$s field has at least one string that is not a valid email address record. Valid emails are in the format: "Name <[email protected]>" or "[email protected]" and multiple emails can be separated by a comma.' |
@@ -463,6 +474,7 @@ discard block |
||
463 | 474 | |
464 | 475 | ) |
465 | 476 | ); |
477 | + } |
|
466 | 478 | break; |
467 | 479 | default : |
468 | 480 | break; |
@@ -539,7 +551,10 @@ discard block |
||
539 | 551 | } |
540 | 552 | } |
541 | 553 | |
542 | - if ( empty( $diff ) ) return FALSE; //there is no diff, we have no invalid shortcodes, so return |
|
554 | + if ( empty( $diff ) ) { |
|
555 | + return FALSE; |
|
556 | + } |
|
557 | + //there is no diff, we have no invalid shortcodes, so return |
|
543 | 558 | |
544 | 559 | //made it here? then let's assemble the error message |
545 | 560 | $invalid_shortcodes = implode( '</strong>,<strong>', $diff ); |
@@ -561,8 +576,9 @@ discard block |
||
561 | 576 | |
562 | 577 | // empty strings will validate because this is how a message template |
563 | 578 | // for a particular context can be "turned off" (if there is no email then no message) |
564 | - if ( empty( $value ) ) |
|
565 | - return $validate; |
|
579 | + if ( empty( $value ) ) { |
|
580 | + return $validate; |
|
581 | + } |
|
566 | 582 | |
567 | 583 | // first determine if there ARE any shortcodes. |
568 | 584 | // If there are shortcodes and then later we find that there were no other valid emails |
@@ -579,8 +595,9 @@ discard block |
||
579 | 595 | // its possible that this message is being "turned off" for a particular context |
580 | 596 | |
581 | 597 | |
582 | - if ( !empty($or_val) && empty($value) ) |
|
583 | - return $validate; |
|
598 | + if ( !empty($or_val) && empty($value) ) { |
|
599 | + return $validate; |
|
600 | + } |
|
584 | 601 | |
585 | 602 | //trim any commas from beginning and end of string ( after whitespace trimmed ); |
586 | 603 | $value = trim( trim($value), ',' ); |
@@ -601,12 +618,12 @@ discard block |
||
601 | 618 | //either its of type "[email protected]", or its of type "fname lname <[email protected]>" |
602 | 619 | if(is_email($email)){ |
603 | 620 | continue; |
604 | - }else{ |
|
621 | + } else{ |
|
605 | 622 | $matches = array(); |
606 | 623 | $validate = preg_match( '/(.*)<(.+)>/', $email, $matches ) ? TRUE : FALSE; |
607 | 624 | if( $validate && is_email($matches[2])){ |
608 | 625 | continue; |
609 | - }else{ |
|
626 | + } else{ |
|
610 | 627 | return false; |
611 | 628 | } |
612 | 629 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | * @param $context |
120 | 120 | * @throws \EE_Error |
121 | 121 | */ |
122 | - public function __construct( $fields, $context ) { |
|
122 | + public function __construct($fields, $context) { |
|
123 | 123 | //check that _m_name and _mt_name have been set by child class otherwise we get out. |
124 | - if ( empty($this->_m_name ) || empty( $this->_mt_name) ) |
|
124 | + if (empty($this->_m_name) || empty($this->_mt_name)) |
|
125 | 125 | throw new EE_Error( |
126 | 126 | __( |
127 | 127 | 'EE_Messages_Validator child classes MUST set the $_m_name and $_mt_name property. Check that the child class is doing this', |
@@ -167,14 +167,14 @@ discard block |
||
167 | 167 | */ |
168 | 168 | private function _load_objects() { |
169 | 169 | //load messenger |
170 | - $messenger = ucwords( str_replace( '_', ' ', $this->_m_name ) ); |
|
171 | - $messenger = str_replace( ' ', '_', $messenger ); |
|
172 | - $messenger = 'EE_' . $messenger . '_messenger'; |
|
170 | + $messenger = ucwords(str_replace('_', ' ', $this->_m_name)); |
|
171 | + $messenger = str_replace(' ', '_', $messenger); |
|
172 | + $messenger = 'EE_'.$messenger.'_messenger'; |
|
173 | 173 | |
174 | - if ( ! class_exists( $messenger ) ) { |
|
174 | + if ( ! class_exists($messenger)) { |
|
175 | 175 | throw new EE_Error( |
176 | 176 | sprintf( |
177 | - __( 'There is no messenger class for the given string (%s)', 'event_espresso' ), |
|
177 | + __('There is no messenger class for the given string (%s)', 'event_espresso'), |
|
178 | 178 | $this->_m_name |
179 | 179 | ) |
180 | 180 | ); |
@@ -183,14 +183,14 @@ discard block |
||
183 | 183 | $this->_messenger = new $messenger(); |
184 | 184 | |
185 | 185 | //load message type |
186 | - $message_type = ucwords( str_replace( '_', ' ', $this->_mt_name ) ); |
|
187 | - $message_type = str_replace( ' ', '_', $message_type ); |
|
188 | - $message_type = 'EE_' . $message_type . '_message_type'; |
|
186 | + $message_type = ucwords(str_replace('_', ' ', $this->_mt_name)); |
|
187 | + $message_type = str_replace(' ', '_', $message_type); |
|
188 | + $message_type = 'EE_'.$message_type.'_message_type'; |
|
189 | 189 | |
190 | - if ( !class_exists( $message_type ) ) { |
|
190 | + if ( ! class_exists($message_type)) { |
|
191 | 191 | throw new EE_Error( |
192 | 192 | sprintf( |
193 | - __( 'There is no message type class for the given string (%s)', 'event_espresso' ), |
|
193 | + __('There is no message type class for the given string (%s)', 'event_espresso'), |
|
194 | 194 | $this->_mt_name |
195 | 195 | ) |
196 | 196 | ); |
@@ -227,25 +227,25 @@ discard block |
||
227 | 227 | $shortcode_groups = $mt_codes; |
228 | 228 | $groups_per_field = array(); |
229 | 229 | |
230 | - foreach ( $msgr_validator as $field => $config ) { |
|
231 | - if ( empty($config) || !isset($config['shortcodes']) ) |
|
232 | - continue; //Nothing to see here. |
|
233 | - $groups_per_field[$field] = array_intersect( $config['shortcodes'], $mt_codes ); |
|
234 | - $shortcode_groups = array_merge( $config[ 'shortcodes'], $shortcode_groups ); |
|
230 | + foreach ($msgr_validator as $field => $config) { |
|
231 | + if (empty($config) || ! isset($config['shortcodes'])) |
|
232 | + continue; //Nothing to see here. |
|
233 | + $groups_per_field[$field] = array_intersect($config['shortcodes'], $mt_codes); |
|
234 | + $shortcode_groups = array_merge($config['shortcodes'], $shortcode_groups); |
|
235 | 235 | } |
236 | 236 | |
237 | - $shortcode_groups = array_unique( $shortcode_groups); |
|
237 | + $shortcode_groups = array_unique($shortcode_groups); |
|
238 | 238 | |
239 | 239 | // okay now we've got our groups. |
240 | 240 | // Let's get the codes from the objects into an array indexed by group for easy retrieval later. |
241 | 241 | $codes_from_objs = array(); |
242 | 242 | |
243 | - foreach ( $shortcode_groups as $group ) { |
|
244 | - $ref = ucwords( str_replace('_', ' ', $group ) ); |
|
245 | - $ref = str_replace( ' ', '_', $ref ); |
|
246 | - $classname = 'EE_' . $ref . '_Shortcodes'; |
|
247 | - if ( class_exists( $classname ) ) { |
|
248 | - $a = new ReflectionClass( $classname ); |
|
243 | + foreach ($shortcode_groups as $group) { |
|
244 | + $ref = ucwords(str_replace('_', ' ', $group)); |
|
245 | + $ref = str_replace(' ', '_', $ref); |
|
246 | + $classname = 'EE_'.$ref.'_Shortcodes'; |
|
247 | + if (class_exists($classname)) { |
|
248 | + $a = new ReflectionClass($classname); |
|
249 | 249 | $obj = $a->newInstance(); |
250 | 250 | $codes_from_objs[$group] = $obj->get_shortcodes(); |
251 | 251 | } |
@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | |
255 | 255 | //let's just replace the $mt shortcode group indexes with the actual shortcodes (unique) |
256 | 256 | $final_mt_codes = array(); |
257 | - foreach ( $mt_codes as $group ) { |
|
258 | - $final_mt_codes = array_merge( $final_mt_codes, $codes_from_objs[$group] ); |
|
257 | + foreach ($mt_codes as $group) { |
|
258 | + $final_mt_codes = array_merge($final_mt_codes, $codes_from_objs[$group]); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | $mt_codes = $final_mt_codes; |
@@ -263,60 +263,60 @@ discard block |
||
263 | 263 | |
264 | 264 | // k now in this next loop we're going to loop through $msgr_validator again |
265 | 265 | // and setup the _validators property from the data we've setup so far. |
266 | - foreach ( $msgr_validator as $field => $config ) { |
|
266 | + foreach ($msgr_validator as $field => $config) { |
|
267 | 267 | //if required shortcode is not in our list of codes for the given field, then we skip this field. |
268 | 268 | $required = isset($config['required']) |
269 | 269 | ? array_intersect($config['required'], array_keys($mt_codes)) |
270 | 270 | : true; |
271 | - if ( empty($required) ) |
|
271 | + if (empty($required)) |
|
272 | 272 | continue; |
273 | 273 | |
274 | 274 | //If we have an override then we use it to indicate the codes we want. |
275 | - if ( isset( $this->_valid_shortcodes_modifier[$context][$field] ) ) { |
|
276 | - $this->_validators[ $field ][ 'shortcodes' ] = $this->_reassemble_valid_shortcodes_from_group( |
|
277 | - $this->_valid_shortcodes_modifier[ $context ][ $field ], |
|
275 | + if (isset($this->_valid_shortcodes_modifier[$context][$field])) { |
|
276 | + $this->_validators[$field]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group( |
|
277 | + $this->_valid_shortcodes_modifier[$context][$field], |
|
278 | 278 | $codes_from_objs |
279 | 279 | ); |
280 | 280 | } |
281 | 281 | |
282 | 282 | //if we have specific shortcodes for a field then we need to use them |
283 | - else if ( isset( $groups_per_field[$field] ) ) { |
|
284 | - $this->_validators[ $field ][ 'shortcodes' ] = $this->_reassemble_valid_shortcodes_from_group( |
|
285 | - $groups_per_field[ $field ], |
|
283 | + else if (isset($groups_per_field[$field])) { |
|
284 | + $this->_validators[$field]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group( |
|
285 | + $groups_per_field[$field], |
|
286 | 286 | $codes_from_objs |
287 | 287 | ); |
288 | 288 | } |
289 | 289 | |
290 | 290 | //if empty config then we're assuming we're just going to use the shortcodes from the message type context |
291 | - else if ( empty( $config ) ) { |
|
291 | + else if (empty($config)) { |
|
292 | 292 | $this->_validators[$field]['shortcodes'] = $mt_codes; |
293 | 293 | } |
294 | 294 | |
295 | 295 | //if we have specific shortcodes then we need to use them |
296 | - else if ( isset($config['specific_shortcodes'] ) ) { |
|
296 | + else if (isset($config['specific_shortcodes'])) { |
|
297 | 297 | $this->_validators[$field]['shortcodes'] = $config['specific_shortcodes']; |
298 | 298 | } |
299 | 299 | |
300 | 300 | //otherwise the shortcodes are what is set by the messenger for that field |
301 | 301 | else { |
302 | - foreach ( $config['shortcodes'] as $group ) { |
|
302 | + foreach ($config['shortcodes'] as $group) { |
|
303 | 303 | $this->_validators[$field]['shortcodes'] = isset($this->_validators[$field]['shortcodes']) |
304 | - ? array_merge( $this->_validators[$field]['shortcodes'], $codes_from_objs[$group] ) |
|
304 | + ? array_merge($this->_validators[$field]['shortcodes'], $codes_from_objs[$group]) |
|
305 | 305 | : $codes_from_objs[$group]; |
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
309 | 309 | //now let's just make sure that any excluded specific shortcodes are removed. |
310 | 310 | $specific_excludes = $this->get_specific_shortcode_excludes(); |
311 | - if ( isset( $specific_excludes[$field] ) ) { |
|
312 | - foreach( $specific_excludes[$field] as $sex ) { |
|
313 | - if ( isset( $this->_validators[$field]['shortcodes'][$sex] ) ) |
|
314 | - unset( $this->_validators[$field]['shortcodes'][$sex] ); |
|
311 | + if (isset($specific_excludes[$field])) { |
|
312 | + foreach ($specific_excludes[$field] as $sex) { |
|
313 | + if (isset($this->_validators[$field]['shortcodes'][$sex])) |
|
314 | + unset($this->_validators[$field]['shortcodes'][$sex]); |
|
315 | 315 | } |
316 | 316 | } |
317 | 317 | |
318 | 318 | //hey! don't forget to include the type if present! |
319 | - $this->_validators[$field]['type'] = isset( $config['type'] ) ? $config['type'] : NULL; |
|
319 | + $this->_validators[$field]['type'] = isset($config['type']) ? $config['type'] : NULL; |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | public function get_specific_shortcode_excludes() { |
345 | 345 | //specific validator filter |
346 | 346 | $shortcode_excludes = apply_filters( |
347 | - 'FHEE__' . get_class( $this ) . '__get_specific_shortcode_excludes;', |
|
347 | + 'FHEE__'.get_class($this).'__get_specific_shortcode_excludes;', |
|
348 | 348 | $this->_specific_shortcode_excludes, |
349 | 349 | $this->_context |
350 | 350 | ); |
@@ -372,20 +372,20 @@ discard block |
||
372 | 372 | //some defaults |
373 | 373 | $template_fields = $this->_messenger->get_template_fields(); |
374 | 374 | //loop through the fields and check! |
375 | - foreach ( $this->_fields as $field => $value ) { |
|
375 | + foreach ($this->_fields as $field => $value) { |
|
376 | 376 | $this->_errors[$field] = array(); |
377 | 377 | $err_msg = ''; |
378 | 378 | $field_label = ''; |
379 | 379 | //if field is not present in the _validators array then we continue |
380 | - if ( !isset( $this->_validators[$field] ) ) { |
|
381 | - unset( $this->_errors[$field] ); |
|
380 | + if ( ! isset($this->_validators[$field])) { |
|
381 | + unset($this->_errors[$field]); |
|
382 | 382 | continue; |
383 | 383 | } |
384 | 384 | |
385 | 385 | //get the translated field label! |
386 | 386 | //first check if it's in the main fields list |
387 | - if ( isset( $template_fields[$field] ) ) { |
|
388 | - if ( empty( $template_fields[$field] ) ) |
|
387 | + if (isset($template_fields[$field])) { |
|
388 | + if (empty($template_fields[$field])) |
|
389 | 389 | $field_label = $field; //most likely the field is found in the 'extra' array. |
390 | 390 | else |
391 | 391 | $field_label = $template_fields[$field]['label']; |
@@ -393,16 +393,16 @@ discard block |
||
393 | 393 | |
394 | 394 | // if field label is empty OR is equal to the current field |
395 | 395 | // then we need to loop through the 'extra' fields in the template_fields config (if present) |
396 | - if ( isset( $template_fields['extra'] ) && ( empty($field_label) ) || $field_label == $field ) { |
|
397 | - foreach( $template_fields['extra'] as $main_field => $secondary_field ) { |
|
398 | - foreach ( $secondary_field as $name => $values ) { |
|
399 | - if ( $name == $field ) { |
|
396 | + if (isset($template_fields['extra']) && (empty($field_label)) || $field_label == $field) { |
|
397 | + foreach ($template_fields['extra'] as $main_field => $secondary_field) { |
|
398 | + foreach ($secondary_field as $name => $values) { |
|
399 | + if ($name == $field) { |
|
400 | 400 | $field_label = $values['label']; |
401 | 401 | } |
402 | 402 | |
403 | 403 | // if we've got a 'main' secondary field, let's see if that matches what field we're on |
404 | 404 | // which means it contains the label for this field. |
405 | - if ( $name == 'main' && $main_field == $field_label ) |
|
405 | + if ($name == 'main' && $main_field == $field_label) |
|
406 | 406 | $field_label = $values['label']; |
407 | 407 | } |
408 | 408 | } |
@@ -410,36 +410,36 @@ discard block |
||
410 | 410 | |
411 | 411 | //field is present. Let's validate shortcodes first (but only if shortcodes present). |
412 | 412 | if ( |
413 | - isset( $this->_validators[ $field ][ 'shortcodes' ] ) |
|
414 | - && ! empty( $this->_validators[ $field ][ 'shortcodes' ] ) |
|
413 | + isset($this->_validators[$field]['shortcodes']) |
|
414 | + && ! empty($this->_validators[$field]['shortcodes']) |
|
415 | 415 | ) { |
416 | - $invalid_shortcodes = $this->_invalid_shortcodes( $value, $this->_validators[$field]['shortcodes'] ); |
|
416 | + $invalid_shortcodes = $this->_invalid_shortcodes($value, $this->_validators[$field]['shortcodes']); |
|
417 | 417 | // if true then that means there is a returned error message |
418 | 418 | // that we'll need to add to the _errors array for this field. |
419 | - if ( $invalid_shortcodes ) { |
|
419 | + if ($invalid_shortcodes) { |
|
420 | 420 | $v_s = array_keys($this->_validators[$field]['shortcodes']); |
421 | 421 | $err_msg = sprintf( |
422 | 422 | __( |
423 | 423 | '%3$sThe following shortcodes were found in the "%1$s" field that ARE not valid: %2$s%4$s', |
424 | 424 | 'event_espresso' |
425 | 425 | ), |
426 | - '<strong>' . $field_label . '</strong>', |
|
426 | + '<strong>'.$field_label.'</strong>', |
|
427 | 427 | $invalid_shortcodes, |
428 | 428 | '<p>', |
429 | 429 | '</p >' |
430 | 430 | ); |
431 | 431 | $err_msg .= sprintf( |
432 | - __( '%2$sValid shortcodes for this field are: %1$s%3$s', 'event_espresso' ), |
|
433 | - implode( ', ', $v_s ) |
|
432 | + __('%2$sValid shortcodes for this field are: %1$s%3$s', 'event_espresso'), |
|
433 | + implode(', ', $v_s) |
|
434 | 434 | ); |
435 | 435 | } |
436 | 436 | } |
437 | 437 | |
438 | 438 | //if there's a "type" to be validated then let's do that too. |
439 | - if ( isset( $this->_validators[$field]['type'] ) && !empty( $this->_validators[$field]['type'] ) ) { |
|
440 | - switch ( $this->_validators[$field]['type'] ) { |
|
439 | + if (isset($this->_validators[$field]['type']) && ! empty($this->_validators[$field]['type'])) { |
|
440 | + switch ($this->_validators[$field]['type']) { |
|
441 | 441 | case 'number' : |
442 | - if ( !is_numeric($value) ) |
|
442 | + if ( ! is_numeric($value)) |
|
443 | 443 | $err_msg .= sprintf( |
444 | 444 | __( |
445 | 445 | '%3$sThe %1$s field is supposed to be a number. The value given (%2$s) is not. Please double-check and make sure the field contains a number%4$s', |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | break; |
454 | 454 | case 'email' : |
455 | 455 | $valid_email = $this->_validate_email($value); |
456 | - if ( !$valid_email ) |
|
456 | + if ( ! $valid_email) |
|
457 | 457 | $err_msg .= htmlentities( |
458 | 458 | sprintf( |
459 | 459 | __( |
@@ -470,23 +470,23 @@ discard block |
||
470 | 470 | } |
471 | 471 | |
472 | 472 | //if $err_msg isn't empty let's setup the _errors array for this field. |
473 | - if ( !empty($err_msg ) ) { |
|
473 | + if ( ! empty($err_msg)) { |
|
474 | 474 | $this->_errors[$field]['msg'] = $err_msg; |
475 | 475 | } else { |
476 | - unset( $this->_errors[$field] ); |
|
476 | + unset($this->_errors[$field]); |
|
477 | 477 | } |
478 | 478 | } |
479 | 479 | |
480 | 480 | // if we have ANY errors, then we want to make sure we return the values |
481 | 481 | // for ALL the fields so the user doesn't have to retype them all. |
482 | - if ( !empty( $this->_errors ) ) { |
|
483 | - foreach ( $this->_fields as $field => $value ) { |
|
482 | + if ( ! empty($this->_errors)) { |
|
483 | + foreach ($this->_fields as $field => $value) { |
|
484 | 484 | $this->_errors[$field]['value'] = stripslashes($value); |
485 | 485 | } |
486 | 486 | } |
487 | 487 | |
488 | 488 | //return any errors or just TRUE if everything validates |
489 | - return empty( $this->_errors ) ? TRUE : $this->_errors; |
|
489 | + return empty($this->_errors) ? TRUE : $this->_errors; |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | |
@@ -499,10 +499,10 @@ discard block |
||
499 | 499 | * @param array $codes_from_objs All the codes available. |
500 | 500 | * @return array an array of actual shortcodes (that will be used for validation). |
501 | 501 | */ |
502 | - private function _reassemble_valid_shortcodes_from_group( $groups, $codes_from_objs ) { |
|
502 | + private function _reassemble_valid_shortcodes_from_group($groups, $codes_from_objs) { |
|
503 | 503 | $shortcodes = array(); |
504 | - foreach ( $groups as $group ) { |
|
505 | - $shortcodes = array_merge( $shortcodes, $codes_from_objs[$group] ); |
|
504 | + foreach ($groups as $group) { |
|
505 | + $shortcodes = array_merge($shortcodes, $codes_from_objs[$group]); |
|
506 | 506 | } |
507 | 507 | return $shortcodes; |
508 | 508 | } |
@@ -521,29 +521,29 @@ discard block |
||
521 | 521 | */ |
522 | 522 | protected function _invalid_shortcodes($value, $valid_shortcodes) { |
523 | 523 | //first we need to go through the string and get the shortcodes in the string |
524 | - preg_match_all( '/(\[.+?\])/', $value, $matches ); |
|
524 | + preg_match_all('/(\[.+?\])/', $value, $matches); |
|
525 | 525 | $incoming_shortcodes = (array) $matches[0]; |
526 | 526 | |
527 | 527 | //get a diff of the shortcodes in the string vs the valid shortcodes |
528 | - $diff = array_diff( $incoming_shortcodes, array_keys($valid_shortcodes) ); |
|
528 | + $diff = array_diff($incoming_shortcodes, array_keys($valid_shortcodes)); |
|
529 | 529 | |
530 | 530 | //we need to account for custom codes so let's loop through the diff and remove any of those type of codes |
531 | - foreach ( $diff as $ind => $code ) { |
|
532 | - if ( preg_match('/(\[[A-Za-z0-9\_]+_\*)/', $code ) ) { |
|
531 | + foreach ($diff as $ind => $code) { |
|
532 | + if (preg_match('/(\[[A-Za-z0-9\_]+_\*)/', $code)) { |
|
533 | 533 | //strip the shortcode so we just have the BASE string (i.e. [ANSWER_*] ) |
534 | 534 | $dynamic_sc = preg_replace('/(_\*+.+)/', '_*]', $code); |
535 | 535 | //does this exist in the $valid_shortcodes? If so then unset. |
536 | - if ( isset( $valid_shortcodes[$dynamic_sc] ) ) { |
|
537 | - unset( $diff[$ind] ); |
|
536 | + if (isset($valid_shortcodes[$dynamic_sc])) { |
|
537 | + unset($diff[$ind]); |
|
538 | 538 | } |
539 | 539 | } |
540 | 540 | } |
541 | 541 | |
542 | - if ( empty( $diff ) ) return FALSE; //there is no diff, we have no invalid shortcodes, so return |
|
542 | + if (empty($diff)) return FALSE; //there is no diff, we have no invalid shortcodes, so return |
|
543 | 543 | |
544 | 544 | //made it here? then let's assemble the error message |
545 | - $invalid_shortcodes = implode( '</strong>,<strong>', $diff ); |
|
546 | - $invalid_shortcodes = '<strong>' . $invalid_shortcodes . '</strong>'; |
|
545 | + $invalid_shortcodes = implode('</strong>,<strong>', $diff); |
|
546 | + $invalid_shortcodes = '<strong>'.$invalid_shortcodes.'</strong>'; |
|
547 | 547 | return $invalid_shortcodes; |
548 | 548 | } |
549 | 549 | |
@@ -555,13 +555,13 @@ discard block |
||
555 | 555 | * @param string $value incoming value to validate |
556 | 556 | * @return bool true if the string validates, false if it doesn't |
557 | 557 | */ |
558 | - protected function _validate_email( $value ) { |
|
558 | + protected function _validate_email($value) { |
|
559 | 559 | $validate = TRUE; |
560 | 560 | $or_val = $value; |
561 | 561 | |
562 | 562 | // empty strings will validate because this is how a message template |
563 | 563 | // for a particular context can be "turned off" (if there is no email then no message) |
564 | - if ( empty( $value ) ) |
|
564 | + if (empty($value)) |
|
565 | 565 | return $validate; |
566 | 566 | |
567 | 567 | // first determine if there ARE any shortcodes. |
@@ -579,19 +579,19 @@ discard block |
||
579 | 579 | // its possible that this message is being "turned off" for a particular context |
580 | 580 | |
581 | 581 | |
582 | - if ( !empty($or_val) && empty($value) ) |
|
582 | + if ( ! empty($or_val) && empty($value)) |
|
583 | 583 | return $validate; |
584 | 584 | |
585 | 585 | //trim any commas from beginning and end of string ( after whitespace trimmed ); |
586 | - $value = trim( trim($value), ',' ); |
|
586 | + $value = trim(trim($value), ','); |
|
587 | 587 | |
588 | 588 | |
589 | 589 | //next we need to split up the string if its comma delimited. |
590 | 590 | $emails = explode(',', $value); |
591 | 591 | $empty = FALSE; //used to indicate that there is an empty comma. |
592 | 592 | //now let's loop through the emails and do our checks |
593 | - foreach ( $emails as $email ) { |
|
594 | - if ( empty($email) ) { |
|
593 | + foreach ($emails as $email) { |
|
594 | + if (empty($email)) { |
|
595 | 595 | $empty = TRUE; |
596 | 596 | continue; |
597 | 597 | } |
@@ -599,20 +599,20 @@ discard block |
||
599 | 599 | //trim whitespace |
600 | 600 | $email = trim($email); |
601 | 601 | //either its of type "[email protected]", or its of type "fname lname <[email protected]>" |
602 | - if(is_email($email)){ |
|
602 | + if (is_email($email)) { |
|
603 | 603 | continue; |
604 | - }else{ |
|
604 | + } else { |
|
605 | 605 | $matches = array(); |
606 | - $validate = preg_match( '/(.*)<(.+)>/', $email, $matches ) ? TRUE : FALSE; |
|
607 | - if( $validate && is_email($matches[2])){ |
|
606 | + $validate = preg_match('/(.*)<(.+)>/', $email, $matches) ? TRUE : FALSE; |
|
607 | + if ($validate && is_email($matches[2])) { |
|
608 | 608 | continue; |
609 | - }else{ |
|
609 | + } else { |
|
610 | 610 | return false; |
611 | 611 | } |
612 | 612 | } |
613 | 613 | } |
614 | 614 | |
615 | - $validate = $empty && !$has_shortcodes ? FALSE : $validate; |
|
615 | + $validate = $empty && ! $has_shortcodes ? FALSE : $validate; |
|
616 | 616 | |
617 | 617 | return $validate; |
618 | 618 | |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | * @throws Exception |
629 | 629 | * @return mixed |
630 | 630 | */ |
631 | - public function __get( $property ) { |
|
631 | + public function __get($property) { |
|
632 | 632 | $expected_properties_map = array( |
633 | 633 | /** |
634 | 634 | * @deprecated 4.9.0 |
@@ -640,15 +640,15 @@ discard block |
||
640 | 640 | '_MSGTYP' => '_message_type' |
641 | 641 | ); |
642 | 642 | |
643 | - if ( isset( $expected_properties_map[ $property ] ) ) { |
|
644 | - return $this->{$expected_properties_map[ $property ]}; |
|
643 | + if (isset($expected_properties_map[$property])) { |
|
644 | + return $this->{$expected_properties_map[$property]}; |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | throw new Exception( |
648 | 648 | sprintf( |
649 | - __( 'The property %1$s being requested on %2$s does not exist', 'event_espresso' ), |
|
649 | + __('The property %1$s being requested on %2$s does not exist', 'event_espresso'), |
|
650 | 650 | $property, |
651 | - get_class( $this ) |
|
651 | + get_class($this) |
|
652 | 652 | ) |
653 | 653 | ); |
654 | 654 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | class EE_Messages_Email_Payment_Reminder_Validator extends EE_Messages_Validator { |
31 | 31 | |
32 | 32 | |
33 | - public function __construct( $fields, $context ) { |
|
33 | + public function __construct($fields, $context) { |
|
34 | 34 | $this->_m_name = 'email'; |
35 | 35 | $this->_mt_name = 'payment_reminder'; |
36 | 36 | |
37 | - parent::__construct( $fields, $context ); |
|
37 | + parent::__construct($fields, $context); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -45,17 +45,17 @@ discard block |
||
45 | 45 | |
46 | 46 | //modify just event_list |
47 | 47 | $new_config['event_list'] = array( |
48 | - 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization','recipient_details', 'recipient_list', 'event_author', 'primary_registration_details', 'primary_registration_list') |
|
48 | + 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'recipient_details', 'recipient_list', 'event_author', 'primary_registration_details', 'primary_registration_list') |
|
49 | 49 | ); |
50 | 50 | $new_config['ticket_list'] = array( |
51 | 51 | 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'recipient_details', 'transaction') |
52 | 52 | ); |
53 | 53 | $new_config['content'] = array( |
54 | - 'shortcodes' => array('event_list','attendee_list', 'ticket_list', 'organization', 'recipient_details', 'recipient_list', 'transaction', 'primary_registration_details', 'primary_registration_list', 'messenger') |
|
54 | + 'shortcodes' => array('event_list', 'attendee_list', 'ticket_list', 'organization', 'recipient_details', 'recipient_list', 'transaction', 'primary_registration_details', 'primary_registration_list', 'messenger') |
|
55 | 55 | ); |
56 | - $this->_messenger->set_validator_config( $new_config ); |
|
56 | + $this->_messenger->set_validator_config($new_config); |
|
57 | 57 | |
58 | - if ( $this->_context != 'admin' ) |
|
58 | + if ($this->_context != 'admin') |
|
59 | 59 | $this->_valid_shortcodes_modifier[$this->_context]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
60 | 60 | |
61 | 61 | $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | class EE_Messages_Email_Cancelled_Registration_Validator extends EE_Messages_Validator { |
31 | 31 | |
32 | 32 | |
33 | - public function __construct( $fields, $context ) { |
|
33 | + public function __construct($fields, $context) { |
|
34 | 34 | $this->_m_name = 'email'; |
35 | 35 | $this->_mt_name = 'cancelled_registration'; |
36 | 36 | |
37 | - parent::__construct( $fields, $context ); |
|
37 | + parent::__construct($fields, $context); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'), |
47 | 47 | 'required' => array('[EVENT_LIST]') |
48 | 48 | ); |
49 | - $this->_messenger->set_validator_config( $new_config ); |
|
49 | + $this->_messenger->set_validator_config($new_config); |
|
50 | 50 | |
51 | - if ( $this->_context != 'admin' ) |
|
51 | + if ($this->_context != 'admin') |
|
52 | 52 | $this->_valid_shortcodes_modifier[$this->_context]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
53 | 53 | |
54 | 54 | $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -97,67 +97,67 @@ discard block |
||
97 | 97 | 'message_type' => $message_type, |
98 | 98 | 'message' => $message |
99 | 99 | ); |
100 | - $this->_init_data( $template, $data, $valid_shortcodes, $extra_data ); |
|
100 | + $this->_init_data($template, $data, $valid_shortcodes, $extra_data); |
|
101 | 101 | $this->_template = is_array($template) ? $template['main'] : $template; |
102 | 102 | return $this->_parse_message_template(); |
103 | 103 | } |
104 | 104 | |
105 | 105 | |
106 | - public function parse_attendee_list_template( $template, EE_Registration $registration, $valid_shortcodes, $extra_data = array() ) { |
|
107 | - $this->_init_data( $template, $registration, $valid_shortcodes, $extra_data ); |
|
106 | + public function parse_attendee_list_template($template, EE_Registration $registration, $valid_shortcodes, $extra_data = array()) { |
|
107 | + $this->_init_data($template, $registration, $valid_shortcodes, $extra_data); |
|
108 | 108 | $this->_template = is_array($template) ? $template['attendee_list'] : $template; |
109 | 109 | return $this->_parse_message_template(); |
110 | 110 | } |
111 | 111 | |
112 | - public function parse_event_list_template( $template, EE_Event $event, $valid_shortcodes, $extra_data = array() ) { |
|
113 | - $this->_init_data( $template, $event, $valid_shortcodes, $extra_data ); |
|
112 | + public function parse_event_list_template($template, EE_Event $event, $valid_shortcodes, $extra_data = array()) { |
|
113 | + $this->_init_data($template, $event, $valid_shortcodes, $extra_data); |
|
114 | 114 | $this->_template = is_array($template) ? $template['event_list'] : $template; |
115 | 115 | return $this->_parse_message_template(); |
116 | 116 | } |
117 | 117 | |
118 | 118 | |
119 | - public function parse_ticket_list_template( $template, EE_Ticket $ticket, $valid_shortcodes, $extra_data = array() ) { |
|
120 | - $this->_init_data( $template, $ticket, $valid_shortcodes, $extra_data ); |
|
119 | + public function parse_ticket_list_template($template, EE_Ticket $ticket, $valid_shortcodes, $extra_data = array()) { |
|
120 | + $this->_init_data($template, $ticket, $valid_shortcodes, $extra_data); |
|
121 | 121 | $this->_template = is_array($template) ? $template['ticket_list'] : $template; |
122 | 122 | return $this->_parse_message_template(); |
123 | 123 | } |
124 | 124 | |
125 | 125 | |
126 | 126 | |
127 | - public function parse_line_item_list_template( $template, EE_Line_Item $line_item, $valid_shortcodes, $extra_data = array() ) { |
|
128 | - $this->_init_data( $template, $line_item, $valid_shortcodes, $extra_data ); |
|
129 | - $this->_template = is_array( $template ) ? $template['ticket_line_item_no_pms'] : $template; |
|
127 | + public function parse_line_item_list_template($template, EE_Line_Item $line_item, $valid_shortcodes, $extra_data = array()) { |
|
128 | + $this->_init_data($template, $line_item, $valid_shortcodes, $extra_data); |
|
129 | + $this->_template = is_array($template) ? $template['ticket_line_item_no_pms'] : $template; |
|
130 | 130 | return $this->_parse_message_template(); |
131 | 131 | } |
132 | 132 | |
133 | 133 | |
134 | - public function parse_payment_list_template( $template, EE_Payment $payment_item, $valid_shortcodes, $extra_data = array() ) { |
|
135 | - $this->_init_data( $template, $payment_item, $valid_shortcodes, $extra_data ); |
|
136 | - $this->_template = is_array( $template ) ? $template['payment_list'] : $template; |
|
134 | + public function parse_payment_list_template($template, EE_Payment $payment_item, $valid_shortcodes, $extra_data = array()) { |
|
135 | + $this->_init_data($template, $payment_item, $valid_shortcodes, $extra_data); |
|
136 | + $this->_template = is_array($template) ? $template['payment_list'] : $template; |
|
137 | 137 | return $this->_parse_message_template(); |
138 | 138 | } |
139 | 139 | |
140 | 140 | |
141 | - public function parse_datetime_list_template( $template, EE_Datetime $datetime, $valid_shortcodes, $extra_data = array() ) { |
|
142 | - $this->_init_data( $template, $datetime, $valid_shortcodes, $extra_data ); |
|
141 | + public function parse_datetime_list_template($template, EE_Datetime $datetime, $valid_shortcodes, $extra_data = array()) { |
|
142 | + $this->_init_data($template, $datetime, $valid_shortcodes, $extra_data); |
|
143 | 143 | $this->_template = is_array($template) ? $template['datetime_list'] : $template; |
144 | 144 | return $this->_parse_message_template(); |
145 | 145 | } |
146 | 146 | |
147 | 147 | |
148 | - public function parse_question_list_template( $template, EE_Answer $answer, $valid_shortcodes, $extra_data = array() ) { |
|
149 | - $this->_init_data( $template, $answer, $valid_shortcodes, $extra_data ); |
|
148 | + public function parse_question_list_template($template, EE_Answer $answer, $valid_shortcodes, $extra_data = array()) { |
|
149 | + $this->_init_data($template, $answer, $valid_shortcodes, $extra_data); |
|
150 | 150 | $this->_template = is_array($template) ? $template['question_list'] : $template; |
151 | 151 | return $this->_parse_message_template(); |
152 | 152 | } |
153 | 153 | |
154 | 154 | |
155 | - private function _init_data( $template, $data, $valid_shortcodes, $extra_data = array() ) { |
|
155 | + private function _init_data($template, $data, $valid_shortcodes, $extra_data = array()) { |
|
156 | 156 | $this->_reset_props(); |
157 | 157 | $this->_data['template'] = $template; |
158 | 158 | $this->_data['data'] = $data; |
159 | 159 | $this->_data['extra_data'] = $extra_data; |
160 | - $this->_set_shortcodes( $valid_shortcodes ); |
|
160 | + $this->_set_shortcodes($valid_shortcodes); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | private function _parse_message_template() { |
177 | 177 | //now let's get a list of shortcodes that are found in the given template |
178 | - preg_match_all( '/(\[.+?\])/', $this->_template, $matches ); |
|
178 | + preg_match_all('/(\[.+?\])/', $this->_template, $matches); |
|
179 | 179 | $shortcodes = (array) $matches[0]; //this should be an array of shortcodes in the template string. |
180 | 180 | |
181 | 181 | $matched_code = array(); |
@@ -200,30 +200,30 @@ discard block |
||
200 | 200 | '[PAYMENT_LIST_*]' |
201 | 201 | ); |
202 | 202 | |
203 | - $list_type_shortcodes = apply_filters( 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', $list_type_shortcodes ); |
|
203 | + $list_type_shortcodes = apply_filters('FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', $list_type_shortcodes); |
|
204 | 204 | |
205 | 205 | //now lets go ahead and loop through our parsers for each shortcode and setup the values |
206 | - foreach ( $shortcodes as $shortcode ) { |
|
206 | + foreach ($shortcodes as $shortcode) { |
|
207 | 207 | |
208 | - foreach ( $this->_shortcode_objs as $sc_obj ) { |
|
209 | - if ( $sc_obj instanceof EE_Shortcodes ){ |
|
208 | + foreach ($this->_shortcode_objs as $sc_obj) { |
|
209 | + if ($sc_obj instanceof EE_Shortcodes) { |
|
210 | 210 | //we need to setup any dynamic shortcodes so that they work with the array_key_exists |
211 | - preg_match_all( '/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches ); |
|
212 | - $sc_to_verify = !empty($matches[0] ) ? $matches[0][0] . ']' : $shortcode; |
|
211 | + preg_match_all('/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches); |
|
212 | + $sc_to_verify = ! empty($matches[0]) ? $matches[0][0].']' : $shortcode; |
|
213 | 213 | |
214 | - if ( !array_key_exists( $sc_to_verify, $sc_obj->get_shortcodes() ) ) { |
|
214 | + if ( ! array_key_exists($sc_to_verify, $sc_obj->get_shortcodes())) { |
|
215 | 215 | continue; //the given shortcode isn't in this object |
216 | 216 | } |
217 | 217 | |
218 | 218 | //if this isn't a "list" type shortcode then we'll send along the data vanilla instead of in an array. |
219 | - if ( ! in_array( $sc_to_verify, $list_type_shortcodes ) ) { |
|
220 | - $data_send = !is_object($this->_data) && isset($this->_data['data']) ? $this->_data['data'] : $this->_data; |
|
219 | + if ( ! in_array($sc_to_verify, $list_type_shortcodes)) { |
|
220 | + $data_send = ! is_object($this->_data) && isset($this->_data['data']) ? $this->_data['data'] : $this->_data; |
|
221 | 221 | } else { |
222 | 222 | $data_send = $this->_data; |
223 | 223 | } |
224 | 224 | |
225 | 225 | |
226 | - $parsed = $sc_obj->parser( $shortcode, $data_send, $this->_data['extra_data'] ); |
|
226 | + $parsed = $sc_obj->parser($shortcode, $data_send, $this->_data['extra_data']); |
|
227 | 227 | |
228 | 228 | $matched_code[] = $shortcode; |
229 | 229 | $sc_values[] = $parsed; |
@@ -246,12 +246,12 @@ discard block |
||
246 | 246 | * @param array $valid_shortcodes an array of strings corresponding to EE_Shortcode Library objects |
247 | 247 | * @return void |
248 | 248 | */ |
249 | - private function _set_shortcodes( $valid_shortcodes ) { |
|
250 | - foreach ( $valid_shortcodes as $shortcode_ref ) { |
|
251 | - $ref = ucwords( str_replace('_', ' ', $shortcode_ref ) ); |
|
252 | - $ref = str_replace( ' ', '_', $ref ); |
|
253 | - $classname = 'EE_' . $ref . '_Shortcodes'; |
|
254 | - if ( class_exists( $classname ) ) { |
|
249 | + private function _set_shortcodes($valid_shortcodes) { |
|
250 | + foreach ($valid_shortcodes as $shortcode_ref) { |
|
251 | + $ref = ucwords(str_replace('_', ' ', $shortcode_ref)); |
|
252 | + $ref = str_replace(' ', '_', $ref); |
|
253 | + $classname = 'EE_'.$ref.'_Shortcodes'; |
|
254 | + if (class_exists($classname)) { |
|
255 | 255 | $this->_shortcode_objs[] = new $classname; |
256 | 256 | } |
257 | 257 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | class EE_Messages_Email_Cancelled_Registration_Validator extends EE_Messages_Validator { |
31 | 31 | |
32 | 32 | |
33 | - public function __construct( $fields, $context ) { |
|
33 | + public function __construct($fields, $context) { |
|
34 | 34 | $this->_m_name = 'email'; |
35 | 35 | $this->_mt_name = 'cancelled_registration'; |
36 | 36 | |
37 | - parent::__construct( $fields, $context ); |
|
37 | + parent::__construct($fields, $context); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'), |
47 | 47 | 'required' => array('[EVENT_LIST]') |
48 | 48 | ); |
49 | - $this->_messenger->set_validator_config( $new_config ); |
|
49 | + $this->_messenger->set_validator_config($new_config); |
|
50 | 50 | |
51 | - if ( $this->_context != 'admin' ) |
|
51 | + if ($this->_context != 'admin') |
|
52 | 52 | $this->_valid_shortcodes_modifier[$this->_context]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
53 | 53 | |
54 | 54 | $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | class EE_Messages_Email_Cancelled_Registration_Validator extends EE_Messages_Validator { |
31 | 31 | |
32 | 32 | |
33 | - public function __construct( $fields, $context ) { |
|
33 | + public function __construct($fields, $context) { |
|
34 | 34 | $this->_m_name = 'email'; |
35 | 35 | $this->_mt_name = 'cancelled_registration'; |
36 | 36 | |
37 | - parent::__construct( $fields, $context ); |
|
37 | + parent::__construct($fields, $context); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'), |
47 | 47 | 'required' => array('[EVENT_LIST]') |
48 | 48 | ); |
49 | - $this->_messenger->set_validator_config( $new_config ); |
|
49 | + $this->_messenger->set_validator_config($new_config); |
|
50 | 50 | |
51 | - if ( $this->_context != 'admin' ) |
|
51 | + if ($this->_context != 'admin') |
|
52 | 52 | $this->_valid_shortcodes_modifier[$this->_context]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
53 | 53 | |
54 | 54 | $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | class EE_Messages_Email_Cancelled_Registration_Validator extends EE_Messages_Validator { |
31 | 31 | |
32 | 32 | |
33 | - public function __construct( $fields, $context ) { |
|
33 | + public function __construct($fields, $context) { |
|
34 | 34 | $this->_m_name = 'email'; |
35 | 35 | $this->_mt_name = 'cancelled_registration'; |
36 | 36 | |
37 | - parent::__construct( $fields, $context ); |
|
37 | + parent::__construct($fields, $context); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'), |
47 | 47 | 'required' => array('[EVENT_LIST]') |
48 | 48 | ); |
49 | - $this->_messenger->set_validator_config( $new_config ); |
|
49 | + $this->_messenger->set_validator_config($new_config); |
|
50 | 50 | |
51 | - if ( $this->_context != 'admin' ) |
|
51 | + if ($this->_context != 'admin') |
|
52 | 52 | $this->_valid_shortcodes_modifier[$this->_context]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
53 | 53 | |
54 | 54 | $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | class EE_Messages_Email_Payment_Reminder_Validator extends EE_Messages_Validator { |
31 | 31 | |
32 | 32 | |
33 | - public function __construct( $fields, $context ) { |
|
33 | + public function __construct($fields, $context) { |
|
34 | 34 | $this->_m_name = 'email'; |
35 | 35 | $this->_mt_name = 'payment_reminder'; |
36 | 36 | |
37 | - parent::__construct( $fields, $context ); |
|
37 | + parent::__construct($fields, $context); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -45,17 +45,17 @@ discard block |
||
45 | 45 | |
46 | 46 | //modify just event_list |
47 | 47 | $new_config['event_list'] = array( |
48 | - 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization','recipient_details', 'recipient_list', 'event_author', 'primary_registration_details', 'primary_registration_list') |
|
48 | + 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'recipient_details', 'recipient_list', 'event_author', 'primary_registration_details', 'primary_registration_list') |
|
49 | 49 | ); |
50 | 50 | $new_config['ticket_list'] = array( |
51 | 51 | 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'recipient_details', 'transaction') |
52 | 52 | ); |
53 | 53 | $new_config['content'] = array( |
54 | - 'shortcodes' => array('event_list','attendee_list', 'ticket_list', 'organization', 'recipient_details', 'recipient_list', 'transaction', 'primary_registration_details', 'primary_registration_list', 'messenger') |
|
54 | + 'shortcodes' => array('event_list', 'attendee_list', 'ticket_list', 'organization', 'recipient_details', 'recipient_list', 'transaction', 'primary_registration_details', 'primary_registration_list', 'messenger') |
|
55 | 55 | ); |
56 | - $this->_messenger->set_validator_config( $new_config ); |
|
56 | + $this->_messenger->set_validator_config($new_config); |
|
57 | 57 | |
58 | - if ( $this->_context != 'admin' ) |
|
58 | + if ($this->_context != 'admin') |
|
59 | 59 | $this->_valid_shortcodes_modifier[$this->_context]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
60 | 60 | |
61 | 61 | $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | class EE_Messages_Email_Cancelled_Registration_Validator extends EE_Messages_Validator { |
31 | 31 | |
32 | 32 | |
33 | - public function __construct( $fields, $context ) { |
|
33 | + public function __construct($fields, $context) { |
|
34 | 34 | $this->_m_name = 'email'; |
35 | 35 | $this->_mt_name = 'cancelled_registration'; |
36 | 36 | |
37 | - parent::__construct( $fields, $context ); |
|
37 | + parent::__construct($fields, $context); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'), |
47 | 47 | 'required' => array('[EVENT_LIST]') |
48 | 48 | ); |
49 | - $this->_messenger->set_validator_config( $new_config ); |
|
49 | + $this->_messenger->set_validator_config($new_config); |
|
50 | 50 | |
51 | - if ( $this->_context != 'admin' ) |
|
51 | + if ($this->_context != 'admin') |
|
52 | 52 | $this->_valid_shortcodes_modifier[$this->_context]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
53 | 53 | |
54 | 54 | $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'); |