@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | |
252 | 252 | /** |
253 | 253 | * Returns whether the given message type is active for the given messenger. |
254 | - * @param $messenger_name |
|
254 | + * @param string $messenger_name |
|
255 | 255 | * @param $message_type_name |
256 | 256 | * |
257 | 257 | * @return bool |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | * |
368 | 368 | * @param EE_Messenger $messenger |
369 | 369 | * @param string $message_type_name |
370 | - * @return array |
|
370 | + * @return boolean |
|
371 | 371 | * @throws \EE_Error |
372 | 372 | */ |
373 | 373 | public function valid_message_type_for_messenger( EE_Messenger $messenger, $message_type_name ) { |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | * messenger are active in one go. |
556 | 556 | * |
557 | 557 | * @param $message_type_names Array of message type names to ensure are active. |
558 | - * @param $messenger_name The name of the messenger that the message types are to be activated on. |
|
558 | + * @param string $messenger_name The name of the messenger that the message types are to be activated on. |
|
559 | 559 | * @param bool $update_option Whether to persist the activation to the database or not (default true). |
560 | 560 | * @return array |
561 | 561 | */ |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $this->_message_type_collection_loader->load_message_types_from_folder(); |
125 | 125 | $this->_message_template_group_model = $Message_Template_Group_Model; |
126 | 126 | $this->_set_active_messengers_and_message_types(); |
127 | - $this->get_has_activated_messengers_option( true ); |
|
127 | + $this->get_has_activated_messengers_option(true); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | * @param string $messenger_name |
152 | 152 | * @return \EE_Messenger |
153 | 153 | */ |
154 | - public function get_messenger( $messenger_name ) { |
|
155 | - return $this->messenger_collection()->get_by_info( $messenger_name ); |
|
154 | + public function get_messenger($messenger_name) { |
|
155 | + return $this->messenger_collection()->get_by_info($messenger_name); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | * @param string $messenger |
164 | 164 | * @return EE_Messenger | null |
165 | 165 | */ |
166 | - public function get_active_messenger( $messenger ) { |
|
167 | - return ! empty( $this->_active_messengers[ $messenger ] ) ? $this->_active_messengers[ $messenger ] : null; |
|
166 | + public function get_active_messenger($messenger) { |
|
167 | + return ! empty($this->_active_messengers[$messenger]) ? $this->_active_messengers[$messenger] : null; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | |
@@ -173,11 +173,11 @@ discard block |
||
173 | 173 | * @return \EE_Messenger[] |
174 | 174 | */ |
175 | 175 | public function installed_messengers() { |
176 | - if ( empty( $this->_installed_messengers ) ) { |
|
176 | + if (empty($this->_installed_messengers)) { |
|
177 | 177 | $this->_installed_messengers = array(); |
178 | 178 | $this->messenger_collection()->rewind(); |
179 | - while ( $this->messenger_collection()->valid() ) { |
|
180 | - $this->_installed_messengers[ $this->messenger_collection()->current()->name ] = $this->messenger_collection()->current(); |
|
179 | + while ($this->messenger_collection()->valid()) { |
|
180 | + $this->_installed_messengers[$this->messenger_collection()->current()->name] = $this->messenger_collection()->current(); |
|
181 | 181 | $this->messenger_collection()->next(); |
182 | 182 | } |
183 | 183 | } |
@@ -191,14 +191,14 @@ discard block |
||
191 | 191 | * @return \EE_Messenger |
192 | 192 | * @throws \EE_Error |
193 | 193 | */ |
194 | - public function valid_messenger( $messenger_name ) { |
|
195 | - $messenger = $this->get_messenger( $messenger_name ); |
|
196 | - if ( $messenger instanceof EE_Messenger ) { |
|
194 | + public function valid_messenger($messenger_name) { |
|
195 | + $messenger = $this->get_messenger($messenger_name); |
|
196 | + if ($messenger instanceof EE_Messenger) { |
|
197 | 197 | return $messenger; |
198 | 198 | } |
199 | 199 | throw new EE_Error( |
200 | 200 | sprintf( |
201 | - __( 'The "%1$s" messenger is either invalid or not installed', 'event_espresso' ), |
|
201 | + __('The "%1$s" messenger is either invalid or not installed', 'event_espresso'), |
|
202 | 202 | $messenger_name |
203 | 203 | ) |
204 | 204 | ); |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | * @param string $message_type_name |
229 | 229 | * @return \EE_Message_Type |
230 | 230 | */ |
231 | - public function get_message_type( $message_type_name ) { |
|
232 | - return $this->message_type_collection()->get_by_info( $message_type_name ); |
|
231 | + public function get_message_type($message_type_name) { |
|
232 | + return $this->message_type_collection()->get_by_info($message_type_name); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | * @param string $message_type_name |
242 | 242 | * @return \EE_Message_Type|null |
243 | 243 | */ |
244 | - public function get_active_message_type_for_messenger( $messenger_name, $message_type_name ) { |
|
245 | - return $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) |
|
246 | - ? $this->get_message_type( $message_type_name ) |
|
244 | + public function get_active_message_type_for_messenger($messenger_name, $message_type_name) { |
|
245 | + return $this->is_message_type_active_for_messenger($messenger_name, $message_type_name) |
|
246 | + ? $this->get_message_type($message_type_name) |
|
247 | 247 | : null; |
248 | 248 | } |
249 | 249 | |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | * |
257 | 257 | * @return bool |
258 | 258 | */ |
259 | - public function is_message_type_active_for_messenger( $messenger_name, $message_type_name ) { |
|
260 | - return ! empty( $this->_active_message_types[ $messenger_name ]['settings'][$messenger_name . '-message_types'][ $message_type_name ] ); |
|
259 | + public function is_message_type_active_for_messenger($messenger_name, $message_type_name) { |
|
260 | + return ! empty($this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | |
@@ -270,15 +270,15 @@ discard block |
||
270 | 270 | * @param string $messenger_name The messenger being checked |
271 | 271 | * @return EE_message_type[] (or empty array if none present) |
272 | 272 | */ |
273 | - public function get_active_message_types_for_messenger( $messenger_name ) { |
|
273 | + public function get_active_message_types_for_messenger($messenger_name) { |
|
274 | 274 | $message_types = array(); |
275 | - if ( empty( $this->_active_message_types[ $messenger_name ] ) ) { |
|
275 | + if (empty($this->_active_message_types[$messenger_name])) { |
|
276 | 276 | return $message_types; |
277 | 277 | } |
278 | 278 | $installed_message_types = $this->installed_message_types(); |
279 | - foreach ( $installed_message_types as $message_type_name => $message_type ) { |
|
280 | - if ( $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
|
281 | - $message_types[ $message_type_name ] = $message_type; |
|
279 | + foreach ($installed_message_types as $message_type_name => $message_type) { |
|
280 | + if ($this->is_message_type_active_for_messenger($messenger_name, $message_type_name)) { |
|
281 | + $message_types[$message_type_name] = $message_type; |
|
282 | 282 | } |
283 | 283 | } |
284 | 284 | return $message_types; |
@@ -295,9 +295,9 @@ discard block |
||
295 | 295 | */ |
296 | 296 | public function list_of_active_message_types() { |
297 | 297 | $active_message_type_names = array(); |
298 | - foreach ( $this->_active_message_types as $messenger => $messenger_settings ) { |
|
299 | - foreach ( $messenger_settings[ $messenger . '-message_types' ] as $message_type_name => $message_type_config ) { |
|
300 | - if ( ! in_array( $message_type_name, $active_message_type_names ) ) { |
|
298 | + foreach ($this->_active_message_types as $messenger => $messenger_settings) { |
|
299 | + foreach ($messenger_settings[$messenger.'-message_types'] as $message_type_name => $message_type_config) { |
|
300 | + if ( ! in_array($message_type_name, $active_message_type_names)) { |
|
301 | 301 | $active_message_type_names[] = $message_type_name; |
302 | 302 | } |
303 | 303 | } |
@@ -317,9 +317,9 @@ discard block |
||
317 | 317 | $active_message_types = array(); |
318 | 318 | $installed_message_types = $this->installed_message_types(); |
319 | 319 | $active_message_type_names = $this->list_of_active_message_types(); |
320 | - foreach ( $active_message_type_names as $active_message_type_name ) { |
|
321 | - if ( isset( $installed_message_types[ $active_message_type_name ] ) ) { |
|
322 | - $active_message_types[ $active_message_type_name ] = $installed_message_types[ $active_message_type_name ]; |
|
320 | + foreach ($active_message_type_names as $active_message_type_name) { |
|
321 | + if (isset($installed_message_types[$active_message_type_name])) { |
|
322 | + $active_message_types[$active_message_type_name] = $installed_message_types[$active_message_type_name]; |
|
323 | 323 | } |
324 | 324 | } |
325 | 325 | return $active_message_types; |
@@ -331,10 +331,10 @@ discard block |
||
331 | 331 | * @return \EE_Message_Type[] |
332 | 332 | */ |
333 | 333 | public function installed_message_types() { |
334 | - if ( empty( $this->_installed_message_types ) ) { |
|
334 | + if (empty($this->_installed_message_types)) { |
|
335 | 335 | $this->message_type_collection()->rewind(); |
336 | - while ( $this->message_type_collection()->valid() ) { |
|
337 | - $this->_installed_message_types[ $this->message_type_collection()->current()->name ] = $this->message_type_collection()->current(); |
|
336 | + while ($this->message_type_collection()->valid()) { |
|
337 | + $this->_installed_message_types[$this->message_type_collection()->current()->name] = $this->message_type_collection()->current(); |
|
338 | 338 | $this->message_type_collection()->next(); |
339 | 339 | } |
340 | 340 | } |
@@ -347,14 +347,14 @@ discard block |
||
347 | 347 | * @return \EE_message_type |
348 | 348 | * @throws \EE_Error |
349 | 349 | */ |
350 | - public function valid_message_type( $message_type_name ) { |
|
351 | - $message_type = $this->get_message_type( $message_type_name ); |
|
352 | - if ( $message_type instanceof EE_message_type ) { |
|
350 | + public function valid_message_type($message_type_name) { |
|
351 | + $message_type = $this->get_message_type($message_type_name); |
|
352 | + if ($message_type instanceof EE_message_type) { |
|
353 | 353 | return $message_type; |
354 | 354 | } |
355 | 355 | throw new EE_Error( |
356 | 356 | sprintf( |
357 | - __( 'The "%1$s" message type is either invalid or not installed', 'event_espresso' ), |
|
357 | + __('The "%1$s" message type is either invalid or not installed', 'event_espresso'), |
|
358 | 358 | $message_type_name |
359 | 359 | ) |
360 | 360 | ); |
@@ -370,9 +370,9 @@ discard block |
||
370 | 370 | * @return array |
371 | 371 | * @throws \EE_Error |
372 | 372 | */ |
373 | - public function valid_message_type_for_messenger( EE_Messenger $messenger, $message_type_name ) { |
|
373 | + public function valid_message_type_for_messenger(EE_Messenger $messenger, $message_type_name) { |
|
374 | 374 | $valid_message_types = $messenger->get_valid_message_types(); |
375 | - if ( ! in_array( $message_type_name, $valid_message_types ) ) { |
|
375 | + if ( ! in_array($message_type_name, $valid_message_types)) { |
|
376 | 376 | throw new EE_Error( |
377 | 377 | sprintf( |
378 | 378 | __( |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | * @return array |
397 | 397 | */ |
398 | 398 | public function get_active_messengers_option() { |
399 | - return get_option( 'ee_active_messengers', array() ); |
|
399 | + return get_option('ee_active_messengers', array()); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | |
@@ -408,9 +408,9 @@ discard block |
||
408 | 408 | * representing this data is used. |
409 | 409 | * @return bool FALSE if not updated, TRUE if updated. |
410 | 410 | */ |
411 | - public function update_active_messengers_option( $active_messengers = array() ) { |
|
412 | - $active_messengers = empty( $active_messengers ) ? $this->_active_message_types : $active_messengers; |
|
413 | - return update_option( 'ee_active_messengers', $active_messengers ); |
|
411 | + public function update_active_messengers_option($active_messengers = array()) { |
|
412 | + $active_messengers = empty($active_messengers) ? $this->_active_message_types : $active_messengers; |
|
413 | + return update_option('ee_active_messengers', $active_messengers); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | |
@@ -425,9 +425,9 @@ discard block |
||
425 | 425 | * |
426 | 426 | * @return array |
427 | 427 | */ |
428 | - public function get_has_activated_messengers_option( $reset = false ) { |
|
429 | - if ( $reset ) { |
|
430 | - $this->_has_activated_messengers_and_message_types = get_option( 'ee_has_activated_messenger', array() ); |
|
428 | + public function get_has_activated_messengers_option($reset = false) { |
|
429 | + if ($reset) { |
|
430 | + $this->_has_activated_messengers_and_message_types = get_option('ee_has_activated_messenger', array()); |
|
431 | 431 | } |
432 | 432 | return $this->_has_activated_messengers_and_message_types; |
433 | 433 | } |
@@ -442,9 +442,9 @@ discard block |
||
442 | 442 | * |
443 | 443 | * @return bool FALSE if not updated, TRUE if updated. |
444 | 444 | */ |
445 | - public function update_has_activated_messengers_option( $has_activated_messengers = array() ) { |
|
446 | - $has_activated_messengers = empty( $has_activated_messengers ) ? $this->_has_activated_messengers_and_message_types : $has_activated_messengers; |
|
447 | - return update_option( 'ee_has_activated_messenger', $has_activated_messengers ); |
|
445 | + public function update_has_activated_messengers_option($has_activated_messengers = array()) { |
|
446 | + $has_activated_messengers = empty($has_activated_messengers) ? $this->_has_activated_messengers_and_message_types : $has_activated_messengers; |
|
447 | + return update_option('ee_has_activated_messenger', $has_activated_messengers); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | |
@@ -466,14 +466,14 @@ discard block |
||
466 | 466 | //echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() \n"; |
467 | 467 | // list of activated messengers as set via the admin |
468 | 468 | $active_messengers = $this->get_active_messengers_option(); |
469 | - $active_messengers = is_array( $active_messengers ) ? $active_messengers : array( $active_messengers ); |
|
469 | + $active_messengers = is_array($active_messengers) ? $active_messengers : array($active_messengers); |
|
470 | 470 | //echo "\n active_messengers: \n"; |
471 | 471 | //var_dump( $active_messengers ); |
472 | 472 | $not_installed = array(); |
473 | - foreach ( $active_messengers as $active_messenger => $data ) { |
|
473 | + foreach ($active_messengers as $active_messenger => $data) { |
|
474 | 474 | // check if supposedly active messenger is actually installed by looking in our collection |
475 | - if ( $this->messenger_collection()->has_by_name( $active_messenger ) ) { |
|
476 | - $this->activate_messenger( $active_messenger, array(), false ); |
|
475 | + if ($this->messenger_collection()->has_by_name($active_messenger)) { |
|
476 | + $this->activate_messenger($active_messenger, array(), false); |
|
477 | 477 | // grab installed messenger object |
478 | 478 | //$this->_active_messengers[ $active_messenger ] = $this->messenger_collection()->get_by_info( |
479 | 479 | // $active_messenger |
@@ -484,15 +484,15 @@ discard block |
||
484 | 484 | // : array(); |
485 | 485 | } else { |
486 | 486 | $not_installed[] = $active_messenger; |
487 | - $this->deactivate_messenger( $active_messenger ); |
|
487 | + $this->deactivate_messenger($active_messenger); |
|
488 | 488 | } |
489 | 489 | } |
490 | - if ( ! empty( $not_installed ) ) { |
|
490 | + if ( ! empty($not_installed)) { |
|
491 | 491 | EE_Error::add_error( |
492 | 492 | sprintf( |
493 | - __( 'The following messengers are either not installed or are invalid:%1$s %2$s', 'event_espresso' ), |
|
493 | + __('The following messengers are either not installed or are invalid:%1$s %2$s', 'event_espresso'), |
|
494 | 494 | '<br />', |
495 | - implode( ', ', $not_installed ) |
|
495 | + implode(', ', $not_installed) |
|
496 | 496 | ), |
497 | 497 | __FILE__, __FUNCTION__, __LINE__ |
498 | 498 | ); |
@@ -509,9 +509,9 @@ discard block |
||
509 | 509 | * @param bool $update_option Whether to update the option in the db or not. |
510 | 510 | * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive |
511 | 511 | */ |
512 | - public function ensure_messenger_is_active( $messenger_name, $update_option = true ) { |
|
513 | - if ( ! isset( $this->_active_messengers[ $messenger_name ] ) ) { |
|
514 | - $this->activate_messenger( $messenger_name, array(), $update_option ); |
|
512 | + public function ensure_messenger_is_active($messenger_name, $update_option = true) { |
|
513 | + if ( ! isset($this->_active_messengers[$messenger_name])) { |
|
514 | + $this->activate_messenger($messenger_name, array(), $update_option); |
|
515 | 515 | return false; |
516 | 516 | } |
517 | 517 | return true; |
@@ -529,17 +529,17 @@ discard block |
||
529 | 529 | * @return array |
530 | 530 | * @throws \EE_Error |
531 | 531 | */ |
532 | - public function ensure_message_type_is_active( $message_type_name, $messenger_name, $update_option = true ) { |
|
532 | + public function ensure_message_type_is_active($message_type_name, $messenger_name, $update_option = true) { |
|
533 | 533 | // grab the messenger to work with. |
534 | - $messenger = $this->valid_messenger( $messenger_name ); |
|
535 | - if ( $this->valid_message_type_for_messenger( $messenger, $message_type_name ) ) { |
|
534 | + $messenger = $this->valid_messenger($messenger_name); |
|
535 | + if ($this->valid_message_type_for_messenger($messenger, $message_type_name)) { |
|
536 | 536 | //ensure messenger is active (that's an inherent coupling between active message types and the |
537 | 537 | //messenger they are being activated for. Note option is not being updated here because that gets handled later |
538 | 538 | //in this method. |
539 | - $this->ensure_messenger_is_active( $messenger_name, false ); |
|
539 | + $this->ensure_messenger_is_active($messenger_name, false); |
|
540 | 540 | //all is good so let's just get it active |
541 | - $this->_activate_message_types( $messenger, array( $message_type_name ) ); |
|
542 | - if ( $update_option ) { |
|
541 | + $this->_activate_message_types($messenger, array($message_type_name)); |
|
542 | + if ($update_option) { |
|
543 | 543 | $this->update_active_messengers_option(); |
544 | 544 | $this->update_has_activated_messengers_option(); |
545 | 545 | } |
@@ -559,14 +559,14 @@ discard block |
||
559 | 559 | * @param bool $update_option Whether to persist the activation to the database or not (default true). |
560 | 560 | * @return array |
561 | 561 | */ |
562 | - public function ensure_message_types_are_active( $message_type_names, $messenger_name, $update_option = true ) { |
|
562 | + public function ensure_message_types_are_active($message_type_names, $messenger_name, $update_option = true) { |
|
563 | 563 | $message_type_names = (array) $message_type_names; |
564 | - foreach ( $message_type_names as $message_type_name ) { |
|
564 | + foreach ($message_type_names as $message_type_name) { |
|
565 | 565 | //note, intentionally not updating option here because we're in a loop. We'll follow the instructions of the |
566 | 566 | //incoming $update_option argument after the loop. |
567 | - $this->ensure_message_type_is_active( $message_type_name, $messenger_name, false ); |
|
567 | + $this->ensure_message_type_is_active($message_type_name, $messenger_name, false); |
|
568 | 568 | } |
569 | - if ( $update_option ) { |
|
569 | + if ($update_option) { |
|
570 | 570 | $this->update_active_messengers_option(); |
571 | 571 | $this->update_has_activated_messengers_option(); |
572 | 572 | } |
@@ -594,22 +594,22 @@ discard block |
||
594 | 594 | //EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__ ); |
595 | 595 | $templates = array(); |
596 | 596 | // grab the messenger to work with. |
597 | - $messenger = $this->messenger_collection()->get_by_info( $messenger_name ); |
|
597 | + $messenger = $this->messenger_collection()->get_by_info($messenger_name); |
|
598 | 598 | // it's inactive. Activate it. |
599 | - if ( $messenger instanceof EE_Messenger ) { |
|
599 | + if ($messenger instanceof EE_Messenger) { |
|
600 | 600 | //EEH_Debug_Tools::printr( $messenger->name, 'activate_messenger', __FILE__, __LINE__ ); |
601 | - $this->_active_messengers[ $messenger->name ] = $messenger; |
|
601 | + $this->_active_messengers[$messenger->name] = $messenger; |
|
602 | 602 | // setup any initial settings for the messenger |
603 | - $this->_add_settings_for_messenger( $messenger ); |
|
603 | + $this->_add_settings_for_messenger($messenger); |
|
604 | 604 | //activate incoming message types set to be activated with messenger. |
605 | - $message_type_names = $this->_activate_message_types( $messenger, $message_type_names ); |
|
606 | - if ( $update_active_messengers_option ) { |
|
605 | + $message_type_names = $this->_activate_message_types($messenger, $message_type_names); |
|
606 | + if ($update_active_messengers_option) { |
|
607 | 607 | $this->update_active_messengers_option(); |
608 | 608 | $this->update_has_activated_messengers_option(); |
609 | 609 | } |
610 | 610 | // might need to generate new templates |
611 | - if ( ! empty( $message_type_names ) ) { |
|
612 | - $templates = EEH_MSG_Template::generate_new_templates( $messenger->name, $message_type_names, 0, true ); |
|
611 | + if ( ! empty($message_type_names)) { |
|
612 | + $templates = EEH_MSG_Template::generate_new_templates($messenger->name, $message_type_names, 0, true); |
|
613 | 613 | } |
614 | 614 | } |
615 | 615 | return $templates; |
@@ -628,16 +628,16 @@ discard block |
||
628 | 628 | * |
629 | 629 | * @return array |
630 | 630 | */ |
631 | - protected function _activate_message_types( EE_Messenger $messenger, $message_type_names = array() ) { |
|
631 | + protected function _activate_message_types(EE_Messenger $messenger, $message_type_names = array()) { |
|
632 | 632 | //EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__ ); |
633 | 633 | // use incoming list of message types or if that's empty, then get defaults |
634 | - $message_type_names = ! empty( $message_type_names ) |
|
634 | + $message_type_names = ! empty($message_type_names) |
|
635 | 635 | ? $message_type_names |
636 | 636 | : $messenger->get_default_message_types(); |
637 | 637 | // cycle thru message types |
638 | - foreach ( $message_type_names as $message_type_name ) { |
|
638 | + foreach ($message_type_names as $message_type_name) { |
|
639 | 639 | //EEH_Debug_Tools::printr( $message_type_name, '$message_type_name', __FILE__, __LINE__ ); |
640 | - $this->_add_settings_for_message_type( $messenger, $message_type_name ); |
|
640 | + $this->_add_settings_for_message_type($messenger, $message_type_name); |
|
641 | 641 | $this->_set_messenger_has_activated_message_type( |
642 | 642 | $messenger, |
643 | 643 | $message_type_name |
@@ -655,18 +655,18 @@ discard block |
||
655 | 655 | * @param \EE_Messenger $messenger |
656 | 656 | * @param string $message_type_name |
657 | 657 | */ |
658 | - protected function _add_settings_for_message_type( EE_Messenger $messenger, $message_type_name ) { |
|
658 | + protected function _add_settings_for_message_type(EE_Messenger $messenger, $message_type_name) { |
|
659 | 659 | $settings = array(); |
660 | 660 | // get installed message type from collection |
661 | - $message_type = $this->message_type_collection()->get_by_info( $message_type_name ); |
|
661 | + $message_type = $this->message_type_collection()->get_by_info($message_type_name); |
|
662 | 662 | //we need to setup any initial settings for message types |
663 | - if ( $message_type instanceof EE_Message_Type ) { |
|
663 | + if ($message_type instanceof EE_Message_Type) { |
|
664 | 664 | $settings_fields = $message_type->get_admin_settings_fields(); |
665 | - foreach ( $settings_fields as $field => $values ) { |
|
666 | - $settings[ $field ] = $values[ 'default' ]; |
|
665 | + foreach ($settings_fields as $field => $values) { |
|
666 | + $settings[$field] = $values['default']; |
|
667 | 667 | } |
668 | 668 | } |
669 | - $this->_active_message_types[ $messenger->name ][ 'settings' ][ $messenger->name . '-message_types' ][ $message_type_name ][ 'settings' ] = $settings; |
|
669 | + $this->_active_message_types[$messenger->name]['settings'][$messenger->name.'-message_types'][$message_type_name]['settings'] = $settings; |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | |
@@ -679,14 +679,14 @@ discard block |
||
679 | 679 | * @param \EE_Messenger $messenger |
680 | 680 | * @param string $message_type_name |
681 | 681 | */ |
682 | - protected function _set_messenger_has_activated_message_type( EE_Messenger $messenger, $message_type_name ) { |
|
682 | + protected function _set_messenger_has_activated_message_type(EE_Messenger $messenger, $message_type_name) { |
|
683 | 683 | // make sure this messenger has a record in the has_activated array |
684 | - if ( ! isset( $this->_has_activated_messengers_and_message_types[ $messenger->name ] ) ) { |
|
685 | - $this->_has_activated_messengers_and_message_types[ $messenger->name ] = array(); |
|
684 | + if ( ! isset($this->_has_activated_messengers_and_message_types[$messenger->name])) { |
|
685 | + $this->_has_activated_messengers_and_message_types[$messenger->name] = array(); |
|
686 | 686 | } |
687 | 687 | // check if message type has already been added |
688 | - if ( ! in_array( $message_type_name, $this->_has_activated_messengers_and_message_types[ $messenger->name ] ) ) { |
|
689 | - $this->_has_activated_messengers_and_message_types[ $messenger->name ][] = $message_type_name; |
|
688 | + if ( ! in_array($message_type_name, $this->_has_activated_messengers_and_message_types[$messenger->name])) { |
|
689 | + $this->_has_activated_messengers_and_message_types[$messenger->name][] = $message_type_name; |
|
690 | 690 | } |
691 | 691 | } |
692 | 692 | |
@@ -698,11 +698,11 @@ discard block |
||
698 | 698 | * @access protected |
699 | 699 | * @param \EE_Messenger $messenger |
700 | 700 | */ |
701 | - protected function _add_settings_for_messenger( EE_Messenger $messenger ) { |
|
701 | + protected function _add_settings_for_messenger(EE_Messenger $messenger) { |
|
702 | 702 | $msgr_settings = $messenger->get_admin_settings_fields(); |
703 | - if ( ! empty( $msgr_settings ) ) { |
|
704 | - foreach ( $msgr_settings as $field => $value ) { |
|
705 | - $this->_active_message_types[ $messenger->name ][ 'settings' ][ $field ] = $value; |
|
703 | + if ( ! empty($msgr_settings)) { |
|
704 | + foreach ($msgr_settings as $field => $value) { |
|
705 | + $this->_active_message_types[$messenger->name]['settings'][$field] = $value; |
|
706 | 706 | } |
707 | 707 | } |
708 | 708 | } |
@@ -715,14 +715,14 @@ discard block |
||
715 | 715 | * @param string $messenger_name name of messenger |
716 | 716 | * @return void |
717 | 717 | */ |
718 | - public function deactivate_messenger( $messenger_name ) { |
|
719 | - if ( $messenger_name instanceof EE_Messenger ) { |
|
718 | + public function deactivate_messenger($messenger_name) { |
|
719 | + if ($messenger_name instanceof EE_Messenger) { |
|
720 | 720 | $messenger_name = $messenger_name->name; |
721 | 721 | } |
722 | - unset( $this->_active_messengers[ $messenger_name ] ); |
|
723 | - unset( $this->_active_message_types[ $messenger_name ] ); |
|
724 | - $this->_message_template_group_model->deactivate_message_template_groups_for( $messenger_name ); |
|
725 | - $this->update_active_messengers_option( $this->_active_message_types ); |
|
722 | + unset($this->_active_messengers[$messenger_name]); |
|
723 | + unset($this->_active_message_types[$messenger_name]); |
|
724 | + $this->_message_template_group_model->deactivate_message_template_groups_for($messenger_name); |
|
725 | + $this->update_active_messengers_option($this->_active_message_types); |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | |
@@ -731,17 +731,17 @@ discard block |
||
731 | 731 | * |
732 | 732 | * @param string $message_type_name name of message type being deactivated |
733 | 733 | */ |
734 | - public function deactivate_message_type( $message_type_name ) { |
|
735 | - if ( $message_type_name instanceof EE_Message_Type ) { |
|
734 | + public function deactivate_message_type($message_type_name) { |
|
735 | + if ($message_type_name instanceof EE_Message_Type) { |
|
736 | 736 | $message_type_name = $message_type_name->name; |
737 | 737 | } |
738 | - foreach ( $this->_active_message_types as $messenger => $settings ) { |
|
738 | + foreach ($this->_active_message_types as $messenger => $settings) { |
|
739 | 739 | unset( |
740 | - $this->_active_message_types[ $messenger ][ 'settings' ][ $messenger . '-message_types' ][ $message_type_name ] |
|
740 | + $this->_active_message_types[$messenger]['settings'][$messenger.'-message_types'][$message_type_name] |
|
741 | 741 | ); |
742 | 742 | } |
743 | - $this->_message_template_group_model->deactivate_message_template_groups_for( '', $message_type_name ); |
|
744 | - $this->update_active_messengers_option( $this->_active_message_types ); |
|
743 | + $this->_message_template_group_model->deactivate_message_template_groups_for('', $message_type_name); |
|
744 | + $this->update_active_messengers_option($this->_active_message_types); |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | |
@@ -753,9 +753,9 @@ discard block |
||
753 | 753 | */ |
754 | 754 | public function activate_default_messengers_and_message_types() { |
755 | 755 | $installed_messengers = $this->installed_messengers(); |
756 | - foreach ( $installed_messengers as $messenger ) { |
|
757 | - if ( $messenger->activate_on_install ) { |
|
758 | - $this->activate_messenger( $messenger->name ); |
|
756 | + foreach ($installed_messengers as $messenger) { |
|
757 | + if ($messenger->activate_on_install) { |
|
758 | + $this->activate_messenger($messenger->name); |
|
759 | 759 | } |
760 | 760 | } |
761 | 761 | } |
@@ -771,12 +771,12 @@ discard block |
||
771 | 771 | * |
772 | 772 | * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
773 | 773 | */ |
774 | - public function is_generating_messenger_and_active( EE_Messenger $messenger, EE_message_type $message_type ) { |
|
774 | + public function is_generating_messenger_and_active(EE_Messenger $messenger, EE_message_type $message_type) { |
|
775 | 775 | //get the $messengers the message type says it can be used with. |
776 | - foreach ( $message_type->with_messengers() as $generating_messenger => $secondary_messengers ) { |
|
776 | + foreach ($message_type->with_messengers() as $generating_messenger => $secondary_messengers) { |
|
777 | 777 | if ( |
778 | 778 | $messenger->name === $generating_messenger |
779 | - && $this->is_message_type_active_for_messenger( $messenger->name, $message_type->name ) |
|
779 | + && $this->is_message_type_active_for_messenger($messenger->name, $message_type->name) |
|
780 | 780 | ) { |
781 | 781 | return true; |
782 | 782 | } |
@@ -815,25 +815,25 @@ discard block |
||
815 | 815 | * @param bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by message type. |
816 | 816 | * @return array |
817 | 817 | */ |
818 | - public function get_all_contexts( $slugs_only = true ) { |
|
818 | + public function get_all_contexts($slugs_only = true) { |
|
819 | 819 | $key = $slugs_only ? 'slugs' : 'all'; |
820 | 820 | // check if contexts has been setup yet. |
821 | - if ( empty( $this->_contexts[ $key ] ) ) { |
|
821 | + if (empty($this->_contexts[$key])) { |
|
822 | 822 | // So let's get all active message type objects and loop through to get all unique contexts |
823 | - foreach ( $this->get_active_message_type_objects() as $message_type ) { |
|
824 | - if ( $message_type instanceof EE_message_type ) { |
|
823 | + foreach ($this->get_active_message_type_objects() as $message_type) { |
|
824 | + if ($message_type instanceof EE_message_type) { |
|
825 | 825 | $message_type_contexts = $message_type->get_contexts(); |
826 | - if ( $slugs_only ) { |
|
827 | - foreach ( $message_type_contexts as $context => $context_details ) { |
|
828 | - $this->_contexts[ $key ][ $context ] = $context_details[ 'label' ]; |
|
826 | + if ($slugs_only) { |
|
827 | + foreach ($message_type_contexts as $context => $context_details) { |
|
828 | + $this->_contexts[$key][$context] = $context_details['label']; |
|
829 | 829 | } |
830 | 830 | } else { |
831 | - $this->_contexts[ $key ][ $message_type->name ] = $message_type_contexts; |
|
831 | + $this->_contexts[$key][$message_type->name] = $message_type_contexts; |
|
832 | 832 | } |
833 | 833 | } |
834 | 834 | } |
835 | 835 | } |
836 | - return ! empty( $this->_contexts[ $key ] ) ? $this->_contexts[ $key ] : array(); |
|
836 | + return ! empty($this->_contexts[$key]) ? $this->_contexts[$key] : array(); |
|
837 | 837 | } |
838 | 838 | |
839 | 839 |
@@ -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 | /** |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | $this->_mt_name = $message_type_name; |
107 | 107 | |
108 | 108 | //make sure required props have been set |
109 | - if ( empty( $this->_m_name) || empty( $this->_mt_name ) ) { |
|
109 | + if (empty($this->_m_name) || empty($this->_mt_name)) { |
|
110 | 110 | $msg[] = __('Message Templates cannot be generated because the Messenger and Message Types haven\'t been defined for the generator.', 'event_espresso'); |
111 | 111 | $msg[] = __('You need to set the "$m_name" and "$mt_name" properties', 'event_espresso'); |
112 | - throw new EE_Error( implode( '||', $msg ) ); |
|
112 | + throw new EE_Error(implode('||', $msg)); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | $this->_init(); |
@@ -125,12 +125,12 @@ discard block |
||
125 | 125 | * @param string $template_pack This corresponds to a template pack class reference which will contain information about where to obtain the templates. |
126 | 126 | * @return void |
127 | 127 | */ |
128 | - final private function _set_templates( $template_pack ) { |
|
128 | + final private function _set_templates($template_pack) { |
|
129 | 129 | |
130 | 130 | //get the corresponding template pack object (if present. If not then we just load the default and add a notice). The class name should be something like 'EE_Messages_Template_Pack_Default' where "default' would be the incoming template pack reference. |
131 | - $class_name = 'EE_Messages_Template_Pack_' . str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $template_pack ) ) ); |
|
131 | + $class_name = 'EE_Messages_Template_Pack_'.str_replace(' ', '_', ucwords(str_replace('_', ' ', $template_pack))); |
|
132 | 132 | |
133 | - if ( ! class_exists( $class_name ) ) { |
|
133 | + if ( ! class_exists($class_name)) { |
|
134 | 134 | EE_Error::add_error( |
135 | 135 | sprintf( |
136 | 136 | __( |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $template_pack = new $class_name; |
150 | 150 | |
151 | 151 | //get all the templates from the template pack. |
152 | - $this->_templates = $template_pack->get_templates( $this->_messenger, $this->_message_type ); |
|
152 | + $this->_templates = $template_pack->get_templates($this->_messenger, $this->_message_type); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $active_message_types = $this->_message_resource_manager->installed_message_types(); |
167 | 167 | |
168 | 168 | //check if messenger is active |
169 | - if ( !isset($active_messengers[$this->_m_name] ) ) { |
|
169 | + if ( ! isset($active_messengers[$this->_m_name])) { |
|
170 | 170 | $msg[] = __('Message Templates cannot be generated because the given messenger is not active', 'event_espresso'); |
171 | 171 | $msg[] = sprintf( |
172 | 172 | __( |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | ), |
176 | 176 | $this->_m_name |
177 | 177 | ); |
178 | - throw new EE_Error( implode( '||', $msg ) ); |
|
178 | + throw new EE_Error(implode('||', $msg)); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | //check if message type is installed |
182 | - if ( !isset($active_messengers[$this->_m_name] ) ) { |
|
182 | + if ( ! isset($active_messengers[$this->_m_name])) { |
|
183 | 183 | $msg[] = __( |
184 | 184 | 'Message Templates cannot be generated because the given message type is not installed', |
185 | 185 | 'event_espresso' |
@@ -191,32 +191,32 @@ discard block |
||
191 | 191 | ), |
192 | 192 | $this->_mt_name |
193 | 193 | ); |
194 | - throw new EE_Error( implode( '||', $msg ) ); |
|
194 | + throw new EE_Error(implode('||', $msg)); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | $this->_messenger = $active_messengers[$this->_m_name]; |
198 | 198 | $this->_message_type = $active_message_types[$this->_mt_name]; |
199 | 199 | |
200 | 200 | //verify we have the messenger and message type objects |
201 | - if ( ! $this->_messenger instanceof EE_Messenger ) { |
|
201 | + if ( ! $this->_messenger instanceof EE_Messenger) { |
|
202 | 202 | throw new EE_Error( |
203 | 203 | sprintf( |
204 | 204 | __( |
205 | 205 | 'The _messenger property must be an instance of EE_Messenger by this point. It isn\'t. Something has gone wrong. Here is the value it holds: %1$s', |
206 | 206 | 'event_espresso' |
207 | 207 | ), |
208 | - '<br />' . print_r( $this->_messenger, true ) |
|
208 | + '<br />'.print_r($this->_messenger, true) |
|
209 | 209 | ) |
210 | 210 | ); |
211 | 211 | } |
212 | - if ( ! $this->_message_type instanceof EE_message_type ) { |
|
212 | + if ( ! $this->_message_type instanceof EE_message_type) { |
|
213 | 213 | throw new EE_Error( |
214 | 214 | sprintf( |
215 | 215 | __( |
216 | 216 | 'The _message_type property must be an instance of EE_message_type by this point. It isn\'t. Something has gone wrong. Here is the value it holds: %1$s', |
217 | 217 | 'event_espresso' |
218 | 218 | ), |
219 | - '<br />' . print_r( $this->_message_type, true ) |
|
219 | + '<br />'.print_r($this->_message_type, true) |
|
220 | 220 | ) |
221 | 221 | ); |
222 | 222 | } |
@@ -244,13 +244,13 @@ discard block |
||
244 | 244 | public function create_new_templates() { |
245 | 245 | $template_pack = 'default'; |
246 | 246 | //if we have the GRP_ID then let's use that to see if there is a set template pack and use that for the new templates. |
247 | - if ( !empty( $this->_GRP_ID ) ) { |
|
248 | - $message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID( $this->_GRP_ID ); |
|
247 | + if ( ! empty($this->_GRP_ID)) { |
|
248 | + $message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_GRP_ID); |
|
249 | 249 | $template_pack = $message_template_group instanceof EE_Message_Template_Group ? $message_template_group->get_template_pack_name() : 'default'; |
250 | 250 | //we also need to reset the template variation to default |
251 | - $message_template_group->set_template_pack_variation( 'default' ); |
|
251 | + $message_template_group->set_template_pack_variation('default'); |
|
252 | 252 | } |
253 | - return $this->_create_new_templates( $template_pack ); |
|
253 | + return $this->_create_new_templates($template_pack); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | |
@@ -264,15 +264,15 @@ discard block |
||
264 | 264 | * which will contain information about where to obtain the templates. |
265 | 265 | * @return mixed (array|bool) success array or false. |
266 | 266 | */ |
267 | - private function _create_new_templates( $template_pack ) { |
|
267 | + private function _create_new_templates($template_pack) { |
|
268 | 268 | |
269 | - $this->_set_templates( $template_pack ); |
|
269 | + $this->_set_templates($template_pack); |
|
270 | 270 | |
271 | 271 | //necessary properties are set, let's save the default templates |
272 | 272 | |
273 | - if ( empty( $this->_GRP_ID ) ) { |
|
273 | + if (empty($this->_GRP_ID)) { |
|
274 | 274 | |
275 | - $main_template_data = array( |
|
275 | + $main_template_data = array( |
|
276 | 276 | 'MTP_messenger' => $this->_messenger->name, |
277 | 277 | 'MTP_message_type' => $this->_message_type->name, |
278 | 278 | 'MTP_is_override' => 0, |
@@ -284,23 +284,23 @@ discard block |
||
284 | 284 | |
285 | 285 | |
286 | 286 | //let's insert the above and get our GRP_ID, then reset the template data array to just include the GRP_ID |
287 | - $grp_id = $this->_EEM_data->insert( $main_template_data ); |
|
287 | + $grp_id = $this->_EEM_data->insert($main_template_data); |
|
288 | 288 | |
289 | - if ( empty( $grp_id ) ) return $grp_id; |
|
289 | + if (empty($grp_id)) return $grp_id; |
|
290 | 290 | $this->_GRP_ID = $grp_id; |
291 | 291 | } |
292 | 292 | |
293 | - $template_data = array( 'GRP_ID' => $this->_GRP_ID ); |
|
293 | + $template_data = array('GRP_ID' => $this->_GRP_ID); |
|
294 | 294 | |
295 | - foreach ( $this->_contexts as $context => $details ) { |
|
296 | - foreach ( $this->_fields as $field => $field_type ) { |
|
297 | - if ( $field != 'extra' ) { |
|
295 | + foreach ($this->_contexts as $context => $details) { |
|
296 | + foreach ($this->_fields as $field => $field_type) { |
|
297 | + if ($field != 'extra') { |
|
298 | 298 | $template_data['MTP_context'] = $context; |
299 | 299 | $template_data['MTP_template_field'] = $field; |
300 | 300 | $template_data['MTP_content'] = $this->_templates[$context][$field]; |
301 | 301 | |
302 | 302 | $MTP = EEM_Message_Template::instance()->insert($template_data); |
303 | - if ( !$MTP ) { |
|
303 | + if ( ! $MTP) { |
|
304 | 304 | EE_Error::add_error( |
305 | 305 | sprintf( |
306 | 306 | __( |
@@ -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,24 +55,24 @@ discard block |
||
55 | 55 | * @throws \EE_Error |
56 | 56 | * @return array|bool array of data required for the redirect to the correct edit page or FALSE if encountering problems. |
57 | 57 | */ |
58 | - public static function generate_new_templates( $messenger, $message_types, $GRP_ID = 0, $global = false ) { |
|
58 | + public static function generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = false) { |
|
59 | 59 | //make sure message_type is an array. |
60 | 60 | $message_types = (array) $message_types; |
61 | 61 | $templates = array(); |
62 | 62 | $success = false; |
63 | - if ( empty( $messenger ) ) { |
|
64 | - throw new EE_Error( __('We need a messenger to generate templates!', 'event_espresso') ); |
|
63 | + if (empty($messenger)) { |
|
64 | + throw new EE_Error(__('We need a messenger to generate templates!', 'event_espresso')); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | //if we STILL have empty $message_types then we need to generate an error message b/c we NEED message types to do the template files. |
68 | - if ( empty( $message_types ) ) { |
|
69 | - throw new EE_Error( __('We need at least one message type to generate templates!', 'event_espresso') ); |
|
68 | + if (empty($message_types)) { |
|
69 | + throw new EE_Error(__('We need at least one message type to generate templates!', 'event_espresso')); |
|
70 | 70 | } |
71 | 71 | EEH_MSG_Template::_set_autoloader(); |
72 | - foreach ( $message_types as $message_type ) { |
|
72 | + foreach ($message_types as $message_type) { |
|
73 | 73 | //if global then let's attempt to get the GRP_ID for this combo IF GRP_ID is empty. |
74 | - if ( $global && empty( $GRP_ID ) ) { |
|
75 | - $GRP_ID = EEM_Message_Template_Group::instance()->get_one( array( |
|
74 | + if ($global && empty($GRP_ID)) { |
|
75 | + $GRP_ID = EEM_Message_Template_Group::instance()->get_one(array( |
|
76 | 76 | array( |
77 | 77 | 'MTP_messenger' => $messenger, |
78 | 78 | 'MTP_message_type' => $message_type, |
@@ -84,16 +84,16 @@ discard block |
||
84 | 84 | // if this is global template generation. |
85 | 85 | // First let's determine if we already HAVE global templates for this messenger and message_type combination. |
86 | 86 | // If we do then NO generation!! |
87 | - if ( $global && EEH_MSG_Template::already_generated( $messenger, $message_type, $GRP_ID ) ) { |
|
87 | + if ($global && EEH_MSG_Template::already_generated($messenger, $message_type, $GRP_ID)) { |
|
88 | 88 | $templates = true; |
89 | 89 | continue; //get out we've already got generated templates for this. |
90 | 90 | } |
91 | 91 | $new_message_template_group = EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $global); |
92 | 92 | |
93 | - if ( ! $new_message_template_group ) { |
|
93 | + if ( ! $new_message_template_group) { |
|
94 | 94 | continue; |
95 | 95 | } |
96 | - if ( $templates === true ) { |
|
96 | + if ($templates === true) { |
|
97 | 97 | $templates = array(); |
98 | 98 | } |
99 | 99 | $templates[] = $new_message_template_group; |
@@ -112,10 +112,10 @@ discard block |
||
112 | 112 | * @param bool $update_to_active if true then we also toggle the template to active. |
113 | 113 | * @return bool true = generated, false = hasn't been generated. |
114 | 114 | */ |
115 | - public static function already_generated( $messenger, $message_type, $GRP_ID = 0, $update_to_active = TRUE ) { |
|
115 | + public static function already_generated($messenger, $message_type, $GRP_ID = 0, $update_to_active = TRUE) { |
|
116 | 116 | EEH_MSG_Template::_set_autoloader(); |
117 | 117 | //what method we use depends on whether we have an GRP_ID or not |
118 | - $count = empty( $GRP_ID ) |
|
118 | + $count = empty($GRP_ID) |
|
119 | 119 | ? EEM_Message_Template::instance()->count( |
120 | 120 | array( |
121 | 121 | array( |
@@ -125,13 +125,13 @@ discard block |
||
125 | 125 | ) |
126 | 126 | ) |
127 | 127 | ) |
128 | - : EEM_Message_Template::instance()->count( array( array( 'GRP_ID' => $GRP_ID ) ) ); |
|
128 | + : EEM_Message_Template::instance()->count(array(array('GRP_ID' => $GRP_ID))); |
|
129 | 129 | |
130 | - if ( $update_to_active ) { |
|
131 | - EEH_MSG_Template::update_to_active( $messenger, $message_type ); |
|
130 | + if ($update_to_active) { |
|
131 | + EEH_MSG_Template::update_to_active($messenger, $message_type); |
|
132 | 132 | } |
133 | 133 | |
134 | - return ( $count > 0 ) ? TRUE : FALSE; |
|
134 | + return ($count > 0) ? TRUE : FALSE; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | * @static |
146 | 146 | * @return int count of updated records. |
147 | 147 | */ |
148 | - public static function update_to_active( $messenger, $message_type ) { |
|
148 | + public static function update_to_active($messenger, $message_type) { |
|
149 | 149 | return EEM_Message_Template_Group::instance()->update( |
150 | - array( 'MTP_is_active' => 1 ), |
|
150 | + array('MTP_is_active' => 1), |
|
151 | 151 | array( |
152 | 152 | array( |
153 | 153 | 'MTP_messenger' => $messenger, |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * |
172 | 172 | * @return int count of updated records. |
173 | 173 | */ |
174 | - public static function update_to_inactive( $messenger = '', $message_type = '' ) { |
|
174 | + public static function update_to_inactive($messenger = '', $message_type = '') { |
|
175 | 175 | return EEM_Message_Template_Group::instance()->deactivate_message_template_groups_for( |
176 | 176 | $messenger, |
177 | 177 | $message_type |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | * @param string $type |
188 | 188 | * @return array array consisting of installed messenger objects and installed message type objects. |
189 | 189 | */ |
190 | - public static function get_installed_message_objects( $type = 'all' ) { |
|
190 | + public static function get_installed_message_objects($type = 'all') { |
|
191 | 191 | self::_set_autoloader(); |
192 | 192 | //get all installed messengers and message_types |
193 | 193 | /** @type EE_Messages $messages_controller */ |
194 | - $messages_controller = EE_Registry::instance()->load_lib( 'messages' ); |
|
194 | + $messages_controller = EE_Registry::instance()->load_lib('messages'); |
|
195 | 195 | return $messages_controller->get_installed($type); |
196 | 196 | } |
197 | 197 | |
@@ -224,38 +224,38 @@ discard block |
||
224 | 224 | $context = 'admin', |
225 | 225 | $merged = false |
226 | 226 | ) { |
227 | - $messenger_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $messenger ) ) ); |
|
228 | - $mt_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $message_type ) ) ); |
|
227 | + $messenger_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $messenger))); |
|
228 | + $mt_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $message_type))); |
|
229 | 229 | |
230 | 230 | //convert slug to object |
231 | - $messenger = self::messenger_obj( $messenger ); |
|
231 | + $messenger = self::messenger_obj($messenger); |
|
232 | 232 | |
233 | 233 | //validate class for getting our list of shortcodes |
234 | - $classname = 'EE_Messages_' . $messenger_name . '_' . $mt_name . '_Validator'; |
|
235 | - if ( !class_exists( $classname ) ) { |
|
236 | - $msg[] = __( 'The Validator class was unable to load', 'event_espresso'); |
|
234 | + $classname = 'EE_Messages_'.$messenger_name.'_'.$mt_name.'_Validator'; |
|
235 | + if ( ! class_exists($classname)) { |
|
236 | + $msg[] = __('The Validator class was unable to load', 'event_espresso'); |
|
237 | 237 | $msg[] = sprintf( |
238 | 238 | __('The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', 'event_espresso'), |
239 | 239 | $classname |
240 | 240 | ); |
241 | - throw new EE_Error( implode( '||', $msg ) ); |
|
241 | + throw new EE_Error(implode('||', $msg)); |
|
242 | 242 | } |
243 | 243 | /** @type EE_Messages_Validator $_VLD */ |
244 | - $_VLD = new $classname( array(), $context ); |
|
244 | + $_VLD = new $classname(array(), $context); |
|
245 | 245 | $valid_shortcodes = $_VLD->get_validators(); |
246 | 246 | |
247 | 247 | //let's make sure we're only getting the shortcode part of the validators |
248 | 248 | $shortcodes = array(); |
249 | - foreach( $valid_shortcodes as $field => $validators ) { |
|
249 | + foreach ($valid_shortcodes as $field => $validators) { |
|
250 | 250 | $shortcodes[$field] = $validators['shortcodes']; |
251 | 251 | } |
252 | 252 | $valid_shortcodes = $shortcodes; |
253 | 253 | |
254 | 254 | //if not all fields let's make sure we ONLY include the shortcodes for the specified fields. |
255 | - if ( ! empty( $fields ) ) { |
|
255 | + if ( ! empty($fields)) { |
|
256 | 256 | $specified_shortcodes = array(); |
257 | - foreach ( $fields as $field ) { |
|
258 | - if ( isset( $valid_shortcodes[$field] ) ) |
|
257 | + foreach ($fields as $field) { |
|
258 | + if (isset($valid_shortcodes[$field])) |
|
259 | 259 | $specified_shortcodes[$field] = $valid_shortcodes[$field]; |
260 | 260 | } |
261 | 261 | $valid_shortcodes = $specified_shortcodes; |
@@ -263,16 +263,16 @@ discard block |
||
263 | 263 | |
264 | 264 | |
265 | 265 | //if not merged then let's replace the fields with the localized fields |
266 | - if ( ! $merged ) { |
|
266 | + if ( ! $merged) { |
|
267 | 267 | //let's get all the fields for the set messenger so that we can get the localized label and use that in the returned array. |
268 | 268 | $field_settings = $messenger->get_template_fields(); |
269 | 269 | $localized = array(); |
270 | - foreach ( $valid_shortcodes as $field => $shortcodes ) { |
|
270 | + foreach ($valid_shortcodes as $field => $shortcodes) { |
|
271 | 271 | //get localized field label |
272 | - if ( isset( $field_settings[$field] ) ) { |
|
272 | + if (isset($field_settings[$field])) { |
|
273 | 273 | //possible that this is used as a main field. |
274 | - if ( empty( $field_settings[$field] ) ) { |
|
275 | - if ( isset( $field_settings['extra'][$field] ) ) { |
|
274 | + if (empty($field_settings[$field])) { |
|
275 | + if (isset($field_settings['extra'][$field])) { |
|
276 | 276 | $_field = $field_settings['extra'][$field]['main']['label']; |
277 | 277 | } else { |
278 | 278 | $_field = $field; |
@@ -280,10 +280,10 @@ discard block |
||
280 | 280 | } else { |
281 | 281 | $_field = $field_settings[$field]['label']; |
282 | 282 | } |
283 | - } else if ( isset( $field_settings['extra'] ) ) { |
|
283 | + } else if (isset($field_settings['extra'])) { |
|
284 | 284 | //loop through extra "main fields" and see if any of their children have our field |
285 | - foreach ( $field_settings['extra'] as $main_field => $fields ) { |
|
286 | - if ( isset( $fields[$field] ) ) |
|
285 | + foreach ($field_settings['extra'] as $main_field => $fields) { |
|
286 | + if (isset($fields[$field])) |
|
287 | 287 | $_field = $fields[$field]['label']; |
288 | 288 | else |
289 | 289 | $_field = $field; |
@@ -291,8 +291,8 @@ discard block |
||
291 | 291 | } else { |
292 | 292 | $_field = $field; |
293 | 293 | } |
294 | - if ( isset( $_field )) { |
|
295 | - $localized[ $_field ] = $shortcodes; |
|
294 | + if (isset($_field)) { |
|
295 | + $localized[$_field] = $shortcodes; |
|
296 | 296 | } |
297 | 297 | } |
298 | 298 | $valid_shortcodes = $localized; |
@@ -300,11 +300,11 @@ discard block |
||
300 | 300 | |
301 | 301 | |
302 | 302 | //if $merged then let's merge all the shortcodes into one list NOT indexed by field. |
303 | - if ( $merged ) { |
|
303 | + if ($merged) { |
|
304 | 304 | $merged_codes = array(); |
305 | - foreach ( $valid_shortcodes as $field => $shortcode ) { |
|
306 | - foreach ( $shortcode as $code => $label ) { |
|
307 | - if ( isset( $merged_codes[$code] ) ) |
|
305 | + foreach ($valid_shortcodes as $field => $shortcode) { |
|
306 | + foreach ($shortcode as $code => $label) { |
|
307 | + if (isset($merged_codes[$code])) |
|
308 | 308 | continue; |
309 | 309 | else |
310 | 310 | $merged_codes[$code] = $label; |
@@ -326,10 +326,10 @@ discard block |
||
326 | 326 | * @throws \EE_Error |
327 | 327 | * @return EE_Messenger |
328 | 328 | */ |
329 | - public static function messenger_obj( $messenger ) { |
|
329 | + public static function messenger_obj($messenger) { |
|
330 | 330 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
331 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
332 | - return $Message_Resource_Manager->get_messenger( $messenger ); |
|
331 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
332 | + return $Message_Resource_Manager->get_messenger($messenger); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | |
@@ -342,10 +342,10 @@ discard block |
||
342 | 342 | * @throws \EE_Error |
343 | 343 | * @return EE_message_type |
344 | 344 | */ |
345 | - public static function message_type_obj( $message_type ) { |
|
345 | + public static function message_type_obj($message_type) { |
|
346 | 346 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
347 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
348 | - return $Message_Resource_Manager->get_message_type( $message_type ); |
|
347 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
348 | + return $Message_Resource_Manager->get_message_type($message_type); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | |
@@ -359,11 +359,11 @@ discard block |
||
359 | 359 | * @param string $message_type message type to check for. |
360 | 360 | * @return boolean |
361 | 361 | */ |
362 | - public static function is_mt_active( $message_type ) { |
|
362 | + public static function is_mt_active($message_type) { |
|
363 | 363 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
364 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
364 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
365 | 365 | $active_mts = $Message_Resource_Manager->list_of_active_message_types(); |
366 | - return in_array( $message_type, $active_mts ); |
|
366 | + return in_array($message_type, $active_mts); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | |
@@ -376,10 +376,10 @@ discard block |
||
376 | 376 | * @param string $messenger slug for messenger to check. |
377 | 377 | * @return boolean |
378 | 378 | */ |
379 | - public static function is_messenger_active( $messenger ) { |
|
379 | + public static function is_messenger_active($messenger) { |
|
380 | 380 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
381 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
382 | - $active_messenger = $Message_Resource_Manager->get_active_messenger( $messenger ); |
|
381 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
382 | + $active_messenger = $Message_Resource_Manager->get_active_messenger($messenger); |
|
383 | 383 | return $active_messenger instanceof EE_Messenger ? true : false; |
384 | 384 | } |
385 | 385 | |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | public static function get_active_messengers_in_db() { |
397 | 397 | return apply_filters( |
398 | 398 | 'FHEE__EEH_MSG_Template__get_active_messengers_in_db', |
399 | - get_option( 'ee_active_messengers', array() ) |
|
399 | + get_option('ee_active_messengers', array()) |
|
400 | 400 | ); |
401 | 401 | } |
402 | 402 | |
@@ -412,8 +412,8 @@ discard block |
||
412 | 412 | * |
413 | 413 | * @return bool FALSE if not updated, TRUE if updated. |
414 | 414 | */ |
415 | - public static function update_active_messengers_in_db( $data_to_save ) { |
|
416 | - return update_option( 'ee_active_messengers', $data_to_save ); |
|
415 | + public static function update_active_messengers_in_db($data_to_save) { |
|
416 | + return update_option('ee_active_messengers', $data_to_save); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | |
@@ -437,34 +437,34 @@ discard block |
||
437 | 437 | $sending_messenger = '' |
438 | 438 | ) { |
439 | 439 | //first determine if the url can be to the EE_Message object. |
440 | - if ( ! $message_type->always_generate() ) { |
|
441 | - return EEH_MSG_Template::generate_browser_trigger( $message ); |
|
440 | + if ( ! $message_type->always_generate()) { |
|
441 | + return EEH_MSG_Template::generate_browser_trigger($message); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | //if $registration object is not valid then exit early because there's nothing that can be generated. |
445 | - if ( ! $registration instanceof EE_Registration ) { |
|
445 | + if ( ! $registration instanceof EE_Registration) { |
|
446 | 446 | throw new EE_Error( |
447 | - __( 'Incoming value for registration is not a valid EE_Registration object.', 'event_espresso' ) |
|
447 | + __('Incoming value for registration is not a valid EE_Registration object.', 'event_espresso') |
|
448 | 448 | ); |
449 | 449 | } |
450 | 450 | |
451 | 451 | //validate given context |
452 | 452 | $contexts = $message_type->get_contexts(); |
453 | - if ( $message->context() !== '' && ! isset( $contexts[$message->context()] ) ) { |
|
453 | + if ($message->context() !== '' && ! isset($contexts[$message->context()])) { |
|
454 | 454 | throw new EE_Error( |
455 | 455 | sprintf( |
456 | - __( 'The context %s is not a valid context for %s.', 'event_espresso' ), |
|
456 | + __('The context %s is not a valid context for %s.', 'event_espresso'), |
|
457 | 457 | $message->context(), |
458 | - get_class( $message_type ) |
|
458 | + get_class($message_type) |
|
459 | 459 | ) |
460 | 460 | ); |
461 | 461 | } |
462 | 462 | |
463 | 463 | //valid sending messenger but only if sending messenger set. Otherwise generating messenger is used. |
464 | - if ( ! empty( $sending_messenger ) ) { |
|
464 | + if ( ! empty($sending_messenger)) { |
|
465 | 465 | $with_messengers = $message_type->with_messengers(); |
466 | - if ( ! isset( $with_messengers[$message->messenger()] ) |
|
467 | - || ! in_array( $sending_messenger, $with_messengers[$message->messenger()] ) ) { |
|
466 | + if ( ! isset($with_messengers[$message->messenger()]) |
|
467 | + || ! in_array($sending_messenger, $with_messengers[$message->messenger()])) { |
|
468 | 468 | throw new EE_Error( |
469 | 469 | sprintf( |
470 | 470 | __( |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | 'event_espresso' |
473 | 473 | ), |
474 | 474 | $sending_messenger, |
475 | - get_class( $message_type ) |
|
475 | + get_class($message_type) |
|
476 | 476 | ) |
477 | 477 | ); |
478 | 478 | } |
@@ -495,14 +495,14 @@ discard block |
||
495 | 495 | * @param EE_Message $message |
496 | 496 | * @return string. |
497 | 497 | */ |
498 | - public static function generate_browser_trigger( EE_Message $message ) { |
|
498 | + public static function generate_browser_trigger(EE_Message $message) { |
|
499 | 499 | $query_args = array( |
500 | 500 | 'ee' => 'msg_browser_trigger', |
501 | 501 | 'token' => $message->MSG_token() |
502 | 502 | ); |
503 | 503 | return apply_filters( |
504 | 504 | 'FHEE__EEH_MSG_Template__generate_browser_trigger', |
505 | - add_query_arg( $query_args, site_url() ), |
|
505 | + add_query_arg($query_args, site_url()), |
|
506 | 506 | $message |
507 | 507 | ); |
508 | 508 | } |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | * @param EE_Message $message |
518 | 518 | * @return string |
519 | 519 | */ |
520 | - public static function generate_error_display_trigger( EE_Message $message ) { |
|
520 | + public static function generate_error_display_trigger(EE_Message $message) { |
|
521 | 521 | return apply_filters( |
522 | 522 | 'FHEE__EEH_MSG_Template__generate_error_display_trigger', |
523 | 523 | add_query_arg( |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | 'GRP_ID' => $message_template_group, |
568 | 568 | 'id' => $data_id |
569 | 569 | ); |
570 | - $url = add_query_arg( $query_args, get_site_url() ); |
|
570 | + $url = add_query_arg($query_args, get_site_url()); |
|
571 | 571 | |
572 | 572 | //made it here so now we can just get the url and filter it. Filtered globally and by message type. |
573 | 573 | $url = apply_filters( |
@@ -595,9 +595,9 @@ discard block |
||
595 | 595 | * @param string $type What action to return. |
596 | 596 | * @return string |
597 | 597 | */ |
598 | - public static function get_message_action_icon( $type ) { |
|
598 | + public static function get_message_action_icon($type) { |
|
599 | 599 | $action_icons = self::get_message_action_icons(); |
600 | - return isset( $action_icons[ $type ] ) ? $action_icons[ $type ] : ''; |
|
600 | + return isset($action_icons[$type]) ? $action_icons[$type] : ''; |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | |
@@ -609,34 +609,34 @@ discard block |
||
609 | 609 | * @return array |
610 | 610 | */ |
611 | 611 | public static function get_message_action_icons() { |
612 | - return apply_filters( 'FHEE__EEH_MSG_Template__message_action_icons', |
|
612 | + return apply_filters('FHEE__EEH_MSG_Template__message_action_icons', |
|
613 | 613 | array( |
614 | 614 | 'view' => array( |
615 | - 'label' => __( 'View Message', 'event_espresso' ), |
|
615 | + 'label' => __('View Message', 'event_espresso'), |
|
616 | 616 | 'css_class' => 'dashicons dashicons-welcome-view-site', |
617 | 617 | ), |
618 | 618 | 'error' => array( |
619 | - 'label' => __( 'View Error Message', 'event_espresso' ), |
|
619 | + 'label' => __('View Error Message', 'event_espresso'), |
|
620 | 620 | 'css_class' => 'dashicons dashicons-info', |
621 | 621 | ), |
622 | 622 | 'see_notifications_for' => array( |
623 | - 'label' => __( 'View Related Messages', 'event_espresso' ), |
|
623 | + 'label' => __('View Related Messages', 'event_espresso'), |
|
624 | 624 | 'css_class' => 'dashicons dashicons-images-alt', |
625 | 625 | ), |
626 | 626 | 'generate_now' => array( |
627 | - 'label' => __( 'Generate the message now.', 'event_espresso' ), |
|
627 | + 'label' => __('Generate the message now.', 'event_espresso'), |
|
628 | 628 | 'css_class' => 'dashicons dashicons-admin-tools', |
629 | 629 | ), |
630 | 630 | 'send_now' => array( |
631 | - 'label' => __( 'Send Immediately', 'event_espresso' ), |
|
631 | + 'label' => __('Send Immediately', 'event_espresso'), |
|
632 | 632 | 'css_class' => 'dashicons dashicons-controls-forward', |
633 | 633 | ), |
634 | 634 | 'queue_for_resending' => array( |
635 | - 'label' => __( 'Queue for Resending', 'event_espresso' ), |
|
635 | + 'label' => __('Queue for Resending', 'event_espresso'), |
|
636 | 636 | 'css_class' => 'dashicons dashicons-controls-repeat', |
637 | 637 | ), |
638 | 638 | 'view_transaction' => array( |
639 | - 'label' => __( 'View related Transaction', 'event_espresso' ), |
|
639 | + 'label' => __('View related Transaction', 'event_espresso'), |
|
640 | 640 | 'css_class' => 'dashicons dashicons-cart', |
641 | 641 | ) |
642 | 642 | ) |
@@ -655,9 +655,9 @@ discard block |
||
655 | 655 | * |
656 | 656 | * @return string |
657 | 657 | */ |
658 | - public static function get_message_action_url( $type, EE_Message $message = null, $query_params = array() ) { |
|
659 | - $action_urls = self::get_message_action_urls( $message, $query_params ); |
|
660 | - return isset( $action_urls[ $type ] ) ? $action_urls[ $type ] : ''; |
|
658 | + public static function get_message_action_url($type, EE_Message $message = null, $query_params = array()) { |
|
659 | + $action_urls = self::get_message_action_urls($message, $query_params); |
|
660 | + return isset($action_urls[$type]) ? $action_urls[$type] : ''; |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | |
@@ -671,15 +671,15 @@ discard block |
||
671 | 671 | * |
672 | 672 | * @return array |
673 | 673 | */ |
674 | - public static function get_message_action_urls( EE_Message $message = null, $query_params = array() ) { |
|
675 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
674 | + public static function get_message_action_urls(EE_Message $message = null, $query_params = array()) { |
|
675 | + EE_Registry::instance()->load_helper('URL'); |
|
676 | 676 | //if $message is not an instance of EE_Message then let's just do a dummy. |
677 | - $message = empty( $message ) ? EE_Message_Factory::create() : $message; |
|
678 | - $action_urls = apply_filters( |
|
677 | + $message = empty($message) ? EE_Message_Factory::create() : $message; |
|
678 | + $action_urls = apply_filters( |
|
679 | 679 | 'FHEE__EEH_MSG_Template__get_message_action_url', |
680 | 680 | array( |
681 | - 'view' => EEH_MSG_Template::generate_browser_trigger( $message ), |
|
682 | - 'error' => EEH_MSG_Template::generate_error_display_trigger( $message ), |
|
681 | + 'view' => EEH_MSG_Template::generate_browser_trigger($message), |
|
682 | + 'error' => EEH_MSG_Template::generate_error_display_trigger($message), |
|
683 | 683 | 'see_notifications_for' => EEH_URL::add_query_args_and_nonce( |
684 | 684 | array_merge( |
685 | 685 | array( |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | ), |
690 | 690 | $query_params |
691 | 691 | ), |
692 | - admin_url( 'admin.php' ) |
|
692 | + admin_url('admin.php') |
|
693 | 693 | ), |
694 | 694 | 'generate_now' => EEH_URL::add_query_args_and_nonce( |
695 | 695 | array( |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | 'action' => 'generate_now', |
698 | 698 | 'MSG_ID' => $message->ID() |
699 | 699 | ), |
700 | - admin_url( 'admin.php' ) |
|
700 | + admin_url('admin.php') |
|
701 | 701 | ), |
702 | 702 | 'send_now' => EEH_URL::add_query_args_and_nonce( |
703 | 703 | array( |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | 'action' => 'send_now', |
706 | 706 | 'MSG_ID' => $message->ID() |
707 | 707 | ), |
708 | - admin_url( 'admin.php' ) |
|
708 | + admin_url('admin.php') |
|
709 | 709 | ), |
710 | 710 | 'queue_for_resending' => EEH_URL::add_query_args_and_nonce( |
711 | 711 | array( |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | 'action' => 'queue_for_resending', |
714 | 714 | 'MSG_ID' => $message->ID() |
715 | 715 | ), |
716 | - admin_url( 'admin.php' ) |
|
716 | + admin_url('admin.php') |
|
717 | 717 | ), |
718 | 718 | ) |
719 | 719 | ); |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | 'action' => 'view_transaction', |
732 | 732 | 'TXN_ID' => $message->TXN_ID() |
733 | 733 | ), |
734 | - admin_url( 'admin.php' ) |
|
734 | + admin_url('admin.php') |
|
735 | 735 | ); |
736 | 736 | } else { |
737 | 737 | $action_urls['view_transaction'] = ''; |
@@ -752,24 +752,24 @@ discard block |
||
752 | 752 | * |
753 | 753 | * @return string |
754 | 754 | */ |
755 | - public static function get_message_action_link( $type, EE_Message $message = null, $query_params = array() ) { |
|
756 | - $url = EEH_MSG_Template::get_message_action_url( $type, $message, $query_params ); |
|
757 | - $icon_css = EEH_MSG_Template::get_message_action_icon( $type ); |
|
758 | - if ( empty( $url ) || empty( $icon_css ) || ! isset( $icon_css['css_class'] ) ) { |
|
755 | + public static function get_message_action_link($type, EE_Message $message = null, $query_params = array()) { |
|
756 | + $url = EEH_MSG_Template::get_message_action_url($type, $message, $query_params); |
|
757 | + $icon_css = EEH_MSG_Template::get_message_action_icon($type); |
|
758 | + if (empty($url) || empty($icon_css) || ! isset($icon_css['css_class'])) { |
|
759 | 759 | return ''; |
760 | 760 | } |
761 | 761 | |
762 | 762 | $icon_css['css_class'] .= esc_attr( |
763 | 763 | apply_filters( |
764 | 764 | 'FHEE__EEH_MSG_Template__get_message_action_link__icon_css_class', |
765 | - ' js-ee-message-action-link ee-message-action-link-' . $type, |
|
765 | + ' js-ee-message-action-link ee-message-action-link-'.$type, |
|
766 | 766 | $type, |
767 | 767 | $message, |
768 | 768 | $query_params |
769 | 769 | ) |
770 | 770 | ); |
771 | 771 | |
772 | - return '<a href="' . $url . '"><span class="' . esc_attr( $icon_css['css_class'] ) . '"></span></a>'; |
|
772 | + return '<a href="'.$url.'"><span class="'.esc_attr($icon_css['css_class']).'"></span></a>'; |
|
773 | 773 | |
774 | 774 | } |
775 | 775 | |
@@ -807,9 +807,9 @@ discard block |
||
807 | 807 | * @param $reg_status |
808 | 808 | * @return string |
809 | 809 | */ |
810 | - public static function convert_reg_status_to_message_type( $reg_status ) { |
|
810 | + public static function convert_reg_status_to_message_type($reg_status) { |
|
811 | 811 | $reg_status_array = self::reg_status_to_message_type_array(); |
812 | - return isset( $reg_status_array[$reg_status] ) ? $reg_status_array[$reg_status] : ''; |
|
812 | + return isset($reg_status_array[$reg_status]) ? $reg_status_array[$reg_status] : ''; |
|
813 | 813 | } |
814 | 814 | |
815 | 815 | |
@@ -843,9 +843,9 @@ discard block |
||
843 | 843 | * @param $payment_status |
844 | 844 | * @return string |
845 | 845 | */ |
846 | - public static function convert_payment_status_to_message_type( $payment_status ) { |
|
846 | + public static function convert_payment_status_to_message_type($payment_status) { |
|
847 | 847 | $payment_status_array = self::payment_status_to_message_type_array(); |
848 | - return isset( $payment_status_array[$payment_status] ) ? $payment_status_array[$payment_status] : ''; |
|
848 | + return isset($payment_status_array[$payment_status]) ? $payment_status_array[$payment_status] : ''; |
|
849 | 849 | } |
850 | 850 | |
851 | 851 | |
@@ -856,32 +856,32 @@ discard block |
||
856 | 856 | * |
857 | 857 | * @return EE_Messages_Template_Pack |
858 | 858 | */ |
859 | - public static function get_template_pack( $template_pack_name ) { |
|
860 | - if ( ! self::$_template_pack_collection instanceof EE_Object_Collection ) { |
|
859 | + public static function get_template_pack($template_pack_name) { |
|
860 | + if ( ! self::$_template_pack_collection instanceof EE_Object_Collection) { |
|
861 | 861 | self::$_template_pack_collection = new EE_Messages_Template_Pack_Collection(); |
862 | 862 | } |
863 | 863 | |
864 | 864 | //first see if in collection already |
865 | - $template_pack = self::$_template_pack_collection->get_by_name( $template_pack_name ); |
|
865 | + $template_pack = self::$_template_pack_collection->get_by_name($template_pack_name); |
|
866 | 866 | |
867 | - if ( $template_pack instanceof EE_Messages_Template_Pack ) { |
|
867 | + if ($template_pack instanceof EE_Messages_Template_Pack) { |
|
868 | 868 | return $template_pack; |
869 | 869 | } |
870 | 870 | |
871 | 871 | //nope...let's get it. |
872 | 872 | //not set yet so let's attempt to get it. |
873 | - $pack_class_name = 'EE_Messages_Template_Pack_' . str_replace( |
|
873 | + $pack_class_name = 'EE_Messages_Template_Pack_'.str_replace( |
|
874 | 874 | ' ', |
875 | 875 | '_', |
876 | 876 | ucwords( |
877 | - str_replace( '_', ' ', $template_pack_name ) |
|
877 | + str_replace('_', ' ', $template_pack_name) |
|
878 | 878 | ) |
879 | 879 | ); |
880 | - if ( ! class_exists( $pack_class_name ) && $template_pack_name !== 'default' ) { |
|
881 | - return self::get_template_pack( 'default' ); |
|
880 | + if ( ! class_exists($pack_class_name) && $template_pack_name !== 'default') { |
|
881 | + return self::get_template_pack('default'); |
|
882 | 882 | } else { |
883 | 883 | $template_pack = new $pack_class_name; |
884 | - self::$_template_pack_collection->add( $template_pack ); |
|
884 | + self::$_template_pack_collection->add($template_pack); |
|
885 | 885 | return $template_pack; |
886 | 886 | } |
887 | 887 | } |
@@ -899,26 +899,26 @@ discard block |
||
899 | 899 | */ |
900 | 900 | public static function get_template_pack_collection() { |
901 | 901 | $new_collection = false; |
902 | - if ( ! self::$_template_pack_collection instanceof EE_Messages_Template_Pack_Collection ) { |
|
902 | + if ( ! self::$_template_pack_collection instanceof EE_Messages_Template_Pack_Collection) { |
|
903 | 903 | self::$_template_pack_collection = new EE_Messages_Template_Pack_Collection(); |
904 | 904 | $new_collection = true; |
905 | 905 | } |
906 | 906 | |
907 | 907 | //glob the defaults directory for messages |
908 | - $templates = glob( EE_LIBRARIES . 'messages/defaults/*', GLOB_ONLYDIR ); |
|
909 | - foreach( $templates as $template_path ) { |
|
908 | + $templates = glob(EE_LIBRARIES.'messages/defaults/*', GLOB_ONLYDIR); |
|
909 | + foreach ($templates as $template_path) { |
|
910 | 910 | //grab folder name |
911 | - $template = basename( $template_path ); |
|
911 | + $template = basename($template_path); |
|
912 | 912 | |
913 | - if ( ! $new_collection ) { |
|
913 | + if ( ! $new_collection) { |
|
914 | 914 | //already have it? |
915 | - if ( self::$_template_pack_collection->get_by_name( $template ) instanceof EE_Messages_Template_Pack ) { |
|
915 | + if (self::$_template_pack_collection->get_by_name($template) instanceof EE_Messages_Template_Pack) { |
|
916 | 916 | continue; |
917 | 917 | } |
918 | 918 | } |
919 | 919 | |
920 | 920 | //setup classname. |
921 | - $template_pack_class_name = 'EE_Messages_Template_Pack_' . str_replace( |
|
921 | + $template_pack_class_name = 'EE_Messages_Template_Pack_'.str_replace( |
|
922 | 922 | ' ', |
923 | 923 | '_', |
924 | 924 | ucwords( |
@@ -929,20 +929,20 @@ discard block |
||
929 | 929 | ) |
930 | 930 | ) |
931 | 931 | ); |
932 | - if ( ! class_exists( $template_pack_class_name ) ) { |
|
932 | + if ( ! class_exists($template_pack_class_name)) { |
|
933 | 933 | continue; |
934 | 934 | } |
935 | - self::$_template_pack_collection->add( new $template_pack_class_name ); |
|
935 | + self::$_template_pack_collection->add(new $template_pack_class_name); |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | /** |
939 | 939 | * Filter for plugins to add in any additional template packs |
940 | 940 | * Note the filter name here is for backward compat, this used to be found in EED_Messages. |
941 | 941 | */ |
942 | - $additional_template_packs = apply_filters( 'FHEE__EED_Messages__get_template_packs__template_packs', array() ); |
|
943 | - foreach ( (array) $additional_template_packs as $template_pack ) { |
|
944 | - if ( ! self::$_template_pack_collection->contains($template_pack ) ) { |
|
945 | - self::$_template_pack_collection->add( $template_pack ); |
|
942 | + $additional_template_packs = apply_filters('FHEE__EED_Messages__get_template_packs__template_packs', array()); |
|
943 | + foreach ((array) $additional_template_packs as $template_pack) { |
|
944 | + if ( ! self::$_template_pack_collection->contains($template_pack)) { |
|
945 | + self::$_template_pack_collection->add($template_pack); |
|
946 | 946 | } |
947 | 947 | } |
948 | 948 | return self::$_template_pack_collection; |
@@ -960,16 +960,16 @@ discard block |
||
960 | 960 | * @return array |
961 | 961 | * @throws \EE_Error |
962 | 962 | */ |
963 | - public static function create_new_templates( $messenger_name, $message_type_name, $GRP_ID = 0, $global = false ) { |
|
963 | + public static function create_new_templates($messenger_name, $message_type_name, $GRP_ID = 0, $global = false) { |
|
964 | 964 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
965 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
966 | - $messenger = $Message_Resource_Manager->valid_messenger( $messenger_name ); |
|
967 | - $message_type = $Message_Resource_Manager->valid_message_type( $message_type_name ); |
|
968 | - if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger( $messenger, $message_type, $global ) ) { |
|
965 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
966 | + $messenger = $Message_Resource_Manager->valid_messenger($messenger_name); |
|
967 | + $message_type = $Message_Resource_Manager->valid_message_type($message_type_name); |
|
968 | + if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger($messenger, $message_type, $global)) { |
|
969 | 969 | return array(); |
970 | 970 | } |
971 | 971 | //whew made it this far! Okay, let's go ahead and create the templates then |
972 | - return EEH_MSG_Template::_create_new_templates( $messenger, $message_type, $GRP_ID, $global ); |
|
972 | + return EEH_MSG_Template::_create_new_templates($messenger, $message_type, $GRP_ID, $global); |
|
973 | 973 | } |
974 | 974 | |
975 | 975 | |
@@ -981,13 +981,13 @@ discard block |
||
981 | 981 | * @param $global |
982 | 982 | * @return array|mixed |
983 | 983 | */ |
984 | - protected static function _create_new_templates( EE_Messenger $messenger, EE_message_type $message_type, $GRP_ID, $global ) { |
|
984 | + protected static function _create_new_templates(EE_Messenger $messenger, EE_message_type $message_type, $GRP_ID, $global) { |
|
985 | 985 | //if we're creating a custom template then we don't need to use the defaults class |
986 | - if ( ! $global ) { |
|
987 | - return EEH_MSG_Template::_create_custom_template_group( $messenger, $message_type, $GRP_ID ); |
|
986 | + if ( ! $global) { |
|
987 | + return EEH_MSG_Template::_create_custom_template_group($messenger, $message_type, $GRP_ID); |
|
988 | 988 | } |
989 | 989 | $Message_Template_Defaults = new EE_Message_Template_Defaults( |
990 | - EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ), |
|
990 | + EE_Registry::instance()->load_lib('Message_Resource_Manager'), |
|
991 | 991 | $messenger->name, |
992 | 992 | $message_type->name, |
993 | 993 | $GRP_ID |
@@ -1019,11 +1019,11 @@ discard block |
||
1019 | 1019 | * ) |
1020 | 1020 | * @access private |
1021 | 1021 | */ |
1022 | - private static function _create_custom_template_group( EE_Messenger $messenger, EE_message_type $message_type, $GRP_ID ) { |
|
1022 | + private static function _create_custom_template_group(EE_Messenger $messenger, EE_message_type $message_type, $GRP_ID) { |
|
1023 | 1023 | //defaults |
1024 | - $success = array( 'GRP_ID' => null, 'MTP_context' => '' ); |
|
1024 | + $success = array('GRP_ID' => null, 'MTP_context' => ''); |
|
1025 | 1025 | //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. |
1026 | - $Message_Template_Group = empty( $GRP_ID ) |
|
1026 | + $Message_Template_Group = empty($GRP_ID) |
|
1027 | 1027 | ? EEM_Message_Template_Group::instance()->get_one( |
1028 | 1028 | array( |
1029 | 1029 | array( |
@@ -1033,9 +1033,9 @@ discard block |
||
1033 | 1033 | ) |
1034 | 1034 | ) |
1035 | 1035 | ) |
1036 | - : EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID ); |
|
1036 | + : EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID); |
|
1037 | 1037 | //if we don't have a mtg at this point then we need to bail. |
1038 | - if ( ! $Message_Template_Group instanceof EE_Message_Template_Group ) { |
|
1038 | + if ( ! $Message_Template_Group instanceof EE_Message_Template_Group) { |
|
1039 | 1039 | EE_Error::add_error( |
1040 | 1040 | sprintf( |
1041 | 1041 | __( |
@@ -1054,42 +1054,42 @@ discard block |
||
1054 | 1054 | $mtts = $Message_Template_Group->message_templates(); |
1055 | 1055 | //now we have what we need to setup the new template |
1056 | 1056 | $new_mtg = clone $Message_Template_Group; |
1057 | - $new_mtg->set( 'GRP_ID', 0 ); |
|
1058 | - $new_mtg->set( 'MTP_is_global', false ); |
|
1059 | - $template_name = defined( 'DOING_AJAX' ) && ! empty( $_POST[ 'templateName' ] ) |
|
1060 | - ? $_POST[ 'templateName' ] |
|
1057 | + $new_mtg->set('GRP_ID', 0); |
|
1058 | + $new_mtg->set('MTP_is_global', false); |
|
1059 | + $template_name = defined('DOING_AJAX') && ! empty($_POST['templateName']) |
|
1060 | + ? $_POST['templateName'] |
|
1061 | 1061 | : __( |
1062 | 1062 | 'New Custom Template', |
1063 | 1063 | 'event_espresso' |
1064 | 1064 | ); |
1065 | - $template_description = defined( "DOING_AJAX" ) && ! empty( $_POST[ 'templateDescription' ] ) |
|
1066 | - ? $_POST[ 'templateDescription' ] |
|
1065 | + $template_description = defined("DOING_AJAX") && ! empty($_POST['templateDescription']) |
|
1066 | + ? $_POST['templateDescription'] |
|
1067 | 1067 | : sprintf( |
1068 | 1068 | __( |
1069 | 1069 | 'This is a custom template that was created for the %s messenger and %s message type.', |
1070 | 1070 | 'event_espresso' |
1071 | 1071 | ), |
1072 | - $new_mtg->messenger_obj()->label[ 'singular' ], |
|
1073 | - $new_mtg->message_type_obj()->label[ 'singular' ] |
|
1072 | + $new_mtg->messenger_obj()->label['singular'], |
|
1073 | + $new_mtg->message_type_obj()->label['singular'] |
|
1074 | 1074 | ); |
1075 | - $new_mtg->set( 'MTP_name', $template_name ); |
|
1076 | - $new_mtg->set( 'MTP_description', $template_description ); |
|
1075 | + $new_mtg->set('MTP_name', $template_name); |
|
1076 | + $new_mtg->set('MTP_description', $template_description); |
|
1077 | 1077 | //remove ALL relations on this template group so they don't get saved! |
1078 | - $new_mtg->_remove_relations( 'Message_Template' ); |
|
1078 | + $new_mtg->_remove_relations('Message_Template'); |
|
1079 | 1079 | $new_mtg->save(); |
1080 | - $success[ 'GRP_ID' ] = $new_mtg->ID(); |
|
1081 | - $success[ 'template_name' ] = $template_name; |
|
1080 | + $success['GRP_ID'] = $new_mtg->ID(); |
|
1081 | + $success['template_name'] = $template_name; |
|
1082 | 1082 | //add new message templates and add relation to. |
1083 | - foreach ( $mtts as $mtt ) { |
|
1084 | - if ( ! $mtt instanceof EE_Message_Template ) { |
|
1083 | + foreach ($mtts as $mtt) { |
|
1084 | + if ( ! $mtt instanceof EE_Message_Template) { |
|
1085 | 1085 | continue; |
1086 | 1086 | } |
1087 | 1087 | $nmtt = clone $mtt; |
1088 | - $nmtt->set( 'MTP_ID', 0 ); |
|
1089 | - $nmtt->set( 'GRP_ID', $new_mtg->ID() ); //relation |
|
1088 | + $nmtt->set('MTP_ID', 0); |
|
1089 | + $nmtt->set('GRP_ID', $new_mtg->ID()); //relation |
|
1090 | 1090 | $nmtt->save(); |
1091 | - if ( empty( $success[ 'MTP_context' ] ) ) { |
|
1092 | - $success[ 'MTP_context' ] = $nmtt->get( 'MTP_context' ); |
|
1091 | + if (empty($success['MTP_context'])) { |
|
1092 | + $success['MTP_context'] = $nmtt->get('MTP_context'); |
|
1093 | 1093 | } |
1094 | 1094 | } |
1095 | 1095 | return $success; |
@@ -1111,7 +1111,7 @@ discard block |
||
1111 | 1111 | $global = false |
1112 | 1112 | ) { |
1113 | 1113 | //is given message_type valid for given messenger (if this is not a global save) |
1114 | - if ( $global ) { |
|
1114 | + if ($global) { |
|
1115 | 1115 | return true; |
1116 | 1116 | } |
1117 | 1117 | $active_templates = EEM_Message_Template_Group::instance()->count( |
@@ -1123,7 +1123,7 @@ discard block |
||
1123 | 1123 | ) |
1124 | 1124 | ) |
1125 | 1125 | ); |
1126 | - if ( $active_templates > 0 ) { |
|
1126 | + if ($active_templates > 0) { |
|
1127 | 1127 | return true; |
1128 | 1128 | } |
1129 | 1129 | EE_Error::add_error( |
@@ -1152,24 +1152,24 @@ discard block |
||
1152 | 1152 | * @param string $message_type_name name of EE_message_type |
1153 | 1153 | * @return array |
1154 | 1154 | */ |
1155 | - public static function get_fields( $messenger_name, $message_type_name ) { |
|
1155 | + public static function get_fields($messenger_name, $message_type_name) { |
|
1156 | 1156 | $template_fields = array(); |
1157 | 1157 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
1158 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1159 | - $messenger = $Message_Resource_Manager->valid_messenger( $messenger_name ); |
|
1160 | - $message_type = $Message_Resource_Manager->valid_message_type( $message_type_name ); |
|
1161 | - if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger( $messenger, $message_type ) ) { |
|
1158 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1159 | + $messenger = $Message_Resource_Manager->valid_messenger($messenger_name); |
|
1160 | + $message_type = $Message_Resource_Manager->valid_message_type($message_type_name); |
|
1161 | + if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger($messenger, $message_type)) { |
|
1162 | 1162 | return array(); |
1163 | 1163 | } |
1164 | 1164 | //okay now let's assemble an array with the messenger template fields added to the message_type contexts. |
1165 | - foreach ( $message_type->get_contexts() as $context => $details ) { |
|
1166 | - foreach ( $messenger->get_template_fields() as $field => $value ) { |
|
1167 | - $template_fields[ $context ][ $field ] = $value; |
|
1165 | + foreach ($message_type->get_contexts() as $context => $details) { |
|
1166 | + foreach ($messenger->get_template_fields() as $field => $value) { |
|
1167 | + $template_fields[$context][$field] = $value; |
|
1168 | 1168 | } |
1169 | 1169 | } |
1170 | - if ( empty( $template_fields ) ) { |
|
1170 | + if (empty($template_fields)) { |
|
1171 | 1171 | EE_Error::add_error( |
1172 | - __( 'Something went wrong and we couldn\'t get any templates assembled', 'event_espresso' ), |
|
1172 | + __('Something went wrong and we couldn\'t get any templates assembled', 'event_espresso'), |
|
1173 | 1173 | __FILE__, |
1174 | 1174 | __FUNCTION__, |
1175 | 1175 | __LINE__ |
@@ -1,7 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | +} |
|
5 | 6 | |
6 | 7 | /** |
7 | 8 | * Event Espresso |
@@ -255,8 +256,9 @@ discard block |
||
255 | 256 | if ( ! empty( $fields ) ) { |
256 | 257 | $specified_shortcodes = array(); |
257 | 258 | foreach ( $fields as $field ) { |
258 | - if ( isset( $valid_shortcodes[$field] ) ) |
|
259 | - $specified_shortcodes[$field] = $valid_shortcodes[$field]; |
|
259 | + if ( isset( $valid_shortcodes[$field] ) ) { |
|
260 | + $specified_shortcodes[$field] = $valid_shortcodes[$field]; |
|
261 | + } |
|
260 | 262 | } |
261 | 263 | $valid_shortcodes = $specified_shortcodes; |
262 | 264 | } |
@@ -283,10 +285,11 @@ discard block |
||
283 | 285 | } else if ( isset( $field_settings['extra'] ) ) { |
284 | 286 | //loop through extra "main fields" and see if any of their children have our field |
285 | 287 | foreach ( $field_settings['extra'] as $main_field => $fields ) { |
286 | - if ( isset( $fields[$field] ) ) |
|
287 | - $_field = $fields[$field]['label']; |
|
288 | - else |
|
289 | - $_field = $field; |
|
288 | + if ( isset( $fields[$field] ) ) { |
|
289 | + $_field = $fields[$field]['label']; |
|
290 | + } else { |
|
291 | + $_field = $field; |
|
292 | + } |
|
290 | 293 | } |
291 | 294 | } else { |
292 | 295 | $_field = $field; |
@@ -304,10 +307,11 @@ discard block |
||
304 | 307 | $merged_codes = array(); |
305 | 308 | foreach ( $valid_shortcodes as $field => $shortcode ) { |
306 | 309 | foreach ( $shortcode as $code => $label ) { |
307 | - if ( isset( $merged_codes[$code] ) ) |
|
308 | - continue; |
|
309 | - else |
|
310 | - $merged_codes[$code] = $label; |
|
310 | + if ( isset( $merged_codes[$code] ) ) { |
|
311 | + continue; |
|
312 | + } else { |
|
313 | + $merged_codes[$code] = $label; |
|
314 | + } |
|
311 | 315 | } |
312 | 316 | } |
313 | 317 | $valid_shortcodes = $merged_codes; |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 4.0 |
9 | 9 | * |
10 | 10 | */ |
11 | -class EEH_Debug_Tools{ |
|
11 | +class EEH_Debug_Tools { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * instance of the EEH_Autoloader object |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public static function instance() { |
43 | 43 | // check if class object is instantiated, and instantiated properly |
44 | - if ( ! self::$_instance instanceof EEH_Debug_Tools ) { |
|
44 | + if ( ! self::$_instance instanceof EEH_Debug_Tools) { |
|
45 | 45 | self::$_instance = new self(); |
46 | 46 | } |
47 | 47 | return self::$_instance; |
@@ -57,21 +57,21 @@ discard block |
||
57 | 57 | */ |
58 | 58 | private function __construct() { |
59 | 59 | // load Kint PHP debugging library |
60 | - if ( ! class_exists( 'Kint' ) && file_exists( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' )){ |
|
60 | + if ( ! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php')) { |
|
61 | 61 | // despite EE4 having a check for an existing copy of the Kint debugging class, |
62 | 62 | // if another plugin was loaded AFTER EE4 and they did NOT perform a similar check, |
63 | 63 | // then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error |
64 | 64 | // so we've moved it to our test folder so that it is not included with production releases |
65 | 65 | // plz use https://wordpress.org/plugins/kint-debugger/ if testing production versions of EE |
66 | - require_once( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' ); |
|
66 | + require_once(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php'); |
|
67 | 67 | } |
68 | - if ( ! defined('DOING_AJAX') || ! isset( $_REQUEST['noheader'] ) || $_REQUEST['noheader'] != 'true' || ! isset( $_REQUEST['TB_iframe'] )) { |
|
68 | + if ( ! defined('DOING_AJAX') || ! isset($_REQUEST['noheader']) || $_REQUEST['noheader'] != 'true' || ! isset($_REQUEST['TB_iframe'])) { |
|
69 | 69 | //add_action( 'shutdown', array($this,'espresso_session_footer_dump') ); |
70 | 70 | } |
71 | - $plugin = basename( EE_PLUGIN_DIR_PATH ); |
|
72 | - add_action( "activate_{$plugin}", array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' )); |
|
73 | - add_action( 'activated_plugin', array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' )); |
|
74 | - add_action( 'shutdown', array( 'EEH_Debug_Tools', 'show_db_name' )); |
|
71 | + $plugin = basename(EE_PLUGIN_DIR_PATH); |
|
72 | + add_action("activate_{$plugin}", array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
73 | + add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
74 | + add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name')); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | * @return void |
83 | 83 | */ |
84 | 84 | public static function show_db_name() { |
85 | - if ( ! defined( 'DOING_AJAX' ) && ( defined( 'EE_ERROR_EMAILS' ) && EE_ERROR_EMAILS )) { |
|
86 | - echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '. DB_NAME .'</p>'; |
|
85 | + if ( ! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) { |
|
86 | + echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '.DB_NAME.'</p>'; |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | * @return void |
96 | 96 | */ |
97 | 97 | public function espresso_session_footer_dump() { |
98 | - if ( class_exists('Kint') && function_exists( 'wp_get_current_user' ) && current_user_can('update_core') && ( defined('WP_DEBUG') && WP_DEBUG ) && ! defined('DOING_AJAX') && class_exists( 'EE_Registry' )) { |
|
99 | - Kint::dump( EE_Registry::instance()->SSN->id() ); |
|
100 | - Kint::dump( EE_Registry::instance()->SSN ); |
|
98 | + if (class_exists('Kint') && function_exists('wp_get_current_user') && current_user_can('update_core') && (defined('WP_DEBUG') && WP_DEBUG) && ! defined('DOING_AJAX') && class_exists('EE_Registry')) { |
|
99 | + Kint::dump(EE_Registry::instance()->SSN->id()); |
|
100 | + Kint::dump(EE_Registry::instance()->SSN); |
|
101 | 101 | // Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() ); |
102 | 102 | $this->espresso_list_hooked_functions(); |
103 | 103 | $this->show_times(); |
@@ -114,27 +114,27 @@ discard block |
||
114 | 114 | * @param bool $tag |
115 | 115 | * @return void |
116 | 116 | */ |
117 | - public function espresso_list_hooked_functions( $tag=FALSE ){ |
|
117 | + public function espresso_list_hooked_functions($tag = FALSE) { |
|
118 | 118 | global $wp_filter; |
119 | 119 | echo '<br/><br/><br/><h3>Hooked Functions</h3>'; |
120 | - if ( $tag ) { |
|
121 | - $hook[$tag]=$wp_filter[$tag]; |
|
122 | - if ( ! is_array( $hook[$tag] )) { |
|
123 | - trigger_error( "Nothing found for '$tag' hook", E_USER_WARNING ); |
|
120 | + if ($tag) { |
|
121 | + $hook[$tag] = $wp_filter[$tag]; |
|
122 | + if ( ! is_array($hook[$tag])) { |
|
123 | + trigger_error("Nothing found for '$tag' hook", E_USER_WARNING); |
|
124 | 124 | return; |
125 | 125 | } |
126 | - echo '<h5>For Tag: '. $tag .'</h5>'; |
|
126 | + echo '<h5>For Tag: '.$tag.'</h5>'; |
|
127 | 127 | } |
128 | 128 | else { |
129 | - $hook=$wp_filter; |
|
130 | - ksort( $hook ); |
|
129 | + $hook = $wp_filter; |
|
130 | + ksort($hook); |
|
131 | 131 | } |
132 | - foreach( $hook as $tag => $priorities ) { |
|
132 | + foreach ($hook as $tag => $priorities) { |
|
133 | 133 | echo "<br />>>>>>\t<strong>$tag</strong><br />"; |
134 | - ksort( $priorities ); |
|
135 | - foreach( $priorities as $priority => $function ){ |
|
134 | + ksort($priorities); |
|
135 | + foreach ($priorities as $priority => $function) { |
|
136 | 136 | echo $priority; |
137 | - foreach( $function as $name => $properties ) { |
|
137 | + foreach ($function as $name => $properties) { |
|
138 | 138 | echo "\t$name<br />"; |
139 | 139 | } |
140 | 140 | } |
@@ -150,15 +150,15 @@ discard block |
||
150 | 150 | * @param string $hook_name |
151 | 151 | * @return array |
152 | 152 | */ |
153 | - public static function registered_filter_callbacks( $hook_name = '' ) { |
|
153 | + public static function registered_filter_callbacks($hook_name = '') { |
|
154 | 154 | $filters = array(); |
155 | 155 | global $wp_filter; |
156 | - if ( isset( $wp_filter[ $hook_name ] ) ) { |
|
157 | - $filters[ $hook_name ] = array(); |
|
158 | - foreach ( $wp_filter[ $hook_name ] as $priority => $callbacks ) { |
|
159 | - $filters[ $hook_name ][ $priority ] = array(); |
|
160 | - foreach ( $callbacks as $callback ) { |
|
161 | - $filters[ $hook_name ][ $priority ][] = $callback['function']; |
|
156 | + if (isset($wp_filter[$hook_name])) { |
|
157 | + $filters[$hook_name] = array(); |
|
158 | + foreach ($wp_filter[$hook_name] as $priority => $callbacks) { |
|
159 | + $filters[$hook_name][$priority] = array(); |
|
160 | + foreach ($callbacks as $callback) { |
|
161 | + $filters[$hook_name][$priority][] = $callback['function']; |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | * start_timer |
172 | 172 | * @param null $timer_name |
173 | 173 | */ |
174 | - public function start_timer( $timer_name = NULL ){ |
|
175 | - $this->_start_times[$timer_name] = microtime( TRUE ); |
|
174 | + public function start_timer($timer_name = NULL) { |
|
175 | + $this->_start_times[$timer_name] = microtime(TRUE); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -181,15 +181,15 @@ discard block |
||
181 | 181 | * stop_timer |
182 | 182 | * @param string $timer_name |
183 | 183 | */ |
184 | - public function stop_timer($timer_name = 'default'){ |
|
185 | - if( isset( $this->_start_times[ $timer_name ] ) ){ |
|
186 | - $start_time = $this->_start_times[ $timer_name ]; |
|
187 | - unset( $this->_start_times[ $timer_name ] ); |
|
188 | - }else{ |
|
189 | - $start_time = array_pop( $this->_start_times ); |
|
184 | + public function stop_timer($timer_name = 'default') { |
|
185 | + if (isset($this->_start_times[$timer_name])) { |
|
186 | + $start_time = $this->_start_times[$timer_name]; |
|
187 | + unset($this->_start_times[$timer_name]); |
|
188 | + } else { |
|
189 | + $start_time = array_pop($this->_start_times); |
|
190 | 190 | } |
191 | - $total_time = microtime( TRUE ) - $start_time; |
|
192 | - switch ( $total_time ) { |
|
191 | + $total_time = microtime(TRUE) - $start_time; |
|
192 | + switch ($total_time) { |
|
193 | 193 | case $total_time < 0.00001 : |
194 | 194 | $color = '#8A549A'; |
195 | 195 | $bold = 'normal'; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $bold = 'bold'; |
216 | 216 | break; |
217 | 217 | } |
218 | - $this->_times[] = '<hr /><div style="display: inline-block; min-width: 10px; margin:0 1em; color:'.$color.'; font-weight:'.$bold.'; font-size:1.2em;">' . number_format( $total_time, 8 ) . '</div> ' . $timer_name; |
|
218 | + $this->_times[] = '<hr /><div style="display: inline-block; min-width: 10px; margin:0 1em; color:'.$color.'; font-weight:'.$bold.'; font-size:1.2em;">'.number_format($total_time, 8).'</div> '.$timer_name; |
|
219 | 219 | } |
220 | 220 | /** |
221 | 221 | * Measure the memory usage by PHP so far. |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called |
224 | 224 | * @return void |
225 | 225 | */ |
226 | - public function measure_memory( $label, $output_now = false ) { |
|
227 | - $memory_used = $this->convert( memory_get_peak_usage( true ) ); |
|
228 | - $this->_memory_usage_points[ $label ] = $memory_used; |
|
229 | - if( $output_now ) { |
|
226 | + public function measure_memory($label, $output_now = false) { |
|
227 | + $memory_used = $this->convert(memory_get_peak_usage(true)); |
|
228 | + $this->_memory_usage_points[$label] = $memory_used; |
|
229 | + if ($output_now) { |
|
230 | 230 | echo "\r\n<br>$label : $memory_used"; |
231 | 231 | } |
232 | 232 | } |
@@ -236,9 +236,9 @@ discard block |
||
236 | 236 | * @param int $size |
237 | 237 | * @return string |
238 | 238 | */ |
239 | - public function convert( $size ) { |
|
240 | - $unit=array('b','kb','mb','gb','tb','pb'); |
|
241 | - return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[ absint( $i ) ]; |
|
239 | + public function convert($size) { |
|
240 | + $unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb'); |
|
241 | + return @round($size / pow(1024, ($i = floor(log($size, 1024)))), 2).' '.$unit[absint($i)]; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | * @param bool $output_now |
249 | 249 | * @return string |
250 | 250 | */ |
251 | - public function show_times($output_now=true){ |
|
252 | - $output = '<h2>Times:</h2>' . implode("<br>",$this->_times) . '<h2>Memory</h2>' . implode('<br>', $this->_memory_usage_points ); |
|
253 | - if($output_now){ |
|
251 | + public function show_times($output_now = true) { |
|
252 | + $output = '<h2>Times:</h2>'.implode("<br>", $this->_times).'<h2>Memory</h2>'.implode('<br>', $this->_memory_usage_points); |
|
253 | + if ($output_now) { |
|
254 | 254 | echo $output; |
255 | 255 | return ''; |
256 | 256 | } |
@@ -265,25 +265,25 @@ discard block |
||
265 | 265 | * @return void |
266 | 266 | */ |
267 | 267 | public static function ee_plugin_activation_errors() { |
268 | - if ( WP_DEBUG ) { |
|
268 | + if (WP_DEBUG) { |
|
269 | 269 | $activation_errors = ob_get_contents(); |
270 | - if ( ! empty( $activation_errors ) ) { |
|
271 | - $activation_errors = date( 'Y-m-d H:i:s' ) . "\n" . $activation_errors; |
|
270 | + if ( ! empty($activation_errors)) { |
|
271 | + $activation_errors = date('Y-m-d H:i:s')."\n".$activation_errors; |
|
272 | 272 | } |
273 | - espresso_load_required( 'EEH_File', EE_HELPERS . 'EEH_File.helper.php' ); |
|
274 | - if ( class_exists( 'EEH_File' )) { |
|
273 | + espresso_load_required('EEH_File', EE_HELPERS.'EEH_File.helper.php'); |
|
274 | + if (class_exists('EEH_File')) { |
|
275 | 275 | try { |
276 | - EEH_File::ensure_file_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html' ); |
|
277 | - EEH_File::write_to_file( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors ); |
|
278 | - } catch( EE_Error $e ){ |
|
279 | - EE_Error::add_error( sprintf( __( 'The Event Espresso activation errors file could not be setup because: %s', 'event_espresso' ), $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
276 | + EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html'); |
|
277 | + EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors); |
|
278 | + } catch (EE_Error $e) { |
|
279 | + EE_Error::add_error(sprintf(__('The Event Espresso activation errors file could not be setup because: %s', 'event_espresso'), $e->getMessage()), __FILE__, __FUNCTION__, __LINE__); |
|
280 | 280 | } |
281 | 281 | } else { |
282 | 282 | // old school attempt |
283 | - file_put_contents( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors ); |
|
283 | + file_put_contents(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors); |
|
284 | 284 | } |
285 | - $activation_errors = get_option( 'ee_plugin_activation_errors', '' ) . $activation_errors; |
|
286 | - update_option( 'ee_plugin_activation_errors', $activation_errors ); |
|
285 | + $activation_errors = get_option('ee_plugin_activation_errors', '').$activation_errors; |
|
286 | + update_option('ee_plugin_activation_errors', $activation_errors); |
|
287 | 287 | } |
288 | 288 | } |
289 | 289 | |
@@ -299,22 +299,22 @@ discard block |
||
299 | 299 | * @param int $error_type |
300 | 300 | * @uses trigger_error() |
301 | 301 | */ |
302 | - public function doing_it_wrong( $function, $message, $version, $error_type = E_USER_NOTICE ) { |
|
303 | - do_action( 'AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version); |
|
304 | - $version = is_null( $version ) ? '' : sprintf( __('(This message was added in version %s of Event Espresso.', 'event_espresso' ), $version ); |
|
305 | - $error_message = sprintf( esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s','event_espresso' ), $function, '<strong>', '</strong>', $message, $version ); |
|
302 | + public function doing_it_wrong($function, $message, $version, $error_type = E_USER_NOTICE) { |
|
303 | + do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version); |
|
304 | + $version = is_null($version) ? '' : sprintf(__('(This message was added in version %s of Event Espresso.', 'event_espresso'), $version); |
|
305 | + $error_message = sprintf(esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s', 'event_espresso'), $function, '<strong>', '</strong>', $message, $version); |
|
306 | 306 | |
307 | 307 | //don't trigger error if doing ajax, instead we'll add a transient EE_Error notice that in theory should show on the next request. |
308 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
309 | - $error_message .= ' ' . esc_html__( 'This is a doing_it_wrong message that was triggered during an ajax request. The request params on this request were: ', 'event_espresso' ); |
|
308 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
309 | + $error_message .= ' '.esc_html__('This is a doing_it_wrong message that was triggered during an ajax request. The request params on this request were: ', 'event_espresso'); |
|
310 | 310 | $error_message .= '<ul><li>'; |
311 | - $error_message .= implode( '</li><li>', EE_Registry::instance()->REQ->params() ); |
|
311 | + $error_message .= implode('</li><li>', EE_Registry::instance()->REQ->params()); |
|
312 | 312 | $error_message .= '</ul>'; |
313 | - EE_Error::add_error( $error_message, 'debug::doing_it_wrong', $function, '42' ); |
|
313 | + EE_Error::add_error($error_message, 'debug::doing_it_wrong', $function, '42'); |
|
314 | 314 | //now we set this on the transient so it shows up on the next request. |
315 | - EE_Error::get_notices( is_admin(), true ); |
|
315 | + EE_Error::get_notices(is_admin(), true); |
|
316 | 316 | } else { |
317 | - trigger_error( $error_message, $error_type ); |
|
317 | + trigger_error($error_message, $error_type); |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | |
@@ -336,22 +336,22 @@ discard block |
||
336 | 336 | * @param string $debug_index |
337 | 337 | * @param string $debug_key |
338 | 338 | */ |
339 | - public static function log( $class='', $func = '', $line = '', $info = array(), $display_request = false, $debug_index = '', $debug_key = 'EE_DEBUG_SPCO' ) { |
|
340 | - if ( WP_DEBUG && false ) { |
|
341 | - $debug_key = $debug_key . '_' . EE_Session::instance()->id(); |
|
342 | - $debug_data = get_option( $debug_key, array() ); |
|
339 | + public static function log($class = '', $func = '', $line = '', $info = array(), $display_request = false, $debug_index = '', $debug_key = 'EE_DEBUG_SPCO') { |
|
340 | + if (WP_DEBUG && false) { |
|
341 | + $debug_key = $debug_key.'_'.EE_Session::instance()->id(); |
|
342 | + $debug_data = get_option($debug_key, array()); |
|
343 | 343 | $default_data = array( |
344 | - $class => $func . '() : ' . $line, |
|
344 | + $class => $func.'() : '.$line, |
|
345 | 345 | 'REQ' => $display_request ? $_REQUEST : '', |
346 | 346 | ); |
347 | 347 | // don't serialize objects |
348 | - $info = self::strip_objects( $info ); |
|
349 | - $index = ! empty( $debug_index ) ? $debug_index : 0; |
|
350 | - if ( ! isset( $debug_data[$index] ) ) { |
|
348 | + $info = self::strip_objects($info); |
|
349 | + $index = ! empty($debug_index) ? $debug_index : 0; |
|
350 | + if ( ! isset($debug_data[$index])) { |
|
351 | 351 | $debug_data[$index] = array(); |
352 | 352 | } |
353 | - $debug_data[$index][microtime()] = array_merge( $default_data, $info ); |
|
354 | - update_option( $debug_key, $debug_data ); |
|
353 | + $debug_data[$index][microtime()] = array_merge($default_data, $info); |
|
354 | + update_option($debug_key, $debug_data); |
|
355 | 355 | } |
356 | 356 | } |
357 | 357 | |
@@ -363,26 +363,26 @@ discard block |
||
363 | 363 | * @param array $info |
364 | 364 | * @return array |
365 | 365 | */ |
366 | - public static function strip_objects( $info = array() ) { |
|
367 | - foreach ( $info as $key => $value ) { |
|
368 | - if ( is_array( $value ) ) { |
|
369 | - $info[ $key ] = self::strip_objects( $value ); |
|
370 | - } else if ( is_object( $value ) ) { |
|
371 | - $object_class = get_class( $value ); |
|
372 | - $info[ $object_class ] = array(); |
|
373 | - $info[ $object_class ][ 'ID' ] = method_exists( $value, 'ID' ) ? $value->ID() : spl_object_hash( $value ); |
|
374 | - if ( method_exists( $value, 'ID' ) ) { |
|
375 | - $info[ $object_class ][ 'ID' ] = $value->ID(); |
|
366 | + public static function strip_objects($info = array()) { |
|
367 | + foreach ($info as $key => $value) { |
|
368 | + if (is_array($value)) { |
|
369 | + $info[$key] = self::strip_objects($value); |
|
370 | + } else if (is_object($value)) { |
|
371 | + $object_class = get_class($value); |
|
372 | + $info[$object_class] = array(); |
|
373 | + $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value); |
|
374 | + if (method_exists($value, 'ID')) { |
|
375 | + $info[$object_class]['ID'] = $value->ID(); |
|
376 | 376 | } |
377 | - if ( method_exists( $value, 'status' ) ) { |
|
378 | - $info[ $object_class ][ 'status' ] = $value->status(); |
|
379 | - } else if ( method_exists( $value, 'status_ID' ) ) { |
|
380 | - $info[ $object_class ][ 'status' ] = $value->status_ID(); |
|
377 | + if (method_exists($value, 'status')) { |
|
378 | + $info[$object_class]['status'] = $value->status(); |
|
379 | + } else if (method_exists($value, 'status_ID')) { |
|
380 | + $info[$object_class]['status'] = $value->status_ID(); |
|
381 | 381 | } |
382 | - unset( $info[ $key ] ); |
|
382 | + unset($info[$key]); |
|
383 | 383 | } |
384 | 384 | } |
385 | - return (array)$info; |
|
385 | + return (array) $info; |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | |
@@ -399,42 +399,42 @@ discard block |
||
399 | 399 | * @param string $height |
400 | 400 | * @param bool $die |
401 | 401 | */ |
402 | - public static function printr( $var, $var_name = false, $file = __FILE__, $line = __LINE__, $height = 'auto', $die = false ) { |
|
402 | + public static function printr($var, $var_name = false, $file = __FILE__, $line = __LINE__, $height = 'auto', $die = false) { |
|
403 | 403 | //$print_r = false; |
404 | - if ( is_object( $var ) ) { |
|
404 | + if (is_object($var)) { |
|
405 | 405 | $var_name = ! $var_name ? 'object' : $var_name; |
406 | 406 | //$print_r = true; |
407 | - } else if ( is_array( $var ) ) { |
|
407 | + } else if (is_array($var)) { |
|
408 | 408 | $var_name = ! $var_name ? 'array' : $var_name; |
409 | 409 | //$print_r = true; |
410 | - } else if ( is_numeric( $var ) ) { |
|
410 | + } else if (is_numeric($var)) { |
|
411 | 411 | $var_name = ! $var_name ? 'numeric' : $var_name; |
412 | - } else if ( is_string( $var ) ) { |
|
412 | + } else if (is_string($var)) { |
|
413 | 413 | $var_name = ! $var_name ? 'string' : $var_name; |
414 | - } else if ( is_null( $var ) ) { |
|
414 | + } else if (is_null($var)) { |
|
415 | 415 | $var_name = ! $var_name ? 'null' : $var_name; |
416 | 416 | } else { |
417 | - $var_name = ucwords( str_replace( array( '$', '_' ), array( '', ' ' ), $var_name ) ); |
|
417 | + $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name)); |
|
418 | 418 | } |
419 | 419 | $margin = is_admin() ? 'margin-left:180px;' : ''; |
420 | 420 | ob_start(); |
421 | 421 | echo '<pre style="display:block;width:100%;height:'.$height.';border:2px solid light-blue;'.$margin.'">'; |
422 | 422 | //$print_r ? print_r( $var ) : var_dump( $var ); |
423 | - if ( is_string( $var ) && strpos( $file, $var_name ) !== false ) { |
|
424 | - echo '<h3 style="color:#999;line-height:.9em;margin: 1em 0 0;"><span style="color:#2EA2CC">' . $var_name |
|
425 | - . '</span>::<span style="color:#E76700">' . $var . '()</span></h3>'; |
|
426 | - } else if ( is_string( $var ) ) { |
|
427 | - echo '<h4 style="color:#2EA2CC;margin:0;">' . $var_name . ' : <span style="color:#E76700">' . $var . '</span></h4>'; |
|
423 | + if (is_string($var) && strpos($file, $var_name) !== false) { |
|
424 | + echo '<h3 style="color:#999;line-height:.9em;margin: 1em 0 0;"><span style="color:#2EA2CC">'.$var_name |
|
425 | + . '</span>::<span style="color:#E76700">'.$var.'()</span></h3>'; |
|
426 | + } else if (is_string($var)) { |
|
427 | + echo '<h4 style="color:#2EA2CC;margin:0;">'.$var_name.' : <span style="color:#E76700">'.$var.'</span></h4>'; |
|
428 | 428 | } else { |
429 | - echo '<h4 style="color:#2EA2CC;"><b>' . $var_name . '</b></h4><span style="color:#E76700">'; |
|
430 | - var_dump( $var ); |
|
429 | + echo '<h4 style="color:#2EA2CC;"><b>'.$var_name.'</b></h4><span style="color:#E76700">'; |
|
430 | + var_dump($var); |
|
431 | 431 | echo '</span><br />'; |
432 | 432 | } |
433 | - $file = str_replace( rtrim( EE_PLUGIN_DIR_PATH, '/' ), '', $file ); |
|
434 | - echo '<span style="color:#666;font-size:10px;font-weight:normal;">' . $file . ' : ' . $line . '</span></pre>'; |
|
433 | + $file = str_replace(rtrim(EE_PLUGIN_DIR_PATH, '/'), '', $file); |
|
434 | + echo '<span style="color:#666;font-size:10px;font-weight:normal;">'.$file.' : '.$line.'</span></pre>'; |
|
435 | 435 | $result = ob_get_clean(); |
436 | - if ( $die ) { |
|
437 | - die( $result ); |
|
436 | + if ($die) { |
|
437 | + die($result); |
|
438 | 438 | } else { |
439 | 439 | echo $result; |
440 | 440 | } |
@@ -451,8 +451,8 @@ discard block |
||
451 | 451 | * borrowed from Kint Debugger |
452 | 452 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
453 | 453 | */ |
454 | -if ( class_exists('Kint') && ! function_exists( 'dump_wp_query' ) ) { |
|
455 | - function dump_wp_query(){ |
|
454 | +if (class_exists('Kint') && ! function_exists('dump_wp_query')) { |
|
455 | + function dump_wp_query() { |
|
456 | 456 | global $wp_query; |
457 | 457 | d($wp_query); |
458 | 458 | } |
@@ -462,8 +462,8 @@ discard block |
||
462 | 462 | * borrowed from Kint Debugger |
463 | 463 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
464 | 464 | */ |
465 | -if ( class_exists('Kint') && ! function_exists( 'dump_wp' ) ) { |
|
466 | - function dump_wp(){ |
|
465 | +if (class_exists('Kint') && ! function_exists('dump_wp')) { |
|
466 | + function dump_wp() { |
|
467 | 467 | global $wp; |
468 | 468 | d($wp); |
469 | 469 | } |
@@ -473,8 +473,8 @@ discard block |
||
473 | 473 | * borrowed from Kint Debugger |
474 | 474 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
475 | 475 | */ |
476 | -if ( class_exists('Kint') && ! function_exists( 'dump_post' ) ) { |
|
477 | - function dump_post(){ |
|
476 | +if (class_exists('Kint') && ! function_exists('dump_post')) { |
|
477 | + function dump_post() { |
|
478 | 478 | global $post; |
479 | 479 | d($post); |
480 | 480 | } |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | * @param $table_name |
58 | 58 | * @return string |
59 | 59 | */ |
60 | - public static function ensure_table_name_has_prefix( $table_name ) { |
|
60 | + public static function ensure_table_name_has_prefix($table_name) { |
|
61 | 61 | global $wpdb; |
62 | - return strpos( $table_name, $wpdb->prefix ) === 0 ? $table_name : $wpdb->prefix . $table_name; |
|
62 | + return strpos($table_name, $wpdb->prefix) === 0 ? $table_name : $wpdb->prefix.$table_name; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * be called on plugin activation and reactivation |
86 | 86 | * @return boolean success, whether the database and folders are setup properly |
87 | 87 | */ |
88 | - public static function initialize_db_and_folders(){ |
|
88 | + public static function initialize_db_and_folders() { |
|
89 | 89 | $good_filesystem = EEH_Activation::create_upload_directories(); |
90 | 90 | $good_db = EEH_Activation::create_database_tables(); |
91 | 91 | return $good_filesystem && $good_db; |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | * upon activation of a new plugin, reactivation, and at the end |
100 | 100 | * of running migration scripts |
101 | 101 | */ |
102 | - public static function initialize_db_content(){ |
|
102 | + public static function initialize_db_content() { |
|
103 | 103 | //let's avoid doing all this logic repeatedly, especially when addons are requesting it |
104 | - if( EEH_Activation::$_initialized_db_content_already_in_this_request ) { |
|
104 | + if (EEH_Activation::$_initialized_db_content_already_in_this_request) { |
|
105 | 105 | return; |
106 | 106 | } |
107 | 107 | EEH_Activation::$_initialized_db_content_already_in_this_request = true; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | EEH_Activation::remove_cron_tasks(); |
119 | 119 | EEH_Activation::create_cron_tasks(); |
120 | 120 | //also, check for CAF default db content |
121 | - do_action( 'AHEE__EEH_Activation__initialize_db_content' ); |
|
121 | + do_action('AHEE__EEH_Activation__initialize_db_content'); |
|
122 | 122 | //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages |
123 | 123 | //which users really won't care about on initial activation |
124 | 124 | EE_Error::overwrite_success(); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @return array |
139 | 139 | * @throws \EE_Error |
140 | 140 | */ |
141 | - public static function get_cron_tasks( $which_to_include ) { |
|
141 | + public static function get_cron_tasks($which_to_include) { |
|
142 | 142 | $cron_tasks = apply_filters( |
143 | 143 | 'FHEE__EEH_Activation__get_cron_tasks', |
144 | 144 | array( |
@@ -147,17 +147,17 @@ discard block |
||
147 | 147 | 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates |
148 | 148 | ) |
149 | 149 | ); |
150 | - if( $which_to_include === 'all' ) { |
|
150 | + if ($which_to_include === 'all') { |
|
151 | 151 | //leave as-is |
152 | - }elseif( $which_to_include === 'old' ) { |
|
153 | - $cron_tasks = array_filter( $cron_tasks, function ( $value ) { |
|
152 | + }elseif ($which_to_include === 'old') { |
|
153 | + $cron_tasks = array_filter($cron_tasks, function($value) { |
|
154 | 154 | return $value === EEH_Activation::cron_task_no_longer_in_use; |
155 | 155 | }); |
156 | - }elseif( $which_to_include === 'current' ) { |
|
157 | - $cron_tasks = array_filter( $cron_tasks ); |
|
158 | - }elseif( WP_DEBUG ) { |
|
159 | - throw new EE_Error( sprintf( __( 'Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso' ), $which_to_include ) ); |
|
160 | - }else{ |
|
156 | + }elseif ($which_to_include === 'current') { |
|
157 | + $cron_tasks = array_filter($cron_tasks); |
|
158 | + }elseif (WP_DEBUG) { |
|
159 | + throw new EE_Error(sprintf(__('Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso'), $which_to_include)); |
|
160 | + } else { |
|
161 | 161 | //leave as-is |
162 | 162 | } |
163 | 163 | return $cron_tasks; |
@@ -168,9 +168,9 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public static function create_cron_tasks() { |
170 | 170 | |
171 | - foreach( EEH_Activation::get_cron_tasks( 'current' ) as $hook_name => $frequency ) { |
|
172 | - if( ! wp_next_scheduled( $hook_name ) ) { |
|
173 | - wp_schedule_event( time(), $frequency, $hook_name ); |
|
171 | + foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) { |
|
172 | + if ( ! wp_next_scheduled($hook_name)) { |
|
173 | + wp_schedule_event(time(), $frequency, $hook_name); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
@@ -180,10 +180,10 @@ discard block |
||
180 | 180 | * Remove the currently-existing and now-removed cron tasks. |
181 | 181 | * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones |
182 | 182 | */ |
183 | - public static function remove_cron_tasks( $remove_all = true ) { |
|
183 | + public static function remove_cron_tasks($remove_all = true) { |
|
184 | 184 | $cron_tasks_to_remove = $remove_all ? 'all' : 'old'; |
185 | 185 | $crons = _get_cron_array(); |
186 | - $crons = is_array( $crons ) ? $crons : array(); |
|
186 | + $crons = is_array($crons) ? $crons : array(); |
|
187 | 187 | /* reminder that $crons looks like: top-level keys are timestamps, |
188 | 188 | * and their values are arrays. |
189 | 189 | * The 2nd level arrays have keys with each of the cron task hooknames to run at that time |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | * ... |
202 | 202 | * ... |
203 | 203 | */ |
204 | - foreach( EEH_Activation::get_cron_tasks( $cron_tasks_to_remove ) as $hook_name => $frequency ) { |
|
205 | - foreach( $crons as $timestamp => $hooks_to_fire_at_time ) { |
|
206 | - if ( array_key_exists( $hook_name, $hooks_to_fire_at_time ) ) { |
|
207 | - unset( $crons[ $timestamp ][ $hook_name ] ); |
|
204 | + foreach (EEH_Activation::get_cron_tasks($cron_tasks_to_remove) as $hook_name => $frequency) { |
|
205 | + foreach ($crons as $timestamp => $hooks_to_fire_at_time) { |
|
206 | + if (array_key_exists($hook_name, $hooks_to_fire_at_time)) { |
|
207 | + unset($crons[$timestamp][$hook_name]); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | } |
211 | - _set_cron_array( $crons ); |
|
211 | + _set_cron_array($crons); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public static function CPT_initialization() { |
225 | 225 | // register Custom Post Types |
226 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
226 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
227 | 227 | flush_rewrite_rules(); |
228 | 228 | } |
229 | 229 | |
@@ -241,8 +241,8 @@ discard block |
||
241 | 241 | * @return void |
242 | 242 | */ |
243 | 243 | public static function reset_and_update_config() { |
244 | - do_action( 'AHEE__EE_Config___load_core_config__start', array( 'EEH_Activation', 'load_calendar_config' ) ); |
|
245 | - add_filter( 'FHEE__EE_Config___load_core_config__config_settings', array( 'EEH_Activation', 'migrate_old_config_data' ), 10, 3 ); |
|
244 | + do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config')); |
|
245 | + add_filter('FHEE__EE_Config___load_core_config__config_settings', array('EEH_Activation', 'migrate_old_config_data'), 10, 3); |
|
246 | 246 | //EE_Config::reset(); |
247 | 247 | } |
248 | 248 | |
@@ -255,23 +255,23 @@ discard block |
||
255 | 255 | */ |
256 | 256 | public static function load_calendar_config() { |
257 | 257 | // grab array of all plugin folders and loop thru it |
258 | - $plugins = glob( WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR ); |
|
259 | - if ( empty( $plugins ) ) { |
|
258 | + $plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR); |
|
259 | + if (empty($plugins)) { |
|
260 | 260 | return; |
261 | 261 | } |
262 | - foreach ( $plugins as $plugin_path ) { |
|
262 | + foreach ($plugins as $plugin_path) { |
|
263 | 263 | // grab plugin folder name from path |
264 | - $plugin = basename( $plugin_path ); |
|
264 | + $plugin = basename($plugin_path); |
|
265 | 265 | // drill down to Espresso plugins |
266 | - if ( strpos( $plugin, 'espresso' ) !== FALSE || strpos( $plugin, 'Espresso' ) !== FALSE || strpos( $plugin, 'ee4' ) !== FALSE || strpos( $plugin, 'EE4' ) !== FALSE ) { |
|
266 | + if (strpos($plugin, 'espresso') !== FALSE || strpos($plugin, 'Espresso') !== FALSE || strpos($plugin, 'ee4') !== FALSE || strpos($plugin, 'EE4') !== FALSE) { |
|
267 | 267 | // then to calendar related plugins |
268 | - if ( strpos( $plugin, 'calendar' ) !== FALSE ) { |
|
268 | + if (strpos($plugin, 'calendar') !== FALSE) { |
|
269 | 269 | // this is what we are looking for |
270 | - $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php'; |
|
270 | + $calendar_config = $plugin_path.DS.'EE_Calendar_Config.php'; |
|
271 | 271 | // does it exist in this folder ? |
272 | - if ( is_readable( $calendar_config )) { |
|
272 | + if (is_readable($calendar_config)) { |
|
273 | 273 | // YEAH! let's load it |
274 | - require_once( $calendar_config ); |
|
274 | + require_once($calendar_config); |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | } |
@@ -288,21 +288,21 @@ discard block |
||
288 | 288 | * @param \EE_Config $EE_Config |
289 | 289 | * @return \stdClass |
290 | 290 | */ |
291 | - public static function migrate_old_config_data( $settings = array(), $config = '', EE_Config $EE_Config ) { |
|
292 | - $convert_from_array = array( 'addons' ); |
|
291 | + public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) { |
|
292 | + $convert_from_array = array('addons'); |
|
293 | 293 | // in case old settings were saved as an array |
294 | - if ( is_array( $settings ) && in_array( $config, $convert_from_array )) { |
|
294 | + if (is_array($settings) && in_array($config, $convert_from_array)) { |
|
295 | 295 | // convert existing settings to an object |
296 | 296 | $config_array = $settings; |
297 | 297 | $settings = new stdClass(); |
298 | - foreach ( $config_array as $key => $value ){ |
|
299 | - if ( $key == 'calendar' && class_exists( 'EE_Calendar_Config' )) { |
|
300 | - $EE_Config->set_config( 'addons', 'EE_Calendar', 'EE_Calendar_Config', $value ); |
|
298 | + foreach ($config_array as $key => $value) { |
|
299 | + if ($key == 'calendar' && class_exists('EE_Calendar_Config')) { |
|
300 | + $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value); |
|
301 | 301 | } else { |
302 | 302 | $settings->$key = $value; |
303 | 303 | } |
304 | 304 | } |
305 | - add_filter( 'FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true' ); |
|
305 | + add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true'); |
|
306 | 306 | } |
307 | 307 | return $settings; |
308 | 308 | } |
@@ -318,8 +318,8 @@ discard block |
||
318 | 318 | */ |
319 | 319 | public static function deactivate_event_espresso() { |
320 | 320 | // check permissions |
321 | - if ( current_user_can( 'activate_plugins' )) { |
|
322 | - deactivate_plugins( EE_PLUGIN_BASENAME, TRUE ); |
|
321 | + if (current_user_can('activate_plugins')) { |
|
322 | + deactivate_plugins(EE_PLUGIN_BASENAME, TRUE); |
|
323 | 323 | } |
324 | 324 | } |
325 | 325 | |
@@ -341,79 +341,79 @@ discard block |
||
341 | 341 | $critical_pages = array( |
342 | 342 | array( |
343 | 343 | 'id' =>'reg_page_id', |
344 | - 'name' => __( 'Registration Checkout', 'event_espresso' ), |
|
344 | + 'name' => __('Registration Checkout', 'event_espresso'), |
|
345 | 345 | 'post' => NULL, |
346 | 346 | 'code' => 'ESPRESSO_CHECKOUT' |
347 | 347 | ), |
348 | 348 | array( |
349 | 349 | 'id' => 'txn_page_id', |
350 | - 'name' => __( 'Transactions', 'event_espresso' ), |
|
350 | + 'name' => __('Transactions', 'event_espresso'), |
|
351 | 351 | 'post' => NULL, |
352 | 352 | 'code' => 'ESPRESSO_TXN_PAGE' |
353 | 353 | ), |
354 | 354 | array( |
355 | 355 | 'id' => 'thank_you_page_id', |
356 | - 'name' => __( 'Thank You', 'event_espresso' ), |
|
356 | + 'name' => __('Thank You', 'event_espresso'), |
|
357 | 357 | 'post' => NULL, |
358 | 358 | 'code' => 'ESPRESSO_THANK_YOU' |
359 | 359 | ), |
360 | 360 | array( |
361 | 361 | 'id' => 'cancel_page_id', |
362 | - 'name' => __( 'Registration Cancelled', 'event_espresso' ), |
|
362 | + 'name' => __('Registration Cancelled', 'event_espresso'), |
|
363 | 363 | 'post' => NULL, |
364 | 364 | 'code' => 'ESPRESSO_CANCELLED' |
365 | 365 | ), |
366 | 366 | ); |
367 | 367 | |
368 | - foreach ( $critical_pages as $critical_page ) { |
|
368 | + foreach ($critical_pages as $critical_page) { |
|
369 | 369 | // is critical page ID set in config ? |
370 | - if ( EE_Registry::instance()->CFG->core->$critical_page['id'] !== FALSE ) { |
|
370 | + if (EE_Registry::instance()->CFG->core->$critical_page['id'] !== FALSE) { |
|
371 | 371 | // attempt to find post by ID |
372 | - $critical_page['post'] = get_post( EE_Registry::instance()->CFG->core->$critical_page['id'] ); |
|
372 | + $critical_page['post'] = get_post(EE_Registry::instance()->CFG->core->$critical_page['id']); |
|
373 | 373 | } |
374 | 374 | // no dice? |
375 | - if ( $critical_page['post'] == NULL ) { |
|
375 | + if ($critical_page['post'] == NULL) { |
|
376 | 376 | // attempt to find post by title |
377 | - $critical_page['post'] = self::get_page_by_ee_shortcode( $critical_page['code'] ); |
|
377 | + $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']); |
|
378 | 378 | // still nothing? |
379 | - if ( $critical_page['post'] == NULL ) { |
|
380 | - $critical_page = EEH_Activation::create_critical_page( $critical_page ); |
|
379 | + if ($critical_page['post'] == NULL) { |
|
380 | + $critical_page = EEH_Activation::create_critical_page($critical_page); |
|
381 | 381 | // REALLY? Still nothing ??!?!? |
382 | - if ( $critical_page['post'] == NULL ) { |
|
383 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
384 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
382 | + if ($critical_page['post'] == NULL) { |
|
383 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
384 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
385 | 385 | break; |
386 | 386 | } |
387 | 387 | } |
388 | 388 | } |
389 | 389 | // track post_shortcodes |
390 | - if ( $critical_page['post'] ) { |
|
391 | - EEH_Activation::_track_critical_page_post_shortcodes( $critical_page ); |
|
390 | + if ($critical_page['post']) { |
|
391 | + EEH_Activation::_track_critical_page_post_shortcodes($critical_page); |
|
392 | 392 | } |
393 | 393 | // check that Post ID matches critical page ID in config |
394 | - if ( isset( $critical_page['post']->ID ) && $critical_page['post']->ID != EE_Registry::instance()->CFG->core->$critical_page['id'] ) { |
|
394 | + if (isset($critical_page['post']->ID) && $critical_page['post']->ID != EE_Registry::instance()->CFG->core->$critical_page['id']) { |
|
395 | 395 | //update Config with post ID |
396 | 396 | EE_Registry::instance()->CFG->core->$critical_page['id'] = $critical_page['post']->ID; |
397 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE ) ) { |
|
398 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
399 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
397 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
398 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
399 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
400 | 400 | } |
401 | 401 | } |
402 | 402 | |
403 | - $critical_page_problem = ! isset( $critical_page['post']->post_status ) || $critical_page['post']->post_status != 'publish' || strpos( $critical_page['post']->post_content, $critical_page['code'] ) === FALSE ? TRUE : $critical_page_problem; |
|
403 | + $critical_page_problem = ! isset($critical_page['post']->post_status) || $critical_page['post']->post_status != 'publish' || strpos($critical_page['post']->post_content, $critical_page['code']) === FALSE ? TRUE : $critical_page_problem; |
|
404 | 404 | |
405 | 405 | } |
406 | 406 | |
407 | - if ( $critical_page_problem ) { |
|
407 | + if ($critical_page_problem) { |
|
408 | 408 | $msg = sprintf( |
409 | - __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso' ), |
|
410 | - '<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">' . __('Event Espresso Critical Pages Settings', 'event_espresso') . '</a>' |
|
409 | + __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso'), |
|
410 | + '<a href="'.admin_url('admin.php?page=espresso_general_settings&action=critical_pages').'">'.__('Event Espresso Critical Pages Settings', 'event_espresso').'</a>' |
|
411 | 411 | ); |
412 | - EE_Error::add_persistent_admin_notice( 'critical_page_problem', $msg ); |
|
412 | + EE_Error::add_persistent_admin_notice('critical_page_problem', $msg); |
|
413 | 413 | } |
414 | 414 | |
415 | - if ( EE_Error::has_notices() ) { |
|
416 | - EE_Error::get_notices( FALSE, TRUE, TRUE ); |
|
415 | + if (EE_Error::has_notices()) { |
|
416 | + EE_Error::get_notices(FALSE, TRUE, TRUE); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | } |
@@ -426,13 +426,13 @@ discard block |
||
426 | 426 | * parameter to the shortcode |
427 | 427 | * @return WP_Post or NULl |
428 | 428 | */ |
429 | - public static function get_page_by_ee_shortcode($ee_shortcode){ |
|
429 | + public static function get_page_by_ee_shortcode($ee_shortcode) { |
|
430 | 430 | global $wpdb; |
431 | 431 | $shortcode_and_opening_bracket = '['.$ee_shortcode; |
432 | 432 | $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
433 | - if($post_id){ |
|
433 | + if ($post_id) { |
|
434 | 434 | return get_post($post_id); |
435 | - }else{ |
|
435 | + } else { |
|
436 | 436 | return NULL; |
437 | 437 | } |
438 | 438 | |
@@ -449,32 +449,32 @@ discard block |
||
449 | 449 | * @param array $critical_page |
450 | 450 | * @return array |
451 | 451 | */ |
452 | - public static function create_critical_page( $critical_page ) { |
|
452 | + public static function create_critical_page($critical_page) { |
|
453 | 453 | |
454 | 454 | $post_args = array( |
455 | 455 | 'post_title' => $critical_page['name'], |
456 | 456 | 'post_status' => 'publish', |
457 | 457 | 'post_type' => 'page', |
458 | 458 | 'comment_status' => 'closed', |
459 | - 'post_content' => '[' . $critical_page['code'] . ']' |
|
459 | + 'post_content' => '['.$critical_page['code'].']' |
|
460 | 460 | ); |
461 | 461 | |
462 | - $post_id = wp_insert_post( $post_args ); |
|
463 | - if ( ! $post_id ) { |
|
462 | + $post_id = wp_insert_post($post_args); |
|
463 | + if ( ! $post_id) { |
|
464 | 464 | $msg = sprintf( |
465 | - __( 'The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso' ), |
|
465 | + __('The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso'), |
|
466 | 466 | $critical_page['name'] |
467 | 467 | ); |
468 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
468 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
469 | 469 | return $critical_page; |
470 | 470 | } |
471 | 471 | // get newly created post's details |
472 | - if ( ! $critical_page['post'] = get_post( $post_id )) { |
|
472 | + if ( ! $critical_page['post'] = get_post($post_id)) { |
|
473 | 473 | $msg = sprintf( |
474 | - __( 'The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso' ), |
|
474 | + __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'), |
|
475 | 475 | $critical_page['name'] |
476 | 476 | ); |
477 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
477 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | return $critical_page; |
@@ -493,34 +493,34 @@ discard block |
||
493 | 493 | * @param array $critical_page |
494 | 494 | * @return void |
495 | 495 | */ |
496 | - private static function _track_critical_page_post_shortcodes( $critical_page = array() ) { |
|
496 | + private static function _track_critical_page_post_shortcodes($critical_page = array()) { |
|
497 | 497 | // check the goods |
498 | - if ( ! $critical_page['post'] instanceof WP_Post ) { |
|
498 | + if ( ! $critical_page['post'] instanceof WP_Post) { |
|
499 | 499 | $msg = sprintf( |
500 | - __( 'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso' ), |
|
500 | + __('The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso'), |
|
501 | 501 | $critical_page['name'] |
502 | 502 | ); |
503 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
503 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
504 | 504 | return; |
505 | 505 | } |
506 | 506 | // map shortcode to post |
507 | - EE_Registry::instance()->CFG->core->post_shortcodes[ $critical_page['post']->post_name ][ $critical_page['code'] ] = $critical_page['post']->ID; |
|
507 | + EE_Registry::instance()->CFG->core->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID; |
|
508 | 508 | // and make sure it's NOT added to the WP "Posts Page" |
509 | 509 | // name of the WP Posts Page |
510 | 510 | $posts_page = EE_Registry::instance()->CFG->get_page_for_posts(); |
511 | - if ( isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $posts_page ] )) { |
|
512 | - unset( EE_Registry::instance()->CFG->core->post_shortcodes[ $posts_page ][ $critical_page['code'] ] ); |
|
511 | + if (isset(EE_Registry::instance()->CFG->core->post_shortcodes[$posts_page])) { |
|
512 | + unset(EE_Registry::instance()->CFG->core->post_shortcodes[$posts_page][$critical_page['code']]); |
|
513 | 513 | } |
514 | - if ( $posts_page != 'posts' && isset( EE_Registry::instance()->CFG->core->post_shortcodes['posts'] )) { |
|
515 | - unset( EE_Registry::instance()->CFG->core->post_shortcodes['posts'][ $critical_page['code'] ] ); |
|
514 | + if ($posts_page != 'posts' && isset(EE_Registry::instance()->CFG->core->post_shortcodes['posts'])) { |
|
515 | + unset(EE_Registry::instance()->CFG->core->post_shortcodes['posts'][$critical_page['code']]); |
|
516 | 516 | } |
517 | 517 | // update post_shortcode CFG |
518 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE )) { |
|
518 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
519 | 519 | $msg = sprintf( |
520 | - __( 'The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso' ), |
|
520 | + __('The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso'), |
|
521 | 521 | $critical_page['name'] |
522 | 522 | ); |
523 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
523 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
524 | 524 | } |
525 | 525 | } |
526 | 526 | |
@@ -538,24 +538,24 @@ discard block |
||
538 | 538 | public static function get_default_creator_id() { |
539 | 539 | global $wpdb; |
540 | 540 | |
541 | - if ( ! empty( self::$_default_creator_id ) ) { |
|
541 | + if ( ! empty(self::$_default_creator_id)) { |
|
542 | 542 | return self::$_default_creator_id; |
543 | 543 | }/**/ |
544 | 544 | |
545 | - $role_to_check = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator' ); |
|
545 | + $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator'); |
|
546 | 546 | |
547 | 547 | //let's allow pre_filtering for early exits by alternative methods for getting id. We check for truthy result and if so then exit early. |
548 | - $pre_filtered_id = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check ); |
|
549 | - if ( $pre_filtered_id !== false ) { |
|
548 | + $pre_filtered_id = apply_filters('FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check); |
|
549 | + if ($pre_filtered_id !== false) { |
|
550 | 550 | return (int) $pre_filtered_id; |
551 | 551 | } |
552 | 552 | |
553 | - $capabilities_key = EEH_Activation::ensure_table_name_has_prefix( 'capabilities' ); |
|
554 | - $query = $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%' . $role_to_check . '%' ); |
|
555 | - $user_id = $wpdb->get_var( $query ); |
|
556 | - $user_id = apply_filters( 'FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id ); |
|
557 | - if ( $user_id && intval( $user_id ) ) { |
|
558 | - self::$_default_creator_id = intval( $user_id ); |
|
553 | + $capabilities_key = EEH_Activation::ensure_table_name_has_prefix('capabilities'); |
|
554 | + $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%'.$role_to_check.'%'); |
|
555 | + $user_id = $wpdb->get_var($query); |
|
556 | + $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id); |
|
557 | + if ($user_id && intval($user_id)) { |
|
558 | + self::$_default_creator_id = intval($user_id); |
|
559 | 559 | return self::$_default_creator_id; |
560 | 560 | } else { |
561 | 561 | return NULL; |
@@ -582,29 +582,29 @@ discard block |
||
582 | 582 | * @return void |
583 | 583 | * @throws EE_Error if there are database errors |
584 | 584 | */ |
585 | - public static function create_table( $table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false ) { |
|
586 | - if( apply_filters( 'FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql ) ){ |
|
585 | + public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) { |
|
586 | + if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql)) { |
|
587 | 587 | return; |
588 | 588 | } |
589 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
590 | - if ( ! function_exists( 'dbDelta' )) { |
|
591 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
589 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
590 | + if ( ! function_exists('dbDelta')) { |
|
591 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
592 | 592 | } |
593 | 593 | /** @var WPDB $wpdb */ |
594 | 594 | global $wpdb; |
595 | - $wp_table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
595 | + $wp_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
596 | 596 | // do we need to first delete an existing version of this table ? |
597 | - if ( $drop_pre_existing_table && EEH_Activation::table_exists( $wp_table_name ) ){ |
|
597 | + if ($drop_pre_existing_table && EEH_Activation::table_exists($wp_table_name)) { |
|
598 | 598 | // ok, delete the table... but ONLY if it's empty |
599 | - $deleted_safely = EEH_Activation::delete_db_table_if_empty( $wp_table_name ); |
|
599 | + $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name); |
|
600 | 600 | // table is NOT empty, are you SURE you want to delete this table ??? |
601 | - if ( ! $deleted_safely && defined( 'EE_DROP_BAD_TABLES' ) && EE_DROP_BAD_TABLES ){ |
|
602 | - EEH_Activation::delete_unused_db_table( $wp_table_name ); |
|
603 | - } else if ( ! $deleted_safely ) { |
|
601 | + if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) { |
|
602 | + EEH_Activation::delete_unused_db_table($wp_table_name); |
|
603 | + } else if ( ! $deleted_safely) { |
|
604 | 604 | // so we should be more cautious rather than just dropping tables so easily |
605 | 605 | EE_Error::add_persistent_admin_notice( |
606 | - 'bad_table_' . $wp_table_name . '_detected', |
|
607 | - sprintf( __( 'Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso' ), |
|
606 | + 'bad_table_'.$wp_table_name.'_detected', |
|
607 | + sprintf(__('Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso'), |
|
608 | 608 | $wp_table_name, |
609 | 609 | "<pre>define( 'EE_DROP_BAD_TABLES', TRUE );</pre>", |
610 | 610 | '<b>wp-config.php</b>', |
@@ -613,25 +613,25 @@ discard block |
||
613 | 613 | } |
614 | 614 | } |
615 | 615 | // does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns ) |
616 | - if ( preg_match( '((((.*?))(,\s))+)', $sql, $valid_column_data ) ) { |
|
616 | + if (preg_match('((((.*?))(,\s))+)', $sql, $valid_column_data)) { |
|
617 | 617 | $SQL = "CREATE TABLE $wp_table_name ( $sql ) $engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"; |
618 | 618 | //get $wpdb to echo errors, but buffer them. This way at least WE know an error |
619 | 619 | //happened. And then we can choose to tell the end user |
620 | - $old_show_errors_policy = $wpdb->show_errors( TRUE ); |
|
621 | - $old_error_suppression_policy = $wpdb->suppress_errors( FALSE ); |
|
620 | + $old_show_errors_policy = $wpdb->show_errors(TRUE); |
|
621 | + $old_error_suppression_policy = $wpdb->suppress_errors(FALSE); |
|
622 | 622 | ob_start(); |
623 | - dbDelta( $SQL ); |
|
623 | + dbDelta($SQL); |
|
624 | 624 | $output = ob_get_contents(); |
625 | 625 | ob_end_clean(); |
626 | - $wpdb->show_errors( $old_show_errors_policy ); |
|
627 | - $wpdb->suppress_errors( $old_error_suppression_policy ); |
|
628 | - if( ! empty( $output ) ){ |
|
629 | - throw new EE_Error( $output ); |
|
626 | + $wpdb->show_errors($old_show_errors_policy); |
|
627 | + $wpdb->suppress_errors($old_error_suppression_policy); |
|
628 | + if ( ! empty($output)) { |
|
629 | + throw new EE_Error($output); |
|
630 | 630 | } |
631 | 631 | } else { |
632 | 632 | throw new EE_Error( |
633 | 633 | sprintf( |
634 | - __( 'The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso' ), |
|
634 | + __('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso'), |
|
635 | 635 | '<br />', |
636 | 636 | $sql |
637 | 637 | ) |
@@ -654,15 +654,15 @@ discard block |
||
654 | 654 | * 'VARCHAR(10)' |
655 | 655 | * @return bool|int |
656 | 656 | */ |
657 | - public static function add_column_if_it_doesnt_exist($table_name,$column_name,$column_info='INT UNSIGNED NOT NULL'){ |
|
658 | - if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){ |
|
657 | + public static function add_column_if_it_doesnt_exist($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') { |
|
658 | + if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE)) { |
|
659 | 659 | return FALSE; |
660 | 660 | } |
661 | 661 | global $wpdb; |
662 | - $full_table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
662 | + $full_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
663 | 663 | $fields = self::get_fields_on_table($table_name); |
664 | - if (!in_array($column_name, $fields)){ |
|
665 | - $alter_query="ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
664 | + if ( ! in_array($column_name, $fields)) { |
|
665 | + $alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
666 | 666 | //echo "alter query:$alter_query"; |
667 | 667 | return $wpdb->query($alter_query); |
668 | 668 | } |
@@ -681,15 +681,15 @@ discard block |
||
681 | 681 | * @param string $table_name, without prefixed $wpdb->prefix |
682 | 682 | * @return array of database column names |
683 | 683 | */ |
684 | - public static function get_fields_on_table( $table_name = NULL ) { |
|
684 | + public static function get_fields_on_table($table_name = NULL) { |
|
685 | 685 | global $wpdb; |
686 | - $table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
687 | - if ( ! empty( $table_name )) { |
|
686 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
687 | + if ( ! empty($table_name)) { |
|
688 | 688 | $columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name "); |
689 | 689 | if ($columns !== FALSE) { |
690 | 690 | $field_array = array(); |
691 | - foreach($columns as $column ){ |
|
692 | - $field_array[] = $column->Field;; |
|
691 | + foreach ($columns as $column) { |
|
692 | + $field_array[] = $column->Field; ; |
|
693 | 693 | } |
694 | 694 | return $field_array; |
695 | 695 | } |
@@ -707,12 +707,12 @@ discard block |
||
707 | 707 | * @param string $table_name |
708 | 708 | * @return bool |
709 | 709 | */ |
710 | - public static function db_table_is_empty( $table_name ) { |
|
710 | + public static function db_table_is_empty($table_name) { |
|
711 | 711 | global $wpdb; |
712 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
713 | - if ( EEH_Activation::table_exists( $table_name ) ) { |
|
714 | - $count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" ); |
|
715 | - return absint( $count ) === 0 ? true : false; |
|
712 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
713 | + if (EEH_Activation::table_exists($table_name)) { |
|
714 | + $count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name"); |
|
715 | + return absint($count) === 0 ? true : false; |
|
716 | 716 | } |
717 | 717 | return false; |
718 | 718 | } |
@@ -727,9 +727,9 @@ discard block |
||
727 | 727 | * @param string $table_name |
728 | 728 | * @return bool | int |
729 | 729 | */ |
730 | - public static function delete_db_table_if_empty( $table_name ) { |
|
731 | - if ( EEH_Activation::db_table_is_empty( $table_name ) ) { |
|
732 | - return EEH_Activation::delete_unused_db_table( $table_name ); |
|
730 | + public static function delete_db_table_if_empty($table_name) { |
|
731 | + if (EEH_Activation::db_table_is_empty($table_name)) { |
|
732 | + return EEH_Activation::delete_unused_db_table($table_name); |
|
733 | 733 | } |
734 | 734 | return false; |
735 | 735 | } |
@@ -744,11 +744,11 @@ discard block |
||
744 | 744 | * @param string $table_name |
745 | 745 | * @return bool | int |
746 | 746 | */ |
747 | - public static function delete_unused_db_table( $table_name ) { |
|
747 | + public static function delete_unused_db_table($table_name) { |
|
748 | 748 | global $wpdb; |
749 | - if ( EEH_Activation::table_exists( $table_name ) ) { |
|
750 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
751 | - return $wpdb->query( "DROP TABLE IF EXISTS $table_name" ); |
|
749 | + if (EEH_Activation::table_exists($table_name)) { |
|
750 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
751 | + return $wpdb->query("DROP TABLE IF EXISTS $table_name"); |
|
752 | 752 | } |
753 | 753 | return false; |
754 | 754 | } |
@@ -764,18 +764,18 @@ discard block |
||
764 | 764 | * @param string $index_name |
765 | 765 | * @return bool | int |
766 | 766 | */ |
767 | - public static function drop_index( $table_name, $index_name ) { |
|
768 | - if( apply_filters( 'FHEE__EEH_Activation__drop_index__short_circuit', FALSE ) ){ |
|
767 | + public static function drop_index($table_name, $index_name) { |
|
768 | + if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', FALSE)) { |
|
769 | 769 | return FALSE; |
770 | 770 | } |
771 | 771 | global $wpdb; |
772 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
772 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
773 | 773 | $index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$index_name'"; |
774 | 774 | if ( |
775 | - $wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) == $table_name |
|
776 | - && $wpdb->get_var( $index_exists_query ) == $table_name //using get_var with the $index_exists_query returns the table's name |
|
775 | + $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name |
|
776 | + && $wpdb->get_var($index_exists_query) == $table_name //using get_var with the $index_exists_query returns the table's name |
|
777 | 777 | ) { |
778 | - return $wpdb->query( "ALTER TABLE $table_name DROP INDEX $index_name" ); |
|
778 | + return $wpdb->query("ALTER TABLE $table_name DROP INDEX $index_name"); |
|
779 | 779 | } |
780 | 780 | return TRUE; |
781 | 781 | } |
@@ -791,27 +791,27 @@ discard block |
||
791 | 791 | * @return boolean success (whether database is setup properly or not) |
792 | 792 | */ |
793 | 793 | public static function create_database_tables() { |
794 | - EE_Registry::instance()->load_core( 'Data_Migration_Manager' ); |
|
794 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
795 | 795 | //find the migration script that sets the database to be compatible with the code |
796 | 796 | $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms(); |
797 | - if( $dms_name ){ |
|
798 | - $current_data_migration_script = EE_Registry::instance()->load_dms( $dms_name ); |
|
799 | - $current_data_migration_script->set_migrating( false ); |
|
797 | + if ($dms_name) { |
|
798 | + $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name); |
|
799 | + $current_data_migration_script->set_migrating(false); |
|
800 | 800 | $current_data_migration_script->schema_changes_before_migration(); |
801 | 801 | $current_data_migration_script->schema_changes_after_migration(); |
802 | - if( $current_data_migration_script->get_errors() ){ |
|
803 | - if( WP_DEBUG ){ |
|
804 | - foreach( $current_data_migration_script->get_errors() as $error ){ |
|
805 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ ); |
|
802 | + if ($current_data_migration_script->get_errors()) { |
|
803 | + if (WP_DEBUG) { |
|
804 | + foreach ($current_data_migration_script->get_errors() as $error) { |
|
805 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
806 | 806 | } |
807 | - }else{ |
|
808 | - EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) ); |
|
807 | + } else { |
|
808 | + EE_Error::add_error(__('There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso')); |
|
809 | 809 | } |
810 | 810 | return false; |
811 | 811 | } |
812 | 812 | EE_Data_Migration_Manager::instance()->update_current_database_state_to(); |
813 | - }else{ |
|
814 | - EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
813 | + } else { |
|
814 | + EE_Error::add_error(__('Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
815 | 815 | return false; |
816 | 816 | } |
817 | 817 | return true; |
@@ -831,27 +831,27 @@ discard block |
||
831 | 831 | public static function initialize_system_questions() { |
832 | 832 | // QUESTION GROUPS |
833 | 833 | global $wpdb; |
834 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group' ); |
|
834 | + $table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question_group'); |
|
835 | 835 | $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0"; |
836 | 836 | // what we have |
837 | - $question_groups = $wpdb->get_col( $SQL ); |
|
837 | + $question_groups = $wpdb->get_col($SQL); |
|
838 | 838 | // check the response |
839 | - $question_groups = is_array( $question_groups ) ? $question_groups : array(); |
|
839 | + $question_groups = is_array($question_groups) ? $question_groups : array(); |
|
840 | 840 | // what we should have |
841 | - $QSG_systems = array( 1, 2 ); |
|
841 | + $QSG_systems = array(1, 2); |
|
842 | 842 | // loop thru what we should have and compare to what we have |
843 | - foreach ( $QSG_systems as $QSG_system ) { |
|
843 | + foreach ($QSG_systems as $QSG_system) { |
|
844 | 844 | // reset values array |
845 | 845 | $QSG_values = array(); |
846 | 846 | // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db) |
847 | - if ( ! in_array( "$QSG_system", $question_groups )) { |
|
847 | + if ( ! in_array("$QSG_system", $question_groups)) { |
|
848 | 848 | // add it |
849 | - switch ( $QSG_system ) { |
|
849 | + switch ($QSG_system) { |
|
850 | 850 | |
851 | 851 | case 1: |
852 | 852 | $QSG_values = array( |
853 | - 'QSG_name' => __( 'Personal Information', 'event_espresso' ), |
|
854 | - 'QSG_identifier' => 'personal-information-' . time(), |
|
853 | + 'QSG_name' => __('Personal Information', 'event_espresso'), |
|
854 | + 'QSG_identifier' => 'personal-information-'.time(), |
|
855 | 855 | 'QSG_desc' => '', |
856 | 856 | 'QSG_order' => 1, |
857 | 857 | 'QSG_show_group_name' => 1, |
@@ -863,8 +863,8 @@ discard block |
||
863 | 863 | |
864 | 864 | case 2: |
865 | 865 | $QSG_values = array( |
866 | - 'QSG_name' => __( 'Address Information','event_espresso' ), |
|
867 | - 'QSG_identifier' => 'address-information-' . time(), |
|
866 | + 'QSG_name' => __('Address Information', 'event_espresso'), |
|
867 | + 'QSG_identifier' => 'address-information-'.time(), |
|
868 | 868 | 'QSG_desc' => '', |
869 | 869 | 'QSG_order' => 2, |
870 | 870 | 'QSG_show_group_name' => 1, |
@@ -876,14 +876,14 @@ discard block |
||
876 | 876 | |
877 | 877 | } |
878 | 878 | // make sure we have some values before inserting them |
879 | - if ( ! empty( $QSG_values )) { |
|
879 | + if ( ! empty($QSG_values)) { |
|
880 | 880 | // insert system question |
881 | 881 | $wpdb->insert( |
882 | 882 | $table_name, |
883 | 883 | $QSG_values, |
884 | - array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d' ) |
|
884 | + array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d') |
|
885 | 885 | ); |
886 | - $QSG_IDs[ $QSG_system ] = $wpdb->insert_id; |
|
886 | + $QSG_IDs[$QSG_system] = $wpdb->insert_id; |
|
887 | 887 | } |
888 | 888 | } |
889 | 889 | } |
@@ -892,10 +892,10 @@ discard block |
||
892 | 892 | |
893 | 893 | // QUESTIONS |
894 | 894 | global $wpdb; |
895 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question' ); |
|
895 | + $table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question'); |
|
896 | 896 | $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''"; |
897 | 897 | // what we have |
898 | - $questions = $wpdb->get_col( $SQL ); |
|
898 | + $questions = $wpdb->get_col($SQL); |
|
899 | 899 | // what we should have |
900 | 900 | $QST_systems = array( |
901 | 901 | 'fname', |
@@ -912,25 +912,25 @@ discard block |
||
912 | 912 | $order_for_group_1 = 1; |
913 | 913 | $order_for_group_2 = 1; |
914 | 914 | // loop thru what we should have and compare to what we have |
915 | - foreach ( $QST_systems as $QST_system ) { |
|
915 | + foreach ($QST_systems as $QST_system) { |
|
916 | 916 | // reset values array |
917 | 917 | $QST_values = array(); |
918 | 918 | // if we don't have what we should have |
919 | - if ( ! in_array( $QST_system, $questions )) { |
|
919 | + if ( ! in_array($QST_system, $questions)) { |
|
920 | 920 | // add it |
921 | - switch ( $QST_system ) { |
|
921 | + switch ($QST_system) { |
|
922 | 922 | |
923 | 923 | case 'fname': |
924 | 924 | $QST_values = array( |
925 | - 'QST_display_text' => __( 'First Name', 'event_espresso' ), |
|
926 | - 'QST_admin_label' => __( 'First Name - System Question', 'event_espresso' ), |
|
925 | + 'QST_display_text' => __('First Name', 'event_espresso'), |
|
926 | + 'QST_admin_label' => __('First Name - System Question', 'event_espresso'), |
|
927 | 927 | 'QST_system' => 'fname', |
928 | 928 | 'QST_type' => 'TEXT', |
929 | 929 | 'QST_required' => 1, |
930 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
930 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
931 | 931 | 'QST_order' => 1, |
932 | 932 | 'QST_admin_only' => 0, |
933 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
933 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
934 | 934 | 'QST_wp_user' => self::get_default_creator_id(), |
935 | 935 | 'QST_deleted' => 0 |
936 | 936 | ); |
@@ -938,15 +938,15 @@ discard block |
||
938 | 938 | |
939 | 939 | case 'lname': |
940 | 940 | $QST_values = array( |
941 | - 'QST_display_text' => __( 'Last Name', 'event_espresso' ), |
|
942 | - 'QST_admin_label' => __( 'Last Name - System Question', 'event_espresso' ), |
|
941 | + 'QST_display_text' => __('Last Name', 'event_espresso'), |
|
942 | + 'QST_admin_label' => __('Last Name - System Question', 'event_espresso'), |
|
943 | 943 | 'QST_system' => 'lname', |
944 | 944 | 'QST_type' => 'TEXT', |
945 | 945 | 'QST_required' => 1, |
946 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
946 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
947 | 947 | 'QST_order' => 2, |
948 | 948 | 'QST_admin_only' => 0, |
949 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
949 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
950 | 950 | 'QST_wp_user' => self::get_default_creator_id(), |
951 | 951 | 'QST_deleted' => 0 |
952 | 952 | ); |
@@ -954,15 +954,15 @@ discard block |
||
954 | 954 | |
955 | 955 | case 'email': |
956 | 956 | $QST_values = array( |
957 | - 'QST_display_text' => __( 'Email Address', 'event_espresso' ), |
|
958 | - 'QST_admin_label' => __( 'Email Address - System Question', 'event_espresso' ), |
|
957 | + 'QST_display_text' => __('Email Address', 'event_espresso'), |
|
958 | + 'QST_admin_label' => __('Email Address - System Question', 'event_espresso'), |
|
959 | 959 | 'QST_system' => 'email', |
960 | 960 | 'QST_type' => 'TEXT', |
961 | 961 | 'QST_required' => 1, |
962 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
962 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
963 | 963 | 'QST_order' => 3, |
964 | 964 | 'QST_admin_only' => 0, |
965 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
965 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
966 | 966 | 'QST_wp_user' => self::get_default_creator_id(), |
967 | 967 | 'QST_deleted' => 0 |
968 | 968 | ); |
@@ -970,15 +970,15 @@ discard block |
||
970 | 970 | |
971 | 971 | case 'address': |
972 | 972 | $QST_values = array( |
973 | - 'QST_display_text' => __( 'Address', 'event_espresso' ), |
|
974 | - 'QST_admin_label' => __( 'Address - System Question', 'event_espresso' ), |
|
973 | + 'QST_display_text' => __('Address', 'event_espresso'), |
|
974 | + 'QST_admin_label' => __('Address - System Question', 'event_espresso'), |
|
975 | 975 | 'QST_system' => 'address', |
976 | 976 | 'QST_type' => 'TEXT', |
977 | 977 | 'QST_required' => 0, |
978 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
978 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
979 | 979 | 'QST_order' => 4, |
980 | 980 | 'QST_admin_only' => 0, |
981 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
981 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
982 | 982 | 'QST_wp_user' => self::get_default_creator_id(), |
983 | 983 | 'QST_deleted' => 0 |
984 | 984 | ); |
@@ -986,15 +986,15 @@ discard block |
||
986 | 986 | |
987 | 987 | case 'address2': |
988 | 988 | $QST_values = array( |
989 | - 'QST_display_text' => __( 'Address2', 'event_espresso' ), |
|
990 | - 'QST_admin_label' => __( 'Address2 - System Question', 'event_espresso' ), |
|
989 | + 'QST_display_text' => __('Address2', 'event_espresso'), |
|
990 | + 'QST_admin_label' => __('Address2 - System Question', 'event_espresso'), |
|
991 | 991 | 'QST_system' => 'address2', |
992 | 992 | 'QST_type' => 'TEXT', |
993 | 993 | 'QST_required' => 0, |
994 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
994 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
995 | 995 | 'QST_order' => 5, |
996 | 996 | 'QST_admin_only' => 0, |
997 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
997 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
998 | 998 | 'QST_wp_user' => self::get_default_creator_id(), |
999 | 999 | 'QST_deleted' => 0 |
1000 | 1000 | ); |
@@ -1002,15 +1002,15 @@ discard block |
||
1002 | 1002 | |
1003 | 1003 | case 'city': |
1004 | 1004 | $QST_values = array( |
1005 | - 'QST_display_text' => __( 'City', 'event_espresso' ), |
|
1006 | - 'QST_admin_label' => __( 'City - System Question', 'event_espresso' ), |
|
1005 | + 'QST_display_text' => __('City', 'event_espresso'), |
|
1006 | + 'QST_admin_label' => __('City - System Question', 'event_espresso'), |
|
1007 | 1007 | 'QST_system' => 'city', |
1008 | 1008 | 'QST_type' => 'TEXT', |
1009 | 1009 | 'QST_required' => 0, |
1010 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1010 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1011 | 1011 | 'QST_order' => 6, |
1012 | 1012 | 'QST_admin_only' => 0, |
1013 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1013 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1014 | 1014 | 'QST_wp_user' => self::get_default_creator_id(), |
1015 | 1015 | 'QST_deleted' => 0 |
1016 | 1016 | ); |
@@ -1018,12 +1018,12 @@ discard block |
||
1018 | 1018 | |
1019 | 1019 | case 'state': |
1020 | 1020 | $QST_values = array( |
1021 | - 'QST_display_text' => __( 'State/Province', 'event_espresso' ), |
|
1022 | - 'QST_admin_label' => __( 'State/Province - System Question', 'event_espresso' ), |
|
1021 | + 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
1022 | + 'QST_admin_label' => __('State/Province - System Question', 'event_espresso'), |
|
1023 | 1023 | 'QST_system' => 'state', |
1024 | 1024 | 'QST_type' => 'STATE', |
1025 | 1025 | 'QST_required' => 0, |
1026 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1026 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1027 | 1027 | 'QST_order' => 7, |
1028 | 1028 | 'QST_admin_only' => 0, |
1029 | 1029 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1033,12 +1033,12 @@ discard block |
||
1033 | 1033 | |
1034 | 1034 | case 'country' : |
1035 | 1035 | $QST_values = array( |
1036 | - 'QST_display_text' => __( 'Country', 'event_espresso' ), |
|
1037 | - 'QST_admin_label' => __( 'Country - System Question', 'event_espresso' ), |
|
1036 | + 'QST_display_text' => __('Country', 'event_espresso'), |
|
1037 | + 'QST_admin_label' => __('Country - System Question', 'event_espresso'), |
|
1038 | 1038 | 'QST_system' => 'country', |
1039 | 1039 | 'QST_type' => 'COUNTRY', |
1040 | 1040 | 'QST_required' => 0, |
1041 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1041 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1042 | 1042 | 'QST_order' => 8, |
1043 | 1043 | 'QST_admin_only' => 0, |
1044 | 1044 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1048,15 +1048,15 @@ discard block |
||
1048 | 1048 | |
1049 | 1049 | case 'zip': |
1050 | 1050 | $QST_values = array( |
1051 | - 'QST_display_text' => __( 'Zip/Postal Code', 'event_espresso' ), |
|
1052 | - 'QST_admin_label' => __( 'Zip/Postal Code - System Question', 'event_espresso' ), |
|
1051 | + 'QST_display_text' => __('Zip/Postal Code', 'event_espresso'), |
|
1052 | + 'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'), |
|
1053 | 1053 | 'QST_system' => 'zip', |
1054 | 1054 | 'QST_type' => 'TEXT', |
1055 | 1055 | 'QST_required' => 0, |
1056 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1056 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1057 | 1057 | 'QST_order' => 9, |
1058 | 1058 | 'QST_admin_only' => 0, |
1059 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1059 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1060 | 1060 | 'QST_wp_user' => self::get_default_creator_id(), |
1061 | 1061 | 'QST_deleted' => 0 |
1062 | 1062 | ); |
@@ -1064,49 +1064,49 @@ discard block |
||
1064 | 1064 | |
1065 | 1065 | case 'phone': |
1066 | 1066 | $QST_values = array( |
1067 | - 'QST_display_text' => __( 'Phone Number', 'event_espresso' ), |
|
1068 | - 'QST_admin_label' => __( 'Phone Number - System Question', 'event_espresso' ), |
|
1067 | + 'QST_display_text' => __('Phone Number', 'event_espresso'), |
|
1068 | + 'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'), |
|
1069 | 1069 | 'QST_system' => 'phone', |
1070 | 1070 | 'QST_type' => 'TEXT', |
1071 | 1071 | 'QST_required' => 0, |
1072 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1072 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1073 | 1073 | 'QST_order' => 10, |
1074 | 1074 | 'QST_admin_only' => 0, |
1075 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1075 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1076 | 1076 | 'QST_wp_user' => self::get_default_creator_id(), |
1077 | 1077 | 'QST_deleted' => 0 |
1078 | 1078 | ); |
1079 | 1079 | break; |
1080 | 1080 | |
1081 | 1081 | } |
1082 | - if ( ! empty( $QST_values )) { |
|
1082 | + if ( ! empty($QST_values)) { |
|
1083 | 1083 | // insert system question |
1084 | 1084 | $wpdb->insert( |
1085 | 1085 | $table_name, |
1086 | 1086 | $QST_values, |
1087 | - array( '%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d' ) |
|
1087 | + array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d') |
|
1088 | 1088 | ); |
1089 | 1089 | $QST_ID = $wpdb->insert_id; |
1090 | 1090 | |
1091 | 1091 | // QUESTION GROUP QUESTIONS |
1092 | - if( in_array( $QST_system, array( 'fname', 'lname', 'email' ) ) ) { |
|
1092 | + if (in_array($QST_system, array('fname', 'lname', 'email'))) { |
|
1093 | 1093 | $system_question_we_want = EEM_Question_Group::system_personal; |
1094 | 1094 | } else { |
1095 | 1095 | $system_question_we_want = EEM_Question_Group::system_address; |
1096 | 1096 | } |
1097 | - if( isset( $QSG_IDs[ $system_question_we_want ] ) ) { |
|
1098 | - $QSG_ID = $QSG_IDs[ $system_question_we_want ]; |
|
1097 | + if (isset($QSG_IDs[$system_question_we_want])) { |
|
1098 | + $QSG_ID = $QSG_IDs[$system_question_we_want]; |
|
1099 | 1099 | } else { |
1100 | - $id_col = EEM_Question_Group::instance()->get_col( array( array( 'QSG_system' => $system_question_we_want ) ) ); |
|
1101 | - if( is_array( $id_col ) ) { |
|
1102 | - $QSG_ID = reset( $id_col ); |
|
1100 | + $id_col = EEM_Question_Group::instance()->get_col(array(array('QSG_system' => $system_question_we_want))); |
|
1101 | + if (is_array($id_col)) { |
|
1102 | + $QSG_ID = reset($id_col); |
|
1103 | 1103 | } else { |
1104 | 1104 | //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method |
1105 | 1105 | EE_Log::instance()->log( |
1106 | 1106 | __FILE__, |
1107 | 1107 | __FUNCTION__, |
1108 | 1108 | sprintf( |
1109 | - __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1109 | + __('Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1110 | 1110 | $QST_ID ), |
1111 | 1111 | 'error' ); |
1112 | 1112 | continue; |
@@ -1115,9 +1115,9 @@ discard block |
||
1115 | 1115 | |
1116 | 1116 | // add system questions to groups |
1117 | 1117 | $wpdb->insert( |
1118 | - EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group_question' ), |
|
1119 | - array( 'QSG_ID' => $QSG_ID , 'QST_ID' => $QST_ID, 'QGQ_order'=>($QSG_ID==1)? $order_for_group_1++ : $order_for_group_2++ ), |
|
1120 | - array( '%d', '%d','%d' ) |
|
1118 | + EEH_Activation::ensure_table_name_has_prefix('esp_question_group_question'), |
|
1119 | + array('QSG_ID' => $QSG_ID, 'QST_ID' => $QST_ID, 'QGQ_order'=>($QSG_ID == 1) ? $order_for_group_1++ : $order_for_group_2++), |
|
1120 | + array('%d', '%d', '%d') |
|
1121 | 1121 | ); |
1122 | 1122 | } |
1123 | 1123 | } |
@@ -1129,11 +1129,11 @@ discard block |
||
1129 | 1129 | * Makes sure the default payment method (Invoice) is active. |
1130 | 1130 | * This used to be done automatically as part of constructing the old gateways config |
1131 | 1131 | */ |
1132 | - public static function insert_default_payment_methods(){ |
|
1133 | - if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){ |
|
1134 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
1135 | - EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
|
1136 | - }else{ |
|
1132 | + public static function insert_default_payment_methods() { |
|
1133 | + if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) { |
|
1134 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
1135 | + EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
1136 | + } else { |
|
1137 | 1137 | EEM_Payment_Method::instance()->verify_button_urls(); |
1138 | 1138 | } |
1139 | 1139 | } |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | |
1150 | 1150 | global $wpdb; |
1151 | 1151 | |
1152 | - if ( EEH_Activation::table_exists( EEM_Status::instance()->table() ) ) { |
|
1152 | + if (EEH_Activation::table_exists(EEM_Status::instance()->table())) { |
|
1153 | 1153 | |
1154 | 1154 | $table_name = EEM_Status::instance()->table(); |
1155 | 1155 | |
@@ -1220,38 +1220,38 @@ discard block |
||
1220 | 1220 | * @return boolean success of verifying upload directories exist |
1221 | 1221 | */ |
1222 | 1222 | public static function create_upload_directories() { |
1223 | - EE_Registry::instance()->load_helper( 'File' ); |
|
1223 | + EE_Registry::instance()->load_helper('File'); |
|
1224 | 1224 | // Create the required folders |
1225 | 1225 | $folders = array( |
1226 | 1226 | EVENT_ESPRESSO_TEMPLATE_DIR, |
1227 | 1227 | EVENT_ESPRESSO_GATEWAY_DIR, |
1228 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs/', |
|
1229 | - EVENT_ESPRESSO_UPLOAD_DIR . 'css/', |
|
1230 | - EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/' |
|
1228 | + EVENT_ESPRESSO_UPLOAD_DIR.'logs/', |
|
1229 | + EVENT_ESPRESSO_UPLOAD_DIR.'css/', |
|
1230 | + EVENT_ESPRESSO_UPLOAD_DIR.'tickets/' |
|
1231 | 1231 | ); |
1232 | - foreach ( $folders as $folder ) { |
|
1232 | + foreach ($folders as $folder) { |
|
1233 | 1233 | try { |
1234 | - EEH_File::ensure_folder_exists_and_is_writable( $folder ); |
|
1235 | - @ chmod( $folder, 0755 ); |
|
1236 | - } catch( EE_Error $e ){ |
|
1234 | + EEH_File::ensure_folder_exists_and_is_writable($folder); |
|
1235 | + @ chmod($folder, 0755); |
|
1236 | + } catch (EE_Error $e) { |
|
1237 | 1237 | EE_Error::add_error( |
1238 | 1238 | sprintf( |
1239 | - __( 'Could not create the folder at "%1$s" because: %2$s', 'event_espresso' ), |
|
1239 | + __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'), |
|
1240 | 1240 | $folder, |
1241 | - '<br />' . $e->getMessage() |
|
1241 | + '<br />'.$e->getMessage() |
|
1242 | 1242 | ), |
1243 | 1243 | __FILE__, __FUNCTION__, __LINE__ |
1244 | 1244 | ); |
1245 | 1245 | //indicate we'll need to fix this later |
1246 | - update_option( EEH_Activation::upload_directories_incomplete_option_name, true ); |
|
1246 | + update_option(EEH_Activation::upload_directories_incomplete_option_name, true); |
|
1247 | 1247 | return FALSE; |
1248 | 1248 | } |
1249 | 1249 | } |
1250 | 1250 | //just add the .htaccess file to the logs directory to begin with. Even if logging |
1251 | 1251 | //is disabled, there might be activation errors recorded in there |
1252 | - EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs/' ); |
|
1252 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs/'); |
|
1253 | 1253 | //remember EE's folders are all good |
1254 | - delete_option( EEH_Activation::upload_directories_incomplete_option_name ); |
|
1254 | + delete_option(EEH_Activation::upload_directories_incomplete_option_name); |
|
1255 | 1255 | return TRUE; |
1256 | 1256 | } |
1257 | 1257 | |
@@ -1264,7 +1264,7 @@ discard block |
||
1264 | 1264 | * @return boolean |
1265 | 1265 | */ |
1266 | 1266 | public static function upload_directories_incomplete() { |
1267 | - return get_option( EEH_Activation::upload_directories_incomplete_option_name, false ); |
|
1267 | + return get_option(EEH_Activation::upload_directories_incomplete_option_name, false); |
|
1268 | 1268 | } |
1269 | 1269 | |
1270 | 1270 | |
@@ -1282,20 +1282,20 @@ discard block |
||
1282 | 1282 | * To check for errors you will want to use either EE_Error or a try catch for an EE_Error exception. |
1283 | 1283 | */ |
1284 | 1284 | public static function generate_default_message_templates() { |
1285 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
1285 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
1286 | 1286 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
1287 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1287 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1288 | 1288 | /* |
1289 | 1289 | * This first method is taking care of ensuring any default messengers that should be made active and have templates |
1290 | 1290 | * generated are done. |
1291 | 1291 | */ |
1292 | - $new_templates_created_for_messenger = self::_activate_and_generate_default_messengers_and_message_templates( $message_resource_manager ); |
|
1292 | + $new_templates_created_for_messenger = self::_activate_and_generate_default_messengers_and_message_templates($message_resource_manager); |
|
1293 | 1293 | |
1294 | 1294 | /** |
1295 | 1295 | * This method is verifying there are no NEW default message types for ACTIVE messengers that need activated (and |
1296 | 1296 | * corresponding templates setup). |
1297 | 1297 | */ |
1298 | - $new_templates_created_for_message_type = self::_activate_new_message_types_for_active_messengers_and_generate_default_templates( $message_resource_manager ); |
|
1298 | + $new_templates_created_for_message_type = self::_activate_new_message_types_for_active_messengers_and_generate_default_templates($message_resource_manager); |
|
1299 | 1299 | |
1300 | 1300 | //after all is done, let's persist these changes to the db. |
1301 | 1301 | $message_resource_manager->update_has_activated_messengers_option(); |
@@ -1316,34 +1316,34 @@ discard block |
||
1316 | 1316 | $active_messengers = $message_resource_manager->active_messengers(); |
1317 | 1317 | $installed_message_types = $message_resource_manager->installed_message_types(); |
1318 | 1318 | $templates_created = false; |
1319 | - foreach( $active_messengers as $active_messenger ) { |
|
1319 | + foreach ($active_messengers as $active_messenger) { |
|
1320 | 1320 | $default_message_type_names_for_messenger = $active_messenger->get_default_message_types(); |
1321 | 1321 | $default_message_type_names_to_activate = array(); |
1322 | 1322 | |
1323 | 1323 | //looping through each default message type reported by the messenger and setup the actual message types to activate. |
1324 | - foreach ( $default_message_type_names_for_messenger as $default_message_type_name_for_messenger ) { |
|
1324 | + foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) { |
|
1325 | 1325 | //if already active or has already been activated before we skip (otherwise we might reactivate something user's |
1326 | 1326 | //intentionally deactivated.) |
1327 | 1327 | //we also skip if the message type is not installed. |
1328 | 1328 | if ( |
1329 | 1329 | ( |
1330 | - isset( $has_activated[$active_messenger->name] ) |
|
1331 | - && in_array( $default_message_type_name_for_messenger, $has_activated[$active_messenger->name] ) |
|
1330 | + isset($has_activated[$active_messenger->name]) |
|
1331 | + && in_array($default_message_type_name_for_messenger, $has_activated[$active_messenger->name]) |
|
1332 | 1332 | ) |
1333 | - || $message_resource_manager->is_message_type_active_for_messenger( $active_messenger->name, $default_message_type_name_for_messenger ) |
|
1334 | - || ! isset( $installed_message_types[ $default_message_type_name_for_messenger ] ) |
|
1335 | - ){ |
|
1333 | + || $message_resource_manager->is_message_type_active_for_messenger($active_messenger->name, $default_message_type_name_for_messenger) |
|
1334 | + || ! isset($installed_message_types[$default_message_type_name_for_messenger]) |
|
1335 | + ) { |
|
1336 | 1336 | continue; |
1337 | 1337 | } |
1338 | 1338 | $default_message_type_names_to_activate[] = $default_message_type_name_for_messenger; |
1339 | 1339 | } |
1340 | 1340 | |
1341 | 1341 | //let's activate! |
1342 | - $message_resource_manager->ensure_message_types_are_active( $default_message_type_names_to_activate, $active_messenger->name, false ); |
|
1342 | + $message_resource_manager->ensure_message_types_are_active($default_message_type_names_to_activate, $active_messenger->name, false); |
|
1343 | 1343 | |
1344 | 1344 | //activate the templates for these message types |
1345 | - if ( ! empty( $default_message_type_names_to_activate ) ) { |
|
1346 | - $templates_created = EEH_MSG_Template::generate_new_templates( $active_messenger->name, $default_message_type_names_for_messenger, '', true ); |
|
1345 | + if ( ! empty($default_message_type_names_to_activate)) { |
|
1346 | + $templates_created = EEH_MSG_Template::generate_new_templates($active_messenger->name, $default_message_type_names_for_messenger, '', true); |
|
1347 | 1347 | } |
1348 | 1348 | } |
1349 | 1349 | return $templates_created; |
@@ -1365,15 +1365,15 @@ discard block |
||
1365 | 1365 | EE_message_Resource_Manager $message_resource_manager |
1366 | 1366 | ) { |
1367 | 1367 | /** @type EE_Messenger[] $messengers_to_generate */ |
1368 | - $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation( $message_resource_manager ); |
|
1368 | + $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager); |
|
1369 | 1369 | $installed_message_types = $message_resource_manager->installed_message_types(); |
1370 | 1370 | $templates_generated = false; |
1371 | - foreach ( $messengers_to_generate as $messenger_to_generate ) { |
|
1371 | + foreach ($messengers_to_generate as $messenger_to_generate) { |
|
1372 | 1372 | $default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types(); |
1373 | 1373 | //verify the default message types match an installed message type. |
1374 | - foreach ( $default_message_type_names_for_messenger as $key => $name ) { |
|
1375 | - if ( ! isset( $installed_message_types[$name] ) ) { |
|
1376 | - unset( $default_message_type_names_for_messenger[$key] ); |
|
1374 | + foreach ($default_message_type_names_for_messenger as $key => $name) { |
|
1375 | + if ( ! isset($installed_message_types[$name])) { |
|
1376 | + unset($default_message_type_names_for_messenger[$key]); |
|
1377 | 1377 | } |
1378 | 1378 | } |
1379 | 1379 | |
@@ -1381,11 +1381,11 @@ discard block |
||
1381 | 1381 | //however with the changes this may not be necessary. This comment is left here just in case |
1382 | 1382 | //we discover that we _do_ need to update before passing off to create templates (after the refactor is done). |
1383 | 1383 | //@todo remove this comment when determined not necessary. |
1384 | - $message_resource_manager->activate_messenger( $messenger_to_generate->name, $default_message_type_names_for_messenger, false ); |
|
1384 | + $message_resource_manager->activate_messenger($messenger_to_generate->name, $default_message_type_names_for_messenger, false); |
|
1385 | 1385 | |
1386 | 1386 | //create any templates needing created (or will reactivate templates already generated as necessary). |
1387 | - if ( ! empty( $default_message_type_names_for_messenger ) ) { |
|
1388 | - $templates_generated = EEH_MSG_Template::generate_new_templates( $messenger_to_generate->name, $default_message_type_names_for_messenger, '', true ); |
|
1387 | + if ( ! empty($default_message_type_names_for_messenger)) { |
|
1388 | + $templates_generated = EEH_MSG_Template::generate_new_templates($messenger_to_generate->name, $default_message_type_names_for_messenger, '', true); |
|
1389 | 1389 | } |
1390 | 1390 | } |
1391 | 1391 | return $templates_generated; |
@@ -1403,12 +1403,12 @@ discard block |
||
1403 | 1403 | * @param EE_Message_Resource_Manager $message_resource_manager |
1404 | 1404 | * @return EE_Messenger[] |
1405 | 1405 | */ |
1406 | - protected static function _get_default_messengers_to_generate_on_activation( EE_Message_Resource_Manager $message_resource_manager ) { |
|
1406 | + protected static function _get_default_messengers_to_generate_on_activation(EE_Message_Resource_Manager $message_resource_manager) { |
|
1407 | 1407 | $active_messengers = $message_resource_manager->active_messengers(); |
1408 | 1408 | $installed_messengers = $message_resource_manager->installed_messengers(); |
1409 | 1409 | $has_activated = $message_resource_manager->get_has_activated_messengers_option(); |
1410 | 1410 | $messengers_to_generate = array(); |
1411 | - foreach( $installed_messengers as $installed_messenger ) { |
|
1411 | + foreach ($installed_messengers as $installed_messenger) { |
|
1412 | 1412 | //if installed messenger is a messenger that should be activated on install |
1413 | 1413 | //and is not already active |
1414 | 1414 | //and has never been activated |
@@ -1442,7 +1442,7 @@ discard block |
||
1442 | 1442 | */ |
1443 | 1443 | public static function validate_messages_system() { |
1444 | 1444 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
1445 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1445 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1446 | 1446 | // ******************************************************** |
1447 | 1447 | // as soon as EE_Message_Resource_Manager is instantiated, |
1448 | 1448 | // it runs _set_active_messengers_and_message_types() |
@@ -1477,7 +1477,7 @@ discard block |
||
1477 | 1477 | // |
1478 | 1478 | ////all done! let's update the active_messengers. |
1479 | 1479 | //EEH_MSG_Template::update_active_messengers_in_db( $active_messengers ); |
1480 | - do_action( 'AHEE__EEH_Activation__validate_messages_system' ); |
|
1480 | + do_action('AHEE__EEH_Activation__validate_messages_system'); |
|
1481 | 1481 | return; |
1482 | 1482 | } |
1483 | 1483 | |
@@ -1491,12 +1491,12 @@ discard block |
||
1491 | 1491 | * @static |
1492 | 1492 | * @return void |
1493 | 1493 | */ |
1494 | - public static function create_no_ticket_prices_array(){ |
|
1494 | + public static function create_no_ticket_prices_array() { |
|
1495 | 1495 | // this creates an array for tracking events that have no active ticket prices created |
1496 | 1496 | // this allows us to warn admins of the situation so that it can be corrected |
1497 | - $espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', FALSE ); |
|
1498 | - if ( ! $espresso_no_ticket_prices ) { |
|
1499 | - add_option( 'ee_no_ticket_prices', array(), '', FALSE ); |
|
1497 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', FALSE); |
|
1498 | + if ( ! $espresso_no_ticket_prices) { |
|
1499 | + add_option('ee_no_ticket_prices', array(), '', FALSE); |
|
1500 | 1500 | } |
1501 | 1501 | } |
1502 | 1502 | |
@@ -1519,24 +1519,24 @@ discard block |
||
1519 | 1519 | * relations)/ |
1520 | 1520 | * @global wpdb $wpdb |
1521 | 1521 | */ |
1522 | - public static function delete_all_espresso_cpt_data(){ |
|
1522 | + public static function delete_all_espresso_cpt_data() { |
|
1523 | 1523 | global $wpdb; |
1524 | 1524 | //get all the CPT post_types |
1525 | 1525 | $ee_post_types = array(); |
1526 | - foreach(EE_Registry::instance()->non_abstract_db_models as $model_name){ |
|
1527 | - if ( method_exists( $model_name, 'instance' )) { |
|
1528 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1529 | - if ( $model_obj instanceof EEM_CPT_Base ) { |
|
1530 | - $ee_post_types[] = $wpdb->prepare("%s",$model_obj->post_type()); |
|
1526 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1527 | + if (method_exists($model_name, 'instance')) { |
|
1528 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1529 | + if ($model_obj instanceof EEM_CPT_Base) { |
|
1530 | + $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type()); |
|
1531 | 1531 | } |
1532 | 1532 | } |
1533 | 1533 | } |
1534 | 1534 | //get all our CPTs |
1535 | - $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",",$ee_post_types).")"; |
|
1535 | + $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")"; |
|
1536 | 1536 | $cpt_ids = $wpdb->get_col($query); |
1537 | 1537 | //delete each post meta and term relations too |
1538 | - foreach($cpt_ids as $post_id){ |
|
1539 | - wp_delete_post($post_id,true); |
|
1538 | + foreach ($cpt_ids as $post_id) { |
|
1539 | + wp_delete_post($post_id, true); |
|
1540 | 1540 | } |
1541 | 1541 | } |
1542 | 1542 | |
@@ -1550,18 +1550,18 @@ discard block |
||
1550 | 1550 | * @param bool $remove_all |
1551 | 1551 | * @return void |
1552 | 1552 | */ |
1553 | - public static function delete_all_espresso_tables_and_data( $remove_all = true ) { |
|
1553 | + public static function delete_all_espresso_tables_and_data($remove_all = true) { |
|
1554 | 1554 | global $wpdb; |
1555 | 1555 | $undeleted_tables = array(); |
1556 | 1556 | |
1557 | 1557 | // load registry |
1558 | - foreach( EE_Registry::instance()->non_abstract_db_models as $model_name ){ |
|
1559 | - if ( method_exists( $model_name, 'instance' )) { |
|
1560 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1561 | - if ( $model_obj instanceof EEM_Base ) { |
|
1562 | - foreach ( $model_obj->get_tables() as $table ) { |
|
1563 | - if ( strpos( $table->get_table_name(), 'esp_' )) { |
|
1564 | - switch ( EEH_Activation::delete_unused_db_table( $table->get_table_name() )) { |
|
1558 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1559 | + if (method_exists($model_name, 'instance')) { |
|
1560 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1561 | + if ($model_obj instanceof EEM_Base) { |
|
1562 | + foreach ($model_obj->get_tables() as $table) { |
|
1563 | + if (strpos($table->get_table_name(), 'esp_')) { |
|
1564 | + switch (EEH_Activation::delete_unused_db_table($table->get_table_name())) { |
|
1565 | 1565 | case false : |
1566 | 1566 | $undeleted_tables[] = $table->get_table_name(); |
1567 | 1567 | break; |
@@ -1586,8 +1586,8 @@ discard block |
||
1586 | 1586 | 'esp_promotion_rule', |
1587 | 1587 | 'esp_rule' |
1588 | 1588 | ); |
1589 | - foreach( $tables_without_models as $table ){ |
|
1590 | - EEH_Activation::delete_db_table_if_empty( $table ); |
|
1589 | + foreach ($tables_without_models as $table) { |
|
1590 | + EEH_Activation::delete_db_table_if_empty($table); |
|
1591 | 1591 | } |
1592 | 1592 | |
1593 | 1593 | |
@@ -1625,58 +1625,58 @@ discard block |
||
1625 | 1625 | 'ee_job_parameters_' => false, |
1626 | 1626 | 'ee_upload_directories_incomplete' => true, |
1627 | 1627 | ); |
1628 | - if( is_main_site() ) { |
|
1629 | - $wp_options_to_delete[ 'ee_network_config' ] = true; |
|
1628 | + if (is_main_site()) { |
|
1629 | + $wp_options_to_delete['ee_network_config'] = true; |
|
1630 | 1630 | } |
1631 | 1631 | |
1632 | 1632 | $undeleted_options = array(); |
1633 | - foreach ( $wp_options_to_delete as $option_name => $no_wildcard ) { |
|
1633 | + foreach ($wp_options_to_delete as $option_name => $no_wildcard) { |
|
1634 | 1634 | |
1635 | - if( $no_wildcard ){ |
|
1636 | - if( ! delete_option( $option_name ) ){ |
|
1635 | + if ($no_wildcard) { |
|
1636 | + if ( ! delete_option($option_name)) { |
|
1637 | 1637 | $undeleted_options[] = $option_name; |
1638 | 1638 | } |
1639 | - }else{ |
|
1640 | - $option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" ); |
|
1641 | - foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){ |
|
1642 | - if( ! delete_option( $option_name_from_wildcard ) ){ |
|
1639 | + } else { |
|
1640 | + $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'"); |
|
1641 | + foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) { |
|
1642 | + if ( ! delete_option($option_name_from_wildcard)) { |
|
1643 | 1643 | $undeleted_options[] = $option_name_from_wildcard; |
1644 | 1644 | } |
1645 | 1645 | } |
1646 | 1646 | } |
1647 | 1647 | } |
1648 | 1648 | //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
1649 | - remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1649 | + remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10); |
|
1650 | 1650 | |
1651 | - if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) { |
|
1651 | + if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) { |
|
1652 | 1652 | $db_update_sans_ee4 = array(); |
1653 | - foreach($espresso_db_update as $version => $times_activated){ |
|
1654 | - if( $version[0] =='3'){//if its NON EE4 |
|
1653 | + foreach ($espresso_db_update as $version => $times_activated) { |
|
1654 | + if ($version[0] == '3') {//if its NON EE4 |
|
1655 | 1655 | $db_update_sans_ee4[$version] = $times_activated; |
1656 | 1656 | } |
1657 | 1657 | } |
1658 | - update_option( 'espresso_db_update', $db_update_sans_ee4 ); |
|
1658 | + update_option('espresso_db_update', $db_update_sans_ee4); |
|
1659 | 1659 | } |
1660 | 1660 | |
1661 | 1661 | $errors = ''; |
1662 | - if ( ! empty( $undeleted_tables )) { |
|
1662 | + if ( ! empty($undeleted_tables)) { |
|
1663 | 1663 | $errors .= sprintf( |
1664 | - __( 'The following tables could not be deleted: %s%s', 'event_espresso' ), |
|
1664 | + __('The following tables could not be deleted: %s%s', 'event_espresso'), |
|
1665 | 1665 | '<br/>', |
1666 | - implode( ',<br/>', $undeleted_tables ) |
|
1666 | + implode(',<br/>', $undeleted_tables) |
|
1667 | 1667 | ); |
1668 | 1668 | } |
1669 | - if ( ! empty( $undeleted_options )) { |
|
1670 | - $errors .= ! empty( $undeleted_tables ) ? '<br/>' : ''; |
|
1669 | + if ( ! empty($undeleted_options)) { |
|
1670 | + $errors .= ! empty($undeleted_tables) ? '<br/>' : ''; |
|
1671 | 1671 | $errors .= sprintf( |
1672 | - __( 'The following wp-options could not be deleted: %s%s', 'event_espresso' ), |
|
1672 | + __('The following wp-options could not be deleted: %s%s', 'event_espresso'), |
|
1673 | 1673 | '<br/>', |
1674 | - implode( ',<br/>', $undeleted_options ) |
|
1674 | + implode(',<br/>', $undeleted_options) |
|
1675 | 1675 | ); |
1676 | 1676 | |
1677 | 1677 | } |
1678 | - if ( $errors != '' ) { |
|
1679 | - EE_Error::add_attention( $errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
1678 | + if ($errors != '') { |
|
1679 | + EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__); |
|
1680 | 1680 | } |
1681 | 1681 | } |
1682 | 1682 | |
@@ -1686,23 +1686,23 @@ discard block |
||
1686 | 1686 | * @param string $table_name with or without $wpdb->prefix |
1687 | 1687 | * @return boolean |
1688 | 1688 | */ |
1689 | - public static function table_exists( $table_name ){ |
|
1689 | + public static function table_exists($table_name) { |
|
1690 | 1690 | global $wpdb, $EZSQL_ERROR; |
1691 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
1691 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
1692 | 1692 | //ignore if this causes an sql error |
1693 | 1693 | $old_error = $wpdb->last_error; |
1694 | 1694 | $old_suppress_errors = $wpdb->suppress_errors(); |
1695 | - $old_show_errors_value = $wpdb->show_errors( FALSE ); |
|
1695 | + $old_show_errors_value = $wpdb->show_errors(FALSE); |
|
1696 | 1696 | $ezsql_error_cache = $EZSQL_ERROR; |
1697 | - $wpdb->get_results( "SELECT * from $table_name LIMIT 1"); |
|
1698 | - $wpdb->show_errors( $old_show_errors_value ); |
|
1699 | - $wpdb->suppress_errors( $old_suppress_errors ); |
|
1697 | + $wpdb->get_results("SELECT * from $table_name LIMIT 1"); |
|
1698 | + $wpdb->show_errors($old_show_errors_value); |
|
1699 | + $wpdb->suppress_errors($old_suppress_errors); |
|
1700 | 1700 | $new_error = $wpdb->last_error; |
1701 | 1701 | $wpdb->last_error = $old_error; |
1702 | 1702 | $EZSQL_ERROR = $ezsql_error_cache; |
1703 | - if( empty( $new_error ) ){ |
|
1703 | + if (empty($new_error)) { |
|
1704 | 1704 | return TRUE; |
1705 | - }else{ |
|
1705 | + } else { |
|
1706 | 1706 | return FALSE; |
1707 | 1707 | } |
1708 | 1708 | } |
@@ -1710,7 +1710,7 @@ discard block |
||
1710 | 1710 | /** |
1711 | 1711 | * Resets the cache on EEH_Activation |
1712 | 1712 | */ |
1713 | - public static function reset(){ |
|
1713 | + public static function reset() { |
|
1714 | 1714 | self::$_default_creator_id = NULL; |
1715 | 1715 | self::$_initialized_db_content_already_in_this_request = false; |
1716 | 1716 | } |