Completed
Branch FET-8837-purchasing-agent (3c506c)
by
unknown
832:15 queued 816:38
created
core/libraries/messages/EE_messenger.lib.php 2 patches
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	 * @return void
290 290
 	 */
291 291
 	public function enqueue_scripts_styles() {
292
-		do_action( 'AHEE__EE_messenger__enqueue_scripts_styles');
292
+		do_action('AHEE__EE_messenger__enqueue_scripts_styles');
293 293
 	}
294 294
 
295 295
 
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 
326 326
 		$this->_supports_labels->template_variation_description = __('These are different styles to choose from for the selected template structure.  Usually these affect things like font style, color, borders etc.  In some cases the styles will also make minor layout changes.');
327 327
 
328
-		$this->_supports_labels = apply_filters( 'FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this );
328
+		$this->_supports_labels = apply_filters('FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this);
329 329
 	}
330 330
 
331 331
 
@@ -340,10 +340,10 @@  discard block
 block discarded – undo
340 340
 	 * @return stdClass
341 341
 	 */
342 342
 	public function get_supports_labels() {
343
-		if ( empty( $this->_supports_labels->template_pack ) || empty( $this->_supports_labels->template_variation) ) {
343
+		if (empty($this->_supports_labels->template_pack) || empty($this->_supports_labels->template_variation)) {
344 344
 			$this->_set_supports_labels_defaults();
345 345
 		}
346
-		return apply_filters( 'FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this );
346
+		return apply_filters('FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this);
347 347
 	}
348 348
 
349 349
 
@@ -363,10 +363,10 @@  discard block
 block discarded – undo
363 363
 	 *
364 364
 	 * @return string                    path or url for the requested variation.
365 365
 	 */
366
-	public function get_variation( EE_Messages_Template_Pack $pack, $message_type_name, $url = FALSE, $type = 'main', $variation = 'default', $skip_filters = FALSE ) {
366
+	public function get_variation(EE_Messages_Template_Pack $pack, $message_type_name, $url = FALSE, $type = 'main', $variation = 'default', $skip_filters = FALSE) {
367 367
 		$this->_tmp_pack = $pack;
368
-		$variation_path = apply_filters( 'EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters );
369
-		$variation_path = empty( $variation_path ) ? $this->_tmp_pack->get_variation( $this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters ) : $variation_path;
368
+		$variation_path = apply_filters('EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters);
369
+		$variation_path = empty($variation_path) ? $this->_tmp_pack->get_variation($this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters) : $variation_path;
370 370
 		return $variation_path;
371 371
 
372 372
 	}
@@ -384,13 +384,13 @@  discard block
 block discarded – undo
384 384
 	 * @return array
385 385
 	 */
386 386
 	public function get_default_message_types() {
387
-		$class = get_class( $this );
387
+		$class = get_class($this);
388 388
 
389 389
 		//messenger specific filter
390
-		$default_types = apply_filters( 'FHEE__' . $class . '__get_default_message_types__default_types', $this->_default_message_types, $this );
390
+		$default_types = apply_filters('FHEE__'.$class.'__get_default_message_types__default_types', $this->_default_message_types, $this);
391 391
 
392 392
 		//all messengers filter
393
-		$default_types = apply_filters( 'FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this );
393
+		$default_types = apply_filters('FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this);
394 394
 		return $default_types;
395 395
 	}
396 396
 
@@ -405,14 +405,14 @@  discard block
 block discarded – undo
405 405
 	 * @return array
406 406
 	 */
407 407
 	public function get_valid_message_types() {
408
-		$class = get_class( $this );
408
+		$class = get_class($this);
409 409
 
410 410
 		//messenger specific filter
411 411
 		//messenger specific filter
412
-		$valid_types = apply_filters( 'FHEE__' . $class . '__get_valid_message_types__valid_types', $this->_valid_message_types, $this );
412
+		$valid_types = apply_filters('FHEE__'.$class.'__get_valid_message_types__valid_types', $this->_valid_message_types, $this);
413 413
 
414 414
 		//all messengers filter
415
-		$valid_types = apply_filters( 'FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this );
415
+		$valid_types = apply_filters('FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this);
416 416
 		return $valid_types;
417 417
 	}
418 418
 
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 	 * @access public
427 427
 	 * @param array $new_config Whatever is put in here will reset the _validator_config property
428 428
 	 */
429
-	public function set_validator_config( $new_config ) {
429
+	public function set_validator_config($new_config) {
430 430
 		$this->_validator_config = $new_config;
431 431
 	}
432 432
 
@@ -442,8 +442,8 @@  discard block
 block discarded – undo
442 442
 	public function get_validator_config() {
443 443
 		$class = get_class($this);
444 444
 
445
-		$config = apply_filters( 'FHEE__' . $class . '__get_validator_config', $this->_validator_config, $this );
446
-		$config = apply_filters( 'FHEE__EE_messenger__get_validator_config', $config, $this );
445
+		$config = apply_filters('FHEE__'.$class.'__get_validator_config', $this->_validator_config, $this);
446
+		$config = apply_filters('FHEE__EE_messenger__get_validator_config', $config, $this);
447 447
 		return $config;
448 448
 	}
449 449
 
@@ -460,8 +460,8 @@  discard block
 block discarded – undo
460 460
 	 * @access public
461 461
 	 * @return string content for page
462 462
 	 */
463
-	public function get_messenger_admin_page_content( $page, $action = null, $extra = array(), $message_types = array() ) {
464
-		return $this->_get_admin_page_content( $page, $action, $extra, $message_types );
463
+	public function get_messenger_admin_page_content($page, $action = null, $extra = array(), $message_types = array()) {
464
+		return $this->_get_admin_page_content($page, $action, $extra, $message_types);
465 465
 	}
466 466
 
467 467
 
@@ -470,76 +470,76 @@  discard block
 block discarded – undo
470 470
 
471 471
 
472 472
 
473
-	protected function _get_admin_content_events_edit( $message_types, $extra ) {
473
+	protected function _get_admin_content_events_edit($message_types, $extra) {
474 474
 		//defaults
475 475
 		$template_args = array();
476 476
 		$custom_templates = array();
477 477
 		$selector_rows = '';
478 478
 
479 479
 		//we don't need message types here so we're just going to ignore. we do, however, expect the event id here. The event id is needed to provide a link to setup a custom template for this event.
480
-		$event_id = isset( $extra['event'] ) ? $extra['event'] : NULL;
480
+		$event_id = isset($extra['event']) ? $extra['event'] : NULL;
481 481
 
482
-		$template_wrapper_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_wrapper.template.php';
483
-		$template_row_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_row.template.php';
482
+		$template_wrapper_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_wrapper.template.php';
483
+		$template_row_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_row.template.php';
484 484
 
485 485
 		//array of template objects for global and custom (non-trashed) (but remember just for this messenger!)
486
-		$global_templates = EEM_Message_Template_Group::instance()->get_all( array( array('MTP_messenger' => $this->name, 'MTP_is_global' => TRUE, 'MTP_is_active' => TRUE ) ) );
487
-		$templates_for_event = EEM_Message_Template_Group::instance()->get_all_custom_templates_by_event( $event_id, array( 'MTP_messenger' => $this->name, 'MTP_is_active' => TRUE ) );
488
-		$templates_for_event = !empty( $templates_for_event ) ? $templates_for_event : array();
486
+		$global_templates = EEM_Message_Template_Group::instance()->get_all(array(array('MTP_messenger' => $this->name, 'MTP_is_global' => TRUE, 'MTP_is_active' => TRUE)));
487
+		$templates_for_event = EEM_Message_Template_Group::instance()->get_all_custom_templates_by_event($event_id, array('MTP_messenger' => $this->name, 'MTP_is_active' => TRUE));
488
+		$templates_for_event = ! empty($templates_for_event) ? $templates_for_event : array();
489 489
 
490 490
 		//so we need to setup the rows for the selectors and we use the global mtpgs (cause those will the active message template groups)
491
-		foreach ( $global_templates as $mtpgID => $mtpg ) {
491
+		foreach ($global_templates as $mtpgID => $mtpg) {
492 492
 			//verify this message type is supposed to show on this page
493 493
 			$mtp_obj = $mtpg->message_type_obj();
494
-			if ( ! $mtp_obj instanceof EE_message_type ) {
494
+			if ( ! $mtp_obj instanceof EE_message_type) {
495 495
 				continue;
496 496
 			}
497 497
 			$mtp_obj->admin_registered_pages = (array) $mtp_obj->admin_registered_pages;
498
-			if ( ! in_array( 'events_edit', $mtp_obj->admin_registered_pages ) )
498
+			if ( ! in_array('events_edit', $mtp_obj->admin_registered_pages))
499 499
 				continue;
500 500
 			$stargs = array();
501 501
 			$default_value = '';
502 502
 			$select_values = array();
503 503
 			$select_values[$mtpgID] = __('Global', 'event_espresso');
504
-			$default_value = array_key_exists( $mtpgID, $templates_for_event ) && ! $mtpg->get('MTP_is_override' ) ? $mtpgID : NULL;
504
+			$default_value = array_key_exists($mtpgID, $templates_for_event) && ! $mtpg->get('MTP_is_override') ? $mtpgID : NULL;
505 505
 
506 506
 			//if the override has been set for the global template, then that means even if there are custom templates already created we ignore them because of the set override.
507 507
 
508
-			if ( ! $mtpg->get('MTP_is_override' ) ) {
508
+			if ( ! $mtpg->get('MTP_is_override')) {
509 509
 				//any custom templates for this message type?
510
-				$custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt( $this->name, $mtpg->message_type() );
510
+				$custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt($this->name, $mtpg->message_type());
511 511
 
512
-				foreach( $custom_templates as $cmtpgID => $cmtpg ) {
512
+				foreach ($custom_templates as $cmtpgID => $cmtpg) {
513 513
 					$select_values[$cmtpgID] = $cmtpg->name();
514
-					$default_value = array_key_exists( $cmtpgID, $templates_for_event ) ? $cmtpgID : $default_value;
514
+					$default_value = array_key_exists($cmtpgID, $templates_for_event) ? $cmtpgID : $default_value;
515 515
 				}
516 516
 			}
517 517
 
518 518
 			//if there is no $default_value then we set it as the global
519
-			$default_value = empty( $default_value ) ? $mtpgID : $default_value;
519
+			$default_value = empty($default_value) ? $mtpgID : $default_value;
520 520
 
521
-			$edit_url = EEH_URL::add_query_args_and_nonce( array('page' => 'espresso_messages', 'action' => 'edit_message_template', 'id' => $default_value), admin_url('admin.php') );
522
-			$create_url = EEH_URL::add_query_args_and_nonce( array('page' => 'espresso_messages', 'action' => 'add_new_message_template', 'GRP_ID' => $default_value ), admin_url( 'admin.php' ) );
521
+			$edit_url = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'edit_message_template', 'id' => $default_value), admin_url('admin.php'));
522
+			$create_url = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'add_new_message_template', 'GRP_ID' => $default_value), admin_url('admin.php'));
523 523
 
524
-			$st_args['mt_name'] = ucwords( $mtp_obj->label['singular'] );
524
+			$st_args['mt_name'] = ucwords($mtp_obj->label['singular']);
525 525
 			$st_args['mt_slug'] = $mtpg->message_type();
526 526
 			$st_args['messenger_slug'] = $this->name;
527
-			$st_args['selector'] = EEH_Form_Fields::select_input( 'event_message_templates_relation[' . $mtpgID . ']', $select_values, $default_value, 'data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '"', 'message-template-selector' );
527
+			$st_args['selector'] = EEH_Form_Fields::select_input('event_message_templates_relation['.$mtpgID.']', $select_values, $default_value, 'data-messenger="'.$this->name.'" data-messagetype="'.$mtpg->message_type().'"', 'message-template-selector');
528 528
 
529 529
 			//note that  message template group that has override_all_custom set will remove the ability to set a custom message template based off of the global (and that also in turn overrides any other custom templates).
530
-			$st_args['create_button'] =  $mtpg->get('MTP_is_override') ? '' : '<a data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $create_url . '" class="button button-small create-mtpg-button">' . __('Create New Custom', 'event_espresso') . '</a>';
531
-			$st_args['create_button'] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'espresso_messsages_add_new_message_template' ) ? $st_args['create_button'] : '';
532
-			$st_args['edit_button'] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $mtpgID ) ?  '<a data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $edit_url . '" class="button button-small edit-mtpg-button">' . __('Edit', 'event_espresso') . '</a>' : '';
533
-			$selector_rows .= EEH_Template::display_template( $template_row_path, $st_args, TRUE );
530
+			$st_args['create_button'] = $mtpg->get('MTP_is_override') ? '' : '<a data-messenger="'.$this->name.'" data-messagetype="'.$mtpg->message_type().'" data-grpid="'.$default_value.'" target="_blank" href="'.$create_url.'" class="button button-small create-mtpg-button">'.__('Create New Custom', 'event_espresso').'</a>';
531
+			$st_args['create_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'espresso_messsages_add_new_message_template') ? $st_args['create_button'] : '';
532
+			$st_args['edit_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $mtpgID) ? '<a data-messagetype="'.$mtpg->message_type().'" data-grpid="'.$default_value.'" target="_blank" href="'.$edit_url.'" class="button button-small edit-mtpg-button">'.__('Edit', 'event_espresso').'</a>' : '';
533
+			$selector_rows .= EEH_Template::display_template($template_row_path, $st_args, TRUE);
534 534
 		}
535 535
 
536 536
 		//if no selectors present then get out.
537
-		if ( empty( $selector_rows ) ) {
537
+		if (empty($selector_rows)) {
538 538
 			return '';
539 539
 		}
540 540
 
541 541
 		$template_args['selector_rows'] = $selector_rows;
542
-		return EEH_Template::display_template( $template_wrapper_path, $template_args, TRUE );
542
+		return EEH_Template::display_template($template_wrapper_path, $template_args, TRUE);
543 543
 	}
544 544
 
545 545
 
@@ -554,8 +554,8 @@  discard block
 block discarded – undo
554 554
 	 * @return array $this->_template_fields
555 555
 	 */
556 556
 	public function get_template_fields() {
557
-		$template_fields = apply_filters( 'FHEE__' . get_class($this) . '__get_template_fields', $this->_template_fields, $this );
558
-		$template_fields = apply_filters( 'FHEE__EE_messenger__get_template_fields', $template_fields, $this );
557
+		$template_fields = apply_filters('FHEE__'.get_class($this).'__get_template_fields', $this->_template_fields, $this);
558
+		$template_fields = apply_filters('FHEE__EE_messenger__get_template_fields', $template_fields, $this);
559 559
 		return $template_fields;
560 560
 	}
561 561
 
@@ -568,9 +568,9 @@  discard block
 block discarded – undo
568 568
 	 * The following method doesn't NEED to be used by child classes but might be modified by the specific messenger
569 569
 	 */
570 570
 	protected function _set_template_value($item, $value) {
571
-		if ( array_key_exists($item, $this->_template_fields) ) {
572
-			$prop = '_' . $item;
573
-			$this->{$prop}= $value;
571
+		if (array_key_exists($item, $this->_template_fields)) {
572
+			$prop = '_'.$item;
573
+			$this->{$prop} = $value;
574 574
 		}
575 575
 	}
576 576
 
@@ -580,8 +580,8 @@  discard block
 block discarded – undo
580 580
 	 * @param EE_message_type $message_type The message type object used in combination with this messenger to generate the provided message.
581 581
 	 * @return bool | WP_Error
582 582
 	 */
583
-	public function send_message( $message, EE_message_type $message_type ) {
584
-		$this->_validate_and_setup( $message );
583
+	public function send_message($message, EE_message_type $message_type) {
584
+		$this->_validate_and_setup($message);
585 585
 		$this->_incoming_message_type = $message_type;
586 586
 		return $this->_send_message();
587 587
 	}
@@ -595,28 +595,28 @@  discard block
 block discarded – undo
595 595
 	 * @param  bool   $send    true we will actually use the _send method (for test sends). FALSE we just return preview
596 596
 	 * @return string          return the message html content
597 597
 	 */
598
-	public function get_preview( $message, EE_message_type $message_type, $send = FALSE ) {
599
-		$this->_validate_and_setup( $message );
598
+	public function get_preview($message, EE_message_type $message_type, $send = FALSE) {
599
+		$this->_validate_and_setup($message);
600 600
 
601 601
 		$this->_incoming_message_type = $message_type;
602 602
 
603
-		if ( $send ) {
603
+		if ($send) {
604 604
 			//are we overriding any existing template fields?
605 605
 			$settings = $this->get_existing_test_settings();
606
-			if ( !empty( $settings ) ) {
607
-				foreach( $settings as $field => $value ) {
608
-					$this->_set_template_value( $field, $value );
606
+			if ( ! empty($settings)) {
607
+				foreach ($settings as $field => $value) {
608
+					$this->_set_template_value($field, $value);
609 609
 				}
610 610
 			}
611 611
 		}
612 612
 
613 613
 		//enqueue preview js so that any links/buttons on the page are disabled.
614
-		if ( ! $send ) {
614
+		if ( ! $send) {
615 615
 			// the below may seem like duplication.  However, typically if a messenger enqueues scripts/styles,
616 616
 			// it deregisters all existing wp scripts and styles first.  So the second hook ensures our previewer still gets setup.
617
-			add_action( 'admin_enqueue_scripts', array( $this, 'add_preview_script' ), 10 );
618
-			add_action( 'wp_enqueue_scripts', array( $this, 'add_preview_script' ), 10 );
619
-			add_action( 'AHEE__EE_messenger__enqueue_scripts_styles', array( $this, 'add_preview_script' ), 10 );
617
+			add_action('admin_enqueue_scripts', array($this, 'add_preview_script'), 10);
618
+			add_action('wp_enqueue_scripts', array($this, 'add_preview_script'), 10);
619
+			add_action('AHEE__EE_messenger__enqueue_scripts_styles', array($this, 'add_preview_script'), 10);
620 620
 		}
621 621
 
622 622
 		return $send ? $this->_send_message() : $this->_preview();
@@ -634,10 +634,10 @@  discard block
 block discarded – undo
634 634
 	 */
635 635
 	public function add_preview_script() {
636 636
 		//error message
637
-		EE_Registry::$i18n_js_strings[ 'links_disabled' ] = __( 'All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup.  To test generated links, you must trigger an actual message notification.', 'event_espresso' );
638
-		wp_register_script( 'ee-messages-preview-js', EE_LIBRARIES_URL . 'messages/messenger/assets/js/ee-messages-preview.js', array( 'jquery' ), EVENT_ESPRESSO_VERSION, true );
639
-		wp_localize_script( 'ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings );
640
-		wp_enqueue_script( 'ee-messages-preview-js' );
637
+		EE_Registry::$i18n_js_strings['links_disabled'] = __('All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup.  To test generated links, you must trigger an actual message notification.', 'event_espresso');
638
+		wp_register_script('ee-messages-preview-js', EE_LIBRARIES_URL.'messages/messenger/assets/js/ee-messages-preview.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
639
+		wp_localize_script('ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings);
640
+		wp_enqueue_script('ee-messages-preview-js');
641 641
 	}
642 642
 
643 643
 
@@ -647,23 +647,23 @@  discard block
 block discarded – undo
647 647
 	 * @param  object $message message object
648 648
 	 * @throws \EE_Error
649 649
 	 */
650
-	protected function _validate_and_setup( $message ) {
651
-		if ( !is_object( $message ) )
652
-			throw new EE_Error( __('Incoming "$message" must be an object', 'event_espresso' ) );
650
+	protected function _validate_and_setup($message) {
651
+		if ( ! is_object($message))
652
+			throw new EE_Error(__('Incoming "$message" must be an object', 'event_espresso'));
653 653
 
654 654
 		//verify we have the required template pack value on the $message object.
655
-		if ( empty( $message->template_pack ) || ! $message->template_pack instanceof EE_Messages_Template_Pack ) {
656
-			throw new EE_Error( __('Incoming $message object must have a EE_Messages_Template_Pack object assigned to the template_pack property', 'event_espresso' ) );
655
+		if (empty($message->template_pack) || ! $message->template_pack instanceof EE_Messages_Template_Pack) {
656
+			throw new EE_Error(__('Incoming $message object must have a EE_Messages_Template_Pack object assigned to the template_pack property', 'event_espresso'));
657 657
 		}
658 658
 
659 659
 		$this->_tmp_pack = $message->template_pack;
660 660
 
661
-		$this->_variation = !empty ( $message->variation ) ? $message->variation : 'default';
661
+		$this->_variation = ! empty ($message->variation) ? $message->variation : 'default';
662 662
 
663 663
 		$template_fields = $this->get_template_fields();
664 664
 
665
-		foreach ( $template_fields as $template => $value ) {
666
-			if ( $template !== 'extra' )
665
+		foreach ($template_fields as $template => $value) {
666
+			if ($template !== 'extra')
667 667
 				$this->_set_template_value($template, $message->{$template});
668 668
 		}
669 669
 	}
@@ -678,21 +678,21 @@  discard block
 block discarded – undo
678 678
 	 * @return string
679 679
 	 * @throws \EE_Error
680 680
 	 */
681
-	protected function _get_main_template( $preview = FALSE ) {
681
+	protected function _get_main_template($preview = FALSE) {
682 682
 		$type = $preview ? 'preview' : 'main';
683 683
 
684
-		$wrapper_template = $this->_tmp_pack->get_wrapper( $this->name, $type );
684
+		$wrapper_template = $this->_tmp_pack->get_wrapper($this->name, $type);
685 685
 
686 686
 		//check file exists and is readable
687
-		if ( !is_readable( $wrapper_template ) )
688
-			throw new EE_Error( sprintf( __('Unable to access the template file for the %s messenger main content wrapper.  The location being attempted is %s.', 'event_espresso' ), ucwords($this->label['singular']) , $wrapper_template ) );
687
+		if ( ! is_readable($wrapper_template))
688
+			throw new EE_Error(sprintf(__('Unable to access the template file for the %s messenger main content wrapper.  The location being attempted is %s.', 'event_espresso'), ucwords($this->label['singular']), $wrapper_template));
689 689
 
690 690
 		//add message type to template args
691 691
 		$this->_template_args['message_type'] = $this->_incoming_message_type;
692 692
 
693 693
 		//require template helper
694
-		EE_Registry::instance()->load_helper( 'Template' );
695
-		return EEH_Template::display_template( $wrapper_template, $this->_template_args, TRUE );
694
+		EE_Registry::instance()->load_helper('Template');
695
+		return EEH_Template::display_template($wrapper_template, $this->_template_args, TRUE);
696 696
 	}
697 697
 
698 698
 
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
 	 */
729 729
 	public function get_existing_test_settings() {
730 730
 		$settings = EEH_MSG_Template::get_active_messengers_in_db();
731
-		return isset( $settings[$this->name]['test_settings'] ) ? $settings[$this->name]['test_settings'] : array();
731
+		return isset($settings[$this->name]['test_settings']) ? $settings[$this->name]['test_settings'] : array();
732 732
 	}
733 733
 
734 734
 
@@ -739,10 +739,10 @@  discard block
 block discarded – undo
739 739
 	 * @access public
740 740
 	 * @return bool 	success/fail
741 741
 	 */
742
-	public function set_existing_test_settings( $settings ) {
742
+	public function set_existing_test_settings($settings) {
743 743
 		$existing = EEH_MSG_Template::get_active_messengers_in_db();
744 744
 		$existing[$this->name]['test_settings'] = $settings;
745
-		return EEH_MSG_Template::update_active_messengers_in_db( $existing );
745
+		return EEH_MSG_Template::update_active_messengers_in_db($existing);
746 746
 	}
747 747
 
748 748
 
@@ -755,21 +755,21 @@  discard block
 block discarded – undo
755 755
 	 * @param string $field The field to retrieve the label for
756 756
 	 * @return string        	  The label
757 757
 	 */
758
-	public function get_field_label( $field ) {
758
+	public function get_field_label($field) {
759 759
 		//first let's see if the field requests is in the top level array.
760
-		if ( isset( $this->_template_fields[$field] ) && !empty( $this->_template_fields[$field]['label'] ) )
760
+		if (isset($this->_template_fields[$field]) && ! empty($this->_template_fields[$field]['label']))
761 761
 			return $this->_template[$field]['label'];
762 762
 
763 763
 		//nope so let's look in the extra array to see if it's there HOWEVER if the field exists as a top level index in the extra array then we know the label is in the 'main' index.
764
-		if ( isset( $this->_template_fields['extra'] ) && !empty( $this->_template_fields['extra'][$field] ) && !empty( $this->_template_fields['extra'][$field]['main']['label'] )  )
764
+		if (isset($this->_template_fields['extra']) && ! empty($this->_template_fields['extra'][$field]) && ! empty($this->_template_fields['extra'][$field]['main']['label']))
765 765
 			return $this->_template_fields['extra'][$field]['main']['label'];
766 766
 
767 767
 		//now it's possible this field may just be existing in any of the extra array items.
768
-		if ( !empty( $this->_template_fields['extra'] ) && is_array( $this->_template_fields['extra'] ) ) {
769
-			foreach ( $this->_template_fields['extra'] as $main_field => $subfields ) {
770
-				if ( !is_array( $subfields ) )
768
+		if ( ! empty($this->_template_fields['extra']) && is_array($this->_template_fields['extra'])) {
769
+			foreach ($this->_template_fields['extra'] as $main_field => $subfields) {
770
+				if ( ! is_array($subfields))
771 771
 					continue;
772
-				if ( isset( $subfields[$field] ) && !empty( $subfields[$field]['label'] ) )
772
+				if (isset($subfields[$field]) && ! empty($subfields[$field]['label']))
773 773
 					return $subfields[$field]['label'];
774 774
 			}
775 775
 		}
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 	 *
791 791
 	 * @return void
792 792
 	 */
793
-	public function do_secondary_messenger_hooks( $sending_messenger_name ) {
793
+	public function do_secondary_messenger_hooks($sending_messenger_name) {
794 794
 		return;
795 795
 	}
796 796
 
Please login to merge, or discard this patch.
Braces   +26 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if (!defined('EVENT_ESPRESSO_VERSION') ) {
3 3
 	exit('NO direct script access allowed');
4
+}
4 5
 
5 6
 /**
6 7
  * Event Espresso
@@ -495,8 +496,9 @@  discard block
 block discarded – undo
495 496
 				continue;
496 497
 			}
497 498
 			$mtp_obj->admin_registered_pages = (array) $mtp_obj->admin_registered_pages;
498
-			if ( ! in_array( 'events_edit', $mtp_obj->admin_registered_pages ) )
499
-				continue;
499
+			if ( ! in_array( 'events_edit', $mtp_obj->admin_registered_pages ) ) {
500
+							continue;
501
+			}
500 502
 			$stargs = array();
501 503
 			$default_value = '';
502 504
 			$select_values = array();
@@ -648,8 +650,9 @@  discard block
 block discarded – undo
648 650
 	 * @throws \EE_Error
649 651
 	 */
650 652
 	protected function _validate_and_setup( $message ) {
651
-		if ( !is_object( $message ) )
652
-			throw new EE_Error( __('Incoming "$message" must be an object', 'event_espresso' ) );
653
+		if ( !is_object( $message ) ) {
654
+					throw new EE_Error( __('Incoming "$message" must be an object', 'event_espresso' ) );
655
+		}
653 656
 
654 657
 		//verify we have the required template pack value on the $message object.
655 658
 		if ( empty( $message->template_pack ) || ! $message->template_pack instanceof EE_Messages_Template_Pack ) {
@@ -663,8 +666,9 @@  discard block
 block discarded – undo
663 666
 		$template_fields = $this->get_template_fields();
664 667
 
665 668
 		foreach ( $template_fields as $template => $value ) {
666
-			if ( $template !== 'extra' )
667
-				$this->_set_template_value($template, $message->{$template});
669
+			if ( $template !== 'extra' ) {
670
+							$this->_set_template_value($template, $message->{$template});
671
+			}
668 672
 		}
669 673
 	}
670 674
 
@@ -684,8 +688,9 @@  discard block
 block discarded – undo
684 688
 		$wrapper_template = $this->_tmp_pack->get_wrapper( $this->name, $type );
685 689
 
686 690
 		//check file exists and is readable
687
-		if ( !is_readable( $wrapper_template ) )
688
-			throw new EE_Error( sprintf( __('Unable to access the template file for the %s messenger main content wrapper.  The location being attempted is %s.', 'event_espresso' ), ucwords($this->label['singular']) , $wrapper_template ) );
691
+		if ( !is_readable( $wrapper_template ) ) {
692
+					throw new EE_Error( sprintf( __('Unable to access the template file for the %s messenger main content wrapper.  The location being attempted is %s.', 'event_espresso' ), ucwords($this->label['singular']) , $wrapper_template ) );
693
+		}
689 694
 
690 695
 		//add message type to template args
691 696
 		$this->_template_args['message_type'] = $this->_incoming_message_type;
@@ -757,20 +762,24 @@  discard block
 block discarded – undo
757 762
 	 */
758 763
 	public function get_field_label( $field ) {
759 764
 		//first let's see if the field requests is in the top level array.
760
-		if ( isset( $this->_template_fields[$field] ) && !empty( $this->_template_fields[$field]['label'] ) )
761
-			return $this->_template[$field]['label'];
765
+		if ( isset( $this->_template_fields[$field] ) && !empty( $this->_template_fields[$field]['label'] ) ) {
766
+					return $this->_template[$field]['label'];
767
+		}
762 768
 
763 769
 		//nope so let's look in the extra array to see if it's there HOWEVER if the field exists as a top level index in the extra array then we know the label is in the 'main' index.
764
-		if ( isset( $this->_template_fields['extra'] ) && !empty( $this->_template_fields['extra'][$field] ) && !empty( $this->_template_fields['extra'][$field]['main']['label'] )  )
765
-			return $this->_template_fields['extra'][$field]['main']['label'];
770
+		if ( isset( $this->_template_fields['extra'] ) && !empty( $this->_template_fields['extra'][$field] ) && !empty( $this->_template_fields['extra'][$field]['main']['label'] )  ) {
771
+					return $this->_template_fields['extra'][$field]['main']['label'];
772
+		}
766 773
 
767 774
 		//now it's possible this field may just be existing in any of the extra array items.
768 775
 		if ( !empty( $this->_template_fields['extra'] ) && is_array( $this->_template_fields['extra'] ) ) {
769 776
 			foreach ( $this->_template_fields['extra'] as $main_field => $subfields ) {
770
-				if ( !is_array( $subfields ) )
771
-					continue;
772
-				if ( isset( $subfields[$field] ) && !empty( $subfields[$field]['label'] ) )
773
-					return $subfields[$field]['label'];
777
+				if ( !is_array( $subfields ) ) {
778
+									continue;
779
+				}
780
+				if ( isset( $subfields[$field] ) && !empty( $subfields[$field]['label'] ) ) {
781
+									return $subfields[$field]['label'];
782
+				}
774 783
 			}
775 784
 		}
776 785
 
Please login to merge, or discard this patch.
core/libraries/rest_api/changes/Changes_In_4_8_33.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@  discard block
 block discarded – undo
13 13
 		//is for lower than 4.8.33
14 14
 		add_filter( 
15 15
 			'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes',
16
-			array( $this, 'remove_checkin_routes_earlier_than_4_8_33' ),
16
+			array($this, 'remove_checkin_routes_earlier_than_4_8_33'),
17 17
 			10,
18 18
 			2
19 19
 		);
20 20
 		add_filter( 
21 21
 			'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_headers_from_ee_notices__return',
22
-			array( $this, 'dont_add_headers_from_ee_notices' ),
22
+			array($this, 'dont_add_headers_from_ee_notices'),
23 23
 			10,
24 24
 			2
25 25
 		);
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
 	 * @param string $version
33 33
 	 * @return array like $routes_on_this_version
34 34
 	 */
35
-	public function remove_checkin_routes_earlier_than_4_8_33( $routes_on_this_version, $version ) {
36
-		if( $this->applies_to_version(  $version ) ) {
37
-			unset( $routes_on_this_version[ 'registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)' ] );
35
+	public function remove_checkin_routes_earlier_than_4_8_33($routes_on_this_version, $version) {
36
+		if ($this->applies_to_version($version)) {
37
+			unset($routes_on_this_version['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)']);
38 38
 		}
39 39
 		return $routes_on_this_version;
40 40
 	}
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 	 * @param string $requested_version
46 46
 	 * @return array
47 47
 	 */
48
-	public function dont_add_headers_from_ee_notices( $headers_from_ee_notices, $requested_version ) {
49
-		if( $this->applies_to_version(  $requested_version ) ) {
48
+	public function dont_add_headers_from_ee_notices($headers_from_ee_notices, $requested_version) {
49
+		if ($this->applies_to_version($requested_version)) {
50 50
 			return array();
51 51
 		}
52 52
 		return $headers_from_ee_notices;
Please login to merge, or discard this patch.
core/libraries/rest_api/changes/Changes_In_Base.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 * @return boolean true: this class' name indicates its filters and actions
57 57
 	 * should take effect. False: this class' name indicates it shouldn't do anything
58 58
 	 */
59
-	public function applies_to_version( $requested_version ) {
60
-		if( $this->version() > $requested_version ) {
59
+	public function applies_to_version($requested_version) {
60
+		if ($this->version() > $requested_version) {
61 61
 			return true;
62 62
 		}
63 63
 		return false;
@@ -71,24 +71,24 @@  discard block
 block discarded – undo
71 71
 	 * @throws \EE_Error
72 72
 	 */
73 73
 	public function version() {
74
-		if( $this->_version === null ) {
74
+		if ($this->_version === null) {
75 75
 			$matches = array();
76 76
 			$regex = '~Changes_In_(.*)_(.*)_(.*)$~';
77 77
 			$success = preg_match(
78 78
 				$regex,
79
-				get_class( $this ),
79
+				get_class($this),
80 80
 				$matches
81 81
 			);
82
-			if( ! $success ) {
82
+			if ( ! $success) {
83 83
 				throw new \EE_Error(
84 84
 					sprintf(
85
-						__( 'The class %1$s was misnamed. It name should match the regex "%2$s"', 'event_espresso' ),
86
-						get_class( $this ),
85
+						__('The class %1$s was misnamed. It name should match the regex "%2$s"', 'event_espresso'),
86
+						get_class($this),
87 87
 						$regex
88 88
 					)
89 89
 				);
90 90
 			}
91
-			$this->_version = $matches[1] . '.' . $matches[2] . '.' . $matches[3];
91
+			$this->_version = $matches[1].'.'.$matches[2].'.'.$matches[3];
92 92
 		}
93 93
 		return $this->_version;
94 94
 	}
Please login to merge, or discard this patch.
core/libraries/rest_api/controllers/rpc/Checkin.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 use EventEspresso\core\libraries\rest_api\controllers\Base as Base;
3 3
 use EventEspresso\core\libraries\rest_api\controllers\model\Read;
4 4
 
5
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
6
-	exit( 'No direct script access allowed' );
5
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
6
+	exit('No direct script access allowed');
7 7
 }
8 8
 
9 9
 /**
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
 	 * @param \WP_REST_Request $request
25 25
 	 * @return \WP_Error|\WP_REST_Response
26 26
 	 */
27
-	public static function handle_request_toggle_checkin( \WP_REST_Request $request ) {
27
+	public static function handle_request_toggle_checkin(\WP_REST_Request $request) {
28 28
 		$controller = new Checkin();
29
-		return $controller->_create_checkin_checkout_object( $request );
29
+		return $controller->_create_checkin_checkout_object($request);
30 30
 	}
31 31
 
32 32
 
@@ -37,47 +37,47 @@  discard block
 block discarded – undo
37 37
 	 * @param \WP_REST_Request $request
38 38
 	 * @return \WP_Error|\WP_REST_Response
39 39
 	 */
40
-	protected function _create_checkin_checkout_object( \WP_REST_Request $request ) {
41
-		$reg_id = $request->get_param( 'REG_ID' );
42
-		$dtt_id = $request->get_param( 'DTT_ID' );
43
-		$force = $request->get_param( 'force' );
44
-		if( $force == 'true' ) {
40
+	protected function _create_checkin_checkout_object(\WP_REST_Request $request) {
41
+		$reg_id = $request->get_param('REG_ID');
42
+		$dtt_id = $request->get_param('DTT_ID');
43
+		$force = $request->get_param('force');
44
+		if ($force == 'true') {
45 45
 			$force = true;
46 46
 		} else {
47 47
 			$force = false;
48 48
 		}
49
-		$reg = \EEM_Registration::instance()->get_one_by_ID( $reg_id );
50
-		if( ! $reg instanceof \EE_Registration ) {
49
+		$reg = \EEM_Registration::instance()->get_one_by_ID($reg_id);
50
+		if ( ! $reg instanceof \EE_Registration) {
51 51
 			return $this->send_response(
52 52
 				new \WP_Error(
53 53
 					'rest_registration_toggle_checkin_invalid_id',
54 54
 					sprintf(
55
-						__( 'You cannot checkin registration with ID %1$s because it doesn\'t exist.', 'event_espresso' ),
55
+						__('You cannot checkin registration with ID %1$s because it doesn\'t exist.', 'event_espresso'),
56 56
 						$reg_id
57 57
 					),
58
-					array( 'status' => 422 )
58
+					array('status' => 422)
59 59
 				)
60 60
 			);
61 61
 		}
62
-		if( ! \EE_Capabilities::instance()->current_user_can( 'ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id ) ) {
62
+		if ( ! \EE_Capabilities::instance()->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)) {
63 63
 			return $this->send_response(
64 64
 				new \WP_Error(
65 65
 					'rest_user_cannot_toggle_checkin',
66 66
 					sprintf(
67
-						__( 'You are not allowed to checkin registration with ID %1$s.', 'event_espresso' ),
67
+						__('You are not allowed to checkin registration with ID %1$s.', 'event_espresso'),
68 68
 						$reg_id
69 69
 					),
70
-					array( 'status' => 403 )
70
+					array('status' => 403)
71 71
 				)
72 72
 			);
73 73
 		}
74
-		$success = $reg->toggle_checkin_status( $dtt_id, ! $force );
75
-		if( $success === false ) {
74
+		$success = $reg->toggle_checkin_status($dtt_id, ! $force);
75
+		if ($success === false) {
76 76
 			//rely on EE_Error::add_error messages to have been added to give more data about hwy it failed
77 77
 			return $this->send_response(
78 78
 				new \WP_Error(
79 79
 					'rest_toggle_checkin_failed',
80
-					__( 'Registration checkin failed. Please see additional error data.', 'event_espresso' )
80
+					__('Registration checkin failed. Please see additional error data.', 'event_espresso')
81 81
 				)
82 82
 			);
83 83
 		}
@@ -92,28 +92,28 @@  discard block
 block discarded – undo
92 92
 				)
93 93
 			)
94 94
 		);
95
-		if( ! $checkin instanceof \EE_Checkin ) {
95
+		if ( ! $checkin instanceof \EE_Checkin) {
96 96
 			return $this->send_response(
97 97
 				new \WP_Error(
98 98
 					'rest_toggle_checkin_error',
99 99
 					sprintf(
100
-						__( 'Supposedly we created a new checkin object for registration %1$s at datetime %2$s, but we can\'t find it.', 'event_espresso' ),
100
+						__('Supposedly we created a new checkin object for registration %1$s at datetime %2$s, but we can\'t find it.', 'event_espresso'),
101 101
 						$reg_id,
102 102
 						$dtt_id
103 103
 					)
104 104
 				)
105 105
 			);
106 106
 		}
107
-		$requested_version = $this->get_requested_version( $request->get_route() );
107
+		$requested_version = $this->get_requested_version($request->get_route());
108 108
 		$get_request = new \WP_REST_Request(
109 109
 			'GET',
110
-			\EED_Core_Rest_Api::ee_api_namespace . $requested_version . '/checkins/' . $checkin->ID()
110
+			\EED_Core_Rest_Api::ee_api_namespace.$requested_version.'/checkins/'.$checkin->ID()
111 111
 		);
112 112
 		$get_request->set_url_params(
113 113
 			array(
114 114
 				'id' => $checkin->ID()
115 115
 			)
116 116
 		);
117
-		return Read::handle_request_get_one( $get_request );
117
+		return Read::handle_request_get_one($get_request);
118 118
 	}
119 119
 }
120 120
\ No newline at end of file
Please login to merge, or discard this patch.
core/middleware/EE_Recommended_Versions.core.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -22,35 +22,35 @@  discard block
 block discarded – undo
22 22
 	 * @param 	EE_Response $response
23 23
 	 * @return 	EE_Response
24 24
 	 */
25
-	public function handle_request( EE_Request $request, EE_Response $response ) {
25
+	public function handle_request(EE_Request $request, EE_Response $response) {
26 26
 		$this->_request = $request;
27 27
 		$this->_response = $response;
28 28
 		//$this->_response->add_output( "\n\t IN >>  " . __CLASS__ );
29 29
 		//$this->_response->set_notice( 1, 'hey look at this' );
30 30
 		// check required WP version
31
-		if ( ! $this->_minimum_wp_version_required() ) {
32
-			$this->_request->un_set( 'activate', true );
33
-			add_action( 'admin_notices', array( $this, 'minimum_wp_version_error' ), 1 );
31
+		if ( ! $this->_minimum_wp_version_required()) {
32
+			$this->_request->un_set('activate', true);
33
+			add_action('admin_notices', array($this, 'minimum_wp_version_error'), 1);
34 34
 			//$this->_response->add_output( "\n<br />" . 'minimum_wp_version_error' );
35 35
 			$this->_response->terminate_request();
36 36
 		}
37 37
 		// check required PHP version
38
-		if ( ! $this->_minimum_php_version_required() ) {
39
-			$this->_request->un_set( 'activate', true );
40
-			add_action( 'admin_notices', array( $this, 'minimum_php_version_error' ), 1 );
38
+		if ( ! $this->_minimum_php_version_required()) {
39
+			$this->_request->un_set('activate', true);
40
+			add_action('admin_notices', array($this, 'minimum_php_version_error'), 1);
41 41
 			//$this->_response->add_output( "\n<br />" . 'minimum_php_version_error' );
42 42
 			$this->_response->terminate_request();
43 43
 		}
44 44
 		// check recommended WP version
45
-		if ( ! $this->_minimum_wp_version_recommended() ) {
45
+		if ( ! $this->_minimum_wp_version_recommended()) {
46 46
 			$this->_display_minimum_recommended_wp_version_notice();
47 47
 		}
48 48
 		// check recommended PHP version
49
-		if ( ! $this->_minimum_php_version_recommended() ) {
49
+		if ( ! $this->_minimum_php_version_recommended()) {
50 50
 			$this->_display_minimum_recommended_php_version_notice();
51 51
 		}
52 52
 		$this->_test_for_php_version_7();
53
-		$this->_response = $this->process_request_stack( $this->_request, $this->_response );
53
+		$this->_response = $this->process_request_stack($this->_request, $this->_response);
54 54
 		//$this->_response->add_output( "\n\t OUT << " . __CLASS__ );
55 55
 		return $this->_response;
56 56
 	}
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 	 * @param string $min_version
65 65
 	 * @return boolean
66 66
 	 */
67
-	private function _check_wp_version( $min_version = EE_MIN_WP_VER_REQUIRED ) {
67
+	private function _check_wp_version($min_version = EE_MIN_WP_VER_REQUIRED) {
68 68
 		global $wp_version;
69
-		return version_compare( $wp_version, $min_version, '>=' ) ? true : false;
69
+		return version_compare($wp_version, $min_version, '>=') ? true : false;
70 70
 	}
71 71
 
72 72
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @return boolean
79 79
 	 */
80 80
 	private function _minimum_wp_version_required() {
81
-		return $this->_check_wp_version( EE_MIN_WP_VER_REQUIRED );
81
+		return $this->_check_wp_version(EE_MIN_WP_VER_REQUIRED);
82 82
 	}
83 83
 
84 84
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @return boolean
91 91
 	 */
92 92
 	private function _minimum_wp_version_recommended() {
93
-		return $this->_check_wp_version( EE_MIN_WP_VER_RECOMMENDED );
93
+		return $this->_check_wp_version(EE_MIN_WP_VER_RECOMMENDED);
94 94
 	}
95 95
 
96 96
 
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 	 * @param string $min_version
103 103
 	 * @return boolean
104 104
 	 */
105
-	private function _check_php_version( $min_version = EE_MIN_PHP_VER_RECOMMENDED ) {
106
-		return version_compare( PHP_VERSION, $min_version, '>=' ) ? true : false;
105
+	private function _check_php_version($min_version = EE_MIN_PHP_VER_RECOMMENDED) {
106
+		return version_compare(PHP_VERSION, $min_version, '>=') ? true : false;
107 107
 	}
108 108
 
109 109
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 * @return boolean
116 116
 	 */
117 117
 	private function _minimum_php_version_required() {
118
-		return $this->_check_php_version( EE_MIN_PHP_VER_REQUIRED );
118
+		return $this->_check_php_version(EE_MIN_PHP_VER_REQUIRED);
119 119
 	}
120 120
 
121 121
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 * @return boolean
128 128
 	 */
129 129
 	private function _minimum_php_version_recommended() {
130
-		return $this->_check_php_version( EE_MIN_PHP_VER_RECOMMENDED );
130
+		return $this->_check_php_version(EE_MIN_PHP_VER_RECOMMENDED);
131 131
 	}
132 132
 
133 133
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 			<p>
145 145
 				<?php
146 146
 				printf(
147
-					__( 'We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', 'event_espresso' ),
147
+					__('We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', 'event_espresso'),
148 148
 					EE_MIN_WP_VER_REQUIRED,
149 149
 					$wp_version,
150 150
 					'<br/>',
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 			<p>
170 170
 				<?php
171 171
 				printf(
172
-					__( 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', 'event_espresso' ),
172
+					__('We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', 'event_espresso'),
173 173
 					EE_MIN_PHP_VER_REQUIRED,
174 174
 					PHP_VERSION,
175 175
 					'<br/>',
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
 	private function _display_minimum_recommended_wp_version_notice() {
193 193
 		global $wp_version;
194 194
 		EE_Error::add_persistent_admin_notice(
195
-			'wp_version_' . str_replace( '.', '-', EE_MIN_WP_VER_RECOMMENDED ) . '_recommended',
195
+			'wp_version_'.str_replace('.', '-', EE_MIN_WP_VER_RECOMMENDED).'_recommended',
196 196
 			sprintf(
197
-				__( 'Event Espresso recommends WordPress version %1$s or greater in order for everything to operate properly. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', 'event_espresso' ),
197
+				__('Event Espresso recommends WordPress version %1$s or greater in order for everything to operate properly. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', 'event_espresso'),
198 198
 				EE_MIN_WP_VER_RECOMMENDED,
199 199
 				$wp_version,
200 200
 				'<br/>',
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
 	 */
214 214
 	private function _display_minimum_recommended_php_version_notice() {
215 215
 		EE_Error::add_persistent_admin_notice(
216
-			'php_version_' . str_replace( '.', '-', EE_MIN_PHP_VER_RECOMMENDED ) . '_recommended',
216
+			'php_version_'.str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED).'_recommended',
217 217
 			sprintf(
218
-				__( 'Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', 'event_espresso' ),
218
+				__('Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', 'event_espresso'),
219 219
 				EE_MIN_PHP_VER_RECOMMENDED,
220 220
 				PHP_VERSION,
221 221
 				'<br/>',
@@ -232,10 +232,10 @@  discard block
 block discarded – undo
232 232
 	 * @access private
233 233
 	 */
234 234
 	private function _test_for_php_version_7() {
235
-		if ( $this->_check_php_version( '7' ) ) {
236
-			define( 'EE_PHP_7', true );
235
+		if ($this->_check_php_version('7')) {
236
+			define('EE_PHP_7', true);
237 237
 		} else {
238
-			define( 'EE_PHP_7', false );
238
+			define('EE_PHP_7', false);
239 239
 		}
240 240
 	}
241 241
 
Please login to merge, or discard this patch.
modules/core_rest_api/EED_Core_Rest_Api.module.php 1 patch
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 * @return EED_Core_Rest_Api
28 28
 	 */
29 29
 	public static function instance() {
30
-		return parent::get_instance( __CLASS__ );
30
+		return parent::get_instance(__CLASS__);
31 31
 	}
32 32
 
33 33
 
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
 
58 58
 
59 59
 	public static function set_hooks_both() {
60
-		add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'register_routes' ), 10 );
61
-		add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'set_hooks_rest_api' ), 5 );
62
-		add_filter( 'rest_route_data', array( 'EED_Core_Rest_Api', 'hide_old_endpoints' ), 10, 2 );
63
-		add_filter( 'rest_index', array( 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index' ) );
60
+		add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10);
61
+		add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5);
62
+		add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2);
63
+		add_filter('rest_index', array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index'));
64 64
 	}
65 65
 
66 66
 	/**
@@ -73,16 +73,16 @@  discard block
 block discarded – undo
73 73
 	}
74 74
 
75 75
 	protected static function _set_hooks_for_changes() {
76
-		$folder_contents = EEH_File::get_contents_of_folders( array( EE_LIBRARIES . 'rest_api' . DS . 'changes' ), false );
77
-		foreach( $folder_contents as $classname_in_namespace => $filepath ) {
76
+		$folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES.'rest_api'.DS.'changes'), false);
77
+		foreach ($folder_contents as $classname_in_namespace => $filepath) {
78 78
 			//ignore the base parent class
79
-			if( $classname_in_namespace === 'Changes_In_Base' ) {
79
+			if ($classname_in_namespace === 'Changes_In_Base') {
80 80
 				continue;
81 81
 			}
82
-			$full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace;
83
-			if ( class_exists( $full_classname )) {
82
+			$full_classname = 'EventEspresso\core\libraries\rest_api\changes\\'.$classname_in_namespace;
83
+			if (class_exists($full_classname)) {
84 84
 				$instance_of_class = new $full_classname;
85
-				if ( $instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base ) {
85
+				if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) {
86 86
 					$instance_of_class->set_hooks();
87 87
 				}
88 88
 			}
@@ -95,16 +95,16 @@  discard block
 block discarded – undo
95 95
 	 * so we actually prefer to only do it when an EE plugin is activated or upgraded
96 96
 	 */
97 97
 	public static function register_routes() {
98
-		foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) {
99
-			foreach( $relative_urls as $endpoint => $routes ) {
100
-				foreach( $routes as $route ) {
98
+		foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) {
99
+			foreach ($relative_urls as $endpoint => $routes) {
100
+				foreach ($routes as $route) {
101 101
 					register_rest_route(
102 102
 						$namespace,
103 103
 						$endpoint,
104 104
 						array(
105
-							'callback' => $route[ 'callback' ],
106
-							'methods' => $route[ 'methods' ],
107
-							'args' => isset( $route[ 'args' ] ) ? $route[ 'args' ] : array(),
105
+							'callback' => $route['callback'],
106
+							'methods' => $route['methods'],
107
+							'args' => isset($route['args']) ? $route['args'] : array(),
108 108
 						)
109 109
 					);
110 110
 				}
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
 	 * }
122 122
 	 */
123 123
 	public static function get_ee_route_data() {
124
-		$ee_routes = get_option( self::saved_routes_option_names, null );
125
-		if( ! $ee_routes || ( defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE )){
124
+		$ee_routes = get_option(self::saved_routes_option_names, null);
125
+		if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) {
126 126
 			self::save_ee_routes();
127
-			$ee_routes = get_option( self::saved_routes_option_names, array() );
127
+			$ee_routes = get_option(self::saved_routes_option_names, array());
128 128
 		}
129 129
 		return $ee_routes;
130 130
 	}
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 * @return void
136 136
 	 */
137 137
 	public static function save_ee_routes() {
138
-		if( EE_Maintenance_Mode::instance()->models_can_query() ){
138
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
139 139
 			$instance = self::instance();
140 140
 			$routes = apply_filters(
141 141
 				'EED_Core_Rest_Api__save_ee_routes__routes',
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 					$instance->_register_rpc_routes()
147 147
 				)
148 148
 			);
149
-			update_option( self::saved_routes_option_names, $routes, true );
149
+			update_option(self::saved_routes_option_names, $routes, true);
150 150
 		}
151 151
 	}
152 152
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 * @return array @see get_ee_route_data
156 156
 	 */
157 157
 	protected function _register_model_routes() {
158
-		EE_Registry::instance()->load_helper( 'Inflector' );
158
+		EE_Registry::instance()->load_helper('Inflector');
159 159
 		$models_to_register = apply_filters(
160 160
 			'FHEE__EED_Core_REST_API___register_model_routes',
161 161
 			EE_Registry::instance()->non_abstract_db_models
@@ -164,23 +164,23 @@  discard block
 block discarded – undo
164 164
 		unset($models_to_register['Extra_Meta']);
165 165
 		unset($models_to_register['Extra_Join']);
166 166
 		$model_routes = array( );
167
-		foreach( self::versions_served() as $version => $hidden_endpoint ) {
167
+		foreach (self::versions_served() as $version => $hidden_endpoint) {
168 168
 
169
-			foreach ( $models_to_register as $model_name => $model_classname ) {
169
+			foreach ($models_to_register as $model_name => $model_classname) {
170 170
 				//yes we could just register one route for ALL models, but then they wouldn't show up in the index
171
-				$ee_namespace = self::ee_api_namespace . $version;
172
-				$plural_model_route = EEH_Inflector::pluralize_and_lower( $model_name );
173
-				$singular_model_route = $plural_model_route . '/(?P<id>\d+)' ;
174
-				$model_routes[ $ee_namespace ][ $plural_model_route ] = array(
171
+				$ee_namespace = self::ee_api_namespace.$version;
172
+				$plural_model_route = EEH_Inflector::pluralize_and_lower($model_name);
173
+				$singular_model_route = $plural_model_route.'/(?P<id>\d+)';
174
+				$model_routes[$ee_namespace][$plural_model_route] = array(
175 175
 						array(
176 176
 							'callback' => array(
177 177
 								'EventEspresso\core\libraries\rest_api\controllers\model\Read',
178 178
 								'handle_request_get_all' ),
179 179
 							'methods' => WP_REST_Server::READABLE,
180 180
 							'hidden_endpoint' => $hidden_endpoint,
181
-							'args' => $this->_get_read_query_params( $model_name ),
181
+							'args' => $this->_get_read_query_params($model_name),
182 182
 							'_links' => array(
183
-								'self' => rest_url( $ee_namespace . $singular_model_route ),
183
+								'self' => rest_url($ee_namespace.$singular_model_route),
184 184
 							)
185 185
 						),
186 186
 //						array(
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 //							'hidden_endpoint' => $hidden_endpoint
192 192
 //						)
193 193
 					);
194
-				$model_routes[ $ee_namespace ][ $singular_model_route ] = array(
194
+				$model_routes[$ee_namespace][$singular_model_route] = array(
195 195
 						array(
196 196
 							'callback' => array(
197 197
 								'EventEspresso\core\libraries\rest_api\controllers\model\Read',
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 								'include' => array(
203 203
 									'required' => false,
204 204
 									'default' => '*',
205
-									'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso' ),
205
+									'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso'),
206 206
 								),
207 207
 							)
208 208
 						),
@@ -215,20 +215,20 @@  discard block
 block discarded – undo
215 215
 //							),
216 216
 				);
217 217
 				//@todo: also handle  DELETE for a single item
218
-				$model = EE_Registry::instance()->load_model( $model_classname );
219
-				foreach ( $model->relation_settings() as $relation_name => $relation_obj ) {
218
+				$model = EE_Registry::instance()->load_model($model_classname);
219
+				foreach ($model->relation_settings() as $relation_name => $relation_obj) {
220 220
 					$related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name(
221 221
 						$relation_name,
222 222
 						$relation_obj
223 223
 					);
224
-					$model_routes[ $ee_namespace ][ $singular_model_route . '/' . $related_model_name_endpoint_part ] = array(
224
+					$model_routes[$ee_namespace][$singular_model_route.'/'.$related_model_name_endpoint_part] = array(
225 225
 							array(
226 226
 								'callback' => array(
227 227
 									'EventEspresso\core\libraries\rest_api\controllers\model\Read',
228 228
 									'handle_request_get_related' ),
229 229
 								'methods' => WP_REST_Server::READABLE,
230 230
 								'hidden_endpoint' => $hidden_endpoint,
231
-								'args' => $this->_get_read_query_params( $relation_name ),
231
+								'args' => $this->_get_read_query_params($relation_name),
232 232
 							),
233 233
 //							array(
234 234
 //								'callback' => array(
@@ -252,11 +252,11 @@  discard block
 block discarded – undo
252 252
 	 */
253 253
 	protected function _register_rpc_routes() {
254 254
 		$routes = array();
255
-		foreach( self::versions_served() as $version => $hidden_endpoint ) {
256
-			$ee_namespace = self::ee_api_namespace . $version;
255
+		foreach (self::versions_served() as $version => $hidden_endpoint) {
256
+			$ee_namespace = self::ee_api_namespace.$version;
257 257
 			$this_versions_routes = array();
258 258
 			//checkin endpoint
259
-			$this_versions_routes[ 'registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)' ] = array(
259
+			$this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array(
260 260
 				array(
261 261
 					'callback' => array(
262 262
 						'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin',
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
 						'force' => array(
268 268
 							'required' => false,
269 269
 							'default' => false,
270
-							'description' => __( 'Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso' )
270
+							'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso')
271 271
 						)
272 272
 					)
273 273
 				)
274 274
 			);
275
-			$routes[ $ee_namespace ] = apply_filters(
275
+			$routes[$ee_namespace] = apply_filters(
276 276
 				'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes',
277 277
 				$this_versions_routes,
278 278
 				$version,
@@ -287,47 +287,47 @@  discard block
 block discarded – undo
287 287
 	 * @param string $model_name eg 'Event' or 'Venue'
288 288
 	 * @return array describing the args acceptable when querying this model
289 289
 	 */
290
-	protected function _get_read_query_params( $model_name ) {
291
-		$model = EE_Registry::instance()->load_model( $model_name );
290
+	protected function _get_read_query_params($model_name) {
291
+		$model = EE_Registry::instance()->load_model($model_name);
292 292
 		$default_orderby = array();
293
-		foreach( $model->get_combined_primary_key_fields() as $key_field ) {
294
-			$default_orderby[ $key_field->get_name() ] = 'ASC';
293
+		foreach ($model->get_combined_primary_key_fields() as $key_field) {
294
+			$default_orderby[$key_field->get_name()] = 'ASC';
295 295
 		}
296 296
 		return array(
297 297
 			'where' => array(
298 298
 				'required' => false,
299 299
 				'default' => array(),
300
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#where for documentation', 'event_espresso' ),
300
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#where for documentation', 'event_espresso'),
301 301
 				),
302 302
 			'limit' => array(
303 303
 				'required' => false,
304 304
 				'default' => 50,
305
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#limit for documentation', 'event_espresso' )
305
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#limit for documentation', 'event_espresso')
306 306
 			),
307 307
 			'order_by' => array(
308 308
 				'required' => false,
309 309
 				'default' => $default_orderby,
310
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#order_by for documentation', 'event_espresso' )
310
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#order_by for documentation', 'event_espresso')
311 311
 			),
312 312
 			'group_by' => array(
313 313
 				'required' => false,
314 314
 				'default' => null,
315
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#group_by for documentation', 'event_espresso' )
315
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#group_by for documentation', 'event_espresso')
316 316
 			),
317 317
 			'having' => array(
318 318
 				'required' => false,
319 319
 				'default' => null,
320
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#having for documentation', 'event_espresso' )
320
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#having for documentation', 'event_espresso')
321 321
 			),
322 322
 			'caps' => array(
323 323
 				'required' => false,
324 324
 				'default' => EEM_Base::caps_read,
325
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#caps for documentation', 'event_espresso' )
325
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#caps for documentation', 'event_espresso')
326 326
 			),
327 327
 			'include' => array(
328 328
 				'required' => false,
329 329
 				'default' => '*',
330
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso' ),
330
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso'),
331 331
 			),
332 332
 		);
333 333
 	}
@@ -338,8 +338,8 @@  discard block
 block discarded – undo
338 338
 	 */
339 339
 	protected function _register_config_routes() {
340 340
 		$config_routes = array();
341
-		foreach( self::versions_served() as $version => $hidden_endpoint ) {
342
-			$config_routes[ self::ee_api_namespace . $version ][ 'config' ] = array(
341
+		foreach (self::versions_served() as $version => $hidden_endpoint) {
342
+			$config_routes[self::ee_api_namespace.$version]['config'] = array(
343 343
 					array(
344 344
 						'callback' => array(
345 345
 							'EventEspresso\core\libraries\rest_api\controllers\config\Read',
@@ -358,8 +358,8 @@  discard block
 block discarded – undo
358 358
 	 */
359 359
 	protected function _register_meta_routes() {
360 360
 		$meta_routes = array();
361
-		foreach( self::versions_served() as $version => $hidden_endpoint ) {
362
-			$meta_routes[ self::ee_api_namespace . $version ][ '/resources' ] = array(
361
+		foreach (self::versions_served() as $version => $hidden_endpoint) {
362
+			$meta_routes[self::ee_api_namespace.$version]['/resources'] = array(
363 363
 				array(
364 364
 					'callback' => array(
365 365
 						'EventEspresso\core\libraries\rest_api\controllers\model\Meta',
@@ -380,13 +380,13 @@  discard block
 block discarded – undo
380 380
 	 * @param array $route_data
381 381
 	 * @return array
382 382
 	 */
383
-	public static function hide_old_endpoints( $route_data ) {
384
-		foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) {
385
-			foreach( $relative_urls as $endpoint => $routes ) {
386
-				foreach( $routes as $route ) {
387
-					if( $route[ 'hidden_endpoint' ] ) {
388
-						$full_route = '/' . ltrim( $namespace, '/' ) . '/' . ltrim( $endpoint, '/' );
389
-						unset( $route_data[ $full_route ] );
383
+	public static function hide_old_endpoints($route_data) {
384
+		foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) {
385
+			foreach ($relative_urls as $endpoint => $routes) {
386
+				foreach ($routes as $route) {
387
+					if ($route['hidden_endpoint']) {
388
+						$full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/');
389
+						unset($route_data[$full_route]);
390 390
 					}
391 391
 				}
392 392
 			}
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 	 */
424 424
 	public static function latest_rest_api_version() {
425 425
 		$versions_served = \EED_Core_Rest_Api::versions_served();
426
-		return end( array_keys( $versions_served ) );
426
+		return end(array_keys($versions_served));
427 427
 	}
428 428
 
429 429
 	/**
@@ -437,32 +437,32 @@  discard block
 block discarded – undo
437 437
 	public static function versions_served() {
438 438
 		$versions_served = array();
439 439
 		$possibly_served_versions = EED_Core_Rest_Api::version_compatibilities();
440
-		$lowest_compatible_version = end( $possibly_served_versions);
441
-		reset( $possibly_served_versions );
442
-		$versions_served_historically = array_keys( $possibly_served_versions );
443
-		$latest_version = end( $versions_served_historically );
444
-		reset( $versions_served_historically );
440
+		$lowest_compatible_version = end($possibly_served_versions);
441
+		reset($possibly_served_versions);
442
+		$versions_served_historically = array_keys($possibly_served_versions);
443
+		$latest_version = end($versions_served_historically);
444
+		reset($versions_served_historically);
445 445
 		//for each version of core we have ever served:
446
-		foreach ( $versions_served_historically as $key_versioned_endpoint ) {
446
+		foreach ($versions_served_historically as $key_versioned_endpoint) {
447 447
 			//if it's not above the current core version, and it's compatible with the current version of core
448
-			if( $key_versioned_endpoint == $latest_version ) {
448
+			if ($key_versioned_endpoint == $latest_version) {
449 449
 				//don't hide the latest version in the index
450
-				$versions_served[ $key_versioned_endpoint ] = false;
451
-			} else if(
450
+				$versions_served[$key_versioned_endpoint] = false;
451
+			} else if (
452 452
 				$key_versioned_endpoint < EED_Core_Rest_Api::core_version()
453 453
 				&& $key_versioned_endpoint >= $lowest_compatible_version
454 454
 			) {
455 455
 				//include, but hide, previous versions which are still supported
456
-				$versions_served[ $key_versioned_endpoint ] = true;
457
-			} elseif(
456
+				$versions_served[$key_versioned_endpoint] = true;
457
+			} elseif (
458 458
 				apply_filters(
459 459
 					'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions',
460 460
 					false,
461 461
 					$possibly_served_versions
462 462
 				)
463
-			){
463
+			) {
464 464
 				//if a version is no longer supported, don't include it in index or list of versions served
465
-				$versions_served[ $key_versioned_endpoint ] = true;
465
+				$versions_served[$key_versioned_endpoint] = true;
466 466
 			}
467 467
 		}
468 468
 		return $versions_served;
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 	 * @return string
476 476
 	 */
477 477
 	public static function core_version() {
478
-		return apply_filters( 'FHEE__EED_Core_REST_API__core_version', implode('.', array_slice( explode( '.', espresso_version() ), 0, 3 ) ) );
478
+		return apply_filters('FHEE__EED_Core_REST_API__core_version', implode('.', array_slice(explode('.', espresso_version()), 0, 3)));
479 479
 	}
480 480
 
481 481
 
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 	 * @param  WP $WP
488 488
 	 * @return    void
489 489
 	 */
490
-	public function run( $WP ) {
490
+	public function run($WP) {
491 491
 
492 492
 	}
493 493
 
Please login to merge, or discard this patch.
modules/purchasing_agent/EE_Purchasing_Agent.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
 	 *
47 47
 	 * @param EE_Form_Section_Proper $attendee_info_reg_form
48 48
 	 * @param EE_Checkout            $checkout
49
-	 * @return string content
49
+	 * @return EE_Form_Section_Proper content
50 50
 	 */
51 51
 	public function generate_purchasing_agent_form( EE_Form_Section_Proper $attendee_info_reg_form, EE_Checkout $checkout  ) {
52 52
 		static $sync_info_displayed = false;
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -3,16 +3,16 @@
 block discarded – undo
3 3
 	exit( 'No direct script access allowed' );
4 4
 }
5 5
 /**
6
- * Class EE_Purchasing_Agent
7
- *
8
- * Description
9
- *
10
- * @package               Event Espresso
11
- * @subpackage            core
12
- * @author                Brent Christensen
13
- * @since                 $VID:$
14
- *
15
- */
6
+	 * Class EE_Purchasing_Agent
7
+	 *
8
+	 * Description
9
+	 *
10
+	 * @package               Event Espresso
11
+	 * @subpackage            core
12
+	 * @author                Brent Christensen
13
+	 * @since                 $VID:$
14
+	 *
15
+	 */
16 16
 class EE_Purchasing_Agent {
17 17
 
18 18
 
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 /**
6 6
  * Class EE_Purchasing_Agent
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 * EE_Purchasing_Agent constructor.
31 31
 	 * @param \EE_Attendee $attendee
32 32
 	 */
33
-	public function __construct( EE_Attendee $attendee = null ) {
33
+	public function __construct(EE_Attendee $attendee = null) {
34 34
 		$this->_purchasing_agent = $attendee;
35 35
 	}
36 36
 
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 	 * @param EE_Checkout            $checkout
49 49
 	 * @return string content
50 50
 	 */
51
-	public function generate_purchasing_agent_form( EE_Form_Section_Proper $attendee_info_reg_form, EE_Checkout $checkout  ) {
51
+	public function generate_purchasing_agent_form(EE_Form_Section_Proper $attendee_info_reg_form, EE_Checkout $checkout) {
52 52
 		static $sync_info_displayed = false;
53
-		if ( $sync_info_displayed || $checkout->revisit || $checkout->admin_request ) {
53
+		if ($sync_info_displayed || $checkout->revisit || $checkout->admin_request) {
54 54
 			return $attendee_info_reg_form;
55 55
 		}
56 56
 		$sync_info_displayed = true;
57
-		EE_Registry::instance()->load_helper( 'HTML' );
57
+		EE_Registry::instance()->load_helper('HTML');
58 58
 		$attendee_info_reg_form->add_subsections(
59 59
 			array(
60 60
 				'purchasing_agent' => new EE_Form_Section_Proper(
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 						'layout_strategy' => new EE_Div_Per_Section_Layout(),
65 65
 						'subsections'     => array(
66 66
 							'purchasing_agent_h4'       => new EE_Form_Section_HTML(
67
-								EEH_HTML::h4( __( 'Purchasing Details.', 'event_espresso' ), '', 'ee-reg-form-qstn-grp-title section-title' )
67
+								EEH_HTML::h4(__('Purchasing Details.', 'event_espresso'), '', 'ee-reg-form-qstn-grp-title section-title')
68 68
 							),
69 69
 							'select_input'              => $this->_purchasing_agent_input(),
70 70
 							'attendee_sync_info_notice' => $this->_attendee_sync_info_notice(),
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 	protected function _purchasing_agent_input() {
89 89
 		return new EE_Select_Input(
90 90
 			array(
91
-				'attendee' => __( 'Myself and maybe others: All information entered in the Attendee 1 box below will be mine.', 'event_espresso' ),
92
-				'separate' => __( 'People other than myself: All information entered in the Attendee boxes below is for others.', 'event_espresso' ),
91
+				'attendee' => __('Myself and maybe others: All information entered in the Attendee 1 box below will be mine.', 'event_espresso'),
92
+				'separate' => __('People other than myself: All information entered in the Attendee boxes below is for others.', 'event_espresso'),
93 93
 			),
94 94
 			array(
95 95
 				'html_name'        => 'ee_reg_qstn[purchasing_agent]',
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 				'required'         => true,
99 99
 				'html_label_id'    => 'ee_reg_qstn-purchasing_agent-lbl',
100 100
 				'html_label_class' => 'ee-reg-qstn',
101
-				'html_label_text'  => __( 'I am purchasing tickets for...', 'event_espresso' ),
101
+				'html_label_text'  => __('I am purchasing tickets for...', 'event_espresso'),
102 102
 				'default'          => 'attendee'
103 103
 			)
104 104
 		);
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 		return new EE_Form_Section_HTML(
118 118
 			EEH_HTML::div(
119 119
 				sprintf(
120
-					__( '%1$sNote%2$s: If purchasing tickets for yourself, then any changes made to the %1$sPersonal Information%2$s details for Attendee 1 will be synced with your user profile for this site.', 'event_espresso' ),
120
+					__('%1$sNote%2$s: If purchasing tickets for yourself, then any changes made to the %1$sPersonal Information%2$s details for Attendee 1 will be synced with your user profile for this site.', 'event_espresso'),
121 121
 					'<strong>', '</strong>'
122 122
 				),
123 123
 				'ee-attendee-sync-info-notice-dv',
@@ -136,17 +136,17 @@  discard block
 block discarded – undo
136 136
 	 */
137 137
 	public function _purchasing_agent_billing_form() {
138 138
 		$billing_form = new EE_Billing_Attendee_Info_Form();
139
-		if ( $this->_purchasing_agent instanceof EE_Attendee ) {
140
-			$billing_form->populate_from_attendee( $this->_purchasing_agent );
139
+		if ($this->_purchasing_agent instanceof EE_Attendee) {
140
+			$billing_form->populate_from_attendee($this->_purchasing_agent);
141 141
 		}
142 142
 		return new EE_Form_Section_Proper(
143 143
 			array(
144 144
 				'layout_strategy' => new EE_Div_Per_Section_Layout(),
145 145
 				'subsections'     => array(
146 146
 					'frame_open'   => new EE_Form_Section_HTML(
147
-						EEH_HTML::div( '', '', 'ee-reg-form-qstn-grp-dv' )
147
+						EEH_HTML::div('', '', 'ee-reg-form-qstn-grp-dv')
148 148
 						. EEH_HTML::p(
149
-							__( 'Please provide and/or confirm the following required information if you are purchasing tickets for others. This information will be synced with your user profile for this site', 'event_espresso' ),
149
+							__('Please provide and/or confirm the following required information if you are purchasing tickets for others. This information will be synced with your user profile for this site', 'event_espresso'),
150 150
 							'',
151 151
 							'highlight-bg important-notice'
152 152
 						)
@@ -167,13 +167,13 @@  discard block
 block discarded – undo
167 167
 	 * @param array $defined_vars
168 168
 	 * @return string
169 169
 	 */
170
-	public function display_purchasing_agent_form( $defined_vars ) {
170
+	public function display_purchasing_agent_form($defined_vars) {
171 171
 		$html = '';
172
-		if ( isset( $defined_vars[ 'purchasing_agent' ] ) ) {
173
-			EE_Registry::instance()->load_helper( 'HTML' );
172
+		if (isset($defined_vars['purchasing_agent'])) {
173
+			EE_Registry::instance()->load_helper('HTML');
174 174
 			$html .= '<fieldset id="ee-purchaser" class="ee-reg-form-attendee-dv" >';
175
-			$html .= '<legend class="spco-attendee-lgnd smaller-text lt-grey-text">' . __( 'Purchasing Agent', 'event_espresso' ) . '</legend>';
176
-			$html .= $defined_vars[ 'purchasing_agent' ];
175
+			$html .= '<legend class="spco-attendee-lgnd smaller-text lt-grey-text">'.__('Purchasing Agent', 'event_espresso').'</legend>';
176
+			$html .= $defined_vars['purchasing_agent'];
177 177
 			$html .= '</fieldset>';
178 178
 		}
179 179
 		return $html;
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 * @param array        $valid_data
187 187
 	 * @param \EE_Checkout $checkout
188 188
 	 */
189
-	public function process_attendee_information( $valid_data, EE_Checkout $checkout ) {
189
+	public function process_attendee_information($valid_data, EE_Checkout $checkout) {
190 190
 		// to get info / do stuff, we may need/want to hook into other SPCO actions/filters like:
191 191
 		// FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input
192 192
 		// FHEE__EE_SPCO_Reg_Step_Attendee_Information___associate_attendee_with_registration__attendee  (new filter)
Please login to merge, or discard this patch.
modules/purchasing_agent/EED_Purchasing_Agent.module.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -168,7 +168,7 @@
 block discarded – undo
168 168
 	 *
169 169
 	 * @param EE_Form_Section_Proper $attendee_info_reg_form
170 170
 	 * @param EE_Checkout            $checkout
171
-	 * @return string                                content
171
+	 * @return EE_Form_Section_Proper                                content
172 172
 	 */
173 173
 	public static function generate_purchasing_agent_form(
174 174
 		EE_Form_Section_Proper $attendee_info_reg_form,
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
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
 
@@ -35,17 +35,17 @@  discard block
 block discarded – undo
35 35
 		//hook into spco for styles and scripts.
36 36
 		add_action(
37 37
 			'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information',
38
-			array( 'EED_Purchasing_Agent', 'enqueue_scripts_styles' )
38
+			array('EED_Purchasing_Agent', 'enqueue_scripts_styles')
39 39
 		);
40 40
 		add_filter(
41 41
 			'FHEE__EE_SPCO_Reg_Step_Attendee_Information__generate_reg_form__reg_form',
42
-			array( 'EED_Purchasing_Agent', 'generate_purchasing_agent_form' ),
42
+			array('EED_Purchasing_Agent', 'generate_purchasing_agent_form'),
43 43
 			10,
44 44
 			2
45 45
 		);
46 46
 		add_action(
47 47
 			'FHEE__registration_page_attendee_information__before_attendee_panels',
48
-			array( 'EED_Purchasing_Agent', 'display_purchasing_agent_form' ),
48
+			array('EED_Purchasing_Agent', 'display_purchasing_agent_form'),
49 49
 			10,
50 50
 			1
51 51
 		);
@@ -58,22 +58,22 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public static function set_hooks_admin() {
60 60
 		EED_Purchasing_Agent::set_definitions();
61
-		if ( EE_FRONT_AJAX ) {
61
+		if (EE_FRONT_AJAX) {
62 62
 			add_filter(
63 63
 				'FHEE__EE_SPCO_Reg_Step_Attendee_Information__generate_reg_form__reg_form',
64
-				array( 'EED_Purchasing_Agent', 'generate_purchasing_agent_form' ),
64
+				array('EED_Purchasing_Agent', 'generate_purchasing_agent_form'),
65 65
 				10,
66 66
 				2
67 67
 			);
68 68
 			add_action(
69 69
 				'FHEE__registration_page_attendee_information__before_attendee_panels',
70
-				array( 'EED_Purchasing_Agent', 'display_purchasing_agent_form' ),
70
+				array('EED_Purchasing_Agent', 'display_purchasing_agent_form'),
71 71
 				10,
72 72
 				1
73 73
 			);
74 74
 			add_filter(
75 75
 				'FHEE__Single_Page_Checkout___check_form_submission__request_params',
76
-				array( 'EED_Purchasing_Agent', 'process_attendee_information' ),
76
+				array('EED_Purchasing_Agent', 'process_attendee_information'),
77 77
 				1,
78 78
 				2
79 79
 			);
@@ -86,15 +86,15 @@  discard block
 block discarded – undo
86 86
 	 * set_definitions
87 87
 	 */
88 88
 	public static function set_definitions() {
89
-		define( 'EE_PURCHASING_AGENT_PATH', plugin_dir_path( __FILE__ ) );
90
-		define( 'EE_PURCHASING_AGENT_URL', plugin_dir_url( __FILE__ ) );
89
+		define('EE_PURCHASING_AGENT_PATH', plugin_dir_path(__FILE__));
90
+		define('EE_PURCHASING_AGENT_URL', plugin_dir_url(__FILE__));
91 91
 	}
92 92
 
93 93
 
94 94
 	/**
95 95
 	 * @param WP $WP
96 96
 	 */
97
-	public function run( $WP ) {
97
+	public function run($WP) {
98 98
 	}
99 99
 
100 100
 
@@ -107,20 +107,20 @@  discard block
 block discarded – undo
107 107
 		// add some style
108 108
 		wp_register_style(
109 109
 			'ee_purchasing_agent',
110
-			EE_PURCHASING_AGENT_URL . 'ee-purchasing-agent.css',
110
+			EE_PURCHASING_AGENT_URL.'ee-purchasing-agent.css',
111 111
 			array(),
112 112
 			EVENT_ESPRESSO_VERSION
113 113
 		);
114
-		wp_enqueue_style( 'ee_purchasing_agent' );
114
+		wp_enqueue_style('ee_purchasing_agent');
115 115
 		// and make it dance
116 116
 		wp_register_script(
117 117
 			'ee_purchasing_agent',
118
-			EE_PURCHASING_AGENT_URL . 'ee-purchasing-agent.js',
119
-			array( 'single_page_checkout' ),
118
+			EE_PURCHASING_AGENT_URL.'ee-purchasing-agent.js',
119
+			array('single_page_checkout'),
120 120
 			EVENT_ESPRESSO_VERSION,
121 121
 			true
122 122
 		);
123
-		wp_enqueue_script( 'ee_purchasing_agent' );
123
+		wp_enqueue_script('ee_purchasing_agent');
124 124
 	}
125 125
 
126 126
 
@@ -129,10 +129,10 @@  discard block
 block discarded – undo
129 129
 	 * @return EventEspresso\modules\purchasing_agent\PurchasingAgentForm
130 130
 	 */
131 131
 	protected static function _get_purchasing_agent() {
132
-		if ( ! EED_Purchasing_Agent::$_purchasing_agent instanceof EventEspresso\modules\purchasing_agent\PurchasingAgentForm ) {
133
-			require( EE_PURCHASING_AGENT_PATH . 'EE_Purchasing_Agent.class.php' );
134
-			$attendee = EED_Purchasing_Agent::get_attendee_for_user( get_current_user_id() );
135
-			EED_Purchasing_Agent::$_purchasing_agent = new EventEspresso\modules\purchasing_agent\PurchasingAgentForm( $attendee );
132
+		if ( ! EED_Purchasing_Agent::$_purchasing_agent instanceof EventEspresso\modules\purchasing_agent\PurchasingAgentForm) {
133
+			require(EE_PURCHASING_AGENT_PATH.'EE_Purchasing_Agent.class.php');
134
+			$attendee = EED_Purchasing_Agent::get_attendee_for_user(get_current_user_id());
135
+			EED_Purchasing_Agent::$_purchasing_agent = new EventEspresso\modules\purchasing_agent\PurchasingAgentForm($attendee);
136 136
 		}
137 137
 		return EED_Purchasing_Agent::$_purchasing_agent;
138 138
 	}
@@ -145,12 +145,12 @@  discard block
 block discarded – undo
145 145
 	 * @param $user_or_id int|\WP_User $mixed $user_or_id can be WP_User or the user_id.
146 146
 	 * @return \EE_Attendee
147 147
 	 */
148
-	public static function get_attendee_for_user( $user_or_id ) {
149
-		$user_id = $user_or_id instanceof WP_User ? $user_or_id->ID : (int)$user_or_id;
150
-		$attID = get_user_option( 'EE_Attendee_ID', $user_id );
148
+	public static function get_attendee_for_user($user_or_id) {
149
+		$user_id = $user_or_id instanceof WP_User ? $user_or_id->ID : (int) $user_or_id;
150
+		$attID = get_user_option('EE_Attendee_ID', $user_id);
151 151
 		$attendee = null;
152
-		if ( $attID ) {
153
-			$attendee = EEM_Attendee::instance()->get_one_by_ID( $attID );
152
+		if ($attID) {
153
+			$attendee = EEM_Attendee::instance()->get_one_by_ID($attID);
154 154
 			$attendee = $attendee instanceof EE_Attendee ? $attendee : null;
155 155
 		}
156 156
 		return $attendee;
@@ -187,11 +187,11 @@  discard block
 block discarded – undo
187 187
 	 *
188 188
 	 * @param array $defined_vars
189 189
 	 */
190
-	public static function display_purchasing_agent_form( $defined_vars ) {
191
-		if ( ! is_user_logged_in() ) {
190
+	public static function display_purchasing_agent_form($defined_vars) {
191
+		if ( ! is_user_logged_in()) {
192 192
 			// todo: prompt for login ?
193 193
 		}
194
-		echo EED_Purchasing_Agent::_get_purchasing_agent()->display_purchasing_agent_form( $defined_vars );
194
+		echo EED_Purchasing_Agent::_get_purchasing_agent()->display_purchasing_agent_form($defined_vars);
195 195
 	}
196 196
 
197 197
 
@@ -202,10 +202,10 @@  discard block
 block discarded – undo
202 202
 	 * @param array $valid_data
203 203
 	 * @param \EE_Checkout $checkout
204 204
 	 */
205
-	public static function process_attendee_information( $valid_data, EE_Checkout $checkout ) {
205
+	public static function process_attendee_information($valid_data, EE_Checkout $checkout) {
206 206
 		// collect any other required data from methods in this class,
207 207
 		// and pass along to EE_Purchasing_Agent::process_attendee_information() for processing
208
-		EED_Purchasing_Agent::_get_purchasing_agent()->process_attendee_information( $valid_data, $checkout );
208
+		EED_Purchasing_Agent::_get_purchasing_agent()->process_attendee_information($valid_data, $checkout);
209 209
 	}
210 210
 
211 211
 
Please login to merge, or discard this patch.
modules/purchasing_agent/PurchasingAgentForm.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @param \EE_Form_Section_Proper $attendee_info_reg_form
56 56
 	 * @param \EE_Checkout            $checkout
57
-	 * @return string content
57
+	 * @return \EE_Form_Section_Proper content
58 58
 	 */
59 59
 	public function generate_purchasing_agent_form(
60 60
 		\EE_Form_Section_Proper $attendee_info_reg_form,
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 *
101 101
 	 * displays a dropdown input for selecting the purchasing agent for the TXN
102 102
 	 *
103
-	 * @return \EE_Select_Input
103
+	 * @return \EE_Radio_Button_Input
104 104
 	 */
105 105
 	protected function _purchasing_agent_input() {
106 106
 		return new \EE_Radio_Button_Input(
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\modules\purchasing_agent;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @param \EE_Attendee $attendee
40 40
 	 */
41
-	public function __construct( \EE_Attendee $attendee = null ) {
41
+	public function __construct(\EE_Attendee $attendee = null) {
42 42
 		$this->_purchasing_agent = $attendee;
43 43
 	}
44 44
 
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
 		\EE_Checkout $checkout
62 62
 	) {
63 63
 		static $sync_info_displayed = false;
64
-		if ( $sync_info_displayed || $checkout->revisit || $checkout->admin_request ) {
64
+		if ($sync_info_displayed || $checkout->revisit || $checkout->admin_request) {
65 65
 			return $attendee_info_reg_form;
66 66
 		}
67 67
 		//\EEH_Debug_Tools::printr( $attendee_info_reg_form->name(), '$attendee_info_reg_form->name()', __FILE__, __LINE__ );
68 68
 		$sync_info_displayed = true;
69
-		\EE_Registry::instance()->load_helper( 'HTML' );
69
+		\EE_Registry::instance()->load_helper('HTML');
70 70
 		$attendee_info_reg_form->add_subsections(
71 71
 			array(
72 72
 				'purchasing_agent_form' => new \EE_Form_Section_Proper(
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 						'subsections'     => array(
78 78
 							'purchasing_agent_h4'       => new \EE_Form_Section_HTML(
79 79
 								\EEH_HTML::h4(
80
-									__( 'Purchasing Details.', 'event_espresso' ),
80
+									__('Purchasing Details.', 'event_espresso'),
81 81
 									'',
82 82
 									'ee-reg-form-qstn-grp-title section-title'
83 83
 								)
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 	protected function _purchasing_agent_input() {
106 106
 		return new \EE_Radio_Button_Input(
107 107
 			array(
108
-				'attendee' => __( 'Myself', 'event_espresso' ),
109
-				'separate' =>  __( 'Others', 'event_espresso' ),
108
+				'attendee' => __('Myself', 'event_espresso'),
109
+				'separate' =>  __('Others', 'event_espresso'),
110 110
 			),
111 111
 			array(
112 112
 				'html_name'        => 'ee_purchasing_agent',
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 				'required'         => false,
116 116
 				'html_label_id'    => 'ee_reg_qstn-purchasing_agent-lbl',
117 117
 				'html_label_class' => 'ee-reg-qstn',
118
-				'html_label_text'  =>  __( 'I am registering for...', 'event_espresso' ),
118
+				'html_label_text'  =>  __('I am registering for...', 'event_espresso'),
119 119
 				'default'          => 'attendee',
120 120
 				'label_position'   => \EE_Form_Input_With_Options_Base::label_after_input
121 121
 			)
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 				),
142 142
 				'ee-additional-attendee-info-notice-dv',
143 143
 				'ee-additional-info'
144
-			) .
144
+			).
145 145
 			\EEH_HTML::div(
146 146
 				__(
147 147
 					'If you are NOT registering for yourself and will not be attending, then ALL information entered in the Attendee boxes further below is for others. But we still require some billing related information from you first.',
@@ -165,15 +165,15 @@  discard block
 block discarded – undo
165 165
 	 */
166 166
 	public function _purchasing_agent_billing_form() {
167 167
 		$billing_form = new \EE_Billing_Attendee_Info_Form();
168
-		if ( $this->_purchasing_agent instanceof \EE_Attendee ) {
169
-			$billing_form->populate_from_attendee( $this->_purchasing_agent );
168
+		if ($this->_purchasing_agent instanceof \EE_Attendee) {
169
+			$billing_form->populate_from_attendee($this->_purchasing_agent);
170 170
 		}
171 171
 		return new \EE_Form_Section_Proper(
172 172
 			array(
173 173
 				'layout_strategy' => new \EE_Div_Per_Section_Layout(),
174 174
 				'subsections'     => array(
175 175
 					'frame_open'   => new \EE_Form_Section_HTML(
176
-						\EEH_HTML::div( '', '', 'ee-reg-form-qstn-grp-dv' )
176
+						\EEH_HTML::div('', '', 'ee-reg-form-qstn-grp-dv')
177 177
 						. \EEH_HTML::p(
178 178
 							__(
179 179
 								'Please provide the following required information if you are purchasing tickets for others.',
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
 	 * @param array $defined_vars
201 201
 	 * @return string
202 202
 	 */
203
-	public function display_purchasing_agent_form( $defined_vars ) {
203
+	public function display_purchasing_agent_form($defined_vars) {
204 204
 		$html = '';
205
-		if ( isset( $defined_vars[ 'purchasing_agent_form' ] ) ) {
206
-			\EE_Registry::instance()->load_helper( 'HTML' );
205
+		if (isset($defined_vars['purchasing_agent_form'])) {
206
+			\EE_Registry::instance()->load_helper('HTML');
207 207
 			$html .= '<fieldset id="ee-purchaser" class="ee-reg-form-attendee-dv" >';
208 208
 			$html .= '<legend class="spco-attendee-lgnd smaller-text lt-grey-text">';
209
-			$html .= __( 'Purchasing Agent', 'event_espresso' ) . '</legend>';
210
-			$html .= $defined_vars[ 'purchasing_agent_form' ];
209
+			$html .= __('Purchasing Agent', 'event_espresso').'</legend>';
210
+			$html .= $defined_vars['purchasing_agent_form'];
211 211
 			$html .= '</fieldset>';
212 212
 		}
213 213
 		return $html;
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	 * @param array        $valid_data
222 222
 	 * @param \EE_Checkout $checkout
223 223
 	 */
224
-	public function process_attendee_information( $valid_data, \EE_Checkout $checkout ) {
224
+	public function process_attendee_information($valid_data, \EE_Checkout $checkout) {
225 225
 		//\EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__ );
226 226
 		// to get info / do stuff, we may need/want to hook into other SPCO actions/filters like:
227 227
 		// FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input
@@ -233,16 +233,16 @@  discard block
 block discarded – undo
233 233
 		/** @var \EE_Form_Section_Proper $purchasing_agent_form */
234 234
 		//$purchasing_agent_form = $checkout->current_step->reg_form->get_subsection( 'purchasing_agent_form' );
235 235
 		/** @var \EE_Radio_Button_Input $purchasing_agent_input */
236
-		$purchasing_agent_input = $checkout->current_step->reg_form->find_subsection( 'purchasing_agent_input' );
236
+		$purchasing_agent_input = $checkout->current_step->reg_form->find_subsection('purchasing_agent_input');
237 237
 		//\EEH_Debug_Tools::printr( $purchasing_agent_input, '$purchasing_agent_input', __FILE__, __LINE__ );
238 238
 		$agent = $purchasing_agent_input instanceof \EE_Form_Input_Base
239 239
 			? $purchasing_agent_input->raw_value()
240 240
 			: '';
241 241
 		//\EEH_Debug_Tools::printr( $agent, '$agent', __FILE__, __LINE__ );
242
-		if ( $agent == 'attendee' ) {
243
-			$billing_form = $checkout->current_step->reg_form->find_subsection( 'billing_form' );
244
-			if ( $billing_form instanceof \EE_Form_Section_Proper ) {
245
-				$billing_form->parent_section()->exclude( array( 'billing_form' ) );
242
+		if ($agent == 'attendee') {
243
+			$billing_form = $checkout->current_step->reg_form->find_subsection('billing_form');
244
+			if ($billing_form instanceof \EE_Form_Section_Proper) {
245
+				$billing_form->parent_section()->exclude(array('billing_form'));
246 246
 				//\EEH_Debug_Tools::printr( $billing_form, '$billing_form', __FILE__, __LINE__ );
247 247
 			}
248 248
 		}
Please login to merge, or discard this patch.