@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * before the hook wp_enqueue_scripts is called (so that the form section can enqueue its needed scripts). |
8 | 8 | * However, you may output the form (usually by calling get_html_and_js) anywhere you like. |
9 | 9 | */ |
10 | -class EE_Form_Section_Proper extends EE_Form_Section_Validatable{ |
|
10 | +class EE_Form_Section_Proper extends EE_Form_Section_Validatable { |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * Subsections |
@@ -68,37 +68,37 @@ discard block |
||
68 | 68 | * } @see EE_Form_Section_Validatable::__construct() |
69 | 69 | * |
70 | 70 | */ |
71 | - public function __construct( $options_array = array() ){ |
|
72 | - $options_array = apply_filters( 'FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this ); |
|
71 | + public function __construct($options_array = array()) { |
|
72 | + $options_array = apply_filters('FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this); |
|
73 | 73 | //call parent first, as it may be setting the name |
74 | 74 | parent::__construct($options_array); |
75 | 75 | //if they've included subsections in the constructor, add them now |
76 | - if( isset( $options_array['include'] )){ |
|
76 | + if (isset($options_array['include'])) { |
|
77 | 77 | //we are going to make sure we ONLY have those subsections to include |
78 | 78 | //AND we are going to make sure they're in that specified order |
79 | 79 | $reordered_subsections = array(); |
80 | - foreach($options_array['include'] as $input_name){ |
|
81 | - if(isset($this->_subsections[$input_name])){ |
|
80 | + foreach ($options_array['include'] as $input_name) { |
|
81 | + if (isset($this->_subsections[$input_name])) { |
|
82 | 82 | $reordered_subsections[$input_name] = $this->_subsections[$input_name]; |
83 | 83 | } |
84 | 84 | } |
85 | 85 | $this->_subsections = $reordered_subsections; |
86 | 86 | } |
87 | - if(isset($options_array['exclude'])){ |
|
87 | + if (isset($options_array['exclude'])) { |
|
88 | 88 | $exclude = $options_array['exclude']; |
89 | 89 | $this->_subsections = array_diff_key($this->_subsections, array_flip($exclude)); |
90 | 90 | } |
91 | - if(isset($options_array['layout_strategy'])){ |
|
91 | + if (isset($options_array['layout_strategy'])) { |
|
92 | 92 | $this->_layout_strategy = $options_array['layout_strategy']; |
93 | 93 | } |
94 | - if( ! $this->_layout_strategy){ |
|
94 | + if ( ! $this->_layout_strategy) { |
|
95 | 95 | $this->_layout_strategy = new EE_Two_Column_Layout(); |
96 | 96 | } |
97 | 97 | $this->_layout_strategy->_construct_finalize($this); |
98 | 98 | |
99 | - add_action( 'wp_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
100 | - add_action( 'admin_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
101 | - add_action( 'wp_footer', array( $this, 'ensure_scripts_localized' ), 1 ); |
|
99 | + add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
100 | + add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
101 | + add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | |
@@ -110,25 +110,25 @@ discard block |
||
110 | 110 | * @param string $name |
111 | 111 | * @throws \EE_Error |
112 | 112 | */ |
113 | - public function _construct_finalize( $parent_form_section, $name ) { |
|
113 | + public function _construct_finalize($parent_form_section, $name) { |
|
114 | 114 | parent::_construct_finalize($parent_form_section, $name); |
115 | 115 | $this->_set_default_name_if_empty(); |
116 | 116 | $this->_set_default_html_id_if_empty(); |
117 | - foreach( $this->_subsections as $subsection_name => $subsection ){ |
|
118 | - if ( $subsection instanceof EE_Form_Section_Base ) { |
|
119 | - $subsection->_construct_finalize( $this, $subsection_name ); |
|
117 | + foreach ($this->_subsections as $subsection_name => $subsection) { |
|
118 | + if ($subsection instanceof EE_Form_Section_Base) { |
|
119 | + $subsection->_construct_finalize($this, $subsection_name); |
|
120 | 120 | } else { |
121 | 121 | throw new EE_Error( |
122 | 122 | sprintf( |
123 | - __( 'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso' ), |
|
123 | + __('Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso'), |
|
124 | 124 | $subsection_name, |
125 | 125 | get_class($this), |
126 | - $subsection ? get_class($subsection) : __( 'NULL', 'event_espresso' ) |
|
126 | + $subsection ? get_class($subsection) : __('NULL', 'event_espresso') |
|
127 | 127 | ) |
128 | 128 | ); |
129 | 129 | } |
130 | 130 | } |
131 | - do_action( 'AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name ); |
|
131 | + do_action('AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * Gets the layout strategy for this form section |
138 | 138 | * @return EE_Form_Section_Layout_Base |
139 | 139 | */ |
140 | - public function get_layout_strategy(){ |
|
140 | + public function get_layout_strategy() { |
|
141 | 141 | return $this->_layout_strategy; |
142 | 142 | } |
143 | 143 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @param EE_Form_Input_Base $input |
150 | 150 | * @return string |
151 | 151 | */ |
152 | - public function get_html_for_input($input){ |
|
152 | + public function get_html_for_input($input) { |
|
153 | 153 | return $this->_layout_strategy->layout_input($input); |
154 | 154 | } |
155 | 155 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @param null $form_data |
163 | 163 | * @return boolean |
164 | 164 | */ |
165 | - public function was_submitted($form_data = NULL){ |
|
165 | + public function was_submitted($form_data = NULL) { |
|
166 | 166 | return $this->form_data_present_in($form_data); |
167 | 167 | } |
168 | 168 | |
@@ -187,16 +187,16 @@ discard block |
||
187 | 187 | * (eg you validated the data then stored it in the DB) you may want to skip this step. |
188 | 188 | * @return void |
189 | 189 | */ |
190 | - public function receive_form_submission($req_data = NULL, $validate = TRUE){ |
|
191 | - $req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate ); |
|
192 | - if( $req_data === NULL){ |
|
193 | - $req_data = array_merge( $_GET, $_POST ); |
|
190 | + public function receive_form_submission($req_data = NULL, $validate = TRUE) { |
|
191 | + $req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate); |
|
192 | + if ($req_data === NULL) { |
|
193 | + $req_data = array_merge($_GET, $_POST); |
|
194 | 194 | } |
195 | 195 | $this->_normalize($req_data); |
196 | - if( $validate ){ |
|
196 | + if ($validate) { |
|
197 | 197 | $this->_validate(); |
198 | 198 | } |
199 | - do_action( 'AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate ); |
|
199 | + do_action('AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | |
@@ -209,12 +209,12 @@ discard block |
||
209 | 209 | * the value being an array formatted in teh same way |
210 | 210 | * @param array $default_data |
211 | 211 | */ |
212 | - public function populate_defaults($default_data){ |
|
213 | - foreach($this->subsections() as $subsection_name => $subsection){ |
|
214 | - if(isset($default_data[$subsection_name])){ |
|
215 | - if($subsection instanceof EE_Form_Input_Base){ |
|
212 | + public function populate_defaults($default_data) { |
|
213 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
214 | + if (isset($default_data[$subsection_name])) { |
|
215 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
216 | 216 | $subsection->set_default($default_data[$subsection_name]); |
217 | - }elseif($subsection instanceof EE_Form_Section_Proper){ |
|
217 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
218 | 218 | $subsection->populate_defaults($default_data[$subsection_name]); |
219 | 219 | } |
220 | 220 | } |
@@ -232,8 +232,8 @@ discard block |
||
232 | 232 | * (realizing that the subsections' html names might not be set yet, etc.) |
233 | 233 | * @return EE_Form_Section_Base |
234 | 234 | */ |
235 | - public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
236 | - if( $require_construction_to_be_finalized ){ |
|
235 | + public function get_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
236 | + if ($require_construction_to_be_finalized) { |
|
237 | 237 | $this->ensure_construct_finalized_called(); |
238 | 238 | } |
239 | 239 | return isset($this->_subsections[$name]) ? $this->_subsections[$name] : NULL; |
@@ -245,10 +245,10 @@ discard block |
||
245 | 245 | * Gets all the validatable subsections of this form section |
246 | 246 | * @return EE_Form_Section_Validatable[] |
247 | 247 | */ |
248 | - public function get_validatable_subsections(){ |
|
248 | + public function get_validatable_subsections() { |
|
249 | 249 | $validatable_subsections = array(); |
250 | - foreach($this->subsections() as $name=>$obj){ |
|
251 | - if($obj instanceof EE_Form_Section_Validatable){ |
|
250 | + foreach ($this->subsections() as $name=>$obj) { |
|
251 | + if ($obj instanceof EE_Form_Section_Validatable) { |
|
252 | 252 | $validatable_subsections[$name] = $obj; |
253 | 253 | } |
254 | 254 | } |
@@ -268,10 +268,10 @@ discard block |
||
268 | 268 | * @return EE_Form_Input_Base |
269 | 269 | * @throws EE_Error |
270 | 270 | */ |
271 | - public function get_input($name, $require_construction_to_be_finalized = TRUE ){ |
|
271 | + public function get_input($name, $require_construction_to_be_finalized = TRUE) { |
|
272 | 272 | $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
273 | - if( ! $subsection instanceof EE_Form_Input_Base){ |
|
274 | - throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'),$name, get_class($this),$subsection ? get_class($subsection) : __("NULL", 'event_espresso'))); |
|
273 | + if ( ! $subsection instanceof EE_Form_Input_Base) { |
|
274 | + throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'), $name, get_class($this), $subsection ? get_class($subsection) : __("NULL", 'event_espresso'))); |
|
275 | 275 | } |
276 | 276 | return $subsection; |
277 | 277 | } |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | * @return EE_Form_Section_Proper |
290 | 290 | * @throws EE_Error |
291 | 291 | */ |
292 | - public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
293 | - $subsection = $this->get_subsection( $name, $require_construction_to_be_finalized ); |
|
294 | - if( ! $subsection instanceof EE_Form_Section_Proper){ |
|
295 | - throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'),$name, get_class($this))); |
|
292 | + public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
293 | + $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
|
294 | + if ( ! $subsection instanceof EE_Form_Section_Proper) { |
|
295 | + throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'), $name, get_class($this))); |
|
296 | 296 | } |
297 | 297 | return $subsection; |
298 | 298 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | * @param string $name |
306 | 306 | * @return mixed depending on the input's type and its normalization strategy |
307 | 307 | */ |
308 | - public function get_input_value($name){ |
|
308 | + public function get_input_value($name) { |
|
309 | 309 | $input = $this->get_input($name); |
310 | 310 | return $input->normalized_value(); |
311 | 311 | } |
@@ -318,16 +318,16 @@ discard block |
||
318 | 318 | * @return boolean |
319 | 319 | */ |
320 | 320 | public function is_valid() { |
321 | - if( ! $this->has_received_submission()){ |
|
321 | + if ( ! $this->has_received_submission()) { |
|
322 | 322 | throw new EE_Error(sprintf(__("You cannot check if a form is valid before receiving the form submission using receive_form_submission", "event_espresso"))); |
323 | 323 | } |
324 | - if( ! parent::is_valid()){ |
|
324 | + if ( ! parent::is_valid()) { |
|
325 | 325 | return false; |
326 | 326 | } |
327 | 327 | //ok so no errors general to this entire form section. so let's check the subsections |
328 | - foreach( $this->get_validatable_subsections() as $subsection ){ |
|
329 | - if( ! $subsection->is_valid() || $subsection->get_validation_error_string() != '' ){ |
|
330 | - $this->set_submission_error_message( $subsection->get_validation_error_string() ); |
|
328 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
329 | + if ( ! $subsection->is_valid() || $subsection->get_validation_error_string() != '') { |
|
330 | + $this->set_submission_error_message($subsection->get_validation_error_string()); |
|
331 | 331 | return false; |
332 | 332 | } |
333 | 333 | } |
@@ -340,11 +340,11 @@ discard block |
||
340 | 340 | * gets teh default name of this form section if none is specified |
341 | 341 | * @return string |
342 | 342 | */ |
343 | - protected function _set_default_name_if_empty(){ |
|
344 | - if( ! $this->_name ){ |
|
343 | + protected function _set_default_name_if_empty() { |
|
344 | + if ( ! $this->_name) { |
|
345 | 345 | $classname = get_class($this); |
346 | 346 | $default_name = str_replace("EE_", "", $classname); |
347 | - $this->_name = $default_name; |
|
347 | + $this->_name = $default_name; |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 | |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * Also returns the HTML for the form, except for the form opening and closing tags |
356 | 356 | * (as the form section doesn't know where you necessarily want to send the information to), and except for a submit button. |
357 | 357 | */ |
358 | - public function get_html_and_js(){ |
|
358 | + public function get_html_and_js() { |
|
359 | 359 | $this->enqueue_js(); |
360 | 360 | return $this->get_html(); |
361 | 361 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | * returns HTML for displaying this form section. recursively calls display_section() on all subsections |
367 | 367 | * @return string |
368 | 368 | */ |
369 | - public function get_html(){ |
|
369 | + public function get_html() { |
|
370 | 370 | $this->ensure_construct_finalized_called(); |
371 | 371 | return $this->_layout_strategy->layout_form(); |
372 | 372 | } |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | * enqueues JS for the form |
378 | 378 | * @return string |
379 | 379 | */ |
380 | - public function enqueue_js(){ |
|
380 | + public function enqueue_js() { |
|
381 | 381 | $this->_enqueue_and_localize_form_js(); |
382 | 382 | } |
383 | 383 | |
@@ -393,10 +393,10 @@ discard block |
||
393 | 393 | * @param boolean $init_form_validation_automatically whether or not we want the form validation to be triggered automatically or not |
394 | 394 | * @return void |
395 | 395 | */ |
396 | - public static function wp_enqueue_scripts( $init_form_validation_automatically = false ){ |
|
397 | - add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
398 | - wp_register_script( 'ee_form_section_validation', EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js', array( 'jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
399 | - wp_localize_script( 'ee_form_section_validation', 'ee_form_section_validation_init', array( 'init' => $init_form_validation_automatically ) ); |
|
396 | + public static function wp_enqueue_scripts($init_form_validation_automatically = false) { |
|
397 | + add_filter('FHEE_load_jquery_validate', '__return_true'); |
|
398 | + wp_register_script('ee_form_section_validation', EE_GLOBAL_ASSETS_URL.'scripts'.DS.'form_section_validation.js', array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'), EVENT_ESPRESSO_VERSION, TRUE); |
|
399 | + wp_localize_script('ee_form_section_validation', 'ee_form_section_validation_init', array('init' => $init_form_validation_automatically)); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | |
@@ -406,14 +406,14 @@ discard block |
||
406 | 406 | * This needs to be called AFTER we've called $this->_enqueue_jquery_validate_script, |
407 | 407 | * but before the wordpress hook wp_loaded |
408 | 408 | */ |
409 | - public function _enqueue_and_localize_form_js(){ |
|
409 | + public function _enqueue_and_localize_form_js() { |
|
410 | 410 | $this->ensure_construct_finalized_called(); |
411 | 411 | //actually, we don't want to localize just yet. There may be other forms on the page. |
412 | 412 | //so we need to add our form section data to a static variable accessible by all form sections |
413 | 413 | //and localize it just before the footer |
414 | 414 | $this->localize_validation_rules(); |
415 | - add_action( 'wp_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ), 2 ); |
|
416 | - add_action( 'admin_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ) ); |
|
415 | + add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2); |
|
416 | + add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms')); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | |
@@ -423,11 +423,11 @@ discard block |
||
423 | 423 | * @param bool $return_for_subsection |
424 | 424 | * @return void |
425 | 425 | */ |
426 | - public function localize_validation_rules( $return_for_subsection = FALSE ){ |
|
426 | + public function localize_validation_rules($return_for_subsection = FALSE) { |
|
427 | 427 | // we only want to localize vars ONCE for the entire form, so if the form section doesn't have a parent, then it must be the top dog |
428 | - if ( ! $this->parent_section() || $return_for_subsection ) { |
|
429 | - EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array( |
|
430 | - 'form_section_id'=> $this->html_id( TRUE ), |
|
428 | + if ( ! $this->parent_section() || $return_for_subsection) { |
|
429 | + EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array( |
|
430 | + 'form_section_id'=> $this->html_id(TRUE), |
|
431 | 431 | 'validation_rules'=> $this->get_jquery_validation_rules(), |
432 | 432 | 'errors'=> $this->subsection_validation_errors_by_html_name() |
433 | 433 | ); |
@@ -442,12 +442,12 @@ discard block |
||
442 | 442 | * Keys are their form names, and values are the inputs themselves |
443 | 443 | * @return EE_Form_Input_Base |
444 | 444 | */ |
445 | - public function inputs_in_subsections(){ |
|
445 | + public function inputs_in_subsections() { |
|
446 | 446 | $inputs = array(); |
447 | - foreach($this->subsections() as $subsection){ |
|
448 | - if( $subsection instanceof EE_Form_Input_Base ){ |
|
449 | - $inputs[ $subsection->html_name() ] = $subsection; |
|
450 | - }elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
447 | + foreach ($this->subsections() as $subsection) { |
|
448 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
449 | + $inputs[$subsection->html_name()] = $subsection; |
|
450 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
451 | 451 | $inputs += $subsection->inputs_in_subsections(); |
452 | 452 | } |
453 | 453 | } |
@@ -460,12 +460,12 @@ discard block |
||
460 | 460 | * and values are a string of all their validation errors |
461 | 461 | * @return string[] |
462 | 462 | */ |
463 | - public function subsection_validation_errors_by_html_name(){ |
|
463 | + public function subsection_validation_errors_by_html_name() { |
|
464 | 464 | $inputs = $this->inputs(); |
465 | 465 | $errors = array(); |
466 | - foreach( $inputs as $form_input ){ |
|
467 | - if ( $form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors() ){ |
|
468 | - $errors[ $form_input->html_name() ] = $form_input->get_validation_error_string(); |
|
466 | + foreach ($inputs as $form_input) { |
|
467 | + if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) { |
|
468 | + $errors[$form_input->html_name()] = $form_input->get_validation_error_string(); |
|
469 | 469 | } |
470 | 470 | } |
471 | 471 | return $errors; |
@@ -477,16 +477,16 @@ discard block |
||
477 | 477 | * passes all the form data required by the JS to the JS, and enqueues the few required JS files. |
478 | 478 | * Should be setup by each form during the _enqueues_and_localize_form_js |
479 | 479 | */ |
480 | - public static function localize_script_for_all_forms(){ |
|
480 | + public static function localize_script_for_all_forms() { |
|
481 | 481 | //allow inputs and stuff to hook in their JS and stuff here |
482 | 482 | do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin'); |
483 | 483 | EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages(); |
484 | - $email_validation_level = isset( EE_Registry::instance()->CFG->registration->email_validation_level ) |
|
484 | + $email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level) |
|
485 | 485 | ? EE_Registry::instance()->CFG->registration->email_validation_level |
486 | 486 | : 'wp_default'; |
487 | 487 | EE_Form_Section_Proper::$_js_localization['email_validation_level'] = $email_validation_level; |
488 | - wp_enqueue_script( 'ee_form_section_validation' ); |
|
489 | - wp_localize_script( 'ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization ); |
|
488 | + wp_enqueue_script('ee_form_section_validation'); |
|
489 | + wp_localize_script('ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | |
@@ -494,8 +494,8 @@ discard block |
||
494 | 494 | /** |
495 | 495 | * ensure_scripts_localized |
496 | 496 | */ |
497 | - public function ensure_scripts_localized(){ |
|
498 | - if ( ! EE_Form_Section_Proper::$_scripts_localized ) { |
|
497 | + public function ensure_scripts_localized() { |
|
498 | + if ( ! EE_Form_Section_Proper::$_scripts_localized) { |
|
499 | 499 | $this->_enqueue_and_localize_form_js(); |
500 | 500 | } |
501 | 501 | } |
@@ -507,10 +507,10 @@ discard block |
||
507 | 507 | * is that the key here should be the same as the custom validation rule put in the JS file |
508 | 508 | * @return array keys are custom validation rules, and values are internationalized strings |
509 | 509 | */ |
510 | - private static function _get_localized_error_messages(){ |
|
510 | + private static function _get_localized_error_messages() { |
|
511 | 511 | return array( |
512 | 512 | 'validUrl'=> __("This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg", "event_espresso"), |
513 | - 'regex' => __( 'Please check your input', 'event_espresso' ), |
|
513 | + 'regex' => __('Please check your input', 'event_espresso'), |
|
514 | 514 | ); |
515 | 515 | } |
516 | 516 | |
@@ -538,10 +538,10 @@ discard block |
||
538 | 538 | * Gets the JS to put inside the jquery validation rules for subsection of this form section. See parent function for more... |
539 | 539 | * @return array |
540 | 540 | */ |
541 | - function get_jquery_validation_rules(){ |
|
541 | + function get_jquery_validation_rules() { |
|
542 | 542 | $jquery_validation_rules = array(); |
543 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
544 | - $jquery_validation_rules = array_merge( $jquery_validation_rules, $subsection->get_jquery_validation_rules() ); |
|
543 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
544 | + $jquery_validation_rules = array_merge($jquery_validation_rules, $subsection->get_jquery_validation_rules()); |
|
545 | 545 | } |
546 | 546 | return $jquery_validation_rules; |
547 | 547 | } |
@@ -556,11 +556,11 @@ discard block |
||
556 | 556 | protected function _normalize($req_data) { |
557 | 557 | $this->_received_submission = TRUE; |
558 | 558 | $this->_validation_errors = array(); |
559 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
560 | - try{ |
|
559 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
560 | + try { |
|
561 | 561 | $subsection->_normalize($req_data); |
562 | - }catch( EE_Validation_Error $e ){ |
|
563 | - $subsection->add_validation_error( $e ); |
|
562 | + } catch (EE_Validation_Error $e) { |
|
563 | + $subsection->add_validation_error($e); |
|
564 | 564 | } |
565 | 565 | } |
566 | 566 | } |
@@ -574,9 +574,9 @@ discard block |
||
574 | 574 | * calling parent::_validate() first. |
575 | 575 | */ |
576 | 576 | protected function _validate() { |
577 | - foreach($this->get_validatable_subsections() as $subsection_name => $subsection){ |
|
578 | - if(method_exists($this,'_validate_'.$subsection_name)){ |
|
579 | - call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection)); |
|
577 | + foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
578 | + if (method_exists($this, '_validate_'.$subsection_name)) { |
|
579 | + call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection)); |
|
580 | 580 | } |
581 | 581 | $subsection->_validate(); |
582 | 582 | } |
@@ -588,13 +588,13 @@ discard block |
||
588 | 588 | * Gets all the validated inputs for the form section |
589 | 589 | * @return array |
590 | 590 | */ |
591 | - public function valid_data(){ |
|
591 | + public function valid_data() { |
|
592 | 592 | $inputs = array(); |
593 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
594 | - if ( $subsection instanceof EE_Form_Section_Proper ) { |
|
595 | - $inputs[ $subsection_name ] = $subsection->valid_data(); |
|
596 | - } else if ( $subsection instanceof EE_Form_Input_Base ){ |
|
597 | - $inputs[ $subsection_name ] = $subsection->normalized_value(); |
|
593 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
594 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
595 | + $inputs[$subsection_name] = $subsection->valid_data(); |
|
596 | + } else if ($subsection instanceof EE_Form_Input_Base) { |
|
597 | + $inputs[$subsection_name] = $subsection->normalized_value(); |
|
598 | 598 | } |
599 | 599 | } |
600 | 600 | return $inputs; |
@@ -606,11 +606,11 @@ discard block |
||
606 | 606 | * Gets all the inputs on this form section |
607 | 607 | * @return EE_Form_Input_Base[] |
608 | 608 | */ |
609 | - public function inputs(){ |
|
609 | + public function inputs() { |
|
610 | 610 | $inputs = array(); |
611 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
612 | - if ( $subsection instanceof EE_Form_Input_Base ){ |
|
613 | - $inputs[ $subsection_name ] = $subsection; |
|
611 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
612 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
613 | + $inputs[$subsection_name] = $subsection; |
|
614 | 614 | } |
615 | 615 | } |
616 | 616 | return $inputs; |
@@ -622,10 +622,10 @@ discard block |
||
622 | 622 | * Gets all the subsections which are a proper form |
623 | 623 | * @return EE_Form_Section_Proper[] |
624 | 624 | */ |
625 | - public function subforms(){ |
|
625 | + public function subforms() { |
|
626 | 626 | $form_sections = array(); |
627 | - foreach($this->subsections() as $name=>$obj){ |
|
628 | - if($obj instanceof EE_Form_Section_Proper){ |
|
627 | + foreach ($this->subsections() as $name=>$obj) { |
|
628 | + if ($obj instanceof EE_Form_Section_Proper) { |
|
629 | 629 | $form_sections[$name] = $obj; |
630 | 630 | } |
631 | 631 | } |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | * if you only want form inputs or proper form sections. |
641 | 641 | * @return EE_Form_Section_Proper[] |
642 | 642 | */ |
643 | - public function subsections(){ |
|
643 | + public function subsections() { |
|
644 | 644 | $this->ensure_construct_finalized_called(); |
645 | 645 | return $this->_subsections; |
646 | 646 | } |
@@ -658,8 +658,8 @@ discard block |
||
658 | 658 | * it can be a multidimensional array where keys are always subsection names and values are either the |
659 | 659 | * input's normalized value, or an array like the top-level array |
660 | 660 | */ |
661 | - public function input_values( $include_subform_inputs = false, $flatten = false ){ |
|
662 | - return $this->_input_values( false, $include_subform_inputs, $flatten ); |
|
661 | + public function input_values($include_subform_inputs = false, $flatten = false) { |
|
662 | + return $this->_input_values(false, $include_subform_inputs, $flatten); |
|
663 | 663 | } |
664 | 664 | |
665 | 665 | /** |
@@ -675,8 +675,8 @@ discard block |
||
675 | 675 | * it can be a multidimensional array where keys are always subsection names and values are either the |
676 | 676 | * input's normalized value, or an array like the top-level array |
677 | 677 | */ |
678 | - public function input_pretty_values( $include_subform_inputs = false, $flatten = false ){ |
|
679 | - return $this->_input_values( true, $include_subform_inputs, $flatten ); |
|
678 | + public function input_pretty_values($include_subform_inputs = false, $flatten = false) { |
|
679 | + return $this->_input_values(true, $include_subform_inputs, $flatten); |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | /** |
@@ -689,17 +689,17 @@ discard block |
||
689 | 689 | * it can be a multidimensional array where keys are always subsection names and values are either the |
690 | 690 | * input's normalized value, or an array like the top-level array |
691 | 691 | */ |
692 | - public function _input_values( $pretty = false, $include_subform_inputs = false, $flatten = false ) { |
|
692 | + public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false) { |
|
693 | 693 | $input_values = array(); |
694 | - foreach( $this->subsections() as $subsection_name => $subsection ) { |
|
695 | - if( $subsection instanceof EE_Form_Input_Base ) { |
|
696 | - $input_values[ $subsection_name ] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value(); |
|
697 | - } else if( $subsection instanceof EE_Form_Section_Proper && $include_subform_inputs ) { |
|
698 | - $subform_input_values = $subsection->_input_values( $pretty, $include_subform_inputs, $flatten ); |
|
699 | - if( $flatten ) { |
|
700 | - $input_values = array_merge( $input_values, $subform_input_values ); |
|
694 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
695 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
696 | + $input_values[$subsection_name] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value(); |
|
697 | + } else if ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) { |
|
698 | + $subform_input_values = $subsection->_input_values($pretty, $include_subform_inputs, $flatten); |
|
699 | + if ($flatten) { |
|
700 | + $input_values = array_merge($input_values, $subform_input_values); |
|
701 | 701 | } else { |
702 | - $input_values[ $subsection_name ] = $subform_input_values; |
|
702 | + $input_values[$subsection_name] = $subform_input_values; |
|
703 | 703 | } |
704 | 704 | } |
705 | 705 | } |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | * (ie, had receive_form_submission called on it yet) |
714 | 714 | * @return boolean |
715 | 715 | */ |
716 | - public function has_received_submission(){ |
|
716 | + public function has_received_submission() { |
|
717 | 717 | $this->ensure_construct_finalized_called(); |
718 | 718 | return $this->_received_submission; |
719 | 719 | } |
@@ -726,8 +726,8 @@ discard block |
||
726 | 726 | * @param array $inputs_to_exclude values are the input names |
727 | 727 | * @return void |
728 | 728 | */ |
729 | - public function exclude($inputs_to_exclude = array()){ |
|
730 | - foreach($inputs_to_exclude as $input_to_exclude_name){ |
|
729 | + public function exclude($inputs_to_exclude = array()) { |
|
730 | + foreach ($inputs_to_exclude as $input_to_exclude_name) { |
|
731 | 731 | unset($this->_subsections[$input_to_exclude_name]); |
732 | 732 | } |
733 | 733 | } |
@@ -737,8 +737,8 @@ discard block |
||
737 | 737 | /** |
738 | 738 | * @param array $inputs_to_hide |
739 | 739 | */ |
740 | - public function hide($inputs_to_hide= array()){ |
|
741 | - foreach($inputs_to_hide as $input_to_hide){ |
|
740 | + public function hide($inputs_to_hide = array()) { |
|
741 | + foreach ($inputs_to_hide as $input_to_hide) { |
|
742 | 742 | $input = $this->get_input($input_to_hide); |
743 | 743 | |
744 | 744 | $input->set_display_strategy(new EE_Hidden_Display_Strategy()); |
@@ -763,13 +763,13 @@ discard block |
||
763 | 763 | * or if $subsection_name_to_target is null, before or after entire subsections array |
764 | 764 | * @return void |
765 | 765 | */ |
766 | - public function add_subsections( $new_subsections, $subsection_name_to_target = NULL, $add_before = true ){ |
|
767 | - foreach($new_subsections as $subsection_name => $subsection){ |
|
768 | - if( ! $subsection instanceof EE_Form_Section_Base){ |
|
766 | + public function add_subsections($new_subsections, $subsection_name_to_target = NULL, $add_before = true) { |
|
767 | + foreach ($new_subsections as $subsection_name => $subsection) { |
|
768 | + if ( ! $subsection instanceof EE_Form_Section_Base) { |
|
769 | 769 | EE_Error::add_error( |
770 | 770 | sprintf( |
771 | 771 | __("Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.", "event_espresso"), |
772 | - get_class( $subsection ), |
|
772 | + get_class($subsection), |
|
773 | 773 | $subsection_name, |
774 | 774 | $this->name() |
775 | 775 | ) |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | } |
779 | 779 | } |
780 | 780 | |
781 | - $this->_subsections = EEH_Array::insert_into_array( $this->_subsections, $new_subsections, $subsection_name_to_target, $add_before ); |
|
781 | + $this->_subsections = EEH_Array::insert_into_array($this->_subsections, $new_subsections, $subsection_name_to_target, $add_before); |
|
782 | 782 | |
783 | 783 | /*$subsections_before = array(); |
784 | 784 | if( $subsection_name_to_target ){ |
@@ -809,8 +809,8 @@ discard block |
||
809 | 809 | $this->_subsections = $new_subsections; |
810 | 810 | } |
811 | 811 | }*/ |
812 | - if( $this->_construction_finalized ){ |
|
813 | - foreach($this->_subsections as $name => $subsection){ |
|
812 | + if ($this->_construction_finalized) { |
|
813 | + foreach ($this->_subsections as $name => $subsection) { |
|
814 | 814 | $subsection->_construct_finalize($this, $name); |
815 | 815 | } |
816 | 816 | } |
@@ -821,8 +821,8 @@ discard block |
||
821 | 821 | /** |
822 | 822 | * Just gets all validatable subsections to clean their sensitive data |
823 | 823 | */ |
824 | - public function clean_sensitive_data(){ |
|
825 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
824 | + public function clean_sensitive_data() { |
|
825 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
826 | 826 | $subsection->clean_sensitive_data(); |
827 | 827 | } |
828 | 828 | } |
@@ -832,8 +832,8 @@ discard block |
||
832 | 832 | /** |
833 | 833 | * @param string $form_submission_error_message |
834 | 834 | */ |
835 | - public function set_submission_error_message( $form_submission_error_message = '' ) { |
|
836 | - $this->_form_submission_error_message .= ! empty( $form_submission_error_message ) ? $form_submission_error_message : __( 'Form submission failed due to errors', 'event_espresso' ); |
|
835 | + public function set_submission_error_message($form_submission_error_message = '') { |
|
836 | + $this->_form_submission_error_message .= ! empty($form_submission_error_message) ? $form_submission_error_message : __('Form submission failed due to errors', 'event_espresso'); |
|
837 | 837 | } |
838 | 838 | |
839 | 839 | |
@@ -850,8 +850,8 @@ discard block |
||
850 | 850 | /** |
851 | 851 | * @param string $form_submission_success_message |
852 | 852 | */ |
853 | - public function set_submission_success_message( $form_submission_success_message ) { |
|
854 | - $this->_form_submission_success_message .= ! empty( $form_submission_success_message ) ? $form_submission_success_message : __( 'Form submitted successfully', 'event_espresso' ); |
|
853 | + public function set_submission_success_message($form_submission_success_message) { |
|
854 | + $this->_form_submission_success_message .= ! empty($form_submission_success_message) ? $form_submission_success_message : __('Form submitted successfully', 'event_espresso'); |
|
855 | 855 | } |
856 | 856 | |
857 | 857 | |
@@ -873,10 +873,10 @@ discard block |
||
873 | 873 | * EE_Form_Input_Base::_set_default_html_name_if_empty |
874 | 874 | * @return string |
875 | 875 | */ |
876 | - public function html_name_prefix(){ |
|
877 | - if( $this->parent_section() instanceof EE_Form_Section_Proper ){ |
|
878 | - return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']'; |
|
879 | - }else{ |
|
876 | + public function html_name_prefix() { |
|
877 | + if ($this->parent_section() instanceof EE_Form_Section_Proper) { |
|
878 | + return $this->parent_section()->html_name_prefix().'['.$this->name().']'; |
|
879 | + } else { |
|
880 | 880 | return $this->name(); |
881 | 881 | } |
882 | 882 | } |
@@ -887,7 +887,7 @@ discard block |
||
887 | 887 | * was set, which is probably nothing, or the classname) |
888 | 888 | * @return string |
889 | 889 | */ |
890 | - public function name(){ |
|
890 | + public function name() { |
|
891 | 891 | $this->ensure_construct_finalized_called(); |
892 | 892 | return parent::name(); |
893 | 893 | } |
@@ -896,7 +896,7 @@ discard block |
||
896 | 896 | * |
897 | 897 | * @return EE_Form_Section_Proper |
898 | 898 | */ |
899 | - public function parent_section(){ |
|
899 | + public function parent_section() { |
|
900 | 900 | $this->ensure_construct_finalized_called(); |
901 | 901 | return parent::parent_section(); |
902 | 902 | } |
@@ -905,9 +905,9 @@ discard block |
||
905 | 905 | * make sure construction finalized was called, otherwise children might not be ready |
906 | 906 | * @return void |
907 | 907 | */ |
908 | - public function ensure_construct_finalized_called(){ |
|
909 | - if( ! $this->_construction_finalized ){ |
|
910 | - $this->_construct_finalize($this->_parent_section, $this->_name ); |
|
908 | + public function ensure_construct_finalized_called() { |
|
909 | + if ( ! $this->_construction_finalized) { |
|
910 | + $this->_construct_finalize($this->_parent_section, $this->_name); |
|
911 | 911 | } |
912 | 912 | } |
913 | 913 | |
@@ -919,17 +919,17 @@ discard block |
||
919 | 919 | * @param array $req_data |
920 | 920 | * @return boolean |
921 | 921 | */ |
922 | - public function form_data_present_in( $req_data = NULL ) { |
|
923 | - if( $req_data === NULL){ |
|
922 | + public function form_data_present_in($req_data = NULL) { |
|
923 | + if ($req_data === NULL) { |
|
924 | 924 | $req_data = $_POST; |
925 | 925 | } |
926 | - foreach( $this->subsections() as $subsection ) { |
|
927 | - if($subsection instanceof EE_Form_Input_Base ) { |
|
928 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
926 | + foreach ($this->subsections() as $subsection) { |
|
927 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
928 | + if ($subsection->form_data_present_in($req_data)) { |
|
929 | 929 | return TRUE; |
930 | 930 | } |
931 | - }elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
932 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
931 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
932 | + if ($subsection->form_data_present_in($req_data)) { |
|
933 | 933 | return TRUE; |
934 | 934 | } |
935 | 935 | } |
@@ -946,14 +946,14 @@ discard block |
||
946 | 946 | */ |
947 | 947 | public function get_validation_errors_accumulated() { |
948 | 948 | $validation_errors = $this->get_validation_errors(); |
949 | - foreach($this->get_validatable_subsections() as $subsection ) { |
|
950 | - if( $subsection instanceof EE_Form_Section_Proper ) { |
|
949 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
950 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
951 | 951 | $validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated(); |
952 | 952 | } else { |
953 | - $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
953 | + $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
954 | 954 | } |
955 | - if( $validation_errors_on_this_subsection ){ |
|
956 | - $validation_errors = array_merge( $validation_errors, $validation_errors_on_this_subsection ); |
|
955 | + if ($validation_errors_on_this_subsection) { |
|
956 | + $validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection); |
|
957 | 957 | } |
958 | 958 | } |
959 | 959 | return $validation_errors; |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Event Espresso |
7 | 7 | * @subpackage messages |
8 | 8 | */ |
9 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
10 | 10 | exit('NO direct script access allowed'); |
11 | 11 | |
12 | 12 | /** |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @subpackage messages |
21 | 21 | * @author Darren Ethier |
22 | 22 | */ |
23 | -class EE_Pdf_messenger extends EE_messenger { |
|
23 | +class EE_Pdf_messenger extends EE_messenger { |
|
24 | 24 | |
25 | 25 | |
26 | 26 | /** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @see abstract declaration in EE_messenger for details. |
66 | 66 | */ |
67 | 67 | protected function _set_admin_pages() { |
68 | - $this->admin_registered_pages = array( 'events_edit' => false ); |
|
68 | + $this->admin_registered_pages = array('events_edit' => false); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
@@ -85,10 +85,10 @@ discard block |
||
85 | 85 | protected function _set_validator_config() { |
86 | 86 | $this->_validator_config = array( |
87 | 87 | 'subject' => array( |
88 | - 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email','event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
88 | + 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
89 | 89 | ), |
90 | 90 | 'content' => array( |
91 | - 'shortcodes' => array( 'recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email','event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
91 | + 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
92 | 92 | ), |
93 | 93 | 'attendee_list' => array( |
94 | 94 | 'shortcodes' => array('attendee', 'event_list', 'ticket_list'), |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | 'required' => array('[EVENT_LIST]') |
100 | 100 | ), |
101 | 101 | 'ticket_list' => array( |
102 | - 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list','primary_registration_details', 'recipient_details'), |
|
102 | + 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'primary_registration_details', 'recipient_details'), |
|
103 | 103 | 'required' => array('[TICKET_LIST]') |
104 | 104 | ), |
105 | 105 | 'datetime_list' => array( |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function enqueue_scripts_styles() { |
121 | 121 | parent::enqueue_scripts_styles(); |
122 | - do_action( 'AHEE__EE_Pdf_messenger__enqueue_scripts_styles'); |
|
122 | + do_action('AHEE__EE_Pdf_messenger__enqueue_scripts_styles'); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | |
@@ -245,18 +245,18 @@ discard block |
||
245 | 245 | */ |
246 | 246 | protected function _send_message() { |
247 | 247 | $this->_template_args = array( |
248 | - 'page_title' => html_entity_decode( stripslashes( $this->_subject ), ENT_QUOTES, "UTF-8"), |
|
249 | - 'base_css' => $this->get_variation( $this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'base', $this->_variation ), |
|
250 | - 'print_css' => $this->get_variation( $this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'print', $this->_variation ), |
|
251 | - 'main_css' => $this->get_variation( $this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'main', $this->_variation ), |
|
252 | - 'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css', |
|
253 | - 'main_body' => apply_filters( 'FHEE__EE_Pdf_messenger___send_message__main_body', wpautop(stripslashes_deep( html_entity_decode($this->_content, ENT_QUOTES,"UTF-8" ) )), $this->_content ) |
|
248 | + 'page_title' => html_entity_decode(stripslashes($this->_subject), ENT_QUOTES, "UTF-8"), |
|
249 | + 'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'base', $this->_variation), |
|
250 | + 'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'print', $this->_variation), |
|
251 | + 'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'main', $this->_variation), |
|
252 | + 'extra_css' => EE_LIBRARIES_URL.'messages/defaults/default/variations/pdf_base_default.css', |
|
253 | + 'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop(stripslashes_deep(html_entity_decode($this->_content, ENT_QUOTES, "UTF-8"))), $this->_content) |
|
254 | 254 | ); |
255 | 255 | $this->_deregister_wp_hooks(); |
256 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts_styles' ) ); |
|
256 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
257 | 257 | $content = $this->_get_main_template(); |
258 | 258 | // die( $content ); |
259 | - $this->_do_pdf( $content ); |
|
259 | + $this->_do_pdf($content); |
|
260 | 260 | exit(0); |
261 | 261 | } |
262 | 262 | |
@@ -280,8 +280,8 @@ discard block |
||
280 | 280 | |
281 | 281 | //just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load. |
282 | 282 | add_action('wp_head', 'wp_enqueue_scripts'); |
283 | - add_action( 'wp_footer', 'wp_print_footer_scripts' ); |
|
284 | - add_action( 'wp_print_footer_scripts', '_wp_footer_scripts' ); |
|
283 | + add_action('wp_footer', 'wp_print_footer_scripts'); |
|
284 | + add_action('wp_print_footer_scripts', '_wp_footer_scripts'); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | |
@@ -294,11 +294,11 @@ discard block |
||
294 | 294 | * @param bool $preview |
295 | 295 | * @return string |
296 | 296 | */ |
297 | - protected function _get_main_template( $preview = FALSE ) { |
|
298 | - $wrapper_template = $this->_tmp_pack->get_wrapper( 'html', 'main' ); |
|
297 | + protected function _get_main_template($preview = FALSE) { |
|
298 | + $wrapper_template = $this->_tmp_pack->get_wrapper('html', 'main'); |
|
299 | 299 | //add message type to template_args |
300 | 300 | $this->_template_args['message_type'] = $this->_incoming_message_type; |
301 | - return EEH_Template::display_template( $wrapper_template, $this->_template_args, TRUE ); |
|
301 | + return EEH_Template::display_template($wrapper_template, $this->_template_args, TRUE); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | |
@@ -311,21 +311,21 @@ discard block |
||
311 | 311 | * |
312 | 312 | * @return void |
313 | 313 | */ |
314 | - protected function _do_pdf( $content = '' ) { |
|
315 | - $invoice_name = html_entity_decode( $this->_subject, ENT_QUOTES, "UTF-8"); |
|
314 | + protected function _do_pdf($content = '') { |
|
315 | + $invoice_name = html_entity_decode($this->_subject, ENT_QUOTES, "UTF-8"); |
|
316 | 316 | |
317 | 317 | //only load dompdf if nobody else has yet... |
318 | - if( ! defined('DOMPDF_DIR')){ |
|
318 | + if ( ! defined('DOMPDF_DIR')) { |
|
319 | 319 | define('DOMPDF_ENABLE_REMOTE', TRUE); |
320 | 320 | define('DOMPDF_ENABLE_JAVASCRIPT', FALSE); |
321 | 321 | define('DOMPDF_ENABLE_CSS_FLOAT', TRUE); |
322 | - require_once(EE_THIRD_PARTY . 'dompdf/dompdf_config.inc.php'); |
|
322 | + require_once(EE_THIRD_PARTY.'dompdf/dompdf_config.inc.php'); |
|
323 | 323 | } |
324 | 324 | $dompdf = new DOMPDF(); |
325 | 325 | $dompdf->load_html($content); |
326 | 326 | $dompdf->render(); |
327 | 327 | //forcing the browser to open a download dialog. |
328 | - $dompdf->stream($invoice_name . ".pdf", array( 'Attachment' => TRUE )); |
|
328 | + $dompdf->stream($invoice_name.".pdf", array('Attachment' => TRUE)); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 |
@@ -167,44 +167,44 @@ discard block |
||
167 | 167 | public function __construct() { |
168 | 168 | $this->_set_props(); |
169 | 169 | //make sure classname is correct |
170 | - $classname = get_class( $this ); |
|
170 | + $classname = get_class($this); |
|
171 | 171 | //make sure required props have been set |
172 | 172 | |
173 | 173 | //if label is empty then throw an error because we should have it defined by now. |
174 | - if ( ! isset( $this->label ) ) { |
|
175 | - throw new EE_Error( sprintf( __('The label property is not set for %s. Please ensure that is set for the class.', 'event_espresso' ), $classname ) ); |
|
174 | + if ( ! isset($this->label)) { |
|
175 | + throw new EE_Error(sprintf(__('The label property is not set for %s. Please ensure that is set for the class.', 'event_espresso'), $classname)); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
179 | 179 | //the reference for this template pack |
180 | - if ( ! isset( $this->dbref ) ) { |
|
181 | - throw new EE_Error( sprintf( __('The dbref property is not set for %s. Please ensure that is set for the class.', 'event_espresso' ), $classname ) ); |
|
180 | + if ( ! isset($this->dbref)) { |
|
181 | + throw new EE_Error(sprintf(__('The dbref property is not set for %s. Please ensure that is set for the class.', 'event_espresso'), $classname)); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | //make sure dbref is safe |
185 | - $this->dbref = str_replace( '-', '_', sanitize_key( $this->dbref ) ); |
|
185 | + $this->dbref = str_replace('-', '_', sanitize_key($this->dbref)); |
|
186 | 186 | |
187 | - $should_be = 'EE_Messages_Template_Pack_' . str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $this->dbref ) ) ); |
|
187 | + $should_be = 'EE_Messages_Template_Pack_'.str_replace(' ', '_', ucwords(str_replace('_', ' ', $this->dbref))); |
|
188 | 188 | |
189 | - if ( $should_be !== $classname ) { |
|
190 | - throw new EE_Error( sprintf( __('The name of the template pack instantiated class is "%s". It should be "%s". Make sure that the name of the template pack class matches is prepended with "EE_Messages_Template_Pack_" and appended with a sentence case iteration of the value for your template pack\'s dbref property.', 'event_espresso' ), $classname, $should_be ) ); |
|
189 | + if ($should_be !== $classname) { |
|
190 | + throw new EE_Error(sprintf(__('The name of the template pack instantiated class is "%s". It should be "%s". Make sure that the name of the template pack class matches is prepended with "EE_Messages_Template_Pack_" and appended with a sentence case iteration of the value for your template pack\'s dbref property.', 'event_espresso'), $classname, $should_be)); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | //if _base_path is not set then throw an error because a base path string is needed. |
194 | - if ( empty( $this->_base_path ) ) { |
|
195 | - throw new EE_Error( sprintf( __('The _base_path property is not set for %s. Please ensure that is set for the class.', 'event_espresso' ), $classname ) ); |
|
194 | + if (empty($this->_base_path)) { |
|
195 | + throw new EE_Error(sprintf(__('The _base_path property is not set for %s. Please ensure that is set for the class.', 'event_espresso'), $classname)); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | |
199 | 199 | //if _base_url is not set then throw an error because a string is needed for variations. |
200 | - if ( empty( $this->_base_url ) ) { |
|
201 | - throw new EE_Error( sprintf( __('The _base_url property is not set for %s. Please ensure that is set for the class.', 'event_espresso' ), $classname ) ); |
|
200 | + if (empty($this->_base_url)) { |
|
201 | + throw new EE_Error(sprintf(__('The _base_url property is not set for %s. Please ensure that is set for the class.', 'event_espresso'), $classname)); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
205 | 205 | //if $supports is not set then throw an error because that effectively means this template_pack does not have any templates! |
206 | - if ( empty( $this->_supports ) ) { |
|
207 | - throw new EE_Error( sprintf( __('The supports property is not set for %s. Please ensure that is set for the class.', 'event_espresso' ), $classname ) ); |
|
206 | + if (empty($this->_supports)) { |
|
207 | + throw new EE_Error(sprintf(__('The supports property is not set for %s. Please ensure that is set for the class.', 'event_espresso'), $classname)); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | |
@@ -241,8 +241,8 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @return array |
243 | 243 | */ |
244 | - public function get_templates( EE_messenger $messenger, EE_message_type $message_type ) { |
|
245 | - return isset( $this->_templates[$messenger->name][$message_type->name] ) ? $this->_templates[$messenger->name][$message_type->name] : $this->_get_templates( $messenger, $message_type ); |
|
244 | + public function get_templates(EE_messenger $messenger, EE_message_type $message_type) { |
|
245 | + return isset($this->_templates[$messenger->name][$message_type->name]) ? $this->_templates[$messenger->name][$message_type->name] : $this->_get_templates($messenger, $message_type); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * @return array Returns an multi-level associative array indexed by template context and field in the format: |
260 | 260 | * array( 'context' => array( 'field' => 'value', 'another-field', 'value' ) ); |
261 | 261 | */ |
262 | - protected function _get_templates( EE_messenger $messenger, EE_message_type $message_type ) { |
|
262 | + protected function _get_templates(EE_messenger $messenger, EE_message_type $message_type) { |
|
263 | 263 | $templates = array(); |
264 | 264 | |
265 | 265 | /** |
@@ -278,28 +278,28 @@ discard block |
||
278 | 278 | $contexts = $message_type->get_contexts(); |
279 | 279 | |
280 | 280 | |
281 | - foreach ( $contexts as $context => $details ) { |
|
282 | - foreach ( $fields as $field => $field_details ) { |
|
283 | - if ( empty( $field_details ) ) |
|
281 | + foreach ($contexts as $context => $details) { |
|
282 | + foreach ($fields as $field => $field_details) { |
|
283 | + if (empty($field_details)) |
|
284 | 284 | continue; |
285 | 285 | /** |
286 | 286 | * is this a field array (linked to a main field)? |
287 | 287 | */ |
288 | - if ( $field == 'extra' ) { |
|
289 | - foreach ( $field_details as $main_field => $sub_fields ) { |
|
290 | - foreach ( $sub_fields as $sub_field => $sub_field_details ) { |
|
288 | + if ($field == 'extra') { |
|
289 | + foreach ($field_details as $main_field => $sub_fields) { |
|
290 | + foreach ($sub_fields as $sub_field => $sub_field_details) { |
|
291 | 291 | //make sure that the template_field_ref matches what the main template field is for this template group. |
292 | 292 | $template_field_ref = $sub_field == 'main' ? $main_field : $sub_field; |
293 | - $templates[ $context ][ $main_field ][ $sub_field ] = $this->_get_specific_template( $default_pack, $messenger, $message_type, $template_field_ref, $context ); |
|
293 | + $templates[$context][$main_field][$sub_field] = $this->_get_specific_template($default_pack, $messenger, $message_type, $template_field_ref, $context); |
|
294 | 294 | } |
295 | 295 | } |
296 | 296 | } else { |
297 | - $templates[ $context ][ $field ] = $this->_get_specific_template( $default_pack, $messenger, $message_type, $field, $context ); |
|
297 | + $templates[$context][$field] = $this->_get_specific_template($default_pack, $messenger, $message_type, $field, $context); |
|
298 | 298 | } |
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
302 | - $templates = apply_filters( 'FHEE__EE_Template_Pack___get_templates__templates', $templates, $messenger, $message_type, $this ); |
|
302 | + $templates = apply_filters('FHEE__EE_Template_Pack___get_templates__templates', $templates, $messenger, $message_type, $this); |
|
303 | 303 | |
304 | 304 | $this->_templates[$messenger->name][$message_type->name] = $templates; |
305 | 305 | return $templates; |
@@ -317,22 +317,22 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @return string The template contents. |
319 | 319 | */ |
320 | - protected function _get_specific_template( $default_pack, EE_messenger $messenger, EE_message_type $message_type, $field, $context ) { |
|
320 | + protected function _get_specific_template($default_pack, EE_messenger $messenger, EE_message_type $message_type, $field, $context) { |
|
321 | 321 | |
322 | 322 | //default templates |
323 | - $default_templates = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_templates( $messenger, $message_type ) : array(); |
|
323 | + $default_templates = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_templates($messenger, $message_type) : array(); |
|
324 | 324 | |
325 | 325 | //first we allow for the $_base_path to be filtered. However, we assign this to a new variable so that we have the original base_path as a fallback. |
326 | - $filtered_base_path = apply_filters( 'FHEE__EE_Template_Pack___get_specific_template__filtered_base_path', $this->_base_path, $messenger, $message_type, $field, $context, $this ); |
|
326 | + $filtered_base_path = apply_filters('FHEE__EE_Template_Pack___get_specific_template__filtered_base_path', $this->_base_path, $messenger, $message_type, $field, $context, $this); |
|
327 | 327 | |
328 | 328 | $master_templates = $message_type->get_master_templates(); |
329 | - $master_templates_mt = isset( $master_templates[$messenger->name] ) ? $master_templates[$messenger->name] : $message_type->name; |
|
330 | - $full_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '_' . $context . '.template.php'; |
|
331 | - $fallback_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '.template.php'; |
|
332 | - $mt_defined_full_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php'; |
|
333 | - $mt_defined_fallback_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php'; |
|
334 | - $base_defined_full_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php'; |
|
335 | - $base_defined_fallback_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php'; |
|
329 | + $master_templates_mt = isset($master_templates[$messenger->name]) ? $master_templates[$messenger->name] : $message_type->name; |
|
330 | + $full_path = $filtered_base_path.$messenger->name.'_'.$message_type->name.'_'.$field.'_'.$context.'.template.php'; |
|
331 | + $fallback_path = $filtered_base_path.$messenger->name.'_'.$message_type->name.'_'.$field.'.template.php'; |
|
332 | + $mt_defined_full_path = $filtered_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'_'.$context.'.template.php'; |
|
333 | + $mt_defined_fallback_path = $filtered_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'.template.php'; |
|
334 | + $base_defined_full_path = $this->_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'_'.$context.'.template.php'; |
|
335 | + $base_defined_fallback_path = $this->_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'.template.php'; |
|
336 | 336 | |
337 | 337 | /** |
338 | 338 | * Template checks are done hierarchically in the following order: |
@@ -346,28 +346,28 @@ discard block |
||
346 | 346 | */ |
347 | 347 | |
348 | 348 | |
349 | - if ( is_readable( $full_path ) ) { |
|
349 | + if (is_readable($full_path)) { |
|
350 | 350 | $actual_path = $full_path; |
351 | - } elseif ( is_readable( $fallback_path ) ) { |
|
351 | + } elseif (is_readable($fallback_path)) { |
|
352 | 352 | $actual_path = $fallback_path; |
353 | - } elseif ( is_readable( $mt_defined_full_path ) ) { |
|
353 | + } elseif (is_readable($mt_defined_full_path)) { |
|
354 | 354 | $actual_path = $mt_defined_full_path; |
355 | - } elseif ( is_readable( $mt_defined_fallback_path ) ) { |
|
355 | + } elseif (is_readable($mt_defined_fallback_path)) { |
|
356 | 356 | $actual_path = $mt_defined_fallback_path; |
357 | - } elseif ( is_readable( $base_defined_full_path ) ) { |
|
357 | + } elseif (is_readable($base_defined_full_path)) { |
|
358 | 358 | $actual_path = $base_defined_full_path; |
359 | - } elseif ( is_readable( $base_defined_fallback_path ) ) { |
|
359 | + } elseif (is_readable($base_defined_fallback_path)) { |
|
360 | 360 | $actual_path = $base_defined_fallback_path; |
361 | - } else { |
|
361 | + } else { |
|
362 | 362 | $actual_path = ''; |
363 | 363 | } |
364 | - if ( empty( $actual_path ) ) { |
|
365 | - $contents = isset( $default_templates[$context][$field] ) ? $default_templates[$context][$field] : ''; |
|
364 | + if (empty($actual_path)) { |
|
365 | + $contents = isset($default_templates[$context][$field]) ? $default_templates[$context][$field] : ''; |
|
366 | 366 | } else { |
367 | - $contents = EEH_Template::display_template( $actual_path, array(), TRUE ); |
|
367 | + $contents = EEH_Template::display_template($actual_path, array(), TRUE); |
|
368 | 368 | } |
369 | 369 | |
370 | - return apply_filters( 'FHEE__EE_Messages_Template_Pack__get_specific_template__contents', $contents, $actual_path, $messenger, $message_type, $field, $context, $this ); |
|
370 | + return apply_filters('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', $contents, $actual_path, $messenger, $message_type, $field, $context, $this); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | * @return array |
383 | 383 | */ |
384 | 384 | public function get_supports() { |
385 | - $supports = apply_filters( 'FHEE__' . get_class( $this ) . '__get_supports', $this->_supports ); |
|
386 | - return apply_filters( 'FHEE__EE_Messages_Template_Pack__get_supports', $supports, $this ); |
|
385 | + $supports = apply_filters('FHEE__'.get_class($this).'__get_supports', $this->_supports); |
|
386 | + return apply_filters('FHEE__EE_Messages_Template_Pack__get_supports', $supports, $this); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | |
@@ -398,11 +398,11 @@ discard block |
||
398 | 398 | * |
399 | 399 | * @return array|string |
400 | 400 | */ |
401 | - public function get_default_variation_labels( $messenger = '' ) { |
|
402 | - $label = empty( $messenger ) ? $this->_default_variation_labels : array(); |
|
403 | - $label = empty( $label ) && ! empty( $this->_default_variation_labels[$messenger] ) ? $this->_default_variation_labels[$messenger] : __('Default', 'event_espresso'); |
|
401 | + public function get_default_variation_labels($messenger = '') { |
|
402 | + $label = empty($messenger) ? $this->_default_variation_labels : array(); |
|
403 | + $label = empty($label) && ! empty($this->_default_variation_labels[$messenger]) ? $this->_default_variation_labels[$messenger] : __('Default', 'event_espresso'); |
|
404 | 404 | |
405 | - return apply_filters( 'FHEE__EE_Messages_Template_Pack__get_default_variation_labels', $label, $this->_default_variation_labels, $messenger ); |
|
405 | + return apply_filters('FHEE__EE_Messages_Template_Pack__get_default_variation_labels', $label, $this->_default_variation_labels, $messenger); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | |
@@ -418,25 +418,25 @@ discard block |
||
418 | 418 | * @param string $message_type if included then css variations matching the message_type are returned (must have $messenger set). Otherwise the array of variations per message type are returned. If message_type is provided but NOT the messenger, then just all variations for all messengers are returned. |
419 | 419 | * @return array |
420 | 420 | */ |
421 | - public function get_variations( $messenger = '', $message_type = '' ) { |
|
422 | - $messenger_variations = ! empty( $messenger ) && isset( $this->_variations[$messenger] ) ? $this->_variations[$messenger] : array(); |
|
421 | + public function get_variations($messenger = '', $message_type = '') { |
|
422 | + $messenger_variations = ! empty($messenger) && isset($this->_variations[$messenger]) ? $this->_variations[$messenger] : array(); |
|
423 | 423 | |
424 | 424 | //message_type provided? IF so, then we've requested a specific set of variations, so we need to make sure we set it as empty if that's not present. |
425 | - $variations = !empty( $messenger ) && !empty( $message_type ) && isset( $messenger_variations[$message_type] ) ? $messenger_variations[$message_type] : array(); |
|
425 | + $variations = ! empty($messenger) && ! empty($message_type) && isset($messenger_variations[$message_type]) ? $messenger_variations[$message_type] : array(); |
|
426 | 426 | |
427 | 427 | //now let's account for the possibility we just want all the variations for a messenger (which is indicated by providing the messenger but not the message type). |
428 | - $variations = empty( $variations ) && !empty( $messenger ) && empty( $message_type ) ? $messenger_variations : $variations; |
|
428 | + $variations = empty($variations) && ! empty($messenger) && empty($message_type) ? $messenger_variations : $variations; |
|
429 | 429 | |
430 | 430 | //filter per template pack and globally. |
431 | - $variations = apply_filters( 'FHEE__' . get_class( $this ) . '__get_variations', $variations, $messenger, $message_type ); |
|
432 | - $variations = apply_filters( 'FHEE__EE_Messages_Template_Pack__get_variations', $variations, $messenger, $message_type, $this ); |
|
431 | + $variations = apply_filters('FHEE__'.get_class($this).'__get_variations', $variations, $messenger, $message_type); |
|
432 | + $variations = apply_filters('FHEE__EE_Messages_Template_Pack__get_variations', $variations, $messenger, $message_type, $this); |
|
433 | 433 | |
434 | 434 | //prepend the _default_variation, but ONLY if we're returning the fully validated array. |
435 | - if ( !empty( $messenger ) && !empty( $message_type ) && ! empty( $variations ) ) { |
|
436 | - $variations = array( 'default' => $this->get_default_variation_labels( $messenger ) ) + $variations; |
|
435 | + if ( ! empty($messenger) && ! empty($message_type) && ! empty($variations)) { |
|
436 | + $variations = array('default' => $this->get_default_variation_labels($messenger)) + $variations; |
|
437 | 437 | } |
438 | 438 | |
439 | - return empty( $variations ) ? array( 'default' => $this->get_default_variation_labels('dft') ): $variations; |
|
439 | + return empty($variations) ? array('default' => $this->get_default_variation_labels('dft')) : $variations; |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | |
@@ -457,39 +457,39 @@ discard block |
||
457 | 457 | * |
458 | 458 | * @return string The variation path or url (typically css reference) |
459 | 459 | */ |
460 | - public function get_variation( $messenger, $message_type, $type, $variation, $url = true, $file_extension = '.css', $skip_filters = FALSE ) { |
|
460 | + public function get_variation($messenger, $message_type, $type, $variation, $url = true, $file_extension = '.css', $skip_filters = FALSE) { |
|
461 | 461 | |
462 | 462 | $base = $url ? $this->_base_url : $this->_base_path; |
463 | 463 | $base_path = $this->_base_path; |
464 | 464 | |
465 | - if ( ! $skip_filters ) { |
|
466 | - $base = apply_filters( 'FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', $base, $messenger, $message_type, $type, $variation, $url, $file_extension, $this ); |
|
467 | - $base_path = apply_filters( 'FHEE__EE_Messages_Template_Pack__get_variation__base_path', $base_path, $messenger, $message_type, $type, $variation, FALSE, $file_extension, $this ); |
|
465 | + if ( ! $skip_filters) { |
|
466 | + $base = apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', $base, $messenger, $message_type, $type, $variation, $url, $file_extension, $this); |
|
467 | + $base_path = apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path', $base_path, $messenger, $message_type, $type, $variation, FALSE, $file_extension, $this); |
|
468 | 468 | } |
469 | 469 | |
470 | - $default_pack = get_class( $this ) != 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : $this; |
|
470 | + $default_pack = get_class($this) != 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : $this; |
|
471 | 471 | |
472 | 472 | //possible variation paths considering whether message type is present or not in the file name. |
473 | - $path_string = 'variations/' . $messenger . '_' . $message_type . '_' . $type . '_' . $variation . $file_extension; |
|
474 | - $default_path_string = 'variations/' . $messenger . '_' . $type . '_' . $variation . $file_extension; |
|
473 | + $path_string = 'variations/'.$messenger.'_'.$message_type.'_'.$type.'_'.$variation.$file_extension; |
|
474 | + $default_path_string = 'variations/'.$messenger.'_'.$type.'_'.$variation.$file_extension; |
|
475 | 475 | |
476 | 476 | //first see if fully validated file exists. |
477 | - if ( is_readable( $base_path . $path_string ) ) { |
|
478 | - $variation_path = $base . $path_string; |
|
477 | + if (is_readable($base_path.$path_string)) { |
|
478 | + $variation_path = $base.$path_string; |
|
479 | 479 | //otherwise see if default exists. |
480 | - } elseif ( is_readable( $base_path . $default_path_string ) ) { |
|
481 | - $variation_path = $base . $default_path_string; |
|
480 | + } elseif (is_readable($base_path.$default_path_string)) { |
|
481 | + $variation_path = $base.$default_path_string; |
|
482 | 482 | } else { |
483 | - $variation_path = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_default_variation( $messenger, $message_type, $type, $url, $file_extension ) : ''; |
|
483 | + $variation_path = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_default_variation($messenger, $message_type, $type, $url, $file_extension) : ''; |
|
484 | 484 | } |
485 | 485 | |
486 | - if ( $skip_filters ) { |
|
486 | + if ($skip_filters) { |
|
487 | 487 | return $variation_path; |
488 | 488 | } |
489 | 489 | |
490 | 490 | //filter result |
491 | - $variation_path = apply_filters( 'FHEE__' . get_class( $this ) . '__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url ); |
|
492 | - return apply_filters( 'FHEE__EE_Messages_Template_Pack__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, $this ); |
|
491 | + $variation_path = apply_filters('FHEE__'.get_class($this).'__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url); |
|
492 | + return apply_filters('FHEE__EE_Messages_Template_Pack__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, $this); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | |
@@ -504,19 +504,19 @@ discard block |
||
504 | 504 | * |
505 | 505 | * @return string returns the path for the requested wrapper template. |
506 | 506 | */ |
507 | - public function get_wrapper( $messenger, $type = 'main' ) { |
|
508 | - $default_pack = get_class( $this ) !== 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : NULL; |
|
507 | + public function get_wrapper($messenger, $type = 'main') { |
|
508 | + $default_pack = get_class($this) !== 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : NULL; |
|
509 | 509 | |
510 | - $path_string = $this->_base_path . $messenger . '_' . $type . '_wrapper.template.php'; |
|
510 | + $path_string = $this->_base_path.$messenger.'_'.$type.'_wrapper.template.php'; |
|
511 | 511 | |
512 | - if ( is_readable( $path_string ) ) { |
|
512 | + if (is_readable($path_string)) { |
|
513 | 513 | $template = $path_string; |
514 | 514 | } else { |
515 | - $template = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_wrapper( $messenger, $type ) : ''; |
|
515 | + $template = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_wrapper($messenger, $type) : ''; |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | //filter |
519 | - $template = apply_filters( 'FHEE__' . get_class( $this ) . '__get_wrapper', $template, $messenger, $type ); |
|
520 | - return apply_filters( 'FHEE__EE_Messages_Template_Pack__get_wrapper', $template, $messenger, $type, $this ); |
|
519 | + $template = apply_filters('FHEE__'.get_class($this).'__get_wrapper', $template, $messenger, $type); |
|
520 | + return apply_filters('FHEE__EE_Messages_Template_Pack__get_wrapper', $template, $messenger, $type, $this); |
|
521 | 521 | } |
522 | 522 | } |
@@ -1,5 +1,5 @@ discard block |
||
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 | /** |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * @param bool $preview indicate whether a preview is being generated or not. |
272 | 272 | * @return void |
273 | 273 | */ |
274 | - public function set_messages($data, EE_messenger $active_messenger, $context = '', $preview = FALSE ) { |
|
274 | + public function set_messages($data, EE_messenger $active_messenger, $context = '', $preview = FALSE) { |
|
275 | 275 | |
276 | 276 | $this->_active_messenger = $active_messenger; |
277 | 277 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | |
281 | 281 | //this is a special method that allows child message types to trigger an exit from generating messages early (in cases where there may be a delay on send). |
282 | 282 | $exit = $this->_trigger_exit(); |
283 | - if ( $exit && ! $this->_preview ) return FALSE; |
|
283 | + if ($exit && ! $this->_preview) return FALSE; |
|
284 | 284 | |
285 | 285 | //todo: need to move require into registration hook but for now we'll require here. |
286 | 286 | //get shortcode_replace instance- set when _get_messages is called in child... |
@@ -293,9 +293,9 @@ discard block |
||
293 | 293 | $this->_data_handler = ! $this->_preview ? $this->_data_handler : 'Preview'; |
294 | 294 | |
295 | 295 | //if there is an incoming context then this is a preview so let's ONLY show the given context! |
296 | - if ( !empty( $context ) ) { |
|
297 | - $cntxt = ! empty( $this->_contexts[$context] ) ? $this->_contexts[$context] : ''; |
|
298 | - if ( ! empty( $cntxt ) ) { |
|
296 | + if ( ! empty($context)) { |
|
297 | + $cntxt = ! empty($this->_contexts[$context]) ? $this->_contexts[$context] : ''; |
|
298 | + if ( ! empty($cntxt)) { |
|
299 | 299 | $this->_contexts = array(); |
300 | 300 | $this->_contexts[$context] = $cntxt; |
301 | 301 | } |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | $exit = $this->_init_data(); |
305 | 305 | |
306 | 306 | //final check for if we exit or not cause child objects may have run conditionals that cleared out data so no addresees generated. |
307 | - if ( $exit ) return FALSE; |
|
307 | + if ($exit) return FALSE; |
|
308 | 308 | |
309 | 309 | $this->_get_templates(); //get the templates that have been set with this type and for the given messenger that have been saved in the database. |
310 | 310 | $this->_assemble_messages(); |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | * @param int $id Optional. Integer corresponding to the value for the primary key of a EE_Base_Class_Object |
341 | 341 | * @return mixed ( EE_Base_Class||EE_Base_Class[] ) |
342 | 342 | */ |
343 | - abstract protected function _get_data_for_context( $context, EE_Registration $registration, $id ); |
|
343 | + abstract protected function _get_data_for_context($context, EE_Registration $registration, $id); |
|
344 | 344 | |
345 | 345 | |
346 | 346 | |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @return int |
374 | 374 | */ |
375 | - protected function _get_id_for_msg_url( $context, EE_Registration $registration ) { |
|
375 | + protected function _get_id_for_msg_url($context, EE_Registration $registration) { |
|
376 | 376 | return 0; |
377 | 377 | } |
378 | 378 | |
@@ -405,27 +405,27 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @return string generated url |
407 | 407 | */ |
408 | - public function get_url_trigger( $context, $sending_messenger, EE_Registration $registration ) { |
|
408 | + public function get_url_trigger($context, $sending_messenger, EE_Registration $registration) { |
|
409 | 409 | |
410 | 410 | //validate context |
411 | 411 | //valid context? |
412 | - if ( !isset( $this->_contexts[$context] ) ) { |
|
413 | - throw new EE_Error( sprintf( __('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class( $this ) ) ); |
|
412 | + if ( ! isset($this->_contexts[$context])) { |
|
413 | + throw new EE_Error(sprintf(__('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class($this))); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | //valid sending_messenger? |
417 | 417 | $not_valid_msgr = FALSE; |
418 | - foreach ( $this->_with_messengers as $generating => $sendings ) { |
|
419 | - if ( empty( $sendings ) || array_search( $sending_messenger, $sendings ) === FALSE ) { |
|
418 | + foreach ($this->_with_messengers as $generating => $sendings) { |
|
419 | + if (empty($sendings) || array_search($sending_messenger, $sendings) === FALSE) { |
|
420 | 420 | $not_valid_msgr = TRUE; |
421 | 421 | } |
422 | 422 | } |
423 | 423 | |
424 | - if ( $not_valid_msgr ) { |
|
425 | - throw new EE_Error( sprintf( __('The given sending messenger string (%s) does not match a valid sending messenger with the %s. If this is incorrect, make sure that the message type has defined this messenger as a sending messenger in its $_with_messengers array.', 'event_espresso'), $sending_messenger, get_class( $this ) ) ); |
|
424 | + if ($not_valid_msgr) { |
|
425 | + throw new EE_Error(sprintf(__('The given sending messenger string (%s) does not match a valid sending messenger with the %s. If this is incorrect, make sure that the message type has defined this messenger as a sending messenger in its $_with_messengers array.', 'event_espresso'), $sending_messenger, get_class($this))); |
|
426 | 426 | } |
427 | 427 | |
428 | - return EEH_MSG_Template::generate_url_trigger( $sending_messenger, $this->_active_messenger->name, $context, $this->name, $registration, $this->_GRP_ID, $this->_get_id_for_msg_url( $context, $registration ) ); |
|
428 | + return EEH_MSG_Template::generate_url_trigger($sending_messenger, $this->_active_messenger->name, $context, $this->name, $registration, $this->_GRP_ID, $this->_get_id_for_msg_url($context, $registration)); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | |
@@ -446,19 +446,19 @@ discard block |
||
446 | 446 | * |
447 | 447 | * @return mixed (EE_Base_Class||EE_Base_Class[]) |
448 | 448 | */ |
449 | - public function get_data_for_context( $context, EE_Registration $registration, $id = 0 ) { |
|
449 | + public function get_data_for_context($context, EE_Registration $registration, $id = 0) { |
|
450 | 450 | //valid context? |
451 | - if ( !isset( $this->_contexts[$context] ) ) { |
|
452 | - throw new EE_Error( sprintf( __('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class( $this ) ) ); |
|
451 | + if ( ! isset($this->_contexts[$context])) { |
|
452 | + throw new EE_Error(sprintf(__('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class($this))); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | //get data and apply global and class specific filters on it. |
456 | - $data = apply_filters( 'FHEE__EE_message_type__get_data_for_context__data', $this->_get_data_for_context( $context, $registration, $id ), $this ); |
|
457 | - $data = apply_filters( 'FHEE__' . get_class( $this ) . '__get_data_for_context__data', $data, $this ); |
|
456 | + $data = apply_filters('FHEE__EE_message_type__get_data_for_context__data', $this->_get_data_for_context($context, $registration, $id), $this); |
|
457 | + $data = apply_filters('FHEE__'.get_class($this).'__get_data_for_context__data', $data, $this); |
|
458 | 458 | |
459 | 459 | //if empty then something went wrong! |
460 | - if ( empty( $data ) ) { |
|
461 | - throw new EE_Error( sprintf( __('There is no data retrieved, it is possible that the id given (%d) does not match any value in the database for the corresponding EE_Base_Class used by the data handler for the %s message type.', 'event_espresso'), $id, $this->name ) ); |
|
460 | + if (empty($data)) { |
|
461 | + throw new EE_Error(sprintf(__('There is no data retrieved, it is possible that the id given (%d) does not match any value in the database for the corresponding EE_Base_Class used by the data handler for the %s message type.', 'event_espresso'), $id, $this->name)); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | return $data; |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | */ |
494 | 494 | public function with_messengers() { |
495 | 495 | |
496 | - return apply_filters( 'FHEE__EE_message_type__get_with_messengers__with_messengers__' . get_class( $this ), $this->_with_messengers); |
|
496 | + return apply_filters('FHEE__EE_message_type__get_with_messengers__with_messengers__'.get_class($this), $this->_with_messengers); |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | |
@@ -511,9 +511,9 @@ discard block |
||
511 | 511 | * @access public |
512 | 512 | * @return void |
513 | 513 | */ |
514 | - public function get_message_type_admin_page_content($page, $action = NULL, $extra = array(), $messengers = array() ) { |
|
514 | + public function get_message_type_admin_page_content($page, $action = NULL, $extra = array(), $messengers = array()) { |
|
515 | 515 | //we can also further refine the context by action (if present). |
516 | - return $this->_get_admin_page_content( $page, $action, $extra, $messengers ); |
|
516 | + return $this->_get_admin_page_content($page, $action, $extra, $messengers); |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | |
@@ -557,8 +557,8 @@ discard block |
||
557 | 557 | */ |
558 | 558 | public function get_master_templates() { |
559 | 559 | //first class specific filter then filter that by the global filter. |
560 | - $master_templates = apply_filters( 'FHEE__' . get_class( $this ) . '__get_master_templates', $this->_master_templates ); |
|
561 | - return apply_filters( 'FHEE__EE_message_type__get_master_templates', $master_templates, $this ); |
|
560 | + $master_templates = apply_filters('FHEE__'.get_class($this).'__get_master_templates', $this->_master_templates); |
|
561 | + return apply_filters('FHEE__EE_message_type__get_master_templates', $master_templates, $this); |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | |
@@ -577,31 +577,31 @@ discard block |
||
577 | 577 | /** |
578 | 578 | * first let's make sure that incoming data isn't empty! |
579 | 579 | */ |
580 | - if ( is_array($this->_data) && empty($this->_data) && !$this->_preview ) { |
|
581 | - $msg = sprintf( __( '"%s" message type incoming data is empty. There is nothing to work with so why are you bugging me?', 'event_espresso'), $this->label['singular'] ); |
|
582 | - throw new EE_Error( $msg ); |
|
580 | + if (is_array($this->_data) && empty($this->_data) && ! $this->_preview) { |
|
581 | + $msg = sprintf(__('"%s" message type incoming data is empty. There is nothing to work with so why are you bugging me?', 'event_espresso'), $this->label['singular']); |
|
582 | + throw new EE_Error($msg); |
|
583 | 583 | } |
584 | 584 | |
585 | - if ( empty( $this->_data_handler) ) { |
|
586 | - $msg = sprintf( __('Hey %s hasn\'t declared a handler for the incoming data, so I\'m stuck', 'event_espresso'), __CLASS__ ); |
|
587 | - throw new EE_Error( $msg ); |
|
585 | + if (empty($this->_data_handler)) { |
|
586 | + $msg = sprintf(__('Hey %s hasn\'t declared a handler for the incoming data, so I\'m stuck', 'event_espresso'), __CLASS__); |
|
587 | + throw new EE_Error($msg); |
|
588 | 588 | } |
589 | 589 | |
590 | 590 | |
591 | 591 | //setup class name for the data handler |
592 | - $classname = 'EE_Messages_' . $this->_data_handler . '_incoming_data'; |
|
592 | + $classname = 'EE_Messages_'.$this->_data_handler.'_incoming_data'; |
|
593 | 593 | |
594 | 594 | //check that the class exists |
595 | - if ( !class_exists( $classname ) ) { |
|
595 | + if ( ! class_exists($classname)) { |
|
596 | 596 | |
597 | 597 | $msg[] = __('uhoh, Something went wrong and no data handler is found', 'event_espresso'); |
598 | - $msg[] = sprintf( __('The %s class has set the "$_data_handler" property but the string included (%s) does not match any existing "EE_Messages_incoming_data" classes (found in "/includes/core/messages/data_class"). Looking for %s.', 'event_espresso'), __CLASS__, $this->_data_handler, $classname ); |
|
599 | - throw new EE_error( implode('||', $msg) ); |
|
598 | + $msg[] = sprintf(__('The %s class has set the "$_data_handler" property but the string included (%s) does not match any existing "EE_Messages_incoming_data" classes (found in "/includes/core/messages/data_class"). Looking for %s.', 'event_espresso'), __CLASS__, $this->_data_handler, $classname); |
|
599 | + throw new EE_error(implode('||', $msg)); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | //k lets get the prepared data object and replace existing data property with it. |
603 | - $a = new ReflectionClass( $classname ); |
|
604 | - $this->_data = $a->newInstance( $this->_data ); |
|
603 | + $a = new ReflectionClass($classname); |
|
604 | + $this->_data = $a->newInstance($this->_data); |
|
605 | 605 | |
606 | 606 | $this->_set_default_addressee_data(); |
607 | 607 | return $this->_process_data(); |
@@ -617,15 +617,15 @@ discard block |
||
617 | 617 | protected function _process_data() { |
618 | 618 | //at a minimum, we NEED EE_Attendee objects. |
619 | 619 | |
620 | - if ( empty( $this->_data->attendees ) ) |
|
621 | - return TRUE; //EXIT! |
|
620 | + if (empty($this->_data->attendees)) |
|
621 | + return TRUE; //EXIT! |
|
622 | 622 | |
623 | 623 | //process addressees for each context. Child classes will have to have methods for each context defined to handle the processing of the data object within them |
624 | - foreach ( $this->_contexts as $context => $details ) { |
|
625 | - $xpctd_method = '_' . $context . '_addressees'; |
|
626 | - if ( !method_exists( $this, $xpctd_method ) ) |
|
627 | - throw new EE_Error( sprintf( __('The data for %1$s message type cannot be prepared because there is no set method for doing so. The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present', 'event_espresso'), $this->label['singular'], $xpctd_method) ); |
|
628 | - $this->_addressees[$context] = call_user_func( array( $this, $xpctd_method ) ); |
|
624 | + foreach ($this->_contexts as $context => $details) { |
|
625 | + $xpctd_method = '_'.$context.'_addressees'; |
|
626 | + if ( ! method_exists($this, $xpctd_method)) |
|
627 | + throw new EE_Error(sprintf(__('The data for %1$s message type cannot be prepared because there is no set method for doing so. The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present', 'event_espresso'), $this->label['singular'], $xpctd_method)); |
|
628 | + $this->_addressees[$context] = call_user_func(array($this, $xpctd_method)); |
|
629 | 629 | } |
630 | 630 | return FALSE; //DON'T EXIT |
631 | 631 | } |
@@ -660,8 +660,8 @@ discard block |
||
660 | 660 | 'total_ticket_count' => $this->_data->total_ticket_count |
661 | 661 | ); |
662 | 662 | |
663 | - if ( is_array( $this->_data->primary_attendee_data ) ) { |
|
664 | - $this->_default_addressee_data = array_merge( $this->_default_addressee_data, $this->_data->primary_attendee_data ); |
|
663 | + if (is_array($this->_data->primary_attendee_data)) { |
|
664 | + $this->_default_addressee_data = array_merge($this->_default_addressee_data, $this->_data->primary_attendee_data); |
|
665 | 665 | $this->_default_addressee_data['primary_att_obj'] = $this->_data->primary_attendee_data['att_obj']; |
666 | 666 | $this->_default_addressee_data['primary_reg_obj'] = $this->_data->primary_attendee_data['reg_obj']; |
667 | 667 | } |
@@ -679,26 +679,26 @@ discard block |
||
679 | 679 | * see abstract declaration in parent class for details, children message types can override these valid shortcodes if desired (we include all for all contexts by default). |
680 | 680 | */ |
681 | 681 | protected function _set_valid_shortcodes() { |
682 | - $all_shortcodes = array( 'attendee_list', 'attendee', 'datetime_list', 'datetime', 'event_list', 'event_meta', 'event', 'organization', 'recipient_details', 'recipient_list', 'ticket_list', 'ticket', 'transaction', 'venue', 'primary_registration_details', 'primary_registration_list', 'event_author', 'email', 'messenger' ); |
|
682 | + $all_shortcodes = array('attendee_list', 'attendee', 'datetime_list', 'datetime', 'event_list', 'event_meta', 'event', 'organization', 'recipient_details', 'recipient_list', 'ticket_list', 'ticket', 'transaction', 'venue', 'primary_registration_details', 'primary_registration_list', 'event_author', 'email', 'messenger'); |
|
683 | 683 | $contexts = $this->get_contexts(); |
684 | - foreach ( $contexts as $context => $details ) { |
|
684 | + foreach ($contexts as $context => $details) { |
|
685 | 685 | $this->_valid_shortcodes[$context] = $all_shortcodes; |
686 | 686 | |
687 | 687 | //make sure non admin context does not include the event_author shortcodes |
688 | - if ( $context != 'admin' ) { |
|
689 | - if( ($key = array_search('event_author', $this->_valid_shortcodes[$context] ) ) !== false) { |
|
688 | + if ($context != 'admin') { |
|
689 | + if (($key = array_search('event_author', $this->_valid_shortcodes[$context])) !== false) { |
|
690 | 690 | unset($this->_valid_shortcodes[$context][$key]); |
691 | 691 | } |
692 | 692 | } |
693 | 693 | } |
694 | 694 | |
695 | 695 | //make sure admin context does not include the recipient_details shortcodes IF we have admin context hooked in message types might not have that context. |
696 | - if ( !empty( $this->_valid_shortcodes['admin'] ) ) { |
|
697 | - if( ($key = array_search('recipient_details', $this->_valid_shortcodes['admin'] ) ) !== false) { |
|
696 | + if ( ! empty($this->_valid_shortcodes['admin'])) { |
|
697 | + if (($key = array_search('recipient_details', $this->_valid_shortcodes['admin'])) !== false) { |
|
698 | 698 | unset($this->_valid_shortcodes['admin'][$key]); |
699 | 699 | } |
700 | 700 | //make sure admin context does not include the recipient_details shortcodes |
701 | - if( ($key = array_search('recipient_list', $this->_valid_shortcodes['admin'] ) ) !== false) { |
|
701 | + if (($key = array_search('recipient_list', $this->_valid_shortcodes['admin'])) !== false) { |
|
702 | 702 | unset($this->_valid_shortcodes['admin'][$key]); |
703 | 703 | } |
704 | 704 | } |
@@ -711,8 +711,8 @@ discard block |
||
711 | 711 | * @param array $new_config array of valid shortcodes (by context) |
712 | 712 | * @return void sets valid_shortcodes property |
713 | 713 | */ |
714 | - public function reset_valid_shortcodes_config( $new_config ) { |
|
715 | - foreach ( $new_config as $context => $shortcodes ) { |
|
714 | + public function reset_valid_shortcodes_config($new_config) { |
|
715 | + foreach ($new_config as $context => $shortcodes) { |
|
716 | 716 | $this->_valid_shortcodes[$context] = $shortcodes; |
717 | 717 | } |
718 | 718 | } |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | $addressees = array(); |
733 | 733 | |
734 | 734 | //first we need to get the event admin user id for all the events and setup an addressee object for each unique admin user. |
735 | - foreach ( $this->_data->events as $line_ref => $event ) { |
|
735 | + foreach ($this->_data->events as $line_ref => $event) { |
|
736 | 736 | $admin_id = $this->_get_event_admin_id($event['ID']); |
737 | 737 | //get the user_id for the event |
738 | 738 | $admin_ids[] = $admin_id; |
@@ -744,14 +744,14 @@ discard block |
||
744 | 744 | $admin_ids = array_unique($admin_ids); |
745 | 745 | |
746 | 746 | //k now we can loop through the event_admins and setup the addressee data. |
747 | - foreach ( $admin_ids as $event_admin ) { |
|
747 | + foreach ($admin_ids as $event_admin) { |
|
748 | 748 | $aee = array( |
749 | 749 | 'user_id' => $event_admin, |
750 | 750 | 'events' => $admin_events[$event_admin], |
751 | 751 | 'attendees' => $this->_data->attendees |
752 | 752 | ); |
753 | - $aee = array_merge( $this->_default_addressee_data, $aee ); |
|
754 | - $addressees[] = new EE_Messages_Addressee( $aee ); |
|
753 | + $aee = array_merge($this->_default_addressee_data, $aee); |
|
754 | + $addressees[] = new EE_Messages_Addressee($aee); |
|
755 | 755 | } |
756 | 756 | |
757 | 757 | return $addressees; |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | $aee['attendees'] = $this->_data->attendees; |
772 | 772 | |
773 | 773 | //great now we can instantiate the $addressee object and return (as an array); |
774 | - $add[] = new EE_Messages_Addressee( $aee ); |
|
774 | + $add[] = new EE_Messages_Addressee($aee); |
|
775 | 775 | return $add; |
776 | 776 | } |
777 | 777 | |
@@ -790,38 +790,38 @@ discard block |
||
790 | 790 | //use to verify unique attendee emails... we don't want to sent multiple copies to the same attendee do we? |
791 | 791 | $already_processed = array(); |
792 | 792 | |
793 | - foreach ( $this->_data->attendees as $att_id => $details ) { |
|
793 | + foreach ($this->_data->attendees as $att_id => $details) { |
|
794 | 794 | //set the attendee array to blank on each loop; |
795 | 795 | $aee = array(); |
796 | 796 | |
797 | - if ( isset( $this->_data->reg_obj ) && ( $this->_data->reg_obj->attendee_ID() != $att_id ) && $this->_single_message ) continue; |
|
797 | + if (isset($this->_data->reg_obj) && ($this->_data->reg_obj->attendee_ID() != $att_id) && $this->_single_message) continue; |
|
798 | 798 | |
799 | 799 | //is $this->_regs_for_sending present? If so, let's make sure we ONLY generate addressee for registrations in that array. |
800 | - if ( ! empty( $this->_regs_for_sending ) && is_array( $this->_regs_for_sending ) ) { |
|
801 | - $regs_allowed = array_intersect_key( array_flip( $this->_regs_for_sending ), $details['reg_objs'] ); |
|
802 | - if ( empty( $regs_allowed ) ) { |
|
800 | + if ( ! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) { |
|
801 | + $regs_allowed = array_intersect_key(array_flip($this->_regs_for_sending), $details['reg_objs']); |
|
802 | + if (empty($regs_allowed)) { |
|
803 | 803 | continue; |
804 | 804 | } |
805 | 805 | } |
806 | 806 | |
807 | 807 | if ( |
808 | - in_array( $details['attendee_email'], $already_processed ) |
|
809 | - && apply_filters( 'FHEE__EE_message_type___attendee_addressees__prevent_duplicate_email_sends', true, $this->_data, $this ) |
|
808 | + in_array($details['attendee_email'], $already_processed) |
|
809 | + && apply_filters('FHEE__EE_message_type___attendee_addressees__prevent_duplicate_email_sends', true, $this->_data, $this) |
|
810 | 810 | ) { |
811 | 811 | continue; |
812 | 812 | } |
813 | 813 | |
814 | 814 | $already_processed[] = $details['attendee_email']; |
815 | 815 | |
816 | - foreach ( $details as $item => $value ) { |
|
816 | + foreach ($details as $item => $value) { |
|
817 | 817 | $aee[$item] = $value; |
818 | - if ( $item == 'line_ref' ) { |
|
819 | - foreach ( $value as $event_id ) { |
|
818 | + if ($item == 'line_ref') { |
|
819 | + foreach ($value as $event_id) { |
|
820 | 820 | $aee['events'][$event_id] = $this->_data->events[$event_id]; |
821 | 821 | } |
822 | 822 | } |
823 | 823 | |
824 | - if ( $item == 'attendee_email' ) { |
|
824 | + if ($item == 'attendee_email') { |
|
825 | 825 | $aee['attendee_email'] = $value; |
826 | 826 | } |
827 | 827 | |
@@ -836,8 +836,8 @@ discard block |
||
836 | 836 | $aee['attendees'] = $this->_data->attendees; |
837 | 837 | |
838 | 838 | //merge in the primary attendee data |
839 | - $aee = array_merge( $this->_default_addressee_data, $aee ); |
|
840 | - $add[] = new EE_Messages_Addressee( $aee ); |
|
839 | + $aee = array_merge($this->_default_addressee_data, $aee); |
|
840 | + $add[] = new EE_Messages_Addressee($aee); |
|
841 | 841 | } |
842 | 842 | |
843 | 843 | return $add; |
@@ -862,46 +862,46 @@ discard block |
||
862 | 862 | ); |
863 | 863 | |
864 | 864 | //in vanilla EE we're assuming there's only one event. However, if there are multiple events then we'll just use the default templates instead of different templates per event (which could create problems). |
865 | - if ( count($this->_data->events) === 1 ) { |
|
866 | - foreach ( $this->_data->events as $event ) { |
|
865 | + if (count($this->_data->events) === 1) { |
|
866 | + foreach ($this->_data->events as $event) { |
|
867 | 867 | $EVT_ID = $event['ID']; |
868 | 868 | } |
869 | 869 | } |
870 | 870 | // is there a Group ID in the incoming request? |
871 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
871 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
872 | 872 | // if not, set a default value of false |
873 | - $GRP_ID = EE_Registry::instance()->REQ->get( 'GRP_ID', false ); |
|
873 | + $GRP_ID = EE_Registry::instance()->REQ->get('GRP_ID', false); |
|
874 | 874 | //if this is a preview then we just get whatever message group is for the preview and skip this part! |
875 | - if ( $this->_preview && $GRP_ID ) { |
|
876 | - $mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID ); |
|
875 | + if ($this->_preview && $GRP_ID) { |
|
876 | + $mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID); |
|
877 | 877 | } else { |
878 | 878 | //not a preview or test send so lets continue on our way! |
879 | 879 | //is there an evt_id? If so let's get that. template. |
880 | - if ( !empty( $EVT_ID ) ) { |
|
880 | + if ( ! empty($EVT_ID)) { |
|
881 | 881 | $evt_qa = array( |
882 | 882 | 'Event.EVT_ID' => $EVT_ID |
883 | 883 | ); |
884 | - $qa = array_merge( $template_qa, $evt_qa ); |
|
885 | - $mtpg = EEM_Message_Template_Group::instance()->get_one( array( $qa ) ); |
|
884 | + $qa = array_merge($template_qa, $evt_qa); |
|
885 | + $mtpg = EEM_Message_Template_Group::instance()->get_one(array($qa)); |
|
886 | 886 | } |
887 | 887 | |
888 | 888 | //is there a 'GRP_ID' ? if so let's get that. |
889 | 889 | |
890 | 890 | //if global template is NOT an override, and there is a 'GRP_ID' in the request, then we'll assume a specific template has ben requested. |
891 | - if ( $GRP_ID ) { |
|
892 | - $mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID ); |
|
891 | + if ($GRP_ID) { |
|
892 | + $mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID); |
|
893 | 893 | } |
894 | 894 | |
895 | 895 | |
896 | 896 | $template_qa['MTP_is_global'] = TRUE; |
897 | 897 | |
898 | 898 | //this gets the current global template (message template group) for the active messenger and message type. |
899 | - $global_mtpg = EEM_Message_Template_Group::instance()->get_one( array( $template_qa ) ); |
|
899 | + $global_mtpg = EEM_Message_Template_Group::instance()->get_one(array($template_qa)); |
|
900 | 900 | |
901 | - $mtpg = $mtpg instanceof EE_Message_Template_Group && ! $global_mtpg->get( 'MTP_is_override' ) ? $mtpg : $global_mtpg; |
|
901 | + $mtpg = $mtpg instanceof EE_Message_Template_Group && ! $global_mtpg->get('MTP_is_override') ? $mtpg : $global_mtpg; |
|
902 | 902 | } |
903 | 903 | |
904 | - if ( ! $mtpg instanceof EE_Message_Template_Group ) { |
|
904 | + if ( ! $mtpg instanceof EE_Message_Template_Group) { |
|
905 | 905 | //get out because we can't process anything, there are no message template groups |
906 | 906 | // and thus some sort of bad setup issues. |
907 | 907 | return false; |
@@ -917,8 +917,8 @@ discard block |
||
917 | 917 | |
918 | 918 | |
919 | 919 | |
920 | - foreach ( $templates as $context => $template_fields ) { |
|
921 | - foreach( $template_fields as $template_field=> $template_obj ) { |
|
920 | + foreach ($templates as $context => $template_fields) { |
|
921 | + foreach ($template_fields as $template_field=> $template_obj) { |
|
922 | 922 | $this->_templates[$template_field][$context] = $template_obj->get('MTP_content'); |
923 | 923 | } |
924 | 924 | } |
@@ -933,11 +933,11 @@ discard block |
||
933 | 933 | protected function _assemble_messages() { |
934 | 934 | //make sure any set messages object is cleared |
935 | 935 | $this->messages = array(); |
936 | - foreach ( $this->_addressees as $context => $addressees ) { |
|
937 | - foreach ( $addressees as $addressee ) { |
|
936 | + foreach ($this->_addressees as $context => $addressees) { |
|
937 | + foreach ($addressees as $addressee) { |
|
938 | 938 | $message = $this->_setup_message_object($context, $addressee); |
939 | 939 | //only assign message if everything went okay |
940 | - if ( $message ) { |
|
940 | + if ($message) { |
|
941 | 941 | $message->template_pack = $this->_template_pack; |
942 | 942 | $message->variation = $this->_variation; |
943 | 943 | $this->messages[] = $message; |
@@ -961,22 +961,22 @@ discard block |
||
961 | 961 | $m_shortcodes = $this->_active_messenger->get_valid_shortcodes(); |
962 | 962 | |
963 | 963 | //if the 'to' field is empty (messages will ALWAYS have a "to" field, then we get out because this context is turned off) EXCEPT if we're previewing |
964 | - if ( ( isset( $this->_templates['to'][$context] ) && empty( $this->_templates['to'][$context] ) ) && !$this->_preview ) |
|
964 | + if ((isset($this->_templates['to'][$context]) && empty($this->_templates['to'][$context])) && ! $this->_preview) |
|
965 | 965 | return false; |
966 | 966 | |
967 | - if ( empty( $this->_templates ) ) { |
|
967 | + if (empty($this->_templates)) { |
|
968 | 968 | //unable to setup any messages because there are no templates. Some sort of catastrophic setup |
969 | 969 | //issue exists |
970 | 970 | return false; |
971 | 971 | } |
972 | 972 | |
973 | - foreach ( $this->_templates as $field => $ctxt ) { |
|
973 | + foreach ($this->_templates as $field => $ctxt) { |
|
974 | 974 | //let's setup the valid shortcodes for the incoming context. |
975 | 975 | $valid_shortcodes = $mt_shortcodes[$context]; |
976 | 976 | //merge in valid shortcodes for the field. |
977 | 977 | $shortcodes = isset($m_shortcodes[$field]) ? $m_shortcodes[$field] : $valid_shortcodes; |
978 | - if ( isset( $this->_templates[$field][$context] ) ) { |
|
979 | - $message->{$field} = $this->_shortcode_replace->parse_message_template($this->_templates[$field][$context], $addressee, $shortcodes, $this, $this->_active_messenger, $context, $this->_GRP_ID ); |
|
978 | + if (isset($this->_templates[$field][$context])) { |
|
979 | + $message->{$field} = $this->_shortcode_replace->parse_message_template($this->_templates[$field][$context], $addressee, $shortcodes, $this, $this->_active_messenger, $context, $this->_GRP_ID); |
|
980 | 980 | } |
981 | 981 | } |
982 | 982 | return $message; |
@@ -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 | /** |
@@ -59,17 +59,17 @@ discard block |
||
59 | 59 | $actives = is_array($_actives) ? array_keys($_actives) : $_actives; |
60 | 60 | $active_names = $this->_load_files('messenger', $actives); |
61 | 61 | |
62 | - if ( is_array($active_names) ) { |
|
63 | - foreach ( $active_names as $name => $class ) { |
|
64 | - $a = new ReflectionClass( $class ); |
|
62 | + if (is_array($active_names)) { |
|
63 | + foreach ($active_names as $name => $class) { |
|
64 | + $a = new ReflectionClass($class); |
|
65 | 65 | $active = $a->newInstance(); |
66 | - if ( is_wp_error($active) ) { |
|
66 | + if (is_wp_error($active)) { |
|
67 | 67 | //we've got an error so let's bubble up the error_object to be caught by caller. |
68 | 68 | //todo: would be better to just catch the errors and then return any aggregated errors later. |
69 | 69 | EE_Error::add_error($active->get_error_message(), __FILE__, __FUNCTION__, __LINE__); |
70 | 70 | } |
71 | 71 | $this->_active_messengers[$name] = $active; |
72 | - $this->_active_message_types[$name] = ! empty( $_actives[$name]['settings'][$name . '-message_types'] ) ? $_actives[$name]['settings'][$name . '-message_types'] : array(); |
|
72 | + $this->_active_message_types[$name] = ! empty($_actives[$name]['settings'][$name.'-message_types']) ? $_actives[$name]['settings'][$name.'-message_types'] : array(); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | } |
@@ -80,13 +80,13 @@ discard block |
||
80 | 80 | * @param string $messenger_name |
81 | 81 | * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive |
82 | 82 | */ |
83 | - public function ensure_messenger_is_active( $messenger_name ){ |
|
83 | + public function ensure_messenger_is_active($messenger_name) { |
|
84 | 84 | //note: active messengers indexed by their names |
85 | 85 | $active_messengers = EEH_MSG_Template::get_active_messengers_in_db(); |
86 | - if( ! isset( $active_messengers[ $messenger_name ] ) ) { |
|
87 | - $this->activate_messenger( $messenger_name ); |
|
86 | + if ( ! isset($active_messengers[$messenger_name])) { |
|
87 | + $this->activate_messenger($messenger_name); |
|
88 | 88 | return FALSE; |
89 | - }else{ |
|
89 | + } else { |
|
90 | 90 | return TRUE; |
91 | 91 | } |
92 | 92 | } |
@@ -101,21 +101,21 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return boolean true if it got activated (or was active) and false if not. |
103 | 103 | */ |
104 | - public function ensure_message_type_is_active( $message_type, $messenger ) { |
|
104 | + public function ensure_message_type_is_active($message_type, $messenger) { |
|
105 | 105 | //first validate that the incoming messenger allows this message type to be activated. |
106 | 106 | $messengers = $this->get_installed_messengers(); |
107 | - if ( ! isset( $messengers[$messenger] ) ) { |
|
108 | - throw new EE_Error( sprintf( __('The messenger sent to %s is not installed', 'event_espresso'), __METHOD__ ) ); |
|
107 | + if ( ! isset($messengers[$messenger])) { |
|
108 | + throw new EE_Error(sprintf(__('The messenger sent to %s is not installed', 'event_espresso'), __METHOD__)); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | $msgr = $messengers[$messenger]; |
112 | 112 | $valid_message_types = $msgr->get_valid_message_types(); |
113 | - if ( ! in_array( $message_type, $valid_message_types ) ) { |
|
114 | - throw new EE_Error( sprint_f( __('The message type ($1%s) sent to $2%s is not valid for the $3%s messenger. Doublecheck the spelling and verify that message type has been registered as a valid type with the messenger.', 'event_espresso' ), $message_type, __METHOD__, $messenger ) ); |
|
113 | + if ( ! in_array($message_type, $valid_message_types)) { |
|
114 | + throw new EE_Error(sprint_f(__('The message type ($1%s) sent to $2%s is not valid for the $3%s messenger. Doublecheck the spelling and verify that message type has been registered as a valid type with the messenger.', 'event_espresso'), $message_type, __METHOD__, $messenger)); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | //all is good so let's just get it active |
118 | - return $this->activate_messenger( $messenger, array( $message_type ) ); |
|
118 | + return $this->activate_messenger($messenger, array($message_type)); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * they are already setup.) |
127 | 127 | * @return boolean an array of generated templates or false if nothing generated/activated. |
128 | 128 | */ |
129 | - public function activate_messenger( $messenger_name, $mts = array() ){ |
|
129 | + public function activate_messenger($messenger_name, $mts = array()) { |
|
130 | 130 | $active_messengers = EEH_MSG_Template::get_active_messengers_in_db(); |
131 | 131 | $message_types = $this->get_installed_message_types(); |
132 | 132 | $installed_messengers = $this->get_installed_messengers(); |
@@ -134,33 +134,33 @@ discard block |
||
134 | 134 | $templates = false; |
135 | 135 | |
136 | 136 | //get has_active so we can be sure its kept up to date. |
137 | - $has_activated = get_option( 'ee_has_activated_messenger' ); |
|
137 | + $has_activated = get_option('ee_has_activated_messenger'); |
|
138 | 138 | |
139 | 139 | //grab the messenger to work with. |
140 | - $messenger = isset( $installed_messengers[$messenger_name] ) ? $installed_messengers[$messenger_name] : null; |
|
140 | + $messenger = isset($installed_messengers[$messenger_name]) ? $installed_messengers[$messenger_name] : null; |
|
141 | 141 | |
142 | 142 | //it's inactive. Activate it. |
143 | 143 | |
144 | - if( $messenger instanceof EE_messenger ) { |
|
145 | - $active_messengers[ $messenger->name ][ 'obj' ] = $messenger; |
|
144 | + if ($messenger instanceof EE_messenger) { |
|
145 | + $active_messengers[$messenger->name]['obj'] = $messenger; |
|
146 | 146 | |
147 | 147 | /** @var EE_messenger[] $installed_messengers */ |
148 | - $mts_to_activate = ! empty( $mts ) ? $mts : $messenger->get_default_message_types(); |
|
149 | - foreach ( $mts_to_activate as $message_type ) { |
|
148 | + $mts_to_activate = ! empty($mts) ? $mts : $messenger->get_default_message_types(); |
|
149 | + foreach ($mts_to_activate as $message_type) { |
|
150 | 150 | //we need to setup any initial settings for message types |
151 | 151 | /** @var EE_message_type[] $installed_mts */ |
152 | - $settings_fields = isset( $message_types[$message_type] ) ? $message_types[ $message_type ]->get_admin_settings_fields() : array(); |
|
153 | - if ( !empty( $settings_fields ) ) { |
|
154 | - foreach ( $settings_fields as $field => $values ) { |
|
155 | - $settings[$field] = $values[ 'default' ]; |
|
152 | + $settings_fields = isset($message_types[$message_type]) ? $message_types[$message_type]->get_admin_settings_fields() : array(); |
|
153 | + if ( ! empty($settings_fields)) { |
|
154 | + foreach ($settings_fields as $field => $values) { |
|
155 | + $settings[$field] = $values['default']; |
|
156 | 156 | } |
157 | 157 | } else { |
158 | 158 | $settings = array(); |
159 | 159 | } |
160 | 160 | |
161 | - $active_messengers[ $messenger->name ][ 'settings' ][ $messenger->name . '-message_types' ][ $message_type ][ 'settings' ] = $settings; |
|
161 | + $active_messengers[$messenger->name]['settings'][$messenger->name.'-message_types'][$message_type]['settings'] = $settings; |
|
162 | 162 | |
163 | - if ( ! empty( $has_activated[$messenger->name] ) && ! in_array( $message_type, $has_activated[$messenger->name] ) ) { |
|
163 | + if ( ! empty($has_activated[$messenger->name]) && ! in_array($message_type, $has_activated[$messenger->name])) { |
|
164 | 164 | $has_activated[$messenger->name][] = $message_type; |
165 | 165 | } |
166 | 166 | } |
@@ -168,22 +168,22 @@ discard block |
||
168 | 168 | //setup any initial settings for the messenger |
169 | 169 | $msgr_settings = $messenger->get_admin_settings_fields(); |
170 | 170 | |
171 | - if ( !empty( $msgr_settings ) ) { |
|
172 | - foreach ( $msgr_settings as $field => $value ) { |
|
173 | - $active_messengers[ $messenger->name ][ 'settings' ][ $field ] = $value; |
|
171 | + if ( ! empty($msgr_settings)) { |
|
172 | + foreach ($msgr_settings as $field => $value) { |
|
173 | + $active_messengers[$messenger->name]['settings'][$field] = $value; |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | - EEH_MSG_Template::update_active_messengers_in_db( $active_messengers ); |
|
178 | - update_option( 'ee_has_activated_messenger', $has_activated ); |
|
177 | + EEH_MSG_Template::update_active_messengers_in_db($active_messengers); |
|
178 | + update_option('ee_has_activated_messenger', $has_activated); |
|
179 | 179 | |
180 | 180 | //make sure that the cached active_messengers is set on this object |
181 | 181 | $this->_active_messengers[$messenger->name] = $messenger; |
182 | 182 | $this->_active_message_types[$messenger->name] = $active_messengers[$messenger->name]; |
183 | 183 | |
184 | 184 | //might need to generate new templates |
185 | - if ( ! empty( $mts_to_activate ) ) { |
|
186 | - $templates = EEH_MSG_Template::generate_new_templates( $messenger->name, $mts_to_activate, 0, TRUE ); |
|
185 | + if ( ! empty($mts_to_activate)) { |
|
186 | + $templates = EEH_MSG_Template::generate_new_templates($messenger->name, $mts_to_activate, 0, TRUE); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
@@ -202,8 +202,8 @@ discard block |
||
202 | 202 | */ |
203 | 203 | private function _load_files($kind, $actives) { |
204 | 204 | $active_names = array(); |
205 | - $base_path = EE_LIBRARIES . 'messages' . DS . $kind . DS; |
|
206 | - if ( empty($actives) ) return false; |
|
205 | + $base_path = EE_LIBRARIES.'messages'.DS.$kind.DS; |
|
206 | + if (empty($actives)) return false; |
|
207 | 207 | |
208 | 208 | //make sure autoloaders are set (failsafe) |
209 | 209 | EED_Messages::set_autoloaders(); |
@@ -211,17 +211,17 @@ discard block |
||
211 | 211 | //make sure $actives is an array |
212 | 212 | $actives = (array) $actives; |
213 | 213 | |
214 | - foreach ( $actives as $active ) { |
|
215 | - $msg_name = 'EE_' . ucwords( str_replace( ' ', '_', $active) ) . '_' . $kind; |
|
216 | - $filename = $msg_name . '.class.php'; |
|
217 | - $load_file = $base_path . DS . $filename; |
|
218 | - if ( is_readable($load_file) ) { |
|
214 | + foreach ($actives as $active) { |
|
215 | + $msg_name = 'EE_'.ucwords(str_replace(' ', '_', $active)).'_'.$kind; |
|
216 | + $filename = $msg_name.'.class.php'; |
|
217 | + $load_file = $base_path.DS.$filename; |
|
218 | + if (is_readable($load_file)) { |
|
219 | 219 | require_once($load_file); |
220 | 220 | $active_names[$active] = $msg_name; |
221 | 221 | } else { |
222 | 222 | $this->_unset_active($active, $kind); |
223 | 223 | //set WP_Error |
224 | - return EE_Error::add_error( sprintf( __("Missing messages system file set as inactive: (%s) %s has been made inactive.", 'event_espresso'), $load_file, $msg_name), __FILE__, __FUNCTION__, __LINE__ ); |
|
224 | + return EE_Error::add_error(sprintf(__("Missing messages system file set as inactive: (%s) %s has been made inactive.", 'event_espresso'), $load_file, $msg_name), __FILE__, __FUNCTION__, __LINE__); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | return $active_names; |
@@ -238,24 +238,24 @@ discard block |
||
238 | 238 | * @param string $kind messenger or message_type? |
239 | 239 | * @return void |
240 | 240 | */ |
241 | - private function _unset_active( $active_name, $kind ) { |
|
241 | + private function _unset_active($active_name, $kind) { |
|
242 | 242 | //pluralize |
243 | 243 | $active_messengers = EEH_MSG_Template::get_active_messengers_in_db(); |
244 | - if ( $kind == 'messenger' ) { |
|
245 | - unset( $active_messengers[$active_name] ); |
|
246 | - EEH_MSG_Template::update_to_inactive( $active_name ); |
|
247 | - if ( isset( $this->_active_messengers[$active_name] ) ) { |
|
248 | - unset( $this->_active_messengers[$active_name] ); |
|
244 | + if ($kind == 'messenger') { |
|
245 | + unset($active_messengers[$active_name]); |
|
246 | + EEH_MSG_Template::update_to_inactive($active_name); |
|
247 | + if (isset($this->_active_messengers[$active_name])) { |
|
248 | + unset($this->_active_messengers[$active_name]); |
|
249 | 249 | } |
250 | 250 | } else { |
251 | - foreach( $active_messengers as $messenger => $settings ) { |
|
252 | - if ( ! empty( $settings['settings'][$messenger . '-message_types'][$active_name] ) ) { |
|
253 | - unset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$active_name] ); |
|
251 | + foreach ($active_messengers as $messenger => $settings) { |
|
252 | + if ( ! empty($settings['settings'][$messenger.'-message_types'][$active_name])) { |
|
253 | + unset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$active_name]); |
|
254 | 254 | } |
255 | 255 | } |
256 | - EEH_MSG_Template::update_to_inactive( '', $active_name ); |
|
257 | - if ( isset( $this->_active_message_types[$active_name] ) ) { |
|
258 | - unset( $this->_active_message_types[$active_name] ); |
|
256 | + EEH_MSG_Template::update_to_inactive('', $active_name); |
|
257 | + if (isset($this->_active_message_types[$active_name])) { |
|
258 | + unset($this->_active_message_types[$active_name]); |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
@@ -273,13 +273,13 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
275 | 275 | */ |
276 | - private function _is_generating_messenger_and_active( EE_messenger $messenger, EE_message_type $message_type ) { |
|
276 | + private function _is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) { |
|
277 | 277 | $generating_msgrs = array(); |
278 | 278 | //get the $messengers the message type says it can be used with. |
279 | 279 | $used_with = $message_type->with_messengers(); |
280 | 280 | |
281 | - foreach ( $used_with as $generating_msgr => $secondary_msgrs ) { |
|
282 | - if ( $messenger->name == $generating_msgr && isset( $this->_active_message_types[$generating_msgr][$message_type->name] ) ) { |
|
281 | + foreach ($used_with as $generating_msgr => $secondary_msgrs) { |
|
282 | + if ($messenger->name == $generating_msgr && isset($this->_active_message_types[$generating_msgr][$message_type->name])) { |
|
283 | 283 | return true; |
284 | 284 | } |
285 | 285 | } |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @param bool $send Default TRUE. If false, then this will just return the generated EE_Messages objects which might be used by the trigger to setup a batch message (typically html messenger uses it). |
300 | 300 | * @return bool |
301 | 301 | */ |
302 | - public function send_message( $type, $vars, $sending_messenger = '', $generating_messenger='', $context='', $send = TRUE ) { |
|
302 | + public function send_message($type, $vars, $sending_messenger = '', $generating_messenger = '', $context = '', $send = TRUE) { |
|
303 | 303 | |
304 | 304 | $error = FALSE; |
305 | 305 | $installed_message_types = $this->get_installed_message_types(); |
@@ -328,34 +328,34 @@ discard block |
||
328 | 328 | //); |
329 | 329 | |
330 | 330 | // is that a real class ? |
331 | - if ( isset( $installed_message_types[$type] ) ) { |
|
331 | + if (isset($installed_message_types[$type])) { |
|
332 | 332 | //is the messenger specified? If so then let's see if can send. This is the check where its possible secondary messengers might be in use. |
333 | - if ( !empty ( $sending_messenger ) ) { |
|
334 | - $generating_messenger = !empty( $generating_messenger ) && !empty( $this->_active_messengers[$generating_messenger] ) ? $this->_active_messengers[$generating_messenger]: NULL; |
|
335 | - $generating_messenger = empty( $generating_messenger ) && ! empty( $this->_active_messengers[$sending_messenger] ) ? $this->_active_messengers[$sending_messenger] : $generating_messenger; |
|
333 | + if ( ! empty ($sending_messenger)) { |
|
334 | + $generating_messenger = ! empty($generating_messenger) && ! empty($this->_active_messengers[$generating_messenger]) ? $this->_active_messengers[$generating_messenger] : NULL; |
|
335 | + $generating_messenger = empty($generating_messenger) && ! empty($this->_active_messengers[$sending_messenger]) ? $this->_active_messengers[$sending_messenger] : $generating_messenger; |
|
336 | 336 | |
337 | - if ( !$this->_is_generating_messenger_and_active( $generating_messenger, $installed_message_types[$type] ) ) { |
|
337 | + if ( ! $this->_is_generating_messenger_and_active($generating_messenger, $installed_message_types[$type])) { |
|
338 | 338 | return false; |
339 | 339 | } |
340 | - $sending_messenger = ! empty( $this->_active_messengers[$sending_messenger] ) ? $this->_active_messengers[$sending_messenger] : NULL; |
|
340 | + $sending_messenger = ! empty($this->_active_messengers[$sending_messenger]) ? $this->_active_messengers[$sending_messenger] : NULL; |
|
341 | 341 | |
342 | - $context = !empty( $context ) ? $context : FALSE; |
|
343 | - $success = $this->_send_message( $generating_messenger, $installed_message_types[$type], $vars, $sending_messenger, $context, $send ); |
|
344 | - if ( ! $send ) { |
|
342 | + $context = ! empty($context) ? $context : FALSE; |
|
343 | + $success = $this->_send_message($generating_messenger, $installed_message_types[$type], $vars, $sending_messenger, $context, $send); |
|
344 | + if ( ! $send) { |
|
345 | 345 | return $success; //returning generated EE_Messages objects |
346 | 346 | } |
347 | 347 | } else { |
348 | 348 | //no messenger sent so let's just loop through active messengers (this method is only acceptable for primary messengers) |
349 | 349 | $send_messages = array(); |
350 | - foreach ( $this->_active_messengers as $active_messenger ) { |
|
350 | + foreach ($this->_active_messengers as $active_messenger) { |
|
351 | 351 | |
352 | 352 | //we ONLY continue if the given messenger is a primary messenger and is an active messenger for the given message type. Otherwise we skip. |
353 | - if ( ! $this->_is_generating_messenger_and_active( $active_messenger, $installed_message_types[$type] ) ) { |
|
353 | + if ( ! $this->_is_generating_messenger_and_active($active_messenger, $installed_message_types[$type])) { |
|
354 | 354 | continue; |
355 | 355 | } |
356 | 356 | |
357 | - $success = $this->_send_message( $active_messenger, $installed_message_types[$type], $vars, $active_messenger ); |
|
358 | - if ( $success === FALSE ) { |
|
357 | + $success = $this->_send_message($active_messenger, $installed_message_types[$type], $vars, $active_messenger); |
|
358 | + if ($success === FALSE) { |
|
359 | 359 | $error = TRUE; |
360 | 360 | } else { |
361 | 361 | $send_messages[] = $success; |
@@ -375,17 +375,17 @@ discard block |
||
375 | 375 | // ); |
376 | 376 | |
377 | 377 | //return generated EE_Messages objects? |
378 | - if ( ! $send ) { |
|
378 | + if ( ! $send) { |
|
379 | 379 | return $send_messages; |
380 | 380 | } |
381 | 381 | } |
382 | 382 | } else { |
383 | - EE_Error::add_error( sprintf( __('Message type: %s does not exist', 'event_espresso'), $type ), __FILE__, __FUNCTION__, __LINE__ ); |
|
383 | + EE_Error::add_error(sprintf(__('Message type: %s does not exist', 'event_espresso'), $type), __FILE__, __FUNCTION__, __LINE__); |
|
384 | 384 | return false; |
385 | 385 | } |
386 | 386 | // add a success message |
387 | - if ( ! $error ) { |
|
388 | - EE_Error::add_success( sprintf( __( 'The %s message has been successfully sent.', 'event_espresso'), $installed_message_types[$type]->label['singular'] ), __FILE__, __FUNCTION__, __LINE__ ); |
|
387 | + if ( ! $error) { |
|
388 | + EE_Error::add_success(sprintf(__('The %s message has been successfully sent.', 'event_espresso'), $installed_message_types[$type]->label['singular']), __FILE__, __FUNCTION__, __LINE__); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | return $error ? FALSE : TRUE; //yeah backwards eh? Really what we're returning is if there is a total success for all the messages or not. We'll modify this once we get message recording in place. |
@@ -402,35 +402,35 @@ discard block |
||
402 | 402 | * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular preview |
403 | 403 | * @return string The body of the message. |
404 | 404 | */ |
405 | - public function preview_message( $type, $context, $messenger, $send = FALSE ) { |
|
405 | + public function preview_message($type, $context, $messenger, $send = FALSE) { |
|
406 | 406 | |
407 | 407 | $installed_message_types = $this->get_installed_message_types(); |
408 | 408 | |
409 | 409 | //does the given type match an actual message type class. |
410 | - if ( isset( $installed_message_types[$type] ) ) { |
|
410 | + if (isset($installed_message_types[$type])) { |
|
411 | 411 | // valid messenger? |
412 | - if ( isset( $this->_active_messengers[$messenger] ) ) { |
|
412 | + if (isset($this->_active_messengers[$messenger])) { |
|
413 | 413 | |
414 | 414 | //we ONLY continue if the given messenger has that message type active with it (note previews only come from primary messengers so no need to check secondarys) |
415 | - if ( !isset( $this->_active_message_types[$messenger][$type] ) ) |
|
415 | + if ( ! isset($this->_active_message_types[$messenger][$type])) |
|
416 | 416 | return false; |
417 | 417 | |
418 | 418 | $message = $installed_message_types[$type]; |
419 | 419 | $messenger = $this->_active_messengers[$messenger]; |
420 | 420 | |
421 | 421 | //set data for preview |
422 | - $message->set_messages( array(), $messenger, $context, TRUE ); |
|
422 | + $message->set_messages(array(), $messenger, $context, TRUE); |
|
423 | 423 | |
424 | 424 | //let's GET the message body from the messenger (instead of the normal send_message) |
425 | - return $messenger->get_preview( $message->messages[0], $message, $send ); |
|
425 | + return $messenger->get_preview($message->messages[0], $message, $send); |
|
426 | 426 | |
427 | 427 | } else { |
428 | - EE_Error::add_error( sprintf( __('Messenger: %s does not exist', 'event_espresso'), $messenger ), __FILE__, __FUNCTION__, __LINE__ ); |
|
428 | + EE_Error::add_error(sprintf(__('Messenger: %s does not exist', 'event_espresso'), $messenger), __FILE__, __FUNCTION__, __LINE__); |
|
429 | 429 | return FALSE; |
430 | 430 | } |
431 | 431 | |
432 | 432 | } else { |
433 | - EE_Error::add_error( sprintf( __('Message type: %s does not exist', 'event_espresso'), $type ), __FILE__, __FUNCTION__, __LINE__ ); |
|
433 | + EE_Error::add_error(sprintf(__('Message type: %s does not exist', 'event_espresso'), $type), __FILE__, __FUNCTION__, __LINE__); |
|
434 | 434 | return FALSE; |
435 | 435 | } |
436 | 436 | |
@@ -451,22 +451,22 @@ discard block |
||
451 | 451 | * |
452 | 452 | * @return mixed(bool|std_Class[]) |
453 | 453 | */ |
454 | - private function _send_message( EE_messenger $generating_messenger, EE_message_type $message_type, $data, EE_messenger $sending_messenger, $context = FALSE, $send = TRUE ) { |
|
454 | + private function _send_message(EE_messenger $generating_messenger, EE_message_type $message_type, $data, EE_messenger $sending_messenger, $context = FALSE, $send = TRUE) { |
|
455 | 455 | //can't even get started yo! |
456 | - if ( $message_type === FALSE || is_wp_error( $message_type ) || $message_type->set_messages( $data, $generating_messenger, $context ) === FALSE ) { |
|
456 | + if ($message_type === FALSE || is_wp_error($message_type) || $message_type->set_messages($data, $generating_messenger, $context) === FALSE) { |
|
457 | 457 | return FALSE; |
458 | 458 | } |
459 | 459 | // if the generating messenger and the sending messengers are different... |
460 | 460 | // then are there any hooks that the generating messenger sets for the sending messenger (i.e. css file swap outs etc.) |
461 | - if ( $sending_messenger != $generating_messenger ) { |
|
462 | - $generating_messenger->do_secondary_messenger_hooks( $sending_messenger->name ); |
|
461 | + if ($sending_messenger != $generating_messenger) { |
|
462 | + $generating_messenger->do_secondary_messenger_hooks($sending_messenger->name); |
|
463 | 463 | } |
464 | 464 | //it is possible that the user has the messenger turned off for this type. |
465 | - if ( $message_type->count === 0 ) { |
|
465 | + if ($message_type->count === 0) { |
|
466 | 466 | return FALSE; |
467 | 467 | } |
468 | 468 | //are we just sending the EE_Messages stdClass objects back? |
469 | - if ( ! $send ) { |
|
469 | + if ( ! $send) { |
|
470 | 470 | return $message_type->messages; |
471 | 471 | } |
472 | 472 | //TODO: check count (at some point we'll use this to decide whether we send to queue or not i.e. |
@@ -474,12 +474,12 @@ discard block |
||
474 | 474 | //else... |
475 | 475 | $success = TRUE; |
476 | 476 | // $success is a flag for the loop. If there is NO error then everything is a success (true) otherwise it wasn't a success (false) |
477 | - foreach ( $message_type->messages as $message ) { |
|
477 | + foreach ($message_type->messages as $message) { |
|
478 | 478 | //todo: should we do some reporting on messages gone out at some point? I think we could have the $active_messenger object return bool for whether message was sent or not and we can compile a report based on that. |
479 | 479 | // if messages send successfully then $success retains it's value, but a single fail will toggle it to FALSE |
480 | - $success = $sending_messenger->send_message( $message, $message_type ) === TRUE ? $success : FALSE; |
|
480 | + $success = $sending_messenger->send_message($message, $message_type) === TRUE ? $success : FALSE; |
|
481 | 481 | } |
482 | - unset( $message_type ); |
|
482 | + unset($message_type); |
|
483 | 483 | return $success; |
484 | 484 | } |
485 | 485 | |
@@ -498,24 +498,24 @@ discard block |
||
498 | 498 | * |
499 | 499 | * @return bool success or fail. |
500 | 500 | */ |
501 | - public function send_message_with_messenger_only( $messenger, $message_type, $message ) { |
|
501 | + public function send_message_with_messenger_only($messenger, $message_type, $message) { |
|
502 | 502 | |
503 | 503 | //get EE_messenger object (which also checks if its active) |
504 | - $msgr = !empty( $messenger ) && !empty( $this->_active_messengers[$messenger] ) ? $this->_active_messengers[$messenger]: NULL; |
|
504 | + $msgr = ! empty($messenger) && ! empty($this->_active_messengers[$messenger]) ? $this->_active_messengers[$messenger] : NULL; |
|
505 | 505 | $installed_message_types = $this->get_installed_message_types(); |
506 | 506 | |
507 | - if ( ! $msgr instanceof EE_messenger ) { |
|
507 | + if ( ! $msgr instanceof EE_messenger) { |
|
508 | 508 | return false; //can't do anything without a valid messenger. |
509 | 509 | } |
510 | 510 | |
511 | 511 | //check valid message type |
512 | - $mtype = isset( $installed_message_types[$message_type] ) ? $installed_message_types[$message_type] : NULL; |
|
512 | + $mtype = isset($installed_message_types[$message_type]) ? $installed_message_types[$message_type] : NULL; |
|
513 | 513 | |
514 | - if( ! $mtype instanceof EE_message_type ) { |
|
514 | + if ( ! $mtype instanceof EE_message_type) { |
|
515 | 515 | return false; //can't do anything without a valid message type. |
516 | 516 | } |
517 | 517 | |
518 | - return $msgr->send_message( $message, $mtype ); |
|
518 | + return $msgr->send_message($message, $mtype); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | */ |
532 | 532 | private function _validate_setup($messenger, $message_type, $is_global = FALSE) { |
533 | 533 | |
534 | - $message_type = strtolower(str_replace(' ', '_', $message_type) ); |
|
534 | + $message_type = strtolower(str_replace(' ', '_', $message_type)); |
|
535 | 535 | $messenger = strtolower(str_replace(' ', '_', $messenger)); |
536 | 536 | $installed_message_types = $this->get_installed_message_types(); |
537 | 537 | |
@@ -547,16 +547,16 @@ discard block |
||
547 | 547 | |
548 | 548 | |
549 | 549 | //do we have the necessary objects loaded? |
550 | - if ( empty( $this->_messenger) || empty($this->_message_type) ) |
|
551 | - throw new EE_Error( sprintf( __(' The %s messenger or the %s message_type are not active. Are you sure they exist?', 'event_espresso'), $messenger, $message_type ) ); |
|
550 | + if (empty($this->_messenger) || empty($this->_message_type)) |
|
551 | + throw new EE_Error(sprintf(__(' The %s messenger or the %s message_type are not active. Are you sure they exist?', 'event_espresso'), $messenger, $message_type)); |
|
552 | 552 | |
553 | 553 | //is given message_type valid for given messenger (if this is not a global save) |
554 | 554 | $types_to_check = array(); |
555 | - if ( !$is_global ) { |
|
556 | - $has_active = EEM_Message_Template_Group::instance()->count( array( array( 'MTP_is_active' => TRUE, 'MTP_messenger' => $this->_messenger->name, 'MTP_message_type' => $message_type ) ) ); |
|
555 | + if ( ! $is_global) { |
|
556 | + $has_active = EEM_Message_Template_Group::instance()->count(array(array('MTP_is_active' => TRUE, 'MTP_messenger' => $this->_messenger->name, 'MTP_message_type' => $message_type))); |
|
557 | 557 | |
558 | - if ( $has_active == 0 ) { |
|
559 | - EE_Error::add_error( sprintf(__(' The %s message type is not registered with the %s messenger. Please visit the Messenger activation page to assign this message type first if you want to use it.', 'event_espresso'), $message_type, $messenger), __FILE__, __FUNCTION__, __LINE__ ); |
|
558 | + if ($has_active == 0) { |
|
559 | + EE_Error::add_error(sprintf(__(' The %s message type is not registered with the %s messenger. Please visit the Messenger activation page to assign this message type first if you want to use it.', 'event_espresso'), $message_type, $messenger), __FILE__, __FUNCTION__, __LINE__); |
|
560 | 560 | return false; |
561 | 561 | } |
562 | 562 | |
@@ -569,17 +569,17 @@ discard block |
||
569 | 569 | * @param string $message_type message type that the templates are being created for |
570 | 570 | * @return array|object if creation is succesful then we return an array of info, otherwise an error_object is returned. |
571 | 571 | */ |
572 | - public function create_new_templates( $messenger, $message_type, $GRP_ID = 0, $is_global = false ) { |
|
572 | + public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) { |
|
573 | 573 | $valid_mt = false; |
574 | 574 | |
575 | 575 | $valid_mt = $this->_validate_setup($messenger, $message_type, $is_global); |
576 | 576 | |
577 | - if ( is_wp_error($valid_mt) && $is_global ) { |
|
577 | + if (is_wp_error($valid_mt) && $is_global) { |
|
578 | 578 | //we're setting up a brand new global templates (with messenger activation) so we're assuming that the message types sent in are valid. |
579 | 579 | $valid_mt = true; |
580 | 580 | } |
581 | 581 | |
582 | - if ( is_wp_error($valid_mt) ) { |
|
582 | + if (is_wp_error($valid_mt)) { |
|
583 | 583 | //if we've still got no valid_mt then bubble up error object |
584 | 584 | return $valid_mt; |
585 | 585 | } |
@@ -591,10 +591,10 @@ discard block |
||
591 | 591 | protected function _create_new_templates($GRP_ID, $is_global) { |
592 | 592 | |
593 | 593 | //if we're creating a custom template then we don't need to use the defaults class |
594 | - if ( ! $is_global ) |
|
595 | - return $this->_create_custom_template_group( $GRP_ID ); |
|
594 | + if ( ! $is_global) |
|
595 | + return $this->_create_custom_template_group($GRP_ID); |
|
596 | 596 | |
597 | - $DFLT = new EE_Message_Template_Defaults( $this, $this->_messenger->name, $this->_message_type->name, $GRP_ID ); |
|
597 | + $DFLT = new EE_Message_Template_Defaults($this, $this->_messenger->name, $this->_message_type->name, $GRP_ID); |
|
598 | 598 | |
599 | 599 | //generate templates |
600 | 600 | $success = $DFLT->create_new_templates(); |
@@ -622,16 +622,16 @@ discard block |
||
622 | 622 | * ) |
623 | 623 | * @access private |
624 | 624 | */ |
625 | - private function _create_custom_template_group( $GRP_ID ) { |
|
625 | + private function _create_custom_template_group($GRP_ID) { |
|
626 | 626 | //defaults |
627 | - $success = array( 'GRP_ID' => NULL, 'MTP_context' => '' ); |
|
627 | + $success = array('GRP_ID' => NULL, 'MTP_context' => ''); |
|
628 | 628 | |
629 | 629 | //get the template group to use as a template from the db. If $GRP_ID is empty then we'll assume the base will be the global template matching the messenger and message type. |
630 | - $mtg = empty( $GRP_ID ) ? EEM_Message_Template_Group::instance()->get_one( array( array( 'MTP_messenger' => $this->_messenger->name, 'MTP_message_type' => $this->_message_type->name, 'MTP_is_global' => TRUE ) ) ) : EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID ); |
|
630 | + $mtg = empty($GRP_ID) ? EEM_Message_Template_Group::instance()->get_one(array(array('MTP_messenger' => $this->_messenger->name, 'MTP_message_type' => $this->_message_type->name, 'MTP_is_global' => TRUE))) : EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID); |
|
631 | 631 | |
632 | 632 | //if we don't have a mtg at this point then we need to bail. |
633 | - if ( ! $mtg instanceof EE_Message_Template_Group ) { |
|
634 | - EE_Error::add_error( sprintf( __('Something went wrong with generating the custom template from this group id: %s. This usually happens when there is no matching message template group in the db.', 'event_espresso'), $GRP_ID ), __FILE__, __FUNCTION__, __LINE__ ); |
|
633 | + if ( ! $mtg instanceof EE_Message_Template_Group) { |
|
634 | + EE_Error::add_error(sprintf(__('Something went wrong with generating the custom template from this group id: %s. This usually happens when there is no matching message template group in the db.', 'event_espresso'), $GRP_ID), __FILE__, __FUNCTION__, __LINE__); |
|
635 | 635 | return $success; |
636 | 636 | } |
637 | 637 | |
@@ -643,27 +643,27 @@ discard block |
||
643 | 643 | $new_mtg->set('GRP_ID', 0); |
644 | 644 | $new_mtg->set('MTP_is_global', FALSE); |
645 | 645 | |
646 | - $template_name = defined('DOING_AJAX') && !empty( $_POST['templateName'] ) ? $_POST['templateName'] : __('New Custom Template', 'event_espresso'); |
|
647 | - $template_description = defined("DOING_AJAX") && !empty( $_POST['templateDescription'] ) ? $_POST['templateDescription'] : sprintf( __('This is a custom template that was created for the %s messenger and %s message type.', 'event_espresso' ), $new_mtg->messenger_obj()->label['singular'], $new_mtg->message_type_obj()->label['singular'] ); |
|
646 | + $template_name = defined('DOING_AJAX') && ! empty($_POST['templateName']) ? $_POST['templateName'] : __('New Custom Template', 'event_espresso'); |
|
647 | + $template_description = defined("DOING_AJAX") && ! empty($_POST['templateDescription']) ? $_POST['templateDescription'] : sprintf(__('This is a custom template that was created for the %s messenger and %s message type.', 'event_espresso'), $new_mtg->messenger_obj()->label['singular'], $new_mtg->message_type_obj()->label['singular']); |
|
648 | 648 | |
649 | 649 | |
650 | - $new_mtg->set('MTP_name', $template_name ); |
|
651 | - $new_mtg->set('MTP_description', $template_description ); |
|
650 | + $new_mtg->set('MTP_name', $template_name); |
|
651 | + $new_mtg->set('MTP_description', $template_description); |
|
652 | 652 | //remove ALL relations on this template group so they don't get saved! |
653 | - $new_mtg->_remove_relations( 'Message_Template' ); |
|
653 | + $new_mtg->_remove_relations('Message_Template'); |
|
654 | 654 | $new_mtg->save(); |
655 | 655 | $success['GRP_ID'] = $new_mtg->ID(); |
656 | 656 | $success['template_name'] = $template_name; |
657 | 657 | |
658 | 658 | //add new message templates and add relation to. |
659 | - foreach ( $mtts as $mtt ) { |
|
660 | - if ( ! $mtt instanceof EE_Message_Template ) |
|
659 | + foreach ($mtts as $mtt) { |
|
660 | + if ( ! $mtt instanceof EE_Message_Template) |
|
661 | 661 | continue; |
662 | 662 | $nmtt = clone $mtt; |
663 | 663 | $nmtt->set('MTP_ID', 0); |
664 | - $nmtt->set( 'GRP_ID', $new_mtg->ID() ); //relation |
|
664 | + $nmtt->set('GRP_ID', $new_mtg->ID()); //relation |
|
665 | 665 | $nmtt->save(); |
666 | - if ( empty( $success['MTP_context'] ) ) |
|
666 | + if (empty($success['MTP_context'])) |
|
667 | 667 | $success['MTP_context'] = $nmtt->get('MTP_context'); |
668 | 668 | } |
669 | 669 | |
@@ -688,14 +688,14 @@ discard block |
||
688 | 688 | |
689 | 689 | |
690 | 690 | //okay now let's assemble an array with the messenger template fields added to the message_type contexts. |
691 | - foreach ( $this->_message_type->get_contexts() as $context => $details ) { |
|
692 | - foreach ( $this->_messenger->get_template_fields() as $field => $value ) { |
|
691 | + foreach ($this->_message_type->get_contexts() as $context => $details) { |
|
692 | + foreach ($this->_messenger->get_template_fields() as $field => $value) { |
|
693 | 693 | $template_fields[$context][$field] = $value; |
694 | 694 | } |
695 | 695 | } |
696 | 696 | |
697 | - if ( empty($template_fields) ) { |
|
698 | - EE_Error::add_error( __('Something went wrong and we couldn\'t get any templates assembled', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
697 | + if (empty($template_fields)) { |
|
698 | + EE_Error::add_error(__('Something went wrong and we couldn\'t get any templates assembled', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
699 | 699 | return FALSE; |
700 | 700 | } |
701 | 701 | |
@@ -710,30 +710,30 @@ discard block |
||
710 | 710 | * @param bool $set if true then we skip the cache and retrieve via files. |
711 | 711 | * @return array multidimensional array of messenger and message_type objects (messengers index, and message_type index); |
712 | 712 | */ |
713 | - public function get_installed( $type = 'all', $skip_cache = false ) { |
|
713 | + public function get_installed($type = 'all', $skip_cache = false) { |
|
714 | 714 | $installed = array(); |
715 | 715 | |
716 | 716 | //first let's account for caching |
717 | - if ( $skip_cache ) { |
|
718 | - $message_base = EE_LIBRARIES . "messages" . DS; |
|
717 | + if ($skip_cache) { |
|
718 | + $message_base = EE_LIBRARIES."messages".DS; |
|
719 | 719 | |
720 | - $messenger_files = $type == 'all' || $type == 'messengers' ? scandir( $message_base . "messenger", 1) : NULL; |
|
721 | - $messagetype_files = $type == 'all' || $type == 'message_types' ? scandir( $message_base . "message_type", 1) : NULL; |
|
720 | + $messenger_files = $type == 'all' || $type == 'messengers' ? scandir($message_base."messenger", 1) : NULL; |
|
721 | + $messagetype_files = $type == 'all' || $type == 'message_types' ? scandir($message_base."message_type", 1) : NULL; |
|
722 | 722 | |
723 | 723 | |
724 | 724 | //allow plugins to filter in their messenger/message_type files |
725 | - $messenger_files = apply_filters('FHEE__EE_messages__get_installed__messenger_files', $messenger_files, $type ); |
|
726 | - $messagetype_files = apply_filters('FHEE__EE_messages__get_installed__messagetype_files', $messagetype_files, $type ); |
|
725 | + $messenger_files = apply_filters('FHEE__EE_messages__get_installed__messenger_files', $messenger_files, $type); |
|
726 | + $messagetype_files = apply_filters('FHEE__EE_messages__get_installed__messagetype_files', $messagetype_files, $type); |
|
727 | 727 | |
728 | - $installed['messengers'] = !empty($messenger_files ) ? $this->_get_installed($messenger_files) : ''; |
|
729 | - $installed['message_types'] = !empty($messagetype_files) ? $this->_get_installed($messagetype_files) : ''; |
|
728 | + $installed['messengers'] = ! empty($messenger_files) ? $this->_get_installed($messenger_files) : ''; |
|
729 | + $installed['message_types'] = ! empty($messagetype_files) ? $this->_get_installed($messagetype_files) : ''; |
|
730 | 730 | } else { |
731 | 731 | $installed['messengers'] = $this->get_installed_messengers(); |
732 | 732 | $installed['message_types'] = $this->get_installed_message_types(); |
733 | 733 | } |
734 | 734 | |
735 | 735 | |
736 | - if ( $type != 'all' ) { |
|
736 | + if ($type != 'all') { |
|
737 | 737 | $installed = $type == 'messengers' ? $installed['messengers'] : $installed['message_types']; |
738 | 738 | } |
739 | 739 | |
@@ -751,11 +751,11 @@ discard block |
||
751 | 751 | $the_goods = array(); |
752 | 752 | $filenames = (array) $filenames; |
753 | 753 | $replace = ".class.php"; |
754 | - foreach ( $filenames as $filename ) { |
|
755 | - $classname = preg_match("/" . $replace . "/", $filename ) ? str_replace($replace, "", $filename) : false; |
|
754 | + foreach ($filenames as $filename) { |
|
755 | + $classname = preg_match("/".$replace."/", $filename) ? str_replace($replace, "", $filename) : false; |
|
756 | 756 | |
757 | 757 | //no classname? no match? move along, nothing to see here. note, the stripos is checking to make sure the filename (classname) begins with EE. |
758 | - if ( !$classname || 0 !== stripos($classname, 'EE') ) continue; |
|
758 | + if ( ! $classname || 0 !== stripos($classname, 'EE')) continue; |
|
759 | 759 | |
760 | 760 | //note: I'm not sure if this will work without including the file. We do have autoloaders so it "may" work. |
761 | 761 | $a = new ReflectionClass($classname); |
@@ -778,9 +778,9 @@ discard block |
||
778 | 778 | */ |
779 | 779 | public function get_active_message_types() { |
780 | 780 | $message_types = array(); |
781 | - foreach ( $this->_active_message_types as $messenger => $mtvalues ) { |
|
782 | - foreach ( $mtvalues as $mt => $config ) { |
|
783 | - if ( !in_array( $mt, $message_types ) ) |
|
781 | + foreach ($this->_active_message_types as $messenger => $mtvalues) { |
|
782 | + foreach ($mtvalues as $mt => $config) { |
|
783 | + if ( ! in_array($mt, $message_types)) |
|
784 | 784 | $message_types[] = $mt; |
785 | 785 | } |
786 | 786 | } |
@@ -800,17 +800,17 @@ discard block |
||
800 | 800 | * |
801 | 801 | * @return EE_message_type[] (or empty array if none present) |
802 | 802 | */ |
803 | - public function get_active_message_types_per_messenger( $messenger ) { |
|
803 | + public function get_active_message_types_per_messenger($messenger) { |
|
804 | 804 | $messenger = (string) $messenger; |
805 | - if ( empty( $this->_active_message_types[$messenger] ) ) { |
|
805 | + if (empty($this->_active_message_types[$messenger])) { |
|
806 | 806 | return array(); |
807 | 807 | } |
808 | 808 | |
809 | 809 | $mts = array(); |
810 | 810 | $message_types = $this->_active_message_types[$messenger]; |
811 | 811 | $installed_message_types = $this->get_installed_message_types(); |
812 | - foreach ( $message_types as $mt => $settings ) { |
|
813 | - if ( ! empty( $installed_message_types[$mt] ) ) { |
|
812 | + foreach ($message_types as $mt => $settings) { |
|
813 | + if ( ! empty($installed_message_types[$mt])) { |
|
814 | 814 | $mts[] = $installed_message_types[$mt]; |
815 | 815 | } |
816 | 816 | } |
@@ -827,9 +827,9 @@ discard block |
||
827 | 827 | * |
828 | 828 | * @return EE_Message_Type|null |
829 | 829 | */ |
830 | - public function get_active_message_type( $messenger, $message_type ) { |
|
830 | + public function get_active_message_type($messenger, $message_type) { |
|
831 | 831 | $installed_message_types = $this->get_installed_message_types(); |
832 | - if ( !empty( $this->_active_message_types[$messenger][$message_type] ) && !empty( $installed_message_types[$message_type] ) ) { |
|
832 | + if ( ! empty($this->_active_message_types[$messenger][$message_type]) && ! empty($installed_message_types[$message_type])) { |
|
833 | 833 | return $installed_message_types[$message_type]; |
834 | 834 | } |
835 | 835 | return NULL; |
@@ -838,13 +838,13 @@ discard block |
||
838 | 838 | |
839 | 839 | |
840 | 840 | public function get_installed_message_types() { |
841 | - $this->_installed_message_types = empty( $this->_installed_message_types ) ? $this->get_installed( 'message_types', true ) : $this->_installed_message_types; |
|
841 | + $this->_installed_message_types = empty($this->_installed_message_types) ? $this->get_installed('message_types', true) : $this->_installed_message_types; |
|
842 | 842 | return $this->_installed_message_types; |
843 | 843 | } |
844 | 844 | |
845 | 845 | |
846 | 846 | public function get_installed_messengers() { |
847 | - $this->_installed_messengers = empty( $this->_installed_messengers ) ? $this->get_installed( 'messengers', true ) : $this->_installed_messengers; |
|
847 | + $this->_installed_messengers = empty($this->_installed_messengers) ? $this->get_installed('messengers', true) : $this->_installed_messengers; |
|
848 | 848 | return $this->_installed_messengers; |
849 | 849 | } |
850 | 850 | } |
@@ -1,5 +1,5 @@ discard block |
||
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 | /** |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * @return void |
290 | 290 | */ |
291 | 291 | public function enqueue_scripts_styles() { |
292 | - do_action( 'AHEE__EE_messenger__enqueue_scripts_styles'); |
|
292 | + do_action('AHEE__EE_messenger__enqueue_scripts_styles'); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | |
326 | 326 | $this->_supports_labels->template_variation_description = __('These are different styles to choose from for the selected template structure. Usually these affect things like font style, color, borders etc. In some cases the styles will also make minor layout changes.'); |
327 | 327 | |
328 | - $this->_supports_labels = apply_filters( 'FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this ); |
|
328 | + $this->_supports_labels = apply_filters('FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | |
@@ -340,10 +340,10 @@ discard block |
||
340 | 340 | * @return stdClass |
341 | 341 | */ |
342 | 342 | public function get_supports_labels() { |
343 | - if ( empty( $this->_supports_labels->template_pack ) || empty( $this->_supports_labels->template_variation) ) { |
|
343 | + if (empty($this->_supports_labels->template_pack) || empty($this->_supports_labels->template_variation)) { |
|
344 | 344 | $this->_set_supports_labels_defaults(); |
345 | 345 | } |
346 | - return apply_filters( 'FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this ); |
|
346 | + return apply_filters('FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | |
@@ -363,10 +363,10 @@ discard block |
||
363 | 363 | * |
364 | 364 | * @return string path or url for the requested variation. |
365 | 365 | */ |
366 | - public function get_variation( EE_Messages_Template_Pack $pack, $message_type_name, $url = FALSE, $type = 'main', $variation = 'default', $skip_filters = FALSE ) { |
|
366 | + public function get_variation(EE_Messages_Template_Pack $pack, $message_type_name, $url = FALSE, $type = 'main', $variation = 'default', $skip_filters = FALSE) { |
|
367 | 367 | $this->_tmp_pack = $pack; |
368 | - $variation_path = apply_filters( 'EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters ); |
|
369 | - $variation_path = empty( $variation_path ) ? $this->_tmp_pack->get_variation( $this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters ) : $variation_path; |
|
368 | + $variation_path = apply_filters('EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters); |
|
369 | + $variation_path = empty($variation_path) ? $this->_tmp_pack->get_variation($this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters) : $variation_path; |
|
370 | 370 | return $variation_path; |
371 | 371 | |
372 | 372 | } |
@@ -384,13 +384,13 @@ discard block |
||
384 | 384 | * @return array |
385 | 385 | */ |
386 | 386 | public function get_default_message_types() { |
387 | - $class = get_class( $this ); |
|
387 | + $class = get_class($this); |
|
388 | 388 | |
389 | 389 | //messenger specific filter |
390 | - $default_types = apply_filters( 'FHEE__' . $class . '__get_default_message_types__default_types', $this->_default_message_types, $this ); |
|
390 | + $default_types = apply_filters('FHEE__'.$class.'__get_default_message_types__default_types', $this->_default_message_types, $this); |
|
391 | 391 | |
392 | 392 | //all messengers filter |
393 | - $default_types = apply_filters( 'FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this ); |
|
393 | + $default_types = apply_filters('FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this); |
|
394 | 394 | return $default_types; |
395 | 395 | } |
396 | 396 | |
@@ -405,14 +405,14 @@ discard block |
||
405 | 405 | * @return array |
406 | 406 | */ |
407 | 407 | public function get_valid_message_types() { |
408 | - $class = get_class( $this ); |
|
408 | + $class = get_class($this); |
|
409 | 409 | |
410 | 410 | //messenger specific filter |
411 | 411 | //messenger specific filter |
412 | - $valid_types = apply_filters( 'FHEE__' . $class . '__get_valid_message_types__valid_types', $this->_valid_message_types, $this ); |
|
412 | + $valid_types = apply_filters('FHEE__'.$class.'__get_valid_message_types__valid_types', $this->_valid_message_types, $this); |
|
413 | 413 | |
414 | 414 | //all messengers filter |
415 | - $valid_types = apply_filters( 'FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this ); |
|
415 | + $valid_types = apply_filters('FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this); |
|
416 | 416 | return $valid_types; |
417 | 417 | } |
418 | 418 | |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * @access public |
427 | 427 | * @param array $new_config Whatever is put in here will reset the _validator_config property |
428 | 428 | */ |
429 | - public function set_validator_config( $new_config ) { |
|
429 | + public function set_validator_config($new_config) { |
|
430 | 430 | $this->_validator_config = $new_config; |
431 | 431 | } |
432 | 432 | |
@@ -442,8 +442,8 @@ discard block |
||
442 | 442 | public function get_validator_config() { |
443 | 443 | $class = get_class($this); |
444 | 444 | |
445 | - $config = apply_filters( 'FHEE__' . $class . '__get_validator_config', $this->_validator_config, $this ); |
|
446 | - $config = apply_filters( 'FHEE__EE_messenger__get_validator_config', $config, $this ); |
|
445 | + $config = apply_filters('FHEE__'.$class.'__get_validator_config', $this->_validator_config, $this); |
|
446 | + $config = apply_filters('FHEE__EE_messenger__get_validator_config', $config, $this); |
|
447 | 447 | return $config; |
448 | 448 | } |
449 | 449 | |
@@ -460,8 +460,8 @@ discard block |
||
460 | 460 | * @access public |
461 | 461 | * @return string content for page |
462 | 462 | */ |
463 | - public function get_messenger_admin_page_content( $page, $action = null, $extra = array(), $message_types = array() ) { |
|
464 | - return $this->_get_admin_page_content( $page, $action, $extra, $message_types ); |
|
463 | + public function get_messenger_admin_page_content($page, $action = null, $extra = array(), $message_types = array()) { |
|
464 | + return $this->_get_admin_page_content($page, $action, $extra, $message_types); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | |
@@ -470,76 +470,76 @@ discard block |
||
470 | 470 | |
471 | 471 | |
472 | 472 | |
473 | - protected function _get_admin_content_events_edit( $message_types, $extra ) { |
|
473 | + protected function _get_admin_content_events_edit($message_types, $extra) { |
|
474 | 474 | //defaults |
475 | 475 | $template_args = array(); |
476 | 476 | $custom_templates = array(); |
477 | 477 | $selector_rows = ''; |
478 | 478 | |
479 | 479 | //we don't need message types here so we're just going to ignore. we do, however, expect the event id here. The event id is needed to provide a link to setup a custom template for this event. |
480 | - $event_id = isset( $extra['event'] ) ? $extra['event'] : NULL; |
|
480 | + $event_id = isset($extra['event']) ? $extra['event'] : NULL; |
|
481 | 481 | |
482 | - $template_wrapper_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_wrapper.template.php'; |
|
483 | - $template_row_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_row.template.php'; |
|
482 | + $template_wrapper_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_wrapper.template.php'; |
|
483 | + $template_row_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_row.template.php'; |
|
484 | 484 | |
485 | 485 | //array of template objects for global and custom (non-trashed) (but remember just for this messenger!) |
486 | - $global_templates = EEM_Message_Template_Group::instance()->get_all( array( array('MTP_messenger' => $this->name, 'MTP_is_global' => TRUE, 'MTP_is_active' => TRUE ) ) ); |
|
487 | - $templates_for_event = EEM_Message_Template_Group::instance()->get_all_custom_templates_by_event( $event_id, array( 'MTP_messenger' => $this->name, 'MTP_is_active' => TRUE ) ); |
|
488 | - $templates_for_event = !empty( $templates_for_event ) ? $templates_for_event : array(); |
|
486 | + $global_templates = EEM_Message_Template_Group::instance()->get_all(array(array('MTP_messenger' => $this->name, 'MTP_is_global' => TRUE, 'MTP_is_active' => TRUE))); |
|
487 | + $templates_for_event = EEM_Message_Template_Group::instance()->get_all_custom_templates_by_event($event_id, array('MTP_messenger' => $this->name, 'MTP_is_active' => TRUE)); |
|
488 | + $templates_for_event = ! empty($templates_for_event) ? $templates_for_event : array(); |
|
489 | 489 | |
490 | 490 | //so we need to setup the rows for the selectors and we use the global mtpgs (cause those will the active message template groups) |
491 | - foreach ( $global_templates as $mtpgID => $mtpg ) { |
|
491 | + foreach ($global_templates as $mtpgID => $mtpg) { |
|
492 | 492 | //verify this message type is supposed to show on this page |
493 | 493 | $mtp_obj = $mtpg->message_type_obj(); |
494 | - if ( ! $mtp_obj instanceof EE_message_type ) { |
|
494 | + if ( ! $mtp_obj instanceof EE_message_type) { |
|
495 | 495 | continue; |
496 | 496 | } |
497 | 497 | $mtp_obj->admin_registered_pages = (array) $mtp_obj->admin_registered_pages; |
498 | - if ( ! in_array( 'events_edit', $mtp_obj->admin_registered_pages ) ) |
|
498 | + if ( ! in_array('events_edit', $mtp_obj->admin_registered_pages)) |
|
499 | 499 | continue; |
500 | 500 | $stargs = array(); |
501 | 501 | $default_value = ''; |
502 | 502 | $select_values = array(); |
503 | 503 | $select_values[$mtpgID] = __('Global', 'event_espresso'); |
504 | - $default_value = array_key_exists( $mtpgID, $templates_for_event ) && ! $mtpg->get('MTP_is_override' ) ? $mtpgID : NULL; |
|
504 | + $default_value = array_key_exists($mtpgID, $templates_for_event) && ! $mtpg->get('MTP_is_override') ? $mtpgID : NULL; |
|
505 | 505 | |
506 | 506 | //if the override has been set for the global template, then that means even if there are custom templates already created we ignore them because of the set override. |
507 | 507 | |
508 | - if ( ! $mtpg->get('MTP_is_override' ) ) { |
|
508 | + if ( ! $mtpg->get('MTP_is_override')) { |
|
509 | 509 | //any custom templates for this message type? |
510 | - $custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt( $this->name, $mtpg->message_type() ); |
|
510 | + $custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt($this->name, $mtpg->message_type()); |
|
511 | 511 | |
512 | - foreach( $custom_templates as $cmtpgID => $cmtpg ) { |
|
512 | + foreach ($custom_templates as $cmtpgID => $cmtpg) { |
|
513 | 513 | $select_values[$cmtpgID] = $cmtpg->name(); |
514 | - $default_value = array_key_exists( $cmtpgID, $templates_for_event ) ? $cmtpgID : $default_value; |
|
514 | + $default_value = array_key_exists($cmtpgID, $templates_for_event) ? $cmtpgID : $default_value; |
|
515 | 515 | } |
516 | 516 | } |
517 | 517 | |
518 | 518 | //if there is no $default_value then we set it as the global |
519 | - $default_value = empty( $default_value ) ? $mtpgID : $default_value; |
|
519 | + $default_value = empty($default_value) ? $mtpgID : $default_value; |
|
520 | 520 | |
521 | - $edit_url = EEH_URL::add_query_args_and_nonce( array('page' => 'espresso_messages', 'action' => 'edit_message_template', 'id' => $default_value), admin_url('admin.php') ); |
|
522 | - $create_url = EEH_URL::add_query_args_and_nonce( array('page' => 'espresso_messages', 'action' => 'add_new_message_template', 'GRP_ID' => $default_value ), admin_url( 'admin.php' ) ); |
|
521 | + $edit_url = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'edit_message_template', 'id' => $default_value), admin_url('admin.php')); |
|
522 | + $create_url = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'add_new_message_template', 'GRP_ID' => $default_value), admin_url('admin.php')); |
|
523 | 523 | |
524 | - $st_args['mt_name'] = ucwords( $mtp_obj->label['singular'] ); |
|
524 | + $st_args['mt_name'] = ucwords($mtp_obj->label['singular']); |
|
525 | 525 | $st_args['mt_slug'] = $mtpg->message_type(); |
526 | 526 | $st_args['messenger_slug'] = $this->name; |
527 | - $st_args['selector'] = EEH_Form_Fields::select_input( 'event_message_templates_relation[' . $mtpgID . ']', $select_values, $default_value, 'data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '"', 'message-template-selector' ); |
|
527 | + $st_args['selector'] = EEH_Form_Fields::select_input('event_message_templates_relation['.$mtpgID.']', $select_values, $default_value, 'data-messenger="'.$this->name.'" data-messagetype="'.$mtpg->message_type().'"', 'message-template-selector'); |
|
528 | 528 | |
529 | 529 | //note that message template group that has override_all_custom set will remove the ability to set a custom message template based off of the global (and that also in turn overrides any other custom templates). |
530 | - $st_args['create_button'] = $mtpg->get('MTP_is_override') ? '' : '<a data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $create_url . '" class="button button-small create-mtpg-button">' . __('Create New Custom', 'event_espresso') . '</a>'; |
|
531 | - $st_args['create_button'] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'espresso_messsages_add_new_message_template' ) ? $st_args['create_button'] : ''; |
|
532 | - $st_args['edit_button'] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $mtpgID ) ? '<a data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $edit_url . '" class="button button-small edit-mtpg-button">' . __('Edit', 'event_espresso') . '</a>' : ''; |
|
533 | - $selector_rows .= EEH_Template::display_template( $template_row_path, $st_args, TRUE ); |
|
530 | + $st_args['create_button'] = $mtpg->get('MTP_is_override') ? '' : '<a data-messenger="'.$this->name.'" data-messagetype="'.$mtpg->message_type().'" data-grpid="'.$default_value.'" target="_blank" href="'.$create_url.'" class="button button-small create-mtpg-button">'.__('Create New Custom', 'event_espresso').'</a>'; |
|
531 | + $st_args['create_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'espresso_messsages_add_new_message_template') ? $st_args['create_button'] : ''; |
|
532 | + $st_args['edit_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $mtpgID) ? '<a data-messagetype="'.$mtpg->message_type().'" data-grpid="'.$default_value.'" target="_blank" href="'.$edit_url.'" class="button button-small edit-mtpg-button">'.__('Edit', 'event_espresso').'</a>' : ''; |
|
533 | + $selector_rows .= EEH_Template::display_template($template_row_path, $st_args, TRUE); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | //if no selectors present then get out. |
537 | - if ( empty( $selector_rows ) ) { |
|
537 | + if (empty($selector_rows)) { |
|
538 | 538 | return ''; |
539 | 539 | } |
540 | 540 | |
541 | 541 | $template_args['selector_rows'] = $selector_rows; |
542 | - return EEH_Template::display_template( $template_wrapper_path, $template_args, TRUE ); |
|
542 | + return EEH_Template::display_template($template_wrapper_path, $template_args, TRUE); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | |
@@ -554,8 +554,8 @@ discard block |
||
554 | 554 | * @return array $this->_template_fields |
555 | 555 | */ |
556 | 556 | public function get_template_fields() { |
557 | - $template_fields = apply_filters( 'FHEE__' . get_class($this) . '__get_template_fields', $this->_template_fields, $this ); |
|
558 | - $template_fields = apply_filters( 'FHEE__EE_messenger__get_template_fields', $template_fields, $this ); |
|
557 | + $template_fields = apply_filters('FHEE__'.get_class($this).'__get_template_fields', $this->_template_fields, $this); |
|
558 | + $template_fields = apply_filters('FHEE__EE_messenger__get_template_fields', $template_fields, $this); |
|
559 | 559 | return $template_fields; |
560 | 560 | } |
561 | 561 | |
@@ -568,9 +568,9 @@ discard block |
||
568 | 568 | * The following method doesn't NEED to be used by child classes but might be modified by the specific messenger |
569 | 569 | */ |
570 | 570 | protected function _set_template_value($item, $value) { |
571 | - if ( array_key_exists($item, $this->_template_fields) ) { |
|
572 | - $prop = '_' . $item; |
|
573 | - $this->{$prop}= $value; |
|
571 | + if (array_key_exists($item, $this->_template_fields)) { |
|
572 | + $prop = '_'.$item; |
|
573 | + $this->{$prop} = $value; |
|
574 | 574 | } |
575 | 575 | } |
576 | 576 | |
@@ -580,8 +580,8 @@ discard block |
||
580 | 580 | * @param EE_message_type $message_type The message type object used in combination with this messenger to generate the provided message. |
581 | 581 | * @return bool | WP_Error |
582 | 582 | */ |
583 | - public function send_message( $message, EE_message_type $message_type ) { |
|
584 | - $this->_validate_and_setup( $message ); |
|
583 | + public function send_message($message, EE_message_type $message_type) { |
|
584 | + $this->_validate_and_setup($message); |
|
585 | 585 | $this->_incoming_message_type = $message_type; |
586 | 586 | return $this->_send_message(); |
587 | 587 | } |
@@ -595,28 +595,28 @@ discard block |
||
595 | 595 | * @param bool $send true we will actually use the _send method (for test sends). FALSE we just return preview |
596 | 596 | * @return string return the message html content |
597 | 597 | */ |
598 | - public function get_preview( $message, EE_message_type $message_type, $send = FALSE ) { |
|
599 | - $this->_validate_and_setup( $message ); |
|
598 | + public function get_preview($message, EE_message_type $message_type, $send = FALSE) { |
|
599 | + $this->_validate_and_setup($message); |
|
600 | 600 | |
601 | 601 | $this->_incoming_message_type = $message_type; |
602 | 602 | |
603 | - if ( $send ) { |
|
603 | + if ($send) { |
|
604 | 604 | //are we overriding any existing template fields? |
605 | 605 | $settings = $this->get_existing_test_settings(); |
606 | - if ( !empty( $settings ) ) { |
|
607 | - foreach( $settings as $field => $value ) { |
|
608 | - $this->_set_template_value( $field, $value ); |
|
606 | + if ( ! empty($settings)) { |
|
607 | + foreach ($settings as $field => $value) { |
|
608 | + $this->_set_template_value($field, $value); |
|
609 | 609 | } |
610 | 610 | } |
611 | 611 | } |
612 | 612 | |
613 | 613 | //enqueue preview js so that any links/buttons on the page are disabled. |
614 | - if ( ! $send ) { |
|
614 | + if ( ! $send) { |
|
615 | 615 | // the below may seem like duplication. However, typically if a messenger enqueues scripts/styles, |
616 | 616 | // it deregisters all existing wp scripts and styles first. So the second hook ensures our previewer still gets setup. |
617 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_preview_script' ), 10 ); |
|
618 | - add_action( 'wp_enqueue_scripts', array( $this, 'add_preview_script' ), 10 ); |
|
619 | - add_action( 'AHEE__EE_messenger__enqueue_scripts_styles', array( $this, 'add_preview_script' ), 10 ); |
|
617 | + add_action('admin_enqueue_scripts', array($this, 'add_preview_script'), 10); |
|
618 | + add_action('wp_enqueue_scripts', array($this, 'add_preview_script'), 10); |
|
619 | + add_action('AHEE__EE_messenger__enqueue_scripts_styles', array($this, 'add_preview_script'), 10); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | return $send ? $this->_send_message() : $this->_preview(); |
@@ -634,10 +634,10 @@ discard block |
||
634 | 634 | */ |
635 | 635 | public function add_preview_script() { |
636 | 636 | //error message |
637 | - EE_Registry::$i18n_js_strings[ 'links_disabled' ] = __( 'All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup. To test generated links, you must trigger an actual message notification.', 'event_espresso' ); |
|
638 | - wp_register_script( 'ee-messages-preview-js', EE_LIBRARIES_URL . 'messages/messenger/assets/js/ee-messages-preview.js', array( 'jquery' ), EVENT_ESPRESSO_VERSION, true ); |
|
639 | - wp_localize_script( 'ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings ); |
|
640 | - wp_enqueue_script( 'ee-messages-preview-js' ); |
|
637 | + EE_Registry::$i18n_js_strings['links_disabled'] = __('All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup. To test generated links, you must trigger an actual message notification.', 'event_espresso'); |
|
638 | + wp_register_script('ee-messages-preview-js', EE_LIBRARIES_URL.'messages/messenger/assets/js/ee-messages-preview.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
639 | + wp_localize_script('ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings); |
|
640 | + wp_enqueue_script('ee-messages-preview-js'); |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | |
@@ -647,23 +647,23 @@ discard block |
||
647 | 647 | * @param object $message message object |
648 | 648 | * @throws \EE_Error |
649 | 649 | */ |
650 | - protected function _validate_and_setup( $message ) { |
|
651 | - if ( !is_object( $message ) ) |
|
652 | - throw new EE_Error( __('Incoming "$message" must be an object', 'event_espresso' ) ); |
|
650 | + protected function _validate_and_setup($message) { |
|
651 | + if ( ! is_object($message)) |
|
652 | + throw new EE_Error(__('Incoming "$message" must be an object', 'event_espresso')); |
|
653 | 653 | |
654 | 654 | //verify we have the required template pack value on the $message object. |
655 | - if ( empty( $message->template_pack ) || ! $message->template_pack instanceof EE_Messages_Template_Pack ) { |
|
656 | - throw new EE_Error( __('Incoming $message object must have a EE_Messages_Template_Pack object assigned to the template_pack property', 'event_espresso' ) ); |
|
655 | + if (empty($message->template_pack) || ! $message->template_pack instanceof EE_Messages_Template_Pack) { |
|
656 | + throw new EE_Error(__('Incoming $message object must have a EE_Messages_Template_Pack object assigned to the template_pack property', 'event_espresso')); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | $this->_tmp_pack = $message->template_pack; |
660 | 660 | |
661 | - $this->_variation = !empty ( $message->variation ) ? $message->variation : 'default'; |
|
661 | + $this->_variation = ! empty ($message->variation) ? $message->variation : 'default'; |
|
662 | 662 | |
663 | 663 | $template_fields = $this->get_template_fields(); |
664 | 664 | |
665 | - foreach ( $template_fields as $template => $value ) { |
|
666 | - if ( $template !== 'extra' ) |
|
665 | + foreach ($template_fields as $template => $value) { |
|
666 | + if ($template !== 'extra') |
|
667 | 667 | $this->_set_template_value($template, $message->{$template}); |
668 | 668 | } |
669 | 669 | } |
@@ -678,19 +678,19 @@ discard block |
||
678 | 678 | * @return string |
679 | 679 | * @throws \EE_Error |
680 | 680 | */ |
681 | - protected function _get_main_template( $preview = FALSE ) { |
|
681 | + protected function _get_main_template($preview = FALSE) { |
|
682 | 682 | $type = $preview ? 'preview' : 'main'; |
683 | 683 | |
684 | - $wrapper_template = $this->_tmp_pack->get_wrapper( $this->name, $type ); |
|
684 | + $wrapper_template = $this->_tmp_pack->get_wrapper($this->name, $type); |
|
685 | 685 | |
686 | 686 | //check file exists and is readable |
687 | - if ( !is_readable( $wrapper_template ) ) |
|
688 | - throw new EE_Error( sprintf( __('Unable to access the template file for the %s messenger main content wrapper. The location being attempted is %s.', 'event_espresso' ), ucwords($this->label['singular']) , $wrapper_template ) ); |
|
687 | + if ( ! is_readable($wrapper_template)) |
|
688 | + throw new EE_Error(sprintf(__('Unable to access the template file for the %s messenger main content wrapper. The location being attempted is %s.', 'event_espresso'), ucwords($this->label['singular']), $wrapper_template)); |
|
689 | 689 | |
690 | 690 | //add message type to template args |
691 | 691 | $this->_template_args['message_type'] = $this->_incoming_message_type; |
692 | 692 | |
693 | - return EEH_Template::display_template( $wrapper_template, $this->_template_args, TRUE ); |
|
693 | + return EEH_Template::display_template($wrapper_template, $this->_template_args, TRUE); |
|
694 | 694 | } |
695 | 695 | |
696 | 696 | |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | */ |
727 | 727 | public function get_existing_test_settings() { |
728 | 728 | $settings = EEH_MSG_Template::get_active_messengers_in_db(); |
729 | - return isset( $settings[$this->name]['test_settings'] ) ? $settings[$this->name]['test_settings'] : array(); |
|
729 | + return isset($settings[$this->name]['test_settings']) ? $settings[$this->name]['test_settings'] : array(); |
|
730 | 730 | } |
731 | 731 | |
732 | 732 | |
@@ -737,10 +737,10 @@ discard block |
||
737 | 737 | * @access public |
738 | 738 | * @return bool success/fail |
739 | 739 | */ |
740 | - public function set_existing_test_settings( $settings ) { |
|
740 | + public function set_existing_test_settings($settings) { |
|
741 | 741 | $existing = EEH_MSG_Template::get_active_messengers_in_db(); |
742 | 742 | $existing[$this->name]['test_settings'] = $settings; |
743 | - return EEH_MSG_Template::update_active_messengers_in_db( $existing ); |
|
743 | + return EEH_MSG_Template::update_active_messengers_in_db($existing); |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | |
@@ -753,21 +753,21 @@ discard block |
||
753 | 753 | * @param string $field The field to retrieve the label for |
754 | 754 | * @return string The label |
755 | 755 | */ |
756 | - public function get_field_label( $field ) { |
|
756 | + public function get_field_label($field) { |
|
757 | 757 | //first let's see if the field requests is in the top level array. |
758 | - if ( isset( $this->_template_fields[$field] ) && !empty( $this->_template_fields[$field]['label'] ) ) |
|
758 | + if (isset($this->_template_fields[$field]) && ! empty($this->_template_fields[$field]['label'])) |
|
759 | 759 | return $this->_template[$field]['label']; |
760 | 760 | |
761 | 761 | //nope so let's look in the extra array to see if it's there HOWEVER if the field exists as a top level index in the extra array then we know the label is in the 'main' index. |
762 | - if ( isset( $this->_template_fields['extra'] ) && !empty( $this->_template_fields['extra'][$field] ) && !empty( $this->_template_fields['extra'][$field]['main']['label'] ) ) |
|
762 | + if (isset($this->_template_fields['extra']) && ! empty($this->_template_fields['extra'][$field]) && ! empty($this->_template_fields['extra'][$field]['main']['label'])) |
|
763 | 763 | return $this->_template_fields['extra'][$field]['main']['label']; |
764 | 764 | |
765 | 765 | //now it's possible this field may just be existing in any of the extra array items. |
766 | - if ( !empty( $this->_template_fields['extra'] ) && is_array( $this->_template_fields['extra'] ) ) { |
|
767 | - foreach ( $this->_template_fields['extra'] as $main_field => $subfields ) { |
|
768 | - if ( !is_array( $subfields ) ) |
|
766 | + if ( ! empty($this->_template_fields['extra']) && is_array($this->_template_fields['extra'])) { |
|
767 | + foreach ($this->_template_fields['extra'] as $main_field => $subfields) { |
|
768 | + if ( ! is_array($subfields)) |
|
769 | 769 | continue; |
770 | - if ( isset( $subfields[$field] ) && !empty( $subfields[$field]['label'] ) ) |
|
770 | + if (isset($subfields[$field]) && ! empty($subfields[$field]['label'])) |
|
771 | 771 | return $subfields[$field]['label']; |
772 | 772 | } |
773 | 773 | } |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | * |
789 | 789 | * @return void |
790 | 790 | */ |
791 | - public function do_secondary_messenger_hooks( $sending_messenger_name ) { |
|
791 | + public function do_secondary_messenger_hooks($sending_messenger_name) { |
|
792 | 792 | return; |
793 | 793 | } |
794 | 794 |
@@ -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 | /** |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | |
164 | 164 | |
165 | 165 | public function get_shortcode_helper() { |
166 | - if ( ! $this->_shortcode_helper instanceof EEH_Parse_Shortcodes ) |
|
166 | + if ( ! $this->_shortcode_helper instanceof EEH_Parse_Shortcodes) |
|
167 | 167 | $this->_set_shortcode_helper(); |
168 | 168 | return $this->_shortcode_helper; |
169 | 169 | } |
@@ -176,25 +176,25 @@ discard block |
||
176 | 176 | * @param mixed (object|array) $extra_data extra incoming data (usually EE_Messages_Addressee) |
177 | 177 | * @return string parsed shortcode. |
178 | 178 | */ |
179 | - public function parser($shortcode, $data, $extra_data = array() ) { |
|
179 | + public function parser($shortcode, $data, $extra_data = array()) { |
|
180 | 180 | |
181 | 181 | //filter setup shortcodes |
182 | 182 | $this->_shortcodes = $this->get_shortcodes(); |
183 | 183 | |
184 | 184 | //we need to setup any dynamic shortcodes so that they work with the array_key_exists |
185 | - $sc = preg_match_all( '/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches ); |
|
186 | - $sc_to_verify = !empty($matches[0] ) ? $matches[0][0] . ']' : $shortcode; |
|
185 | + $sc = preg_match_all('/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches); |
|
186 | + $sc_to_verify = ! empty($matches[0]) ? $matches[0][0].']' : $shortcode; |
|
187 | 187 | |
188 | 188 | //first we want to make sure this is a valid shortcode |
189 | - if ( !array_key_exists($sc_to_verify, $this->_shortcodes ) ) |
|
189 | + if ( ! array_key_exists($sc_to_verify, $this->_shortcodes)) |
|
190 | 190 | return false; //get out, this parser doesn't handle the incoming shortcode. |
191 | 191 | $this->_data = $data; |
192 | 192 | $this->_extra_data = $extra_data; |
193 | 193 | $this->_set_messages_properties(); |
194 | - $parsed = apply_filters( 'FHEE__' . get_class($this) . '__parser_after', $this->_parser($shortcode), $shortcode, $data, $extra_data, $this ); |
|
194 | + $parsed = apply_filters('FHEE__'.get_class($this).'__parser_after', $this->_parser($shortcode), $shortcode, $data, $extra_data, $this); |
|
195 | 195 | |
196 | 196 | //note the below filter applies to ALL shortcode parsers... be careful! |
197 | - $parsed = apply_filters( 'FHEE__EE_Shortcodes__parser_after', $parsed, $shortcode, $data, $extra_data, $this ); |
|
197 | + $parsed = apply_filters('FHEE__EE_Shortcodes__parser_after', $parsed, $shortcode, $data, $extra_data, $this); |
|
198 | 198 | return $parsed; |
199 | 199 | } |
200 | 200 | |
@@ -210,10 +210,10 @@ discard block |
||
210 | 210 | * @return array array of shortcodes => description pairs |
211 | 211 | */ |
212 | 212 | public function get_shortcodes() { |
213 | - $this->_shortcodes = apply_filters( 'FHEE__' . get_class($this) . '__shortcodes', $this->_shortcodes, $this ); |
|
213 | + $this->_shortcodes = apply_filters('FHEE__'.get_class($this).'__shortcodes', $this->_shortcodes, $this); |
|
214 | 214 | |
215 | 215 | //note the below filter applies to ALL shortcode parsers... be careful! |
216 | - $this->_shortcodes = apply_filters( 'FHEE__EE_Shortcodes__shortcodes', $this->_shortcodes, $this ); |
|
216 | + $this->_shortcodes = apply_filters('FHEE__EE_Shortcodes__shortcodes', $this->_shortcodes, $this); |
|
217 | 217 | |
218 | 218 | return $this->_shortcodes; |
219 | 219 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * @param mixed (object|array) $data incoming data for the parser. The data could be either an object or array because there are some shortcodes that might be replaced by prepared data that has multiple items in a list (i.e. list of attendees in an event and we're showing fname/lname for each attendee). In this case data will be in an array. Otherwise the data shoudl be in a properly formatted object. The EEH_Parse_Shortcodes.helper.php describes the data object we're expecting. |
244 | 244 | * @return string parsed shortcode |
245 | 245 | */ |
246 | - abstract protected function _parser( $shortcode ); |
|
246 | + abstract protected function _parser($shortcode); |
|
247 | 247 | |
248 | 248 | |
249 | 249 | |
@@ -255,22 +255,22 @@ discard block |
||
255 | 255 | protected function _validate_list_requirements() { |
256 | 256 | |
257 | 257 | //first test to make sure we've got an array! |
258 | - if ( !is_array($this->_data) ) { |
|
259 | - throw new EE_Error( sprintf( __('Expecting an array for the data sent to %s. Instead it was %s', 'event_espresso'), get_class($this), gettype( $this->_data ) ) ); |
|
258 | + if ( ! is_array($this->_data)) { |
|
259 | + throw new EE_Error(sprintf(__('Expecting an array for the data sent to %s. Instead it was %s', 'event_espresso'), get_class($this), gettype($this->_data))); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | //next test to make sure we've got the required template in the index! |
263 | - if ( !isset( $this->_data['template'] ) ) { |
|
264 | - throw new EE_Error( sprintf( __('The incoming data does not have the required template index in its array', 'event_espresso') ) ); |
|
263 | + if ( ! isset($this->_data['template'])) { |
|
264 | + throw new EE_Error(sprintf(__('The incoming data does not have the required template index in its array', 'event_espresso'))); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | //next test to make sure we've got got a data index in the incoming data array |
268 | - if ( !isset( $this->_data['data'] ) ) |
|
269 | - throw new EE_Error( __('The incoming data does not have the required data index in its array', 'event_espresso') ); |
|
268 | + if ( ! isset($this->_data['data'])) |
|
269 | + throw new EE_Error(__('The incoming data does not have the required data index in its array', 'event_espresso')); |
|
270 | 270 | |
271 | 271 | //all is well let's make sure _extra_data always has the values needed. |
272 | 272 | //let's make sure that extra_data includes all templates (for later parsing if necessary) |
273 | - if ( empty( $this->_extra_data ) || ( empty( $this->_extra_data['data'] ) && empty( $this->_extra_data['template'] ) ) ) { |
|
273 | + if (empty($this->_extra_data) || (empty($this->_extra_data['data']) && empty($this->_extra_data['template']))) { |
|
274 | 274 | $this->_extra_data['data'] = $this->_data['data']; |
275 | 275 | $this->_extra_data['template'] = $this->_data['template']; |
276 | 276 | } |
@@ -287,16 +287,16 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @return array An array with the attributes |
289 | 289 | */ |
290 | - protected function _get_shortcode_attrs( $shortcode ) { |
|
290 | + protected function _get_shortcode_attrs($shortcode) { |
|
291 | 291 | //make sure the required wp helper function is present |
292 | 292 | //require the shortcode file if necessary |
293 | - if ( ! function_exists( 'shortcode_parse_atts' ) ) { |
|
294 | - require_once( ABSPATH . WPINC . '/shortcodes.php'); |
|
293 | + if ( ! function_exists('shortcode_parse_atts')) { |
|
294 | + require_once(ABSPATH.WPINC.'/shortcodes.php'); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | //let's get any attributes that may be present and set the defaults. |
298 | - $shortcode_to_parse = str_replace( '[', '', str_replace( ']', '', $shortcode ) ); |
|
299 | - return shortcode_parse_atts( $shortcode_to_parse ); |
|
298 | + $shortcode_to_parse = str_replace('[', '', str_replace(']', '', $shortcode)); |
|
299 | + return shortcode_parse_atts($shortcode_to_parse); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | */ |
312 | 312 | protected function _set_messages_properties() { |
313 | 313 | //should be in _extra_data |
314 | - if ( isset( $this->_extra_data['messenger'] ) ) { |
|
314 | + if (isset($this->_extra_data['messenger'])) { |
|
315 | 315 | $this->_messenger = $this->_extra_data['messenger']; |
316 | 316 | $this->_message_type = $this->_extra_data['message_type']; |
317 | 317 | $this->_context = $this->_extra_data['context']; |
@@ -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 | /** |
@@ -42,25 +42,25 @@ discard block |
||
42 | 42 | $this->_shortcodes = array( |
43 | 43 | '[TXN_ID]' => __('The transaction id for the purchase.', 'event_espresso'), |
44 | 44 | '[PAYMENT_URL]' => __('This is a link to make a payment for the event', 'event_espresso'), |
45 | - '[PAYMENT_LINK_IF_NEEDED_*]' => __('This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso') . '<ul>' |
|
46 | - . '<li>' . sprintf( __('%class:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
47 | - . '<li>' . sprintf( __('%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
48 | - . '<li>' . sprintf( __('%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
45 | + '[PAYMENT_LINK_IF_NEEDED_*]' => __('This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso').'<ul>' |
|
46 | + . '<li>'.sprintf(__('%class:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
47 | + . '<li>'.sprintf(__('%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
48 | + . '<li>'.sprintf(__('%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
49 | 49 | . '</ul>', |
50 | - '[PAYMENT_DUE_DATE_*]' => __( 'This is a special dynamic shortcode that allows one to output a payment due date. It will only result in a date shown if there is money owing. Three parameters are available on this shortcode:', 'event_espresso' ) |
|
50 | + '[PAYMENT_DUE_DATE_*]' => __('This is a special dynamic shortcode that allows one to output a payment due date. It will only result in a date shown if there is money owing. Three parameters are available on this shortcode:', 'event_espresso') |
|
51 | 51 | . '<ul>' |
52 | - . '<li>' . sprintf( __( '%sformat:%s This is used to indicate what format the date is in. Default is whatever is set as date formats for your website.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
53 | - . '<li>' . sprintf( __( '%days_until_due:%s This is the number of days form the transaction creation date that the payment is due. Defaults to 30.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
54 | - . '<li>' . sprintf( __( '%sprefix_text:%s You can use this to indicate what text will prefix the date string. Defaults to "Payment in full due by:"', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>', |
|
52 | + . '<li>'.sprintf(__('%sformat:%s This is used to indicate what format the date is in. Default is whatever is set as date formats for your website.', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
53 | + . '<li>'.sprintf(__('%days_until_due:%s This is the number of days form the transaction creation date that the payment is due. Defaults to 30.', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
54 | + . '<li>'.sprintf(__('%sprefix_text:%s You can use this to indicate what text will prefix the date string. Defaults to "Payment in full due by:"', 'event_espresso'), '<strong>', '</strong>').'</li>', |
|
55 | 55 | '[INVOICE_LINK]' => __('This is a full html link to the invoice', 'event_espresso'), |
56 | 56 | '[INVOICE_URL]' => __('This is just the url for the invoice', 'event_espresso'), |
57 | 57 | '[INVOICE_LOGO_URL]' => __('This returns the url for the logo uploaded via the invoice settings page.', 'event_espresso'), |
58 | 58 | '[INVOICE_LOGO]' => __('This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.', 'event_espresso'), |
59 | 59 | '[INVOICE_PAYEE_NAME]' => __('This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
60 | - '[INVOICE_PAYEE_ADDRESS]' => __('This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ), |
|
61 | - '[INVOICE_PAYMENT_INSTRUCTIONS]' => __('This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso' ), |
|
62 | - '[INVOICE_PAYEE_EMAIL]' => __('This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ), |
|
63 | - '[INVOICE_PAYEE_TAX_NUMBER_*]' => __('This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: <code>[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]</code> and that will ouptut: GST: 12345t56. If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso' ), |
|
60 | + '[INVOICE_PAYEE_ADDRESS]' => __('This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
|
61 | + '[INVOICE_PAYMENT_INSTRUCTIONS]' => __('This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso'), |
|
62 | + '[INVOICE_PAYEE_EMAIL]' => __('This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
|
63 | + '[INVOICE_PAYEE_TAX_NUMBER_*]' => __('This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: <code>[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]</code> and that will ouptut: GST: 12345t56. If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso'), |
|
64 | 64 | '[TOTAL_COST]' => __('The total cost for the transaction', 'event_espresso'), |
65 | 65 | '[TXN_STATUS]' => __('The transaction status for the transaction.', 'event_espresso'), |
66 | 66 | '[TXN_STATUS_ID]' => __('The ID representing the transaction status as saved in the db. This tends to be useful for including with css classes for styling certain statuses differently from others.', 'event_espresso'), |
@@ -71,52 +71,52 @@ discard block |
||
71 | 71 | '[TOTAL_OWING]' => __('The total owing on a transaction with no attributes.', 'event_espresso'), |
72 | 72 | '[TXN_SUBTOTAL]' => __('The subtotal for all txn line items.', 'event_espresso'), |
73 | 73 | '[TXN_TAX_SUBTOTAL]' => __('The subtotal for all tax line items.', 'event_espresso'), |
74 | - '[OWING_STATUS_MESSAGE_*]' => __('A dynamic shortcode for adjusting how total oweing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso') . '<p></ul>' . |
|
75 | - '<li><strong>still_owing</strong>:' . __('If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount oweing). The default is:', 'event_espresso' ) . sprintf( __( '%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' ) . '</li>' . |
|
76 | - '<li><strong>none_owing</strong>:' . __('If the transaction is paid in full, then you can indicate how this gets displayed. Note, that it defaults to just be the total oweing.', 'event_espresso') . '</li></ul></p>', |
|
74 | + '[OWING_STATUS_MESSAGE_*]' => __('A dynamic shortcode for adjusting how total oweing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso').'<p></ul>'. |
|
75 | + '<li><strong>still_owing</strong>:'.__('If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount oweing). The default is:', 'event_espresso').sprintf(__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>').'</li>'. |
|
76 | + '<li><strong>none_owing</strong>:'.__('If the transaction is paid in full, then you can indicate how this gets displayed. Note, that it defaults to just be the total oweing.', 'event_espresso').'</li></ul></p>', |
|
77 | 77 | '[TXN_TOTAL_TICKETS]' => __('The total number of all tickets purchased in a transaction', 'event_espresso'), |
78 | 78 | '[TKT_QTY_PURCHASED]' => __('The total number of all tickets purchased in a transaction. <strong>NOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.</strong>', 'event_espresso'), |
79 | 79 | '[TRANSACTION_ADMIN_URL]' => __('The url to the admin page for this transaction', 'event_espresso'), |
80 | 80 | '[RECEIPT_URL]' => __('This parses to the generated url for retrieving the receipt for the transaction', 'event_espresso'), |
81 | - '[INVOICE_RECEIPT_SWITCHER_URL]' => __( 'This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active then will parse to an empty string.', 'event_espresso'), |
|
82 | - '[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf( __( 'The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso' ), '<code>', '</code>' ) |
|
81 | + '[INVOICE_RECEIPT_SWITCHER_URL]' => __('This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active then will parse to an empty string.', 'event_espresso'), |
|
82 | + '[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf(__('The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso'), '<code>', '</code>') |
|
83 | 83 | ); |
84 | 84 | } |
85 | 85 | |
86 | 86 | |
87 | - protected function _parser( $shortcode ) { |
|
87 | + protected function _parser($shortcode) { |
|
88 | 88 | |
89 | 89 | //attempt to get the transaction. Since this is potentially used in more fields, we may have to look in the _extra_data for the transaction. |
90 | 90 | $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null; |
91 | - $transaction = ! $transaction instanceof EE_Transaction && is_array( $this->_extra_data ) && isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn: $transaction; |
|
91 | + $transaction = ! $transaction instanceof EE_Transaction && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn : $transaction; |
|
92 | 92 | |
93 | 93 | //payment |
94 | 94 | $payment = $this->_data->payment instanceof EE_Payment ? $this->_data->payment : null; |
95 | - $payment = ! $payment instanceof EE_Payment && is_array( $this->_extra_data ) && isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment: $payment; |
|
95 | + $payment = ! $payment instanceof EE_Payment && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment : $payment; |
|
96 | 96 | |
97 | 97 | |
98 | - if ( ! $transaction instanceof EE_Transaction ) |
|
98 | + if ( ! $transaction instanceof EE_Transaction) |
|
99 | 99 | return ''; |
100 | 100 | |
101 | - switch ( $shortcode ) { |
|
101 | + switch ($shortcode) { |
|
102 | 102 | case '[TXN_ID]' : |
103 | 103 | return $transaction->ID(); |
104 | 104 | break; |
105 | 105 | |
106 | 106 | case '[PAYMENT_URL]' : |
107 | 107 | $payment_url = $transaction->payment_overview_url(); |
108 | - return empty( $payment_url ) ? __( 'http://dummypaymenturlforpreview.com', 'event_espresso') : $payment_url; |
|
108 | + return empty($payment_url) ? __('http://dummypaymenturlforpreview.com', 'event_espresso') : $payment_url; |
|
109 | 109 | break; |
110 | 110 | |
111 | 111 | case '[INVOICE_LINK]' : |
112 | 112 | $invoice_url = $transaction->invoice_url(); |
113 | - $invoice_url = empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
114 | - return sprintf( __('%sClick here for Invoice%s', 'event_espresso'), '<a href="' . $invoice_url . '">', '</a>' ); |
|
113 | + $invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
114 | + return sprintf(__('%sClick here for Invoice%s', 'event_espresso'), '<a href="'.$invoice_url.'">', '</a>'); |
|
115 | 115 | break; /**/ |
116 | 116 | |
117 | 117 | case '[INVOICE_URL]' : |
118 | 118 | $invoice_url = $transaction->invoice_url(); |
119 | - return empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
119 | + return empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
120 | 120 | break; |
121 | 121 | |
122 | 122 | case '[INVOICE_LOGO_URL]' : |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | break; |
125 | 125 | |
126 | 126 | case '[INVOICE_LOGO]' : |
127 | - return $this->_get_invoice_logo( TRUE ); |
|
127 | + return $this->_get_invoice_logo(TRUE); |
|
128 | 128 | break; |
129 | 129 | |
130 | 130 | case '[INVOICE_PAYEE_NAME]' : |
@@ -146,18 +146,18 @@ discard block |
||
146 | 146 | |
147 | 147 | case "[TOTAL_COST]" : |
148 | 148 | $total = $transaction->total(); |
149 | - return ! empty($total) ? EEH_Template::format_currency( $total ) : ''; |
|
149 | + return ! empty($total) ? EEH_Template::format_currency($total) : ''; |
|
150 | 150 | break; |
151 | 151 | |
152 | 152 | case "[PAYMENT_STATUS]" : |
153 | 153 | $status = $transaction->pretty_status(); |
154 | - return !empty($status) ? $status : __('Unknown', 'event_espresso'); |
|
154 | + return ! empty($status) ? $status : __('Unknown', 'event_espresso'); |
|
155 | 155 | break; /**/ |
156 | 156 | |
157 | 157 | // note the [payment_status] shortcode is kind of misleading because payment status might be different from txn status so I'm adding this here for clarity. |
158 | 158 | case "[TXN_STATUS]" : |
159 | 159 | $status = $transaction->pretty_status(); |
160 | - return !empty( $status ) ? $status : __('Unknown', 'event_espresso'); |
|
160 | + return ! empty($status) ? $status : __('Unknown', 'event_espresso'); |
|
161 | 161 | break; |
162 | 162 | |
163 | 163 | case "[TXN_STATUS_ID]" : |
@@ -165,21 +165,21 @@ discard block |
||
165 | 165 | break; |
166 | 166 | |
167 | 167 | case "[PAYMENT_GATEWAY]" : |
168 | - return $this->_get_payment_gateway( $transaction ); |
|
168 | + return $this->_get_payment_gateway($transaction); |
|
169 | 169 | break; |
170 | 170 | |
171 | 171 | case "[AMOUNT_PAID]" : |
172 | 172 | $amount = $payment instanceof EE_Payment ? $payment->amount() : 0; |
173 | - return EEH_Template::format_currency( $amount ); |
|
173 | + return EEH_Template::format_currency($amount); |
|
174 | 174 | break; |
175 | 175 | |
176 | 176 | case "[TOTAL_AMOUNT_PAID]" : |
177 | - return EEH_Template::format_currency( $transaction->paid() ); |
|
177 | + return EEH_Template::format_currency($transaction->paid()); |
|
178 | 178 | break; |
179 | 179 | |
180 | 180 | case "[TOTAL_OWING]" : |
181 | 181 | $total_owing = $transaction->remaining(); |
182 | - return EEH_Template::format_currency( $total_owing ); |
|
182 | + return EEH_Template::format_currency($total_owing); |
|
183 | 183 | break; |
184 | 184 | |
185 | 185 | case "[TXN_SUBTOTAL]" : |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | break; |
188 | 188 | |
189 | 189 | case "[TXN_TAX_SUBTOTAL]" : |
190 | - return EEH_Template::format_currency($this->_get_subtotal( TRUE )); |
|
190 | + return EEH_Template::format_currency($this->_get_subtotal(TRUE)); |
|
191 | 191 | break; |
192 | 192 | |
193 | 193 | case "[TKT_QTY_PURCHASED]" : |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | break; |
197 | 197 | |
198 | 198 | case "[TRANSACTION_ADMIN_URL]" : |
199 | - require_once EE_CORE . 'admin/EE_Admin_Page.core.php'; |
|
200 | - $query_args = array( 'page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID() ); |
|
201 | - $url = EE_Admin_Page::add_query_args_and_nonce( $query_args, admin_url('admin.php') ); |
|
199 | + require_once EE_CORE.'admin/EE_Admin_Page.core.php'; |
|
200 | + $query_args = array('page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID()); |
|
201 | + $url = EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php')); |
|
202 | 202 | return $url; |
203 | 203 | break; |
204 | 204 | |
@@ -206,14 +206,14 @@ discard block |
||
206 | 206 | //get primary_registration |
207 | 207 | $reg = $this->_data->primary_reg_obj; |
208 | 208 | |
209 | - if ( ! $reg instanceof EE_Registration ) { |
|
209 | + if ( ! $reg instanceof EE_Registration) { |
|
210 | 210 | return ''; |
211 | 211 | } |
212 | 212 | return $reg->receipt_url(); |
213 | 213 | break; |
214 | 214 | |
215 | 215 | case "[INVOICE_RECEIPT_SWITCHER_URL]" : |
216 | - return $this->_get_invoice_receipt_switcher( FALSE ); |
|
216 | + return $this->_get_invoice_receipt_switcher(FALSE); |
|
217 | 217 | break; |
218 | 218 | |
219 | 219 | case "[INVOICE_RECEIPT_SWITCHER_BUTTON]" : |
@@ -223,20 +223,20 @@ discard block |
||
223 | 223 | |
224 | 224 | } |
225 | 225 | |
226 | - if ( strpos( $shortcode, '[OWING_STATUS_MESSAGE_*' ) !== FALSE ) { |
|
227 | - return $this->_get_custom_total_oweing( $shortcode ); |
|
226 | + if (strpos($shortcode, '[OWING_STATUS_MESSAGE_*') !== FALSE) { |
|
227 | + return $this->_get_custom_total_oweing($shortcode); |
|
228 | 228 | } |
229 | 229 | |
230 | - if ( strpos( $shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*' ) !== FALSE ) { |
|
231 | - return $this->_get_invoice_payee_tax_number( $shortcode ); |
|
230 | + if (strpos($shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*') !== FALSE) { |
|
231 | + return $this->_get_invoice_payee_tax_number($shortcode); |
|
232 | 232 | } |
233 | 233 | |
234 | - if ( strpos( $shortcode, '[PAYMENT_LINK_IF_NEEDED_*' ) !== FALSE ) { |
|
235 | - return $this->_get_payment_link_if_needed( $shortcode ); |
|
234 | + if (strpos($shortcode, '[PAYMENT_LINK_IF_NEEDED_*') !== FALSE) { |
|
235 | + return $this->_get_payment_link_if_needed($shortcode); |
|
236 | 236 | } |
237 | 237 | |
238 | - if ( strpos( $shortcode, '[PAYMENT_DUE_DATE_*' ) !== false ) { |
|
239 | - return $this->_get_payment_due_date( $shortcode, $transaction ); |
|
238 | + if (strpos($shortcode, '[PAYMENT_DUE_DATE_*') !== false) { |
|
239 | + return $this->_get_payment_due_date($shortcode, $transaction); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | return ''; |
@@ -253,22 +253,22 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return string parsed. |
255 | 255 | */ |
256 | - private function _get_custom_total_oweing( $shortcode ) { |
|
257 | - $valid_shortcodes = array( 'transaction' ); |
|
258 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
256 | + private function _get_custom_total_oweing($shortcode) { |
|
257 | + $valid_shortcodes = array('transaction'); |
|
258 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
259 | 259 | |
260 | 260 | //ensure default is set. |
261 | 261 | $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
262 | 262 | $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0; |
263 | 263 | |
264 | - if ( $total_owing > 0 ) { |
|
265 | - $owing_content = ! empty( $attrs['still_owing'] ) ? $attrs['still_owing'] : sprintf( __( '%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' ); |
|
264 | + if ($total_owing > 0) { |
|
265 | + $owing_content = ! empty($attrs['still_owing']) ? $attrs['still_owing'] : sprintf(__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>'); |
|
266 | 266 | |
267 | 267 | //we need to re run this string through the parser to catch any shortcodes that are in it. |
268 | 268 | $this->_set_shortcode_helper(); |
269 | - $owing_content = $this->_shortcode_helper->parse_message_template( $owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_context, $this->_GRP_ID ); |
|
269 | + $owing_content = $this->_shortcode_helper->parse_message_template($owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_context, $this->_GRP_ID); |
|
270 | 270 | } else { |
271 | - $owing_content = !empty( $attrs['none_owing']) ? $attrs['none_owing'] : ''; |
|
271 | + $owing_content = ! empty($attrs['none_owing']) ? $attrs['none_owing'] : ''; |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | return $owing_content; |
@@ -276,8 +276,8 @@ discard block |
||
276 | 276 | |
277 | 277 | |
278 | 278 | |
279 | - private function _get_payment_gateway( $transaction ) { |
|
280 | - $pm = $this->_get_payment_method( $transaction ); |
|
279 | + private function _get_payment_gateway($transaction) { |
|
280 | + $pm = $this->_get_payment_method($transaction); |
|
281 | 281 | return $pm instanceof EE_Payment_Method ? $pm->name() : ''; |
282 | 282 | } |
283 | 283 | |
@@ -292,37 +292,37 @@ discard block |
||
292 | 292 | * |
293 | 293 | * @return string url or html |
294 | 294 | */ |
295 | - private function _get_invoice_logo( $img_tags = FALSE ) { |
|
295 | + private function _get_invoice_logo($img_tags = FALSE) { |
|
296 | 296 | //try to get the invoice payment method's logo for this transaction image first |
297 | 297 | $pm = $this->_get_payment_method(); |
298 | - if ( $pm instanceof EE_Payment_Method ){ |
|
299 | - $invoice_logo_url = $pm->get_extra_meta( 'pdf_logo_image', TRUE ); |
|
300 | - }else{ |
|
298 | + if ($pm instanceof EE_Payment_Method) { |
|
299 | + $invoice_logo_url = $pm->get_extra_meta('pdf_logo_image', TRUE); |
|
300 | + } else { |
|
301 | 301 | $invoice_logo_url = NULL; |
302 | 302 | } |
303 | - if( empty( $invoice_logo_url ) ){ |
|
303 | + if (empty($invoice_logo_url)) { |
|
304 | 304 | $invoice_logo_url = EE_Registry::instance()->CFG->organization->logo_url; |
305 | 305 | } |
306 | 306 | |
307 | - if ( empty( $invoice_logo_url ) ) { |
|
307 | + if (empty($invoice_logo_url)) { |
|
308 | 308 | return ''; |
309 | 309 | } |
310 | 310 | |
311 | - if ( ! $img_tags ) { |
|
311 | + if ( ! $img_tags) { |
|
312 | 312 | return $invoice_logo_url; |
313 | 313 | } |
314 | 314 | |
315 | 315 | //image tags have been requested. |
316 | - $image_size = getimagesize( $invoice_logo_url ); |
|
316 | + $image_size = getimagesize($invoice_logo_url); |
|
317 | 317 | |
318 | 318 | //if image is wider than 200px, set the wideth to 200 |
319 | - if ( $image_size[0] > 300 ) { |
|
319 | + if ($image_size[0] > 300) { |
|
320 | 320 | $image_width = 300; |
321 | - }else{ |
|
321 | + } else { |
|
322 | 322 | $image_width = $image_size[0]; |
323 | 323 | } |
324 | 324 | |
325 | - return '<img class="logo screen" src="' . $invoice_logo_url . '" width="' . $image_width . '" alt="logo" />'; |
|
325 | + return '<img class="logo screen" src="'.$invoice_logo_url.'" width="'.$image_width.'" alt="logo" />'; |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | |
@@ -339,26 +339,26 @@ discard block |
||
339 | 339 | private function _get_invoice_payee_name() { |
340 | 340 | $payee_name = NULL; |
341 | 341 | $pm = $this->_get_payment_method(); |
342 | - if( $pm instanceof EE_Payment_Method ){ |
|
343 | - $payee_name = $pm->get_extra_meta( 'pdf_payee_name', TRUE ); |
|
342 | + if ($pm instanceof EE_Payment_Method) { |
|
343 | + $payee_name = $pm->get_extra_meta('pdf_payee_name', TRUE); |
|
344 | 344 | } |
345 | - $payee_name = empty( $payee_name ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) : $payee_name; |
|
345 | + $payee_name = empty($payee_name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : $payee_name; |
|
346 | 346 | return $payee_name; |
347 | 347 | } |
348 | 348 | |
349 | 349 | /** |
350 | 350 | * gets the payment method for this transaction. Otherwise gets a default one. |
351 | 351 | */ |
352 | - private function _get_payment_method( $transaction = null ){ |
|
353 | - if( $transaction instanceof EE_Transaction ) { |
|
352 | + private function _get_payment_method($transaction = null) { |
|
353 | + if ($transaction instanceof EE_Transaction) { |
|
354 | 354 | $payment_method = $transaction->payment_method(); |
355 | - if ( empty( $payment_method ) ) { |
|
356 | - return apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
355 | + if (empty($payment_method)) { |
|
356 | + return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
357 | 357 | } |
358 | 358 | return $payment_method; |
359 | - }else{ |
|
359 | + } else { |
|
360 | 360 | //get the first payment method we can find |
361 | - return apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
361 | + return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
362 | 362 | } |
363 | 363 | } |
364 | 364 | |
@@ -375,10 +375,10 @@ discard block |
||
375 | 375 | private function _get_invoice_payee_email() { |
376 | 376 | $payee_email = NULL; |
377 | 377 | $pm = $this->_get_payment_method(); |
378 | - if( $pm instanceof EE_Payment_Method ){ |
|
379 | - $payee_email = $pm->get_extra_meta( 'pdf_payee_email', TRUE ); |
|
378 | + if ($pm instanceof EE_Payment_Method) { |
|
379 | + $payee_email = $pm->get_extra_meta('pdf_payee_email', TRUE); |
|
380 | 380 | } |
381 | - $payee_email = empty( $payee_email ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) : $payee_email; |
|
381 | + $payee_email = empty($payee_email) ? EE_Registry::instance()->CFG->organization->get_pretty('email') : $payee_email; |
|
382 | 382 | return $payee_email; |
383 | 383 | } |
384 | 384 | |
@@ -394,24 +394,24 @@ discard block |
||
394 | 394 | * |
395 | 395 | * @return string |
396 | 396 | */ |
397 | - private function _get_invoice_payee_tax_number( $shortcode ) { |
|
397 | + private function _get_invoice_payee_tax_number($shortcode) { |
|
398 | 398 | $payee_tax_number = NULL; |
399 | 399 | $pm = $this->_get_payment_method(); |
400 | - if( $pm instanceof EE_Payment_Method ){ |
|
401 | - $payee_tax_number = $pm->get_extra_meta( 'pdf_payee_tax_number', TRUE ); |
|
400 | + if ($pm instanceof EE_Payment_Method) { |
|
401 | + $payee_tax_number = $pm->get_extra_meta('pdf_payee_tax_number', TRUE); |
|
402 | 402 | } |
403 | - $payee_tax_number = empty( $payee_tax_number ) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number; |
|
403 | + $payee_tax_number = empty($payee_tax_number) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number; |
|
404 | 404 | |
405 | - if ( empty( $payee_tax_number ) ) { |
|
405 | + if (empty($payee_tax_number)) { |
|
406 | 406 | return ''; |
407 | 407 | } |
408 | 408 | |
409 | 409 | //any attributes? |
410 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
410 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
411 | 411 | |
412 | 412 | //prefix? |
413 | - $prefix = isset( $attrs['prefix'] ) ? $attrs['prefix'] : __( 'VAT/Tax Number: ', 'event_espresso' ); |
|
414 | - return $prefix . $payee_tax_number; |
|
413 | + $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : __('VAT/Tax Number: ', 'event_espresso'); |
|
414 | + return $prefix.$payee_tax_number; |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | |
@@ -428,22 +428,22 @@ discard block |
||
428 | 428 | private function _get_invoice_payee_address() { |
429 | 429 | $payee_address = NULL; |
430 | 430 | $pm = $this->_get_payment_method(); |
431 | - if( $pm instanceof EE_Payment_Method ){ |
|
432 | - $payee_address = $pm->get_extra_meta( 'pdf_payee_address', TRUE ); |
|
431 | + if ($pm instanceof EE_Payment_Method) { |
|
432 | + $payee_address = $pm->get_extra_meta('pdf_payee_address', TRUE); |
|
433 | 433 | } |
434 | - if ( empty( $payee_address ) ) { |
|
434 | + if (empty($payee_address)) { |
|
435 | 435 | $organization = EE_Registry::instance()->CFG->organization; |
436 | - $payee_address = $organization->get_pretty( 'address_1' ) . '<br>'; |
|
437 | - $payee_address .= !empty( $organization->address_2 ) ? $organization->get_pretty( 'address_2' ) . '<br>' : ''; |
|
438 | - $payee_address .= $organization->get_pretty( 'city' ) . '<br>'; |
|
436 | + $payee_address = $organization->get_pretty('address_1').'<br>'; |
|
437 | + $payee_address .= ! empty($organization->address_2) ? $organization->get_pretty('address_2').'<br>' : ''; |
|
438 | + $payee_address .= $organization->get_pretty('city').'<br>'; |
|
439 | 439 | |
440 | 440 | //state |
441 | - $state = EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $organization->STA_ID ); |
|
442 | - $payee_address .= $state instanceof EE_State ? $state->name() : ''; |
|
441 | + $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID); |
|
442 | + $payee_address .= $state instanceof EE_State ? $state->name() : ''; |
|
443 | 443 | |
444 | 444 | //Country |
445 | - $payee_address .= ! empty( $organization->CNT_ISO ) ? ', ' . $organization->CNT_ISO . '<br>' : ''; |
|
446 | - $payee_address .= ! empty( $organization->zip ) ? $organization->zip : ''; |
|
445 | + $payee_address .= ! empty($organization->CNT_ISO) ? ', '.$organization->CNT_ISO.'<br>' : ''; |
|
446 | + $payee_address .= ! empty($organization->zip) ? $organization->zip : ''; |
|
447 | 447 | } |
448 | 448 | return $payee_address; |
449 | 449 | } |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | private function _get_invoice_payment_instructions() { |
462 | 462 | $instructions = NULL; |
463 | 463 | $pm = $this->_get_payment_method(); |
464 | - return ( $pm instanceof EE_Payment_Method ) ? $pm->get_extra_meta( 'pdf_instructions', TRUE) : ''; |
|
464 | + return ($pm instanceof EE_Payment_Method) ? $pm->get_extra_meta('pdf_instructions', TRUE) : ''; |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | |
@@ -475,27 +475,27 @@ discard block |
||
475 | 475 | * |
476 | 476 | * @return string |
477 | 477 | */ |
478 | - protected function _get_invoice_receipt_switcher( $button = TRUE ) { |
|
478 | + protected function _get_invoice_receipt_switcher($button = TRUE) { |
|
479 | 479 | $reg = $this->_data->primary_reg_obj; |
480 | - $message_type = isset( $this->_extra_data['message_type'] ) ? $this->_extra_data['message_type'] : ''; |
|
481 | - if ( ! $reg instanceof EE_Registration || empty( $message_type ) ) { |
|
480 | + $message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : ''; |
|
481 | + if ( ! $reg instanceof EE_Registration || empty($message_type)) { |
|
482 | 482 | return''; |
483 | 483 | } |
484 | 484 | |
485 | - $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false; |
|
486 | - $switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? __('View Invoice', 'event_espresso' ) : __( 'Switch to Invoice', 'event_espresso' ); |
|
487 | - $switch_to_label = ! $switch_to_invoice ? __( 'Switch to Receipt', 'event_espresso' ) : $switch_to_label; |
|
485 | + $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false; |
|
486 | + $switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? __('View Invoice', 'event_espresso') : __('Switch to Invoice', 'event_espresso'); |
|
487 | + $switch_to_label = ! $switch_to_invoice ? __('Switch to Receipt', 'event_espresso') : $switch_to_label; |
|
488 | 488 | $switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url(); |
489 | 489 | |
490 | - if ( ! $button ) { |
|
490 | + if ( ! $button) { |
|
491 | 491 | return $switch_to_url; |
492 | 492 | } |
493 | 493 | |
494 | - if ( ! empty( $switch_to_url ) ) { |
|
494 | + if ( ! empty($switch_to_url)) { |
|
495 | 495 | |
496 | 496 | return ' |
497 | -<form method="post" action="' . $switch_to_url . '" > |
|
498 | - <input class="print_button" type="submit" value="' . $switch_to_label . '" /> |
|
497 | +<form method="post" action="' . $switch_to_url.'" > |
|
498 | + <input class="print_button" type="submit" value="' . $switch_to_label.'" /> |
|
499 | 499 | </form> |
500 | 500 | '; |
501 | 501 | } |
@@ -515,11 +515,11 @@ discard block |
||
515 | 515 | * |
516 | 516 | * @return string |
517 | 517 | */ |
518 | - private function _get_receipt_url( EE_Transaction $transaction ) { |
|
518 | + private function _get_receipt_url(EE_Transaction $transaction) { |
|
519 | 519 | //get primary_registration |
520 | 520 | $reg = $this->_data->primary_reg_obj; |
521 | 521 | |
522 | - if ( ! $reg instanceof EE_Registration ) { |
|
522 | + if ( ! $reg instanceof EE_Registration) { |
|
523 | 523 | return ''; |
524 | 524 | } |
525 | 525 | |
@@ -535,10 +535,10 @@ discard block |
||
535 | 535 | * |
536 | 536 | * @return int |
537 | 537 | */ |
538 | - private function _get_subtotal( $tax = FALSE ) { |
|
539 | - $grand_total = isset( $this->_data->grand_total_line_item ) ? $this->_data->grand_total_line_item : NULL; |
|
538 | + private function _get_subtotal($tax = FALSE) { |
|
539 | + $grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : NULL; |
|
540 | 540 | |
541 | - if ( ! $grand_total instanceof EE_Line_Item ) { |
|
541 | + if ( ! $grand_total instanceof EE_Line_Item) { |
|
542 | 542 | return 0; |
543 | 543 | } |
544 | 544 | |
@@ -557,27 +557,27 @@ discard block |
||
557 | 557 | * |
558 | 558 | * @return string parsed. |
559 | 559 | */ |
560 | - private function _get_payment_link_if_needed( $shortcode ) { |
|
561 | - $valid_shortcodes = array( 'transaction' ); |
|
562 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
560 | + private function _get_payment_link_if_needed($shortcode) { |
|
561 | + $valid_shortcodes = array('transaction'); |
|
562 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
563 | 563 | |
564 | 564 | //ensure default is set. |
565 | 565 | $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
566 | 566 | $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0; |
567 | 567 | |
568 | - if ( $total_owing > 0 ) { |
|
569 | - $class = isset( $attrs['class'] ) ? $attrs['class'] : 'callout'; |
|
570 | - $custom_text = isset( $attrs['custom_text'] ) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.'; |
|
571 | - $container_tag = isset( $attrs['container_tag'] ) ? $attrs['container_tag'] : 'p'; |
|
572 | - $opening_tag = ! empty( $container_tag ) ? '<' . $container_tag : ''; |
|
573 | - $opening_tag .= ! empty( $opening_tag ) && !empty( $class ) ? ' class="' . $class . '"' : $opening_tag; |
|
574 | - $opening_tag .= !empty( $opening_tag ) ? '>' : $opening_tag; |
|
575 | - $closing_tag = ! empty( $container_tag ) ? '</' . $container_tag .'>' : ''; |
|
576 | - $content = $opening_tag . sprintf( $custom_text, '<a href="[PAYMENT_URL]">', '</a>' ) . $closing_tag; |
|
568 | + if ($total_owing > 0) { |
|
569 | + $class = isset($attrs['class']) ? $attrs['class'] : 'callout'; |
|
570 | + $custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.'; |
|
571 | + $container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p'; |
|
572 | + $opening_tag = ! empty($container_tag) ? '<'.$container_tag : ''; |
|
573 | + $opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="'.$class.'"' : $opening_tag; |
|
574 | + $opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag; |
|
575 | + $closing_tag = ! empty($container_tag) ? '</'.$container_tag.'>' : ''; |
|
576 | + $content = $opening_tag.sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>').$closing_tag; |
|
577 | 577 | |
578 | 578 | //we need to re run this string through the parser to catch any shortcodes that are in it. |
579 | 579 | $this->_set_shortcode_helper(); |
580 | - $owing_content = $this->_shortcode_helper->parse_message_template( $content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_context, $this->_GRP_ID ); |
|
580 | + $owing_content = $this->_shortcode_helper->parse_message_template($content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_context, $this->_GRP_ID); |
|
581 | 581 | } else { |
582 | 582 | return ''; |
583 | 583 | } |
@@ -597,31 +597,31 @@ discard block |
||
597 | 597 | * @param EE_Transaction $transaction |
598 | 598 | * @return string |
599 | 599 | */ |
600 | - protected function _get_payment_due_date( $shortcode, EE_Transaction $transaction ) { |
|
600 | + protected function _get_payment_due_date($shortcode, EE_Transaction $transaction) { |
|
601 | 601 | //if transaction is paid in full then we can just return an empty string |
602 | - if ( $transaction->remaining() === 0 ) { |
|
602 | + if ($transaction->remaining() === 0) { |
|
603 | 603 | return ''; |
604 | 604 | } |
605 | 605 | |
606 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
607 | - $format = isset( $attrs['format'] ) ? $attrs['format'] : get_option( 'date_format' ); |
|
608 | - $days_until_due = isset( $attrs['days_until_due'] ) ? (int) $attrs['days_until_due'] : 30; |
|
609 | - $prefix_text = isset( $attrs['prefix_text'] ) ? $attrs['prefix_text'] : __( 'Payment in full due by: ', 'event_espresso' ); |
|
610 | - $transaction_created = $transaction->get_DateTime_object( 'TXN_timestamp' ); |
|
606 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
607 | + $format = isset($attrs['format']) ? $attrs['format'] : get_option('date_format'); |
|
608 | + $days_until_due = isset($attrs['days_until_due']) ? (int) $attrs['days_until_due'] : 30; |
|
609 | + $prefix_text = isset($attrs['prefix_text']) ? $attrs['prefix_text'] : __('Payment in full due by: ', 'event_espresso'); |
|
610 | + $transaction_created = $transaction->get_DateTime_object('TXN_timestamp'); |
|
611 | 611 | |
612 | 612 | //setup date due: |
613 | 613 | try { |
614 | - if ( $transaction_created instanceof DateTime ) { |
|
615 | - $date_due = $transaction_created->add( new DateInterval( 'P' . $days_until_due . 'D' ) )->format( $format ); |
|
614 | + if ($transaction_created instanceof DateTime) { |
|
615 | + $date_due = $transaction_created->add(new DateInterval('P'.$days_until_due.'D'))->format($format); |
|
616 | 616 | } else { |
617 | 617 | throw new Exception(); |
618 | 618 | } |
619 | - } catch( Exception $e ) { |
|
619 | + } catch (Exception $e) { |
|
620 | 620 | //format was likely invalid. |
621 | 621 | $date_due = 'Unable to calculate date due, likely the format string is invalid.'; |
622 | 622 | } |
623 | 623 | |
624 | - return $prefix_text . $date_due; |
|
624 | + return $prefix_text.$date_due; |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | } //end EE_Transaction Shortcodes library |
@@ -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 | /** |
@@ -55,33 +55,33 @@ discard block |
||
55 | 55 | '[EVENT_NAME]' => __("This also can be used for the name of the event", 'event_espresso'), |
56 | 56 | '[EVENT_PHONE]' => __('The phone number for the event (usually an info number)', 'event_espresso'), |
57 | 57 | '[EVENT_DESCRIPTION]' => __('The description of the event', 'event_espresso'), |
58 | - '[EVENT_EXCERPT]' => __( 'This gets parsed to the value for the excerpt field in the event or blank if there is no excerpt.', 'event_espresso' ), |
|
58 | + '[EVENT_EXCERPT]' => __('This gets parsed to the value for the excerpt field in the event or blank if there is no excerpt.', 'event_espresso'), |
|
59 | 59 | '[EVENT_LINK]' => __('A link associated with the event', 'event_espresso'), |
60 | 60 | '[EVENT_URL]' => __('A link to the event set up on the host site.', 'event_espresso'), |
61 | 61 | '[VIRTUAL_URL]' => __('What was used for the "URL of Event" field in the Venue settings', 'event_espresso'), |
62 | 62 | '[VIRTUAL_PHONE]' => __('An alternate phone number for the event. Typically used as a "call-in" number', 'event_espresso'), |
63 | 63 | '[EVENT_IMAGE]' => __('This will parse to the Feature image for the event.', 'event_espresso'), |
64 | 64 | '[EVENT_TOTAL_AVAILABLE_SPACES_*]' => sprintf( |
65 | - __( 'This will parse to the total available spaces for an event. Calculating total spaces is approximate because it is dependent on the complexity of limits on your event. There are two methods of calculation (which can be indicated by the %1$smethod%2$s param on the shortcode). %1$scurrent%2$s which will do a more accurate calculation of total available spaces based on current sales, and %1$sfull%2$s which will be the maximum total available spaces that is on the event in optimal conditions. The shortcode will default to current.', 'event_espresso' ), |
|
65 | + __('This will parse to the total available spaces for an event. Calculating total spaces is approximate because it is dependent on the complexity of limits on your event. There are two methods of calculation (which can be indicated by the %1$smethod%2$s param on the shortcode). %1$scurrent%2$s which will do a more accurate calculation of total available spaces based on current sales, and %1$sfull%2$s which will be the maximum total available spaces that is on the event in optimal conditions. The shortcode will default to current.', 'event_espresso'), |
|
66 | 66 | '<code>', |
67 | 67 | '</code>' |
68 | 68 | ), |
69 | - '[EVENT_TOTAL_SPOTS_TAKEN]' => __( 'This shortcode will parse to the output the total approved registrations for this event', 'event_espresso' ), |
|
69 | + '[EVENT_TOTAL_SPOTS_TAKEN]' => __('This shortcode will parse to the output the total approved registrations for this event', 'event_espresso'), |
|
70 | 70 | '[EVENT_FACEBOOK_URL]' => __('This will return the Facebook URL for the event if you have it set via custom field in your event, otherwise it will use the Facebook URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_facebook</code> and the value as your facebook url.', 'event_espresso'), |
71 | 71 | '[EVENT_TWITTER_URL]' => __('This will return the Twitter URL for the event if you have it set via custom field in your event, otherwise it will use the Twitter URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_twitter</code> and the value as your facebook url', 'event_espresso'), |
72 | 72 | '[EVENT_META_*]' => __('This is a special dynamic shortcode. After the "*", add the exact name for your custom field, if there is a value set for that custom field within the event then it will be output in place of this shortcode.', 'event_espresso'), |
73 | - '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' => __( 'This parses to the url for the registration list table filtered by registrations for this event.', 'event_espresso' ), |
|
73 | + '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' => __('This parses to the url for the registration list table filtered by registrations for this event.', 'event_espresso'), |
|
74 | 74 | ); |
75 | 75 | } |
76 | 76 | |
77 | 77 | |
78 | - protected function _parser( $shortcode ) { |
|
78 | + protected function _parser($shortcode) { |
|
79 | 79 | |
80 | 80 | |
81 | 81 | $this->_event = $this->_data instanceof EE_Event ? $this->_data : null; |
82 | 82 | |
83 | 83 | //if no event, then let's see if there is a reg_obj. If there IS, then we'll try and grab the event from the reg_obj instead. |
84 | - if ( empty( $this->_event ) ) { |
|
84 | + if (empty($this->_event)) { |
|
85 | 85 | $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : NULL; |
86 | 86 | $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee; |
87 | 87 | |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | |
91 | 91 | |
92 | 92 | //If there is no event objecdt by now then get out. |
93 | - if ( ! $this->_event instanceof EE_Event ) |
|
93 | + if ( ! $this->_event instanceof EE_Event) |
|
94 | 94 | return ''; |
95 | 95 | |
96 | - switch ( $shortcode ) { |
|
96 | + switch ($shortcode) { |
|
97 | 97 | |
98 | 98 | case '[EVENT_ID]' : |
99 | 99 | return $this->_event->ID(); |
@@ -126,41 +126,41 @@ discard block |
||
126 | 126 | |
127 | 127 | case '[VIRTUAL_URL]' : |
128 | 128 | $venue = $this->_event->get_first_related('Venue'); |
129 | - if ( empty( $venue ) ) |
|
129 | + if (empty($venue)) |
|
130 | 130 | return ''; |
131 | 131 | return $venue->get('VNU_virtual_url'); |
132 | 132 | |
133 | 133 | case '[VIRTUAL_PHONE]' : |
134 | 134 | $venue = $this->_event->get_first_related('Venue'); |
135 | - if ( empty( $venue ) ) |
|
135 | + if (empty($venue)) |
|
136 | 136 | return ''; |
137 | 137 | return $venue->get('VNU_virtual_phone'); |
138 | 138 | break; |
139 | 139 | |
140 | 140 | case '[EVENT_IMAGE]' : |
141 | - $image = $this->_event->feature_image_url(array(600,300) ); |
|
141 | + $image = $this->_event->feature_image_url(array(600, 300)); |
|
142 | 142 | // @todo: eventually we should make this an attribute shortcode so that em can send along what size they want returned. |
143 | - return !empty( $image ) ? '<img src="' . $image . '" alt="' . sprintf( esc_attr__( '%s Feature Image', 'event_espresso'), $this->_event->get('EVT_name') ) . '" />' : ''; |
|
143 | + return ! empty($image) ? '<img src="'.$image.'" alt="'.sprintf(esc_attr__('%s Feature Image', 'event_espresso'), $this->_event->get('EVT_name')).'" />' : ''; |
|
144 | 144 | break; |
145 | 145 | |
146 | 146 | case '[EVENT_FACEBOOK_URL]' : |
147 | - $facebook_url = $this->_event->get_post_meta('event_facebook', true ); |
|
148 | - return empty( $facebook_url ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ) : $facebook_url; |
|
147 | + $facebook_url = $this->_event->get_post_meta('event_facebook', true); |
|
148 | + return empty($facebook_url) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook') : $facebook_url; |
|
149 | 149 | break; |
150 | 150 | |
151 | 151 | case '[EVENT_TWITTER_URL]' : |
152 | 152 | $twitter_url = $this->_event->get_post_meta('event_twitter', true); |
153 | - return empty( $twitter_url ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ) : $twitter_url; |
|
153 | + return empty($twitter_url) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter') : $twitter_url; |
|
154 | 154 | break; |
155 | 155 | |
156 | 156 | case '[EVENT_AUTHOR_EMAIL]' : |
157 | 157 | $author_id = $this->_event->get('EVT_wp_user'); |
158 | - $user_data = get_userdata( (int) $author_id ); |
|
158 | + $user_data = get_userdata((int) $author_id); |
|
159 | 159 | return $user_data->user_email; |
160 | 160 | break; |
161 | 161 | |
162 | 162 | case '[EVENT_TOTAL_SPOTS_TAKEN]' : |
163 | - return EEM_Registration::instance()->count( array( array( 'EVT_ID' => $this->_event->ID(), 'STS_ID' => EEM_Registration::status_id_approved ) ), 'REG_ID', true ); |
|
163 | + return EEM_Registration::instance()->count(array(array('EVT_ID' => $this->_event->ID(), 'STS_ID' => EEM_Registration::status_id_approved)), 'REG_ID', true); |
|
164 | 164 | break; |
165 | 165 | |
166 | 166 | case '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' : |
@@ -170,26 +170,26 @@ discard block |
||
170 | 170 | 'page' => 'espresso_registrations', |
171 | 171 | 'action' => 'default' |
172 | 172 | ), |
173 | - admin_url( 'admin.php' ), |
|
173 | + admin_url('admin.php'), |
|
174 | 174 | true |
175 | 175 | ); |
176 | 176 | break; |
177 | 177 | } |
178 | 178 | |
179 | - if ( strpos( $shortcode, '[EVENT_META_*' ) !== false ) { |
|
180 | - $shortcode = str_replace( '[EVENT_META_*', '', $shortcode ); |
|
181 | - $shortcode = trim( str_replace( ']', '', $shortcode ) ); |
|
179 | + if (strpos($shortcode, '[EVENT_META_*') !== false) { |
|
180 | + $shortcode = str_replace('[EVENT_META_*', '', $shortcode); |
|
181 | + $shortcode = trim(str_replace(']', '', $shortcode)); |
|
182 | 182 | |
183 | 183 | //pull the meta value from the event post |
184 | - $event_meta = $this->_event->get_post_meta( $shortcode, true ); |
|
184 | + $event_meta = $this->_event->get_post_meta($shortcode, true); |
|
185 | 185 | |
186 | - return !empty( $event_meta ) ? $this->_event->get_post_meta( $shortcode, true ) : ''; |
|
186 | + return ! empty($event_meta) ? $this->_event->get_post_meta($shortcode, true) : ''; |
|
187 | 187 | |
188 | 188 | } |
189 | 189 | |
190 | - if ( strpos( $shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*' ) !== false ) { |
|
191 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
192 | - $method = empty( $attrs['method'] ) ? 'current' : $attrs['method']; |
|
190 | + if (strpos($shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*') !== false) { |
|
191 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
192 | + $method = empty($attrs['method']) ? 'current' : $attrs['method']; |
|
193 | 193 | $method = $method === 'current'; |
194 | 194 | $available = $this->_event->total_available_spaces($method); |
195 | 195 | return $available === EE_INF ? '∞' : $available; |
@@ -205,10 +205,10 @@ discard block |
||
205 | 205 | * @param boolean $full_link if TRUE (default) we return the html for the name of the event linked to the event. Otherwise we just return the url of the event. |
206 | 206 | * @return string |
207 | 207 | */ |
208 | - private function _get_event_link( $event, $full_link = TRUE ) { |
|
208 | + private function _get_event_link($event, $full_link = TRUE) { |
|
209 | 209 | $url = get_permalink($event->ID()); |
210 | 210 | |
211 | - return $full_link ? '<a href="' . $url . '">' . $event->get('EVT_name') . '</a>' : $url; |
|
211 | + return $full_link ? '<a href="'.$url.'">'.$event->get('EVT_name').'</a>' : $url; |
|
212 | 212 | } |
213 | 213 | |
214 | 214 |