Completed
Branch models-cleanup/main (de94a1)
by
unknown
86:45 queued 77:08
created
core/libraries/messages/EE_Message_Template_Group_Collection.lib.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
     /**
48 48
      * This retrieves any EE_Message_Template_Group in the repo by its ID.
49 49
      *
50
-     * @param $GRP_ID
50
+     * @param integer $GRP_ID
51 51
      * @return EE_Message_Template_Group | null
52 52
      */
53 53
     public function get_by_ID($GRP_ID)
Please login to merge, or discard this patch.
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -14,115 +14,115 @@
 block discarded – undo
14 14
 {
15 15
 
16 16
 
17
-    /**
18
-     * EE_Message_Template_Group_Collection constructor.
19
-     */
20
-    public function __construct()
21
-    {
22
-        $this->interface = 'EE_Message_Template_Group';
23
-    }
17
+	/**
18
+	 * EE_Message_Template_Group_Collection constructor.
19
+	 */
20
+	public function __construct()
21
+	{
22
+		$this->interface = 'EE_Message_Template_Group';
23
+	}
24 24
 
25 25
 
26
-    /**
27
-     * Adds the Message Template Group object to the repository.
28
-     *
29
-     * @param           $message_template_group
30
-     * @param array|int $EVT_ID    Some templates are specific to EVT, so this is provided as a way of
31
-     *                         indexing the template by key.  If this template is shared among multiple events then
32
-     *                         include the events as an array.
33
-     * @return bool
34
-     */
35
-    public function add($message_template_group, $EVT_ID = array())
36
-    {
37
-        $EVT_ID = is_array($EVT_ID) ? $EVT_ID : (array) $EVT_ID;
38
-        if ($message_template_group instanceof $this->interface) {
39
-            $data['key'] = $this->getKey(
40
-                $message_template_group->messenger(),
41
-                $message_template_group->message_type(),
42
-                $EVT_ID
43
-            );
44
-            return parent::add($message_template_group, $data);
45
-        }
46
-        return false;
47
-    }
26
+	/**
27
+	 * Adds the Message Template Group object to the repository.
28
+	 *
29
+	 * @param           $message_template_group
30
+	 * @param array|int $EVT_ID    Some templates are specific to EVT, so this is provided as a way of
31
+	 *                         indexing the template by key.  If this template is shared among multiple events then
32
+	 *                         include the events as an array.
33
+	 * @return bool
34
+	 */
35
+	public function add($message_template_group, $EVT_ID = array())
36
+	{
37
+		$EVT_ID = is_array($EVT_ID) ? $EVT_ID : (array) $EVT_ID;
38
+		if ($message_template_group instanceof $this->interface) {
39
+			$data['key'] = $this->getKey(
40
+				$message_template_group->messenger(),
41
+				$message_template_group->message_type(),
42
+				$EVT_ID
43
+			);
44
+			return parent::add($message_template_group, $data);
45
+		}
46
+		return false;
47
+	}
48 48
 
49 49
 
50
-    /**
51
-     * This retrieves any EE_Message_Template_Group in the repo by its ID.
52
-     *
53
-     * @param $GRP_ID
54
-     * @return EE_Message_Template_Group | null
55
-     */
56
-    public function get_by_ID($GRP_ID)
57
-    {
58
-        $this->rewind();
59
-        while ($this->valid()) {
60
-            if ($this->current()->ID() === $GRP_ID) {
61
-                /** @var EE_Message_Template_Group $message_template_group */
62
-                $message_template_group = $this->current();
63
-                $this->rewind();
64
-                return $message_template_group;
65
-            }
66
-            $this->next();
67
-        }
68
-        return null;
69
-    }
50
+	/**
51
+	 * This retrieves any EE_Message_Template_Group in the repo by its ID.
52
+	 *
53
+	 * @param $GRP_ID
54
+	 * @return EE_Message_Template_Group | null
55
+	 */
56
+	public function get_by_ID($GRP_ID)
57
+	{
58
+		$this->rewind();
59
+		while ($this->valid()) {
60
+			if ($this->current()->ID() === $GRP_ID) {
61
+				/** @var EE_Message_Template_Group $message_template_group */
62
+				$message_template_group = $this->current();
63
+				$this->rewind();
64
+				return $message_template_group;
65
+			}
66
+			$this->next();
67
+		}
68
+		return null;
69
+	}
70 70
 
71 71
 
72
-    /**
73
-     * Generates a hash used to identify a given Message Template Group.
74
-     *
75
-     * @param string $messenger    The EE_messenger->name
76
-     * @param string $message_type The EE_message_type->name
77
-     * @param int    $EVT_ID       Optional.  If the template is for a specific EVT then that should be included.
78
-     * @deprecated 4.9.40.rc.017  Use getKey instead.
79
-     * @return string
80
-     */
81
-    public function get_key($messenger, $message_type, $EVT_ID = 0)
82
-    {
83
-        $EVT_ID = (array) $EVT_ID;
84
-        return $this->getKey($messenger, $message_type, $EVT_ID);
85
-    }
72
+	/**
73
+	 * Generates a hash used to identify a given Message Template Group.
74
+	 *
75
+	 * @param string $messenger    The EE_messenger->name
76
+	 * @param string $message_type The EE_message_type->name
77
+	 * @param int    $EVT_ID       Optional.  If the template is for a specific EVT then that should be included.
78
+	 * @deprecated 4.9.40.rc.017  Use getKey instead.
79
+	 * @return string
80
+	 */
81
+	public function get_key($messenger, $message_type, $EVT_ID = 0)
82
+	{
83
+		$EVT_ID = (array) $EVT_ID;
84
+		return $this->getKey($messenger, $message_type, $EVT_ID);
85
+	}
86 86
 
87 87
 
88
-    /**
89
-     * Generates a hash used to identify a given Message Template Group
90
-     * @param string    $messenger      The EE_messenger->name
91
-     * @param string    $message_type   The EE_message_type->name
92
-     * @param array     $EVT_ID         Optional.  If the template is for a specific EVT_ID (or events) then that should
93
-     *                                  be included.
94
-     * @since 4.9.40.rc.017
95
-     * @return string
96
-     */
97
-    public function getKey($messenger, $message_type, array $EVT_ID = array())
98
-    {
99
-        sort($EVT_ID);
100
-        $EVT_ID = implode(',', array_unique($EVT_ID));
101
-        return md5($messenger . $message_type . $EVT_ID);
102
-    }
88
+	/**
89
+	 * Generates a hash used to identify a given Message Template Group
90
+	 * @param string    $messenger      The EE_messenger->name
91
+	 * @param string    $message_type   The EE_message_type->name
92
+	 * @param array     $EVT_ID         Optional.  If the template is for a specific EVT_ID (or events) then that should
93
+	 *                                  be included.
94
+	 * @since 4.9.40.rc.017
95
+	 * @return string
96
+	 */
97
+	public function getKey($messenger, $message_type, array $EVT_ID = array())
98
+	{
99
+		sort($EVT_ID);
100
+		$EVT_ID = implode(',', array_unique($EVT_ID));
101
+		return md5($messenger . $message_type . $EVT_ID);
102
+	}
103 103
 
104 104
 
105
-    /**
106
-     * This returns a saved EE_Message_Template_Group object if there is one in the repository indexed by a key matching
107
-     * the given string.
108
-     *
109
-     * @param string $key @see EE_Message_Template_Group::get_key() to setup a key formatted for searching.
110
-     * @return null|EE_Message_Template_Group
111
-     */
112
-    public function get_by_key($key)
113
-    {
114
-        $this->rewind();
115
-        while ($this->valid()) {
116
-            $data = $this->getInfo();
117
-            if (isset($data['key']) && $data['key'] === $key) {
118
-                /** @var EE_Message_Template_Group $message_template_group */
119
-                $message_template_group = $this->current();
120
-                $this->rewind();
121
-                return $message_template_group;
122
-            }
123
-            $this->next();
124
-        }
125
-        return null;
126
-    }
105
+	/**
106
+	 * This returns a saved EE_Message_Template_Group object if there is one in the repository indexed by a key matching
107
+	 * the given string.
108
+	 *
109
+	 * @param string $key @see EE_Message_Template_Group::get_key() to setup a key formatted for searching.
110
+	 * @return null|EE_Message_Template_Group
111
+	 */
112
+	public function get_by_key($key)
113
+	{
114
+		$this->rewind();
115
+		while ($this->valid()) {
116
+			$data = $this->getInfo();
117
+			if (isset($data['key']) && $data['key'] === $key) {
118
+				/** @var EE_Message_Template_Group $message_template_group */
119
+				$message_template_group = $this->current();
120
+				$this->rewind();
121
+				return $message_template_group;
122
+			}
123
+			$this->next();
124
+		}
125
+		return null;
126
+	}
127 127
 
128 128
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@
 block discarded – undo
98 98
     {
99 99
         sort($EVT_ID);
100 100
         $EVT_ID = implode(',', array_unique($EVT_ID));
101
-        return md5($messenger . $message_type . $EVT_ID);
101
+        return md5($messenger.$message_type.$EVT_ID);
102 102
     }
103 103
 
104 104
 
Please login to merge, or discard this patch.
public/template_tags.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
  * can_use_espresso_conditionals
131 131
  * tests whether the Espresso Conditional tags like is_espresso_event_single() can be called
132 132
  *
133
- * @param $conditional_tag
133
+ * @param string $conditional_tag
134 134
  * @return bool
135 135
  */
136 136
 function can_use_espresso_conditionals( $conditional_tag ) {
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 if ( ! function_exists( 'espresso_ticket_selector' )) {
202 202
 	/**
203 203
 	 * espresso_ticket_selector
204
-	 * @param null $event
204
+	 * @param EE_Event $event
205 205
 	 */
206 206
 	function espresso_ticket_selector( $event = NULL ) {
207 207
 		if (  ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) {
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
 	/**
843 843
 	 * espresso_event_venues
844 844
 	 *
845
-	 * @return array  all venues related to an event
845
+	 * @return EE_Venue[]  all venues related to an event
846 846
 	 */
847 847
 	function espresso_event_venues() {
848 848
 		return EEH_Venue_View::get_event_venues();
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
 	 *
876 876
 	 * @param int     $VNU_ID optional, the venue id to check.
877 877
 	 *
878
-	 * @return bool | null
878
+	 * @return null|boolean | null
879 879
 	 */
880 880
 	function espresso_is_venue_private( $VNU_ID = 0 ) {
881 881
 		return EEH_Venue_View::is_venue_private( $VNU_ID );
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
 	 * returns true or false if a venue is password protected or not
890 890
 	 *
891 891
 	 * @param int     $VNU_ID optional, the venue id to check.
892
-	 * @return string
892
+	 * @return boolean
893 893
 	 */
894 894
 	function espresso_venue_is_password_protected( $VNU_ID = 0 ) {
895 895
 		EE_Registry::instance()->load_helper( 'Venue_View' );
Please login to merge, or discard this patch.
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	function espresso_ticket_selector( $event = NULL ) {
207 207
 		if (  ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) {
208 208
 			espresso_load_ticket_selector();
209
-            \EED_Ticket_Selector::set_definitions();
209
+			\EED_Ticket_Selector::set_definitions();
210 210
 			echo EED_Ticket_Selector::display_ticket_selector( $event );
211 211
 		}
212 212
 	}
@@ -460,12 +460,12 @@  discard block
 block discarded – undo
460 460
 	 * @return string
461 461
 	 */
462 462
 	function espresso_list_of_event_dates( $EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL ) {
463
-	    $arguments = apply_filters(
464
-            'FHEE__espresso_list_of_event_dates__arguments',
465
-            [ $EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit ]
466
-        );
467
-        list($EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit) = $arguments;
468
-	    $datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit );
463
+		$arguments = apply_filters(
464
+			'FHEE__espresso_list_of_event_dates__arguments',
465
+			[ $EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit ]
466
+		);
467
+		list($EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit) = $arguments;
468
+		$datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit );
469 469
 		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
470 470
 		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
471 471
 		$date_format = apply_filters( 'FHEE__espresso_list_of_event_dates__date_format', $date_format );
@@ -478,42 +478,42 @@  discard block
 block discarded – undo
478 478
 			$html = '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul ee-clearfix">';
479 479
 			foreach ( $datetimes as $datetime ) {
480 480
 				if ( $datetime instanceof EE_Datetime ) {
481
-                    $datetime_name = $datetime->name();
482
-                    $datetime_description = $datetime->description();
483
-                    $html .= '<li id="ee-event-datetimes-li-' . $datetime->ID();
484
-                    $html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-' . $datetime->get_active_status() . '">';
485
-                    $inner_html = '';
486
-                    if (! empty( $datetime_name )) {
487
-                        $inner_html .= '<strong>' . $datetime_name . '</strong>';
488
-                        $inner_html .= $add_breaks ? '<br />' : '';
489
-                    }
490
-                    // add date
491
-                    $inner_html .= '<span class="dashicons dashicons-calendar"></span>';
492
-                    $inner_html .= '</span><span class="ee-event-datetimes-li-daterange">';
493
-                    $inner_html .= $datetime->date_range( $date_format ) . '</span><br/>';
494
-                    // add time
495
-                    $inner_html .= '<span class="dashicons dashicons-clock"></span>';
496
-                    $inner_html .= '<span class="ee-event-datetimes-li-timerange">';
497
-                    $inner_html .= $datetime->time_range( $time_format ) . '</span>';
498
-                    if (! empty( $datetime_description )) {
499
-                        $inner_html .= $add_breaks ? '<br />' : '';
500
-                        $inner_html .= ' - ' . $datetime_description;
501
-                    }
502
-                    $inner_html = apply_filters(
503
-                        'FHEE__espresso_list_of_event_dates__datetime_html',
504
-                        $inner_html,
505
-                        $datetime,
506
-                        $arguments
507
-                    );
508
-                    $html .= $inner_html . '</li>';
481
+					$datetime_name = $datetime->name();
482
+					$datetime_description = $datetime->description();
483
+					$html .= '<li id="ee-event-datetimes-li-' . $datetime->ID();
484
+					$html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-' . $datetime->get_active_status() . '">';
485
+					$inner_html = '';
486
+					if (! empty( $datetime_name )) {
487
+						$inner_html .= '<strong>' . $datetime_name . '</strong>';
488
+						$inner_html .= $add_breaks ? '<br />' : '';
489
+					}
490
+					// add date
491
+					$inner_html .= '<span class="dashicons dashicons-calendar"></span>';
492
+					$inner_html .= '</span><span class="ee-event-datetimes-li-daterange">';
493
+					$inner_html .= $datetime->date_range( $date_format ) . '</span><br/>';
494
+					// add time
495
+					$inner_html .= '<span class="dashicons dashicons-clock"></span>';
496
+					$inner_html .= '<span class="ee-event-datetimes-li-timerange">';
497
+					$inner_html .= $datetime->time_range( $time_format ) . '</span>';
498
+					if (! empty( $datetime_description )) {
499
+						$inner_html .= $add_breaks ? '<br />' : '';
500
+						$inner_html .= ' - ' . $datetime_description;
501
+					}
502
+					$inner_html = apply_filters(
503
+						'FHEE__espresso_list_of_event_dates__datetime_html',
504
+						$inner_html,
505
+						$datetime,
506
+						$arguments
507
+					);
508
+					$html .= $inner_html . '</li>';
509 509
 				}
510 510
 			}
511 511
 			$html .= '</ul>';
512
-            $html = apply_filters('FHEE__espresso_list_of_event_dates__html', $html, $arguments, $datetime);
512
+			$html = apply_filters('FHEE__espresso_list_of_event_dates__html', $html, $arguments, $datetime);
513 513
 		} else {
514
-            $html = '<p><span class="dashicons dashicons-marker pink-text"></span>';
515
-            $html .= esc_html__( 'There are no upcoming dates for this event.', 'event_espresso' );
516
-            $html .= '</p><br/>';
514
+			$html = '<p><span class="dashicons dashicons-marker pink-text"></span>';
515
+			$html .= esc_html__( 'There are no upcoming dates for this event.', 'event_espresso' );
516
+			$html .= '</p><br/>';
517 517
 		}
518 518
 		if ( $echo ) {
519 519
 			echo $html;
Please login to merge, or discard this patch.
Spacing   +292 added lines, -292 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
  * @param int | \EE_Event $event
15 15
  * @return bool
16 16
  */
17
-function is_espresso_event( $event = NULL ) {
18
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
17
+function is_espresso_event($event = NULL) {
18
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
19 19
 		// extract EE_Event object from passed param regardless of what it is (within reason of course)
20
-		$event = EEH_Event_View::get_event( $event );
20
+		$event = EEH_Event_View::get_event($event);
21 21
 		// do we have a valid event ?
22
-		return $event instanceof EE_Event  ? TRUE : FALSE;
22
+		return $event instanceof EE_Event ? TRUE : FALSE;
23 23
 	}
24 24
 	return FALSE;
25 25
 }
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  * @return bool
32 32
  */
33 33
 function is_espresso_event_single() {
34
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
34
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
35 35
 		global $wp_query;
36 36
 		// return conditionals set by CPTs
37 37
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_single : FALSE;
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
  * @return bool
47 47
  */
48 48
 function is_espresso_event_archive() {
49
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
49
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
50 50
 		global $wp_query;
51 51
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_archive : FALSE;
52 52
 	}
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
  * @return bool
61 61
  */
62 62
 function is_espresso_event_taxonomy() {
63
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
63
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
64 64
 		global $wp_query;
65 65
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_taxonomy : FALSE;
66 66
 	}
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
  * @param int | \EE_Venue $venue
75 75
  * @return bool
76 76
  */
77
-function is_espresso_venue( $venue = NULL ) {
78
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
77
+function is_espresso_venue($venue = NULL) {
78
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
79 79
 		// extract EE_Venue object from passed param regardless of what it is (within reason of course)
80
-		$venue = EEH_Venue_View::get_venue( $venue, FALSE );
80
+		$venue = EEH_Venue_View::get_venue($venue, FALSE);
81 81
 		// do we have a valid event ?
82 82
 		return $venue instanceof EE_Venue ? TRUE : FALSE;
83 83
 	}
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
  * @return bool
92 92
  */
93 93
 function is_espresso_venue_single() {
94
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
94
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
95 95
 		global $wp_query;
96 96
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_single : FALSE;
97 97
 	}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
  * @return bool
106 106
  */
107 107
 function is_espresso_venue_archive() {
108
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
108
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
109 109
 		global $wp_query;
110 110
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_archive : FALSE;
111 111
 	}
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
  * @return bool
120 120
  */
121 121
 function is_espresso_venue_taxonomy() {
122
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
122
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
123 123
 		global $wp_query;
124 124
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_taxonomy : FALSE;
125 125
 	}
@@ -133,12 +133,12 @@  discard block
 block discarded – undo
133 133
  * @param $conditional_tag
134 134
  * @return bool
135 135
  */
136
-function can_use_espresso_conditionals( $conditional_tag ) {
137
-	if ( ! did_action( 'AHEE__EE_System__initialize' )) {
136
+function can_use_espresso_conditionals($conditional_tag) {
137
+	if ( ! did_action('AHEE__EE_System__initialize')) {
138 138
 		EE_Error::doing_it_wrong(
139 139
 			__FUNCTION__,
140 140
 			sprintf(
141
-				esc_html__( 'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.','event_espresso'),
141
+				esc_html__('The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', 'event_espresso'),
142 142
 				$conditional_tag
143 143
 			),
144 144
 			'4.4.0'
@@ -153,13 +153,13 @@  discard block
 block discarded – undo
153 153
 
154 154
 /*************************** Event Queries ***************************/
155 155
 
156
-if ( ! function_exists( 'espresso_get_events' )) {
156
+if ( ! function_exists('espresso_get_events')) {
157 157
 	/**
158 158
 	 * 	espresso_get_events
159 159
 	 * @param array $params
160 160
 	 * @return array
161 161
 	 */
162
-	function espresso_get_events( $params = array() ) {
162
+	function espresso_get_events($params = array()) {
163 163
 		//set default params
164 164
 		$default_espresso_events_params = array(
165 165
 			'limit' => 10,
@@ -170,18 +170,18 @@  discard block
 block discarded – undo
170 170
 			'sort' => 'ASC'
171 171
 		);
172 172
 		// allow the defaults to be filtered
173
-		$default_espresso_events_params = apply_filters( 'espresso_get_events__default_espresso_events_params', $default_espresso_events_params );
173
+		$default_espresso_events_params = apply_filters('espresso_get_events__default_espresso_events_params', $default_espresso_events_params);
174 174
 		// grab params and merge with defaults, then extract
175
-		$params = array_merge( $default_espresso_events_params, $params );
175
+		$params = array_merge($default_espresso_events_params, $params);
176 176
 		// run the query
177
-		$events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery( $params );
177
+		$events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery($params);
178 178
 		// assign results to a variable so we can return it
179 179
 		$events = $events_query->have_posts() ? $events_query->posts : array();
180 180
 		// but first reset the query and postdata
181 181
 		wp_reset_query();
182 182
 		wp_reset_postdata();
183 183
 		EED_Events_Archive::remove_all_events_archive_filters();
184
-		unset( $events_query );
184
+		unset($events_query);
185 185
 		return $events;
186 186
 	}
187 187
 }
@@ -195,33 +195,33 @@  discard block
 block discarded – undo
195 195
  * espresso_load_ticket_selector
196 196
  */
197 197
 function espresso_load_ticket_selector() {
198
-	EE_Registry::instance()->load_file( EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module' );
198
+	EE_Registry::instance()->load_file(EE_MODULES.'ticket_selector', 'EED_Ticket_Selector', 'module');
199 199
 }
200 200
 
201
-if ( ! function_exists( 'espresso_ticket_selector' )) {
201
+if ( ! function_exists('espresso_ticket_selector')) {
202 202
 	/**
203 203
 	 * espresso_ticket_selector
204 204
 	 * @param null $event
205 205
 	 */
206
-	function espresso_ticket_selector( $event = NULL ) {
207
-		if (  ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) {
206
+	function espresso_ticket_selector($event = NULL) {
207
+		if ( ! apply_filters('FHEE_disable_espresso_ticket_selector', FALSE)) {
208 208
 			espresso_load_ticket_selector();
209 209
             \EED_Ticket_Selector::set_definitions();
210
-			echo EED_Ticket_Selector::display_ticket_selector( $event );
210
+			echo EED_Ticket_Selector::display_ticket_selector($event);
211 211
 		}
212 212
 	}
213 213
 }
214 214
 
215 215
 
216
-	if ( ! function_exists( 'espresso_view_details_btn' )) {
216
+	if ( ! function_exists('espresso_view_details_btn')) {
217 217
 	/**
218 218
 	 * espresso_view_details_btn
219 219
 	 * @param null $event
220 220
 	 */
221
-	function espresso_view_details_btn( $event = NULL ) {
222
-		if (  ! apply_filters( 'FHEE_disable_espresso_view_details_btn', FALSE ) ) {
221
+	function espresso_view_details_btn($event = NULL) {
222
+		if ( ! apply_filters('FHEE_disable_espresso_view_details_btn', FALSE)) {
223 223
 			espresso_load_ticket_selector();
224
-			echo EED_Ticket_Selector::display_ticket_selector( $event, TRUE );
224
+			echo EED_Ticket_Selector::display_ticket_selector($event, TRUE);
225 225
 		}
226 226
 	}
227 227
 }
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
 /*************************** EEH_Event_View ***************************/
233 233
 
234
-if ( ! function_exists( 'espresso_load_event_list_assets' )) {
234
+if ( ! function_exists('espresso_load_event_list_assets')) {
235 235
 	/**
236 236
 	 * espresso_load_event_list_assets
237 237
 	 * ensures that event list styles and scripts are loaded
@@ -240,13 +240,13 @@  discard block
 block discarded – undo
240 240
 	 */
241 241
 	function espresso_load_event_list_assets() {
242 242
 		$event_list = EED_Events_Archive::instance();
243
-		add_action( 'AHEE__EE_System__initialize_last', array( $event_list, 'load_event_list_assets' ), 10 );
244
-		add_filter( 'FHEE_enable_default_espresso_css', '__return_true' );
243
+		add_action('AHEE__EE_System__initialize_last', array($event_list, 'load_event_list_assets'), 10);
244
+		add_filter('FHEE_enable_default_espresso_css', '__return_true');
245 245
 	}
246 246
 }
247 247
 
248 248
 
249
-if ( ! function_exists( 'espresso_event_reg_button' )) {
249
+if ( ! function_exists('espresso_event_reg_button')) {
250 250
 	/**
251 251
 	 * espresso_event_reg_button
252 252
 	 * returns the "Register Now" button if event is active,
@@ -258,13 +258,13 @@  discard block
 block discarded – undo
258 258
 	 * @param bool $EVT_ID
259 259
 	 * @return string
260 260
 	 */
261
-	function espresso_event_reg_button( $btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE ) {
262
-		$event = EEH_Event_View::get_event( $EVT_ID );
263
-		if ( ! $event instanceof EE_Event ) {
261
+	function espresso_event_reg_button($btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE) {
262
+		$event = EEH_Event_View::get_event($EVT_ID);
263
+		if ( ! $event instanceof EE_Event) {
264 264
 			return;
265 265
 		}
266 266
 		$event_status = $event->get_active_status();
267
-		switch ( $event_status ) {
267
+		switch ($event_status) {
268 268
 			case EE_Datetime::sold_out :
269 269
 				$btn_text = esc_html__('Sold Out', 'event_espresso');
270 270
 				$class = 'ee-pink';
@@ -284,15 +284,15 @@  discard block
 block discarded – undo
284 284
 			case EE_Datetime::upcoming :
285 285
 			case EE_Datetime::active :
286 286
 			default :
287
-				$btn_text =! empty( $btn_text_if_active ) ? $btn_text_if_active : esc_html__( 'Register Now', 'event_espresso' );
287
+				$btn_text = ! empty($btn_text_if_active) ? $btn_text_if_active : esc_html__('Register Now', 'event_espresso');
288 288
 				$class = 'ee-green';
289 289
 		}
290
-		if ( $event_status < 1 && ! empty( $btn_text_if_inactive )) {
290
+		if ($event_status < 1 && ! empty($btn_text_if_inactive)) {
291 291
 			$btn_text = $btn_text_if_inactive;
292 292
 			$class = 'ee-grey';
293 293
 		}
294 294
 		?>
295
-		<a class="ee-button ee-register-button <?php echo $class; ?>" href="<?php espresso_event_link_url( $EVT_ID ); ?>"<?php echo \EED_Events_Archive::link_target(); ?>>
295
+		<a class="ee-button ee-register-button <?php echo $class; ?>" href="<?php espresso_event_link_url($EVT_ID); ?>"<?php echo \EED_Events_Archive::link_target(); ?>>
296 296
 			<?php echo $btn_text; ?>
297 297
 		</a>
298 298
 	<?php
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 
302 302
 
303 303
 
304
-if ( ! function_exists( 'espresso_display_ticket_selector' )) {
304
+if ( ! function_exists('espresso_display_ticket_selector')) {
305 305
 	/**
306 306
 	 * espresso_display_ticket_selector
307 307
 	 * whether or not to display the Ticket Selector for an event
@@ -309,14 +309,14 @@  discard block
 block discarded – undo
309 309
 	 * @param bool $EVT_ID
310 310
 	 * @return boolean
311 311
 	 */
312
-	function espresso_display_ticket_selector( $EVT_ID = FALSE ) {
313
-		return EEH_Event_View::display_ticket_selector( $EVT_ID );
312
+	function espresso_display_ticket_selector($EVT_ID = FALSE) {
313
+		return EEH_Event_View::display_ticket_selector($EVT_ID);
314 314
 	}
315 315
 }
316 316
 
317 317
 
318 318
 
319
-if ( ! function_exists( 'espresso_event_status_banner' )) {
319
+if ( ! function_exists('espresso_event_status_banner')) {
320 320
 	/**
321 321
 	 * espresso_event_status
322 322
 	 * returns a banner showing the event status if it is sold out, expired, or inactive
@@ -324,13 +324,13 @@  discard block
 block discarded – undo
324 324
 	 * @param bool $EVT_ID
325 325
 	 * @return string
326 326
 	 */
327
-	function espresso_event_status_banner( $EVT_ID = FALSE ) {
328
-		return EEH_Event_View::event_status( $EVT_ID );
327
+	function espresso_event_status_banner($EVT_ID = FALSE) {
328
+		return EEH_Event_View::event_status($EVT_ID);
329 329
 	}
330 330
 }
331 331
 
332 332
 
333
-if ( ! function_exists( 'espresso_event_status' )) {
333
+if ( ! function_exists('espresso_event_status')) {
334 334
 	/**
335 335
 	 * espresso_event_status
336 336
 	 * returns the event status if it is sold out, expired, or inactive
@@ -339,13 +339,13 @@  discard block
 block discarded – undo
339 339
 	 * @param bool $echo
340 340
 	 * @return string
341 341
 	 */
342
-	function espresso_event_status( $EVT_ID = 0, $echo = TRUE ) {
343
-		return EEH_Event_View::event_active_status( $EVT_ID, $echo );
342
+	function espresso_event_status($EVT_ID = 0, $echo = TRUE) {
343
+		return EEH_Event_View::event_active_status($EVT_ID, $echo);
344 344
 	}
345 345
 }
346 346
 
347 347
 
348
-if ( ! function_exists( 'espresso_event_categories' )) {
348
+if ( ! function_exists('espresso_event_categories')) {
349 349
 	/**
350 350
 	 * espresso_event_categories
351 351
 	 * returns the terms associated with an event
@@ -355,17 +355,17 @@  discard block
 block discarded – undo
355 355
 	 * @param bool $echo
356 356
 	 * @return string
357 357
 	 */
358
-	function espresso_event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) {
359
-		if ( $echo ) {
360
-			echo EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized );
358
+	function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) {
359
+		if ($echo) {
360
+			echo EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized);
361 361
 			return '';
362 362
 		}
363
-		return EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized );
363
+		return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized);
364 364
 	}
365 365
 }
366 366
 
367 367
 
368
-if ( ! function_exists( 'espresso_event_tickets_available' )) {
368
+if ( ! function_exists('espresso_event_tickets_available')) {
369 369
 	/**
370 370
 	 * espresso_event_tickets_available
371 371
 	 * returns the ticket types available for purchase for an event
@@ -375,26 +375,26 @@  discard block
 block discarded – undo
375 375
 	 * @param bool $format
376 376
 	 * @return string
377 377
 	 */
378
-	function espresso_event_tickets_available( $EVT_ID = 0, $echo = TRUE, $format = TRUE ) {
379
-		$tickets = EEH_Event_View::event_tickets_available( $EVT_ID );
380
-		if ( is_array( $tickets ) && ! empty( $tickets )) {
378
+	function espresso_event_tickets_available($EVT_ID = 0, $echo = TRUE, $format = TRUE) {
379
+		$tickets = EEH_Event_View::event_tickets_available($EVT_ID);
380
+		if (is_array($tickets) && ! empty($tickets)) {
381 381
 			// if formatting then $html will be a string, else it will be an array of ticket objects
382
-			$html = $format ? '<ul id="ee-event-tickets-ul-' . $EVT_ID . '" class="ee-event-tickets-ul">' : array();
383
-			foreach ( $tickets as $ticket ) {
384
-				if ( $ticket instanceof EE_Ticket ) {
385
-					if ( $format ) {
386
-						$html .= '<li id="ee-event-tickets-li-' . $ticket->ID() . '" class="ee-event-tickets-li">';
387
-						$html .= $ticket->name() . ' ' . EEH_Template::format_currency( $ticket->get_ticket_total_with_taxes() );
382
+			$html = $format ? '<ul id="ee-event-tickets-ul-'.$EVT_ID.'" class="ee-event-tickets-ul">' : array();
383
+			foreach ($tickets as $ticket) {
384
+				if ($ticket instanceof EE_Ticket) {
385
+					if ($format) {
386
+						$html .= '<li id="ee-event-tickets-li-'.$ticket->ID().'" class="ee-event-tickets-li">';
387
+						$html .= $ticket->name().' '.EEH_Template::format_currency($ticket->get_ticket_total_with_taxes());
388 388
 						$html .= '</li>';
389 389
 					} else {
390 390
 						$html[] = $ticket;
391 391
 					}
392 392
 				}
393 393
 			}
394
-			if ( $format ) {
394
+			if ($format) {
395 395
 				$html .= '</ul>';
396 396
 			}
397
-			if ( $echo && $format ) {
397
+			if ($echo && $format) {
398 398
 				echo $html;
399 399
 				return '';
400 400
 			}
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 	}
405 405
 }
406 406
 
407
-if ( ! function_exists( 'espresso_event_date_obj' )) {
407
+if ( ! function_exists('espresso_event_date_obj')) {
408 408
 	/**
409 409
 	 * espresso_event_date_obj
410 410
 	 * returns the primary date object for an event
@@ -412,13 +412,13 @@  discard block
 block discarded – undo
412 412
 	 * @param bool $EVT_ID
413 413
 	 * @return object
414 414
 	 */
415
-	function espresso_event_date_obj( $EVT_ID = FALSE ) {
416
-		return EEH_Event_View::get_primary_date_obj( $EVT_ID );
415
+	function espresso_event_date_obj($EVT_ID = FALSE) {
416
+		return EEH_Event_View::get_primary_date_obj($EVT_ID);
417 417
 	}
418 418
 }
419 419
 
420 420
 
421
-if ( ! function_exists( 'espresso_event_date' )) {
421
+if ( ! function_exists('espresso_event_date')) {
422 422
 	/**
423 423
 	 * espresso_event_date
424 424
 	 * returns the primary date for an event
@@ -429,22 +429,22 @@  discard block
 block discarded – undo
429 429
 	 * @param bool $echo
430 430
 	 * @return string
431 431
 	 */
432
-	function espresso_event_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
433
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
434
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
435
-		$date_format = apply_filters( 'FHEE__espresso_event_date__date_format', $date_format );
436
-		$time_format = apply_filters( 'FHEE__espresso_event_date__time_format', $time_format );
437
-		if($echo){
438
-			echo EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID );
432
+	function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
433
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
434
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
435
+		$date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format);
436
+		$time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format);
437
+		if ($echo) {
438
+			echo EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID);
439 439
 			return '';
440 440
 		}
441
-		return EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID );
441
+		return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID);
442 442
 
443 443
 	}
444 444
 }
445 445
 
446 446
 
447
-if ( ! function_exists( 'espresso_list_of_event_dates' )) {
447
+if ( ! function_exists('espresso_list_of_event_dates')) {
448 448
 	/**
449 449
 	 * espresso_list_of_event_dates
450 450
 	 * returns a unordered list of dates for an event
@@ -459,45 +459,45 @@  discard block
 block discarded – undo
459 459
 	 * @param null   $limit
460 460
 	 * @return string
461 461
 	 */
462
-	function espresso_list_of_event_dates( $EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL ) {
462
+	function espresso_list_of_event_dates($EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL) {
463 463
 	    $arguments = apply_filters(
464 464
             'FHEE__espresso_list_of_event_dates__arguments',
465
-            [ $EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit ]
465
+            [$EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit]
466 466
         );
467 467
         list($EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit) = $arguments;
468
-	    $datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit );
469
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
470
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
471
-		$date_format = apply_filters( 'FHEE__espresso_list_of_event_dates__date_format', $date_format );
472
-		$time_format = apply_filters( 'FHEE__espresso_list_of_event_dates__time_format', $time_format );
473
-		if ( ! $format ) {
474
-			return apply_filters( 'FHEE__espresso_list_of_event_dates__datetimes', $datetimes );
468
+	    $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, FALSE, $limit);
469
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
470
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
471
+		$date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format);
472
+		$time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format);
473
+		if ( ! $format) {
474
+			return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes);
475 475
 		}
476
-		if ( is_array( $datetimes ) && ! empty( $datetimes )) {
476
+		if (is_array($datetimes) && ! empty($datetimes)) {
477 477
 			global $post;
478
-			$html = '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul ee-clearfix">';
479
-			foreach ( $datetimes as $datetime ) {
480
-				if ( $datetime instanceof EE_Datetime ) {
478
+			$html = '<ul id="ee-event-datetimes-ul-'.$post->ID.'" class="ee-event-datetimes-ul ee-clearfix">';
479
+			foreach ($datetimes as $datetime) {
480
+				if ($datetime instanceof EE_Datetime) {
481 481
                     $datetime_name = $datetime->name();
482 482
                     $datetime_description = $datetime->description();
483
-                    $html .= '<li id="ee-event-datetimes-li-' . $datetime->ID();
484
-                    $html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-' . $datetime->get_active_status() . '">';
483
+                    $html .= '<li id="ee-event-datetimes-li-'.$datetime->ID();
484
+                    $html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-'.$datetime->get_active_status().'">';
485 485
                     $inner_html = '';
486
-                    if (! empty( $datetime_name )) {
487
-                        $inner_html .= '<strong>' . $datetime_name . '</strong>';
486
+                    if ( ! empty($datetime_name)) {
487
+                        $inner_html .= '<strong>'.$datetime_name.'</strong>';
488 488
                         $inner_html .= $add_breaks ? '<br />' : '';
489 489
                     }
490 490
                     // add date
491 491
                     $inner_html .= '<span class="dashicons dashicons-calendar"></span>';
492 492
                     $inner_html .= '</span><span class="ee-event-datetimes-li-daterange">';
493
-                    $inner_html .= $datetime->date_range( $date_format ) . '</span><br/>';
493
+                    $inner_html .= $datetime->date_range($date_format).'</span><br/>';
494 494
                     // add time
495 495
                     $inner_html .= '<span class="dashicons dashicons-clock"></span>';
496 496
                     $inner_html .= '<span class="ee-event-datetimes-li-timerange">';
497
-                    $inner_html .= $datetime->time_range( $time_format ) . '</span>';
498
-                    if (! empty( $datetime_description )) {
497
+                    $inner_html .= $datetime->time_range($time_format).'</span>';
498
+                    if ( ! empty($datetime_description)) {
499 499
                         $inner_html .= $add_breaks ? '<br />' : '';
500
-                        $inner_html .= ' - ' . $datetime_description;
500
+                        $inner_html .= ' - '.$datetime_description;
501 501
                     }
502 502
                     $inner_html = apply_filters(
503 503
                         'FHEE__espresso_list_of_event_dates__datetime_html',
@@ -505,17 +505,17 @@  discard block
 block discarded – undo
505 505
                         $datetime,
506 506
                         $arguments
507 507
                     );
508
-                    $html .= $inner_html . '</li>';
508
+                    $html .= $inner_html.'</li>';
509 509
 				}
510 510
 			}
511 511
 			$html .= '</ul>';
512 512
             $html = apply_filters('FHEE__espresso_list_of_event_dates__html', $html, $arguments, $datetime);
513 513
 		} else {
514 514
             $html = '<p><span class="dashicons dashicons-marker pink-text"></span>';
515
-            $html .= esc_html__( 'There are no upcoming dates for this event.', 'event_espresso' );
515
+            $html .= esc_html__('There are no upcoming dates for this event.', 'event_espresso');
516 516
             $html .= '</p><br/>';
517 517
 		}
518
-		if ( $echo ) {
518
+		if ($echo) {
519 519
 			echo $html;
520 520
 			return '';
521 521
 		}
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 }
525 525
 
526 526
 
527
-if ( ! function_exists( 'espresso_event_end_date' )) {
527
+if ( ! function_exists('espresso_event_end_date')) {
528 528
 	/**
529 529
 	 * espresso_event_end_date
530 530
 	 * returns the last date for an event
@@ -535,20 +535,20 @@  discard block
 block discarded – undo
535 535
 	 * @param bool   $echo
536 536
 	 * @return string
537 537
 	 */
538
-	function espresso_event_end_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
539
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
540
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
541
-		$date_format = apply_filters( 'FHEE__espresso_event_end_date__date_format', $date_format );
542
-		$time_format = apply_filters( 'FHEE__espresso_event_end_date__time_format', $time_format );
543
-		if($echo){
544
-			echo EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID );
538
+	function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
539
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
540
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
541
+		$date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format);
542
+		$time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format);
543
+		if ($echo) {
544
+			echo EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID);
545 545
 			return '';
546 546
 		}
547
-		return EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID );
547
+		return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID);
548 548
 	}
549 549
 }
550 550
 
551
-if ( ! function_exists( 'espresso_event_date_range' )) {
551
+if ( ! function_exists('espresso_event_date_range')) {
552 552
 	/**
553 553
 	 * espresso_event_date_range
554 554
 	 * returns the first and last chronologically ordered dates for an event (if different)
@@ -561,32 +561,32 @@  discard block
 block discarded – undo
561 561
 	 * @param bool   $echo
562 562
 	 * @return string
563 563
 	 */
564
-	function espresso_event_date_range( $date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
564
+	function espresso_event_date_range($date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
565 565
 		// set and filter date and time formats when a range is returned
566
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
567
-		$date_format = apply_filters( 'FHEE__espresso_event_date_range__date_format', $date_format );
566
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
567
+		$date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format);
568 568
 		// get the start and end date with NO time portion
569
-		$the_event_date = EEH_Event_View::the_earliest_event_date( $date_format, '', $EVT_ID );
570
-		$the_event_end_date = EEH_Event_View::the_latest_event_date( $date_format, '', $EVT_ID );
569
+		$the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID);
570
+		$the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID);
571 571
 		// now we can determine if date range spans more than one day
572
-		if ( $the_event_date != $the_event_end_date ) {
573
-			$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
574
-			$time_format = apply_filters( 'FHEE__espresso_event_date_range__time_format', $time_format );
572
+		if ($the_event_date != $the_event_end_date) {
573
+			$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
574
+			$time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format);
575 575
 			$html = sprintf(
576 576
 				/* translators: 1: first event date, 2: last event date */
577
-				esc_html__( '%1$s - %2$s', 'event_espresso' ),
578
-				EEH_Event_View::the_earliest_event_date( $date_format, $time_format, $EVT_ID ),
579
-				EEH_Event_View::the_latest_event_date( $date_format, $time_format, $EVT_ID )
577
+				esc_html__('%1$s - %2$s', 'event_espresso'),
578
+				EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID),
579
+				EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID)
580 580
 			);
581 581
 		} else {
582 582
 			// set and filter date and time formats when only a single datetime is returned
583
-			$single_date_format = ! empty( $single_date_format ) ? $single_date_format : get_option( 'date_format' );
584
-			$single_time_format = ! empty( $single_time_format ) ? $single_time_format : get_option( 'time_format' );
585
-			$single_date_format = apply_filters( 'FHEE__espresso_event_date_range__single_date_format', $single_date_format );
586
-			$single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', $single_time_format );
587
-			$html = EEH_Event_View::the_earliest_event_date( $single_date_format, $single_time_format, $EVT_ID );
583
+			$single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format');
584
+			$single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format');
585
+			$single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format);
586
+			$single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format);
587
+			$html = EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID);
588 588
 		}
589
-		if ( $echo ) {
589
+		if ($echo) {
590 590
 			echo $html;
591 591
 			return '';
592 592
 		}
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 	}
595 595
 }
596 596
 
597
-if ( ! function_exists( 'espresso_next_upcoming_datetime_obj' )) {
597
+if ( ! function_exists('espresso_next_upcoming_datetime_obj')) {
598 598
 	/**
599 599
 	 * espresso_next_upcoming_datetime_obj
600 600
 	 * returns the next upcoming datetime object for an event
@@ -602,12 +602,12 @@  discard block
 block discarded – undo
602 602
 	 * @param int $EVT_ID
603 603
 	 * @return EE_Datetime|null
604 604
 	 */
605
-	function espresso_next_upcoming_datetime_obj( $EVT_ID = 0 ) {
606
-		return EEH_Event_View::get_next_upcoming_date_obj( $EVT_ID );
605
+	function espresso_next_upcoming_datetime_obj($EVT_ID = 0) {
606
+		return EEH_Event_View::get_next_upcoming_date_obj($EVT_ID);
607 607
 	}
608 608
 }
609 609
 
610
-if ( ! function_exists( 'espresso_next_upcoming_datetime' ) ) {
610
+if ( ! function_exists('espresso_next_upcoming_datetime')) {
611 611
 	/**
612 612
 	 * espresso_next_upcoming_datetime
613 613
 	 * returns the start date and time for the next upcoming event.
@@ -618,30 +618,30 @@  discard block
 block discarded – undo
618 618
 	 * @param bool $echo
619 619
 	 * @return string
620 620
 	 */
621
-	function espresso_next_upcoming_datetime( $date_format = '', $time_format = '', $EVT_ID = 0, $echo = true ) {
621
+	function espresso_next_upcoming_datetime($date_format = '', $time_format = '', $EVT_ID = 0, $echo = true) {
622 622
 
623
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
624
-		$date_format = apply_filters( 'FHEE__espresso_next_upcoming_datetime__date_format', $date_format );
623
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
624
+		$date_format = apply_filters('FHEE__espresso_next_upcoming_datetime__date_format', $date_format);
625 625
 
626
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
627
-		$time_format = apply_filters( 'FHEE__espresso_next_upcoming_datetime__time_format', $time_format );
626
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
627
+		$time_format = apply_filters('FHEE__espresso_next_upcoming_datetime__time_format', $time_format);
628 628
 
629
-		$datetime_format = trim( $date_format . ' ' . $time_format);
629
+		$datetime_format = trim($date_format.' '.$time_format);
630 630
 
631
-		$datetime = espresso_next_upcoming_datetime_obj( $EVT_ID );
631
+		$datetime = espresso_next_upcoming_datetime_obj($EVT_ID);
632 632
 
633
-		if( ! $datetime instanceof EE_Datetime ) {
633
+		if ( ! $datetime instanceof EE_Datetime) {
634 634
 			return '';
635 635
 		}
636
-		if ( $echo ){
637
-			echo $datetime->get_i18n_datetime( 'DTT_EVT_start', $datetime_format );
636
+		if ($echo) {
637
+			echo $datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format);
638 638
 			return '';
639 639
 		}
640
-		return $datetime->get_i18n_datetime( 'DTT_EVT_start', $datetime_format );
640
+		return $datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format);
641 641
 	}
642 642
 }
643 643
 
644
-if ( ! function_exists( 'espresso_event_date_as_calendar_page' )) {
644
+if ( ! function_exists('espresso_event_date_as_calendar_page')) {
645 645
 	/**
646 646
 	 * espresso_event_date_as_calendar_page
647 647
 	 * returns the primary date for an event, stylized to appear as the page of a calendar
@@ -649,15 +649,15 @@  discard block
 block discarded – undo
649 649
 	 * @param bool $EVT_ID
650 650
 	 * @return string
651 651
 	 */
652
-	function espresso_event_date_as_calendar_page( $EVT_ID = FALSE ) {
653
-		EEH_Event_View::event_date_as_calendar_page( $EVT_ID );
652
+	function espresso_event_date_as_calendar_page($EVT_ID = FALSE) {
653
+		EEH_Event_View::event_date_as_calendar_page($EVT_ID);
654 654
 	}
655 655
 }
656 656
 
657 657
 
658 658
 
659 659
 
660
-if ( ! function_exists( 'espresso_event_link_url' )) {
660
+if ( ! function_exists('espresso_event_link_url')) {
661 661
 	/**
662 662
 	 * espresso_event_link_url
663 663
 	 *
@@ -665,18 +665,18 @@  discard block
 block discarded – undo
665 665
 	 * @param bool $echo
666 666
 	 * @return string
667 667
 	 */
668
-	function espresso_event_link_url( $EVT_ID = 0, $echo = TRUE ) {
669
-		if ( $echo ) {
670
-			echo EEH_Event_View::event_link_url( $EVT_ID );
668
+	function espresso_event_link_url($EVT_ID = 0, $echo = TRUE) {
669
+		if ($echo) {
670
+			echo EEH_Event_View::event_link_url($EVT_ID);
671 671
 			return '';
672 672
 		}
673
-		return EEH_Event_View::event_link_url( $EVT_ID );
673
+		return EEH_Event_View::event_link_url($EVT_ID);
674 674
 	}
675 675
 }
676 676
 
677 677
 
678 678
 
679
-if ( ! function_exists( 'espresso_event_has_content_or_excerpt' )) {
679
+if ( ! function_exists('espresso_event_has_content_or_excerpt')) {
680 680
 	/**
681 681
 	 *    espresso_event_has_content_or_excerpt
682 682
 	 *
@@ -684,15 +684,15 @@  discard block
 block discarded – undo
684 684
 	 * @param bool $EVT_ID
685 685
 	 * @return    boolean
686 686
 	 */
687
-	function espresso_event_has_content_or_excerpt( $EVT_ID = FALSE ) {
688
-		return EEH_Event_View::event_has_content_or_excerpt( $EVT_ID );
687
+	function espresso_event_has_content_or_excerpt($EVT_ID = FALSE) {
688
+		return EEH_Event_View::event_has_content_or_excerpt($EVT_ID);
689 689
 	}
690 690
 }
691 691
 
692 692
 
693 693
 
694 694
 
695
-if ( ! function_exists( 'espresso_event_content_or_excerpt' )) {
695
+if ( ! function_exists('espresso_event_content_or_excerpt')) {
696 696
 	/**
697 697
 	 * espresso_event_content_or_excerpt
698 698
 	 *
@@ -701,18 +701,18 @@  discard block
 block discarded – undo
701 701
 	 * @param bool $echo
702 702
 	 * @return string
703 703
 	 */
704
-	function espresso_event_content_or_excerpt( $num_words = 55, $more = NULL, $echo = TRUE ) {
705
-		if ( $echo ) {
706
-			echo EEH_Event_View::event_content_or_excerpt( $num_words, $more );
704
+	function espresso_event_content_or_excerpt($num_words = 55, $more = NULL, $echo = TRUE) {
705
+		if ($echo) {
706
+			echo EEH_Event_View::event_content_or_excerpt($num_words, $more);
707 707
 			return '';
708 708
 		}
709
-		return EEH_Event_View::event_content_or_excerpt( $num_words, $more );
709
+		return EEH_Event_View::event_content_or_excerpt($num_words, $more);
710 710
 	}
711 711
 }
712 712
 
713 713
 
714 714
 
715
-if ( ! function_exists( 'espresso_event_phone' )) {
715
+if ( ! function_exists('espresso_event_phone')) {
716 716
 	/**
717 717
 	 * espresso_event_phone
718 718
 	 *
@@ -720,18 +720,18 @@  discard block
 block discarded – undo
720 720
 	 * @param bool $echo
721 721
 	 * @return string
722 722
 	 */
723
-	function espresso_event_phone( $EVT_ID = 0, $echo = TRUE ) {
724
-		if ( $echo ) {
725
-			echo EEH_Event_View::event_phone( $EVT_ID );
723
+	function espresso_event_phone($EVT_ID = 0, $echo = TRUE) {
724
+		if ($echo) {
725
+			echo EEH_Event_View::event_phone($EVT_ID);
726 726
 			return '';
727 727
 		}
728
-		return EEH_Event_View::event_phone( $EVT_ID );
728
+		return EEH_Event_View::event_phone($EVT_ID);
729 729
 	}
730 730
 }
731 731
 
732 732
 
733 733
 
734
-if ( ! function_exists( 'espresso_edit_event_link' )) {
734
+if ( ! function_exists('espresso_edit_event_link')) {
735 735
 	/**
736 736
 	 * espresso_edit_event_link
737 737
 	 * returns a link to edit an event
@@ -740,39 +740,39 @@  discard block
 block discarded – undo
740 740
 	 * @param bool $echo
741 741
 	 * @return string
742 742
 	 */
743
-	function espresso_edit_event_link( $EVT_ID = 0, $echo = TRUE ) {
744
-		if ( $echo ) {
745
-			echo EEH_Event_View::edit_event_link( $EVT_ID );
743
+	function espresso_edit_event_link($EVT_ID = 0, $echo = TRUE) {
744
+		if ($echo) {
745
+			echo EEH_Event_View::edit_event_link($EVT_ID);
746 746
 			return '';
747 747
 		}
748
-		return EEH_Event_View::edit_event_link( $EVT_ID );
748
+		return EEH_Event_View::edit_event_link($EVT_ID);
749 749
 	}
750 750
 }
751 751
 
752 752
 
753
-if ( ! function_exists( 'espresso_organization_name' )) {
753
+if ( ! function_exists('espresso_organization_name')) {
754 754
 	/**
755 755
 	 * espresso_organization_name
756 756
 	 * @param bool $echo
757 757
 	 * @return string
758 758
 	 */
759 759
 	function espresso_organization_name($echo = TRUE) {
760
-		if($echo){
761
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'name' );
760
+		if ($echo) {
761
+			echo EE_Registry::instance()->CFG->organization->get_pretty('name');
762 762
 			return '';
763 763
 		}
764
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'name' );
764
+		return EE_Registry::instance()->CFG->organization->get_pretty('name');
765 765
 	}
766 766
 }
767 767
 
768
-if ( ! function_exists( 'espresso_organization_address' )) {
768
+if ( ! function_exists('espresso_organization_address')) {
769 769
 	/**
770 770
 	 * espresso_organization_address
771 771
 	 * @param string $type
772 772
 	 * @return string
773 773
 	 */
774
-	function espresso_organization_address( $type = 'inline' ) {
775
-		if ( EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ) {
774
+	function espresso_organization_address($type = 'inline') {
775
+		if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) {
776 776
 			$address = new EventEspresso\core\domain\entities\GenericAddress(
777 777
 				EE_Registry::instance()->CFG->organization->address_1,
778 778
 				EE_Registry::instance()->CFG->organization->address_2,
@@ -781,129 +781,129 @@  discard block
 block discarded – undo
781 781
 				EE_Registry::instance()->CFG->organization->zip,
782 782
 				EE_Registry::instance()->CFG->organization->CNT_ISO
783 783
 			);
784
-			return EEH_Address::format( $address, $type );
784
+			return EEH_Address::format($address, $type);
785 785
 		}
786 786
 		return '';
787 787
 	}
788 788
 }
789 789
 
790
-if ( ! function_exists( 'espresso_organization_email' )) {
790
+if ( ! function_exists('espresso_organization_email')) {
791 791
 	/**
792 792
 	 * espresso_organization_email
793 793
 	 * @param bool $echo
794 794
 	 * @return string
795 795
 	 */
796
-	function espresso_organization_email( $echo = TRUE ) {
797
-		if($echo){
798
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'email' );
796
+	function espresso_organization_email($echo = TRUE) {
797
+		if ($echo) {
798
+			echo EE_Registry::instance()->CFG->organization->get_pretty('email');
799 799
 			return '';
800 800
 		}
801
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'email' );
801
+		return EE_Registry::instance()->CFG->organization->get_pretty('email');
802 802
 	}
803 803
 }
804 804
 
805
-if ( ! function_exists( 'espresso_organization_logo_url' )) {
805
+if ( ! function_exists('espresso_organization_logo_url')) {
806 806
 	/**
807 807
 	 * espresso_organization_logo_url
808 808
 	 * @param bool $echo
809 809
 	 * @return string
810 810
 	 */
811
-	function espresso_organization_logo_url( $echo = TRUE ) {
812
-		if($echo){
813
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' );
811
+	function espresso_organization_logo_url($echo = TRUE) {
812
+		if ($echo) {
813
+			echo EE_Registry::instance()->CFG->organization->get_pretty('logo_url');
814 814
 			return '';
815 815
 		}
816
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' );
816
+		return EE_Registry::instance()->CFG->organization->get_pretty('logo_url');
817 817
 	}
818 818
 }
819 819
 
820
-if ( ! function_exists( 'espresso_organization_facebook' )) {
820
+if ( ! function_exists('espresso_organization_facebook')) {
821 821
 	/**
822 822
 	 * espresso_organization_facebook
823 823
 	 * @param bool $echo
824 824
 	 * @return string
825 825
 	 */
826
-	function espresso_organization_facebook( $echo = TRUE ) {
827
-		if($echo){
828
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' );
826
+	function espresso_organization_facebook($echo = TRUE) {
827
+		if ($echo) {
828
+			echo EE_Registry::instance()->CFG->organization->get_pretty('facebook');
829 829
 			return '';
830 830
 		}
831
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' );
831
+		return EE_Registry::instance()->CFG->organization->get_pretty('facebook');
832 832
 	}
833 833
 }
834 834
 
835
-if ( ! function_exists( 'espresso_organization_twitter' )) {
835
+if ( ! function_exists('espresso_organization_twitter')) {
836 836
 	/**
837 837
 	 * espresso_organization_twitter
838 838
 	 * @param bool $echo
839 839
 	 * @return string
840 840
 	 */
841
-	function espresso_organization_twitter( $echo = TRUE ) {
842
-		if($echo){
843
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' );
841
+	function espresso_organization_twitter($echo = TRUE) {
842
+		if ($echo) {
843
+			echo EE_Registry::instance()->CFG->organization->get_pretty('twitter');
844 844
 			return '';
845 845
 		}
846
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' );
846
+		return EE_Registry::instance()->CFG->organization->get_pretty('twitter');
847 847
 	}
848 848
 }
849 849
 
850
-if ( ! function_exists( 'espresso_organization_linkedin' )) {
850
+if ( ! function_exists('espresso_organization_linkedin')) {
851 851
 	/**
852 852
 	 * espresso_organization_linkedin
853 853
 	 * @param bool $echo
854 854
 	 * @return string
855 855
 	 */
856
-	function espresso_organization_linkedin( $echo = TRUE ) {
857
-		if($echo){
858
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' );
856
+	function espresso_organization_linkedin($echo = TRUE) {
857
+		if ($echo) {
858
+			echo EE_Registry::instance()->CFG->organization->get_pretty('linkedin');
859 859
 			return '';
860 860
 		}
861
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' );
861
+		return EE_Registry::instance()->CFG->organization->get_pretty('linkedin');
862 862
 	}
863 863
 }
864 864
 
865
-if ( ! function_exists( 'espresso_organization_pinterest' )) {
865
+if ( ! function_exists('espresso_organization_pinterest')) {
866 866
 	/**
867 867
 	 * espresso_organization_pinterest
868 868
 	 * @param bool $echo
869 869
 	 * @return string
870 870
 	 */
871
-	function espresso_organization_pinterest( $echo = TRUE ) {
872
-		if($echo){
873
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' );
871
+	function espresso_organization_pinterest($echo = TRUE) {
872
+		if ($echo) {
873
+			echo EE_Registry::instance()->CFG->organization->get_pretty('pinterest');
874 874
 			return '';
875 875
 		}
876
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' );
876
+		return EE_Registry::instance()->CFG->organization->get_pretty('pinterest');
877 877
 	}
878 878
 }
879 879
 
880
-if ( ! function_exists( 'espresso_organization_google' )) {
880
+if ( ! function_exists('espresso_organization_google')) {
881 881
 	/**
882 882
 	 * espresso_organization_google
883 883
 	 * @param bool $echo
884 884
 	 * @return string
885 885
 	 */
886
-	function espresso_organization_google( $echo = TRUE ) {
887
-		if($echo){
888
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'google' );
886
+	function espresso_organization_google($echo = TRUE) {
887
+		if ($echo) {
888
+			echo EE_Registry::instance()->CFG->organization->get_pretty('google');
889 889
 			return '';
890 890
 		}
891
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'google' );
891
+		return EE_Registry::instance()->CFG->organization->get_pretty('google');
892 892
 	}
893 893
 }
894 894
 
895
-if ( ! function_exists( 'espresso_organization_instagram' )) {
895
+if ( ! function_exists('espresso_organization_instagram')) {
896 896
 	/**
897 897
 	 * espresso_organization_instagram
898 898
 	 * @param bool $echo
899 899
 	 * @return string
900 900
 	 */
901
-	function espresso_organization_instagram( $echo = TRUE ) {
902
-		if($echo){
903
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' );
901
+	function espresso_organization_instagram($echo = TRUE) {
902
+		if ($echo) {
903
+			echo EE_Registry::instance()->CFG->organization->get_pretty('instagram');
904 904
 			return '';
905 905
 		}
906
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' );
906
+		return EE_Registry::instance()->CFG->organization->get_pretty('instagram');
907 907
 	}
908 908
 }
909 909
 
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
 
914 914
 
915 915
 
916
-if ( ! function_exists( 'espresso_event_venues' )) {
916
+if ( ! function_exists('espresso_event_venues')) {
917 917
 	/**
918 918
 	 * espresso_event_venues
919 919
 	 *
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
 
928 928
 
929 929
 
930
-if ( ! function_exists( 'espresso_venue_id' )) {
930
+if ( ! function_exists('espresso_venue_id')) {
931 931
 	/**
932 932
 	 *    espresso_venue_name
933 933
 	 *
@@ -935,15 +935,15 @@  discard block
 block discarded – undo
935 935
 	 * @param     int $EVT_ID
936 936
 	 * @return    string
937 937
 	 */
938
-	function espresso_venue_id( $EVT_ID = 0 ) {
939
-		$venue = EEH_Venue_View::get_venue( $EVT_ID );
938
+	function espresso_venue_id($EVT_ID = 0) {
939
+		$venue = EEH_Venue_View::get_venue($EVT_ID);
940 940
 		return $venue instanceof EE_Venue ? $venue->ID() : 0;
941 941
 	}
942 942
 }
943 943
 
944 944
 
945 945
 
946
-if ( ! function_exists( 'espresso_is_venue_private' ) ) {
946
+if ( ! function_exists('espresso_is_venue_private')) {
947 947
 	/**
948 948
 	 * Return whether a venue is private or not.
949 949
 	 * @see EEH_Venue_View::get_venue() for more info on expected return results.
@@ -952,45 +952,45 @@  discard block
 block discarded – undo
952 952
 	 *
953 953
 	 * @return bool | null
954 954
 	 */
955
-	function espresso_is_venue_private( $VNU_ID = 0 ) {
956
-		return EEH_Venue_View::is_venue_private( $VNU_ID );
955
+	function espresso_is_venue_private($VNU_ID = 0) {
956
+		return EEH_Venue_View::is_venue_private($VNU_ID);
957 957
 	}
958 958
 }
959 959
 
960 960
 
961 961
 
962
-if ( ! function_exists( 'espresso_venue_is_password_protected' ) ) {
962
+if ( ! function_exists('espresso_venue_is_password_protected')) {
963 963
 	/**
964 964
 	 * returns true or false if a venue is password protected or not
965 965
 	 *
966 966
 	 * @param int     $VNU_ID optional, the venue id to check.
967 967
 	 * @return string
968 968
 	 */
969
-	function espresso_venue_is_password_protected( $VNU_ID = 0 ) {
970
-		EE_Registry::instance()->load_helper( 'Venue_View' );
971
-		return EEH_Venue_View::is_venue_password_protected( $VNU_ID );
969
+	function espresso_venue_is_password_protected($VNU_ID = 0) {
970
+		EE_Registry::instance()->load_helper('Venue_View');
971
+		return EEH_Venue_View::is_venue_password_protected($VNU_ID);
972 972
 	}
973 973
 }
974 974
 
975 975
 
976 976
 
977
-if ( ! function_exists( 'espresso_password_protected_venue_form' ) ) {
977
+if ( ! function_exists('espresso_password_protected_venue_form')) {
978 978
 	/**
979 979
 	 * Returns a password form if venue is password protected.
980 980
 	 *
981 981
 	 * @param int     $VNU_ID optional, the venue id to check.
982 982
 	 * @return string
983 983
 	 */
984
-	function espresso_password_protected_venue_form( $VNU_ID = 0 ) {
985
-		EE_Registry::instance()->load_helper( 'Venue_View' );
986
-		return EEH_Venue_View::password_protected_venue_form( $VNU_ID );
984
+	function espresso_password_protected_venue_form($VNU_ID = 0) {
985
+		EE_Registry::instance()->load_helper('Venue_View');
986
+		return EEH_Venue_View::password_protected_venue_form($VNU_ID);
987 987
 	}
988 988
 }
989 989
 
990 990
 
991 991
 
992 992
 
993
-if ( ! function_exists( 'espresso_venue_name' )) {
993
+if ( ! function_exists('espresso_venue_name')) {
994 994
 	/**
995 995
 	 *    espresso_venue_name
996 996
 	 *
@@ -1000,19 +1000,19 @@  discard block
 block discarded – undo
1000 1000
 	 * @param bool   $echo
1001 1001
 	 * @return    string
1002 1002
 	 */
1003
-	function espresso_venue_name( $VNU_ID = 0, $link_to = 'details', $echo = TRUE ) {
1004
-		if($echo){
1005
-			echo EEH_Venue_View::venue_name( $link_to, $VNU_ID );
1003
+	function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = TRUE) {
1004
+		if ($echo) {
1005
+			echo EEH_Venue_View::venue_name($link_to, $VNU_ID);
1006 1006
 			return '';
1007 1007
 		}
1008
-		return EEH_Venue_View::venue_name( $link_to, $VNU_ID );
1008
+		return EEH_Venue_View::venue_name($link_to, $VNU_ID);
1009 1009
 	}
1010 1010
 }
1011 1011
 
1012 1012
 
1013 1013
 
1014 1014
 
1015
-if ( ! function_exists( 'espresso_venue_link' )) {
1015
+if ( ! function_exists('espresso_venue_link')) {
1016 1016
 	/**
1017 1017
 	 * 	espresso_venue_link
1018 1018
 	 *
@@ -1021,14 +1021,14 @@  discard block
 block discarded – undo
1021 1021
 	 *  @param 	string 	$text
1022 1022
 	 *  @return 	string
1023 1023
 	 */
1024
-	function espresso_venue_link( $VNU_ID = 0, $text = '' ) {
1025
-		return EEH_Venue_View::venue_details_link( $VNU_ID, $text );
1024
+	function espresso_venue_link($VNU_ID = 0, $text = '') {
1025
+		return EEH_Venue_View::venue_details_link($VNU_ID, $text);
1026 1026
 	}
1027 1027
 }
1028 1028
 
1029 1029
 
1030 1030
 
1031
-if ( ! function_exists( 'espresso_venue_description' )) {
1031
+if ( ! function_exists('espresso_venue_description')) {
1032 1032
 	/**
1033 1033
 	 *    espresso_venue_description
1034 1034
 	 *
@@ -1037,17 +1037,17 @@  discard block
 block discarded – undo
1037 1037
 	 * @param bool $echo
1038 1038
 	 * @return    string
1039 1039
 	 */
1040
-	function espresso_venue_description( $VNU_ID = FALSE, $echo = TRUE ) {
1041
-		if($echo){
1042
-			echo EEH_Venue_View::venue_description( $VNU_ID );
1040
+	function espresso_venue_description($VNU_ID = FALSE, $echo = TRUE) {
1041
+		if ($echo) {
1042
+			echo EEH_Venue_View::venue_description($VNU_ID);
1043 1043
 			return '';
1044 1044
 		}
1045
-		return EEH_Venue_View::venue_description( $VNU_ID );
1045
+		return EEH_Venue_View::venue_description($VNU_ID);
1046 1046
 	}
1047 1047
 }
1048 1048
 
1049 1049
 
1050
-if ( ! function_exists( 'espresso_venue_excerpt' )) {
1050
+if ( ! function_exists('espresso_venue_excerpt')) {
1051 1051
 	/**
1052 1052
 	 *    espresso_venue_excerpt
1053 1053
 	 *
@@ -1056,18 +1056,18 @@  discard block
 block discarded – undo
1056 1056
 	 * @param bool $echo
1057 1057
 	 * @return    string
1058 1058
 	 */
1059
-	function espresso_venue_excerpt( $VNU_ID = 0,  $echo = TRUE ) {
1060
-		if ( $echo ) {
1061
-			echo EEH_Venue_View::venue_excerpt( $VNU_ID );
1059
+	function espresso_venue_excerpt($VNU_ID = 0, $echo = TRUE) {
1060
+		if ($echo) {
1061
+			echo EEH_Venue_View::venue_excerpt($VNU_ID);
1062 1062
 			return '';
1063 1063
 		}
1064
-		return EEH_Venue_View::venue_excerpt( $VNU_ID );
1064
+		return EEH_Venue_View::venue_excerpt($VNU_ID);
1065 1065
 	}
1066 1066
 }
1067 1067
 
1068 1068
 
1069 1069
 
1070
-if ( ! function_exists( 'espresso_venue_categories' )) {
1070
+if ( ! function_exists('espresso_venue_categories')) {
1071 1071
 	/**
1072 1072
 	 * espresso_venue_categories
1073 1073
 	 * returns the terms associated with a venue
@@ -1077,17 +1077,17 @@  discard block
 block discarded – undo
1077 1077
 	 * @param bool $echo
1078 1078
 	 * @return string
1079 1079
 	 */
1080
-	function espresso_venue_categories( $VNU_ID = 0, $hide_uncategorized = TRUE,  $echo = TRUE ) {
1081
-		if ( $echo ) {
1082
-			echo EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized );
1080
+	function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) {
1081
+		if ($echo) {
1082
+			echo EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized);
1083 1083
 			return '';
1084 1084
 		}
1085
-		return EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized );
1085
+		return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized);
1086 1086
 	}
1087 1087
 }
1088 1088
 
1089 1089
 
1090
-if ( ! function_exists( 'espresso_venue_address' )) {
1090
+if ( ! function_exists('espresso_venue_address')) {
1091 1091
 	/**
1092 1092
 	 * espresso_venue_address
1093 1093
 	 * returns a formatted block of html  for displaying a venue's address
@@ -1097,17 +1097,17 @@  discard block
 block discarded – undo
1097 1097
 	 * @param bool   $echo
1098 1098
 	 * @return string
1099 1099
 	 */
1100
-	function espresso_venue_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) {
1101
-		if ( $echo ) {
1102
-			echo EEH_Venue_View::venue_address( $type, $VNU_ID );
1100
+	function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) {
1101
+		if ($echo) {
1102
+			echo EEH_Venue_View::venue_address($type, $VNU_ID);
1103 1103
 			return '';
1104 1104
 		}
1105
-		return EEH_Venue_View::venue_address( $type, $VNU_ID );
1105
+		return EEH_Venue_View::venue_address($type, $VNU_ID);
1106 1106
 	}
1107 1107
 }
1108 1108
 
1109 1109
 
1110
-if ( ! function_exists( 'espresso_venue_raw_address' )) {
1110
+if ( ! function_exists('espresso_venue_raw_address')) {
1111 1111
 	/**
1112 1112
 	 * espresso_venue_address
1113 1113
 	 * returns an UN-formatted string containing a venue's address
@@ -1117,17 +1117,17 @@  discard block
 block discarded – undo
1117 1117
 	 * @param bool     $echo
1118 1118
 	 * @return string
1119 1119
 	 */
1120
-	function espresso_venue_raw_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) {
1121
-		if ( $echo ) {
1122
-			echo EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE );
1120
+	function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) {
1121
+		if ($echo) {
1122
+			echo EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE);
1123 1123
 			return '';
1124 1124
 		}
1125
-		return EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE );
1125
+		return EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE);
1126 1126
 	}
1127 1127
 }
1128 1128
 
1129 1129
 
1130
-if ( ! function_exists( 'espresso_venue_has_address' )) {
1130
+if ( ! function_exists('espresso_venue_has_address')) {
1131 1131
 	/**
1132 1132
 	 * espresso_venue_has_address
1133 1133
 	 * returns TRUE or FALSE if a Venue has address information
@@ -1135,13 +1135,13 @@  discard block
 block discarded – undo
1135 1135
 	 * @param int $VNU_ID
1136 1136
 	 * @return bool
1137 1137
 	 */
1138
-	function espresso_venue_has_address( $VNU_ID = 0 ) {
1139
-		return EEH_Venue_View::venue_has_address( $VNU_ID );
1138
+	function espresso_venue_has_address($VNU_ID = 0) {
1139
+		return EEH_Venue_View::venue_has_address($VNU_ID);
1140 1140
 	}
1141 1141
 }
1142 1142
 
1143 1143
 
1144
-if ( ! function_exists( 'espresso_venue_gmap' )) {
1144
+if ( ! function_exists('espresso_venue_gmap')) {
1145 1145
 	/**
1146 1146
 	 * espresso_venue_gmap
1147 1147
 	 * returns a google map for the venue address
@@ -1152,17 +1152,17 @@  discard block
 block discarded – undo
1152 1152
 	 * @param bool     $echo
1153 1153
 	 * @return string
1154 1154
 	 */
1155
-	function espresso_venue_gmap( $VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE  ) {
1156
-		if ( $echo ) {
1157
-			echo EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap );
1155
+	function espresso_venue_gmap($VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE) {
1156
+		if ($echo) {
1157
+			echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap);
1158 1158
 			return '';
1159 1159
 		}
1160
-		return EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap );
1160
+		return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap);
1161 1161
 	}
1162 1162
 }
1163 1163
 
1164 1164
 
1165
-if ( ! function_exists( 'espresso_venue_phone' )) {
1165
+if ( ! function_exists('espresso_venue_phone')) {
1166 1166
 	/**
1167 1167
 	 * espresso_venue_phone
1168 1168
 	 *
@@ -1170,18 +1170,18 @@  discard block
 block discarded – undo
1170 1170
 	 * @param bool $echo
1171 1171
 	 * @return string
1172 1172
 	 */
1173
-	function espresso_venue_phone( $VNU_ID = 0, $echo = TRUE ) {
1174
-		if ( $echo ) {
1175
-			echo EEH_Venue_View::venue_phone( $VNU_ID );
1173
+	function espresso_venue_phone($VNU_ID = 0, $echo = TRUE) {
1174
+		if ($echo) {
1175
+			echo EEH_Venue_View::venue_phone($VNU_ID);
1176 1176
 			return '';
1177 1177
 		}
1178
-		return EEH_Venue_View::venue_phone( $VNU_ID );
1178
+		return EEH_Venue_View::venue_phone($VNU_ID);
1179 1179
 	}
1180 1180
 }
1181 1181
 
1182 1182
 
1183 1183
 
1184
-if ( ! function_exists( 'espresso_venue_website' )) {
1184
+if ( ! function_exists('espresso_venue_website')) {
1185 1185
 	/**
1186 1186
 	 * espresso_venue_website
1187 1187
 	 *
@@ -1189,18 +1189,18 @@  discard block
 block discarded – undo
1189 1189
 	 * @param bool $echo
1190 1190
 	 * @return string
1191 1191
 	 */
1192
-	function espresso_venue_website( $VNU_ID = 0, $echo = TRUE ) {
1193
-		if ( $echo ) {
1194
-			echo EEH_Venue_View::venue_website_link( $VNU_ID );
1192
+	function espresso_venue_website($VNU_ID = 0, $echo = TRUE) {
1193
+		if ($echo) {
1194
+			echo EEH_Venue_View::venue_website_link($VNU_ID);
1195 1195
 			return '';
1196 1196
 		}
1197
-		return EEH_Venue_View::venue_website_link( $VNU_ID );
1197
+		return EEH_Venue_View::venue_website_link($VNU_ID);
1198 1198
 	}
1199 1199
 }
1200 1200
 
1201 1201
 
1202 1202
 
1203
-if ( ! function_exists( 'espresso_edit_venue_link' )) {
1203
+if ( ! function_exists('espresso_edit_venue_link')) {
1204 1204
 	/**
1205 1205
 	 * espresso_edit_venue_link
1206 1206
 	 *
@@ -1208,12 +1208,12 @@  discard block
 block discarded – undo
1208 1208
 	 * @param bool $echo
1209 1209
 	 * @return string
1210 1210
 	 */
1211
-	function espresso_edit_venue_link( $VNU_ID = 0, $echo = TRUE ) {
1212
-		if($echo){
1213
-			echo EEH_Venue_View::edit_venue_link( $VNU_ID );
1211
+	function espresso_edit_venue_link($VNU_ID = 0, $echo = TRUE) {
1212
+		if ($echo) {
1213
+			echo EEH_Venue_View::edit_venue_link($VNU_ID);
1214 1214
 			return '';
1215 1215
 		}
1216
-		return EEH_Venue_View::edit_venue_link( $VNU_ID );
1216
+		return EEH_Venue_View::edit_venue_link($VNU_ID);
1217 1217
 	}
1218 1218
 }
1219 1219
 
Please login to merge, or discard this patch.
core/services/cache/BasicCacheManager.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
         // with these parameters
141 141
         $cache_id .= filter_input(INPUT_SERVER, 'QUERY_STRING', FILTER_SANITIZE_URL);
142 142
         // then md5 the above to control it's length, add all of our prefixes, and truncate
143
-        return substr($this->cachePrefix() . $id_prefix . '-' . md5($cache_id), 0, 182);
143
+        return substr($this->cachePrefix().$id_prefix.'-'.md5($cache_id), 0, 182);
144 144
     }
145 145
 
146 146
 
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
         return '
171 171
 <div class="ee-cached-content-notice" style="position:fixed; bottom:0; left: 0;">
172 172
     <p style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;margin:0 0 3px 5px">
173
-        <b>' . $type . '</b><span style="color:#999"> : </span>
174
-        <span>' . $cache_id . '</span>
175
-        <span style="margin-left:2em;">' . __FILE__ . '</span>
173
+        <b>' . $type.'</b><span style="color:#999"> : </span>
174
+        <span>' . $cache_id.'</span>
175
+        <span style="margin-left:2em;">' . __FILE__.'</span>
176 176
     </p>
177 177
 </div>';
178 178
     }
Please login to merge, or discard this patch.
Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -16,135 +16,135 @@  discard block
 block discarded – undo
16 16
 class BasicCacheManager implements CacheManagerInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @type string
21
-     */
22
-    const CACHE_PREFIX = 'ee_cache_';
23
-
24
-
25
-    /**
26
-     * @var CacheStorageInterface $cache_storage
27
-     */
28
-    private $cache_storage;
29
-
30
-
31
-    /**
32
-     * BasicCacheManager constructor.
33
-     *
34
-     * @param CacheStorageInterface $cache_storage [required]
35
-     */
36
-    public function __construct(CacheStorageInterface $cache_storage)
37
-    {
38
-        $this->cache_storage = $cache_storage;
39
-    }
40
-
41
-
42
-    /**
43
-     * returns a string that will be prepended to all cache identifiers
44
-     *
45
-     * @return string
46
-     */
47
-    public function cachePrefix()
48
-    {
49
-        return BasicCacheManager::CACHE_PREFIX;
50
-    }
51
-
52
-
53
-    /**
54
-     * @param string  $id_prefix [required] Prepended to all cache IDs. Can be helpful in finding specific cache types.
55
-     *                           May also be helpful to include an additional specific identifier,
56
-     *                           such as a post ID as part of the $id_prefix so that individual caches
57
-     *                           can be found and/or cleared. ex: "venue-28", or "shortcode-156".
58
-     *                           BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id.
59
-     * @param string  $cache_id  [required] Additional identifying details that make this cache unique.
60
-     *                           It is advisable to use some of the actual data
61
-     *                           that is used to generate the content being cached,
62
-     *                           in order to guarantee that the cache id is unique for that content.
63
-     *                           The cache id will be md5'd before usage to make it more db friendly,
64
-     *                           and the entire cache id string will be truncated to 190 characters.
65
-     * @param Closure $callback  [required] since the point of caching is to avoid generating content when not
66
-     *                           necessary,
67
-     *                           we wrap our content creation in a Closure so that it is not executed until needed.
68
-     * @param int     $expiration
69
-     * @return Closure|mixed
70
-     */
71
-    public function get($id_prefix, $cache_id, Closure $callback, $expiration = HOUR_IN_SECONDS)
72
-    {
73
-        $content = '';
74
-        $expiration = absint(
75
-            apply_filters(
76
-                'FHEE__CacheManager__get__cache_expiration',
77
-                $expiration,
78
-                $id_prefix,
79
-                $cache_id
80
-            )
81
-        );
82
-        $cache_id = $this->generateCacheIdentifier($id_prefix, $cache_id);
83
-        // is caching enabled for this content ?
84
-        if ($expiration) {
85
-            $content = $this->cache_storage->get($cache_id);
86
-        }
87
-        // any existing content ?
88
-        if (empty($content)) {
89
-            // nope! let's generate some new stuff
90
-            $content = $callback();
91
-            // save the new content if caching is enabled
92
-            if ($expiration) {
93
-                $this->cache_storage->add($cache_id, $content, $expiration);
94
-                if (EE_DEBUG) {
95
-                    $content .= $this->displayCacheNotice($cache_id, 'REFRESH CACHE');
96
-                }
97
-            }
98
-        } else {
99
-            if (EE_DEBUG) {
100
-                $content .= $this->displayCacheNotice($cache_id, 'CACHED CONTENT');
101
-            }
102
-        }
103
-        return $content;
104
-    }
105
-
106
-
107
-    /**
108
-     * Generates a unique identifier string for the cache
109
-     *
110
-     * @param string $id_prefix [required] see BasicCacheManager::get()
111
-     * @param string $cache_id  [required] see BasicCacheManager::get()
112
-     * @return string
113
-     */
114
-    private function generateCacheIdentifier($id_prefix, $cache_id)
115
-    {
116
-        // let's make the cached content unique for this "page"
117
-        $cache_id .= filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL);
118
-        // with these parameters
119
-        $cache_id .= filter_input(INPUT_SERVER, 'QUERY_STRING', FILTER_SANITIZE_URL);
120
-        // then md5 the above to control it's length, add all of our prefixes, and truncate
121
-        return substr($this->cachePrefix() . $id_prefix . '-' . md5($cache_id), 0, 182);
122
-    }
123
-
124
-
125
-    /**
126
-     * @param array|string $cache_id [required] Could be an ID prefix affecting many caches
127
-     *                               or a specific ID targeting a single cache item
128
-     * @return void
129
-     */
130
-    public function clear($cache_id)
131
-    {
132
-        // ensure incoming arg is in an array
133
-        $cache_id = is_array($cache_id) ? $cache_id : array($cache_id);
134
-        // delete corresponding transients for the supplied id prefix
135
-        $this->cache_storage->deleteMany($cache_id);
136
-    }
137
-
138
-
139
-    /**
140
-     * @param array|string $cache_id [required] Could be an ID prefix affecting many caches
141
-     *                               or a specific ID targeting a single cache item
142
-     * @param string       $type
143
-     * @return string
144
-     */
145
-    private function displayCacheNotice($cache_id, $type)
146
-    {
147
-        return '
19
+	/**
20
+	 * @type string
21
+	 */
22
+	const CACHE_PREFIX = 'ee_cache_';
23
+
24
+
25
+	/**
26
+	 * @var CacheStorageInterface $cache_storage
27
+	 */
28
+	private $cache_storage;
29
+
30
+
31
+	/**
32
+	 * BasicCacheManager constructor.
33
+	 *
34
+	 * @param CacheStorageInterface $cache_storage [required]
35
+	 */
36
+	public function __construct(CacheStorageInterface $cache_storage)
37
+	{
38
+		$this->cache_storage = $cache_storage;
39
+	}
40
+
41
+
42
+	/**
43
+	 * returns a string that will be prepended to all cache identifiers
44
+	 *
45
+	 * @return string
46
+	 */
47
+	public function cachePrefix()
48
+	{
49
+		return BasicCacheManager::CACHE_PREFIX;
50
+	}
51
+
52
+
53
+	/**
54
+	 * @param string  $id_prefix [required] Prepended to all cache IDs. Can be helpful in finding specific cache types.
55
+	 *                           May also be helpful to include an additional specific identifier,
56
+	 *                           such as a post ID as part of the $id_prefix so that individual caches
57
+	 *                           can be found and/or cleared. ex: "venue-28", or "shortcode-156".
58
+	 *                           BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id.
59
+	 * @param string  $cache_id  [required] Additional identifying details that make this cache unique.
60
+	 *                           It is advisable to use some of the actual data
61
+	 *                           that is used to generate the content being cached,
62
+	 *                           in order to guarantee that the cache id is unique for that content.
63
+	 *                           The cache id will be md5'd before usage to make it more db friendly,
64
+	 *                           and the entire cache id string will be truncated to 190 characters.
65
+	 * @param Closure $callback  [required] since the point of caching is to avoid generating content when not
66
+	 *                           necessary,
67
+	 *                           we wrap our content creation in a Closure so that it is not executed until needed.
68
+	 * @param int     $expiration
69
+	 * @return Closure|mixed
70
+	 */
71
+	public function get($id_prefix, $cache_id, Closure $callback, $expiration = HOUR_IN_SECONDS)
72
+	{
73
+		$content = '';
74
+		$expiration = absint(
75
+			apply_filters(
76
+				'FHEE__CacheManager__get__cache_expiration',
77
+				$expiration,
78
+				$id_prefix,
79
+				$cache_id
80
+			)
81
+		);
82
+		$cache_id = $this->generateCacheIdentifier($id_prefix, $cache_id);
83
+		// is caching enabled for this content ?
84
+		if ($expiration) {
85
+			$content = $this->cache_storage->get($cache_id);
86
+		}
87
+		// any existing content ?
88
+		if (empty($content)) {
89
+			// nope! let's generate some new stuff
90
+			$content = $callback();
91
+			// save the new content if caching is enabled
92
+			if ($expiration) {
93
+				$this->cache_storage->add($cache_id, $content, $expiration);
94
+				if (EE_DEBUG) {
95
+					$content .= $this->displayCacheNotice($cache_id, 'REFRESH CACHE');
96
+				}
97
+			}
98
+		} else {
99
+			if (EE_DEBUG) {
100
+				$content .= $this->displayCacheNotice($cache_id, 'CACHED CONTENT');
101
+			}
102
+		}
103
+		return $content;
104
+	}
105
+
106
+
107
+	/**
108
+	 * Generates a unique identifier string for the cache
109
+	 *
110
+	 * @param string $id_prefix [required] see BasicCacheManager::get()
111
+	 * @param string $cache_id  [required] see BasicCacheManager::get()
112
+	 * @return string
113
+	 */
114
+	private function generateCacheIdentifier($id_prefix, $cache_id)
115
+	{
116
+		// let's make the cached content unique for this "page"
117
+		$cache_id .= filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL);
118
+		// with these parameters
119
+		$cache_id .= filter_input(INPUT_SERVER, 'QUERY_STRING', FILTER_SANITIZE_URL);
120
+		// then md5 the above to control it's length, add all of our prefixes, and truncate
121
+		return substr($this->cachePrefix() . $id_prefix . '-' . md5($cache_id), 0, 182);
122
+	}
123
+
124
+
125
+	/**
126
+	 * @param array|string $cache_id [required] Could be an ID prefix affecting many caches
127
+	 *                               or a specific ID targeting a single cache item
128
+	 * @return void
129
+	 */
130
+	public function clear($cache_id)
131
+	{
132
+		// ensure incoming arg is in an array
133
+		$cache_id = is_array($cache_id) ? $cache_id : array($cache_id);
134
+		// delete corresponding transients for the supplied id prefix
135
+		$this->cache_storage->deleteMany($cache_id);
136
+	}
137
+
138
+
139
+	/**
140
+	 * @param array|string $cache_id [required] Could be an ID prefix affecting many caches
141
+	 *                               or a specific ID targeting a single cache item
142
+	 * @param string       $type
143
+	 * @return string
144
+	 */
145
+	private function displayCacheNotice($cache_id, $type)
146
+	{
147
+		return '
148 148
 <div class="ee-cached-content-notice" style="position:fixed; bottom:0; left: 0;">
149 149
     <p style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;margin:0 0 3px 5px">
150 150
         <b>' . $type . '</b><span style="color:#999"> : </span>
@@ -152,5 +152,5 @@  discard block
 block discarded – undo
152 152
         <span style="margin-left:2em;">' . __FILE__ . '</span>
153 153
     </p>
154 154
 </div>';
155
-    }
155
+	}
156 156
 }
Please login to merge, or discard this patch.
libraries/form_sections/strategies/layout/EE_Two_Column_Layout.strategy.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
             $this->_form_section->html_id(),
19 19
             $this->_form_section->html_class(),
20 20
             $this->_form_section->html_style()
21
-        ) . EEH_HTML::tbody();
21
+        ).EEH_HTML::tbody();
22 22
     }
23 23
 
24 24
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      */
32 32
     public function layout_form_end($additional_args = array())
33 33
     {
34
-        return EEH_HTML::tbodyx() . EEH_HTML::tablex($this->_form_section->html_id());
34
+        return EEH_HTML::tbodyx().EEH_HTML::tablex($this->_form_section->html_id());
35 35
     }
36 36
 
37 37
 
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
         } else {
51 51
             $html_for_input = $input->get_html_for_input();
52 52
             $html_for_input .= $input->get_html_for_errors() != ''
53
-                ? EEH_HTML::nl() . $input->get_html_for_errors()
53
+                ? EEH_HTML::nl().$input->get_html_for_errors()
54 54
                 : '';
55
-            $html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : '';
55
+            $html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl().$input->get_html_for_help() : '';
56 56
             $html .= EEH_HTML::tr(
57
-                EEH_HTML::th($input->get_html_for_label()) .
57
+                EEH_HTML::th($input->get_html_for_label()).
58 58
                 EEH_HTML::td($html_for_input)
59 59
             );
60 60
         }
Please login to merge, or discard this patch.
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -3,82 +3,82 @@
 block discarded – undo
3 3
 class EE_Two_Column_Layout extends EE_Form_Section_Layout_Base
4 4
 {
5 5
 
6
-    /**
7
-     * Should be used to start teh form section (Eg a table tag, or a div tag, etc.)
8
-     *
9
-     * @param array $additional_args
10
-     * @return string
11
-     */
12
-    public function layout_form_begin($additional_args = array())
13
-    {
14
-        return $this->display_form_wide_errors()
15
-        . EEH_HTML::table(
16
-            '',
17
-            $this->_form_section->html_id(),
18
-            $this->_form_section->html_class(),
19
-            $this->_form_section->html_style()
20
-        ) . EEH_HTML::tbody();
21
-    }
6
+	/**
7
+	 * Should be used to start teh form section (Eg a table tag, or a div tag, etc.)
8
+	 *
9
+	 * @param array $additional_args
10
+	 * @return string
11
+	 */
12
+	public function layout_form_begin($additional_args = array())
13
+	{
14
+		return $this->display_form_wide_errors()
15
+		. EEH_HTML::table(
16
+			'',
17
+			$this->_form_section->html_id(),
18
+			$this->_form_section->html_class(),
19
+			$this->_form_section->html_style()
20
+		) . EEH_HTML::tbody();
21
+	}
22 22
 
23 23
 
24 24
 
25
-    /**
26
-     * Should be used to end the form section (eg a /table tag, or a /div tag, etc)
27
-     *
28
-     * @param array $additional_args
29
-     * @return string
30
-     */
31
-    public function layout_form_end($additional_args = array())
32
-    {
33
-        return EEH_HTML::tbodyx() . EEH_HTML::tablex($this->_form_section->html_id());
34
-    }
25
+	/**
26
+	 * Should be used to end the form section (eg a /table tag, or a /div tag, etc)
27
+	 *
28
+	 * @param array $additional_args
29
+	 * @return string
30
+	 */
31
+	public function layout_form_end($additional_args = array())
32
+	{
33
+		return EEH_HTML::tbodyx() . EEH_HTML::tablex($this->_form_section->html_id());
34
+	}
35 35
 
36 36
 
37 37
 
38
-    /**
39
-     * Lays out the row for the input, including label and errors
40
-     *
41
-     * @param EE_Form_Input_Base $input
42
-     * @return string
43
-     */
44
-    public function layout_input($input)
45
-    {
46
-        $html = '';
47
-        if ($input instanceof EE_Hidden_Input) {
48
-            $html .= $input->get_html_for_input();
49
-        } else {
50
-            $html_for_input = $input->get_html_for_input();
51
-            $html_for_input .= $input->get_html_for_errors() != ''
52
-                ? EEH_HTML::nl() . $input->get_html_for_errors()
53
-                : '';
54
-            $html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : '';
55
-            $html .= EEH_HTML::tr(
56
-                EEH_HTML::th($input->get_html_for_label()) .
57
-                EEH_HTML::td($html_for_input)
58
-            );
59
-        }
60
-        return $html;
61
-    }
38
+	/**
39
+	 * Lays out the row for the input, including label and errors
40
+	 *
41
+	 * @param EE_Form_Input_Base $input
42
+	 * @return string
43
+	 */
44
+	public function layout_input($input)
45
+	{
46
+		$html = '';
47
+		if ($input instanceof EE_Hidden_Input) {
48
+			$html .= $input->get_html_for_input();
49
+		} else {
50
+			$html_for_input = $input->get_html_for_input();
51
+			$html_for_input .= $input->get_html_for_errors() != ''
52
+				? EEH_HTML::nl() . $input->get_html_for_errors()
53
+				: '';
54
+			$html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : '';
55
+			$html .= EEH_HTML::tr(
56
+				EEH_HTML::th($input->get_html_for_label()) .
57
+				EEH_HTML::td($html_for_input)
58
+			);
59
+		}
60
+		return $html;
61
+	}
62 62
 
63 63
 
64 64
 
65
-    /**
66
-     * Lays out a row for the subsection. Please note that if you have a subsection which you don't want wrapped in
67
-     * a tr and td with a colspan=2, you should use a different layout strategy, like EE_No_Layout, EE_Template_Layout,
68
-     * or EE_Div_Per_Section_Layout, and create subsections using EE_Two_Column_Layout for everywhere you want the
69
-     * two-column layout, and then other sub-sections can be outside the EE_Two_Column_Layout table.
70
-     *
71
-     * @param EE_Form_Section_Proper $form_section
72
-     * @return string
73
-    */
74
-    public function layout_subsection($form_section)
75
-    {
76
-        if (
77
-            $form_section instanceof EE_Form_Section_Proper
78
-            || $form_section instanceof EE_Form_Section_HTML
79
-        ) {
80
-            return EEH_HTML::no_row($form_section->get_html());
81
-        }
82
-        return '';
83
-    }
65
+	/**
66
+	 * Lays out a row for the subsection. Please note that if you have a subsection which you don't want wrapped in
67
+	 * a tr and td with a colspan=2, you should use a different layout strategy, like EE_No_Layout, EE_Template_Layout,
68
+	 * or EE_Div_Per_Section_Layout, and create subsections using EE_Two_Column_Layout for everywhere you want the
69
+	 * two-column layout, and then other sub-sections can be outside the EE_Two_Column_Layout table.
70
+	 *
71
+	 * @param EE_Form_Section_Proper $form_section
72
+	 * @return string
73
+	 */
74
+	public function layout_subsection($form_section)
75
+	{
76
+		if (
77
+			$form_section instanceof EE_Form_Section_Proper
78
+			|| $form_section instanceof EE_Form_Section_HTML
79
+		) {
80
+			return EEH_HTML::no_row($form_section->get_html());
81
+		}
82
+		return '';
83
+	}
84 84
 }
Please login to merge, or discard this patch.
admin_pages/transactions/EE_Admin_Transactions_List_Table.class.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      *
103 103
      * @abstract
104 104
      * @access protected
105
-     * @return array
105
+     * @return string[]
106 106
      */
107 107
     protected function _get_table_filters()
108 108
     {
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
      *    column_TXN_paid
266 266
      *
267 267
      * @param \EE_Transaction $transaction
268
-     * @return mixed|string
268
+     * @return string
269 269
      * @throws \EE_Error
270 270
      */
271 271
     public function column_TXN_paid(EE_Transaction $transaction)
Please login to merge, or discard this patch.
Indentation   +665 added lines, -665 removed lines patch added patch discarded remove patch
@@ -15,121 +15,121 @@  discard block
 block discarded – undo
15 15
 class EE_Admin_Transactions_List_Table extends EE_Admin_List_Table
16 16
 {
17 17
 
18
-    /**
19
-     * @var SessionLifespan $session_lifespan
20
-     */
21
-    private $session_lifespan;
22
-
23
-    private $_status;
24
-
25
-
26
-    /**
27
-     * @param \Transactions_Admin_Page $admin_page
28
-     * @param SessionLifespan          $lifespan
29
-     */
30
-    public function __construct(\Transactions_Admin_Page $admin_page, SessionLifespan $lifespan)
31
-    {
32
-        parent::__construct($admin_page);
33
-        $this->session_lifespan = $lifespan;
34
-        $this->_status = $this->_admin_page->get_transaction_status_array();
35
-    }
36
-
37
-
38
-    /**
39
-     *_setup_data
40
-     */
41
-    protected function _setup_data()
42
-    {
43
-        $this->_data = $this->_admin_page->get_transactions($this->_per_page);
44
-        $status = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all';
45
-        $this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, true, $status);
46
-    }
47
-
48
-
49
-    /**
50
-     *_set_properties
51
-     */
52
-    protected function _set_properties()
53
-    {
54
-        $this->_wp_list_args = array(
55
-            'singular' => __('transaction', 'event_espresso'),
56
-            'plural'   => __('transactions', 'event_espresso'),
57
-            'ajax'     => true,
58
-            'screen'   => $this->_admin_page->get_current_screen()->id,
59
-        );
60
-        $ID_column_name = __('ID', 'event_espresso');
61
-        $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">';
62
-        $ID_column_name .= __('Transaction Date', 'event_espresso');
63
-        $ID_column_name .= '</span> ';
64
-        $this->_columns = array(
65
-            'TXN_ID'        => $ID_column_name,
66
-            'TXN_timestamp' => __('Transaction Date', 'event_espresso'),
67
-            'TXN_total'     => __('Total', 'event_espresso'),
68
-            'TXN_paid'      => __('Paid', 'event_espresso'),
69
-            'ATT_fname'     => __('Primary Registrant', 'event_espresso'),
70
-            'event_name'    => __('Event', 'event_espresso'),
71
-            'actions'       => __('Actions', 'event_espresso'),
72
-        );
73
-
74
-        $this->_sortable_columns = array(
75
-            'TXN_ID'        => array('TXN_ID' => false),
76
-            'event_name'    => array('event_name' => false),
77
-            'ATT_fname'     => array('ATT_fname' => false),
78
-            'TXN_timestamp' => array('TXN_timestamp' => true) // true means its already sorted
79
-        );
80
-
81
-        $this->_primary_column = 'TXN_ID';
82
-
83
-        $this->_hidden_columns = array();
84
-    }
85
-
86
-
87
-    /**
88
-     * This simply sets up the row class for the table rows.
89
-     * Allows for easier overriding of child methods for setting up sorting.
90
-     *
91
-     * @param  EE_Transaction $transaction the current item
92
-     * @return string
93
-     * @throws \EE_Error
94
-     */
95
-    protected function _get_row_class($transaction)
96
-    {
97
-        $class = parent::_get_row_class($transaction);
98
-        // add status class
99
-        $class .= ' ee-status-strip txn-status-' . $transaction->status_ID();
100
-        if ($this->_has_checkbox_column) {
101
-            $class .= ' has-checkbox-column';
102
-        }
103
-        return $class;
104
-    }
105
-
106
-
107
-    /**
108
-     * _get_table_filters
109
-     * We use this to assemble and return any filters that are associated with this table that help further refine what
110
-     * get's shown in the table.
111
-     *
112
-     * @abstract
113
-     * @access protected
114
-     * @return array
115
-     */
116
-    protected function _get_table_filters()
117
-    {
118
-        $filters = array();
119
-        $start_date = isset($this->_req_data['txn-filter-start-date'])
120
-            ? wp_strip_all_tags($this->_req_data['txn-filter-start-date'])
121
-            : date(
122
-                'm/d/Y',
123
-                strtotime('-10 year')
124
-            );
125
-        $end_date = isset($this->_req_data['txn-filter-end-date'])
126
-            ? wp_strip_all_tags($this->_req_data['txn-filter-end-date'])
127
-            : date(
128
-                'm/d/Y',
129
-                current_time('timestamp')
130
-            );
131
-        ob_start();
132
-        ?>
18
+	/**
19
+	 * @var SessionLifespan $session_lifespan
20
+	 */
21
+	private $session_lifespan;
22
+
23
+	private $_status;
24
+
25
+
26
+	/**
27
+	 * @param \Transactions_Admin_Page $admin_page
28
+	 * @param SessionLifespan          $lifespan
29
+	 */
30
+	public function __construct(\Transactions_Admin_Page $admin_page, SessionLifespan $lifespan)
31
+	{
32
+		parent::__construct($admin_page);
33
+		$this->session_lifespan = $lifespan;
34
+		$this->_status = $this->_admin_page->get_transaction_status_array();
35
+	}
36
+
37
+
38
+	/**
39
+	 *_setup_data
40
+	 */
41
+	protected function _setup_data()
42
+	{
43
+		$this->_data = $this->_admin_page->get_transactions($this->_per_page);
44
+		$status = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all';
45
+		$this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, true, $status);
46
+	}
47
+
48
+
49
+	/**
50
+	 *_set_properties
51
+	 */
52
+	protected function _set_properties()
53
+	{
54
+		$this->_wp_list_args = array(
55
+			'singular' => __('transaction', 'event_espresso'),
56
+			'plural'   => __('transactions', 'event_espresso'),
57
+			'ajax'     => true,
58
+			'screen'   => $this->_admin_page->get_current_screen()->id,
59
+		);
60
+		$ID_column_name = __('ID', 'event_espresso');
61
+		$ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">';
62
+		$ID_column_name .= __('Transaction Date', 'event_espresso');
63
+		$ID_column_name .= '</span> ';
64
+		$this->_columns = array(
65
+			'TXN_ID'        => $ID_column_name,
66
+			'TXN_timestamp' => __('Transaction Date', 'event_espresso'),
67
+			'TXN_total'     => __('Total', 'event_espresso'),
68
+			'TXN_paid'      => __('Paid', 'event_espresso'),
69
+			'ATT_fname'     => __('Primary Registrant', 'event_espresso'),
70
+			'event_name'    => __('Event', 'event_espresso'),
71
+			'actions'       => __('Actions', 'event_espresso'),
72
+		);
73
+
74
+		$this->_sortable_columns = array(
75
+			'TXN_ID'        => array('TXN_ID' => false),
76
+			'event_name'    => array('event_name' => false),
77
+			'ATT_fname'     => array('ATT_fname' => false),
78
+			'TXN_timestamp' => array('TXN_timestamp' => true) // true means its already sorted
79
+		);
80
+
81
+		$this->_primary_column = 'TXN_ID';
82
+
83
+		$this->_hidden_columns = array();
84
+	}
85
+
86
+
87
+	/**
88
+	 * This simply sets up the row class for the table rows.
89
+	 * Allows for easier overriding of child methods for setting up sorting.
90
+	 *
91
+	 * @param  EE_Transaction $transaction the current item
92
+	 * @return string
93
+	 * @throws \EE_Error
94
+	 */
95
+	protected function _get_row_class($transaction)
96
+	{
97
+		$class = parent::_get_row_class($transaction);
98
+		// add status class
99
+		$class .= ' ee-status-strip txn-status-' . $transaction->status_ID();
100
+		if ($this->_has_checkbox_column) {
101
+			$class .= ' has-checkbox-column';
102
+		}
103
+		return $class;
104
+	}
105
+
106
+
107
+	/**
108
+	 * _get_table_filters
109
+	 * We use this to assemble and return any filters that are associated with this table that help further refine what
110
+	 * get's shown in the table.
111
+	 *
112
+	 * @abstract
113
+	 * @access protected
114
+	 * @return array
115
+	 */
116
+	protected function _get_table_filters()
117
+	{
118
+		$filters = array();
119
+		$start_date = isset($this->_req_data['txn-filter-start-date'])
120
+			? wp_strip_all_tags($this->_req_data['txn-filter-start-date'])
121
+			: date(
122
+				'm/d/Y',
123
+				strtotime('-10 year')
124
+			);
125
+		$end_date = isset($this->_req_data['txn-filter-end-date'])
126
+			? wp_strip_all_tags($this->_req_data['txn-filter-end-date'])
127
+			: date(
128
+				'm/d/Y',
129
+				current_time('timestamp')
130
+			);
131
+		ob_start();
132
+		?>
133 133
         <label for="txn-filter-start-date">Display Transactions from </label>
134 134
         <input id="txn-filter-start-date" class="datepicker" type="text" value="<?php echo $start_date; ?>"
135 135
                name="txn-filter-start-date" size="15"/>
@@ -137,585 +137,585 @@  discard block
 block discarded – undo
137 137
         <input id="txn-filter-end-date" class="datepicker" type="text" value="<?php echo $end_date; ?>"
138 138
                name="txn-filter-end-date" size="15"/>
139 139
         <?php
140
-        $filters[] = ob_get_contents();
141
-        ob_end_clean();
142
-        return $filters;
143
-    }
144
-
145
-
146
-    /**
147
-     *_add_view_counts
148
-     */
149
-    protected function _add_view_counts()
150
-    {
151
-        foreach ($this->_views as $view) {
152
-            $this->_views[ $view['slug'] ]['count'] = $this->_admin_page->get_transactions($this->_per_page, true, $view['slug']);
153
-        }
154
-    }
155
-
156
-
157
-    /**
158
-     *    column TXN_ID
159
-     *
160
-     * @param \EE_Transaction $transaction
161
-     * @return string
162
-     * @throws \EE_Error
163
-     */
164
-    public function column_TXN_ID(EE_Transaction $transaction)
165
-    {
166
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
167
-            array(
168
-                'action' => 'view_transaction',
169
-                'TXN_ID' => $transaction->ID(),
170
-            ),
171
-            TXN_ADMIN_URL
172
-        );
173
-        $content = '<a href="' . $view_lnk_url . '"'
174
-                   . ' title="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">'
175
-                   . $transaction->ID()
176
-                   . '</a>';
177
-
178
-        // txn timestamp
179
-        $content .= '  <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>';
180
-        return $content;
181
-    }
182
-
183
-
184
-    /**
185
-     * @param \EE_Transaction $transaction
186
-     * @return string
187
-     * @throws EE_Error
188
-     * @throws InvalidArgumentException
189
-     * @throws InvalidDataTypeException
190
-     * @throws InvalidInterfaceException
191
-     */
192
-    protected function _get_txn_timestamp(EE_Transaction $transaction)
193
-    {
194
-        // is TXN less than 2 hours old ?
195
-        if (
196
-            ($transaction->failed() || $transaction->is_abandoned())
197
-            && $this->session_lifespan->expiration() < $transaction->datetime(false, true)
198
-        ) {
199
-            $timestamp = esc_html__('TXN in progress...', 'event_espresso');
200
-        } else {
201
-            $timestamp = $transaction->get_i18n_datetime('TXN_timestamp');
202
-        }
203
-        return $timestamp;
204
-    }
205
-
206
-
207
-    /**
208
-     *    column_cb
209
-     *
210
-     * @param \EE_Transaction $transaction
211
-     * @return string
212
-     * @throws \EE_Error
213
-     */
214
-    public function column_cb($transaction)
215
-    {
216
-        return sprintf(
217
-            '<input type="checkbox" name="%1$s[]" value="%2$s" />',
218
-            $this->_wp_list_args['singular'],
219
-            $transaction->ID()
220
-        );
221
-    }
222
-
223
-
224
-    /**
225
-     *    column_TXN_timestamp
226
-     *
227
-     * @param \EE_Transaction $transaction
228
-     * @return string
229
-     * @throws \EE_Error
230
-     */
231
-    public function column_TXN_timestamp(EE_Transaction $transaction)
232
-    {
233
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
234
-            array(
235
-                'action' => 'view_transaction',
236
-                'TXN_ID' => $transaction->ID(),
237
-            ),
238
-            TXN_ADMIN_URL
239
-        );
240
-        $txn_date = '<a href="' . $view_lnk_url . '"'
241
-                    . ' title="'
242
-                    . esc_attr__('View Transaction Details for TXN #', 'event_espresso') . $transaction->ID() . '">'
243
-                    . $this->_get_txn_timestamp($transaction)
244
-                    . '</a>';
245
-        // status
246
-        $txn_date .= '<br><span class="ee-status-text-small">'
247
-                    . EEH_Template::pretty_status(
248
-                        $transaction->status_ID(),
249
-                        false,
250
-                        'sentence'
251
-                    )
252
-                     . '</span>';
253
-        return $txn_date;
254
-    }
255
-
256
-
257
-    /**
258
-     *    column_TXN_total
259
-     *
260
-     * @param \EE_Transaction $transaction
261
-     * @return string
262
-     * @throws \EE_Error
263
-     */
264
-    public function column_TXN_total(EE_Transaction $transaction)
265
-    {
266
-        if ($transaction->get('TXN_total') > 0) {
267
-            return '<span class="txn-pad-rght">'
268
-                   . apply_filters(
269
-                       'FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total',
270
-                       $transaction->get_pretty('TXN_total'),
271
-                       $transaction
272
-                   )
273
-                   . '</span>';
274
-        } else {
275
-            return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
276
-        }
277
-    }
278
-
279
-
280
-    /**
281
-     *    column_TXN_paid
282
-     *
283
-     * @param \EE_Transaction $transaction
284
-     * @return mixed|string
285
-     * @throws \EE_Error
286
-     */
287
-    public function column_TXN_paid(EE_Transaction $transaction)
288
-    {
289
-        $transaction_total = $transaction->get('TXN_total');
290
-        $transaction_paid = $transaction->get('TXN_paid');
291
-
292
-        if (\EEH_Money::compare_floats($transaction_total, 0, '>')) {
293
-            // monies owing
294
-            $span_class = 'txn-overview-part-payment-spn';
295
-            if (\EEH_Money::compare_floats($transaction_paid, $transaction_total, '>=')) {
296
-                // paid in full
297
-                $span_class = 'txn-overview-full-payment-spn';
298
-            } elseif (\EEH_Money::compare_floats($transaction_paid, 0, '==')) {
299
-                // no payments made
300
-                $span_class = 'txn-overview-no-payment-spn';
301
-            }
302
-        } else {
303
-            // transaction_total == 0 so this is a free event
304
-            $span_class = 'txn-overview-free-event-spn';
305
-        }
306
-
307
-        $payment_method = $transaction->payment_method();
308
-        $payment_method_name = $payment_method instanceof EE_Payment_Method
309
-            ? $payment_method->admin_name()
310
-            : esc_html__('Unknown', 'event_espresso');
311
-
312
-        $content = '<span class="' . $span_class . ' txn-pad-rght">'
313
-                   . $transaction->get_pretty('TXN_paid')
314
-                   . '</span>';
315
-        if ($transaction_paid > 0) {
316
-            $content .= '<br><span class="ee-status-text-small">'
317
-                        . sprintf(
318
-                            esc_html__('...via %s', 'event_espresso'),
319
-                            $payment_method_name
320
-                        )
321
-                        . '</span>';
322
-        }
323
-        return $content;
324
-    }
325
-
326
-
327
-    /**
328
-     *    column_ATT_fname
329
-     *
330
-     * @param \EE_Transaction $transaction
331
-     * @return string
332
-     * @throws EE_Error
333
-     * @throws InvalidArgumentException
334
-     * @throws InvalidDataTypeException
335
-     * @throws InvalidInterfaceException
336
-     */
337
-    public function column_ATT_fname(EE_Transaction $transaction)
338
-    {
339
-        $primary_reg = $transaction->primary_registration();
340
-        $attendee = $primary_reg->get_first_related('Attendee');
341
-        if ($attendee instanceof EE_Attendee) {
342
-            $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
343
-                array(
344
-                    'action'  => 'view_registration',
345
-                    '_REG_ID' => $primary_reg->ID(),
346
-                ),
347
-                REG_ADMIN_URL
348
-            );
349
-            $content = EE_Registry::instance()->CAP->current_user_can(
350
-                'ee_read_registration',
351
-                'espresso_registrations_view_registration',
352
-                $primary_reg->ID()
353
-            )
354
-                ? '<a href="' . $edit_lnk_url . '"'
355
-                  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
356
-                  . $attendee->full_name()
357
-                  . '</a>'
358
-                : $attendee->full_name();
359
-            $content .= '<br>' . $attendee->email();
360
-            return $content;
361
-        }
362
-        return $transaction->failed() || $transaction->is_abandoned()
363
-            ? esc_html__('no contact record.', 'event_espresso')
364
-            : esc_html__(
365
-                'No contact record, because the transaction was abandoned or the registration process failed.',
366
-                'event_espresso'
367
-            );
368
-    }
369
-
370
-
371
-    /**
372
-     *    column_ATT_email
373
-     *
374
-     * @param \EE_Transaction $transaction
375
-     * @return string
376
-     * @throws \EE_Error
377
-     */
378
-    public function column_ATT_email(EE_Transaction $transaction)
379
-    {
380
-        $attendee = $transaction->primary_registration()->get_first_related('Attendee');
381
-        if (! empty($attendee)) {
382
-            return '<a href="mailto:' . $attendee->get('ATT_email') . '">'
383
-                   . $attendee->get('ATT_email')
384
-                   . '</a>';
385
-        } else {
386
-            return $transaction->failed() || $transaction->is_abandoned()
387
-                ? esc_html__('no contact record.', 'event_espresso')
388
-                : esc_html__(
389
-                    'No contact record, because the transaction was abandoned or the registration process failed.',
390
-                    'event_espresso'
391
-                );
392
-        }
393
-    }
394
-
395
-
396
-    /**
397
-     *    column_event_name
398
-     *
399
-     * @param \EE_Transaction $transaction
400
-     * @return string
401
-     * @throws EE_Error
402
-     * @throws InvalidArgumentException
403
-     * @throws InvalidDataTypeException
404
-     * @throws InvalidInterfaceException
405
-     */
406
-    public function column_event_name(EE_Transaction $transaction)
407
-    {
408
-        $actions = array();
409
-        $event = $transaction->primary_registration()->get_first_related('Event');
410
-        if (! empty($event)) {
411
-            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
412
-                array('action' => 'edit', 'post' => $event->ID()),
413
-                EVENTS_ADMIN_URL
414
-            );
415
-            $event_name = $event->get('EVT_name');
416
-
417
-            // filter this view by transactions for this event
418
-            $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce(
419
-                array(
420
-                    'action' => 'default',
421
-                    'EVT_ID' => $event->ID(),
422
-                )
423
-            );
424
-            if (
425
-                empty($this->_req_data['EVT_ID'])
426
-                && EE_Registry::instance()->CAP->current_user_can(
427
-                    'ee_edit_event',
428
-                    'espresso_events_edit',
429
-                    $event->ID()
430
-                )
431
-            ) {
432
-                $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '"'
433
-                                              . ' title="' . esc_attr__(
434
-                                                  'Filter transactions by this event',
435
-                                                  'event_espresso'
436
-                                              ) . '">'
437
-                                              . esc_html__('View Transactions for this event', 'event_espresso')
438
-                                              . '</a>';
439
-            }
440
-
441
-            return sprintf(
442
-                '%1$s %2$s',
443
-                EE_Registry::instance()->CAP->current_user_can(
444
-                    'ee_edit_event',
445
-                    'espresso_events_edit',
446
-                    $event->ID()
447
-                )
448
-                    ? '<a href="' . $edit_event_url . '"'
449
-                      . ' title="'
450
-                      . sprintf(
451
-                          esc_attr__('Edit Event: %s', 'event_espresso'),
452
-                          $event->get('EVT_name')
453
-                      )
454
-                      . '">'
455
-                      . wp_trim_words(
456
-                          $event_name,
457
-                          30,
458
-                          '...'
459
-                      )
460
-                      . '</a>'
461
-                    : wp_trim_words($event_name, 30, '...'),
462
-                $this->row_actions($actions)
463
-            );
464
-        } else {
465
-            return esc_html__(
466
-                'The event associated with this transaction via the primary registration cannot be retrieved.',
467
-                'event_espresso'
468
-            );
469
-        }
470
-    }
471
-
472
-
473
-    /**
474
-     *    column_actions
475
-     *
476
-     * @param \EE_Transaction $transaction
477
-     * @return string
478
-     * @throws \EE_Error
479
-     */
480
-    public function column_actions(EE_Transaction $transaction)
481
-    {
482
-        return $this->_action_string(
483
-            $this->get_transaction_details_link($transaction)
484
-            . $this->get_invoice_link($transaction)
485
-            . $this->get_receipt_link($transaction)
486
-            . $this->get_primary_registration_details_link($transaction)
487
-            . $this->get_send_payment_reminder_trigger_link($transaction)
488
-            . $this->get_payment_overview_link($transaction)
489
-            . $this->get_related_messages_link($transaction),
490
-            $transaction,
491
-            'ul',
492
-            'txn-overview-actions-ul'
493
-        );
494
-    }
495
-
496
-
497
-    /**
498
-     * Get the transaction details link.
499
-     *
500
-     * @param EE_Transaction $transaction
501
-     * @return string
502
-     * @throws EE_Error
503
-     */
504
-    protected function get_transaction_details_link(EE_Transaction $transaction)
505
-    {
506
-        $url = EE_Admin_Page::add_query_args_and_nonce(
507
-            array(
508
-                'action' => 'view_transaction',
509
-                'TXN_ID' => $transaction->ID(),
510
-            ),
511
-            TXN_ADMIN_URL
512
-        );
513
-        return '
140
+		$filters[] = ob_get_contents();
141
+		ob_end_clean();
142
+		return $filters;
143
+	}
144
+
145
+
146
+	/**
147
+	 *_add_view_counts
148
+	 */
149
+	protected function _add_view_counts()
150
+	{
151
+		foreach ($this->_views as $view) {
152
+			$this->_views[ $view['slug'] ]['count'] = $this->_admin_page->get_transactions($this->_per_page, true, $view['slug']);
153
+		}
154
+	}
155
+
156
+
157
+	/**
158
+	 *    column TXN_ID
159
+	 *
160
+	 * @param \EE_Transaction $transaction
161
+	 * @return string
162
+	 * @throws \EE_Error
163
+	 */
164
+	public function column_TXN_ID(EE_Transaction $transaction)
165
+	{
166
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
167
+			array(
168
+				'action' => 'view_transaction',
169
+				'TXN_ID' => $transaction->ID(),
170
+			),
171
+			TXN_ADMIN_URL
172
+		);
173
+		$content = '<a href="' . $view_lnk_url . '"'
174
+				   . ' title="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">'
175
+				   . $transaction->ID()
176
+				   . '</a>';
177
+
178
+		// txn timestamp
179
+		$content .= '  <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>';
180
+		return $content;
181
+	}
182
+
183
+
184
+	/**
185
+	 * @param \EE_Transaction $transaction
186
+	 * @return string
187
+	 * @throws EE_Error
188
+	 * @throws InvalidArgumentException
189
+	 * @throws InvalidDataTypeException
190
+	 * @throws InvalidInterfaceException
191
+	 */
192
+	protected function _get_txn_timestamp(EE_Transaction $transaction)
193
+	{
194
+		// is TXN less than 2 hours old ?
195
+		if (
196
+			($transaction->failed() || $transaction->is_abandoned())
197
+			&& $this->session_lifespan->expiration() < $transaction->datetime(false, true)
198
+		) {
199
+			$timestamp = esc_html__('TXN in progress...', 'event_espresso');
200
+		} else {
201
+			$timestamp = $transaction->get_i18n_datetime('TXN_timestamp');
202
+		}
203
+		return $timestamp;
204
+	}
205
+
206
+
207
+	/**
208
+	 *    column_cb
209
+	 *
210
+	 * @param \EE_Transaction $transaction
211
+	 * @return string
212
+	 * @throws \EE_Error
213
+	 */
214
+	public function column_cb($transaction)
215
+	{
216
+		return sprintf(
217
+			'<input type="checkbox" name="%1$s[]" value="%2$s" />',
218
+			$this->_wp_list_args['singular'],
219
+			$transaction->ID()
220
+		);
221
+	}
222
+
223
+
224
+	/**
225
+	 *    column_TXN_timestamp
226
+	 *
227
+	 * @param \EE_Transaction $transaction
228
+	 * @return string
229
+	 * @throws \EE_Error
230
+	 */
231
+	public function column_TXN_timestamp(EE_Transaction $transaction)
232
+	{
233
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
234
+			array(
235
+				'action' => 'view_transaction',
236
+				'TXN_ID' => $transaction->ID(),
237
+			),
238
+			TXN_ADMIN_URL
239
+		);
240
+		$txn_date = '<a href="' . $view_lnk_url . '"'
241
+					. ' title="'
242
+					. esc_attr__('View Transaction Details for TXN #', 'event_espresso') . $transaction->ID() . '">'
243
+					. $this->_get_txn_timestamp($transaction)
244
+					. '</a>';
245
+		// status
246
+		$txn_date .= '<br><span class="ee-status-text-small">'
247
+					. EEH_Template::pretty_status(
248
+						$transaction->status_ID(),
249
+						false,
250
+						'sentence'
251
+					)
252
+					 . '</span>';
253
+		return $txn_date;
254
+	}
255
+
256
+
257
+	/**
258
+	 *    column_TXN_total
259
+	 *
260
+	 * @param \EE_Transaction $transaction
261
+	 * @return string
262
+	 * @throws \EE_Error
263
+	 */
264
+	public function column_TXN_total(EE_Transaction $transaction)
265
+	{
266
+		if ($transaction->get('TXN_total') > 0) {
267
+			return '<span class="txn-pad-rght">'
268
+				   . apply_filters(
269
+					   'FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total',
270
+					   $transaction->get_pretty('TXN_total'),
271
+					   $transaction
272
+				   )
273
+				   . '</span>';
274
+		} else {
275
+			return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
276
+		}
277
+	}
278
+
279
+
280
+	/**
281
+	 *    column_TXN_paid
282
+	 *
283
+	 * @param \EE_Transaction $transaction
284
+	 * @return mixed|string
285
+	 * @throws \EE_Error
286
+	 */
287
+	public function column_TXN_paid(EE_Transaction $transaction)
288
+	{
289
+		$transaction_total = $transaction->get('TXN_total');
290
+		$transaction_paid = $transaction->get('TXN_paid');
291
+
292
+		if (\EEH_Money::compare_floats($transaction_total, 0, '>')) {
293
+			// monies owing
294
+			$span_class = 'txn-overview-part-payment-spn';
295
+			if (\EEH_Money::compare_floats($transaction_paid, $transaction_total, '>=')) {
296
+				// paid in full
297
+				$span_class = 'txn-overview-full-payment-spn';
298
+			} elseif (\EEH_Money::compare_floats($transaction_paid, 0, '==')) {
299
+				// no payments made
300
+				$span_class = 'txn-overview-no-payment-spn';
301
+			}
302
+		} else {
303
+			// transaction_total == 0 so this is a free event
304
+			$span_class = 'txn-overview-free-event-spn';
305
+		}
306
+
307
+		$payment_method = $transaction->payment_method();
308
+		$payment_method_name = $payment_method instanceof EE_Payment_Method
309
+			? $payment_method->admin_name()
310
+			: esc_html__('Unknown', 'event_espresso');
311
+
312
+		$content = '<span class="' . $span_class . ' txn-pad-rght">'
313
+				   . $transaction->get_pretty('TXN_paid')
314
+				   . '</span>';
315
+		if ($transaction_paid > 0) {
316
+			$content .= '<br><span class="ee-status-text-small">'
317
+						. sprintf(
318
+							esc_html__('...via %s', 'event_espresso'),
319
+							$payment_method_name
320
+						)
321
+						. '</span>';
322
+		}
323
+		return $content;
324
+	}
325
+
326
+
327
+	/**
328
+	 *    column_ATT_fname
329
+	 *
330
+	 * @param \EE_Transaction $transaction
331
+	 * @return string
332
+	 * @throws EE_Error
333
+	 * @throws InvalidArgumentException
334
+	 * @throws InvalidDataTypeException
335
+	 * @throws InvalidInterfaceException
336
+	 */
337
+	public function column_ATT_fname(EE_Transaction $transaction)
338
+	{
339
+		$primary_reg = $transaction->primary_registration();
340
+		$attendee = $primary_reg->get_first_related('Attendee');
341
+		if ($attendee instanceof EE_Attendee) {
342
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
343
+				array(
344
+					'action'  => 'view_registration',
345
+					'_REG_ID' => $primary_reg->ID(),
346
+				),
347
+				REG_ADMIN_URL
348
+			);
349
+			$content = EE_Registry::instance()->CAP->current_user_can(
350
+				'ee_read_registration',
351
+				'espresso_registrations_view_registration',
352
+				$primary_reg->ID()
353
+			)
354
+				? '<a href="' . $edit_lnk_url . '"'
355
+				  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
356
+				  . $attendee->full_name()
357
+				  . '</a>'
358
+				: $attendee->full_name();
359
+			$content .= '<br>' . $attendee->email();
360
+			return $content;
361
+		}
362
+		return $transaction->failed() || $transaction->is_abandoned()
363
+			? esc_html__('no contact record.', 'event_espresso')
364
+			: esc_html__(
365
+				'No contact record, because the transaction was abandoned or the registration process failed.',
366
+				'event_espresso'
367
+			);
368
+	}
369
+
370
+
371
+	/**
372
+	 *    column_ATT_email
373
+	 *
374
+	 * @param \EE_Transaction $transaction
375
+	 * @return string
376
+	 * @throws \EE_Error
377
+	 */
378
+	public function column_ATT_email(EE_Transaction $transaction)
379
+	{
380
+		$attendee = $transaction->primary_registration()->get_first_related('Attendee');
381
+		if (! empty($attendee)) {
382
+			return '<a href="mailto:' . $attendee->get('ATT_email') . '">'
383
+				   . $attendee->get('ATT_email')
384
+				   . '</a>';
385
+		} else {
386
+			return $transaction->failed() || $transaction->is_abandoned()
387
+				? esc_html__('no contact record.', 'event_espresso')
388
+				: esc_html__(
389
+					'No contact record, because the transaction was abandoned or the registration process failed.',
390
+					'event_espresso'
391
+				);
392
+		}
393
+	}
394
+
395
+
396
+	/**
397
+	 *    column_event_name
398
+	 *
399
+	 * @param \EE_Transaction $transaction
400
+	 * @return string
401
+	 * @throws EE_Error
402
+	 * @throws InvalidArgumentException
403
+	 * @throws InvalidDataTypeException
404
+	 * @throws InvalidInterfaceException
405
+	 */
406
+	public function column_event_name(EE_Transaction $transaction)
407
+	{
408
+		$actions = array();
409
+		$event = $transaction->primary_registration()->get_first_related('Event');
410
+		if (! empty($event)) {
411
+			$edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
412
+				array('action' => 'edit', 'post' => $event->ID()),
413
+				EVENTS_ADMIN_URL
414
+			);
415
+			$event_name = $event->get('EVT_name');
416
+
417
+			// filter this view by transactions for this event
418
+			$txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce(
419
+				array(
420
+					'action' => 'default',
421
+					'EVT_ID' => $event->ID(),
422
+				)
423
+			);
424
+			if (
425
+				empty($this->_req_data['EVT_ID'])
426
+				&& EE_Registry::instance()->CAP->current_user_can(
427
+					'ee_edit_event',
428
+					'espresso_events_edit',
429
+					$event->ID()
430
+				)
431
+			) {
432
+				$actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '"'
433
+											  . ' title="' . esc_attr__(
434
+												  'Filter transactions by this event',
435
+												  'event_espresso'
436
+											  ) . '">'
437
+											  . esc_html__('View Transactions for this event', 'event_espresso')
438
+											  . '</a>';
439
+			}
440
+
441
+			return sprintf(
442
+				'%1$s %2$s',
443
+				EE_Registry::instance()->CAP->current_user_can(
444
+					'ee_edit_event',
445
+					'espresso_events_edit',
446
+					$event->ID()
447
+				)
448
+					? '<a href="' . $edit_event_url . '"'
449
+					  . ' title="'
450
+					  . sprintf(
451
+						  esc_attr__('Edit Event: %s', 'event_espresso'),
452
+						  $event->get('EVT_name')
453
+					  )
454
+					  . '">'
455
+					  . wp_trim_words(
456
+						  $event_name,
457
+						  30,
458
+						  '...'
459
+					  )
460
+					  . '</a>'
461
+					: wp_trim_words($event_name, 30, '...'),
462
+				$this->row_actions($actions)
463
+			);
464
+		} else {
465
+			return esc_html__(
466
+				'The event associated with this transaction via the primary registration cannot be retrieved.',
467
+				'event_espresso'
468
+			);
469
+		}
470
+	}
471
+
472
+
473
+	/**
474
+	 *    column_actions
475
+	 *
476
+	 * @param \EE_Transaction $transaction
477
+	 * @return string
478
+	 * @throws \EE_Error
479
+	 */
480
+	public function column_actions(EE_Transaction $transaction)
481
+	{
482
+		return $this->_action_string(
483
+			$this->get_transaction_details_link($transaction)
484
+			. $this->get_invoice_link($transaction)
485
+			. $this->get_receipt_link($transaction)
486
+			. $this->get_primary_registration_details_link($transaction)
487
+			. $this->get_send_payment_reminder_trigger_link($transaction)
488
+			. $this->get_payment_overview_link($transaction)
489
+			. $this->get_related_messages_link($transaction),
490
+			$transaction,
491
+			'ul',
492
+			'txn-overview-actions-ul'
493
+		);
494
+	}
495
+
496
+
497
+	/**
498
+	 * Get the transaction details link.
499
+	 *
500
+	 * @param EE_Transaction $transaction
501
+	 * @return string
502
+	 * @throws EE_Error
503
+	 */
504
+	protected function get_transaction_details_link(EE_Transaction $transaction)
505
+	{
506
+		$url = EE_Admin_Page::add_query_args_and_nonce(
507
+			array(
508
+				'action' => 'view_transaction',
509
+				'TXN_ID' => $transaction->ID(),
510
+			),
511
+			TXN_ADMIN_URL
512
+		);
513
+		return '
514 514
 			<li>
515 515
 				<a href="' . $url . '"'
516
-               . ' title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text">
516
+			   . ' title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text">
517 517
 					<span class="dashicons dashicons-cart"></span>
518 518
 				</a>
519 519
 			</li>';
520
-    }
521
-
522
-
523
-    /**
524
-     * Get the invoice link for the given registration.
525
-     *
526
-     * @param EE_Transaction $transaction
527
-     * @return string
528
-     * @throws EE_Error
529
-     */
530
-    protected function get_invoice_link(EE_Transaction $transaction)
531
-    {
532
-        $registration = $transaction->primary_registration();
533
-        if ($registration instanceof EE_Registration) {
534
-            $url = $registration->invoice_url();
535
-            // only show invoice link if message type is active.
536
-            if (
537
-                $registration->attendee() instanceof EE_Attendee
538
-                && EEH_MSG_Template::is_mt_active('invoice')
539
-            ) {
540
-                return '
520
+	}
521
+
522
+
523
+	/**
524
+	 * Get the invoice link for the given registration.
525
+	 *
526
+	 * @param EE_Transaction $transaction
527
+	 * @return string
528
+	 * @throws EE_Error
529
+	 */
530
+	protected function get_invoice_link(EE_Transaction $transaction)
531
+	{
532
+		$registration = $transaction->primary_registration();
533
+		if ($registration instanceof EE_Registration) {
534
+			$url = $registration->invoice_url();
535
+			// only show invoice link if message type is active.
536
+			if (
537
+				$registration->attendee() instanceof EE_Attendee
538
+				&& EEH_MSG_Template::is_mt_active('invoice')
539
+			) {
540
+				return '
541 541
                 <li>
542 542
                     <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso') . '"'
543
-                       . ' target="_blank" href="' . $url . '" class="tiny-text">
543
+					   . ' target="_blank" href="' . $url . '" class="tiny-text">
544 544
                         <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
545 545
                     </a>
546 546
                 </li>';
547
-            }
548
-        }
549
-        return '';
550
-    }
551
-
552
-
553
-    /**
554
-     * Get the receipt link for the transaction.
555
-     *
556
-     * @param EE_Transaction $transaction
557
-     * @return string
558
-     * @throws EE_Error
559
-     */
560
-    protected function get_receipt_link(EE_Transaction $transaction)
561
-    {
562
-        $registration = $transaction->primary_registration();
563
-        if ($registration instanceof EE_Registration) {
564
-            $url = $registration->receipt_url();
565
-            // only show receipt link if message type is active.
566
-            if (
567
-                $registration->attendee() instanceof EE_Attendee
568
-                && EEH_MSG_Template::is_mt_active('receipt')
569
-            ) {
570
-                return '
547
+			}
548
+		}
549
+		return '';
550
+	}
551
+
552
+
553
+	/**
554
+	 * Get the receipt link for the transaction.
555
+	 *
556
+	 * @param EE_Transaction $transaction
557
+	 * @return string
558
+	 * @throws EE_Error
559
+	 */
560
+	protected function get_receipt_link(EE_Transaction $transaction)
561
+	{
562
+		$registration = $transaction->primary_registration();
563
+		if ($registration instanceof EE_Registration) {
564
+			$url = $registration->receipt_url();
565
+			// only show receipt link if message type is active.
566
+			if (
567
+				$registration->attendee() instanceof EE_Attendee
568
+				&& EEH_MSG_Template::is_mt_active('receipt')
569
+			) {
570
+				return '
571 571
 			<li>
572 572
 				<a title="' . esc_attr__('View Transaction Receipt', 'event_espresso') . '"'
573
-                       . ' target="_blank" href="' . $url . '" class="tiny-text">
573
+					   . ' target="_blank" href="' . $url . '" class="tiny-text">
574 574
 					<span class="dashicons dashicons-media-default ee-icon-size-18"></span>
575 575
 				</a>
576 576
 			</li>';
577
-            }
578
-        }
579
-        return '';
580
-    }
581
-
582
-
583
-    /**
584
-     * Get the link to view the details for the primary registration.
585
-     *
586
-     * @param EE_Transaction $transaction
587
-     * @return string
588
-     * @throws EE_Error
589
-     * @throws InvalidArgumentException
590
-     * @throws InvalidDataTypeException
591
-     * @throws InvalidInterfaceException
592
-     */
593
-    protected function get_primary_registration_details_link(EE_Transaction $transaction)
594
-    {
595
-        $registration = $transaction->primary_registration();
596
-        if ($registration instanceof EE_Registration) {
597
-            $url = EE_Admin_Page::add_query_args_and_nonce(
598
-                array(
599
-                    'action'  => 'view_registration',
600
-                    '_REG_ID' => $registration->ID(),
601
-                ),
602
-                REG_ADMIN_URL
603
-            );
604
-            return EE_Registry::instance()->CAP->current_user_can(
605
-                'ee_read_registration',
606
-                'espresso_registrations_view_registration',
607
-                $registration->ID()
608
-            )
609
-                ? '
577
+			}
578
+		}
579
+		return '';
580
+	}
581
+
582
+
583
+	/**
584
+	 * Get the link to view the details for the primary registration.
585
+	 *
586
+	 * @param EE_Transaction $transaction
587
+	 * @return string
588
+	 * @throws EE_Error
589
+	 * @throws InvalidArgumentException
590
+	 * @throws InvalidDataTypeException
591
+	 * @throws InvalidInterfaceException
592
+	 */
593
+	protected function get_primary_registration_details_link(EE_Transaction $transaction)
594
+	{
595
+		$registration = $transaction->primary_registration();
596
+		if ($registration instanceof EE_Registration) {
597
+			$url = EE_Admin_Page::add_query_args_and_nonce(
598
+				array(
599
+					'action'  => 'view_registration',
600
+					'_REG_ID' => $registration->ID(),
601
+				),
602
+				REG_ADMIN_URL
603
+			);
604
+			return EE_Registry::instance()->CAP->current_user_can(
605
+				'ee_read_registration',
606
+				'espresso_registrations_view_registration',
607
+				$registration->ID()
608
+			)
609
+				? '
610 610
 				<li>
611 611
 					<a href="' . $url . '"'
612
-                  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
612
+				  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
613 613
 						<span class="dashicons dashicons-clipboard"></span>
614 614
 					</a>
615 615
 				</li>'
616
-                : '';
617
-        }
618
-        return '';
619
-    }
620
-
621
-
622
-    /**
623
-     * Get send payment reminder trigger link
624
-     *
625
-     * @param EE_Transaction $transaction
626
-     * @return string
627
-     * @throws EE_Error
628
-     * @throws InvalidArgumentException
629
-     * @throws InvalidDataTypeException
630
-     * @throws InvalidInterfaceException
631
-     */
632
-    protected function get_send_payment_reminder_trigger_link(EE_Transaction $transaction)
633
-    {
634
-        $registration = $transaction->primary_registration();
635
-        if (
636
-            $registration instanceof EE_Registration
637
-            && $registration->attendee() instanceof EE_Attendee
638
-            && EEH_MSG_Template::is_mt_active('payment_reminder')
639
-            && ! in_array(
640
-                $transaction->status_ID(),
641
-                array(EEM_Transaction::complete_status_code, EEM_Transaction::overpaid_status_code),
642
-                true
643
-            )
644
-            && EE_Registry::instance()->CAP->current_user_can(
645
-                'ee_send_message',
646
-                'espresso_transactions_send_payment_reminder'
647
-            )
648
-        ) {
649
-            $url = EE_Admin_Page::add_query_args_and_nonce(
650
-                array(
651
-                    'action' => 'send_payment_reminder',
652
-                    'TXN_ID' => $transaction->ID(),
653
-                ),
654
-                TXN_ADMIN_URL
655
-            );
656
-            return '
616
+				: '';
617
+		}
618
+		return '';
619
+	}
620
+
621
+
622
+	/**
623
+	 * Get send payment reminder trigger link
624
+	 *
625
+	 * @param EE_Transaction $transaction
626
+	 * @return string
627
+	 * @throws EE_Error
628
+	 * @throws InvalidArgumentException
629
+	 * @throws InvalidDataTypeException
630
+	 * @throws InvalidInterfaceException
631
+	 */
632
+	protected function get_send_payment_reminder_trigger_link(EE_Transaction $transaction)
633
+	{
634
+		$registration = $transaction->primary_registration();
635
+		if (
636
+			$registration instanceof EE_Registration
637
+			&& $registration->attendee() instanceof EE_Attendee
638
+			&& EEH_MSG_Template::is_mt_active('payment_reminder')
639
+			&& ! in_array(
640
+				$transaction->status_ID(),
641
+				array(EEM_Transaction::complete_status_code, EEM_Transaction::overpaid_status_code),
642
+				true
643
+			)
644
+			&& EE_Registry::instance()->CAP->current_user_can(
645
+				'ee_send_message',
646
+				'espresso_transactions_send_payment_reminder'
647
+			)
648
+		) {
649
+			$url = EE_Admin_Page::add_query_args_and_nonce(
650
+				array(
651
+					'action' => 'send_payment_reminder',
652
+					'TXN_ID' => $transaction->ID(),
653
+				),
654
+				TXN_ADMIN_URL
655
+			);
656
+			return '
657 657
             <li>
658 658
                 <a href="' . $url . '"'
659
-                   . ' title="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" class="tiny-text">
659
+				   . ' title="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" class="tiny-text">
660 660
                     <span class="dashicons dashicons-email-alt"></span>
661 661
                 </a>
662 662
             </li>';
663
-        }
664
-        return '';
665
-    }
666
-
667
-
668
-    /**
669
-     * Get link to filtered view in the message activity list table of messages for this transaction.
670
-     *
671
-     * @param EE_Transaction $transaction
672
-     * @return string
673
-     * @throws EE_Error
674
-     * @throws InvalidArgumentException
675
-     * @throws InvalidDataTypeException
676
-     * @throws InvalidInterfaceException
677
-     */
678
-    protected function get_related_messages_link(EE_Transaction $transaction)
679
-    {
680
-        $url = EEH_MSG_Template::get_message_action_link(
681
-            'see_notifications_for',
682
-            null,
683
-            array('TXN_ID' => $transaction->ID())
684
-        );
685
-        return EE_Registry::instance()->CAP->current_user_can(
686
-            'ee_read_global_messages',
687
-            'view_filtered_messages'
688
-        )
689
-            ? '<li>' . $url . '</li>'
690
-            : '';
691
-    }
692
-
693
-
694
-    /**
695
-     * Return the link to make a payment on the frontend
696
-     *
697
-     * @param EE_Transaction $transaction
698
-     * @return string
699
-     * @throws EE_Error
700
-     */
701
-    protected function get_payment_overview_link(EE_Transaction $transaction)
702
-    {
703
-        $registration = $transaction->primary_registration();
704
-        if (
705
-            $registration instanceof EE_Registration
706
-            && $transaction->status_ID() !== EEM_Transaction::complete_status_code
707
-            && $registration->owes_monies_and_can_pay()
708
-        ) {
709
-            return '
663
+		}
664
+		return '';
665
+	}
666
+
667
+
668
+	/**
669
+	 * Get link to filtered view in the message activity list table of messages for this transaction.
670
+	 *
671
+	 * @param EE_Transaction $transaction
672
+	 * @return string
673
+	 * @throws EE_Error
674
+	 * @throws InvalidArgumentException
675
+	 * @throws InvalidDataTypeException
676
+	 * @throws InvalidInterfaceException
677
+	 */
678
+	protected function get_related_messages_link(EE_Transaction $transaction)
679
+	{
680
+		$url = EEH_MSG_Template::get_message_action_link(
681
+			'see_notifications_for',
682
+			null,
683
+			array('TXN_ID' => $transaction->ID())
684
+		);
685
+		return EE_Registry::instance()->CAP->current_user_can(
686
+			'ee_read_global_messages',
687
+			'view_filtered_messages'
688
+		)
689
+			? '<li>' . $url . '</li>'
690
+			: '';
691
+	}
692
+
693
+
694
+	/**
695
+	 * Return the link to make a payment on the frontend
696
+	 *
697
+	 * @param EE_Transaction $transaction
698
+	 * @return string
699
+	 * @throws EE_Error
700
+	 */
701
+	protected function get_payment_overview_link(EE_Transaction $transaction)
702
+	{
703
+		$registration = $transaction->primary_registration();
704
+		if (
705
+			$registration instanceof EE_Registration
706
+			&& $transaction->status_ID() !== EEM_Transaction::complete_status_code
707
+			&& $registration->owes_monies_and_can_pay()
708
+		) {
709
+			return '
710 710
             <li>
711 711
                 <a title="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso') . '"'
712
-                   . ' target="_blank" href="' . $registration->payment_overview_url(true) . '"'
713
-                   . ' class="tiny-text">
712
+				   . ' target="_blank" href="' . $registration->payment_overview_url(true) . '"'
713
+				   . ' class="tiny-text">
714 714
                     <span class="dashicons dashicons-money ee-icon-size-18"></span>
715 715
                 </a>
716 716
             </li>
717 717
             ';
718
-        }
719
-        return '';
720
-    }
718
+		}
719
+		return '';
720
+	}
721 721
 }
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     {
97 97
         $class = parent::_get_row_class($transaction);
98 98
         // add status class
99
-        $class .= ' ee-status-strip txn-status-' . $transaction->status_ID();
99
+        $class .= ' ee-status-strip txn-status-'.$transaction->status_ID();
100 100
         if ($this->_has_checkbox_column) {
101 101
             $class .= ' has-checkbox-column';
102 102
         }
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
     protected function _add_view_counts()
150 150
     {
151 151
         foreach ($this->_views as $view) {
152
-            $this->_views[ $view['slug'] ]['count'] = $this->_admin_page->get_transactions($this->_per_page, true, $view['slug']);
152
+            $this->_views[$view['slug']]['count'] = $this->_admin_page->get_transactions($this->_per_page, true, $view['slug']);
153 153
         }
154 154
     }
155 155
 
@@ -170,13 +170,13 @@  discard block
 block discarded – undo
170 170
             ),
171 171
             TXN_ADMIN_URL
172 172
         );
173
-        $content = '<a href="' . $view_lnk_url . '"'
174
-                   . ' title="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">'
173
+        $content = '<a href="'.$view_lnk_url.'"'
174
+                   . ' title="'.esc_attr__('Go to Transaction Details', 'event_espresso').'">'
175 175
                    . $transaction->ID()
176 176
                    . '</a>';
177 177
 
178 178
         // txn timestamp
179
-        $content .= '  <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>';
179
+        $content .= '  <span class="show-on-mobile-view-only">'.$this->_get_txn_timestamp($transaction).'</span>';
180 180
         return $content;
181 181
     }
182 182
 
@@ -237,9 +237,9 @@  discard block
 block discarded – undo
237 237
             ),
238 238
             TXN_ADMIN_URL
239 239
         );
240
-        $txn_date = '<a href="' . $view_lnk_url . '"'
240
+        $txn_date = '<a href="'.$view_lnk_url.'"'
241 241
                     . ' title="'
242
-                    . esc_attr__('View Transaction Details for TXN #', 'event_espresso') . $transaction->ID() . '">'
242
+                    . esc_attr__('View Transaction Details for TXN #', 'event_espresso').$transaction->ID().'">'
243 243
                     . $this->_get_txn_timestamp($transaction)
244 244
                     . '</a>';
245 245
         // status
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
                    )
273 273
                    . '</span>';
274 274
         } else {
275
-            return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
275
+            return '<span class="txn-overview-free-event-spn">'.esc_html__('free', 'event_espresso').'</span>';
276 276
         }
277 277
     }
278 278
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
             ? $payment_method->admin_name()
310 310
             : esc_html__('Unknown', 'event_espresso');
311 311
 
312
-        $content = '<span class="' . $span_class . ' txn-pad-rght">'
312
+        $content = '<span class="'.$span_class.' txn-pad-rght">'
313 313
                    . $transaction->get_pretty('TXN_paid')
314 314
                    . '</span>';
315 315
         if ($transaction_paid > 0) {
@@ -351,12 +351,12 @@  discard block
 block discarded – undo
351 351
                 'espresso_registrations_view_registration',
352 352
                 $primary_reg->ID()
353 353
             )
354
-                ? '<a href="' . $edit_lnk_url . '"'
355
-                  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
354
+                ? '<a href="'.$edit_lnk_url.'"'
355
+                  . ' title="'.esc_attr__('View Registration Details', 'event_espresso').'">'
356 356
                   . $attendee->full_name()
357 357
                   . '</a>'
358 358
                 : $attendee->full_name();
359
-            $content .= '<br>' . $attendee->email();
359
+            $content .= '<br>'.$attendee->email();
360 360
             return $content;
361 361
         }
362 362
         return $transaction->failed() || $transaction->is_abandoned()
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
     public function column_ATT_email(EE_Transaction $transaction)
379 379
     {
380 380
         $attendee = $transaction->primary_registration()->get_first_related('Attendee');
381
-        if (! empty($attendee)) {
382
-            return '<a href="mailto:' . $attendee->get('ATT_email') . '">'
381
+        if ( ! empty($attendee)) {
382
+            return '<a href="mailto:'.$attendee->get('ATT_email').'">'
383 383
                    . $attendee->get('ATT_email')
384 384
                    . '</a>';
385 385
         } else {
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
     {
408 408
         $actions = array();
409 409
         $event = $transaction->primary_registration()->get_first_related('Event');
410
-        if (! empty($event)) {
410
+        if ( ! empty($event)) {
411 411
             $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
412 412
                 array('action' => 'edit', 'post' => $event->ID()),
413 413
                 EVENTS_ADMIN_URL
@@ -429,11 +429,11 @@  discard block
 block discarded – undo
429 429
                     $event->ID()
430 430
                 )
431 431
             ) {
432
-                $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '"'
433
-                                              . ' title="' . esc_attr__(
432
+                $actions['filter_by_event'] = '<a href="'.$txn_by_event_lnk.'"'
433
+                                              . ' title="'.esc_attr__(
434 434
                                                   'Filter transactions by this event',
435 435
                                                   'event_espresso'
436
-                                              ) . '">'
436
+                                              ).'">'
437 437
                                               . esc_html__('View Transactions for this event', 'event_espresso')
438 438
                                               . '</a>';
439 439
             }
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
                     'espresso_events_edit',
446 446
                     $event->ID()
447 447
                 )
448
-                    ? '<a href="' . $edit_event_url . '"'
448
+                    ? '<a href="'.$edit_event_url.'"'
449 449
                       . ' title="'
450 450
                       . sprintf(
451 451
                           esc_attr__('Edit Event: %s', 'event_espresso'),
@@ -512,8 +512,8 @@  discard block
 block discarded – undo
512 512
         );
513 513
         return '
514 514
 			<li>
515
-				<a href="' . $url . '"'
516
-               . ' title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text">
515
+				<a href="' . $url.'"'
516
+               . ' title="'.esc_attr__('View Transaction Details', 'event_espresso').'" class="tiny-text">
517 517
 					<span class="dashicons dashicons-cart"></span>
518 518
 				</a>
519 519
 			</li>';
@@ -539,8 +539,8 @@  discard block
 block discarded – undo
539 539
             ) {
540 540
                 return '
541 541
                 <li>
542
-                    <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso') . '"'
543
-                       . ' target="_blank" href="' . $url . '" class="tiny-text">
542
+                    <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso').'"'
543
+                       . ' target="_blank" href="'.$url.'" class="tiny-text">
544 544
                         <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
545 545
                     </a>
546 546
                 </li>';
@@ -569,8 +569,8 @@  discard block
 block discarded – undo
569 569
             ) {
570 570
                 return '
571 571
 			<li>
572
-				<a title="' . esc_attr__('View Transaction Receipt', 'event_espresso') . '"'
573
-                       . ' target="_blank" href="' . $url . '" class="tiny-text">
572
+				<a title="' . esc_attr__('View Transaction Receipt', 'event_espresso').'"'
573
+                       . ' target="_blank" href="'.$url.'" class="tiny-text">
574 574
 					<span class="dashicons dashicons-media-default ee-icon-size-18"></span>
575 575
 				</a>
576 576
 			</li>';
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
             )
609 609
                 ? '
610 610
 				<li>
611
-					<a href="' . $url . '"'
612
-                  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
611
+					<a href="' . $url.'"'
612
+                  . ' title="'.esc_attr__('View Registration Details', 'event_espresso').'" class="tiny-text">
613 613
 						<span class="dashicons dashicons-clipboard"></span>
614 614
 					</a>
615 615
 				</li>'
@@ -655,8 +655,8 @@  discard block
 block discarded – undo
655 655
             );
656 656
             return '
657 657
             <li>
658
-                <a href="' . $url . '"'
659
-                   . ' title="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" class="tiny-text">
658
+                <a href="' . $url.'"'
659
+                   . ' title="'.esc_attr__('Send Payment Reminder', 'event_espresso').'" class="tiny-text">
660 660
                     <span class="dashicons dashicons-email-alt"></span>
661 661
                 </a>
662 662
             </li>';
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
             'ee_read_global_messages',
687 687
             'view_filtered_messages'
688 688
         )
689
-            ? '<li>' . $url . '</li>'
689
+            ? '<li>'.$url.'</li>'
690 690
             : '';
691 691
     }
692 692
 
@@ -708,8 +708,8 @@  discard block
 block discarded – undo
708 708
         ) {
709 709
             return '
710 710
             <li>
711
-                <a title="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso') . '"'
712
-                   . ' target="_blank" href="' . $registration->payment_overview_url(true) . '"'
711
+                <a title="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso').'"'
712
+                   . ' target="_blank" href="'.$registration->payment_overview_url(true).'"'
713 713
                    . ' class="tiny-text">
714 714
                     <span class="dashicons dashicons-money ee-icon-size-18"></span>
715 715
                 </a>
Please login to merge, or discard this patch.
core/domain/services/validation/email/strategies/InternationalDNS.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
             $email_address,
35 35
             $this->getAtIndex($email_address)
36 36
         );
37
-        if (! checkdnsrr($domain, 'MX')) {
37
+        if ( ! checkdnsrr($domain, 'MX')) {
38 38
             // domain not found in MX records
39 39
             throw new EmailValidationException(
40 40
                 __(
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
                 )
46 46
             );
47 47
         }
48
-        if (! checkdnsrr($domain, 'A')) {
48
+        if ( ! checkdnsrr($domain, 'A')) {
49 49
             // domain not found in A records
50 50
             throw new EmailValidationException(
51 51
                 __(
Please login to merge, or discard this patch.
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -15,43 +15,43 @@
 block discarded – undo
15 15
 class InternationalDNS extends International
16 16
 {
17 17
 
18
-    /**
19
-     * Validates the email in teh same way as the parent, but also
20
-     * verifies the domain exists.
21
-     *
22
-     * @param string $email_address
23
-     * @return bool
24
-     * @throws EmailValidationException
25
-     */
26
-    public function validate($email_address)
27
-    {
28
-        parent::validate($email_address);
29
-        $domain = $this->getDomainPartOfEmail(
30
-            $email_address,
31
-            $this->getAtIndex($email_address)
32
-        );
33
-        if (! checkdnsrr($domain, 'MX')) {
34
-            // domain not found in MX records
35
-            throw new EmailValidationException(
36
-                __(
37
-                // @codingStandardsIgnoreStart
38
-                    'Although the email address provided is formatted correctly, a valid "MX record" could not be located for that address and domain. Please enter a valid email address.',
39
-                    // @codingStandardsIgnoreEnd
40
-                    'event_espresso'
41
-                )
42
-            );
43
-        }
44
-        if (! checkdnsrr($domain, 'A')) {
45
-            // domain not found in A records
46
-            throw new EmailValidationException(
47
-                __(
48
-                // @codingStandardsIgnoreStart
49
-                    'Although the email address provided is formatted correctly, a valid "A record" could not be located for that address and domain. Please enter a valid email address.',
50
-                    // @codingStandardsIgnoreEnd
51
-                    'event_espresso'
52
-                )
53
-            );
54
-        }
55
-        return true;
56
-    }
18
+	/**
19
+	 * Validates the email in teh same way as the parent, but also
20
+	 * verifies the domain exists.
21
+	 *
22
+	 * @param string $email_address
23
+	 * @return bool
24
+	 * @throws EmailValidationException
25
+	 */
26
+	public function validate($email_address)
27
+	{
28
+		parent::validate($email_address);
29
+		$domain = $this->getDomainPartOfEmail(
30
+			$email_address,
31
+			$this->getAtIndex($email_address)
32
+		);
33
+		if (! checkdnsrr($domain, 'MX')) {
34
+			// domain not found in MX records
35
+			throw new EmailValidationException(
36
+				__(
37
+				// @codingStandardsIgnoreStart
38
+					'Although the email address provided is formatted correctly, a valid "MX record" could not be located for that address and domain. Please enter a valid email address.',
39
+					// @codingStandardsIgnoreEnd
40
+					'event_espresso'
41
+				)
42
+			);
43
+		}
44
+		if (! checkdnsrr($domain, 'A')) {
45
+			// domain not found in A records
46
+			throw new EmailValidationException(
47
+				__(
48
+				// @codingStandardsIgnoreStart
49
+					'Although the email address provided is formatted correctly, a valid "A record" could not be located for that address and domain. Please enter a valid email address.',
50
+					// @codingStandardsIgnoreEnd
51
+					'event_espresso'
52
+				)
53
+			);
54
+		}
55
+		return true;
56
+	}
57 57
 }
Please login to merge, or discard this patch.
core/domain/services/validation/email/EmailValidatorInterface.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@
 block discarded – undo
18 18
 interface EmailValidatorInterface
19 19
 {
20 20
 
21
-    /**
22
-     * Validates the supplied email address. If it is invalid, throws EmailValidationException
23
-     *
24
-     * @param string $email_address
25
-     * @return boolean
26
-     * @throws EmailValidationException
27
-     */
28
-    public function validate($email_address);
21
+	/**
22
+	 * Validates the supplied email address. If it is invalid, throws EmailValidationException
23
+	 *
24
+	 * @param string $email_address
25
+	 * @return boolean
26
+	 * @throws EmailValidationException
27
+	 */
28
+	public function validate($email_address);
29 29
 
30 30
 
31 31
 }
Please login to merge, or discard this patch.
strategies/validation/EE_Email_Validation_Strategy.strategy.php 2 patches
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -18,72 +18,72 @@
 block discarded – undo
18 18
 {
19 19
 
20 20
 
21
-    /**
22
-     * @param string               $validation_error_message
23
-     */
24
-    public function __construct($validation_error_message = '')
25
-    {
26
-        if (! $validation_error_message) {
27
-            $validation_error_message = esc_html__('Please enter a valid email address.', 'event_espresso');
28
-        }
29
-        parent::__construct($validation_error_message);
30
-    }
21
+	/**
22
+	 * @param string               $validation_error_message
23
+	 */
24
+	public function __construct($validation_error_message = '')
25
+	{
26
+		if (! $validation_error_message) {
27
+			$validation_error_message = esc_html__('Please enter a valid email address.', 'event_espresso');
28
+		}
29
+		parent::__construct($validation_error_message);
30
+	}
31 31
 
32 32
 
33 33
 
34
-    /**
35
-     * just checks the field isn't blank
36
-     *
37
-     * @param $normalized_value
38
-     * @return bool
39
-     * @throws InvalidArgumentException
40
-     * @throws InvalidInterfaceException
41
-     * @throws InvalidDataTypeException
42
-     * @throws EE_Validation_Error
43
-     */
44
-    public function validate($normalized_value)
45
-    {
46
-        if ($normalized_value && ! $this->_validate_email($normalized_value)) {
47
-            throw new EE_Validation_Error($this->get_validation_error_message(), 'required');
48
-        }
49
-        return true;
50
-    }
34
+	/**
35
+	 * just checks the field isn't blank
36
+	 *
37
+	 * @param $normalized_value
38
+	 * @return bool
39
+	 * @throws InvalidArgumentException
40
+	 * @throws InvalidInterfaceException
41
+	 * @throws InvalidDataTypeException
42
+	 * @throws EE_Validation_Error
43
+	 */
44
+	public function validate($normalized_value)
45
+	{
46
+		if ($normalized_value && ! $this->_validate_email($normalized_value)) {
47
+			throw new EE_Validation_Error($this->get_validation_error_message(), 'required');
48
+		}
49
+		return true;
50
+	}
51 51
 
52 52
 
53 53
 
54
-    /**
55
-     * @return array
56
-     */
57
-    public function get_jquery_validation_rule_array()
58
-    {
59
-        return array('email' => true, 'messages' => array('email' => $this->get_validation_error_message()));
60
-    }
54
+	/**
55
+	 * @return array
56
+	 */
57
+	public function get_jquery_validation_rule_array()
58
+	{
59
+		return array('email' => true, 'messages' => array('email' => $this->get_validation_error_message()));
60
+	}
61 61
 
62 62
 
63 63
 
64
-    /**
65
-     * Validate an email address.
66
-     * Provide email address (raw input)
67
-     *
68
-     * @param $email
69
-     * @return bool of whether the email is valid or not
70
-     * @throws InvalidArgumentException
71
-     * @throws InvalidInterfaceException
72
-     * @throws InvalidDataTypeException
73
-     * @throws EE_Validation_Error
74
-     */
75
-    private function _validate_email($email)
76
-    {
77
-        try {
78
-            EmailAddressFactory::create($email);
79
-        } catch (EmailValidationException $e) {
80
-            throw new EE_Validation_Error(
81
-                $e->getMessage(),
82
-                'invalid_email',
83
-                $this->_input,
84
-                $e
85
-            );
86
-        }
87
-        return true;
88
-    }
64
+	/**
65
+	 * Validate an email address.
66
+	 * Provide email address (raw input)
67
+	 *
68
+	 * @param $email
69
+	 * @return bool of whether the email is valid or not
70
+	 * @throws InvalidArgumentException
71
+	 * @throws InvalidInterfaceException
72
+	 * @throws InvalidDataTypeException
73
+	 * @throws EE_Validation_Error
74
+	 */
75
+	private function _validate_email($email)
76
+	{
77
+		try {
78
+			EmailAddressFactory::create($email);
79
+		} catch (EmailValidationException $e) {
80
+			throw new EE_Validation_Error(
81
+				$e->getMessage(),
82
+				'invalid_email',
83
+				$this->_input,
84
+				$e
85
+			);
86
+		}
87
+		return true;
88
+	}
89 89
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
      */
24 24
     public function __construct($validation_error_message = '')
25 25
     {
26
-        if (! $validation_error_message) {
26
+        if ( ! $validation_error_message) {
27 27
             $validation_error_message = esc_html__('Please enter a valid email address.', 'event_espresso');
28 28
         }
29 29
         parent::__construct($validation_error_message);
Please login to merge, or discard this patch.
core/libraries/messages/messenger/EE_Email_messenger.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -456,7 +456,7 @@
 block discarded – undo
456 456
      * be empty
457 457
      *
458 458
      * @since 4.3.1
459
-     * @return array
459
+     * @return string[]
460 460
      */
461 461
     private function _parse_from()
462 462
     {
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
             ),
57 57
             '<code>wp_mail</code>'
58 58
         );
59
-        $this->label               = array(
59
+        $this->label = array(
60 60
             'singular' => esc_html__('email', 'event_espresso'),
61 61
             'plural'   => esc_html__('emails', 'event_espresso'),
62 62
         );
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
             $this->_body(),
439 439
             $this->_headers()
440 440
         );
441
-        if (! $success) {
441
+        if ( ! $success) {
442 442
             EE_Error::add_error(
443 443
                 sprintf(
444 444
                     esc_html__(
@@ -482,8 +482,8 @@  discard block
 block discarded – undo
482 482
         $this->_ensure_has_from_email_address();
483 483
         $from    = $this->_from;
484 484
         $headers = array(
485
-            'From:' . $from,
486
-            'Reply-To:' . $from,
485
+            'From:'.$from,
486
+            'Reply-To:'.$from,
487 487
             'Content-Type:text/html; charset=utf-8',
488 488
         );
489 489
 
@@ -492,8 +492,8 @@  discard block
 block discarded – undo
492 492
          * cover back compat where there may be users who have saved cc values in their db for the newsletter message
493 493
          * type which they are no longer able to change.
494 494
          */
495
-        if (! empty($this->_cc) && ! $this->_incoming_message_type instanceof EE_Newsletter_message_type) {
496
-            $headers[] = 'cc: ' . $this->_cc;
495
+        if ( ! empty($this->_cc) && ! $this->_incoming_message_type instanceof EE_Newsletter_message_type) {
496
+            $headers[] = 'cc: '.$this->_cc;
497 497
         }
498 498
 
499 499
         // but wait!  Header's for the from is NOT reliable because some plugins don't respect From: as set in the
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
             'from'      => $this->_from,
601 601
             'main_body' => wpautop($this->_content),
602 602
         );
603
-        $body                 = $this->_get_main_template($preview);
603
+        $body = $this->_get_main_template($preview);
604 604
 
605 605
         /**
606 606
          * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched.
@@ -610,10 +610,10 @@  discard block
 block discarded – undo
610 610
          */
611 611
         if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) {
612 612
             // require CssToInlineStyles library and its dependencies via composer autoloader
613
-            require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php';
613
+            require_once EE_THIRD_PARTY.'cssinliner/vendor/autoload.php';
614 614
 
615 615
             // now if this isn't a preview, let's setup the body so it has inline styles
616
-            if (! $preview || ($preview && defined('DOING_AJAX'))) {
616
+            if ( ! $preview || ($preview && defined('DOING_AJAX'))) {
617 617
                 $style = file_get_contents(
618 618
                     $this->get_variation(
619 619
                         $this->_tmp_pack,
Please login to merge, or discard this patch.
Indentation   +644 added lines, -644 removed lines patch added patch discarded remove patch
@@ -6,648 +6,648 @@
 block discarded – undo
6 6
 class EE_Email_messenger extends EE_messenger
7 7
 {
8 8
 
9
-    /**
10
-     * To field for email
11
-     * @var string
12
-     */
13
-    protected $_to = '';
14
-
15
-
16
-    /**
17
-     * CC field for email.
18
-     * @var string
19
-     */
20
-    protected $_cc = '';
21
-
22
-    /**
23
-     * From field for email
24
-     * @var string
25
-     */
26
-    protected $_from = '';
27
-
28
-
29
-    /**
30
-     * Subject field for email
31
-     * @var string
32
-     */
33
-    protected $_subject = '';
34
-
35
-
36
-    /**
37
-     * Content field for email
38
-     * @var string
39
-     */
40
-    protected $_content = '';
41
-
42
-
43
-    /**
44
-     * constructor
45
-     *
46
-     * @access public
47
-     */
48
-    public function __construct()
49
-    {
50
-        // set name and description properties
51
-        $this->name                = 'email';
52
-        $this->description         = sprintf(
53
-            esc_html__(
54
-                'This messenger delivers messages via email using the built-in %s function included with WordPress',
55
-                'event_espresso'
56
-            ),
57
-            '<code>wp_mail</code>'
58
-        );
59
-        $this->label               = array(
60
-            'singular' => esc_html__('email', 'event_espresso'),
61
-            'plural'   => esc_html__('emails', 'event_espresso'),
62
-        );
63
-        $this->activate_on_install = true;
64
-
65
-        // we're using defaults so let's call parent constructor that will take care of setting up all the other
66
-        // properties
67
-        parent::__construct();
68
-    }
69
-
70
-
71
-    /**
72
-     * see abstract declaration in parent class for details.
73
-     */
74
-    protected function _set_admin_pages()
75
-    {
76
-        $this->admin_registered_pages = array(
77
-            'events_edit' => true,
78
-        );
79
-    }
80
-
81
-
82
-    /**
83
-     * see abstract declaration in parent class for details
84
-     */
85
-    protected function _set_valid_shortcodes()
86
-    {
87
-        // remember by leaving the other fields not set, those fields will inherit the valid shortcodes from the
88
-        // message type.
89
-        $this->_valid_shortcodes = array(
90
-            'to'   => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
91
-            'cc' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
92
-            'from' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
93
-        );
94
-    }
95
-
96
-
97
-    /**
98
-     * see abstract declaration in parent class for details
99
-     *
100
-     * @access protected
101
-     * @return void
102
-     */
103
-    protected function _set_validator_config()
104
-    {
105
-        $valid_shortcodes = $this->get_valid_shortcodes();
106
-
107
-        $this->_validator_config = array(
108
-            'to'            => array(
109
-                'shortcodes' => $valid_shortcodes['to'],
110
-                'type'       => 'email',
111
-            ),
112
-            'cc' => array(
113
-                'shortcodes' => $valid_shortcodes['to'],
114
-                'type' => 'email',
115
-            ),
116
-            'from'          => array(
117
-                'shortcodes' => $valid_shortcodes['from'],
118
-                'type'       => 'email',
119
-            ),
120
-            'subject'       => array(
121
-                'shortcodes' => array(
122
-                    'organization',
123
-                    'primary_registration_details',
124
-                    'event_author',
125
-                    'primary_registration_details',
126
-                    'recipient_details',
127
-                ),
128
-            ),
129
-            'content'       => array(
130
-                'shortcodes' => array(
131
-                    'event_list',
132
-                    'attendee_list',
133
-                    'ticket_list',
134
-                    'organization',
135
-                    'primary_registration_details',
136
-                    'primary_registration_list',
137
-                    'event_author',
138
-                    'recipient_details',
139
-                    'recipient_list',
140
-                    'transaction',
141
-                    'messenger',
142
-                ),
143
-            ),
144
-            'attendee_list' => array(
145
-                'shortcodes' => array('attendee', 'event_list', 'ticket_list'),
146
-                'required'   => array('[ATTENDEE_LIST]'),
147
-            ),
148
-            'event_list'    => array(
149
-                'shortcodes' => array(
150
-                    'event',
151
-                    'attendee_list',
152
-                    'ticket_list',
153
-                    'venue',
154
-                    'datetime_list',
155
-                    'attendee',
156
-                    'primary_registration_details',
157
-                    'primary_registration_list',
158
-                    'event_author',
159
-                    'recipient_details',
160
-                    'recipient_list',
161
-                ),
162
-                'required'   => array('[EVENT_LIST]'),
163
-            ),
164
-            'ticket_list'   => array(
165
-                'shortcodes' => array(
166
-                    'event_list',
167
-                    'attendee_list',
168
-                    'ticket',
169
-                    'datetime_list',
170
-                    'primary_registration_details',
171
-                    'recipient_details',
172
-                ),
173
-                'required'   => array('[TICKET_LIST]'),
174
-            ),
175
-            'datetime_list' => array(
176
-                'shortcodes' => array('datetime'),
177
-                'required'   => array('[DATETIME_LIST]'),
178
-            ),
179
-        );
180
-    }
181
-
182
-
183
-    /**
184
-     * @see   parent EE_messenger class for docs
185
-     * @since 4.5.0
186
-     */
187
-    public function do_secondary_messenger_hooks($sending_messenger_name)
188
-    {
189
-        if ($sending_messenger_name === 'html') {
190
-            add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8);
191
-        }
192
-    }
193
-
194
-
195
-    public function add_email_css(
196
-        $variation_path,
197
-        $messenger,
198
-        $message_type,
199
-        $type,
200
-        $variation,
201
-        $file_extension,
202
-        $url,
203
-        EE_Messages_Template_Pack $template_pack
204
-    ) {
205
-        // prevent recursion on this callback.
206
-        remove_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10);
207
-        $variation = $this->get_variation($template_pack, $message_type, $url, 'main', $variation, false);
208
-
209
-        add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8);
210
-        return $variation;
211
-    }
212
-
213
-
214
-    /**
215
-     * See parent for details
216
-     *
217
-     * @access protected
218
-     * @return void
219
-     */
220
-    protected function _set_test_settings_fields()
221
-    {
222
-        $this->_test_settings_fields = array(
223
-            'to'      => array(
224
-                'input'      => 'text',
225
-                'label'      => esc_html__('Send a test email to', 'event_espresso'),
226
-                'type'       => 'email',
227
-                'required'   => true,
228
-                'validation' => true,
229
-                'css_class'  => 'large-text',
230
-                'format'     => '%s',
231
-                'default'    => get_bloginfo('admin_email'),
232
-            ),
233
-            'subject' => array(
234
-                'input'      => 'hidden',
235
-                'label'      => '',
236
-                'type'       => 'string',
237
-                'required'   => false,
238
-                'validation' => false,
239
-                'format'     => '%s',
240
-                'value'      => sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')),
241
-                'default'    => '',
242
-                'css_class'  => '',
243
-            ),
244
-        );
245
-    }
246
-
247
-
248
-    /**
249
-     * _set_template_fields
250
-     * This sets up the fields that a messenger requires for the message to go out.
251
-     *
252
-     * @access  protected
253
-     * @return void
254
-     */
255
-    protected function _set_template_fields()
256
-    {
257
-        // any extra template fields that are NOT used by the messenger but will get used by a messenger field for
258
-        // shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field
259
-        // they relate to.  This is important for the Messages_admin to know what fields to display to the user.
260
-        //  Also, notice that the "values" are equal to the field type that messages admin will use to know what
261
-        // kind of field to display. The values ALSO have one index labeled "shortcode".  the values in that array
262
-        // indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be
263
-        // displayed.  If the required shortcode isn't part of the shortcodes array then the field is not needed and
264
-        // will not be displayed/parsed.
265
-        $this->_template_fields = array(
266
-            'to'      => array(
267
-                'input'      => 'text',
268
-                'label'      => esc_html_x(
269
-                    'To',
270
-                    'Label for the "To" field for email addresses',
271
-                    'event_espresso'
272
-                ),
273
-                'type'       => 'string',
274
-                'required'   => true,
275
-                'validation' => true,
276
-                'css_class'  => 'large-text',
277
-                'format'     => '%s',
278
-            ),
279
-            'cc'      => array(
280
-                'input'      => 'text',
281
-                'label'      => esc_html_x(
282
-                    'CC',
283
-                    'Label for the "Carbon Copy" field used for additional email addresses',
284
-                    'event_espresso'
285
-                ),
286
-                'type'       => 'string',
287
-                'required'   => false,
288
-                'validation' => true,
289
-                'css_class'  => 'large-text',
290
-                'format'     => '%s',
291
-            ),
292
-            'from'    => array(
293
-                'input'      => 'text',
294
-                'label'      => esc_html_x(
295
-                    'From',
296
-                    'Label for the "From" field for email addresses.',
297
-                    'event_espresso'
298
-                ),
299
-                'type'       => 'string',
300
-                'required'   => true,
301
-                'validation' => true,
302
-                'css_class'  => 'large-text',
303
-                'format'     => '%s',
304
-            ),
305
-            'subject' => array(
306
-                'input'      => 'text',
307
-                'label'      => esc_html_x(
308
-                    'Subject',
309
-                    'Label for the "Subject" field (short description of contents) for emails.',
310
-                    'event_espresso'
311
-                ),
312
-                'type'       => 'string',
313
-                'required'   => true,
314
-                'validation' => true,
315
-                'css_class'  => 'large-text',
316
-                'format'     => '%s',
317
-            ),
318
-            'content' => '',
319
-            // left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field.
320
-            'extra'   => array(
321
-                'content' => array(
322
-                    'main'          => array(
323
-                        'input'      => 'wp_editor',
324
-                        'label'      => esc_html__('Main Content', 'event_espresso'),
325
-                        'type'       => 'string',
326
-                        'required'   => true,
327
-                        'validation' => true,
328
-                        'format'     => '%s',
329
-                        'rows'       => '15',
330
-                    ),
331
-                    'event_list'    => array(
332
-                        'input'               => 'wp_editor',
333
-                        'label'               => '[EVENT_LIST]',
334
-                        'type'                => 'string',
335
-                        'required'            => true,
336
-                        'validation'          => true,
337
-                        'format'              => '%s',
338
-                        'rows'                => '15',
339
-                        'shortcodes_required' => array('[EVENT_LIST]'),
340
-                    ),
341
-                    'attendee_list' => array(
342
-                        'input'               => 'textarea',
343
-                        'label'               => '[ATTENDEE_LIST]',
344
-                        'type'                => 'string',
345
-                        'required'            => true,
346
-                        'validation'          => true,
347
-                        'format'              => '%s',
348
-                        'css_class'           => 'large-text',
349
-                        'rows'                => '5',
350
-                        'shortcodes_required' => array('[ATTENDEE_LIST]'),
351
-                    ),
352
-                    'ticket_list'   => array(
353
-                        'input'               => 'textarea',
354
-                        'label'               => '[TICKET_LIST]',
355
-                        'type'                => 'string',
356
-                        'required'            => true,
357
-                        'validation'          => true,
358
-                        'format'              => '%s',
359
-                        'css_class'           => 'large-text',
360
-                        'rows'                => '10',
361
-                        'shortcodes_required' => array('[TICKET_LIST]'),
362
-                    ),
363
-                    'datetime_list' => array(
364
-                        'input'               => 'textarea',
365
-                        'label'               => '[DATETIME_LIST]',
366
-                        'type'                => 'string',
367
-                        'required'            => true,
368
-                        'validation'          => true,
369
-                        'format'              => '%s',
370
-                        'css_class'           => 'large-text',
371
-                        'rows'                => '10',
372
-                        'shortcodes_required' => array('[DATETIME_LIST]'),
373
-                    ),
374
-                ),
375
-            ),
376
-        );
377
-    }
378
-
379
-
380
-    /**
381
-     * See definition of this class in parent
382
-     */
383
-    protected function _set_default_message_types()
384
-    {
385
-        $this->_default_message_types = array(
386
-            'payment',
387
-            'payment_refund',
388
-            'registration',
389
-            'not_approved_registration',
390
-            'pending_approval',
391
-        );
392
-    }
393
-
394
-
395
-    /**
396
-     * @see   definition of this class in parent
397
-     * @since 4.5.0
398
-     */
399
-    protected function _set_valid_message_types()
400
-    {
401
-        $this->_valid_message_types = array(
402
-            'payment',
403
-            'registration',
404
-            'not_approved_registration',
405
-            'declined_registration',
406
-            'cancelled_registration',
407
-            'pending_approval',
408
-            'registration_summary',
409
-            'payment_reminder',
410
-            'payment_declined',
411
-            'payment_refund',
412
-        );
413
-    }
414
-
415
-
416
-    /**
417
-     * setting up admin_settings_fields for messenger.
418
-     */
419
-    protected function _set_admin_settings_fields()
420
-    {
421
-    }
422
-
423
-    /**
424
-     * We just deliver the messages don't kill us!!
425
-     *
426
-     * @return bool|WP_Error true if message delivered, false if it didn't deliver OR bubble up any error object if
427
-     *              present.
428
-     * @throws EE_Error
429
-     * @throws \TijsVerkoyen\CssToInlineStyles\Exception
430
-     */
431
-    protected function _send_message()
432
-    {
433
-        $success = wp_mail(
434
-            $this->_to,
435
-            // some old values for subject may be expecting HTML entities to be decoded in the subject
436
-            // and subjects aren't interpreted as HTML, so there should be no HTML in them
437
-            wp_strip_all_tags(wp_specialchars_decode($this->_subject, ENT_QUOTES)),
438
-            $this->_body(),
439
-            $this->_headers()
440
-        );
441
-        if (! $success) {
442
-            EE_Error::add_error(
443
-                sprintf(
444
-                    esc_html__(
445
-                        'The email did not send successfully.%3$sThe WordPress wp_mail function is used for sending mails but does not give any useful information when an email fails to send.%3$sIt is possible the "to" address (%1$s) or "from" address (%2$s) is invalid.%3$s',
446
-                        'event_espresso'
447
-                    ),
448
-                    $this->_to,
449
-                    $this->_from,
450
-                    '<br />'
451
-                ),
452
-                __FILE__,
453
-                __FUNCTION__,
454
-                __LINE__
455
-            );
456
-        }
457
-        return $success;
458
-    }
459
-
460
-
461
-    /**
462
-     * see parent for definition
463
-     *
464
-     * @return string html body of the message content and the related css.
465
-     * @throws EE_Error
466
-     * @throws \TijsVerkoyen\CssToInlineStyles\Exception
467
-     */
468
-    protected function _preview()
469
-    {
470
-        return $this->_body(true);
471
-    }
472
-
473
-
474
-    /**
475
-     * Setup headers for email
476
-     *
477
-     * @access protected
478
-     * @return string formatted header for email
479
-     */
480
-    protected function _headers()
481
-    {
482
-        $this->_ensure_has_from_email_address();
483
-        $from    = $this->_from;
484
-        $headers = array(
485
-            'From:' . $from,
486
-            'Reply-To:' . $from,
487
-            'Content-Type:text/html; charset=utf-8',
488
-        );
489
-
490
-        /**
491
-         * Second condition added as a result of https://events.codebasehq.com/projects/event-espresso/tickets/11416 to
492
-         * cover back compat where there may be users who have saved cc values in their db for the newsletter message
493
-         * type which they are no longer able to change.
494
-         */
495
-        if (! empty($this->_cc) && ! $this->_incoming_message_type instanceof EE_Newsletter_message_type) {
496
-            $headers[] = 'cc: ' . $this->_cc;
497
-        }
498
-
499
-        // but wait!  Header's for the from is NOT reliable because some plugins don't respect From: as set in the
500
-        // header.
501
-        add_filter('wp_mail_from', array($this, 'set_from_address'), 100);
502
-        add_filter('wp_mail_from_name', array($this, 'set_from_name'), 100);
503
-        return apply_filters('FHEE__EE_Email_messenger___headers', $headers, $this->_incoming_message_type, $this);
504
-    }
505
-
506
-
507
-    /**
508
-     * This simply ensures that the from address is not empty.  If it is, then we use whatever is set as the site email
509
-     * address for the from address to avoid problems with sending emails.
510
-     */
511
-    protected function _ensure_has_from_email_address()
512
-    {
513
-        if (empty($this->_from)) {
514
-            $this->_from = get_bloginfo('admin_email');
515
-        }
516
-    }
517
-
518
-
519
-    /**
520
-     * This simply parses whatever is set as the $_from address and determines if it is in the format {name} <{email}>
521
-     * or just {email} and returns an array with the "from_name" and "from_email" as the values. Note from_name *MAY*
522
-     * be empty
523
-     *
524
-     * @since 4.3.1
525
-     * @return array
526
-     */
527
-    private function _parse_from()
528
-    {
529
-        if (strpos($this->_from, '<') !== false) {
530
-            $from_name = substr($this->_from, 0, strpos($this->_from, '<') - 1);
531
-            $from_name = str_replace('"', '', $from_name);
532
-            $from_name = trim($from_name);
533
-
534
-            $from_email = substr($this->_from, strpos($this->_from, '<') + 1);
535
-            $from_email = str_replace('>', '', $from_email);
536
-            $from_email = trim($from_email);
537
-        } elseif (trim($this->_from) !== '') {
538
-            $from_name  = '';
539
-            $from_email = trim($this->_from);
540
-        } else {
541
-            $from_name = $from_email = '';
542
-        }
543
-        return array($from_name, $from_email);
544
-    }
545
-
546
-
547
-    /**
548
-     * Callback for the wp_mail_from filter.
549
-     *
550
-     * @since 4.3.1
551
-     * @param string $from_email What the original from_email is.
552
-     * @return string
553
-     */
554
-    public function set_from_address($from_email)
555
-    {
556
-        $parsed_from = $this->_parse_from();
557
-        // includes fallback if the parsing failed.
558
-        $from_email = is_array($parsed_from) && ! empty($parsed_from[1])
559
-            ? $parsed_from[1]
560
-            : get_bloginfo('admin_email');
561
-        return $from_email;
562
-    }
563
-
564
-
565
-    /**
566
-     * Callback fro the wp_mail_from_name filter.
567
-     *
568
-     * @since 4.3.1
569
-     * @param string $from_name The original from_name.
570
-     * @return string
571
-     */
572
-    public function set_from_name($from_name)
573
-    {
574
-        $parsed_from = $this->_parse_from();
575
-        if (is_array($parsed_from) && ! empty($parsed_from[0])) {
576
-            $from_name = $parsed_from[0];
577
-        }
578
-
579
-        // if from name is "WordPress" let's sub in the site name instead (more friendly!)
580
-        // but realize the default name is HTML entity-encoded
581
-        $from_name = $from_name == 'WordPress' ? wp_specialchars_decode(get_bloginfo(), ENT_QUOTES) : $from_name;
582
-
583
-        return $from_name;
584
-    }
585
-
586
-
587
-    /**
588
-     * setup body for email
589
-     *
590
-     * @param bool $preview will determine whether this is preview template or not.
591
-     * @return string formatted body for email.
592
-     * @throws EE_Error
593
-     * @throws \TijsVerkoyen\CssToInlineStyles\Exception
594
-     */
595
-    protected function _body($preview = false)
596
-    {
597
-        // setup template args!
598
-        $this->_template_args = array(
599
-            'subject'   => $this->_subject,
600
-            'from'      => $this->_from,
601
-            'main_body' => wpautop($this->_content),
602
-        );
603
-        $body                 = $this->_get_main_template($preview);
604
-
605
-        /**
606
-         * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched.
607
-         *
608
-         * @type    bool $preview Indicates whether a preview is being generated or not.
609
-         * @return  bool    true  indicates to use the inliner, false bypasses it.
610
-         */
611
-        if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) {
612
-            // require CssToInlineStyles library and its dependencies via composer autoloader
613
-            require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php';
614
-
615
-            // now if this isn't a preview, let's setup the body so it has inline styles
616
-            if (! $preview || ($preview && defined('DOING_AJAX'))) {
617
-                $style = file_get_contents(
618
-                    $this->get_variation(
619
-                        $this->_tmp_pack,
620
-                        $this->_incoming_message_type->name,
621
-                        false,
622
-                        'main',
623
-                        $this->_variation
624
-                    ),
625
-                    true
626
-                );
627
-                $CSS   = new TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($body, $style);
628
-                // for some reason the library has a bracket and new line at the beginning.  This takes care of that.
629
-                $body  = ltrim($CSS->convert(true), ">\n");
630
-                // see https://events.codebasehq.com/projects/event-espresso/tickets/8609
631
-                $body  = ltrim($body, "<?");
632
-            }
633
-        }
634
-        return $body;
635
-    }
636
-
637
-
638
-    /**
639
-     * This just returns any existing test settings that might be saved in the database
640
-     *
641
-     * @access public
642
-     * @return array
643
-     */
644
-    public function get_existing_test_settings()
645
-    {
646
-        $settings = parent::get_existing_test_settings();
647
-        // override subject if present because we always want it to be fresh.
648
-        if (is_array($settings) && ! empty($settings['subject'])) {
649
-            $settings['subject'] = sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name'));
650
-        }
651
-        return $settings;
652
-    }
9
+	/**
10
+	 * To field for email
11
+	 * @var string
12
+	 */
13
+	protected $_to = '';
14
+
15
+
16
+	/**
17
+	 * CC field for email.
18
+	 * @var string
19
+	 */
20
+	protected $_cc = '';
21
+
22
+	/**
23
+	 * From field for email
24
+	 * @var string
25
+	 */
26
+	protected $_from = '';
27
+
28
+
29
+	/**
30
+	 * Subject field for email
31
+	 * @var string
32
+	 */
33
+	protected $_subject = '';
34
+
35
+
36
+	/**
37
+	 * Content field for email
38
+	 * @var string
39
+	 */
40
+	protected $_content = '';
41
+
42
+
43
+	/**
44
+	 * constructor
45
+	 *
46
+	 * @access public
47
+	 */
48
+	public function __construct()
49
+	{
50
+		// set name and description properties
51
+		$this->name                = 'email';
52
+		$this->description         = sprintf(
53
+			esc_html__(
54
+				'This messenger delivers messages via email using the built-in %s function included with WordPress',
55
+				'event_espresso'
56
+			),
57
+			'<code>wp_mail</code>'
58
+		);
59
+		$this->label               = array(
60
+			'singular' => esc_html__('email', 'event_espresso'),
61
+			'plural'   => esc_html__('emails', 'event_espresso'),
62
+		);
63
+		$this->activate_on_install = true;
64
+
65
+		// we're using defaults so let's call parent constructor that will take care of setting up all the other
66
+		// properties
67
+		parent::__construct();
68
+	}
69
+
70
+
71
+	/**
72
+	 * see abstract declaration in parent class for details.
73
+	 */
74
+	protected function _set_admin_pages()
75
+	{
76
+		$this->admin_registered_pages = array(
77
+			'events_edit' => true,
78
+		);
79
+	}
80
+
81
+
82
+	/**
83
+	 * see abstract declaration in parent class for details
84
+	 */
85
+	protected function _set_valid_shortcodes()
86
+	{
87
+		// remember by leaving the other fields not set, those fields will inherit the valid shortcodes from the
88
+		// message type.
89
+		$this->_valid_shortcodes = array(
90
+			'to'   => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
91
+			'cc' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
92
+			'from' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
93
+		);
94
+	}
95
+
96
+
97
+	/**
98
+	 * see abstract declaration in parent class for details
99
+	 *
100
+	 * @access protected
101
+	 * @return void
102
+	 */
103
+	protected function _set_validator_config()
104
+	{
105
+		$valid_shortcodes = $this->get_valid_shortcodes();
106
+
107
+		$this->_validator_config = array(
108
+			'to'            => array(
109
+				'shortcodes' => $valid_shortcodes['to'],
110
+				'type'       => 'email',
111
+			),
112
+			'cc' => array(
113
+				'shortcodes' => $valid_shortcodes['to'],
114
+				'type' => 'email',
115
+			),
116
+			'from'          => array(
117
+				'shortcodes' => $valid_shortcodes['from'],
118
+				'type'       => 'email',
119
+			),
120
+			'subject'       => array(
121
+				'shortcodes' => array(
122
+					'organization',
123
+					'primary_registration_details',
124
+					'event_author',
125
+					'primary_registration_details',
126
+					'recipient_details',
127
+				),
128
+			),
129
+			'content'       => array(
130
+				'shortcodes' => array(
131
+					'event_list',
132
+					'attendee_list',
133
+					'ticket_list',
134
+					'organization',
135
+					'primary_registration_details',
136
+					'primary_registration_list',
137
+					'event_author',
138
+					'recipient_details',
139
+					'recipient_list',
140
+					'transaction',
141
+					'messenger',
142
+				),
143
+			),
144
+			'attendee_list' => array(
145
+				'shortcodes' => array('attendee', 'event_list', 'ticket_list'),
146
+				'required'   => array('[ATTENDEE_LIST]'),
147
+			),
148
+			'event_list'    => array(
149
+				'shortcodes' => array(
150
+					'event',
151
+					'attendee_list',
152
+					'ticket_list',
153
+					'venue',
154
+					'datetime_list',
155
+					'attendee',
156
+					'primary_registration_details',
157
+					'primary_registration_list',
158
+					'event_author',
159
+					'recipient_details',
160
+					'recipient_list',
161
+				),
162
+				'required'   => array('[EVENT_LIST]'),
163
+			),
164
+			'ticket_list'   => array(
165
+				'shortcodes' => array(
166
+					'event_list',
167
+					'attendee_list',
168
+					'ticket',
169
+					'datetime_list',
170
+					'primary_registration_details',
171
+					'recipient_details',
172
+				),
173
+				'required'   => array('[TICKET_LIST]'),
174
+			),
175
+			'datetime_list' => array(
176
+				'shortcodes' => array('datetime'),
177
+				'required'   => array('[DATETIME_LIST]'),
178
+			),
179
+		);
180
+	}
181
+
182
+
183
+	/**
184
+	 * @see   parent EE_messenger class for docs
185
+	 * @since 4.5.0
186
+	 */
187
+	public function do_secondary_messenger_hooks($sending_messenger_name)
188
+	{
189
+		if ($sending_messenger_name === 'html') {
190
+			add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8);
191
+		}
192
+	}
193
+
194
+
195
+	public function add_email_css(
196
+		$variation_path,
197
+		$messenger,
198
+		$message_type,
199
+		$type,
200
+		$variation,
201
+		$file_extension,
202
+		$url,
203
+		EE_Messages_Template_Pack $template_pack
204
+	) {
205
+		// prevent recursion on this callback.
206
+		remove_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10);
207
+		$variation = $this->get_variation($template_pack, $message_type, $url, 'main', $variation, false);
208
+
209
+		add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8);
210
+		return $variation;
211
+	}
212
+
213
+
214
+	/**
215
+	 * See parent for details
216
+	 *
217
+	 * @access protected
218
+	 * @return void
219
+	 */
220
+	protected function _set_test_settings_fields()
221
+	{
222
+		$this->_test_settings_fields = array(
223
+			'to'      => array(
224
+				'input'      => 'text',
225
+				'label'      => esc_html__('Send a test email to', 'event_espresso'),
226
+				'type'       => 'email',
227
+				'required'   => true,
228
+				'validation' => true,
229
+				'css_class'  => 'large-text',
230
+				'format'     => '%s',
231
+				'default'    => get_bloginfo('admin_email'),
232
+			),
233
+			'subject' => array(
234
+				'input'      => 'hidden',
235
+				'label'      => '',
236
+				'type'       => 'string',
237
+				'required'   => false,
238
+				'validation' => false,
239
+				'format'     => '%s',
240
+				'value'      => sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')),
241
+				'default'    => '',
242
+				'css_class'  => '',
243
+			),
244
+		);
245
+	}
246
+
247
+
248
+	/**
249
+	 * _set_template_fields
250
+	 * This sets up the fields that a messenger requires for the message to go out.
251
+	 *
252
+	 * @access  protected
253
+	 * @return void
254
+	 */
255
+	protected function _set_template_fields()
256
+	{
257
+		// any extra template fields that are NOT used by the messenger but will get used by a messenger field for
258
+		// shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field
259
+		// they relate to.  This is important for the Messages_admin to know what fields to display to the user.
260
+		//  Also, notice that the "values" are equal to the field type that messages admin will use to know what
261
+		// kind of field to display. The values ALSO have one index labeled "shortcode".  the values in that array
262
+		// indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be
263
+		// displayed.  If the required shortcode isn't part of the shortcodes array then the field is not needed and
264
+		// will not be displayed/parsed.
265
+		$this->_template_fields = array(
266
+			'to'      => array(
267
+				'input'      => 'text',
268
+				'label'      => esc_html_x(
269
+					'To',
270
+					'Label for the "To" field for email addresses',
271
+					'event_espresso'
272
+				),
273
+				'type'       => 'string',
274
+				'required'   => true,
275
+				'validation' => true,
276
+				'css_class'  => 'large-text',
277
+				'format'     => '%s',
278
+			),
279
+			'cc'      => array(
280
+				'input'      => 'text',
281
+				'label'      => esc_html_x(
282
+					'CC',
283
+					'Label for the "Carbon Copy" field used for additional email addresses',
284
+					'event_espresso'
285
+				),
286
+				'type'       => 'string',
287
+				'required'   => false,
288
+				'validation' => true,
289
+				'css_class'  => 'large-text',
290
+				'format'     => '%s',
291
+			),
292
+			'from'    => array(
293
+				'input'      => 'text',
294
+				'label'      => esc_html_x(
295
+					'From',
296
+					'Label for the "From" field for email addresses.',
297
+					'event_espresso'
298
+				),
299
+				'type'       => 'string',
300
+				'required'   => true,
301
+				'validation' => true,
302
+				'css_class'  => 'large-text',
303
+				'format'     => '%s',
304
+			),
305
+			'subject' => array(
306
+				'input'      => 'text',
307
+				'label'      => esc_html_x(
308
+					'Subject',
309
+					'Label for the "Subject" field (short description of contents) for emails.',
310
+					'event_espresso'
311
+				),
312
+				'type'       => 'string',
313
+				'required'   => true,
314
+				'validation' => true,
315
+				'css_class'  => 'large-text',
316
+				'format'     => '%s',
317
+			),
318
+			'content' => '',
319
+			// left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field.
320
+			'extra'   => array(
321
+				'content' => array(
322
+					'main'          => array(
323
+						'input'      => 'wp_editor',
324
+						'label'      => esc_html__('Main Content', 'event_espresso'),
325
+						'type'       => 'string',
326
+						'required'   => true,
327
+						'validation' => true,
328
+						'format'     => '%s',
329
+						'rows'       => '15',
330
+					),
331
+					'event_list'    => array(
332
+						'input'               => 'wp_editor',
333
+						'label'               => '[EVENT_LIST]',
334
+						'type'                => 'string',
335
+						'required'            => true,
336
+						'validation'          => true,
337
+						'format'              => '%s',
338
+						'rows'                => '15',
339
+						'shortcodes_required' => array('[EVENT_LIST]'),
340
+					),
341
+					'attendee_list' => array(
342
+						'input'               => 'textarea',
343
+						'label'               => '[ATTENDEE_LIST]',
344
+						'type'                => 'string',
345
+						'required'            => true,
346
+						'validation'          => true,
347
+						'format'              => '%s',
348
+						'css_class'           => 'large-text',
349
+						'rows'                => '5',
350
+						'shortcodes_required' => array('[ATTENDEE_LIST]'),
351
+					),
352
+					'ticket_list'   => array(
353
+						'input'               => 'textarea',
354
+						'label'               => '[TICKET_LIST]',
355
+						'type'                => 'string',
356
+						'required'            => true,
357
+						'validation'          => true,
358
+						'format'              => '%s',
359
+						'css_class'           => 'large-text',
360
+						'rows'                => '10',
361
+						'shortcodes_required' => array('[TICKET_LIST]'),
362
+					),
363
+					'datetime_list' => array(
364
+						'input'               => 'textarea',
365
+						'label'               => '[DATETIME_LIST]',
366
+						'type'                => 'string',
367
+						'required'            => true,
368
+						'validation'          => true,
369
+						'format'              => '%s',
370
+						'css_class'           => 'large-text',
371
+						'rows'                => '10',
372
+						'shortcodes_required' => array('[DATETIME_LIST]'),
373
+					),
374
+				),
375
+			),
376
+		);
377
+	}
378
+
379
+
380
+	/**
381
+	 * See definition of this class in parent
382
+	 */
383
+	protected function _set_default_message_types()
384
+	{
385
+		$this->_default_message_types = array(
386
+			'payment',
387
+			'payment_refund',
388
+			'registration',
389
+			'not_approved_registration',
390
+			'pending_approval',
391
+		);
392
+	}
393
+
394
+
395
+	/**
396
+	 * @see   definition of this class in parent
397
+	 * @since 4.5.0
398
+	 */
399
+	protected function _set_valid_message_types()
400
+	{
401
+		$this->_valid_message_types = array(
402
+			'payment',
403
+			'registration',
404
+			'not_approved_registration',
405
+			'declined_registration',
406
+			'cancelled_registration',
407
+			'pending_approval',
408
+			'registration_summary',
409
+			'payment_reminder',
410
+			'payment_declined',
411
+			'payment_refund',
412
+		);
413
+	}
414
+
415
+
416
+	/**
417
+	 * setting up admin_settings_fields for messenger.
418
+	 */
419
+	protected function _set_admin_settings_fields()
420
+	{
421
+	}
422
+
423
+	/**
424
+	 * We just deliver the messages don't kill us!!
425
+	 *
426
+	 * @return bool|WP_Error true if message delivered, false if it didn't deliver OR bubble up any error object if
427
+	 *              present.
428
+	 * @throws EE_Error
429
+	 * @throws \TijsVerkoyen\CssToInlineStyles\Exception
430
+	 */
431
+	protected function _send_message()
432
+	{
433
+		$success = wp_mail(
434
+			$this->_to,
435
+			// some old values for subject may be expecting HTML entities to be decoded in the subject
436
+			// and subjects aren't interpreted as HTML, so there should be no HTML in them
437
+			wp_strip_all_tags(wp_specialchars_decode($this->_subject, ENT_QUOTES)),
438
+			$this->_body(),
439
+			$this->_headers()
440
+		);
441
+		if (! $success) {
442
+			EE_Error::add_error(
443
+				sprintf(
444
+					esc_html__(
445
+						'The email did not send successfully.%3$sThe WordPress wp_mail function is used for sending mails but does not give any useful information when an email fails to send.%3$sIt is possible the "to" address (%1$s) or "from" address (%2$s) is invalid.%3$s',
446
+						'event_espresso'
447
+					),
448
+					$this->_to,
449
+					$this->_from,
450
+					'<br />'
451
+				),
452
+				__FILE__,
453
+				__FUNCTION__,
454
+				__LINE__
455
+			);
456
+		}
457
+		return $success;
458
+	}
459
+
460
+
461
+	/**
462
+	 * see parent for definition
463
+	 *
464
+	 * @return string html body of the message content and the related css.
465
+	 * @throws EE_Error
466
+	 * @throws \TijsVerkoyen\CssToInlineStyles\Exception
467
+	 */
468
+	protected function _preview()
469
+	{
470
+		return $this->_body(true);
471
+	}
472
+
473
+
474
+	/**
475
+	 * Setup headers for email
476
+	 *
477
+	 * @access protected
478
+	 * @return string formatted header for email
479
+	 */
480
+	protected function _headers()
481
+	{
482
+		$this->_ensure_has_from_email_address();
483
+		$from    = $this->_from;
484
+		$headers = array(
485
+			'From:' . $from,
486
+			'Reply-To:' . $from,
487
+			'Content-Type:text/html; charset=utf-8',
488
+		);
489
+
490
+		/**
491
+		 * Second condition added as a result of https://events.codebasehq.com/projects/event-espresso/tickets/11416 to
492
+		 * cover back compat where there may be users who have saved cc values in their db for the newsletter message
493
+		 * type which they are no longer able to change.
494
+		 */
495
+		if (! empty($this->_cc) && ! $this->_incoming_message_type instanceof EE_Newsletter_message_type) {
496
+			$headers[] = 'cc: ' . $this->_cc;
497
+		}
498
+
499
+		// but wait!  Header's for the from is NOT reliable because some plugins don't respect From: as set in the
500
+		// header.
501
+		add_filter('wp_mail_from', array($this, 'set_from_address'), 100);
502
+		add_filter('wp_mail_from_name', array($this, 'set_from_name'), 100);
503
+		return apply_filters('FHEE__EE_Email_messenger___headers', $headers, $this->_incoming_message_type, $this);
504
+	}
505
+
506
+
507
+	/**
508
+	 * This simply ensures that the from address is not empty.  If it is, then we use whatever is set as the site email
509
+	 * address for the from address to avoid problems with sending emails.
510
+	 */
511
+	protected function _ensure_has_from_email_address()
512
+	{
513
+		if (empty($this->_from)) {
514
+			$this->_from = get_bloginfo('admin_email');
515
+		}
516
+	}
517
+
518
+
519
+	/**
520
+	 * This simply parses whatever is set as the $_from address and determines if it is in the format {name} <{email}>
521
+	 * or just {email} and returns an array with the "from_name" and "from_email" as the values. Note from_name *MAY*
522
+	 * be empty
523
+	 *
524
+	 * @since 4.3.1
525
+	 * @return array
526
+	 */
527
+	private function _parse_from()
528
+	{
529
+		if (strpos($this->_from, '<') !== false) {
530
+			$from_name = substr($this->_from, 0, strpos($this->_from, '<') - 1);
531
+			$from_name = str_replace('"', '', $from_name);
532
+			$from_name = trim($from_name);
533
+
534
+			$from_email = substr($this->_from, strpos($this->_from, '<') + 1);
535
+			$from_email = str_replace('>', '', $from_email);
536
+			$from_email = trim($from_email);
537
+		} elseif (trim($this->_from) !== '') {
538
+			$from_name  = '';
539
+			$from_email = trim($this->_from);
540
+		} else {
541
+			$from_name = $from_email = '';
542
+		}
543
+		return array($from_name, $from_email);
544
+	}
545
+
546
+
547
+	/**
548
+	 * Callback for the wp_mail_from filter.
549
+	 *
550
+	 * @since 4.3.1
551
+	 * @param string $from_email What the original from_email is.
552
+	 * @return string
553
+	 */
554
+	public function set_from_address($from_email)
555
+	{
556
+		$parsed_from = $this->_parse_from();
557
+		// includes fallback if the parsing failed.
558
+		$from_email = is_array($parsed_from) && ! empty($parsed_from[1])
559
+			? $parsed_from[1]
560
+			: get_bloginfo('admin_email');
561
+		return $from_email;
562
+	}
563
+
564
+
565
+	/**
566
+	 * Callback fro the wp_mail_from_name filter.
567
+	 *
568
+	 * @since 4.3.1
569
+	 * @param string $from_name The original from_name.
570
+	 * @return string
571
+	 */
572
+	public function set_from_name($from_name)
573
+	{
574
+		$parsed_from = $this->_parse_from();
575
+		if (is_array($parsed_from) && ! empty($parsed_from[0])) {
576
+			$from_name = $parsed_from[0];
577
+		}
578
+
579
+		// if from name is "WordPress" let's sub in the site name instead (more friendly!)
580
+		// but realize the default name is HTML entity-encoded
581
+		$from_name = $from_name == 'WordPress' ? wp_specialchars_decode(get_bloginfo(), ENT_QUOTES) : $from_name;
582
+
583
+		return $from_name;
584
+	}
585
+
586
+
587
+	/**
588
+	 * setup body for email
589
+	 *
590
+	 * @param bool $preview will determine whether this is preview template or not.
591
+	 * @return string formatted body for email.
592
+	 * @throws EE_Error
593
+	 * @throws \TijsVerkoyen\CssToInlineStyles\Exception
594
+	 */
595
+	protected function _body($preview = false)
596
+	{
597
+		// setup template args!
598
+		$this->_template_args = array(
599
+			'subject'   => $this->_subject,
600
+			'from'      => $this->_from,
601
+			'main_body' => wpautop($this->_content),
602
+		);
603
+		$body                 = $this->_get_main_template($preview);
604
+
605
+		/**
606
+		 * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched.
607
+		 *
608
+		 * @type    bool $preview Indicates whether a preview is being generated or not.
609
+		 * @return  bool    true  indicates to use the inliner, false bypasses it.
610
+		 */
611
+		if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) {
612
+			// require CssToInlineStyles library and its dependencies via composer autoloader
613
+			require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php';
614
+
615
+			// now if this isn't a preview, let's setup the body so it has inline styles
616
+			if (! $preview || ($preview && defined('DOING_AJAX'))) {
617
+				$style = file_get_contents(
618
+					$this->get_variation(
619
+						$this->_tmp_pack,
620
+						$this->_incoming_message_type->name,
621
+						false,
622
+						'main',
623
+						$this->_variation
624
+					),
625
+					true
626
+				);
627
+				$CSS   = new TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($body, $style);
628
+				// for some reason the library has a bracket and new line at the beginning.  This takes care of that.
629
+				$body  = ltrim($CSS->convert(true), ">\n");
630
+				// see https://events.codebasehq.com/projects/event-espresso/tickets/8609
631
+				$body  = ltrim($body, "<?");
632
+			}
633
+		}
634
+		return $body;
635
+	}
636
+
637
+
638
+	/**
639
+	 * This just returns any existing test settings that might be saved in the database
640
+	 *
641
+	 * @access public
642
+	 * @return array
643
+	 */
644
+	public function get_existing_test_settings()
645
+	{
646
+		$settings = parent::get_existing_test_settings();
647
+		// override subject if present because we always want it to be fresh.
648
+		if (is_array($settings) && ! empty($settings['subject'])) {
649
+			$settings['subject'] = sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name'));
650
+		}
651
+		return $settings;
652
+	}
653 653
 }
Please login to merge, or discard this patch.