Completed
Branch BUG-10381-asset-loading (2a534d)
by
unknown
73:57 queued 62:56
created
core/helpers/EEH_Event_View.helper.php 2 patches
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -32,47 +32,47 @@  discard block
 block discarded – undo
32 32
 
33 33
 
34 34
 
35
-    /**
36
-     * get_event
37
-     * attempts to retrieve an EE_Event object any way it can
38
-     *
39
-     * @param int|WP_Post $EVT_ID
40
-     * @return EE_Event|null
41
-     * @throws \EE_Error
42
-     */
35
+	/**
36
+	 * get_event
37
+	 * attempts to retrieve an EE_Event object any way it can
38
+	 *
39
+	 * @param int|WP_Post $EVT_ID
40
+	 * @return EE_Event|null
41
+	 * @throws \EE_Error
42
+	 */
43 43
 	public static function get_event( $EVT_ID = 0 ) {
44
-        // international newspaper?
45
-        global $post;
46
-        $EVT_ID = $EVT_ID instanceof WP_Post && $EVT_ID->post_type === 'espresso_events'
47
-            ? $EVT_ID->ID
48
-            : absint($EVT_ID);
49
-        // do we already have the Event  you are looking for?
50
-        if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) {
51
-            return EEH_Event_View::$_event;
52
-        }
53
-        //reset property so that the new event is cached.
54
-        EEH_Event_View::$_event = null;
55
-
56
-        if ($EVT_ID || $post instanceof WP_Post) {
57
-            //if the post type is for an event and it has a cached event and we don't have a different incoming $EVT_ID
58
-            //then let's just use that cached event on the $post object.
59
-            if ($post->post_type === 'espresso_events'
60
-                && isset($post->EE_Event)
61
-                && ($EVT_ID === 0
62
-                    || $EVT_ID === $post->ID
63
-                    )
64
-            ) {
65
-                EEH_Event_View::$_event = $post->EE_Event;
66
-            }
67
-
68
-            //If the event we have isn't an event but we do have an EVT_ID, let's try getting the event using the ID.
69
-            if (! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
70
-                EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
71
-            }
72
-        }
73
-
74
-        return EEH_Event_View::$_event;
75
-    }
44
+		// international newspaper?
45
+		global $post;
46
+		$EVT_ID = $EVT_ID instanceof WP_Post && $EVT_ID->post_type === 'espresso_events'
47
+			? $EVT_ID->ID
48
+			: absint($EVT_ID);
49
+		// do we already have the Event  you are looking for?
50
+		if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) {
51
+			return EEH_Event_View::$_event;
52
+		}
53
+		//reset property so that the new event is cached.
54
+		EEH_Event_View::$_event = null;
55
+
56
+		if ($EVT_ID || $post instanceof WP_Post) {
57
+			//if the post type is for an event and it has a cached event and we don't have a different incoming $EVT_ID
58
+			//then let's just use that cached event on the $post object.
59
+			if ($post->post_type === 'espresso_events'
60
+				&& isset($post->EE_Event)
61
+				&& ($EVT_ID === 0
62
+					|| $EVT_ID === $post->ID
63
+					)
64
+			) {
65
+				EEH_Event_View::$_event = $post->EE_Event;
66
+			}
67
+
68
+			//If the event we have isn't an event but we do have an EVT_ID, let's try getting the event using the ID.
69
+			if (! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
70
+				EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
71
+			}
72
+		}
73
+
74
+		return EEH_Event_View::$_event;
75
+	}
76 76
 
77 77
 
78 78
 
@@ -148,58 +148,58 @@  discard block
 block discarded – undo
148 148
 	 * @return    string
149 149
 	 */
150 150
 	public static function event_content_or_excerpt( $num_words = NULL, $more = NULL ) {
151
-        global $post;
151
+		global $post;
152 152
 		ob_start();
153 153
 		if (( is_single() ) || ( is_archive() && espresso_display_full_description_in_event_list() )) {
154 154
 			// admin has chosen "full description"
155
-            // for the "Event Espresso - Events > Templates > Display Description" option
155
+			// for the "Event Espresso - Events > Templates > Display Description" option
156 156
 			the_content();
157 157
 		} else if (( is_archive() && espresso_display_excerpt_in_event_list() ) ) {
158
-            if ( has_excerpt( $post->ID )) {
159
-                // admin has chosen "excerpt (short desc)"
160
-                // for the "Event Espresso - Events > Templates > Display Description" option
161
-                // AND an excerpt actually exists
162
-                the_excerpt();
163
-            } else {
164
-                // admin has chosen "excerpt (short desc)"
165
-                // for the "Event Espresso - Events > Templates > Display Description" option
166
-                // but NO excerpt actually exists, so we need to create one
167
-                if ( ! empty( $num_words )) {
168
-                    if ( empty( $more )) {
169
-                        $more_link_text = __( '(more…)' );
170
-                        $more = ' <a href="' . get_permalink() . '"';
171
-                        $more .= ' class="more-link"';
172
-                        $more .= \EED_Events_Archive::link_target();
173
-                        $more .= '>' . $more_link_text . '</a>';
174
-                        $more = apply_filters( 'the_content_more_link', $more, $more_link_text );
175
-                    }
176
-                    $content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' ));
177
-
178
-                    $content =  wp_trim_words( $content, $num_words, ' ' ) . $more;
179
-                } else {
180
-                    $content =  get_the_content();
181
-                }
182
-                global $allowedtags;
183
-                // make sure links are allowed
184
-                $allowedtags['a'] = isset($allowedtags['a'])
185
-                    ? $allowedtags['a']
186
-                    : array();
187
-                // as well as target attribute
188
-                $allowedtags['a']['target'] = isset($allowedtags['a']['target'])
189
-                    ? $allowedtags['a']['target']
190
-                    : false;
191
-                // but get previous value so we can reset it
192
-                $prev_value = $allowedtags['a']['target'];
193
-                $allowedtags['a']['target'] = true;
194
-                $content = wp_kses( $content, $allowedtags );
195
-                $content = strip_shortcodes( $content );
196
-                echo apply_filters( 'the_content', $content );
197
-                $allowedtags['a']['target'] = $prev_value;
198
-            }
199
-        } else {
200
-            // admin has chosen "none"
201
-            // for the "Event Espresso - Events > Templates > Display Description" option
202
-            echo apply_filters( 'the_content', '' );
158
+			if ( has_excerpt( $post->ID )) {
159
+				// admin has chosen "excerpt (short desc)"
160
+				// for the "Event Espresso - Events > Templates > Display Description" option
161
+				// AND an excerpt actually exists
162
+				the_excerpt();
163
+			} else {
164
+				// admin has chosen "excerpt (short desc)"
165
+				// for the "Event Espresso - Events > Templates > Display Description" option
166
+				// but NO excerpt actually exists, so we need to create one
167
+				if ( ! empty( $num_words )) {
168
+					if ( empty( $more )) {
169
+						$more_link_text = __( '(more&hellip;)' );
170
+						$more = ' <a href="' . get_permalink() . '"';
171
+						$more .= ' class="more-link"';
172
+						$more .= \EED_Events_Archive::link_target();
173
+						$more .= '>' . $more_link_text . '</a>';
174
+						$more = apply_filters( 'the_content_more_link', $more, $more_link_text );
175
+					}
176
+					$content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' ));
177
+
178
+					$content =  wp_trim_words( $content, $num_words, ' ' ) . $more;
179
+				} else {
180
+					$content =  get_the_content();
181
+				}
182
+				global $allowedtags;
183
+				// make sure links are allowed
184
+				$allowedtags['a'] = isset($allowedtags['a'])
185
+					? $allowedtags['a']
186
+					: array();
187
+				// as well as target attribute
188
+				$allowedtags['a']['target'] = isset($allowedtags['a']['target'])
189
+					? $allowedtags['a']['target']
190
+					: false;
191
+				// but get previous value so we can reset it
192
+				$prev_value = $allowedtags['a']['target'];
193
+				$allowedtags['a']['target'] = true;
194
+				$content = wp_kses( $content, $allowedtags );
195
+				$content = strip_shortcodes( $content );
196
+				echo apply_filters( 'the_content', $content );
197
+				$allowedtags['a']['target'] = $prev_value;
198
+			}
199
+		} else {
200
+			// admin has chosen "none"
201
+			// for the "Event Espresso - Events > Templates > Display Description" option
202
+			echo apply_filters( 'the_content', '' );
203 203
 		}
204 204
 		return ob_get_clean();
205 205
 	}
@@ -246,11 +246,11 @@  discard block
 block discarded – undo
246 246
 					$url = get_term_link( $term, 'espresso_venue_categories' );
247 247
 					if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) {
248 248
 						$category_links[] = '<a href="' . esc_url( $url )
249
-                                            . '" rel="tag"'
250
-                                            . \EED_Events_Archive::link_target()
251
-                                            .'>'
252
-                                            . $term->name
253
-                                            . '</a>';
249
+											. '" rel="tag"'
250
+											. \EED_Events_Archive::link_target()
251
+											.'>'
252
+											. $term->name
253
+											. '</a>';
254 254
 					}
255 255
 				}
256 256
 			}
Please login to merge, or discard this patch.
Spacing   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      * @return EE_Event|null
41 41
      * @throws \EE_Error
42 42
      */
43
-	public static function get_event( $EVT_ID = 0 ) {
43
+	public static function get_event($EVT_ID = 0) {
44 44
         // international newspaper?
45 45
         global $post;
46 46
         $EVT_ID = $EVT_ID instanceof WP_Post && $EVT_ID->post_type === 'espresso_events'
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
             }
67 67
 
68 68
             //If the event we have isn't an event but we do have an EVT_ID, let's try getting the event using the ID.
69
-            if (! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
69
+            if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
70 70
                 EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
71 71
             }
72 72
         }
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 	 * @param    int $EVT_ID
84 84
 	 * @return    boolean
85 85
 	 */
86
-	public static function display_ticket_selector( $EVT_ID = 0 ) {
87
-		$event = EEH_Event_View::get_event( $EVT_ID );
86
+	public static function display_ticket_selector($EVT_ID = 0) {
87
+		$event = EEH_Event_View::get_event($EVT_ID);
88 88
 		return $event instanceof EE_Event ? $event->display_ticket_selector() : FALSE;
89 89
 	}
90 90
 
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 	 * @param    int $EVT_ID
98 98
 	 * @return    string
99 99
 	 */
100
-	public static function event_status( $EVT_ID = 0 ) {
101
-		$event = EEH_Event_View::get_event( $EVT_ID );
102
-		return $event instanceof EE_Event ? $event->pretty_active_status( FALSE ) : '';
100
+	public static function event_status($EVT_ID = 0) {
101
+		$event = EEH_Event_View::get_event($EVT_ID);
102
+		return $event instanceof EE_Event ? $event->pretty_active_status(FALSE) : '';
103 103
 	}
104 104
 
105 105
 
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 	 * @param    int $EVT_ID
112 112
 	 *  @return 	string
113 113
 	 */
114
-	public static function event_active_status( $EVT_ID = 0 ) {
115
-		$event = EEH_Event_View::get_event( $EVT_ID );
114
+	public static function event_active_status($EVT_ID = 0) {
115
+		$event = EEH_Event_View::get_event($EVT_ID);
116 116
 		return $event instanceof EE_Event ? $event->pretty_active_status() : 'inactive';
117 117
 	}
118 118
 
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
 	 * @param    int $EVT_ID
126 126
 	 *  @return 	string
127 127
 	 */
128
-	public static function event_has_content_or_excerpt( $EVT_ID = 0 ) {
129
-		$event = EEH_Event_View::get_event( $EVT_ID );
128
+	public static function event_has_content_or_excerpt($EVT_ID = 0) {
129
+		$event = EEH_Event_View::get_event($EVT_ID);
130 130
 		$has_content_or_excerpt = FALSE;
131
-		if ( $event instanceof EE_Event ) {
132
-			$has_content_or_excerpt = $event->description() != '' || $event->short_description( NULL, NULL, TRUE ) != '' ? TRUE : FALSE;
131
+		if ($event instanceof EE_Event) {
132
+			$has_content_or_excerpt = $event->description() != '' || $event->short_description(NULL, NULL, TRUE) != '' ? TRUE : FALSE;
133 133
 		}
134
-		if ( is_archive() && ! ( espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list() )) {
134
+		if (is_archive() && ! (espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list())) {
135 135
 			$has_content_or_excerpt = FALSE;
136 136
 		}
137 137
 		return $has_content_or_excerpt;
@@ -147,15 +147,15 @@  discard block
 block discarded – undo
147 147
 	 * @param null $more
148 148
 	 * @return    string
149 149
 	 */
150
-	public static function event_content_or_excerpt( $num_words = NULL, $more = NULL ) {
150
+	public static function event_content_or_excerpt($num_words = NULL, $more = NULL) {
151 151
         global $post;
152 152
 		ob_start();
153
-		if (( is_single() ) || ( is_archive() && espresso_display_full_description_in_event_list() )) {
153
+		if ((is_single()) || (is_archive() && espresso_display_full_description_in_event_list())) {
154 154
 			// admin has chosen "full description"
155 155
             // for the "Event Espresso - Events > Templates > Display Description" option
156 156
 			the_content();
157
-		} else if (( is_archive() && espresso_display_excerpt_in_event_list() ) ) {
158
-            if ( has_excerpt( $post->ID )) {
157
+		} else if ((is_archive() && espresso_display_excerpt_in_event_list())) {
158
+            if (has_excerpt($post->ID)) {
159 159
                 // admin has chosen "excerpt (short desc)"
160 160
                 // for the "Event Espresso - Events > Templates > Display Description" option
161 161
                 // AND an excerpt actually exists
@@ -164,20 +164,20 @@  discard block
 block discarded – undo
164 164
                 // admin has chosen "excerpt (short desc)"
165 165
                 // for the "Event Espresso - Events > Templates > Display Description" option
166 166
                 // but NO excerpt actually exists, so we need to create one
167
-                if ( ! empty( $num_words )) {
168
-                    if ( empty( $more )) {
169
-                        $more_link_text = __( '(more&hellip;)' );
170
-                        $more = ' <a href="' . get_permalink() . '"';
167
+                if ( ! empty($num_words)) {
168
+                    if (empty($more)) {
169
+                        $more_link_text = __('(more&hellip;)');
170
+                        $more = ' <a href="'.get_permalink().'"';
171 171
                         $more .= ' class="more-link"';
172 172
                         $more .= \EED_Events_Archive::link_target();
173
-                        $more .= '>' . $more_link_text . '</a>';
174
-                        $more = apply_filters( 'the_content_more_link', $more, $more_link_text );
173
+                        $more .= '>'.$more_link_text.'</a>';
174
+                        $more = apply_filters('the_content_more_link', $more, $more_link_text);
175 175
                     }
176
-                    $content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' ));
176
+                    $content = str_replace('NOMORELINK', '', get_the_content('NOMORELINK'));
177 177
 
178
-                    $content =  wp_trim_words( $content, $num_words, ' ' ) . $more;
178
+                    $content = wp_trim_words($content, $num_words, ' ').$more;
179 179
                 } else {
180
-                    $content =  get_the_content();
180
+                    $content = get_the_content();
181 181
                 }
182 182
                 global $allowedtags;
183 183
                 // make sure links are allowed
@@ -191,15 +191,15 @@  discard block
 block discarded – undo
191 191
                 // but get previous value so we can reset it
192 192
                 $prev_value = $allowedtags['a']['target'];
193 193
                 $allowedtags['a']['target'] = true;
194
-                $content = wp_kses( $content, $allowedtags );
195
-                $content = strip_shortcodes( $content );
196
-                echo apply_filters( 'the_content', $content );
194
+                $content = wp_kses($content, $allowedtags);
195
+                $content = strip_shortcodes($content);
196
+                echo apply_filters('the_content', $content);
197 197
                 $allowedtags['a']['target'] = $prev_value;
198 198
             }
199 199
         } else {
200 200
             // admin has chosen "none"
201 201
             // for the "Event Espresso - Events > Templates > Display Description" option
202
-            echo apply_filters( 'the_content', '' );
202
+            echo apply_filters('the_content', '');
203 203
 		}
204 204
 		return ob_get_clean();
205 205
 	}
@@ -213,13 +213,13 @@  discard block
 block discarded – undo
213 213
 	 * @param    int $EVT_ID
214 214
 	 *  @return 	EE_Ticket[]
215 215
 	 */
216
-	public static function event_tickets_available( $EVT_ID = 0 ) {
217
-		$event = EEH_Event_View::get_event( $EVT_ID );
216
+	public static function event_tickets_available($EVT_ID = 0) {
217
+		$event = EEH_Event_View::get_event($EVT_ID);
218 218
 		$tickets_available_for_purchase = array();
219
-		if( $event instanceof EE_Event ) {
220
-			$datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, FALSE );
221
-			foreach( $datetimes as $datetime ) {
222
-				$tickets_available_for_purchase = array_merge( $tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase() );
219
+		if ($event instanceof EE_Event) {
220
+			$datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, FALSE);
221
+			foreach ($datetimes as $datetime) {
222
+				$tickets_available_for_purchase = array_merge($tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase());
223 223
 			}
224 224
 		}
225 225
 		return $tickets_available_for_purchase;
@@ -235,17 +235,17 @@  discard block
 block discarded – undo
235 235
 	 * @param 	  bool   $hide_uncategorized
236 236
 	 * @return    string
237 237
 	 */
238
-	public static function event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE ) {
238
+	public static function event_categories($EVT_ID = 0, $hide_uncategorized = TRUE) {
239 239
 		$category_links = array();
240
-		$event = EEH_Event_View::get_event( $EVT_ID );
241
-		if ( $event instanceof EE_Event ) {
242
-			$event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' );
243
-			if ( $event_categories ) {
240
+		$event = EEH_Event_View::get_event($EVT_ID);
241
+		if ($event instanceof EE_Event) {
242
+			$event_categories = get_the_terms($event->ID(), 'espresso_event_categories');
243
+			if ($event_categories) {
244 244
 				// loop thru terms and create links
245
-				foreach ( $event_categories as $term ) {
246
-					$url = get_term_link( $term, 'espresso_venue_categories' );
247
-					if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) {
248
-						$category_links[] = '<a href="' . esc_url( $url )
245
+				foreach ($event_categories as $term) {
246
+					$url = get_term_link($term, 'espresso_venue_categories');
247
+					if ( ! is_wp_error($url) && (($hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized)) {
248
+						$category_links[] = '<a href="'.esc_url($url)
249 249
                                             . '" rel="tag"'
250 250
                                             . \EED_Events_Archive::link_target()
251 251
                                             .'>'
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 				}
256 256
 			}
257 257
 		}
258
-		return implode( ', ', $category_links );
258
+		return implode(', ', $category_links);
259 259
 	}
260 260
 
261 261
 
@@ -269,10 +269,10 @@  discard block
 block discarded – undo
269 269
 	 * @param int    $EVT_ID
270 270
 	 * @return    string
271 271
 	 */
272
-	public static function the_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
273
-		$datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID );
274
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
275
-		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) :  '';
272
+	public static function the_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
273
+		$datetime = EEH_Event_View::get_primary_date_obj($EVT_ID);
274
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
275
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : '';
276 276
 	}
277 277
 
278 278
 
@@ -286,10 +286,10 @@  discard block
 block discarded – undo
286 286
 	 * @param int    $EVT_ID
287 287
 	 * @return    string
288 288
 	 */
289
-	public static function the_event_end_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
290
-		$datetime = EEH_Event_View::get_last_date_obj( $EVT_ID );
291
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
292
-		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : '';
289
+	public static function the_event_end_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
290
+		$datetime = EEH_Event_View::get_last_date_obj($EVT_ID);
291
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
292
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : '';
293 293
 	}
294 294
 
295 295
 
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
 	 * @param int    $EVT_ID
304 304
 	 * @return    string
305 305
 	 */
306
-	public static function the_earliest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
307
-		$datetime = EEH_Event_View::get_earliest_date_obj( $EVT_ID );
308
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
309
-		return $datetime instanceof EE_Datetime ?  $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) : '';
306
+	public static function the_earliest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
307
+		$datetime = EEH_Event_View::get_earliest_date_obj($EVT_ID);
308
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
309
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : '';
310 310
 	}
311 311
 
312 312
 
@@ -320,10 +320,10 @@  discard block
 block discarded – undo
320 320
 	 * @param int    $EVT_ID
321 321
 	 * @return    string
322 322
 	 */
323
-	public static function the_latest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
324
-		$datetime = EEH_Event_View::get_latest_date_obj( $EVT_ID );
325
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
326
-		return $datetime instanceof EE_Datetime ?  $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : '';
323
+	public static function the_latest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
324
+		$datetime = EEH_Event_View::get_latest_date_obj($EVT_ID);
325
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
326
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : '';
327 327
 	}
328 328
 
329 329
 
@@ -335,13 +335,13 @@  discard block
 block discarded – undo
335 335
 	 * @param int $EVT_ID
336 336
 	 * @return    string
337 337
 	 */
338
-	public static function event_date_as_calendar_page( $EVT_ID = 0 ) {
339
-		$datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID );
340
-		if ( $datetime instanceof EE_Datetime ) {
338
+	public static function event_date_as_calendar_page($EVT_ID = 0) {
339
+		$datetime = EEH_Event_View::get_primary_date_obj($EVT_ID);
340
+		if ($datetime instanceof EE_Datetime) {
341 341
 	?>
342 342
 		<div class="event-date-calendar-page-dv">
343
-			<div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime( 'DTT_EVT_start', 'M' );?></div>
344
-			<div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date( 'd' );?></div>
343
+			<div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime('DTT_EVT_start', 'M'); ?></div>
344
+			<div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date('d'); ?></div>
345 345
 		</div>
346 346
 	<?php
347 347
 		}
@@ -356,17 +356,17 @@  discard block
 block discarded – undo
356 356
 	 * @param int $EVT_ID
357 357
 	 * @return    string
358 358
 	 */
359
-	public static function get_primary_date_obj( $EVT_ID = 0 ) {
360
-		$event = EEH_Event_View::get_event( $EVT_ID );
361
-		if ( $event instanceof EE_Event ) {
359
+	public static function get_primary_date_obj($EVT_ID = 0) {
360
+		$event = EEH_Event_View::get_event($EVT_ID);
361
+		if ($event instanceof EE_Event) {
362 362
 			$datetimes = $event->get_many_related(
363 363
 				'Datetime',
364 364
 				array(
365 365
 					'limit' => 1,
366
-					'order_by' => array( 'DTT_order' => 'ASC' )
366
+					'order_by' => array('DTT_order' => 'ASC')
367 367
 				)
368 368
 			);
369
-			return reset( $datetimes );
369
+			return reset($datetimes);
370 370
 		} else {
371 371
 			 return FALSE;
372 372
 		}
@@ -381,17 +381,17 @@  discard block
 block discarded – undo
381 381
 	 * @param int $EVT_ID
382 382
 	 * @return    string
383 383
 	 */
384
-	public static function get_last_date_obj( $EVT_ID = 0 ) {
385
-		$event = EEH_Event_View::get_event( $EVT_ID );
386
-		if ( $event instanceof EE_Event ) {
384
+	public static function get_last_date_obj($EVT_ID = 0) {
385
+		$event = EEH_Event_View::get_event($EVT_ID);
386
+		if ($event instanceof EE_Event) {
387 387
 			$datetimes = $event->get_many_related(
388 388
 				'Datetime',
389 389
 				array(
390 390
 					'limit' => 1,
391
-					'order_by' => array( 'DTT_order' => 'DESC' )
391
+					'order_by' => array('DTT_order' => 'DESC')
392 392
 				)
393 393
 			);
394
-			return end( $datetimes );
394
+			return end($datetimes);
395 395
 		} else {
396 396
 			return FALSE;
397 397
 		}
@@ -406,17 +406,17 @@  discard block
 block discarded – undo
406 406
 	 * @param int $EVT_ID
407 407
 	 * @return    string
408 408
 	 */
409
-	public static function get_earliest_date_obj( $EVT_ID = 0 ) {
410
-		$event = EEH_Event_View::get_event( $EVT_ID );
411
-		if ( $event instanceof EE_Event ) {
409
+	public static function get_earliest_date_obj($EVT_ID = 0) {
410
+		$event = EEH_Event_View::get_event($EVT_ID);
411
+		if ($event instanceof EE_Event) {
412 412
 			$datetimes = $event->get_many_related(
413 413
 				'Datetime',
414 414
 				array(
415 415
 					'limit' => 1,
416
-					'order_by' => array( 'DTT_EVT_start' => 'ASC' )
416
+					'order_by' => array('DTT_EVT_start' => 'ASC')
417 417
 				)
418 418
 			);
419
-			return reset( $datetimes );
419
+			return reset($datetimes);
420 420
 		} else {
421 421
 			 return FALSE;
422 422
 		}
@@ -431,17 +431,17 @@  discard block
 block discarded – undo
431 431
 	 * @param int $EVT_ID
432 432
 	 * @return    string
433 433
 	 */
434
-	public static function get_latest_date_obj( $EVT_ID = 0 ) {
435
-		$event = EEH_Event_View::get_event( $EVT_ID );
436
-		if ( $event instanceof EE_Event ) {
434
+	public static function get_latest_date_obj($EVT_ID = 0) {
435
+		$event = EEH_Event_View::get_event($EVT_ID);
436
+		if ($event instanceof EE_Event) {
437 437
 			$datetimes = $event->get_many_related(
438 438
 				'Datetime',
439 439
 				array(
440 440
 					'limit' => 1,
441
-					'order_by' => array( 'DTT_EVT_start' => 'DESC' )
441
+					'order_by' => array('DTT_EVT_start' => 'DESC')
442 442
 				)
443 443
 			);
444
-			return end( $datetimes );
444
+			return end($datetimes);
445 445
 		} else {
446 446
 			return FALSE;
447 447
 		}
@@ -459,17 +459,17 @@  discard block
 block discarded – undo
459 459
 	 * @param null $limit
460 460
 	 * @return EE_Datetime[]
461 461
 	 */
462
-	public static function get_all_date_obj( $EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL ) {
463
-		$event = EEH_Event_View::get_event( $EVT_ID );
464
-		if($include_expired === null){
465
-			if($event instanceof EE_Event && $event->is_expired()){
462
+	public static function get_all_date_obj($EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL) {
463
+		$event = EEH_Event_View::get_event($EVT_ID);
464
+		if ($include_expired === null) {
465
+			if ($event instanceof EE_Event && $event->is_expired()) {
466 466
 				$include_expired = true;
467
-			}else{
467
+			} else {
468 468
 				$include_expired = false;
469 469
 			}
470 470
 		}
471 471
 
472
-		if ( $event instanceof EE_Event ) {
472
+		if ($event instanceof EE_Event) {
473 473
 			return $event->datetimes_ordered($include_expired, $include_deleted, $limit);
474 474
 		} else {
475 475
 			 return array();
@@ -485,11 +485,11 @@  discard block
 block discarded – undo
485 485
 	 * @param int $EVT_ID
486 486
 	 * @return    string
487 487
 	 */
488
-	public static function event_link_url( $EVT_ID = 0 ) {
489
-		$event = EEH_Event_View::get_event( $EVT_ID );
490
-		if ( $event instanceof EE_Event ) {
491
-			$url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink( $event->ID() );
492
-			return preg_match( "~^(?:f|ht)tps?://~i", $url ) ? $url : 'http://' . $url;
488
+	public static function event_link_url($EVT_ID = 0) {
489
+		$event = EEH_Event_View::get_event($EVT_ID);
490
+		if ($event instanceof EE_Event) {
491
+			$url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink($event->ID());
492
+			return preg_match("~^(?:f|ht)tps?://~i", $url) ? $url : 'http://'.$url;
493 493
 		}
494 494
 		return NULL;
495 495
 	}
@@ -503,10 +503,10 @@  discard block
 block discarded – undo
503 503
 	 * @param int $EVT_ID
504 504
 	 * @return    string
505 505
 	 */
506
-	public static function event_phone( $EVT_ID = 0 ) {
507
-		$event = EEH_Event_View::get_event( $EVT_ID );
508
-		if ( $event instanceof EE_Event ) {
509
-			return EEH_Schema::telephone( $event->phone() );
506
+	public static function event_phone($EVT_ID = 0) {
507
+		$event = EEH_Event_View::get_event($EVT_ID);
508
+		if ($event instanceof EE_Event) {
509
+			return EEH_Schema::telephone($event->phone());
510 510
 		}
511 511
 		return NULL;
512 512
 	}
@@ -523,26 +523,26 @@  discard block
 block discarded – undo
523 523
 	 * @param string $after
524 524
 	 * @return    string
525 525
 	 */
526
-	public static function edit_event_link( $EVT_ID = 0, $link = '', $before = '', $after = '' ) {
527
-		$event = EEH_Event_View::get_event( $EVT_ID );
528
-		if ( $event instanceof EE_Event ) {
526
+	public static function edit_event_link($EVT_ID = 0, $link = '', $before = '', $after = '') {
527
+		$event = EEH_Event_View::get_event($EVT_ID);
528
+		if ($event instanceof EE_Event) {
529 529
 			// can the user edit this post ?
530
-			if ( current_user_can( 'edit_post', $event->ID() )) {
530
+			if (current_user_can('edit_post', $event->ID())) {
531 531
 				// set link text
532
-				$link_text = ! empty( $link ) ? $link : __('edit this event');
532
+				$link_text = ! empty($link) ? $link : __('edit this event');
533 533
 				// generate nonce
534
-				$nonce = wp_create_nonce( 'edit_nonce' );
534
+				$nonce = wp_create_nonce('edit_nonce');
535 535
 				// generate url to event editor for this event
536
-				$url = add_query_arg( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce ), admin_url() );
536
+				$url = add_query_arg(array('page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce), admin_url());
537 537
 				// get edit CPT text
538
-				$post_type_obj = get_post_type_object( 'espresso_events' );
538
+				$post_type_obj = get_post_type_object('espresso_events');
539 539
 				// build final link html
540
-				$link = '<a class="post-edit-link" href="' . $url . '" ';
541
-				$link .= ' title="' . esc_attr( $post_type_obj->labels->edit_item ) . '"';
540
+				$link = '<a class="post-edit-link" href="'.$url.'" ';
541
+				$link .= ' title="'.esc_attr($post_type_obj->labels->edit_item).'"';
542 542
 				$link .= \EED_Events_Archive::link_target();
543
-				$link .='>' . $link_text . '</a>';
543
+				$link .= '>'.$link_text.'</a>';
544 544
 				// put it all together
545
-				return $before . apply_filters( 'edit_post_link', $link, $event->ID() ) . $after;
545
+				return $before.apply_filters('edit_post_link', $link, $event->ID()).$after;
546 546
 			}
547 547
 		}
548 548
 		return '';
Please login to merge, or discard this patch.
core/EE_Session.core.php 1 patch
Indentation   +293 added lines, -293 removed lines patch added patch discarded remove patch
@@ -22,19 +22,19 @@  discard block
 block discarded – undo
22 22
 	  */
23 23
 	 private static $_instance;
24 24
 
25
-     /**
26
-      * @var TransientManager $transient_manager
27
-      */
28
-     protected $transient_manager;
29
-
30
-     /**
31
-      * EE_Encryption object
32
-      *
33
-      * @var EE_Encryption
34
-      */
35
-     protected $encryption;
36
-
37
-     /**
25
+	 /**
26
+	  * @var TransientManager $transient_manager
27
+	  */
28
+	 protected $transient_manager;
29
+
30
+	 /**
31
+	  * EE_Encryption object
32
+	  *
33
+	  * @var EE_Encryption
34
+	  */
35
+	 protected $encryption;
36
+
37
+	 /**
38 38
 	  * the session id
39 39
 	  * @var string
40 40
 	  */
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
 	  */
66 66
 	 private $_expiration;
67 67
 
68
-    /**
69
-     * whether or not session has expired at some point
70
-     *
71
-     * @var boolean
72
-     */
73
-    private $_expired = false;
68
+	/**
69
+	 * whether or not session has expired at some point
70
+	 *
71
+	 * @var boolean
72
+	 */
73
+	private $_expired = false;
74 74
 
75 75
 	 /**
76 76
 	  * current time as Unix timestamp in GMT
@@ -107,30 +107,30 @@  discard block
 block discarded – undo
107 107
 	  * @var array
108 108
 	  */
109 109
 	 private $_default_session_vars = array (
110
-        'id'            => null,
111
-        'user_id'       => null,
112
-        'ip_address'    => null,
113
-        'user_agent'    => null,
114
-        'init_access'   => null,
115
-        'last_access'   => null,
116
-        'expiration'    => null,
117
-        'pages_visited' => array(),
110
+		'id'            => null,
111
+		'user_id'       => null,
112
+		'ip_address'    => null,
113
+		'user_agent'    => null,
114
+		'init_access'   => null,
115
+		'last_access'   => null,
116
+		'expiration'    => null,
117
+		'pages_visited' => array(),
118 118
 	);
119 119
 
120 120
 
121 121
 
122 122
 	 /**
123 123
 	  * @singleton method used to instantiate class object
124
-      * @param TransientManager $expired_transient_manager
125
-      * @param \EE_Encryption   $encryption
124
+	  * @param TransientManager $expired_transient_manager
125
+	  * @param \EE_Encryption   $encryption
126 126
 	  * @return EE_Session
127 127
 	  * @throws InvalidSessionDataException
128 128
 	  * @throws \EE_Error
129 129
 	  */
130 130
 	public static function instance(
131
-	    TransientManager $expired_transient_manager = null,
132
-        EE_Encryption $encryption = null
133
-    ) {
131
+		TransientManager $expired_transient_manager = null,
132
+		EE_Encryption $encryption = null
133
+	) {
134 134
 		// check if class object is instantiated
135 135
 		// session loading is turned ON by default, but prior to the init hook, can be turned back OFF via:
136 136
 		// add_filter( 'FHEE_load_EE_Session', '__return_false' );
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
 
144 144
 
145 145
 	 /**
146
-      * protected constructor to prevent direct creation
147
-      *
148
-      * @param TransientManager $expired_transient_manager
149
-      * @param \EE_Encryption $encryption
146
+	  * protected constructor to prevent direct creation
147
+	  *
148
+	  * @param TransientManager $expired_transient_manager
149
+	  * @param \EE_Encryption $encryption
150 150
 	  * @throws \EE_Error
151 151
 	  * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
152 152
 	  */
@@ -181,59 +181,59 @@  discard block
 block discarded – undo
181 181
 				$this->{$var_name} = $session_setting;
182 182
 			}
183 183
 		}
184
-         $this->transient_manager = $expired_transient_manager;
185
-         // are we using encryption?
186
-         $this->_use_encryption = $encryption instanceof EE_Encryption && EE_Registry::instance()->CFG->admin->encode_session_data();
187
-         // \EEH_Debug_Tools::printr($this->_use_encryption, '$this->_use_encryption', __FILE__, __LINE__);
188
-        // encrypt data via: $this->encryption->encrypt();
189
-        $this->encryption = $encryption;
184
+		 $this->transient_manager = $expired_transient_manager;
185
+		 // are we using encryption?
186
+		 $this->_use_encryption = $encryption instanceof EE_Encryption && EE_Registry::instance()->CFG->admin->encode_session_data();
187
+		 // \EEH_Debug_Tools::printr($this->_use_encryption, '$this->_use_encryption', __FILE__, __LINE__);
188
+		// encrypt data via: $this->encryption->encrypt();
189
+		$this->encryption = $encryption;
190 190
 		// filter hook allows outside functions/classes/plugins to change default empty cart
191 191
 		$extra_default_session_vars = apply_filters( 'FHEE__EE_Session__construct__extra_default_session_vars', array() );
192 192
 		array_merge( $this->_default_session_vars, $extra_default_session_vars );
193 193
 		// apply default session vars
194 194
 		$this->_set_defaults();
195
-         add_action('AHEE__EE_System__initialize', array($this, 'open_session'));
196
-         // check request for 'clear_session' param
195
+		 add_action('AHEE__EE_System__initialize', array($this, 'open_session'));
196
+		 // check request for 'clear_session' param
197 197
 		add_action( 'AHEE__EE_Request_Handler__construct__complete', array( $this, 'wp_loaded' ));
198 198
 		// once everything is all said and done,
199 199
 		add_action( 'shutdown', array( $this, 'update' ), 100 );
200
-         $this->configure_garbage_collection_filters();
200
+		 $this->configure_garbage_collection_filters();
201 201
 	}
202 202
 
203 203
 
204 204
 
205
-     /**
206
-      * @return void
207
-      * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
208
-      * @throws \EE_Error
209
-      */
205
+	 /**
206
+	  * @return void
207
+	  * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
208
+	  * @throws \EE_Error
209
+	  */
210 210
 	 public function open_session() {
211
-         // check for existing session and retrieve it from db
212
-         if ( ! $this->_espresso_session()) {
213
-             // or just start a new one
214
-             $this->_create_espresso_session();
215
-         }
216
-     }
211
+		 // check for existing session and retrieve it from db
212
+		 if ( ! $this->_espresso_session()) {
213
+			 // or just start a new one
214
+			 $this->_create_espresso_session();
215
+		 }
216
+	 }
217 217
 
218 218
 
219 219
 
220
-    /**
221
-     * @return bool
222
-     */
223
-    public function expired()
224
-    {
225
-        return $this->_expired;
226
-    }
220
+	/**
221
+	 * @return bool
222
+	 */
223
+	public function expired()
224
+	{
225
+		return $this->_expired;
226
+	}
227 227
 
228 228
 
229 229
 
230
-    /**
231
-     * @return void
232
-     */
233
-    public function reset_expired()
234
-    {
235
-        $this->_expired = false;
236
-    }
230
+	/**
231
+	 * @return void
232
+	 */
233
+	public function reset_expired()
234
+	{
235
+		$this->_expired = false;
236
+	}
237 237
 
238 238
 
239 239
 	 /**
@@ -245,24 +245,24 @@  discard block
 block discarded – undo
245 245
 
246 246
 
247 247
 
248
-    /**
249
-     * @return int
250
-     */
251
-    public function extension()
252
-    {
253
-        return apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', (10 * MINUTE_IN_SECONDS));
254
-    }
248
+	/**
249
+	 * @return int
250
+	 */
251
+	public function extension()
252
+	{
253
+		return apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', (10 * MINUTE_IN_SECONDS));
254
+	}
255 255
 
256 256
 
257 257
 
258
-    /**
259
-     * @param int $time number of seconds to add to session expiration
260
-     */
261
-    public function extend_expiration($time = 0)
262
-    {
263
-        $time = $time ? $time : $this->extension();
264
-        $this->_expiration += absint($time);
265
-    }
258
+	/**
259
+	 * @param int $time number of seconds to add to session expiration
260
+	 */
261
+	public function extend_expiration($time = 0)
262
+	{
263
+		$time = $time ? $time : $this->extension();
264
+		$this->_expiration += absint($time);
265
+	}
266 266
 
267 267
 
268 268
 
@@ -306,15 +306,15 @@  discard block
 block discarded – undo
306 306
 
307 307
 
308 308
 
309
-    /**
310
-     * @param \EE_Cart $cart
311
-     * @return bool
312
-     */
313
-    public function set_cart(EE_Cart $cart)
314
-    {
315
-        $this->_session_data['cart'] = $cart;
316
-        return true;
317
-    }
309
+	/**
310
+	 * @param \EE_Cart $cart
311
+	 * @return bool
312
+	 */
313
+	public function set_cart(EE_Cart $cart)
314
+	{
315
+		$this->_session_data['cart'] = $cart;
316
+		return true;
317
+	}
318 318
 
319 319
 
320 320
 
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	  * reset_cart
323 323
 	  */
324 324
 	 public function reset_cart() {
325
-        do_action('AHEE__EE_Session__reset_cart__before_reset', $this);
325
+		do_action('AHEE__EE_Session__reset_cart__before_reset', $this);
326 326
 		 $this->_session_data['cart'] = NULL;
327 327
 	 }
328 328
 
@@ -332,9 +332,9 @@  discard block
 block discarded – undo
332 332
 	  * @return \EE_Cart
333 333
 	  */
334 334
 	 public function cart() {
335
-        return isset($this->_session_data['cart']) && $this->_session_data['cart'] instanceof EE_Cart
336
-            ? $this->_session_data['cart']
337
-            : null;
335
+		return isset($this->_session_data['cart']) && $this->_session_data['cart'] instanceof EE_Cart
336
+			? $this->_session_data['cart']
337
+			: null;
338 338
 	 }
339 339
 
340 340
 
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 	  * reset_checkout
355 355
 	  */
356 356
 	 public function reset_checkout() {
357
-        do_action('AHEE__EE_Session__reset_checkout__before_reset', $this);
357
+		do_action('AHEE__EE_Session__reset_checkout__before_reset', $this);
358 358
 		 $this->_session_data['checkout'] = NULL;
359 359
 	 }
360 360
 
@@ -364,9 +364,9 @@  discard block
 block discarded – undo
364 364
 	  * @return \EE_Checkout
365 365
 	  */
366 366
 	 public function checkout() {
367
-        return isset($this->_session_data['checkout']) && $this->_session_data['checkout'] instanceof EE_Checkout
368
-            ? $this->_session_data['checkout']
369
-            : null;
367
+		return isset($this->_session_data['checkout']) && $this->_session_data['checkout'] instanceof EE_Checkout
368
+			? $this->_session_data['checkout']
369
+			: null;
370 370
 	 }
371 371
 
372 372
 
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 	  * reset_transaction
390 390
 	  */
391 391
 	 public function reset_transaction() {
392
-        do_action('AHEE__EE_Session__reset_transaction__before_reset', $this);
392
+		do_action('AHEE__EE_Session__reset_transaction__before_reset', $this);
393 393
 		 $this->_session_data['transaction'] = NULL;
394 394
 	 }
395 395
 
@@ -399,10 +399,10 @@  discard block
 block discarded – undo
399 399
 	  * @return \EE_Transaction
400 400
 	  */
401 401
 	 public function transaction() {
402
-        return isset($this->_session_data['transaction'])
403
-               && $this->_session_data['transaction'] instanceof EE_Transaction
404
-           ? $this->_session_data['transaction']
405
-           : null;
402
+		return isset($this->_session_data['transaction'])
403
+			   && $this->_session_data['transaction'] instanceof EE_Transaction
404
+		   ? $this->_session_data['transaction']
405
+		   : null;
406 406
 	 }
407 407
 
408 408
 
@@ -479,16 +479,16 @@  discard block
 block discarded – undo
479 479
 		// set the "user agent"
480 480
 		$this->_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE;
481 481
 		// now let's retrieve what's in the db
482
-        $session_data = $this->_retrieve_session_data();
483
-        if (! empty($session_data)) {
484
-            // get the current time in UTC
482
+		$session_data = $this->_retrieve_session_data();
483
+		if (! empty($session_data)) {
484
+			// get the current time in UTC
485 485
 			$this->_time = isset( $this->_time ) ? $this->_time : time();
486 486
 			// and reset the session expiration
487 487
 			$this->_expiration = isset( $session_data['expiration'] )
488 488
 				? $session_data['expiration']
489 489
 				: $this->_time + $this->_lifespan;
490 490
 		} else {
491
-            // set initial site access time and the session expiration
491
+			// set initial site access time and the session expiration
492 492
 			$this->_set_init_access_and_expiration();
493 493
 			// set referer
494 494
 			$this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] )
@@ -497,14 +497,14 @@  discard block
 block discarded – undo
497 497
 			// no previous session = go back and create one (on top of the data above)
498 498
 			return FALSE;
499 499
 		}
500
-        // now the user agent
500
+		// now the user agent
501 501
 		if ( $session_data['user_agent'] !== $this->_user_agent ) {
502 502
 			return FALSE;
503 503
 		}
504 504
 		// wait a minute... how old are you?
505 505
 		if ( $this->_time > $this->_expiration ) {
506 506
 			// yer too old fer me!
507
-            $this->_expired = true;
507
+			$this->_expired = true;
508 508
 			// wipe out everything that isn't a default session datum
509 509
 			$this->clear_session( __CLASS__, __FUNCTION__ );
510 510
 		}
@@ -516,101 +516,101 @@  discard block
 block discarded – undo
516 516
 
517 517
 
518 518
 
519
-     /**
520
-      * _get_session_data
521
-      * Retrieves the session data, and attempts to correct any encoding issues that can occur due to improperly setup databases
522
-      *
523
-      * @return array
524
-      * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
525
-      */
526
-     protected function _retrieve_session_data()
527
-     {
528
-         $ssn_key = EE_Session::session_id_prefix . $this->_sid;
529
-         try {
530
-             // we're using WP's Transient API to store session data using the PHP session ID as the option name
531
-             $session_data = $this->transient_manager->getTransient($ssn_key, false);
532
-	         if ($session_data === false) {
533
-		         return array();
534
-             }
535
-             if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
536
-                 $hash_check = $this->transient_manager->getTransient(
537
-                     EE_Session::hash_check_prefix . $this->_sid,
538
-                     false
539
-                 );
540
-                 if ($hash_check && $hash_check !== md5($session_data)) {
541
-	                 EE_Error::add_error(
542
-                         sprintf(
543
-                             __(
544
-                                 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.',
545
-                                 'event_espresso'
546
-                             ),
547
-                             EE_Session::session_id_prefix . $this->_sid
548
-                         ),
549
-                         __FILE__, __FUNCTION__, __LINE__
550
-                     );
551
-                 }
552
-             }
553
-         } catch (Exception $e) {
554
-             // let's just eat that error for now and attempt to correct any corrupted data
555
-             global $wpdb;
556
-             $row = $wpdb->get_row(
557
-                 $wpdb->prepare(
558
-                     "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1",
559
-                     '_transient_' . $ssn_key
560
-                 )
561
-             );
562
-             $session_data = is_object($row) ? $row->option_value : null;
563
-             if ($session_data) {
564
-                 $session_data = preg_replace_callback(
565
-                     '!s:(d+):"(.*?)";!',
566
-                     function ($match) {
567
-                         return $match[1] === strlen($match[2])
568
-                             ? $match[0]
569
-                             : 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
570
-                     },
571
-                     $session_data
572
-                 );
573
-             }
574
-	         $session_data = maybe_unserialize($session_data);
575
-         }
576
-	     // in case the data is encoded... try to decode it
577
-         $session_data = $this->encryption instanceof EE_Encryption
578
-             ? $this->encryption->base64_string_decode($session_data)
579
-             : $session_data;
580
-
581
-         if ( ! is_array($session_data)) {
582
-             try {
583
-	             $session_data = maybe_unserialize($session_data);
584
-             } catch (Exception $e) {
585
-                 $msg = esc_html__(
586
-                     'An error occurred while attempting to unserialize the session data.',
587
-                     'event_espresso'
588
-                 );
589
-                 $msg .= WP_DEBUG
590
-                     ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
591
-                     : '';
592
-                 throw new InvalidSessionDataException($msg, 0, $e);
593
-             }
594
-         }
595
-         // just a check to make sure the session array is indeed an array
596
-         if ( ! is_array($session_data)) {
597
-             // no?!?! then something is wrong
598
-             $msg = esc_html__(
599
-                 'The session data is missing, invalid, or corrupted.',
600
-                 'event_espresso'
601
-             );
602
-             $msg .= WP_DEBUG
603
-                 ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
604
-                 : '';
605
-	         throw new InvalidSessionDataException($msg);
606
-         }
607
-	     if ( isset($session_data['transaction'] ) && absint($session_data['transaction'] ) !== 0 ) {
608
-             $session_data['transaction'] = EEM_Transaction::instance()->get_one_by_ID(
609
-                 $session_data['transaction']
610
-	         );
611
-	     }
612
-         return $session_data;
613
-     }
519
+	 /**
520
+	  * _get_session_data
521
+	  * Retrieves the session data, and attempts to correct any encoding issues that can occur due to improperly setup databases
522
+	  *
523
+	  * @return array
524
+	  * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
525
+	  */
526
+	 protected function _retrieve_session_data()
527
+	 {
528
+		 $ssn_key = EE_Session::session_id_prefix . $this->_sid;
529
+		 try {
530
+			 // we're using WP's Transient API to store session data using the PHP session ID as the option name
531
+			 $session_data = $this->transient_manager->getTransient($ssn_key, false);
532
+			 if ($session_data === false) {
533
+				 return array();
534
+			 }
535
+			 if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
536
+				 $hash_check = $this->transient_manager->getTransient(
537
+					 EE_Session::hash_check_prefix . $this->_sid,
538
+					 false
539
+				 );
540
+				 if ($hash_check && $hash_check !== md5($session_data)) {
541
+					 EE_Error::add_error(
542
+						 sprintf(
543
+							 __(
544
+								 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.',
545
+								 'event_espresso'
546
+							 ),
547
+							 EE_Session::session_id_prefix . $this->_sid
548
+						 ),
549
+						 __FILE__, __FUNCTION__, __LINE__
550
+					 );
551
+				 }
552
+			 }
553
+		 } catch (Exception $e) {
554
+			 // let's just eat that error for now and attempt to correct any corrupted data
555
+			 global $wpdb;
556
+			 $row = $wpdb->get_row(
557
+				 $wpdb->prepare(
558
+					 "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1",
559
+					 '_transient_' . $ssn_key
560
+				 )
561
+			 );
562
+			 $session_data = is_object($row) ? $row->option_value : null;
563
+			 if ($session_data) {
564
+				 $session_data = preg_replace_callback(
565
+					 '!s:(d+):"(.*?)";!',
566
+					 function ($match) {
567
+						 return $match[1] === strlen($match[2])
568
+							 ? $match[0]
569
+							 : 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
570
+					 },
571
+					 $session_data
572
+				 );
573
+			 }
574
+			 $session_data = maybe_unserialize($session_data);
575
+		 }
576
+		 // in case the data is encoded... try to decode it
577
+		 $session_data = $this->encryption instanceof EE_Encryption
578
+			 ? $this->encryption->base64_string_decode($session_data)
579
+			 : $session_data;
580
+
581
+		 if ( ! is_array($session_data)) {
582
+			 try {
583
+				 $session_data = maybe_unserialize($session_data);
584
+			 } catch (Exception $e) {
585
+				 $msg = esc_html__(
586
+					 'An error occurred while attempting to unserialize the session data.',
587
+					 'event_espresso'
588
+				 );
589
+				 $msg .= WP_DEBUG
590
+					 ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
591
+					 : '';
592
+				 throw new InvalidSessionDataException($msg, 0, $e);
593
+			 }
594
+		 }
595
+		 // just a check to make sure the session array is indeed an array
596
+		 if ( ! is_array($session_data)) {
597
+			 // no?!?! then something is wrong
598
+			 $msg = esc_html__(
599
+				 'The session data is missing, invalid, or corrupted.',
600
+				 'event_espresso'
601
+			 );
602
+			 $msg .= WP_DEBUG
603
+				 ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
604
+				 : '';
605
+			 throw new InvalidSessionDataException($msg);
606
+		 }
607
+		 if ( isset($session_data['transaction'] ) && absint($session_data['transaction'] ) !== 0 ) {
608
+			 $session_data['transaction'] = EEM_Transaction::instance()->get_one_by_ID(
609
+				 $session_data['transaction']
610
+			 );
611
+		 }
612
+		 return $session_data;
613
+	 }
614 614
 
615 615
 
616 616
 
@@ -677,13 +677,13 @@  discard block
 block discarded – undo
677 677
 
678 678
 
679 679
 
680
-     /**
681
-      * @update session data  prior to saving to the db
682
-      * @access public
683
-      * @param bool $new_session
684
-      * @return TRUE on success, FALSE on fail
685
-      * @throws \EE_Error
686
-      */
680
+	 /**
681
+	  * @update session data  prior to saving to the db
682
+	  * @access public
683
+	  * @param bool $new_session
684
+	  * @return TRUE on success, FALSE on fail
685
+	  * @throws \EE_Error
686
+	  */
687 687
 	public function update( $new_session = FALSE ) {
688 688
 		$this->_session_data = isset( $this->_session_data )
689 689
 			&& is_array( $this->_session_data )
@@ -769,12 +769,12 @@  discard block
 block discarded – undo
769 769
 
770 770
 
771 771
 
772
-     /**
773
-      * @create session data array
774
-      * @access public
775
-      * @return bool
776
-      * @throws \EE_Error
777
-      */
772
+	 /**
773
+	  * @create session data array
774
+	  * @access public
775
+	  * @return bool
776
+	  * @throws \EE_Error
777
+	  */
778 778
 	private function _create_espresso_session( ) {
779 779
 		do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' );
780 780
 		// use the update function for now with $new_session arg set to TRUE
@@ -794,19 +794,19 @@  discard block
 block discarded – undo
794 794
 		if (
795 795
 			// if the current request is NOT one of the following
796 796
 			! (
797
-                // an an AJAX request from the frontend
798
-                EE_Registry::instance()->REQ->front_ajax
799
-                || (
800
-                    // OR an admin request that is NOT AJAX
797
+				// an an AJAX request from the frontend
798
+				EE_Registry::instance()->REQ->front_ajax
799
+				|| (
800
+					// OR an admin request that is NOT AJAX
801 801
 					! ( defined( 'DOING_AJAX' ) && DOING_AJAX )
802
-                    && is_admin()
802
+					&& is_admin()
803 803
 				)
804
-                || (
805
-                    // OR an espresso page
806
-                    EE_Registry::instance()->REQ instanceof EE_Request_Handler
807
-                    && EE_Registry::instance()->REQ->is_espresso_page()
808
-                )
809
-            )
804
+				|| (
805
+					// OR an espresso page
806
+					EE_Registry::instance()->REQ instanceof EE_Request_Handler
807
+					&& EE_Registry::instance()->REQ->is_espresso_page()
808
+				)
809
+			)
810 810
 		) {
811 811
 			return false;
812 812
 		}
@@ -817,27 +817,27 @@  discard block
 block discarded – undo
817 817
 			}
818 818
 			$this->_session_data['transaction'] = $transaction->ID();
819 819
 		}
820
-        // then serialize all of our session data
820
+		// then serialize all of our session data
821 821
 		$session_data = serialize($this->_session_data);
822 822
 		// do we need to also encode it to avoid corrupted data when saved to the db?
823 823
 		$session_data = $this->_use_encryption
824
-            ? $this->encryption->base64_string_encode( $session_data )
825
-            : $session_data;
824
+			? $this->encryption->base64_string_encode( $session_data )
825
+			: $session_data;
826 826
 		// maybe save hash check
827 827
 		if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) {
828
-            $this->transient_manager->addTransient(
829
-                EE_Session::hash_check_prefix . $this->_sid,
830
-                md5($session_data),
831
-                $this->_lifespan
832
-            );
833
-        }
834
-        // we're using the Transient API for storing session data,
835
-        return $this->transient_manager->addTransient(
836
-            EE_Session::session_id_prefix . $this->_sid,
837
-            $session_data,
838
-            $this->_lifespan
839
-        );
840
-    }
828
+			$this->transient_manager->addTransient(
829
+				EE_Session::hash_check_prefix . $this->_sid,
830
+				md5($session_data),
831
+				$this->_lifespan
832
+			);
833
+		}
834
+		// we're using the Transient API for storing session data,
835
+		return $this->transient_manager->addTransient(
836
+			EE_Session::session_id_prefix . $this->_sid,
837
+			$session_data,
838
+			$this->_lifespan
839
+		);
840
+	}
841 841
 
842 842
 
843 843
 
@@ -930,18 +930,18 @@  discard block
 block discarded – undo
930 930
 
931 931
 
932 932
 
933
-     /**
934
-      * Clear EE_Session data
935
-      *
936
-      * @access public
937
-      * @param string $class
938
-      * @param string $function
939
-      * @return void
940
-      * @throws \EE_Error
941
-      */
933
+	 /**
934
+	  * Clear EE_Session data
935
+	  *
936
+	  * @access public
937
+	  * @param string $class
938
+	  * @param string $function
939
+	  * @return void
940
+	  * @throws \EE_Error
941
+	  */
942 942
 	public function clear_session( $class = '', $function = '' ) {
943 943
 		//echo '<h3 style="color:#999;line-height:.9em;"><span style="color:#2EA2CC">' . __CLASS__ . '</span>::<span style="color:#E76700">' . __FUNCTION__ . '( ' . $class . '::' . $function . '() )</span><br/><span style="font-size:9px;font-weight:normal;">' . __FILE__ . '</span>    <b style="font-size:10px;">  ' . __LINE__ . ' </b></h3>';
944
-        do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' .  $function . '()' );
944
+		do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' .  $function . '()' );
945 945
 		$this->reset_cart();
946 946
 		$this->reset_checkout();
947 947
 		$this->reset_transaction();
@@ -1008,12 +1008,12 @@  discard block
 block discarded – undo
1008 1008
 
1009 1009
 
1010 1010
 
1011
-     /**
1012
-      *   wp_loaded
1013
-      *
1014
-      * @access public
1015
-      * @throws \EE_Error
1016
-      */
1011
+	 /**
1012
+	  *   wp_loaded
1013
+	  *
1014
+	  * @access public
1015
+	  * @throws \EE_Error
1016
+	  */
1017 1017
 	public function wp_loaded() {
1018 1018
 		if ( isset(  EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) {
1019 1019
 			$this->clear_session( __CLASS__, __FUNCTION__ );
@@ -1022,12 +1022,12 @@  discard block
 block discarded – undo
1022 1022
 
1023 1023
 
1024 1024
 
1025
-     /**
1026
-      * Used to reset the entire object (for tests).
1027
-      *
1028
-      * @since 4.3.0
1029
-      * @throws \EE_Error
1030
-      */
1025
+	 /**
1026
+	  * Used to reset the entire object (for tests).
1027
+	  *
1028
+	  * @since 4.3.0
1029
+	  * @throws \EE_Error
1030
+	  */
1031 1031
 	public function reset_instance() {
1032 1032
 		$this->clear_session();
1033 1033
 		self::$_instance = NULL;
@@ -1035,29 +1035,29 @@  discard block
 block discarded – undo
1035 1035
 
1036 1036
 
1037 1037
 
1038
-     public function configure_garbage_collection_filters()
1039
-     {
1040
-         // run old filter we had for controlling session cleanup
1041
-         $expired_session_transient_delete_query_limit = absint(
1042
-             apply_filters(
1043
-                 'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit',
1044
-                 50
1045
-             )
1046
-         );
1047
-         // is there a value?
1048
-         if ($expired_session_transient_delete_query_limit) {
1049
-             // then use that for the new transient cleanup query limit
1050
-             add_filter(
1051
-                 'FHEE__EventEspresso_core_services_database_ExpiredTransientManager__clearExpiredTransients__limit',
1052
-                 function () use ($expired_session_transient_delete_query_limit) {
1053
-                     return $expired_session_transient_delete_query_limit;
1054
-                 }
1055
-             );
1056
-         } else {
1057
-             // or hook into TransientManager in case Session cleanup was turned off
1058
-             add_filter('FHEE__ExpiredTransientManager__transient_cleanup_schedule', '__return_zero');
1059
-         }
1060
-     }
1038
+	 public function configure_garbage_collection_filters()
1039
+	 {
1040
+		 // run old filter we had for controlling session cleanup
1041
+		 $expired_session_transient_delete_query_limit = absint(
1042
+			 apply_filters(
1043
+				 'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit',
1044
+				 50
1045
+			 )
1046
+		 );
1047
+		 // is there a value?
1048
+		 if ($expired_session_transient_delete_query_limit) {
1049
+			 // then use that for the new transient cleanup query limit
1050
+			 add_filter(
1051
+				 'FHEE__EventEspresso_core_services_database_ExpiredTransientManager__clearExpiredTransients__limit',
1052
+				 function () use ($expired_session_transient_delete_query_limit) {
1053
+					 return $expired_session_transient_delete_query_limit;
1054
+				 }
1055
+			 );
1056
+		 } else {
1057
+			 // or hook into TransientManager in case Session cleanup was turned off
1058
+			 add_filter('FHEE__ExpiredTransientManager__transient_cleanup_schedule', '__return_zero');
1059
+		 }
1060
+	 }
1061 1061
 
1062 1062
 
1063 1063
 
Please login to merge, or discard this patch.