Completed
Branch BUG/3575-event-deletion-previe... (bbeda1)
by
unknown
06:40 queued 04:49
created
public/Espresso_Arabica_2014/content-espresso_events-venues.php 2 patches
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -51,8 +51,11 @@  discard block
 block discarded – undo
51 51
 		<?php echo do_shortcode( $venue_description ); ?>
52 52
 	</p>
53 53
 		<?php endif;  ?>
54
-	<?php else : ?>
55
-		<?php $venue_excerpt = espresso_venue_excerpt( $VNU_ID, FALSE ); ?>
54
+	<?php else {
55
+	: ?>
56
+		<?php $venue_excerpt = espresso_venue_excerpt( $VNU_ID, FALSE );
57
+}
58
+?>
56 59
 		<?php if ( $venue_excerpt ) : ?>
57 60
 	<p>
58 61
 		<strong><?php esc_html_e( 'Description:', 'event_espresso' ); ?></strong><br/>
@@ -64,12 +67,15 @@  discard block
 block discarded – undo
64 67
 <!-- .espresso-venue-dv -->
65 68
 <?php
66 69
 do_action( 'AHEE_event_details_after_venue_details', $post );
67
-else :
70
+else {
71
+	:
68 72
 	if ( espresso_venue_is_password_protected() ) :
69 73
 ?>
70 74
 	<div class="espresso-venue-dv  espresso-password-protected-venue-dv" >
71 75
 		<h3 class="event-venues-h3 ee-event-h3">
72
-			<?php esc_html_e( 'Location', 'event_espresso' );?>
76
+			<?php esc_html_e( 'Location', 'event_espresso' );
77
+}
78
+?>
73 79
 		</h3>
74 80
 		<?php echo espresso_password_protected_venue_form(); ?>
75 81
 	</div>
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,75 +1,75 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (
4
-	( is_single() && espresso_display_venue_in_event_details() )
5
-	|| ( is_archive() && espresso_display_venue_in_event_list() )
4
+	(is_single() && espresso_display_venue_in_event_details())
5
+	|| (is_archive() && espresso_display_venue_in_event_list())
6 6
 ) :
7 7
 	global $post;
8
-	do_action( 'AHEE_event_details_before_venue_details', $post );
9
-	$venue_name = espresso_venue_name( 0, 'details', FALSE );
10
-	if ( empty( $venue_name ) && espresso_is_venue_private() ) {
11
-		do_action( 'AHEE_event_details_after_venue_details', $post );
8
+	do_action('AHEE_event_details_before_venue_details', $post);
9
+	$venue_name = espresso_venue_name(0, 'details', FALSE);
10
+	if (empty($venue_name) && espresso_is_venue_private()) {
11
+		do_action('AHEE_event_details_after_venue_details', $post);
12 12
 		return '';
13 13
 	}
14 14
 ?>
15 15
 
16 16
 <div class="espresso-venue-dv<?php echo espresso_is_venue_private() ? ' espresso-private-venue-dv' : ''; ?>">
17 17
 	<h4>
18
-        <strong><?php esc_html_e( 'Venue:', 'event_espresso' ); ?></strong>&nbsp;&nbsp;
18
+        <strong><?php esc_html_e('Venue:', 'event_espresso'); ?></strong>&nbsp;&nbsp;
19 19
         <strong> <?php echo $venue_name; // already escaped ?></strong>
20 20
     </h4>
21 21
 	<p><span class="smaller-text tags-links"><?php echo espresso_venue_categories(); ?></span></p>
22
-<?php  if ( $venue_phone = espresso_venue_phone( $post->ID, FALSE )) : ?>
22
+<?php  if ($venue_phone = espresso_venue_phone($post->ID, FALSE)) : ?>
23 23
 	<p>
24 24
 		<span class="small-text">
25
-            <strong><?php esc_html_e( 'Venue Phone:', 'event_espresso' ); ?></strong>
25
+            <strong><?php esc_html_e('Venue Phone:', 'event_espresso'); ?></strong>
26 26
         </span>
27 27
         <?php echo $venue_phone; // already escaped ?>
28 28
 	</p>
29
-<?php endif;  ?>
30
-<?php if ( $venue_website = espresso_venue_website( $post->ID, FALSE )) : ?>
29
+<?php endif; ?>
30
+<?php if ($venue_website = espresso_venue_website($post->ID, FALSE)) : ?>
31 31
 	<p>
32 32
 		<span class="small-text">
33
-            <strong><?php esc_html_e( 'Venue Website:', 'event_espresso' ); ?></strong>
33
+            <strong><?php esc_html_e('Venue Website:', 'event_espresso'); ?></strong>
34 34
         </span>
35 35
         <?php echo $venue_website; // already escaped ?>
36 36
 	</p>
37 37
 <?php endif; ?>
38
-<?php  if ( espresso_venue_has_address( $post->ID )) : ?>
39
-	<strong><span class="dashicons dashicons-location-alt"></span><?php esc_html_e( 'Address:', 'event_espresso' ); ?></strong>
40
-	<?php espresso_venue_address( 'inline' ); // already escaped ?>
41
-	<?php espresso_venue_gmap( $post->ID ); // already escaped ?>
38
+<?php  if (espresso_venue_has_address($post->ID)) : ?>
39
+	<strong><span class="dashicons dashicons-location-alt"></span><?php esc_html_e('Address:', 'event_espresso'); ?></strong>
40
+	<?php espresso_venue_address('inline'); // already escaped ?>
41
+	<?php espresso_venue_gmap($post->ID); // already escaped ?>
42 42
 	<div class="clear"><br/></div>
43
-<?php endif;  ?>
43
+<?php endif; ?>
44 44
 
45
-	<?php $VNU_ID = espresso_venue_id( $post->ID ); ?>
46
-	<?php if ( is_single() ) : ?>
47
-		<?php $venue_description = espresso_venue_description( $VNU_ID, FALSE ); ?>
48
-		<?php if ( $venue_description ) : ?>
45
+	<?php $VNU_ID = espresso_venue_id($post->ID); ?>
46
+	<?php if (is_single()) : ?>
47
+		<?php $venue_description = espresso_venue_description($VNU_ID, FALSE); ?>
48
+		<?php if ($venue_description) : ?>
49 49
 	<p>
50
-		<strong><?php esc_html_e( 'Description:', 'event_espresso' ); ?></strong><br/>
51
-		<?php echo do_shortcode( $venue_description ); ?>
50
+		<strong><?php esc_html_e('Description:', 'event_espresso'); ?></strong><br/>
51
+		<?php echo do_shortcode($venue_description); ?>
52 52
 	</p>
53
-		<?php endif;  ?>
53
+		<?php endif; ?>
54 54
 	<?php else : ?>
55
-		<?php $venue_excerpt = espresso_venue_excerpt( $VNU_ID, FALSE ); ?>
56
-		<?php if ( $venue_excerpt ) : ?>
55
+		<?php $venue_excerpt = espresso_venue_excerpt($VNU_ID, FALSE); ?>
56
+		<?php if ($venue_excerpt) : ?>
57 57
 	<p>
58
-		<strong><?php esc_html_e( 'Description:', 'event_espresso' ); ?></strong><br/>
58
+		<strong><?php esc_html_e('Description:', 'event_espresso'); ?></strong><br/>
59 59
 		<?php echo $venue_excerpt; ?>
60 60
 	</p>
61
-			<?php endif;  ?>
62
-		<?php endif;  ?>
61
+			<?php endif; ?>
62
+		<?php endif; ?>
63 63
 </div>
64 64
 <!-- .espresso-venue-dv -->
65 65
 <?php
66
-do_action( 'AHEE_event_details_after_venue_details', $post );
66
+do_action('AHEE_event_details_after_venue_details', $post);
67 67
 else :
68
-	if ( espresso_venue_is_password_protected() ) :
68
+	if (espresso_venue_is_password_protected()) :
69 69
 ?>
70 70
 	<div class="espresso-venue-dv  espresso-password-protected-venue-dv" >
71 71
 		<h3 class="event-venues-h3 ee-event-h3">
72
-			<?php esc_html_e( 'Location', 'event_espresso' );?>
72
+			<?php esc_html_e('Location', 'event_espresso'); ?>
73 73
 		</h3>
74 74
 		<?php echo espresso_password_protected_venue_form(); ?>
75 75
 	</div>
Please login to merge, or discard this patch.
public/Espresso_Arabica_2014/content-espresso_events-thumbnail.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 global $post;
4
-do_action( 'AHEE_event_details_before_featured_img', $post );
4
+do_action('AHEE_event_details_before_featured_img', $post);
5 5
 
6
-if ( has_post_thumbnail( $post->ID )) :
7
-	if ( $img_ID = get_post_thumbnail_id( $post->ID )) :
8
-		if ( $featured_img = wp_get_attachment_image_src( $img_ID, 'large' )) :
9
-			$caption = get_post( get_post( $img_ID ))->post_excerpt;
6
+if (has_post_thumbnail($post->ID)) :
7
+	if ($img_ID = get_post_thumbnail_id($post->ID)) :
8
+		if ($featured_img = wp_get_attachment_image_src($img_ID, 'large')) :
9
+			$caption = get_post(get_post($img_ID))->post_excerpt;
10 10
 			?>
11 11
 <div id="ee-event-img-dv-<?php echo $post->ID; ?>" class="ee-event-img-dv">
12
-	<a class="ee-event-img-lnk" href="<?php the_permalink(); ?>"<?php echo EED_Events_Archive::link_target();?>>
12
+	<a class="ee-event-img-lnk" href="<?php the_permalink(); ?>"<?php echo EED_Events_Archive::link_target(); ?>>
13 13
 		<img alt="<?php echo esc_attr($caption); ?>"
14 14
              class="ee-event-img"
15 15
              height="<?php echo esc_attr($featured_img[2]); ?>"
@@ -23,4 +23,4 @@  discard block
 block discarded – undo
23 23
 	endif;
24 24
 endif;
25 25
 ?>
26
-<?php do_action( 'AHEE_event_details_after_featured_img', $post );?>
26
+<?php do_action('AHEE_event_details_after_featured_img', $post); ?>
Please login to merge, or discard this patch.
public/Espresso_Arabica_2014/content-espresso_events-header.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@
 block discarded – undo
7 7
 	<?php echo "<{$tag}  id=\"event-details-{$tag}-{$post->ID}\" class=\"entry-title\">"; ?>
8 8
 		<a class="ee-event-header-lnk"
9 9
            href="<?php the_permalink(); ?>"
10
-           <?php echo \EED_Events_Archive::link_target();?>
10
+           <?php echo \EED_Events_Archive::link_target(); ?>
11 11
         >
12 12
             <?php the_title(); ?>
13 13
         </a>
14 14
 	<?php echo "</{$tag}>"; ?>
15
-	<?php if ( ! is_archive() && has_excerpt( $post->ID )): the_excerpt(); endif;?>
15
+	<?php if ( ! is_archive() && has_excerpt($post->ID)): the_excerpt(); endif; ?>
16 16
 </header>
Please login to merge, or discard this patch.
ui/blocks/event-attendees.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -13,25 +13,25 @@  discard block
 block discarded – undo
13 13
 <div id="ee-block-event-attendees" class="ee-core-blocks event-espresso-blocks event-attendees">
14 14
     <ul>
15 15
         <?php
16
-        foreach ($attendees as $attendee) {
17
-            $attendee_name = esc_html($attendee->full_name());
16
+		foreach ($attendees as $attendee) {
17
+			$attendee_name = esc_html($attendee->full_name());
18 18
 
19
-            $gravatar = $attributes['showGravatar']
20
-                ? get_avatar_url(
21
-                    $attendee->email(),
22
-                    array(
23
-                        'width'   => $attributes['avatarSize'],
24
-                        'height'  => $attributes['avatarSize']
25
-                    )
26
-                )
27
-                : '';
19
+			$gravatar = $attributes['showGravatar']
20
+				? get_avatar_url(
21
+					$attendee->email(),
22
+					array(
23
+						'width'   => $attributes['avatarSize'],
24
+						'height'  => $attributes['avatarSize']
25
+					)
26
+				)
27
+				: '';
28 28
 
29
-            $gravatar_class = $attributes['avatarClass']
30
-                ? $attributes['avatarClass'] . ' contact-avatar-img avatar'
31
-                : 'contact-avatar-img avatar';
29
+			$gravatar_class = $attributes['avatarClass']
30
+				? $attributes['avatarClass'] . ' contact-avatar-img avatar'
31
+				: 'contact-avatar-img avatar';
32 32
 
33
-            $gravatar = $gravatar !== ''
34
-                ? '
33
+			$gravatar = $gravatar !== ''
34
+				? '
35 35
                 <div class="contact-image-wrap-div">
36 36
                     <img class="' . esc_attr($gravatar_class) . '"
37 37
                          width="' . esc_attr($attributes['avatarSize']) . '"
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
                          alt="contact avatar"
41 41
                      >
42 42
                  </div>'
43
-                : '';
43
+				: '';
44 44
 
45
-            echo "
45
+			echo "
46 46
             <li>
47 47
                 {$gravatar}<span>{$attendee_name}</span>
48 48
             </li>";
49
-        }
50
-        ?>
49
+		}
50
+		?>
51 51
     </ul>
52 52
 </div>
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,16 +27,16 @@
 block discarded – undo
27 27
                 : '';
28 28
 
29 29
             $gravatar_class = $attributes['avatarClass']
30
-                ? $attributes['avatarClass'] . ' contact-avatar-img avatar'
30
+                ? $attributes['avatarClass'].' contact-avatar-img avatar'
31 31
                 : 'contact-avatar-img avatar';
32 32
 
33 33
             $gravatar = $gravatar !== ''
34 34
                 ? '
35 35
                 <div class="contact-image-wrap-div">
36
-                    <img class="' . esc_attr($gravatar_class) . '"
37
-                         width="' . esc_attr($attributes['avatarSize']) . '"
38
-                         height="' . esc_attr($attributes['avatarSize']) . '"
39
-                         src="' . esc_url_raw($gravatar) . '" 
36
+                    <img class="' . esc_attr($gravatar_class).'"
37
+                         width="' . esc_attr($attributes['avatarSize']).'"
38
+                         height="' . esc_attr($attributes['avatarSize']).'"
39
+                         src="' . esc_url_raw($gravatar).'" 
40 40
                          alt="contact avatar"
41 41
                      >
42 42
                  </div>'
Please login to merge, or discard this patch.
core/templates/espresso-ajax-notices.template.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <div id="espresso-ajax-loading" style="display:none;">
2 2
     <span class="ee-spinner ee-spin"></span><span style="display:none;">
3 3
         <?php esc_html_e(
4
-            'loading...',
5
-            'event_espresso'
6
-        ); ?></span>
4
+			'loading...',
5
+			'event_espresso'
6
+		); ?></span>
7 7
 </div>
8 8
 
9 9
 <div id="espresso-ajax-notices">
Please login to merge, or discard this patch.
core/templates/json_linked_data_for_event.template.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
   "eventStatus": [ <?php echo esc_html($event_status); ?> ],
30 30
   "offers": [
31 31
     <?php
32
-    $i = 0;
33
-    foreach ($event_tickets as $ticket) {?>
32
+	$i = 0;
33
+	foreach ($event_tickets as $ticket) {?>
34 34
     {
35 35
       "@type": "Offer",
36 36
       "url": "<?php echo esc_url_raw($event_permalink); ?>",
@@ -39,18 +39,18 @@  discard block
 block discarded – undo
39 39
       "price": "<?php echo esc_html($ticket['price']); ?>",
40 40
       "priceCurrency": "<?php echo esc_html($currency); ?>"
41 41
         <?php if (isset($ticket['availability'])) {
42
-            ?>,"availability": "<?php echo esc_url_raw('https://schema.org/' . $ticket['availability']); ?>"
42
+			?>,"availability": "<?php echo esc_url_raw('https://schema.org/' . $ticket['availability']); ?>"
43 43
         <?php } ?>
44 44
     }<?php
45
-    $i++;
46
-    if ($i < count($event_tickets)) {
47
-        echo ',';
48
-    }
49
-    }
50
-    ?>
45
+	$i++;
46
+	if ($i < count($event_tickets)) {
47
+		echo ',';
48
+	}
49
+	}
50
+	?>
51 51
     ]<?php
52
-    if ($venue_name) {
53
-        ?>,
52
+	if ($venue_name) {
53
+		?>,
54 54
   "location": {
55 55
     "@type": "Place",
56 56
     "name": <?php echo wp_json_encode($venue_name); ?>,
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
     }
64 64
   }
65 65
         <?php
66
-    } ?>
66
+	} ?>
67 67
     <?php
68
-    if ($event_image) {
69
-        ?>,
68
+	if ($event_image) {
69
+		?>,
70 70
   "image": "<?php echo $event_image; ?>"
71 71
         <?php
72
-    } ?>
72
+	} ?>
73 73
     <?php do_action('AHEE__json_linked_data_for_event__template'); ?>
74 74
 }
75 75
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
   "endDate": "<?php echo esc_html($event_end); ?>",
26 26
   "description": <?php echo wp_json_encode($event_description); ?>,
27 27
   "url": "<?php echo esc_url_raw($event_permalink); ?>",
28
-  "eventAttendanceMode": "<?php echo esc_url_raw('https://schema.org/' . $event_attendance_mode); ?>",
28
+  "eventAttendanceMode": "<?php echo esc_url_raw('https://schema.org/'.$event_attendance_mode); ?>",
29 29
   "eventStatus": [ <?php echo esc_html($event_status); ?> ],
30 30
   "offers": [
31 31
     <?php
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
       "price": "<?php echo esc_html($ticket['price']); ?>",
40 40
       "priceCurrency": "<?php echo esc_html($currency); ?>"
41 41
         <?php if (isset($ticket['availability'])) {
42
-            ?>,"availability": "<?php echo esc_url_raw('https://schema.org/' . $ticket['availability']); ?>"
42
+            ?>,"availability": "<?php echo esc_url_raw('https://schema.org/'.$ticket['availability']); ?>"
43 43
         <?php } ?>
44 44
     }<?php
45 45
     $i++;
Please login to merge, or discard this patch.
core/exceptions/ExceptionStackTraceDisplay.php 2 patches
Indentation   +283 added lines, -283 removed lines patch added patch discarded remove patch
@@ -20,52 +20,52 @@  discard block
 block discarded – undo
20 20
 {
21 21
 
22 22
 
23
-    /**
24
-     * @param Exception $exception
25
-     * @throws Exception
26
-     */
27
-    public function __construct(Exception $exception)
28
-    {
29
-        if (WP_DEBUG && ! defined('EE_TESTS_DIR')) {
30
-            $this->displayException($exception);
31
-        } else {
32
-            throw $exception;
33
-        }
34
-    }
23
+	/**
24
+	 * @param Exception $exception
25
+	 * @throws Exception
26
+	 */
27
+	public function __construct(Exception $exception)
28
+	{
29
+		if (WP_DEBUG && ! defined('EE_TESTS_DIR')) {
30
+			$this->displayException($exception);
31
+		} else {
32
+			throw $exception;
33
+		}
34
+	}
35 35
 
36 36
 
37
-    /**
38
-     * @access protected
39
-     * @param Exception $exception
40
-     * @throws ReflectionException
41
-     */
42
-    protected function displayException(Exception $exception)
43
-    {
44
-        $error_code = '';
45
-        $trace_details = '';
46
-        $time = time();
47
-        $trace = $exception->getTrace();
48
-        // get separate user and developer messages if they exist
49
-        $msg = explode('||', $exception->getMessage());
50
-        $user_msg = $msg[0];
51
-        $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
52
-        $msg = WP_DEBUG ? $dev_msg : $user_msg;
53
-        // start gathering output
54
-        $output = $this->exceptionStyles();
55
-        $output .= '
37
+	/**
38
+	 * @access protected
39
+	 * @param Exception $exception
40
+	 * @throws ReflectionException
41
+	 */
42
+	protected function displayException(Exception $exception)
43
+	{
44
+		$error_code = '';
45
+		$trace_details = '';
46
+		$time = time();
47
+		$trace = $exception->getTrace();
48
+		// get separate user and developer messages if they exist
49
+		$msg = explode('||', $exception->getMessage());
50
+		$user_msg = $msg[0];
51
+		$dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
52
+		$msg = WP_DEBUG ? $dev_msg : $user_msg;
53
+		// start gathering output
54
+		$output = $this->exceptionStyles();
55
+		$output .= '
56 56
 <div id="ee-error-message" class="error">';
57
-        if (! WP_DEBUG) {
58
-            $output .= '
57
+		if (! WP_DEBUG) {
58
+			$output .= '
59 59
 	<p>';
60
-        }
61
-        // process trace info
62
-        if (empty($trace)) {
63
-            $trace_details .= esc_html__(
64
-                'Sorry, but no trace information was available for this exception.',
65
-                'event_espresso'
66
-            );
67
-        } else {
68
-            $trace_details .= '
60
+		}
61
+		// process trace info
62
+		if (empty($trace)) {
63
+			$trace_details .= esc_html__(
64
+				'Sorry, but no trace information was available for this exception.',
65
+				'event_espresso'
66
+			);
67
+		} else {
68
+			$trace_details .= '
69 69
 			<div id="ee-trace-details">
70 70
 			<table width="100%" border="0" cellpadding="5" cellspacing="0">
71 71
 				<tr>
@@ -74,262 +74,262 @@  discard block
 block discarded – undo
74 74
 					<th scope="col" align="left" style="width:40%;">File</th>
75 75
 					<th scope="col" align="left">
76 76
 					' . esc_html__('Class', 'event_espresso')
77
-                      . '->'
78
-                      . esc_html__('Method( arguments )', 'event_espresso') . '
77
+					  . '->'
78
+					  . esc_html__('Method( arguments )', 'event_espresso') . '
79 79
 					</th>
80 80
 				</tr>';
81
-            $last_on_stack = count($trace) - 1;
82
-            // reverse array so that stack is in proper chronological order
83
-            $sorted_trace = array_reverse($trace);
84
-            foreach ($sorted_trace as $nmbr => $trace) {
85
-                $file = isset($trace['file']) ? $trace['file'] : '';
86
-                $class = isset($trace['class']) ? $trace['class'] : '';
87
-                $type = isset($trace['type']) ? $trace['type'] : '';
88
-                $function = isset($trace['function']) ? $trace['function'] : '';
89
-                $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
90
-                $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args;
91
-                $line = isset($trace['line']) ? $trace['line'] : '';
92
-                $zebra = $nmbr % 2 !== 0 ? ' odd' : '';
93
-                if (empty($file) && ! empty($class)) {
94
-                    $a = new ReflectionClass($class);
95
-                    $file = $a->getFileName();
96
-                    if (empty($line) && ! empty($function)) {
97
-                        try {
98
-                            // if $function is a closure, this throws an exception
99
-                            $b = new ReflectionMethod($class, $function);
100
-                            $line = $b->getStartLine();
101
-                        } catch (Exception $closure_exception) {
102
-                            $line = 'unknown';
103
-                        }
104
-                    }
105
-                }
106
-                if ($nmbr === $last_on_stack) {
107
-                    $file = $exception->getFile() !== '' ? $exception->getFile() : $file;
108
-                    $line = $exception->getLine() !== '' ? $exception->getLine() : $line;
109
-                    $error_code = $this->generate_error_code($file, $trace['function'], $line);
110
-                }
111
-                $file = EEH_File::standardise_directory_separators($file);
112
-                $nmbr = ! empty($nmbr) ? $nmbr : '&nbsp;';
113
-                $line = ! empty($line) ? $line : '&nbsp;';
114
-                $file = ! empty($file) ? $file : '&nbsp;';
115
-                $class_display = ! empty($class) ? $class : '';
116
-                $type = ! empty($type) ? $type : '';
117
-                $function = ! empty($function) ? $function : '';
118
-                $args = ! empty($args) ? '( ' . $args . ' )' : '()';
119
-                $trace_details .= '
81
+			$last_on_stack = count($trace) - 1;
82
+			// reverse array so that stack is in proper chronological order
83
+			$sorted_trace = array_reverse($trace);
84
+			foreach ($sorted_trace as $nmbr => $trace) {
85
+				$file = isset($trace['file']) ? $trace['file'] : '';
86
+				$class = isset($trace['class']) ? $trace['class'] : '';
87
+				$type = isset($trace['type']) ? $trace['type'] : '';
88
+				$function = isset($trace['function']) ? $trace['function'] : '';
89
+				$args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
90
+				$args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args;
91
+				$line = isset($trace['line']) ? $trace['line'] : '';
92
+				$zebra = $nmbr % 2 !== 0 ? ' odd' : '';
93
+				if (empty($file) && ! empty($class)) {
94
+					$a = new ReflectionClass($class);
95
+					$file = $a->getFileName();
96
+					if (empty($line) && ! empty($function)) {
97
+						try {
98
+							// if $function is a closure, this throws an exception
99
+							$b = new ReflectionMethod($class, $function);
100
+							$line = $b->getStartLine();
101
+						} catch (Exception $closure_exception) {
102
+							$line = 'unknown';
103
+						}
104
+					}
105
+				}
106
+				if ($nmbr === $last_on_stack) {
107
+					$file = $exception->getFile() !== '' ? $exception->getFile() : $file;
108
+					$line = $exception->getLine() !== '' ? $exception->getLine() : $line;
109
+					$error_code = $this->generate_error_code($file, $trace['function'], $line);
110
+				}
111
+				$file = EEH_File::standardise_directory_separators($file);
112
+				$nmbr = ! empty($nmbr) ? $nmbr : '&nbsp;';
113
+				$line = ! empty($line) ? $line : '&nbsp;';
114
+				$file = ! empty($file) ? $file : '&nbsp;';
115
+				$class_display = ! empty($class) ? $class : '';
116
+				$type = ! empty($type) ? $type : '';
117
+				$function = ! empty($function) ? $function : '';
118
+				$args = ! empty($args) ? '( ' . $args . ' )' : '()';
119
+				$trace_details .= '
120 120
 					<tr>
121 121
 						<td align="right" valign="top" class="'
122
-                                  . $zebra
123
-                                  . '">'
124
-                                  . $nmbr
125
-                                  . '</td>
122
+								  . $zebra
123
+								  . '">'
124
+								  . $nmbr
125
+								  . '</td>
126 126
 						<td align="right" valign="top" class="'
127
-                                  . $zebra
128
-                                  . '">'
129
-                                  . $line
130
-                                  . '</td>
127
+								  . $zebra
128
+								  . '">'
129
+								  . $line
130
+								  . '</td>
131 131
 						<td align="left" valign="top" class="'
132
-                                  . $zebra
133
-                                  . '">'
134
-                                  . $file
135
-                                  . '</td>
132
+								  . $zebra
133
+								  . '">'
134
+								  . $file
135
+								  . '</td>
136 136
 						<td align="left" valign="top" class="'
137
-                                  . $zebra
138
-                                  . '">'
139
-                                  . $class_display
140
-                                  . $type
141
-                                  . $function
142
-                                  . $args
143
-                                  . '</td>
137
+								  . $zebra
138
+								  . '">'
139
+								  . $class_display
140
+								  . $type
141
+								  . $function
142
+								  . $args
143
+								  . '</td>
144 144
 					</tr>';
145
-            }
146
-            $trace_details .= '
145
+			}
146
+			$trace_details .= '
147 147
 			 </table>
148 148
 			</div>';
149
-        }
150
-        $code = $exception->getCode() ? $exception->getCode() : $error_code;
151
-        // add generic non-identifying messages for non-privileged users
152
-        if (! WP_DEBUG) {
153
-            $output .= '<span class="ee-error-user-msg-spn">'
154
-                       . trim($msg)
155
-                       . '</span> &nbsp; <sup>'
156
-                       . $code
157
-                       . '</sup><br />';
158
-        } else {
159
-            // or helpful developer messages if debugging is on
160
-            $output .= '
149
+		}
150
+		$code = $exception->getCode() ? $exception->getCode() : $error_code;
151
+		// add generic non-identifying messages for non-privileged users
152
+		if (! WP_DEBUG) {
153
+			$output .= '<span class="ee-error-user-msg-spn">'
154
+					   . trim($msg)
155
+					   . '</span> &nbsp; <sup>'
156
+					   . $code
157
+					   . '</sup><br />';
158
+		} else {
159
+			// or helpful developer messages if debugging is on
160
+			$output .= '
161 161
 		<div class="ee-error-dev-msg-dv">
162 162
 			<p class="ee-error-dev-msg-pg">
163 163
 				'
164
-                       . sprintf(
165
-                           esc_html__('%1$sAn %2$s was thrown!%3$s code: %4$s', 'event_espresso'),
166
-                           '<strong class="ee-error-dev-msg-str">',
167
-                           get_class($exception),
168
-                           '</strong>  &nbsp; <span>',
169
-                           $code . '</span>'
170
-                       )
171
-                       . '<br />
164
+					   . sprintf(
165
+						   esc_html__('%1$sAn %2$s was thrown!%3$s code: %4$s', 'event_espresso'),
166
+						   '<strong class="ee-error-dev-msg-str">',
167
+						   get_class($exception),
168
+						   '</strong>  &nbsp; <span>',
169
+						   $code . '</span>'
170
+					   )
171
+					   . '<br />
172 172
 				<span class="big-text">"'
173
-                       . trim($msg)
174
-                       . '"</span><br/>
173
+					   . trim($msg)
174
+					   . '"</span><br/>
175 175
 				<a id="display-ee-error-trace-1'
176
-                       . $time
177
-                       . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-1'
178
-                       . $time
179
-                       . '">
176
+					   . $time
177
+					   . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-1'
178
+					   . $time
179
+					   . '">
180 180
 					'
181
-                       . esc_html__('click to view backtrace and class/method details', 'event_espresso')
182
-                       . '
181
+					   . esc_html__('click to view backtrace and class/method details', 'event_espresso')
182
+					   . '
183 183
 				</a><br />
184 184
 				'
185
-                       . $exception->getFile()
186
-                       . sprintf(
187
-                           esc_html__('%1$s( line no: %2$s )%3$s', 'event_espresso'),
188
-                           ' &nbsp; <span class="small-text lt-grey-text">',
189
-                           $exception->getLine(),
190
-                           '</span>'
191
-                       )
192
-                       . '
185
+					   . $exception->getFile()
186
+					   . sprintf(
187
+						   esc_html__('%1$s( line no: %2$s )%3$s', 'event_espresso'),
188
+						   ' &nbsp; <span class="small-text lt-grey-text">',
189
+						   $exception->getLine(),
190
+						   '</span>'
191
+					   )
192
+					   . '
193 193
 			</p>
194 194
 			<div id="ee-error-trace-1'
195
-                       . $time
196
-                       . '-dv" class="ee-error-trace-dv" style="display: none;">
195
+					   . $time
196
+					   . '-dv" class="ee-error-trace-dv" style="display: none;">
197 197
 				'
198
-                       . $trace_details;
199
-            if (! empty($class)) {
200
-                $output .= '
198
+					   . $trace_details;
199
+			if (! empty($class)) {
200
+				$output .= '
201 201
 				<div style="padding:3px; margin:0 0 1em; border:1px solid #999; background:#fff; border-radius:3px;">
202 202
 					<div style="padding:1em 2em; border:1px solid #999; background:#fcfcfc;">
203 203
 						<h3>' . esc_html__('Class Details', 'event_espresso') . '</h3>';
204
-                $a = new ReflectionClass($class);
205
-                $output .= '
204
+				$a = new ReflectionClass($class);
205
+				$output .= '
206 206
 						<pre>' . $a . '</pre>
207 207
 					</div>
208 208
 				</div>';
209
-            }
210
-            $output .= '
209
+			}
210
+			$output .= '
211 211
 			</div>
212 212
 		</div>
213 213
 		<br />';
214
-        }
215
-        // remove last linebreak
216
-        $output = substr($output, 0, -6);
217
-        if (! WP_DEBUG) {
218
-            $output .= '
214
+		}
215
+		// remove last linebreak
216
+		$output = substr($output, 0, -6);
217
+		if (! WP_DEBUG) {
218
+			$output .= '
219 219
 	</p>';
220
-        }
221
-        $output .= '
220
+		}
221
+		$output .= '
222 222
 </div>';
223
-        $output .= $this->printScripts(true);
224
-        if (defined('DOING_AJAX')) {
225
-            echo wp_json_encode(array('error' => $output));
226
-            exit();
227
-        }
228
-        echo $output; // already escaped
229
-    }
223
+		$output .= $this->printScripts(true);
224
+		if (defined('DOING_AJAX')) {
225
+			echo wp_json_encode(array('error' => $output));
226
+			exit();
227
+		}
228
+		echo $output; // already escaped
229
+	}
230 230
 
231 231
 
232
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
233
-    // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
232
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
233
+	// phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
234 234
 
235
-    /**
236
-     * generate string from exception trace args
237
-     *
238
-     * @param array $arguments
239
-     * @param int   $indent
240
-     * @param bool  $array
241
-     * @return string
242
-     */
243
-    private function _convert_args_to_string($arguments = array(), $indent = 0, $array = false)
244
-    {
245
-        $args = array();
246
-        $args_count = count($arguments);
247
-        if ($args_count > 2) {
248
-            $indent++;
249
-            $args[] = '<br />';
250
-        }
251
-        $x = 0;
252
-        foreach ($arguments as $arg) {
253
-            $x++;
254
-            for ($i = 0; $i < $indent; $i++) {
255
-                $args[] = ' &nbsp;&nbsp; ';
256
-            }
257
-            if (is_string($arg)) {
258
-                if (! $array && strlen($arg) > 75) {
259
-                    $args[] = '<br />';
260
-                    for ($i = 0; $i <= $indent; $i++) {
261
-                        $args[] = ' &nbsp;&nbsp; ';
262
-                    }
263
-                    $args[] = "'" . $arg . "'<br />";
264
-                } else {
265
-                    $args[] = " '" . $arg . "'";
266
-                }
267
-            } elseif (is_array($arg)) {
268
-                $arg_count = count($arg);
269
-                if ($arg_count > 2) {
270
-                    $indent++;
271
-                    $args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')';
272
-                    $indent--;
273
-                } elseif ($arg_count === 0) {
274
-                    $args[] = ' array()';
275
-                } else {
276
-                    $args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )';
277
-                }
278
-            } elseif ($arg === null) {
279
-                $args[] = ' null';
280
-            } elseif (is_bool($arg)) {
281
-                $args[] = $arg ? ' true' : ' false';
282
-            } elseif (is_object($arg)) {
283
-                $args[] = get_class($arg);
284
-            } elseif (is_resource($arg)) {
285
-                $args[] = get_resource_type($arg);
286
-            } else {
287
-                $args[] = $arg;
288
-            }
289
-            if ($x === $args_count) {
290
-                if ($args_count > 2) {
291
-                    $args[] = '<br />';
292
-                    $indent--;
293
-                    for ($i = 1; $i < $indent; $i++) {
294
-                        $args[] = ' &nbsp;&nbsp; ';
295
-                    }
296
-                }
297
-            } else {
298
-                $args[] = $args_count > 2 ? ',<br />' : ', ';
299
-            }
300
-        }
301
-        return implode('', $args);
302
-    }
235
+	/**
236
+	 * generate string from exception trace args
237
+	 *
238
+	 * @param array $arguments
239
+	 * @param int   $indent
240
+	 * @param bool  $array
241
+	 * @return string
242
+	 */
243
+	private function _convert_args_to_string($arguments = array(), $indent = 0, $array = false)
244
+	{
245
+		$args = array();
246
+		$args_count = count($arguments);
247
+		if ($args_count > 2) {
248
+			$indent++;
249
+			$args[] = '<br />';
250
+		}
251
+		$x = 0;
252
+		foreach ($arguments as $arg) {
253
+			$x++;
254
+			for ($i = 0; $i < $indent; $i++) {
255
+				$args[] = ' &nbsp;&nbsp; ';
256
+			}
257
+			if (is_string($arg)) {
258
+				if (! $array && strlen($arg) > 75) {
259
+					$args[] = '<br />';
260
+					for ($i = 0; $i <= $indent; $i++) {
261
+						$args[] = ' &nbsp;&nbsp; ';
262
+					}
263
+					$args[] = "'" . $arg . "'<br />";
264
+				} else {
265
+					$args[] = " '" . $arg . "'";
266
+				}
267
+			} elseif (is_array($arg)) {
268
+				$arg_count = count($arg);
269
+				if ($arg_count > 2) {
270
+					$indent++;
271
+					$args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')';
272
+					$indent--;
273
+				} elseif ($arg_count === 0) {
274
+					$args[] = ' array()';
275
+				} else {
276
+					$args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )';
277
+				}
278
+			} elseif ($arg === null) {
279
+				$args[] = ' null';
280
+			} elseif (is_bool($arg)) {
281
+				$args[] = $arg ? ' true' : ' false';
282
+			} elseif (is_object($arg)) {
283
+				$args[] = get_class($arg);
284
+			} elseif (is_resource($arg)) {
285
+				$args[] = get_resource_type($arg);
286
+			} else {
287
+				$args[] = $arg;
288
+			}
289
+			if ($x === $args_count) {
290
+				if ($args_count > 2) {
291
+					$args[] = '<br />';
292
+					$indent--;
293
+					for ($i = 1; $i < $indent; $i++) {
294
+						$args[] = ' &nbsp;&nbsp; ';
295
+					}
296
+				}
297
+			} else {
298
+				$args[] = $args_count > 2 ? ',<br />' : ', ';
299
+			}
300
+		}
301
+		return implode('', $args);
302
+	}
303 303
 
304 304
 
305
-    /**
306
-     * create error code from filepath, function name,
307
-     * and line number where exception or error was thrown
308
-     *
309
-     * @access protected
310
-     * @param string $file
311
-     * @param string $func
312
-     * @param string $line
313
-     * @return string
314
-     */
315
-    protected function generate_error_code($file = '', $func = '', $line = '')
316
-    {
317
-        $file_bits = explode('.', basename($file));
318
-        $error_code = ! empty($file_bits[0]) ? $file_bits[0] : '';
319
-        $error_code .= ! empty($func) ? ' - ' . $func : '';
320
-        $error_code .= ! empty($line) ? ' - ' . $line : '';
321
-        return $error_code;
322
-    }
305
+	/**
306
+	 * create error code from filepath, function name,
307
+	 * and line number where exception or error was thrown
308
+	 *
309
+	 * @access protected
310
+	 * @param string $file
311
+	 * @param string $func
312
+	 * @param string $line
313
+	 * @return string
314
+	 */
315
+	protected function generate_error_code($file = '', $func = '', $line = '')
316
+	{
317
+		$file_bits = explode('.', basename($file));
318
+		$error_code = ! empty($file_bits[0]) ? $file_bits[0] : '';
319
+		$error_code .= ! empty($func) ? ' - ' . $func : '';
320
+		$error_code .= ! empty($line) ? ' - ' . $line : '';
321
+		return $error_code;
322
+	}
323 323
 
324 324
 
325
-    /**
326
-     * _exception_styles
327
-     *
328
-     * @return string
329
-     */
330
-    private function exceptionStyles()
331
-    {
332
-        return '
325
+	/**
326
+	 * _exception_styles
327
+	 *
328
+	 * @return string
329
+	 */
330
+	private function exceptionStyles()
331
+	{
332
+		return '
333 333
 <style type="text/css">
334 334
 	#ee-error-message {
335 335
 		max-width:90% !important;
@@ -386,29 +386,29 @@  discard block
 block discarded – undo
386 386
 		color: #999;
387 387
 	}
388 388
 </style>';
389
-    }
389
+	}
390 390
 
391 391
 
392
-    /**
393
-     * _print_scripts
394
-     *
395
-     * @param bool $force_print
396
-     * @return string
397
-     */
398
-    private function printScripts($force_print = false)
399
-    {
400
-        if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
401
-            if (wp_script_is('ee_error_js', 'enqueued')) {
402
-                return '';
403
-            }
404
-            if (wp_script_is('ee_error_js', 'registered')) {
405
-                wp_enqueue_style('espresso_default');
406
-                wp_enqueue_style('espresso_custom_css');
407
-                wp_enqueue_script('ee_error_js');
408
-                wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG));
409
-            }
410
-        } else {
411
-            return '
392
+	/**
393
+	 * _print_scripts
394
+	 *
395
+	 * @param bool $force_print
396
+	 * @return string
397
+	 */
398
+	private function printScripts($force_print = false)
399
+	{
400
+		if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
401
+			if (wp_script_is('ee_error_js', 'enqueued')) {
402
+				return '';
403
+			}
404
+			if (wp_script_is('ee_error_js', 'registered')) {
405
+				wp_enqueue_style('espresso_default');
406
+				wp_enqueue_style('espresso_custom_css');
407
+				wp_enqueue_script('ee_error_js');
408
+				wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG));
409
+			}
410
+		} else {
411
+			return '
412 412
 <script>
413 413
 /* <![CDATA[ */
414 414
 var ee_settings = {"wp_debug":"' . WP_DEBUG . '"};
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 <script src="' . esc_url_raw(EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version()) . '" type="text/javascript"></script>
419 419
 <script src="' . esc_url_raw(EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version()) . '" type="text/javascript"></script>
420 420
 ';
421
-        }
422
-        return '';
423
-    }
421
+		}
422
+		return '';
423
+	}
424 424
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         $output = $this->exceptionStyles();
55 55
         $output .= '
56 56
 <div id="ee-error-message" class="error">';
57
-        if (! WP_DEBUG) {
57
+        if ( ! WP_DEBUG) {
58 58
             $output .= '
59 59
 	<p>';
60 60
         }
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 					<th scope="col" align="left">
76 76
 					' . esc_html__('Class', 'event_espresso')
77 77
                       . '->'
78
-                      . esc_html__('Method( arguments )', 'event_espresso') . '
78
+                      . esc_html__('Method( arguments )', 'event_espresso').'
79 79
 					</th>
80 80
 				</tr>';
81 81
             $last_on_stack = count($trace) - 1;
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
                 $type = isset($trace['type']) ? $trace['type'] : '';
88 88
                 $function = isset($trace['function']) ? $trace['function'] : '';
89 89
                 $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
90
-                $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args;
90
+                $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />'.$args.'<br />' : $args;
91 91
                 $line = isset($trace['line']) ? $trace['line'] : '';
92 92
                 $zebra = $nmbr % 2 !== 0 ? ' odd' : '';
93 93
                 if (empty($file) && ! empty($class)) {
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
                 $class_display = ! empty($class) ? $class : '';
116 116
                 $type = ! empty($type) ? $type : '';
117 117
                 $function = ! empty($function) ? $function : '';
118
-                $args = ! empty($args) ? '( ' . $args . ' )' : '()';
118
+                $args = ! empty($args) ? '( '.$args.' )' : '()';
119 119
                 $trace_details .= '
120 120
 					<tr>
121 121
 						<td align="right" valign="top" class="'
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         }
150 150
         $code = $exception->getCode() ? $exception->getCode() : $error_code;
151 151
         // add generic non-identifying messages for non-privileged users
152
-        if (! WP_DEBUG) {
152
+        if ( ! WP_DEBUG) {
153 153
             $output .= '<span class="ee-error-user-msg-spn">'
154 154
                        . trim($msg)
155 155
                        . '</span> &nbsp; <sup>'
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
                            '<strong class="ee-error-dev-msg-str">',
167 167
                            get_class($exception),
168 168
                            '</strong>  &nbsp; <span>',
169
-                           $code . '</span>'
169
+                           $code.'</span>'
170 170
                        )
171 171
                        . '<br />
172 172
 				<span class="big-text">"'
@@ -196,14 +196,14 @@  discard block
 block discarded – undo
196 196
                        . '-dv" class="ee-error-trace-dv" style="display: none;">
197 197
 				'
198 198
                        . $trace_details;
199
-            if (! empty($class)) {
199
+            if ( ! empty($class)) {
200 200
                 $output .= '
201 201
 				<div style="padding:3px; margin:0 0 1em; border:1px solid #999; background:#fff; border-radius:3px;">
202 202
 					<div style="padding:1em 2em; border:1px solid #999; background:#fcfcfc;">
203
-						<h3>' . esc_html__('Class Details', 'event_espresso') . '</h3>';
203
+						<h3>' . esc_html__('Class Details', 'event_espresso').'</h3>';
204 204
                 $a = new ReflectionClass($class);
205 205
                 $output .= '
206
-						<pre>' . $a . '</pre>
206
+						<pre>' . $a.'</pre>
207 207
 					</div>
208 208
 				</div>';
209 209
             }
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
         }
215 215
         // remove last linebreak
216 216
         $output = substr($output, 0, -6);
217
-        if (! WP_DEBUG) {
217
+        if ( ! WP_DEBUG) {
218 218
             $output .= '
219 219
 	</p>';
220 220
         }
@@ -255,25 +255,25 @@  discard block
 block discarded – undo
255 255
                 $args[] = ' &nbsp;&nbsp; ';
256 256
             }
257 257
             if (is_string($arg)) {
258
-                if (! $array && strlen($arg) > 75) {
258
+                if ( ! $array && strlen($arg) > 75) {
259 259
                     $args[] = '<br />';
260 260
                     for ($i = 0; $i <= $indent; $i++) {
261 261
                         $args[] = ' &nbsp;&nbsp; ';
262 262
                     }
263
-                    $args[] = "'" . $arg . "'<br />";
263
+                    $args[] = "'".$arg."'<br />";
264 264
                 } else {
265
-                    $args[] = " '" . $arg . "'";
265
+                    $args[] = " '".$arg."'";
266 266
                 }
267 267
             } elseif (is_array($arg)) {
268 268
                 $arg_count = count($arg);
269 269
                 if ($arg_count > 2) {
270 270
                     $indent++;
271
-                    $args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')';
271
+                    $args[] = ' array('.$this->_convert_args_to_string($arg, $indent, true).')';
272 272
                     $indent--;
273 273
                 } elseif ($arg_count === 0) {
274 274
                     $args[] = ' array()';
275 275
                 } else {
276
-                    $args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )';
276
+                    $args[] = ' array( '.$this->_convert_args_to_string($arg).' )';
277 277
                 }
278 278
             } elseif ($arg === null) {
279 279
                 $args[] = ' null';
@@ -316,8 +316,8 @@  discard block
 block discarded – undo
316 316
     {
317 317
         $file_bits = explode('.', basename($file));
318 318
         $error_code = ! empty($file_bits[0]) ? $file_bits[0] : '';
319
-        $error_code .= ! empty($func) ? ' - ' . $func : '';
320
-        $error_code .= ! empty($line) ? ' - ' . $line : '';
319
+        $error_code .= ! empty($func) ? ' - '.$func : '';
320
+        $error_code .= ! empty($line) ? ' - '.$line : '';
321 321
         return $error_code;
322 322
     }
323 323
 
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
      */
398 398
     private function printScripts($force_print = false)
399 399
     {
400
-        if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
400
+        if ( ! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
401 401
             if (wp_script_is('ee_error_js', 'enqueued')) {
402 402
                 return '';
403 403
             }
@@ -411,12 +411,12 @@  discard block
 block discarded – undo
411 411
             return '
412 412
 <script>
413 413
 /* <![CDATA[ */
414
-var ee_settings = {"wp_debug":"' . WP_DEBUG . '"};
414
+var ee_settings = {"wp_debug":"' . WP_DEBUG.'"};
415 415
 /* ]]> */
416 416
 </script>
417
-<script src="' . esc_url_raw(includes_url() . 'js/jquery/jquery.js') . '" type="text/javascript"></script>
418
-<script src="' . esc_url_raw(EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version()) . '" type="text/javascript"></script>
419
-<script src="' . esc_url_raw(EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version()) . '" type="text/javascript"></script>
417
+<script src="' . esc_url_raw(includes_url().'js/jquery/jquery.js').'" type="text/javascript"></script>
418
+<script src="' . esc_url_raw(EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js'.'?ver='.espresso_version()).'" type="text/javascript"></script>
419
+<script src="' . esc_url_raw(EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js'.'?ver='.espresso_version()).'" type="text/javascript"></script>
420 420
 ';
421 421
         }
422 422
         return '';
Please login to merge, or discard this patch.
core/helpers/EEH_Template.helper.php 2 patches
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use EventEspresso\core\services\loaders\LoaderFactory;
6 6
 use EventEspresso\core\services\request\RequestInterface;
7 7
 
8
-if (! function_exists('espresso_get_template_part')) {
8
+if ( ! function_exists('espresso_get_template_part')) {
9 9
     /**
10 10
      * espresso_get_template_part
11 11
      * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 }
22 22
 
23 23
 
24
-if (! function_exists('espresso_get_object_css_class')) {
24
+if ( ! function_exists('espresso_get_object_css_class')) {
25 25
     /**
26 26
      * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
27 27
      *
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public static function load_espresso_theme_functions()
74 74
     {
75
-        if (! defined('EE_THEME_FUNCTIONS_LOADED')) {
76
-            if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php')) {
77
-                require_once(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php');
75
+        if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) {
76
+            if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().'/functions.php')) {
77
+                require_once(EE_PUBLIC.EE_Config::get_current_theme().'/functions.php');
78 78
             }
79 79
         }
80 80
     }
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
     public static function get_espresso_themes()
89 89
     {
90 90
         if (empty(EEH_Template::$_espresso_themes)) {
91
-            $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
91
+            $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR);
92 92
             if (empty($espresso_themes)) {
93 93
                 return [];
94 94
             }
95 95
             if (($key = array_search('global_assets', $espresso_themes)) !== false) {
96
-                unset($espresso_themes[ $key ]);
96
+                unset($espresso_themes[$key]);
97 97
             }
98 98
             EEH_Template::$_espresso_themes = [];
99 99
             foreach ($espresso_themes as $espresso_theme) {
100
-                EEH_Template::$_espresso_themes[ basename($espresso_theme) ] = $espresso_theme;
100
+                EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme;
101 101
             }
102 102
         }
103 103
         return EEH_Template::$_espresso_themes;
@@ -213,10 +213,10 @@  discard block
 block discarded – undo
213 213
                 // get array of EE Custom Post Types
214 214
                 $EE_CPTs = $custom_post_types->getDefinitions();
215 215
                 // build template name based on request
216
-                if (isset($EE_CPTs[ $post_type ])) {
216
+                if (isset($EE_CPTs[$post_type])) {
217 217
                     $archive_or_single = is_archive() ? 'archive' : '';
218 218
                     $archive_or_single = is_single() ? 'single' : $archive_or_single;
219
-                    $templates         = $archive_or_single . '-' . $post_type . '.php';
219
+                    $templates         = $archive_or_single.'-'.$post_type.'.php';
220 220
                 }
221 221
             }
222 222
             // currently active EE template theme
@@ -225,18 +225,18 @@  discard block
 block discarded – undo
225 225
             // array of paths to folders that may contain templates
226 226
             $template_folder_paths = [
227 227
                 // first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
228
-                EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
228
+                EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme,
229 229
                 // then in the root of the /wp-content/uploads/espresso/templates/ folder
230 230
                 EVENT_ESPRESSO_TEMPLATE_DIR,
231 231
             ];
232 232
 
233 233
             // add core plugin folders for checking only if we're not $check_if_custom
234
-            if (! $check_if_custom) {
235
-                $core_paths            = [
234
+            if ( ! $check_if_custom) {
235
+                $core_paths = [
236 236
                     // in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
237
-                    EE_PUBLIC . $current_theme,
237
+                    EE_PUBLIC.$current_theme,
238 238
                     // in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
239
-                    EE_TEMPLATES . $current_theme,
239
+                    EE_TEMPLATES.$current_theme,
240 240
                     // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
241 241
                     EE_PLUGIN_DIR_PATH,
242 242
                 ];
@@ -271,10 +271,10 @@  discard block
 block discarded – undo
271 271
                     );
272 272
                     if ($common_base_path !== '') {
273 273
                         // both paths have a common base, so just tack the filename onto our search path
274
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
274
+                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name;
275 275
                     } else {
276 276
                         // no common base path, so let's just concatenate
277
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
277
+                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template;
278 278
                     }
279 279
                     // build up our template locations array by adding our resolved paths
280 280
                     $full_template_paths[] = $resolved_path;
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
                 // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
283 283
                 array_unshift($full_template_paths, $template);
284 284
                 // path to the directory of the current theme: /wp-content/themes/(current WP theme)/
285
-                array_unshift($full_template_paths, get_stylesheet_directory() . '/' . $file_name);
285
+                array_unshift($full_template_paths, get_stylesheet_directory().'/'.$file_name);
286 286
             }
287 287
             // filter final array of full template paths
288 288
             $full_template_paths = apply_filters(
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
                 }
334 334
             }
335 335
             $common_base_path .= $directory;
336
-            $last_offset      = $index + 1;
336
+            $last_offset = $index + 1;
337 337
         }
338 338
         return substr($common_base_path, 0, -1);
339 339
     }
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
372 372
 
373 373
         // you gimme nuttin - YOU GET NUTTIN !!
374
-        if (! $template_path || ! is_readable($template_path)) {
374
+        if ( ! $template_path || ! is_readable($template_path)) {
375 375
             // ignore whether template is accessible ?
376 376
             if ($throw_exceptions) {
377 377
                 throw new DomainException(
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
             return '';
382 382
         }
383 383
         // if $template_args are not in an array, then make it so
384
-        if (! is_array($template_args) && ! is_object($template_args)) {
384
+        if ( ! is_array($template_args) && ! is_object($template_args)) {
385 385
             $template_args = [$template_args];
386 386
         }
387 387
         extract($template_args, EXTR_SKIP);
@@ -410,11 +410,11 @@  discard block
 block discarded – undo
410 410
     public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
411 411
     {
412 412
         // in the beginning...
413
-        $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
413
+        $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : '';
414 414
         // da muddle
415 415
         $class = '';
416 416
         // the end
417
-        $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
417
+        $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : '';
418 418
         // is the passed object an EE object ?
419 419
         if ($object instanceof EE_Base_Class) {
420 420
             // grab the exact type of object
@@ -424,10 +424,10 @@  discard block
 block discarded – undo
424 424
                 // no specifics just yet...
425 425
                 default:
426 426
                     $class = strtolower(str_replace('_', '-', $obj_class));
427
-                    $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
427
+                    $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : '';
428 428
             }
429 429
         }
430
-        return $prefix . $class . $suffix;
430
+        return $prefix.$class.$suffix;
431 431
     }
432 432
 
433 433
 
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
         // filter raw amount (allows 0.00 to be changed to "free" for example)
463 463
         $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
464 464
         // still a number, or was amount converted to a string like "free" ?
465
-        if (! is_float($amount_formatted)) {
465
+        if ( ! is_float($amount_formatted)) {
466 466
             return esc_html($amount_formatted);
467 467
         }
468 468
         try {
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
             $mny = null;
474 474
         }
475 475
         // verify results
476
-        if (! $mny instanceof EE_Currency_Config) {
476
+        if ( ! $mny instanceof EE_Currency_Config) {
477 477
             // set default config country currency settings
478 478
             $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
479 479
                 ? EE_Registry::instance()->CFG->currency
@@ -482,16 +482,16 @@  discard block
 block discarded – undo
482 482
         // format float
483 483
         $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
484 484
         // add formatting ?
485
-        if (! $return_raw) {
485
+        if ( ! $return_raw) {
486 486
             // add currency sign
487 487
             if ($mny->sign_b4) {
488 488
                 if ($amount >= 0) {
489
-                    $amount_formatted = $mny->sign . $amount_formatted;
489
+                    $amount_formatted = $mny->sign.$amount_formatted;
490 490
                 } else {
491
-                    $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
491
+                    $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted);
492 492
                 }
493 493
             } else {
494
-                $amount_formatted = $amount_formatted . $mny->sign;
494
+                $amount_formatted = $amount_formatted.$mny->sign;
495 495
             }
496 496
 
497 497
             // filter to allow global setting of display_code
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 
503 503
             // add currency code ?
504 504
             $amount_formatted = $display_code
505
-                ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>'
505
+                ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>'
506 506
                 : $amount_formatted;
507 507
         }
508 508
         // filter results
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
             $plural,
539 539
             $schema
540 540
         );
541
-        return $status[ $status_id ];
541
+        return $status[$status_id];
542 542
     }
543 543
 
544 544
 
@@ -555,14 +555,14 @@  discard block
 block discarded – undo
555 555
     public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '')
556 556
     {
557 557
         $icon_html = '';
558
-        if (! empty($icon)) {
558
+        if ( ! empty($icon)) {
559 559
             $dashicons = preg_split("(ee-icon |dashicons )", $icon);
560 560
             $dashicons = array_filter($dashicons);
561 561
             $count     = count($dashicons);
562 562
             $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
563 563
             foreach ($dashicons as $dashicon) {
564
-                $type      = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
565
-                $icon_html .= '<span class="' . $type . $dashicon . '"></span>';
564
+                $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
565
+                $icon_html .= '<span class="'.$type.$dashicon.'"></span>';
566 566
             }
567 567
             $icon_html .= $count > 1 ? '</span>' : '';
568 568
         }
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
         $action  = $action ?: $request->getRequestParam('action', 'default', 'key');
601 601
 
602 602
 
603
-        $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
603
+        $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id;
604 604
         $icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
605 605
         $help_text    = ! $help_text ? '' : $help_text;
606 606
         return '<a id="'
@@ -633,15 +633,15 @@  discard block
 block discarded – undo
633 633
         $id    = $tour->get_slug();
634 634
         $stops = $tour->get_stops();
635 635
 
636
-        $content = '<ol style="display:none" id="' . esc_attr($id) . '">';
636
+        $content = '<ol style="display:none" id="'.esc_attr($id).'">';
637 637
 
638 638
         foreach ($stops as $stop) {
639
-            $data_id    = ! empty($stop['id'])
640
-                ? ' data-id="' . esc_attr($stop['id']) . '"'
639
+            $data_id = ! empty($stop['id'])
640
+                ? ' data-id="'.esc_attr($stop['id']).'"'
641 641
                 : '';
642 642
 
643 643
             $data_class = empty($data_id) && ! empty($stop['class'])
644
-                ? ' data-class="' . esc_attr($stop['class']) . '"'
644
+                ? ' data-class="'.esc_attr($stop['class']).'"'
645 645
                 : '';
646 646
 
647 647
             // if container is set to modal then let's make sure we set the options accordingly
@@ -651,10 +651,10 @@  discard block
 block discarded – undo
651 651
             }
652 652
 
653 653
             $custom_class  = ! empty($stop['custom_class'])
654
-                ? ' class="' . esc_attr($stop['custom_class']) . '"'
654
+                ? ' class="'.esc_attr($stop['custom_class']).'"'
655 655
                 : '';
656 656
             $button_text   = ! empty($stop['button_text'])
657
-                ? ' data-button="' . esc_html($stop['button_text']) . '"'
657
+                ? ' data-button="'.esc_html($stop['button_text']).'"'
658 658
                 : '';
659 659
             $inner_content = isset($stop['content']) ? wp_kses($stop['content'], $allowedtags) : '';
660 660
 
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
             if (isset($stop['options']) && is_array($stop['options'])) {
663 663
                 $options = ' data-options="';
664 664
                 foreach ($stop['options'] as $option => $value) {
665
-                    $options .= esc_attr($option) . ':' . esc_attr($value) . ';';
665
+                    $options .= esc_attr($option).':'.esc_attr($value).';';
666 666
                 }
667 667
                 $options .= '"';
668 668
             } else {
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
      */
703 703
     public static function status_legend($status_array, $active_status = '')
704 704
     {
705
-        if (! is_array($status_array)) {
705
+        if ( ! is_array($status_array)) {
706 706
             throw new EE_Error(
707 707
                 esc_html__(
708 708
                     'The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
@@ -714,17 +714,17 @@  discard block
 block discarded – undo
714 714
         $content = '
715 715
             <div class="ee-list-table-legend-container">
716 716
                 <h4 class="status-legend-title">
717
-                    ' . esc_html__('Status Legend', 'event_espresso') . '
717
+                    ' . esc_html__('Status Legend', 'event_espresso').'
718 718
                 </h4>
719 719
                 <dl class="ee-list-table-legend">';
720 720
 
721 721
         foreach ($status_array as $item => $status) {
722 722
             $active_class = $active_status == $status ? 'class="ee-is-active-status"' : '';
723
-            $content      .= '
724
-                    <dt id="' . esc_attr('ee-legend-item-tooltip-' . $item) . '" ' . $active_class . '>
725
-                        <span class="' . esc_attr('ee-status-legend ee-status-legend-' . $status) . '"></span>
723
+            $content .= '
724
+                    <dt id="' . esc_attr('ee-legend-item-tooltip-'.$item).'" '.$active_class.'>
725
+                        <span class="' . esc_attr('ee-status-legend ee-status-legend-'.$status).'"></span>
726 726
                         <span class="ee-legend-description">
727
-                            ' . EEH_Template::pretty_status($status, false, 'sentence') . '
727
+                            ' . EEH_Template::pretty_status($status, false, 'sentence').'
728 728
                         </span>
729 729
                     </dt>';
730 730
         }
@@ -870,8 +870,8 @@  discard block
 block discarded – undo
870 870
             ];
871 871
         } else {
872 872
             $items_label = [
873
-                'single' => '1 ' . esc_html($items_label['single']),
874
-                'plural' => '%s ' . esc_html($items_label['plural']),
873
+                'single' => '1 '.esc_html($items_label['single']),
874
+                'plural' => '%s '.esc_html($items_label['plural']),
875 875
             ];
876 876
         }
877 877
 
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
 
884 884
         $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
885 885
 
886
-        $output = '<span class="displaying-num">' . $item_label . '</span>';
886
+        $output = '<span class="displaying-num">'.$item_label.'</span>';
887 887
 
888 888
         if ($current === 1) {
889 889
             $disable_first = ' disabled';
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
 
895 895
         $page_links[] = sprintf(
896 896
             "<a class='%s' title='%s' href='%s'>%s</a>",
897
-            'first-page' . $disable_first,
897
+            'first-page'.$disable_first,
898 898
             esc_attr__('Go to the first page', 'event_espresso'),
899 899
             esc_url_raw(remove_query_arg($paged_arg_name, $url)),
900 900
             '&laquo;'
@@ -902,13 +902,13 @@  discard block
 block discarded – undo
902 902
 
903 903
         $page_links[] = sprintf(
904 904
             '<a class="%s" title="%s" href="%s">%s</a>',
905
-            'prev-page' . $disable_first,
905
+            'prev-page'.$disable_first,
906 906
             esc_attr__('Go to the previous page', 'event_espresso'),
907 907
             esc_url_raw(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
908 908
             '&lsaquo;'
909 909
         );
910 910
 
911
-        if (! $show_num_field) {
911
+        if ( ! $show_num_field) {
912 912
             $html_current_page = $current;
913 913
         } else {
914 914
             $html_current_page = sprintf(
@@ -923,7 +923,7 @@  discard block
 block discarded – undo
923 923
             '<span class="total-pages">%s</span>',
924 924
             number_format_i18n($total_pages)
925 925
         );
926
-        $page_links[]     = sprintf(
926
+        $page_links[] = sprintf(
927 927
             _x('%3$s%1$s of %2$s%4$s', 'paging', 'event_espresso'),
928 928
             $html_current_page,
929 929
             $html_total_pages,
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
 
934 934
         $page_links[] = sprintf(
935 935
             '<a class="%s" title="%s" href="%s">%s</a>',
936
-            'next-page' . $disable_last,
936
+            'next-page'.$disable_last,
937 937
             esc_attr__('Go to the next page', 'event_espresso'),
938 938
             esc_url_raw(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
939 939
             '&rsaquo;'
@@ -941,13 +941,13 @@  discard block
 block discarded – undo
941 941
 
942 942
         $page_links[] = sprintf(
943 943
             '<a class="%s" title="%s" href="%s">%s</a>',
944
-            'last-page' . $disable_last,
944
+            'last-page'.$disable_last,
945 945
             esc_attr__('Go to the last page', 'event_espresso'),
946 946
             esc_url_raw(add_query_arg($paged_arg_name, $total_pages, $url)),
947 947
             '&raquo;'
948 948
         );
949 949
 
950
-        $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
950
+        $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>';
951 951
         // set page class
952 952
         if ($total_pages) {
953 953
             $page_class = $total_pages < 2 ? ' one-page' : '';
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
             $page_class = ' no-pages';
956 956
         }
957 957
 
958
-        return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
958
+        return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>';
959 959
     }
960 960
 
961 961
 
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
         );
994 994
         $powered_by = apply_filters(
995 995
             'FHEE__EEH_Template__powered_by_event_espresso_text',
996
-            $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'
996
+            $admin ? 'Event Espresso - '.EVENT_ESPRESSO_VERSION : 'Event Espresso'
997 997
         );
998 998
         $url        = add_query_arg($query_args, 'https://eventespresso.com/');
999 999
         $url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
@@ -1022,12 +1022,12 @@  discard block
 block discarded – undo
1022 1022
      */
1023 1023
     public static function getScreenshotUrl($image_name)
1024 1024
     {
1025
-        return esc_url_raw(EE_GLOBAL_ASSETS_URL . 'images/screenshots/' . $image_name . '.jpg');
1025
+        return esc_url_raw(EE_GLOBAL_ASSETS_URL.'images/screenshots/'.$image_name.'.jpg');
1026 1026
     }
1027 1027
 }
1028 1028
 
1029 1029
 
1030
-if (! function_exists('espresso_pagination')) {
1030
+if ( ! function_exists('espresso_pagination')) {
1031 1031
     /**
1032 1032
      *    espresso_pagination
1033 1033
      *
@@ -1055,6 +1055,6 @@  discard block
 block discarded – undo
1055 1055
                 'add_fragment' => '',
1056 1056
             ]
1057 1057
         );
1058
-        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
1058
+        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">'.$pagination.'</div>' : '';
1059 1059
     }
1060 1060
 }
1061 1061
\ No newline at end of file
Please login to merge, or discard this patch.
Indentation   +994 added lines, -994 removed lines patch added patch discarded remove patch
@@ -6,36 +6,36 @@  discard block
 block discarded – undo
6 6
 use EventEspresso\core\services\request\RequestInterface;
7 7
 
8 8
 if (! function_exists('espresso_get_template_part')) {
9
-    /**
10
-     * espresso_get_template_part
11
-     * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
12
-     * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name
13
-     *
14
-     * @param string $slug The slug name for the generic template.
15
-     * @param string $name The name of the specialised template.
16
-     */
17
-    function espresso_get_template_part($slug = null, $name = null)
18
-    {
19
-        EEH_Template::get_template_part($slug, $name);
20
-    }
9
+	/**
10
+	 * espresso_get_template_part
11
+	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
12
+	 * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name
13
+	 *
14
+	 * @param string $slug The slug name for the generic template.
15
+	 * @param string $name The name of the specialised template.
16
+	 */
17
+	function espresso_get_template_part($slug = null, $name = null)
18
+	{
19
+		EEH_Template::get_template_part($slug, $name);
20
+	}
21 21
 }
22 22
 
23 23
 
24 24
 if (! function_exists('espresso_get_object_css_class')) {
25
-    /**
26
-     * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
27
-     *
28
-     * @param EE_Base_Class $object the EE object the css class is being generated for
29
-     * @param string        $prefix added to the beginning of the generated class
30
-     * @param string        $suffix added to the end of the generated class
31
-     * @return string
32
-     * @throws EE_Error
33
-     * @throws ReflectionException
34
-     */
35
-    function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '')
36
-    {
37
-        return EEH_Template::get_object_css_class($object, $prefix, $suffix);
38
-    }
25
+	/**
26
+	 * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
27
+	 *
28
+	 * @param EE_Base_Class $object the EE object the css class is being generated for
29
+	 * @param string        $prefix added to the beginning of the generated class
30
+	 * @param string        $suffix added to the end of the generated class
31
+	 * @return string
32
+	 * @throws EE_Error
33
+	 * @throws ReflectionException
34
+	 */
35
+	function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '')
36
+	{
37
+		return EEH_Template::get_object_css_class($object, $prefix, $suffix);
38
+	}
39 39
 }
40 40
 
41 41
 
@@ -50,708 +50,708 @@  discard block
 block discarded – undo
50 50
 class EEH_Template
51 51
 {
52 52
 
53
-    private static $_espresso_themes = [];
54
-
55
-
56
-    /**
57
-     *    is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme
58
-     *
59
-     * @return boolean
60
-     */
61
-    public static function is_espresso_theme()
62
-    {
63
-        return wp_get_theme()->get('TextDomain') === 'event_espresso';
64
-    }
65
-
66
-
67
-    /**
68
-     *    load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then
69
-     *    load its functions.php file ( if not already loaded )
70
-     *
71
-     * @return void
72
-     */
73
-    public static function load_espresso_theme_functions()
74
-    {
75
-        if (! defined('EE_THEME_FUNCTIONS_LOADED')) {
76
-            if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php')) {
77
-                require_once(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php');
78
-            }
79
-        }
80
-    }
81
-
82
-
83
-    /**
84
-     *    get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory
85
-     *
86
-     * @return array
87
-     */
88
-    public static function get_espresso_themes()
89
-    {
90
-        if (empty(EEH_Template::$_espresso_themes)) {
91
-            $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
92
-            if (empty($espresso_themes)) {
93
-                return [];
94
-            }
95
-            if (($key = array_search('global_assets', $espresso_themes)) !== false) {
96
-                unset($espresso_themes[ $key ]);
97
-            }
98
-            EEH_Template::$_espresso_themes = [];
99
-            foreach ($espresso_themes as $espresso_theme) {
100
-                EEH_Template::$_espresso_themes[ basename($espresso_theme) ] = $espresso_theme;
101
-            }
102
-        }
103
-        return EEH_Template::$_espresso_themes;
104
-    }
105
-
106
-
107
-    /**
108
-     * EEH_Template::get_template_part
109
-     * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead,
110
-     * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS
111
-     * filtering based off of the entire template part name
112
-     *
113
-     * @param string $slug The slug name for the generic template.
114
-     * @param string $name The name of the specialised template.
115
-     * @param array  $template_args
116
-     * @param bool   $return_string
117
-     * @return string        the html output for the formatted money value
118
-     */
119
-    public static function get_template_part(
120
-        $slug = null,
121
-        $name = null,
122
-        $template_args = [],
123
-        $return_string = false
124
-    ) {
125
-        do_action("get_template_part_{$slug}-{$name}", $slug, $name);
126
-        $templates = [];
127
-        $name      = (string) $name;
128
-        if ($name != '') {
129
-            $templates[] = "{$slug}-{$name}.php";
130
-        }
131
-        // allow template parts to be turned off via something like:
132
-        // add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
133
-        if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) {
134
-            return EEH_Template::locate_template($templates, $template_args, true, $return_string);
135
-        }
136
-        return '';
137
-    }
138
-
139
-
140
-    /**
141
-     *    locate_template
142
-     *    locate a template file by looking in the following places, in the following order:
143
-     *        <server path up to>/wp-content/themes/<current active WordPress theme>/
144
-     *        <assumed full absolute server path>
145
-     *        <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/
146
-     *        <server path up to>/wp-content/uploads/espresso/templates/
147
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/
148
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/
149
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/
150
-     *    as soon as the template is found in one of these locations, it will be returned or loaded
151
-     *        Example:
152
-     *          You are using the WordPress Twenty Sixteen theme,
153
-     *        and you want to customize the "some-event.template.php" template,
154
-     *          which is located in the "/relative/path/to/" folder relative to the main EE plugin folder.
155
-     *          Assuming WP is installed on your server in the "/home/public_html/" folder,
156
-     *        EEH_Template::locate_template() will look at the following paths in order until the template is found:
157
-     *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
158
-     *        /relative/path/to/some-event.template.php
159
-     *        /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
160
-     *        /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php
161
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php
162
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
163
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php
164
-     *          Had you passed an absolute path to your template that was in some other location,
165
-     *        ie: "/absolute/path/to/some-event.template.php"
166
-     *          then the search would have been :
167
-     *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
168
-     *        /absolute/path/to/some-event.template.php
169
-     *          and stopped there upon finding it in the second location
170
-     *
171
-     * @param array|string $templates       array of template file names including extension (or just a single string)
172
-     * @param array        $template_args   an array of arguments to be extracted for use in the template
173
-     * @param boolean      $load            whether to pass the located template path on to the
174
-     *                                      EEH_Template::display_template() method or simply return it
175
-     * @param boolean      $return_string   whether to send output immediately to screen, or capture and return as a
176
-     *                                      string
177
-     * @param boolean      $check_if_custom If TRUE, this flags this method to return boolean for whether this will
178
-     *                                      generate a custom template or not. Used in places where you don't actually
179
-     *                                      load the template, you just want to know if there's a custom version of it.
180
-     * @return mixed
181
-     * @throws DomainException
182
-     * @throws InvalidArgumentException
183
-     * @throws InvalidDataTypeException
184
-     * @throws InvalidInterfaceException
185
-     */
186
-    public static function locate_template(
187
-        $templates = [],
188
-        $template_args = [],
189
-        $load = true,
190
-        $return_string = true,
191
-        $check_if_custom = false
192
-    ) {
193
-        // first use WP locate_template to check for template in the current theme folder
194
-        $template_path = locate_template($templates);
195
-
196
-        if ($check_if_custom && ! empty($template_path)) {
197
-            return true;
198
-        }
199
-
200
-        // not in the theme
201
-        if (empty($template_path)) {
202
-            // not even a template to look for ?
203
-            if (empty($templates)) {
204
-                $loader = LoaderFactory::getLoader();
205
-                /** @var RequestInterface $request */
206
-                $request = $loader->getShared(RequestInterface::class);
207
-                // get post_type
208
-                $post_type = $request->getRequestParam('post_type');
209
-                /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
210
-                $custom_post_types = $loader->getShared(
211
-                    'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
212
-                );
213
-                // get array of EE Custom Post Types
214
-                $EE_CPTs = $custom_post_types->getDefinitions();
215
-                // build template name based on request
216
-                if (isset($EE_CPTs[ $post_type ])) {
217
-                    $archive_or_single = is_archive() ? 'archive' : '';
218
-                    $archive_or_single = is_single() ? 'single' : $archive_or_single;
219
-                    $templates         = $archive_or_single . '-' . $post_type . '.php';
220
-                }
221
-            }
222
-            // currently active EE template theme
223
-            $current_theme = EE_Config::get_current_theme();
224
-
225
-            // array of paths to folders that may contain templates
226
-            $template_folder_paths = [
227
-                // first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
228
-                EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
229
-                // then in the root of the /wp-content/uploads/espresso/templates/ folder
230
-                EVENT_ESPRESSO_TEMPLATE_DIR,
231
-            ];
232
-
233
-            // add core plugin folders for checking only if we're not $check_if_custom
234
-            if (! $check_if_custom) {
235
-                $core_paths            = [
236
-                    // in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
237
-                    EE_PUBLIC . $current_theme,
238
-                    // in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
239
-                    EE_TEMPLATES . $current_theme,
240
-                    // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
241
-                    EE_PLUGIN_DIR_PATH,
242
-                ];
243
-                $template_folder_paths = array_merge($template_folder_paths, $core_paths);
244
-            }
245
-
246
-            // now filter that array
247
-            $template_folder_paths = apply_filters(
248
-                'FHEE__EEH_Template__locate_template__template_folder_paths',
249
-                $template_folder_paths
250
-            );
251
-            $templates             = is_array($templates) ? $templates : [$templates];
252
-            $template_folder_paths =
253
-                is_array($template_folder_paths) ? $template_folder_paths : [$template_folder_paths];
254
-            // array to hold all possible template paths
255
-            $full_template_paths = [];
256
-            $file_name           = '';
257
-
258
-            // loop through $templates
259
-            foreach ($templates as $template) {
260
-                // normalize directory separators
261
-                $template                      = EEH_File::standardise_directory_separators($template);
262
-                $file_name                     = basename($template);
263
-                $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
264
-                // while looping through all template folder paths
265
-                foreach ($template_folder_paths as $template_folder_path) {
266
-                    // normalize directory separators
267
-                    $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
268
-                    // determine if any common base path exists between the two paths
269
-                    $common_base_path = EEH_Template::_find_common_base_path(
270
-                        [$template_folder_path, $template_path_minus_file_name]
271
-                    );
272
-                    if ($common_base_path !== '') {
273
-                        // both paths have a common base, so just tack the filename onto our search path
274
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
275
-                    } else {
276
-                        // no common base path, so let's just concatenate
277
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
278
-                    }
279
-                    // build up our template locations array by adding our resolved paths
280
-                    $full_template_paths[] = $resolved_path;
281
-                }
282
-                // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
283
-                array_unshift($full_template_paths, $template);
284
-                // path to the directory of the current theme: /wp-content/themes/(current WP theme)/
285
-                array_unshift($full_template_paths, get_stylesheet_directory() . '/' . $file_name);
286
-            }
287
-            // filter final array of full template paths
288
-            $full_template_paths = apply_filters(
289
-                'FHEE__EEH_Template__locate_template__full_template_paths',
290
-                $full_template_paths,
291
-                $file_name
292
-            );
293
-            // now loop through our final array of template location paths and check each location
294
-            foreach ((array) $full_template_paths as $full_template_path) {
295
-                if (is_readable($full_template_path)) {
296
-                    $template_path = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $full_template_path);
297
-                    break;
298
-                }
299
-            }
300
-        }
301
-
302
-        // hook that can be used to display the full template path that will be used
303
-        do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path);
304
-
305
-        // if we got it and you want to see it...
306
-        if ($template_path && $load && ! $check_if_custom) {
307
-            if ($return_string) {
308
-                return EEH_Template::display_template($template_path, $template_args, true);
309
-            }
310
-            EEH_Template::display_template($template_path, $template_args);
311
-        }
312
-        return $check_if_custom && ! empty($template_path) ? true : $template_path;
313
-    }
314
-
315
-
316
-    /**
317
-     * _find_common_base_path
318
-     * given two paths, this determines if there is a common base path between the two
319
-     *
320
-     * @param array $paths
321
-     * @return string
322
-     */
323
-    protected static function _find_common_base_path($paths)
324
-    {
325
-        $last_offset      = 0;
326
-        $common_base_path = '';
327
-        while (($index = strpos($paths[0], '/', $last_offset)) !== false) {
328
-            $dir_length = $index - $last_offset + 1;
329
-            $directory  = substr($paths[0], $last_offset, $dir_length);
330
-            foreach ($paths as $path) {
331
-                if (substr($path, $last_offset, $dir_length) != $directory) {
332
-                    return $common_base_path;
333
-                }
334
-            }
335
-            $common_base_path .= $directory;
336
-            $last_offset      = $index + 1;
337
-        }
338
-        return substr($common_base_path, 0, -1);
339
-    }
340
-
341
-
342
-    /**
343
-     * load and display a template
344
-     *
345
-     * @param bool|string $template_path    server path to the file to be loaded, including file name and extension
346
-     * @param array       $template_args    an array of arguments to be extracted for use in the template
347
-     * @param boolean     $return_string    whether to send output immediately to screen, or capture and return as a
348
-     *                                      string
349
-     * @param bool        $throw_exceptions if set to true, will throw an exception if the template is either
350
-     *                                      not found or is not readable
351
-     * @return string
352
-     * @throws DomainException
353
-     */
354
-    public static function display_template(
355
-        $template_path = false,
356
-        $template_args = [],
357
-        $return_string = false,
358
-        $throw_exceptions = false
359
-    ) {
360
-
361
-        /**
362
-         * These two filters are intended for last minute changes to templates being loaded and/or template arg
363
-         * modifications.  NOTE... modifying these things can cause breakage as most templates running through
364
-         * the display_template method are templates we DON'T want modified (usually because of js
365
-         * dependencies etc).  So unless you know what you are doing, do NOT filter templates or template args
366
-         * using this.
367
-         *
368
-         * @since 4.6.0
369
-         */
370
-        $template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
371
-        $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
372
-
373
-        // you gimme nuttin - YOU GET NUTTIN !!
374
-        if (! $template_path || ! is_readable($template_path)) {
375
-            // ignore whether template is accessible ?
376
-            if ($throw_exceptions) {
377
-                throw new DomainException(
378
-                    esc_html__('Invalid, unreadable, or missing file.', 'event_espresso')
379
-                );
380
-            }
381
-            return '';
382
-        }
383
-        // if $template_args are not in an array, then make it so
384
-        if (! is_array($template_args) && ! is_object($template_args)) {
385
-            $template_args = [$template_args];
386
-        }
387
-        extract($template_args, EXTR_SKIP);
388
-
389
-        if ($return_string) {
390
-            // because we want to return a string, we are going to capture the output
391
-            ob_start();
392
-            include($template_path);
393
-            return ob_get_clean();
394
-        }
395
-        include($template_path);
396
-        return '';
397
-    }
398
-
399
-
400
-    /**
401
-     * get_object_css_class - attempts to generate a css class based on the type of EE object passed
402
-     *
403
-     * @param EE_Base_Class $object the EE object the css class is being generated for
404
-     * @param string        $prefix added to the beginning of the generated class
405
-     * @param string        $suffix added to the end of the generated class
406
-     * @return string
407
-     * @throws EE_Error
408
-     * @throws ReflectionException
409
-     */
410
-    public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
411
-    {
412
-        // in the beginning...
413
-        $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
414
-        // da muddle
415
-        $class = '';
416
-        // the end
417
-        $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
418
-        // is the passed object an EE object ?
419
-        if ($object instanceof EE_Base_Class) {
420
-            // grab the exact type of object
421
-            $obj_class = get_class($object);
422
-            // depending on the type of object...
423
-            switch ($obj_class) {
424
-                // no specifics just yet...
425
-                default:
426
-                    $class = strtolower(str_replace('_', '-', $obj_class));
427
-                    $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
428
-            }
429
-        }
430
-        return $prefix . $class . $suffix;
431
-    }
432
-
433
-
434
-    /**
435
-     * EEH_Template::format_currency
436
-     * This helper takes a raw float value and formats it according to the default config country currency settings, or
437
-     * the country currency settings from the supplied country ISO code
438
-     *
439
-     * @param float   $amount       raw money value
440
-     * @param boolean $return_raw   whether to return the formatted float value only with no currency sign or code
441
-     * @param boolean $display_code whether to display the country code (USD). Default = TRUE
442
-     * @param string  $CNT_ISO      2 letter ISO code for a country
443
-     * @param string  $cur_code_span_class
444
-     * @return string        the html output for the formatted money value
445
-     */
446
-    public static function format_currency(
447
-        $amount = null,
448
-        $return_raw = false,
449
-        $display_code = true,
450
-        $CNT_ISO = '',
451
-        $cur_code_span_class = 'currency-code'
452
-    ) {
453
-        // ensure amount was received
454
-        if ($amount === null) {
455
-            $msg = esc_html__('In order to format currency, an amount needs to be passed.', 'event_espresso');
456
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
457
-            return '';
458
-        }
459
-        // ensure amount is float
460
-        $amount  = (float) apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount);
461
-        $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
462
-        // filter raw amount (allows 0.00 to be changed to "free" for example)
463
-        $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
464
-        // still a number, or was amount converted to a string like "free" ?
465
-        if (! is_float($amount_formatted)) {
466
-            return esc_html($amount_formatted);
467
-        }
468
-        try {
469
-            // was a country ISO code passed ? if so generate currency config object for that country
470
-            $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
471
-        } catch (Exception $e) {
472
-            // eat exception
473
-            $mny = null;
474
-        }
475
-        // verify results
476
-        if (! $mny instanceof EE_Currency_Config) {
477
-            // set default config country currency settings
478
-            $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
479
-                ? EE_Registry::instance()->CFG->currency
480
-                : new EE_Currency_Config();
481
-        }
482
-        // format float
483
-        $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
484
-        // add formatting ?
485
-        if (! $return_raw) {
486
-            // add currency sign
487
-            if ($mny->sign_b4) {
488
-                if ($amount >= 0) {
489
-                    $amount_formatted = $mny->sign . $amount_formatted;
490
-                } else {
491
-                    $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
492
-                }
493
-            } else {
494
-                $amount_formatted = $amount_formatted . $mny->sign;
495
-            }
496
-
497
-            // filter to allow global setting of display_code
498
-            $display_code = (bool) apply_filters(
499
-                'FHEE__EEH_Template__format_currency__display_code',
500
-                $display_code
501
-            );
502
-
503
-            // add currency code ?
504
-            $amount_formatted = $display_code
505
-                ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>'
506
-                : $amount_formatted;
507
-        }
508
-        // filter results
509
-        $amount_formatted = apply_filters(
510
-            'FHEE__EEH_Template__format_currency__amount_formatted',
511
-            $amount_formatted,
512
-            $mny,
513
-            $return_raw
514
-        );
515
-        // clean up vars
516
-        unset($mny);
517
-        // return formatted currency amount
518
-        return $amount_formatted;
519
-    }
520
-
521
-
522
-    /**
523
-     * This function is used for outputting the localized label for a given status id in the schema requested (and
524
-     * possibly plural).  The intended use of this function is only for cases where wanting a label outside of a
525
-     * related status model or model object (i.e. in documentation etc.)
526
-     *
527
-     * @param string  $status_id  Status ID matching a registered status in the esp_status table.  If there is no
528
-     *                            match, then 'Unknown' will be returned.
529
-     * @param boolean $plural     Whether to return plural or not
530
-     * @param string  $schema     'UPPER', 'lower', or 'Sentence'
531
-     * @return string             The localized label for the status id.
532
-     * @throws EE_Error
533
-     */
534
-    public static function pretty_status($status_id, $plural = false, $schema = 'upper')
535
-    {
536
-        $status = EEM_Status::instance()->localized_status(
537
-            [$status_id => esc_html__('unknown', 'event_espresso')],
538
-            $plural,
539
-            $schema
540
-        );
541
-        return $status[ $status_id ];
542
-    }
543
-
544
-
545
-    /**
546
-     * This helper just returns a button or link for the given parameters
547
-     *
548
-     * @param string $url   the url for the link, note that `esc_url` will be called on it
549
-     * @param string $label What is the label you want displayed for the button
550
-     * @param string $class what class is used for the button (defaults to 'button-primary')
551
-     * @param string $icon
552
-     * @param string $title
553
-     * @return string the html output for the button
554
-     */
555
-    public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '')
556
-    {
557
-        $icon_html = '';
558
-        if (! empty($icon)) {
559
-            $dashicons = preg_split("(ee-icon |dashicons )", $icon);
560
-            $dashicons = array_filter($dashicons);
561
-            $count     = count($dashicons);
562
-            $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
563
-            foreach ($dashicons as $dashicon) {
564
-                $type      = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
565
-                $icon_html .= '<span class="' . $type . $dashicon . '"></span>';
566
-            }
567
-            $icon_html .= $count > 1 ? '</span>' : '';
568
-        }
569
-        // sanitize & escape
570
-        $id    = sanitize_title_with_dashes($label);
571
-        $url   = esc_url_raw($url);
572
-        $class = esc_attr($class);
573
-        $title = esc_attr($title);
574
-        $label = esc_html($label);
575
-        return "<a id='{$id}' href='{$url}' class='{$class}' title='{$title}'>{$icon_html}{$label}</a>";
576
-    }
577
-
578
-
579
-    /**
580
-     * This returns a generated link that will load the related help tab on admin pages.
581
-     *
582
-     * @param string      $help_tab_id the id for the connected help tab
583
-     * @param bool|string $page        The page identifier for the page the help tab is on
584
-     * @param bool|string $action      The action (route) for the admin page the help tab is on.
585
-     * @param bool|string $icon_style  (optional) include css class for the style you want to use for the help icon.
586
-     * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
587
-     * @return string              generated link
588
-     */
589
-    public static function get_help_tab_link(
590
-        $help_tab_id,
591
-        $page = false,
592
-        $action = false,
593
-        $icon_style = false,
594
-        $help_text = false
595
-    ) {
596
-        global $allowedtags;
597
-        /** @var RequestInterface $request */
598
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
599
-        $page    = $page ?: $request->getRequestParam('page', '', 'key');
600
-        $action  = $action ?: $request->getRequestParam('action', 'default', 'key');
601
-
602
-
603
-        $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
604
-        $icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
605
-        $help_text    = ! $help_text ? '' : $help_text;
606
-        return '<a id="'
607
-               . esc_attr($help_tab_lnk)
608
-               . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'
609
-               . esc_attr($icon)
610
-               . '" title="'
611
-               . esc_attr__(
612
-                   'Click to open the \'Help\' tab for more information about this feature.',
613
-                   'event_espresso'
614
-               )
615
-               . '" > '
616
-               . wp_kses($help_text, $allowedtags)
617
-               . ' </a>';
618
-    }
619
-
620
-
621
-    /**
622
-     * This helper generates the html structure for the jquery joyride plugin with the given params.
623
-     *
624
-     * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin
625
-     * @see  EE_Admin_Page->_stop_callback() for the construct expected for the $stops param.
626
-     * @param EE_Help_Tour
627
-     * @return string         html
628
-     * @throws EE_Error
629
-     */
630
-    public static function help_tour_stops_generator(EE_Help_Tour $tour)
631
-    {
632
-        global $allowedtags;
633
-        $id    = $tour->get_slug();
634
-        $stops = $tour->get_stops();
635
-
636
-        $content = '<ol style="display:none" id="' . esc_attr($id) . '">';
637
-
638
-        foreach ($stops as $stop) {
639
-            $data_id    = ! empty($stop['id'])
640
-                ? ' data-id="' . esc_attr($stop['id']) . '"'
641
-                : '';
642
-
643
-            $data_class = empty($data_id) && ! empty($stop['class'])
644
-                ? ' data-class="' . esc_attr($stop['class']) . '"'
645
-                : '';
646
-
647
-            // if container is set to modal then let's make sure we set the options accordingly
648
-            if (empty($data_id) && empty($data_class)) {
649
-                $stop['options']['modal']  = true;
650
-                $stop['options']['expose'] = true;
651
-            }
652
-
653
-            $custom_class  = ! empty($stop['custom_class'])
654
-                ? ' class="' . esc_attr($stop['custom_class']) . '"'
655
-                : '';
656
-            $button_text   = ! empty($stop['button_text'])
657
-                ? ' data-button="' . esc_html($stop['button_text']) . '"'
658
-                : '';
659
-            $inner_content = isset($stop['content']) ? wp_kses($stop['content'], $allowedtags) : '';
660
-
661
-            // options
662
-            if (isset($stop['options']) && is_array($stop['options'])) {
663
-                $options = ' data-options="';
664
-                foreach ($stop['options'] as $option => $value) {
665
-                    $options .= esc_attr($option) . ':' . esc_attr($value) . ';';
666
-                }
667
-                $options .= '"';
668
-            } else {
669
-                $options = '';
670
-            }
671
-
672
-            // let's put all together
673
-            $content .= '<li'
674
-                        . $data_id
675
-                        . $data_class
676
-                        . $custom_class
677
-                        . $button_text
678
-                        . $options
679
-                        . '>'
680
-                        . $inner_content
681
-                        . '</li>';
682
-        }
683
-
684
-        $content .= '</ol>';
685
-        return $content;
686
-    }
687
-
688
-
689
-    /**
690
-     * This is a helper method to generate a status legend for a given status array.
691
-     * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods
692
-     * status_array.
693
-     *
694
-     * @param array  $status_array   array of statuses that will make up the legend. In format:
695
-     *                               array(
696
-     *                               'status_item' => 'status_name'
697
-     *                               )
698
-     * @param string $active_status  This is used to indicate what the active status is IF that is to be highlighted in
699
-     *                               the legend.
700
-     * @return string               html structure for status.
701
-     * @throws EE_Error
702
-     */
703
-    public static function status_legend($status_array, $active_status = '')
704
-    {
705
-        if (! is_array($status_array)) {
706
-            throw new EE_Error(
707
-                esc_html__(
708
-                    'The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
709
-                    'event_espresso'
710
-                )
711
-            );
712
-        }
713
-
714
-        $content = '
53
+	private static $_espresso_themes = [];
54
+
55
+
56
+	/**
57
+	 *    is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme
58
+	 *
59
+	 * @return boolean
60
+	 */
61
+	public static function is_espresso_theme()
62
+	{
63
+		return wp_get_theme()->get('TextDomain') === 'event_espresso';
64
+	}
65
+
66
+
67
+	/**
68
+	 *    load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then
69
+	 *    load its functions.php file ( if not already loaded )
70
+	 *
71
+	 * @return void
72
+	 */
73
+	public static function load_espresso_theme_functions()
74
+	{
75
+		if (! defined('EE_THEME_FUNCTIONS_LOADED')) {
76
+			if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php')) {
77
+				require_once(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php');
78
+			}
79
+		}
80
+	}
81
+
82
+
83
+	/**
84
+	 *    get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory
85
+	 *
86
+	 * @return array
87
+	 */
88
+	public static function get_espresso_themes()
89
+	{
90
+		if (empty(EEH_Template::$_espresso_themes)) {
91
+			$espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
92
+			if (empty($espresso_themes)) {
93
+				return [];
94
+			}
95
+			if (($key = array_search('global_assets', $espresso_themes)) !== false) {
96
+				unset($espresso_themes[ $key ]);
97
+			}
98
+			EEH_Template::$_espresso_themes = [];
99
+			foreach ($espresso_themes as $espresso_theme) {
100
+				EEH_Template::$_espresso_themes[ basename($espresso_theme) ] = $espresso_theme;
101
+			}
102
+		}
103
+		return EEH_Template::$_espresso_themes;
104
+	}
105
+
106
+
107
+	/**
108
+	 * EEH_Template::get_template_part
109
+	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead,
110
+	 * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS
111
+	 * filtering based off of the entire template part name
112
+	 *
113
+	 * @param string $slug The slug name for the generic template.
114
+	 * @param string $name The name of the specialised template.
115
+	 * @param array  $template_args
116
+	 * @param bool   $return_string
117
+	 * @return string        the html output for the formatted money value
118
+	 */
119
+	public static function get_template_part(
120
+		$slug = null,
121
+		$name = null,
122
+		$template_args = [],
123
+		$return_string = false
124
+	) {
125
+		do_action("get_template_part_{$slug}-{$name}", $slug, $name);
126
+		$templates = [];
127
+		$name      = (string) $name;
128
+		if ($name != '') {
129
+			$templates[] = "{$slug}-{$name}.php";
130
+		}
131
+		// allow template parts to be turned off via something like:
132
+		// add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
133
+		if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) {
134
+			return EEH_Template::locate_template($templates, $template_args, true, $return_string);
135
+		}
136
+		return '';
137
+	}
138
+
139
+
140
+	/**
141
+	 *    locate_template
142
+	 *    locate a template file by looking in the following places, in the following order:
143
+	 *        <server path up to>/wp-content/themes/<current active WordPress theme>/
144
+	 *        <assumed full absolute server path>
145
+	 *        <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/
146
+	 *        <server path up to>/wp-content/uploads/espresso/templates/
147
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/
148
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/
149
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/
150
+	 *    as soon as the template is found in one of these locations, it will be returned or loaded
151
+	 *        Example:
152
+	 *          You are using the WordPress Twenty Sixteen theme,
153
+	 *        and you want to customize the "some-event.template.php" template,
154
+	 *          which is located in the "/relative/path/to/" folder relative to the main EE plugin folder.
155
+	 *          Assuming WP is installed on your server in the "/home/public_html/" folder,
156
+	 *        EEH_Template::locate_template() will look at the following paths in order until the template is found:
157
+	 *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
158
+	 *        /relative/path/to/some-event.template.php
159
+	 *        /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
160
+	 *        /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php
161
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php
162
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
163
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php
164
+	 *          Had you passed an absolute path to your template that was in some other location,
165
+	 *        ie: "/absolute/path/to/some-event.template.php"
166
+	 *          then the search would have been :
167
+	 *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
168
+	 *        /absolute/path/to/some-event.template.php
169
+	 *          and stopped there upon finding it in the second location
170
+	 *
171
+	 * @param array|string $templates       array of template file names including extension (or just a single string)
172
+	 * @param array        $template_args   an array of arguments to be extracted for use in the template
173
+	 * @param boolean      $load            whether to pass the located template path on to the
174
+	 *                                      EEH_Template::display_template() method or simply return it
175
+	 * @param boolean      $return_string   whether to send output immediately to screen, or capture and return as a
176
+	 *                                      string
177
+	 * @param boolean      $check_if_custom If TRUE, this flags this method to return boolean for whether this will
178
+	 *                                      generate a custom template or not. Used in places where you don't actually
179
+	 *                                      load the template, you just want to know if there's a custom version of it.
180
+	 * @return mixed
181
+	 * @throws DomainException
182
+	 * @throws InvalidArgumentException
183
+	 * @throws InvalidDataTypeException
184
+	 * @throws InvalidInterfaceException
185
+	 */
186
+	public static function locate_template(
187
+		$templates = [],
188
+		$template_args = [],
189
+		$load = true,
190
+		$return_string = true,
191
+		$check_if_custom = false
192
+	) {
193
+		// first use WP locate_template to check for template in the current theme folder
194
+		$template_path = locate_template($templates);
195
+
196
+		if ($check_if_custom && ! empty($template_path)) {
197
+			return true;
198
+		}
199
+
200
+		// not in the theme
201
+		if (empty($template_path)) {
202
+			// not even a template to look for ?
203
+			if (empty($templates)) {
204
+				$loader = LoaderFactory::getLoader();
205
+				/** @var RequestInterface $request */
206
+				$request = $loader->getShared(RequestInterface::class);
207
+				// get post_type
208
+				$post_type = $request->getRequestParam('post_type');
209
+				/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
210
+				$custom_post_types = $loader->getShared(
211
+					'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
212
+				);
213
+				// get array of EE Custom Post Types
214
+				$EE_CPTs = $custom_post_types->getDefinitions();
215
+				// build template name based on request
216
+				if (isset($EE_CPTs[ $post_type ])) {
217
+					$archive_or_single = is_archive() ? 'archive' : '';
218
+					$archive_or_single = is_single() ? 'single' : $archive_or_single;
219
+					$templates         = $archive_or_single . '-' . $post_type . '.php';
220
+				}
221
+			}
222
+			// currently active EE template theme
223
+			$current_theme = EE_Config::get_current_theme();
224
+
225
+			// array of paths to folders that may contain templates
226
+			$template_folder_paths = [
227
+				// first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
228
+				EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
229
+				// then in the root of the /wp-content/uploads/espresso/templates/ folder
230
+				EVENT_ESPRESSO_TEMPLATE_DIR,
231
+			];
232
+
233
+			// add core plugin folders for checking only if we're not $check_if_custom
234
+			if (! $check_if_custom) {
235
+				$core_paths            = [
236
+					// in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
237
+					EE_PUBLIC . $current_theme,
238
+					// in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
239
+					EE_TEMPLATES . $current_theme,
240
+					// or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
241
+					EE_PLUGIN_DIR_PATH,
242
+				];
243
+				$template_folder_paths = array_merge($template_folder_paths, $core_paths);
244
+			}
245
+
246
+			// now filter that array
247
+			$template_folder_paths = apply_filters(
248
+				'FHEE__EEH_Template__locate_template__template_folder_paths',
249
+				$template_folder_paths
250
+			);
251
+			$templates             = is_array($templates) ? $templates : [$templates];
252
+			$template_folder_paths =
253
+				is_array($template_folder_paths) ? $template_folder_paths : [$template_folder_paths];
254
+			// array to hold all possible template paths
255
+			$full_template_paths = [];
256
+			$file_name           = '';
257
+
258
+			// loop through $templates
259
+			foreach ($templates as $template) {
260
+				// normalize directory separators
261
+				$template                      = EEH_File::standardise_directory_separators($template);
262
+				$file_name                     = basename($template);
263
+				$template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
264
+				// while looping through all template folder paths
265
+				foreach ($template_folder_paths as $template_folder_path) {
266
+					// normalize directory separators
267
+					$template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
268
+					// determine if any common base path exists between the two paths
269
+					$common_base_path = EEH_Template::_find_common_base_path(
270
+						[$template_folder_path, $template_path_minus_file_name]
271
+					);
272
+					if ($common_base_path !== '') {
273
+						// both paths have a common base, so just tack the filename onto our search path
274
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
275
+					} else {
276
+						// no common base path, so let's just concatenate
277
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
278
+					}
279
+					// build up our template locations array by adding our resolved paths
280
+					$full_template_paths[] = $resolved_path;
281
+				}
282
+				// if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
283
+				array_unshift($full_template_paths, $template);
284
+				// path to the directory of the current theme: /wp-content/themes/(current WP theme)/
285
+				array_unshift($full_template_paths, get_stylesheet_directory() . '/' . $file_name);
286
+			}
287
+			// filter final array of full template paths
288
+			$full_template_paths = apply_filters(
289
+				'FHEE__EEH_Template__locate_template__full_template_paths',
290
+				$full_template_paths,
291
+				$file_name
292
+			);
293
+			// now loop through our final array of template location paths and check each location
294
+			foreach ((array) $full_template_paths as $full_template_path) {
295
+				if (is_readable($full_template_path)) {
296
+					$template_path = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $full_template_path);
297
+					break;
298
+				}
299
+			}
300
+		}
301
+
302
+		// hook that can be used to display the full template path that will be used
303
+		do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path);
304
+
305
+		// if we got it and you want to see it...
306
+		if ($template_path && $load && ! $check_if_custom) {
307
+			if ($return_string) {
308
+				return EEH_Template::display_template($template_path, $template_args, true);
309
+			}
310
+			EEH_Template::display_template($template_path, $template_args);
311
+		}
312
+		return $check_if_custom && ! empty($template_path) ? true : $template_path;
313
+	}
314
+
315
+
316
+	/**
317
+	 * _find_common_base_path
318
+	 * given two paths, this determines if there is a common base path between the two
319
+	 *
320
+	 * @param array $paths
321
+	 * @return string
322
+	 */
323
+	protected static function _find_common_base_path($paths)
324
+	{
325
+		$last_offset      = 0;
326
+		$common_base_path = '';
327
+		while (($index = strpos($paths[0], '/', $last_offset)) !== false) {
328
+			$dir_length = $index - $last_offset + 1;
329
+			$directory  = substr($paths[0], $last_offset, $dir_length);
330
+			foreach ($paths as $path) {
331
+				if (substr($path, $last_offset, $dir_length) != $directory) {
332
+					return $common_base_path;
333
+				}
334
+			}
335
+			$common_base_path .= $directory;
336
+			$last_offset      = $index + 1;
337
+		}
338
+		return substr($common_base_path, 0, -1);
339
+	}
340
+
341
+
342
+	/**
343
+	 * load and display a template
344
+	 *
345
+	 * @param bool|string $template_path    server path to the file to be loaded, including file name and extension
346
+	 * @param array       $template_args    an array of arguments to be extracted for use in the template
347
+	 * @param boolean     $return_string    whether to send output immediately to screen, or capture and return as a
348
+	 *                                      string
349
+	 * @param bool        $throw_exceptions if set to true, will throw an exception if the template is either
350
+	 *                                      not found or is not readable
351
+	 * @return string
352
+	 * @throws DomainException
353
+	 */
354
+	public static function display_template(
355
+		$template_path = false,
356
+		$template_args = [],
357
+		$return_string = false,
358
+		$throw_exceptions = false
359
+	) {
360
+
361
+		/**
362
+		 * These two filters are intended for last minute changes to templates being loaded and/or template arg
363
+		 * modifications.  NOTE... modifying these things can cause breakage as most templates running through
364
+		 * the display_template method are templates we DON'T want modified (usually because of js
365
+		 * dependencies etc).  So unless you know what you are doing, do NOT filter templates or template args
366
+		 * using this.
367
+		 *
368
+		 * @since 4.6.0
369
+		 */
370
+		$template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
371
+		$template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
372
+
373
+		// you gimme nuttin - YOU GET NUTTIN !!
374
+		if (! $template_path || ! is_readable($template_path)) {
375
+			// ignore whether template is accessible ?
376
+			if ($throw_exceptions) {
377
+				throw new DomainException(
378
+					esc_html__('Invalid, unreadable, or missing file.', 'event_espresso')
379
+				);
380
+			}
381
+			return '';
382
+		}
383
+		// if $template_args are not in an array, then make it so
384
+		if (! is_array($template_args) && ! is_object($template_args)) {
385
+			$template_args = [$template_args];
386
+		}
387
+		extract($template_args, EXTR_SKIP);
388
+
389
+		if ($return_string) {
390
+			// because we want to return a string, we are going to capture the output
391
+			ob_start();
392
+			include($template_path);
393
+			return ob_get_clean();
394
+		}
395
+		include($template_path);
396
+		return '';
397
+	}
398
+
399
+
400
+	/**
401
+	 * get_object_css_class - attempts to generate a css class based on the type of EE object passed
402
+	 *
403
+	 * @param EE_Base_Class $object the EE object the css class is being generated for
404
+	 * @param string        $prefix added to the beginning of the generated class
405
+	 * @param string        $suffix added to the end of the generated class
406
+	 * @return string
407
+	 * @throws EE_Error
408
+	 * @throws ReflectionException
409
+	 */
410
+	public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
411
+	{
412
+		// in the beginning...
413
+		$prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
414
+		// da muddle
415
+		$class = '';
416
+		// the end
417
+		$suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
418
+		// is the passed object an EE object ?
419
+		if ($object instanceof EE_Base_Class) {
420
+			// grab the exact type of object
421
+			$obj_class = get_class($object);
422
+			// depending on the type of object...
423
+			switch ($obj_class) {
424
+				// no specifics just yet...
425
+				default:
426
+					$class = strtolower(str_replace('_', '-', $obj_class));
427
+					$class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
428
+			}
429
+		}
430
+		return $prefix . $class . $suffix;
431
+	}
432
+
433
+
434
+	/**
435
+	 * EEH_Template::format_currency
436
+	 * This helper takes a raw float value and formats it according to the default config country currency settings, or
437
+	 * the country currency settings from the supplied country ISO code
438
+	 *
439
+	 * @param float   $amount       raw money value
440
+	 * @param boolean $return_raw   whether to return the formatted float value only with no currency sign or code
441
+	 * @param boolean $display_code whether to display the country code (USD). Default = TRUE
442
+	 * @param string  $CNT_ISO      2 letter ISO code for a country
443
+	 * @param string  $cur_code_span_class
444
+	 * @return string        the html output for the formatted money value
445
+	 */
446
+	public static function format_currency(
447
+		$amount = null,
448
+		$return_raw = false,
449
+		$display_code = true,
450
+		$CNT_ISO = '',
451
+		$cur_code_span_class = 'currency-code'
452
+	) {
453
+		// ensure amount was received
454
+		if ($amount === null) {
455
+			$msg = esc_html__('In order to format currency, an amount needs to be passed.', 'event_espresso');
456
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
457
+			return '';
458
+		}
459
+		// ensure amount is float
460
+		$amount  = (float) apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount);
461
+		$CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
462
+		// filter raw amount (allows 0.00 to be changed to "free" for example)
463
+		$amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
464
+		// still a number, or was amount converted to a string like "free" ?
465
+		if (! is_float($amount_formatted)) {
466
+			return esc_html($amount_formatted);
467
+		}
468
+		try {
469
+			// was a country ISO code passed ? if so generate currency config object for that country
470
+			$mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
471
+		} catch (Exception $e) {
472
+			// eat exception
473
+			$mny = null;
474
+		}
475
+		// verify results
476
+		if (! $mny instanceof EE_Currency_Config) {
477
+			// set default config country currency settings
478
+			$mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
479
+				? EE_Registry::instance()->CFG->currency
480
+				: new EE_Currency_Config();
481
+		}
482
+		// format float
483
+		$amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
484
+		// add formatting ?
485
+		if (! $return_raw) {
486
+			// add currency sign
487
+			if ($mny->sign_b4) {
488
+				if ($amount >= 0) {
489
+					$amount_formatted = $mny->sign . $amount_formatted;
490
+				} else {
491
+					$amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
492
+				}
493
+			} else {
494
+				$amount_formatted = $amount_formatted . $mny->sign;
495
+			}
496
+
497
+			// filter to allow global setting of display_code
498
+			$display_code = (bool) apply_filters(
499
+				'FHEE__EEH_Template__format_currency__display_code',
500
+				$display_code
501
+			);
502
+
503
+			// add currency code ?
504
+			$amount_formatted = $display_code
505
+				? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>'
506
+				: $amount_formatted;
507
+		}
508
+		// filter results
509
+		$amount_formatted = apply_filters(
510
+			'FHEE__EEH_Template__format_currency__amount_formatted',
511
+			$amount_formatted,
512
+			$mny,
513
+			$return_raw
514
+		);
515
+		// clean up vars
516
+		unset($mny);
517
+		// return formatted currency amount
518
+		return $amount_formatted;
519
+	}
520
+
521
+
522
+	/**
523
+	 * This function is used for outputting the localized label for a given status id in the schema requested (and
524
+	 * possibly plural).  The intended use of this function is only for cases where wanting a label outside of a
525
+	 * related status model or model object (i.e. in documentation etc.)
526
+	 *
527
+	 * @param string  $status_id  Status ID matching a registered status in the esp_status table.  If there is no
528
+	 *                            match, then 'Unknown' will be returned.
529
+	 * @param boolean $plural     Whether to return plural or not
530
+	 * @param string  $schema     'UPPER', 'lower', or 'Sentence'
531
+	 * @return string             The localized label for the status id.
532
+	 * @throws EE_Error
533
+	 */
534
+	public static function pretty_status($status_id, $plural = false, $schema = 'upper')
535
+	{
536
+		$status = EEM_Status::instance()->localized_status(
537
+			[$status_id => esc_html__('unknown', 'event_espresso')],
538
+			$plural,
539
+			$schema
540
+		);
541
+		return $status[ $status_id ];
542
+	}
543
+
544
+
545
+	/**
546
+	 * This helper just returns a button or link for the given parameters
547
+	 *
548
+	 * @param string $url   the url for the link, note that `esc_url` will be called on it
549
+	 * @param string $label What is the label you want displayed for the button
550
+	 * @param string $class what class is used for the button (defaults to 'button-primary')
551
+	 * @param string $icon
552
+	 * @param string $title
553
+	 * @return string the html output for the button
554
+	 */
555
+	public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '')
556
+	{
557
+		$icon_html = '';
558
+		if (! empty($icon)) {
559
+			$dashicons = preg_split("(ee-icon |dashicons )", $icon);
560
+			$dashicons = array_filter($dashicons);
561
+			$count     = count($dashicons);
562
+			$icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
563
+			foreach ($dashicons as $dashicon) {
564
+				$type      = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
565
+				$icon_html .= '<span class="' . $type . $dashicon . '"></span>';
566
+			}
567
+			$icon_html .= $count > 1 ? '</span>' : '';
568
+		}
569
+		// sanitize & escape
570
+		$id    = sanitize_title_with_dashes($label);
571
+		$url   = esc_url_raw($url);
572
+		$class = esc_attr($class);
573
+		$title = esc_attr($title);
574
+		$label = esc_html($label);
575
+		return "<a id='{$id}' href='{$url}' class='{$class}' title='{$title}'>{$icon_html}{$label}</a>";
576
+	}
577
+
578
+
579
+	/**
580
+	 * This returns a generated link that will load the related help tab on admin pages.
581
+	 *
582
+	 * @param string      $help_tab_id the id for the connected help tab
583
+	 * @param bool|string $page        The page identifier for the page the help tab is on
584
+	 * @param bool|string $action      The action (route) for the admin page the help tab is on.
585
+	 * @param bool|string $icon_style  (optional) include css class for the style you want to use for the help icon.
586
+	 * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
587
+	 * @return string              generated link
588
+	 */
589
+	public static function get_help_tab_link(
590
+		$help_tab_id,
591
+		$page = false,
592
+		$action = false,
593
+		$icon_style = false,
594
+		$help_text = false
595
+	) {
596
+		global $allowedtags;
597
+		/** @var RequestInterface $request */
598
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
599
+		$page    = $page ?: $request->getRequestParam('page', '', 'key');
600
+		$action  = $action ?: $request->getRequestParam('action', 'default', 'key');
601
+
602
+
603
+		$help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
604
+		$icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
605
+		$help_text    = ! $help_text ? '' : $help_text;
606
+		return '<a id="'
607
+			   . esc_attr($help_tab_lnk)
608
+			   . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'
609
+			   . esc_attr($icon)
610
+			   . '" title="'
611
+			   . esc_attr__(
612
+				   'Click to open the \'Help\' tab for more information about this feature.',
613
+				   'event_espresso'
614
+			   )
615
+			   . '" > '
616
+			   . wp_kses($help_text, $allowedtags)
617
+			   . ' </a>';
618
+	}
619
+
620
+
621
+	/**
622
+	 * This helper generates the html structure for the jquery joyride plugin with the given params.
623
+	 *
624
+	 * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin
625
+	 * @see  EE_Admin_Page->_stop_callback() for the construct expected for the $stops param.
626
+	 * @param EE_Help_Tour
627
+	 * @return string         html
628
+	 * @throws EE_Error
629
+	 */
630
+	public static function help_tour_stops_generator(EE_Help_Tour $tour)
631
+	{
632
+		global $allowedtags;
633
+		$id    = $tour->get_slug();
634
+		$stops = $tour->get_stops();
635
+
636
+		$content = '<ol style="display:none" id="' . esc_attr($id) . '">';
637
+
638
+		foreach ($stops as $stop) {
639
+			$data_id    = ! empty($stop['id'])
640
+				? ' data-id="' . esc_attr($stop['id']) . '"'
641
+				: '';
642
+
643
+			$data_class = empty($data_id) && ! empty($stop['class'])
644
+				? ' data-class="' . esc_attr($stop['class']) . '"'
645
+				: '';
646
+
647
+			// if container is set to modal then let's make sure we set the options accordingly
648
+			if (empty($data_id) && empty($data_class)) {
649
+				$stop['options']['modal']  = true;
650
+				$stop['options']['expose'] = true;
651
+			}
652
+
653
+			$custom_class  = ! empty($stop['custom_class'])
654
+				? ' class="' . esc_attr($stop['custom_class']) . '"'
655
+				: '';
656
+			$button_text   = ! empty($stop['button_text'])
657
+				? ' data-button="' . esc_html($stop['button_text']) . '"'
658
+				: '';
659
+			$inner_content = isset($stop['content']) ? wp_kses($stop['content'], $allowedtags) : '';
660
+
661
+			// options
662
+			if (isset($stop['options']) && is_array($stop['options'])) {
663
+				$options = ' data-options="';
664
+				foreach ($stop['options'] as $option => $value) {
665
+					$options .= esc_attr($option) . ':' . esc_attr($value) . ';';
666
+				}
667
+				$options .= '"';
668
+			} else {
669
+				$options = '';
670
+			}
671
+
672
+			// let's put all together
673
+			$content .= '<li'
674
+						. $data_id
675
+						. $data_class
676
+						. $custom_class
677
+						. $button_text
678
+						. $options
679
+						. '>'
680
+						. $inner_content
681
+						. '</li>';
682
+		}
683
+
684
+		$content .= '</ol>';
685
+		return $content;
686
+	}
687
+
688
+
689
+	/**
690
+	 * This is a helper method to generate a status legend for a given status array.
691
+	 * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods
692
+	 * status_array.
693
+	 *
694
+	 * @param array  $status_array   array of statuses that will make up the legend. In format:
695
+	 *                               array(
696
+	 *                               'status_item' => 'status_name'
697
+	 *                               )
698
+	 * @param string $active_status  This is used to indicate what the active status is IF that is to be highlighted in
699
+	 *                               the legend.
700
+	 * @return string               html structure for status.
701
+	 * @throws EE_Error
702
+	 */
703
+	public static function status_legend($status_array, $active_status = '')
704
+	{
705
+		if (! is_array($status_array)) {
706
+			throw new EE_Error(
707
+				esc_html__(
708
+					'The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
709
+					'event_espresso'
710
+				)
711
+			);
712
+		}
713
+
714
+		$content = '
715 715
             <div class="ee-list-table-legend-container">
716 716
                 <h4 class="status-legend-title">
717 717
                     ' . esc_html__('Status Legend', 'event_espresso') . '
718 718
                 </h4>
719 719
                 <dl class="ee-list-table-legend">';
720 720
 
721
-        foreach ($status_array as $item => $status) {
722
-            $active_class = $active_status == $status ? 'class="ee-is-active-status"' : '';
723
-            $content      .= '
721
+		foreach ($status_array as $item => $status) {
722
+			$active_class = $active_status == $status ? 'class="ee-is-active-status"' : '';
723
+			$content      .= '
724 724
                     <dt id="' . esc_attr('ee-legend-item-tooltip-' . $item) . '" ' . $active_class . '>
725 725
                         <span class="' . esc_attr('ee-status-legend ee-status-legend-' . $status) . '"></span>
726 726
                         <span class="ee-legend-description">
727 727
                             ' . EEH_Template::pretty_status($status, false, 'sentence') . '
728 728
                         </span>
729 729
                     </dt>';
730
-        }
730
+		}
731 731
 
732
-        $content .= '
732
+		$content .= '
733 733
                 </dl>
734 734
             </div>
735 735
 ';
736
-        return $content;
737
-    }
738
-
739
-
740
-    /**
741
-     * Gets HTML for laying out a deeply-nested array (and objects) in a format
742
-     * that's nice for presenting in the wp admin
743
-     *
744
-     * @param mixed $data
745
-     * @return string
746
-     */
747
-    public static function layout_array_as_table($data)
748
-    {
749
-        if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
750
-            $data = (array) $data;
751
-        }
752
-        ob_start();
753
-        if (is_array($data)) {
754
-            if (EEH_Array::is_associative_array($data)) { ?>
736
+		return $content;
737
+	}
738
+
739
+
740
+	/**
741
+	 * Gets HTML for laying out a deeply-nested array (and objects) in a format
742
+	 * that's nice for presenting in the wp admin
743
+	 *
744
+	 * @param mixed $data
745
+	 * @return string
746
+	 */
747
+	public static function layout_array_as_table($data)
748
+	{
749
+		if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
750
+			$data = (array) $data;
751
+		}
752
+		ob_start();
753
+		if (is_array($data)) {
754
+			if (EEH_Array::is_associative_array($data)) { ?>
755 755
                 <table class="widefat">
756 756
                     <tbody>
757 757
                     <?php foreach ($data as $data_key => $data_values) { ?>
@@ -769,292 +769,292 @@  discard block
 block discarded – undo
769 769
             <?php } else { ?>
770 770
                 <ul>
771 771
                     <?php
772
-                    foreach ($data as $datum) {
773
-                        echo "<li>";
774
-                        echo self::layout_array_as_table($datum);
775
-                        echo "</li>";
776
-                    } ?>
772
+					foreach ($data as $datum) {
773
+						echo "<li>";
774
+						echo self::layout_array_as_table($datum);
775
+						echo "</li>";
776
+					} ?>
777 777
                 </ul>
778 778
             <?php }
779
-        } else {
780
-            // simple value
781
-            echo esc_html($data);
782
-        }
783
-        return ob_get_clean();
784
-    }
785
-
786
-
787
-    /**
788
-     * wrapper for self::get_paging_html() that simply echos the generated paging html
789
-     *
790
-     * @param        $total_items
791
-     * @param        $current
792
-     * @param        $per_page
793
-     * @param        $url
794
-     * @param bool   $show_num_field
795
-     * @param string $paged_arg_name
796
-     * @param array  $items_label
797
-     * @see   self:get_paging_html() for argument docs.
798
-     * @since 4.4.0
799
-     */
800
-    public static function paging_html(
801
-        $total_items,
802
-        $current,
803
-        $per_page,
804
-        $url,
805
-        $show_num_field = true,
806
-        $paged_arg_name = 'paged',
807
-        $items_label = []
808
-    ) {
809
-        echo self::get_paging_html(
810
-            $total_items,
811
-            $current,
812
-            $per_page,
813
-            $url,
814
-            $show_num_field,
815
-            $paged_arg_name,
816
-            $items_label
817
-        );
818
-    }
819
-
820
-
821
-    /**
822
-     * A method for generating paging similar to WP_List_Table
823
-     *
824
-     * @param integer $total_items      How many total items there are to page.
825
-     * @param integer $current          What the current page is.
826
-     * @param integer $per_page         How many items per page.
827
-     * @param string  $url              What the base url for page links is.
828
-     * @param boolean $show_num_field   Whether to show the input for changing page number.
829
-     * @param string  $paged_arg_name   The name of the key for the paged query argument.
830
-     * @param array   $items_label      An array of singular/plural values for the items label:
831
-     *                                  array(
832
-     *                                  'single' => 'item',
833
-     *                                  'plural' => 'items'
834
-     *                                  )
835
-     * @return  string
836
-     * @since    4.4.0
837
-     * @see      wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination()
838
-     */
839
-    public static function get_paging_html(
840
-        $total_items,
841
-        $current,
842
-        $per_page,
843
-        $url,
844
-        $show_num_field = true,
845
-        $paged_arg_name = 'paged',
846
-        $items_label = []
847
-    ) {
848
-        $page_links     = [];
849
-        $disable_first  = $disable_last = '';
850
-        $total_items    = (int) $total_items;
851
-        $per_page       = (int) $per_page;
852
-        $current        = (int) $current;
853
-        $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
854
-
855
-        // filter items_label
856
-        $items_label = apply_filters(
857
-            'FHEE__EEH_Template__get_paging_html__items_label',
858
-            $items_label
859
-        );
860
-
861
-        if (
862
-            empty($items_label)
863
-            || ! is_array($items_label)
864
-            || ! isset($items_label['single'])
865
-            || ! isset($items_label['plural'])
866
-        ) {
867
-            $items_label = [
868
-                'single' => esc_html__('1 item', 'event_espresso'),
869
-                'plural' => esc_html__('%s items', 'event_espresso'),
870
-            ];
871
-        } else {
872
-            $items_label = [
873
-                'single' => '1 ' . esc_html($items_label['single']),
874
-                'plural' => '%s ' . esc_html($items_label['plural']),
875
-            ];
876
-        }
877
-
878
-        $total_pages = ceil($total_items / $per_page);
879
-
880
-        if ($total_pages <= 1) {
881
-            return '';
882
-        }
883
-
884
-        $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
885
-
886
-        $output = '<span class="displaying-num">' . $item_label . '</span>';
887
-
888
-        if ($current === 1) {
889
-            $disable_first = ' disabled';
890
-        }
891
-        if ($current == $total_pages) {
892
-            $disable_last = ' disabled';
893
-        }
894
-
895
-        $page_links[] = sprintf(
896
-            "<a class='%s' title='%s' href='%s'>%s</a>",
897
-            'first-page' . $disable_first,
898
-            esc_attr__('Go to the first page', 'event_espresso'),
899
-            esc_url_raw(remove_query_arg($paged_arg_name, $url)),
900
-            '&laquo;'
901
-        );
902
-
903
-        $page_links[] = sprintf(
904
-            '<a class="%s" title="%s" href="%s">%s</a>',
905
-            'prev-page' . $disable_first,
906
-            esc_attr__('Go to the previous page', 'event_espresso'),
907
-            esc_url_raw(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
908
-            '&lsaquo;'
909
-        );
910
-
911
-        if (! $show_num_field) {
912
-            $html_current_page = $current;
913
-        } else {
914
-            $html_current_page = sprintf(
915
-                "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
916
-                esc_attr__('Current page', 'event_espresso'),
917
-                esc_attr($current),
918
-                strlen($total_pages)
919
-            );
920
-        }
921
-
922
-        $html_total_pages = sprintf(
923
-            '<span class="total-pages">%s</span>',
924
-            number_format_i18n($total_pages)
925
-        );
926
-        $page_links[]     = sprintf(
927
-            _x('%3$s%1$s of %2$s%4$s', 'paging', 'event_espresso'),
928
-            $html_current_page,
929
-            $html_total_pages,
930
-            '<span class="paging-input">',
931
-            '</span>'
932
-        );
933
-
934
-        $page_links[] = sprintf(
935
-            '<a class="%s" title="%s" href="%s">%s</a>',
936
-            'next-page' . $disable_last,
937
-            esc_attr__('Go to the next page', 'event_espresso'),
938
-            esc_url_raw(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
939
-            '&rsaquo;'
940
-        );
941
-
942
-        $page_links[] = sprintf(
943
-            '<a class="%s" title="%s" href="%s">%s</a>',
944
-            'last-page' . $disable_last,
945
-            esc_attr__('Go to the last page', 'event_espresso'),
946
-            esc_url_raw(add_query_arg($paged_arg_name, $total_pages, $url)),
947
-            '&raquo;'
948
-        );
949
-
950
-        $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
951
-        // set page class
952
-        if ($total_pages) {
953
-            $page_class = $total_pages < 2 ? ' one-page' : '';
954
-        } else {
955
-            $page_class = ' no-pages';
956
-        }
957
-
958
-        return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
959
-    }
960
-
961
-
962
-    /**
963
-     * @param string $wrap_class
964
-     * @param string $wrap_id
965
-     * @return string
966
-     */
967
-    public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = [])
968
-    {
969
-        $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
970
-        if (
971
-            ! $admin
972
-            && ! apply_filters(
973
-                'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer',
974
-                EE_Registry::instance()->CFG->admin->show_reg_footer
975
-            )
976
-        ) {
977
-            return '';
978
-        }
979
-        $tag        = $admin ? 'span' : 'div';
980
-        $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : '';
981
-        $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class;
982
-        $attributes .= ! empty($wrap_class)
983
-            ? " class=\"{$wrap_class} powered-by-event-espresso-credit\""
984
-            : ' class="powered-by-event-espresso-credit"';
985
-        $query_args = array_merge(
986
-            [
987
-                'ap_id'        => EE_Registry::instance()->CFG->admin->affiliate_id(),
988
-                'utm_source'   => 'powered_by_event_espresso',
989
-                'utm_medium'   => 'link',
990
-                'utm_campaign' => 'powered_by',
991
-            ],
992
-            $query_args
993
-        );
994
-        $powered_by = apply_filters(
995
-            'FHEE__EEH_Template__powered_by_event_espresso_text',
996
-            $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'
997
-        );
998
-        $url        = add_query_arg($query_args, 'https://eventespresso.com/');
999
-        $url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
1000
-        return (string) apply_filters(
1001
-            'FHEE__EEH_Template__powered_by_event_espresso__html',
1002
-            sprintf(
1003
-                esc_html_x(
1004
-                    '%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s',
1005
-                    'Online event registration and ticketing powered by [link to eventespresso.com]',
1006
-                    'event_espresso'
1007
-                ),
1008
-                "<{$tag}{$attributes}>",
1009
-                "<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>",
1010
-                $admin ? '' : '<br />'
1011
-            ),
1012
-            $wrap_class,
1013
-            $wrap_id
1014
-        );
1015
-    }
1016
-
1017
-
1018
-    /**
1019
-     * @param string $image_name
1020
-     * @return string|null
1021
-     * @since   4.10.14.p
1022
-     */
1023
-    public static function getScreenshotUrl($image_name)
1024
-    {
1025
-        return esc_url_raw(EE_GLOBAL_ASSETS_URL . 'images/screenshots/' . $image_name . '.jpg');
1026
-    }
779
+		} else {
780
+			// simple value
781
+			echo esc_html($data);
782
+		}
783
+		return ob_get_clean();
784
+	}
785
+
786
+
787
+	/**
788
+	 * wrapper for self::get_paging_html() that simply echos the generated paging html
789
+	 *
790
+	 * @param        $total_items
791
+	 * @param        $current
792
+	 * @param        $per_page
793
+	 * @param        $url
794
+	 * @param bool   $show_num_field
795
+	 * @param string $paged_arg_name
796
+	 * @param array  $items_label
797
+	 * @see   self:get_paging_html() for argument docs.
798
+	 * @since 4.4.0
799
+	 */
800
+	public static function paging_html(
801
+		$total_items,
802
+		$current,
803
+		$per_page,
804
+		$url,
805
+		$show_num_field = true,
806
+		$paged_arg_name = 'paged',
807
+		$items_label = []
808
+	) {
809
+		echo self::get_paging_html(
810
+			$total_items,
811
+			$current,
812
+			$per_page,
813
+			$url,
814
+			$show_num_field,
815
+			$paged_arg_name,
816
+			$items_label
817
+		);
818
+	}
819
+
820
+
821
+	/**
822
+	 * A method for generating paging similar to WP_List_Table
823
+	 *
824
+	 * @param integer $total_items      How many total items there are to page.
825
+	 * @param integer $current          What the current page is.
826
+	 * @param integer $per_page         How many items per page.
827
+	 * @param string  $url              What the base url for page links is.
828
+	 * @param boolean $show_num_field   Whether to show the input for changing page number.
829
+	 * @param string  $paged_arg_name   The name of the key for the paged query argument.
830
+	 * @param array   $items_label      An array of singular/plural values for the items label:
831
+	 *                                  array(
832
+	 *                                  'single' => 'item',
833
+	 *                                  'plural' => 'items'
834
+	 *                                  )
835
+	 * @return  string
836
+	 * @since    4.4.0
837
+	 * @see      wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination()
838
+	 */
839
+	public static function get_paging_html(
840
+		$total_items,
841
+		$current,
842
+		$per_page,
843
+		$url,
844
+		$show_num_field = true,
845
+		$paged_arg_name = 'paged',
846
+		$items_label = []
847
+	) {
848
+		$page_links     = [];
849
+		$disable_first  = $disable_last = '';
850
+		$total_items    = (int) $total_items;
851
+		$per_page       = (int) $per_page;
852
+		$current        = (int) $current;
853
+		$paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
854
+
855
+		// filter items_label
856
+		$items_label = apply_filters(
857
+			'FHEE__EEH_Template__get_paging_html__items_label',
858
+			$items_label
859
+		);
860
+
861
+		if (
862
+			empty($items_label)
863
+			|| ! is_array($items_label)
864
+			|| ! isset($items_label['single'])
865
+			|| ! isset($items_label['plural'])
866
+		) {
867
+			$items_label = [
868
+				'single' => esc_html__('1 item', 'event_espresso'),
869
+				'plural' => esc_html__('%s items', 'event_espresso'),
870
+			];
871
+		} else {
872
+			$items_label = [
873
+				'single' => '1 ' . esc_html($items_label['single']),
874
+				'plural' => '%s ' . esc_html($items_label['plural']),
875
+			];
876
+		}
877
+
878
+		$total_pages = ceil($total_items / $per_page);
879
+
880
+		if ($total_pages <= 1) {
881
+			return '';
882
+		}
883
+
884
+		$item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
885
+
886
+		$output = '<span class="displaying-num">' . $item_label . '</span>';
887
+
888
+		if ($current === 1) {
889
+			$disable_first = ' disabled';
890
+		}
891
+		if ($current == $total_pages) {
892
+			$disable_last = ' disabled';
893
+		}
894
+
895
+		$page_links[] = sprintf(
896
+			"<a class='%s' title='%s' href='%s'>%s</a>",
897
+			'first-page' . $disable_first,
898
+			esc_attr__('Go to the first page', 'event_espresso'),
899
+			esc_url_raw(remove_query_arg($paged_arg_name, $url)),
900
+			'&laquo;'
901
+		);
902
+
903
+		$page_links[] = sprintf(
904
+			'<a class="%s" title="%s" href="%s">%s</a>',
905
+			'prev-page' . $disable_first,
906
+			esc_attr__('Go to the previous page', 'event_espresso'),
907
+			esc_url_raw(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
908
+			'&lsaquo;'
909
+		);
910
+
911
+		if (! $show_num_field) {
912
+			$html_current_page = $current;
913
+		} else {
914
+			$html_current_page = sprintf(
915
+				"<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
916
+				esc_attr__('Current page', 'event_espresso'),
917
+				esc_attr($current),
918
+				strlen($total_pages)
919
+			);
920
+		}
921
+
922
+		$html_total_pages = sprintf(
923
+			'<span class="total-pages">%s</span>',
924
+			number_format_i18n($total_pages)
925
+		);
926
+		$page_links[]     = sprintf(
927
+			_x('%3$s%1$s of %2$s%4$s', 'paging', 'event_espresso'),
928
+			$html_current_page,
929
+			$html_total_pages,
930
+			'<span class="paging-input">',
931
+			'</span>'
932
+		);
933
+
934
+		$page_links[] = sprintf(
935
+			'<a class="%s" title="%s" href="%s">%s</a>',
936
+			'next-page' . $disable_last,
937
+			esc_attr__('Go to the next page', 'event_espresso'),
938
+			esc_url_raw(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
939
+			'&rsaquo;'
940
+		);
941
+
942
+		$page_links[] = sprintf(
943
+			'<a class="%s" title="%s" href="%s">%s</a>',
944
+			'last-page' . $disable_last,
945
+			esc_attr__('Go to the last page', 'event_espresso'),
946
+			esc_url_raw(add_query_arg($paged_arg_name, $total_pages, $url)),
947
+			'&raquo;'
948
+		);
949
+
950
+		$output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
951
+		// set page class
952
+		if ($total_pages) {
953
+			$page_class = $total_pages < 2 ? ' one-page' : '';
954
+		} else {
955
+			$page_class = ' no-pages';
956
+		}
957
+
958
+		return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
959
+	}
960
+
961
+
962
+	/**
963
+	 * @param string $wrap_class
964
+	 * @param string $wrap_id
965
+	 * @return string
966
+	 */
967
+	public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = [])
968
+	{
969
+		$admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
970
+		if (
971
+			! $admin
972
+			&& ! apply_filters(
973
+				'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer',
974
+				EE_Registry::instance()->CFG->admin->show_reg_footer
975
+			)
976
+		) {
977
+			return '';
978
+		}
979
+		$tag        = $admin ? 'span' : 'div';
980
+		$attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : '';
981
+		$wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class;
982
+		$attributes .= ! empty($wrap_class)
983
+			? " class=\"{$wrap_class} powered-by-event-espresso-credit\""
984
+			: ' class="powered-by-event-espresso-credit"';
985
+		$query_args = array_merge(
986
+			[
987
+				'ap_id'        => EE_Registry::instance()->CFG->admin->affiliate_id(),
988
+				'utm_source'   => 'powered_by_event_espresso',
989
+				'utm_medium'   => 'link',
990
+				'utm_campaign' => 'powered_by',
991
+			],
992
+			$query_args
993
+		);
994
+		$powered_by = apply_filters(
995
+			'FHEE__EEH_Template__powered_by_event_espresso_text',
996
+			$admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'
997
+		);
998
+		$url        = add_query_arg($query_args, 'https://eventespresso.com/');
999
+		$url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
1000
+		return (string) apply_filters(
1001
+			'FHEE__EEH_Template__powered_by_event_espresso__html',
1002
+			sprintf(
1003
+				esc_html_x(
1004
+					'%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s',
1005
+					'Online event registration and ticketing powered by [link to eventespresso.com]',
1006
+					'event_espresso'
1007
+				),
1008
+				"<{$tag}{$attributes}>",
1009
+				"<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>",
1010
+				$admin ? '' : '<br />'
1011
+			),
1012
+			$wrap_class,
1013
+			$wrap_id
1014
+		);
1015
+	}
1016
+
1017
+
1018
+	/**
1019
+	 * @param string $image_name
1020
+	 * @return string|null
1021
+	 * @since   4.10.14.p
1022
+	 */
1023
+	public static function getScreenshotUrl($image_name)
1024
+	{
1025
+		return esc_url_raw(EE_GLOBAL_ASSETS_URL . 'images/screenshots/' . $image_name . '.jpg');
1026
+	}
1027 1027
 }
1028 1028
 
1029 1029
 
1030 1030
 if (! function_exists('espresso_pagination')) {
1031
-    /**
1032
-     *    espresso_pagination
1033
-     *
1034
-     * @access    public
1035
-     * @return    void
1036
-     */
1037
-    function espresso_pagination()
1038
-    {
1039
-        global $wp_query;
1040
-        $big        = 999999999; // need an unlikely integer
1041
-        $pagination = paginate_links(
1042
-            [
1043
-                'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
1044
-                'format'       => '?paged=%#%',
1045
-                'current'      => max(1, get_query_var('paged')),
1046
-                'total'        => $wp_query->max_num_pages,
1047
-                'show_all'     => true,
1048
-                'end_size'     => 10,
1049
-                'mid_size'     => 6,
1050
-                'prev_next'    => true,
1051
-                'prev_text'    => esc_html__('&lsaquo; PREV', 'event_espresso'),
1052
-                'next_text'    => esc_html__('NEXT &rsaquo;', 'event_espresso'),
1053
-                'type'         => 'plain',
1054
-                'add_args'     => false,
1055
-                'add_fragment' => '',
1056
-            ]
1057
-        );
1058
-        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
1059
-    }
1031
+	/**
1032
+	 *    espresso_pagination
1033
+	 *
1034
+	 * @access    public
1035
+	 * @return    void
1036
+	 */
1037
+	function espresso_pagination()
1038
+	{
1039
+		global $wp_query;
1040
+		$big        = 999999999; // need an unlikely integer
1041
+		$pagination = paginate_links(
1042
+			[
1043
+				'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
1044
+				'format'       => '?paged=%#%',
1045
+				'current'      => max(1, get_query_var('paged')),
1046
+				'total'        => $wp_query->max_num_pages,
1047
+				'show_all'     => true,
1048
+				'end_size'     => 10,
1049
+				'mid_size'     => 6,
1050
+				'prev_next'    => true,
1051
+				'prev_text'    => esc_html__('&lsaquo; PREV', 'event_espresso'),
1052
+				'next_text'    => esc_html__('NEXT &rsaquo;', 'event_espresso'),
1053
+				'type'         => 'plain',
1054
+				'add_args'     => false,
1055
+				'add_fragment' => '',
1056
+			]
1057
+		);
1058
+		echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
1059
+	}
1060 1060
 }
1061 1061
\ No newline at end of file
Please login to merge, or discard this patch.
core/helpers/EEH_Tabbed_Content.helper.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
     {
31 31
 
32 32
         // first check if $tabs_names is not empty then the count must match the count of $tabs_content otherwise we've got a problem houston
33
-        if (! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) {
33
+        if ( ! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) {
34 34
             throw new EE_Error(
35 35
                 esc_html__('The count for $tabs_names and $tabs_content does not match.', 'event_espresso')
36 36
             );
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 
50 50
         $index = 0;
51 51
         foreach ($tabs as $tab) {
52
-            $active            = $index === 0;
52
+            $active = $index === 0;
53 53
             $tabs_html         .= self::tab($tab, $active);
54
-            $tabs_content_html .= self::tab_content($tab, $tabs_content[ $tab ], $active);
54
+            $tabs_content_html .= self::tab_content($tab, $tabs_content[$tab], $active);
55 55
             $index++;
56 56
         }
57 57
 
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
     {
119 119
         $nice_name = $nice_name ?: esc_html(ucwords(str_replace(['_', '-'], ' ', $name)));
120 120
         $name      = self::generateTadID($name);
121
-        $class     = $css ? ' ' . esc_attr($css) : '';
122
-        $class     .= $active ? ' nav-tab-active' : '';
123
-        $url       = $url ?: '#' . esc_attr($name);
121
+        $class     = $css ? ' '.esc_attr($css) : '';
122
+        $class .= $active ? ' nav-tab-active' : '';
123
+        $url       = $url ?: '#'.esc_attr($name);
124 124
         return "
125 125
         <a class='nav-tab{$class}' rel='{$name}' href='{$url}'>
126 126
             $nice_name
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      */
137 137
     private static function generateTadID($tab_name)
138 138
     {
139
-        return 'ee-tab-' . esc_attr(str_replace(' ', '-', $tab_name));
139
+        return 'ee-tab-'.esc_attr(str_replace(' ', '-', $tab_name));
140 140
     }
141 141
 
142 142
 
@@ -187,18 +187,18 @@  discard block
 block discarded – undo
187 187
     public static function tab_text_links(array $item_array, $container_class = '', $sep = '|', $default = '')
188 188
     {
189 189
         $item_array = apply_filters('FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class);
190
-        if (! is_array($item_array) || empty($item_array)) {
190
+        if ( ! is_array($item_array) || empty($item_array)) {
191 191
             return false; // get out we don't have even the basic thing we need!
192 192
         }
193 193
 
194
-        $defaults        = [
194
+        $defaults = [
195 195
             'label' => esc_html__('Item', 'event_espresso'),
196 196
             'class' => '',
197 197
             'href'  => '',
198 198
             'title' => esc_attr__('Link for Item', 'event_espresso'),
199 199
             'slug'  => 'item_slug',
200 200
         ];
201
-        $container_class = ! empty($container_class) ? ' ' . esc_attr($container_class) : '';
201
+        $container_class = ! empty($container_class) ? ' '.esc_attr($container_class) : '';
202 202
         $list            = '';
203 203
         $list_length     = count($item_array);
204 204
         // if we're' adding separators, set $current to 1, otherwise set it to list length + 1
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
         // (if we aren't adding separators $current will always be > list length cuz it started at list length + 1)
207 207
         $current = empty($sep) ? $list_length + 1 : 1;
208 208
         foreach ($item_array as $item) {
209
-            $item          = wp_parse_args($item, $defaults);
209
+            $item = wp_parse_args($item, $defaults);
210 210
             $item['class'] .= $default === $item['slug'] ? ' item_display' : '';
211 211
             $list          .= self::textLinkItem($item);
212 212
             $list          .= $current < $list_length ? self::textLinkSeparator($sep) : '';
Please login to merge, or discard this patch.
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -14,246 +14,246 @@
 block discarded – undo
14 14
 class EEH_Tabbed_Content
15 15
 {
16 16
 
17
-    /**
18
-     * assembles and returns the html structure for tabs
19
-     *
20
-     * @static
21
-     * @param array $tabs_contents an array of the content for each tab [required]
22
-     * @param array $tabs_names    a numerically indexed array of names for each tab [optional]
23
-     *                             - if this isn't included then we use the indexes for $tabs_content as the tab names)
24
-     * @param bool  $small_tabs
25
-     * @param bool  $tabs_content
26
-     * @return string the assembled html string containing the tabbed content for display.
27
-     * @throws EE_Error
28
-     */
29
-    public static function display($tabs_contents, $tabs_names = [], $small_tabs = true, $tabs_content = true)
30
-    {
17
+	/**
18
+	 * assembles and returns the html structure for tabs
19
+	 *
20
+	 * @static
21
+	 * @param array $tabs_contents an array of the content for each tab [required]
22
+	 * @param array $tabs_names    a numerically indexed array of names for each tab [optional]
23
+	 *                             - if this isn't included then we use the indexes for $tabs_content as the tab names)
24
+	 * @param bool  $small_tabs
25
+	 * @param bool  $tabs_content
26
+	 * @return string the assembled html string containing the tabbed content for display.
27
+	 * @throws EE_Error
28
+	 */
29
+	public static function display($tabs_contents, $tabs_names = [], $small_tabs = true, $tabs_content = true)
30
+	{
31 31
 
32
-        // first check if $tabs_names is not empty then the count must match the count of $tabs_content otherwise we've got a problem houston
33
-        if (! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) {
34
-            throw new EE_Error(
35
-                esc_html__('The count for $tabs_names and $tabs_content does not match.', 'event_espresso')
36
-            );
37
-        }
32
+		// first check if $tabs_names is not empty then the count must match the count of $tabs_content otherwise we've got a problem houston
33
+		if (! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) {
34
+			throw new EE_Error(
35
+				esc_html__('The count for $tabs_names and $tabs_content does not match.', 'event_espresso')
36
+			);
37
+		}
38 38
 
39
-        // make sure we've got incoming data setup properly
40
-        $tabs         = ! empty($tabs_names)
41
-            ? (array) $tabs_names
42
-            : array_keys((array) $tabs_contents);
43
-        $tabs_content = ! empty($tabs_names)
44
-            ? array_combine((array) $tabs_names, (array) $tabs_content)
45
-            : $tabs_contents;
39
+		// make sure we've got incoming data setup properly
40
+		$tabs         = ! empty($tabs_names)
41
+			? (array) $tabs_names
42
+			: array_keys((array) $tabs_contents);
43
+		$tabs_content = ! empty($tabs_names)
44
+			? array_combine((array) $tabs_names, (array) $tabs_content)
45
+			: $tabs_contents;
46 46
 
47
-        $tabs_html         = '';
48
-        $tabs_content_html = '';
47
+		$tabs_html         = '';
48
+		$tabs_content_html = '';
49 49
 
50
-        $index = 0;
51
-        foreach ($tabs as $tab) {
52
-            $active            = $index === 0;
53
-            $tabs_html         .= self::tab($tab, $active);
54
-            $tabs_content_html .= self::tab_content($tab, $tabs_content[ $tab ], $active);
55
-            $index++;
56
-        }
50
+		$index = 0;
51
+		foreach ($tabs as $tab) {
52
+			$active            = $index === 0;
53
+			$tabs_html         .= self::tab($tab, $active);
54
+			$tabs_content_html .= self::tab_content($tab, $tabs_content[ $tab ], $active);
55
+			$index++;
56
+		}
57 57
 
58
-        $tabs_class = $small_tabs ? ' ee-nav-tabs-small' : '';
58
+		$tabs_class = $small_tabs ? ' ee-nav-tabs-small' : '';
59 59
 
60
-        return "
60
+		return "
61 61
     <div class='ee-nav-tabs{$tabs_class}'>
62 62
         <h2 class='nav-tab-wrapper'>{$tabs_html}</h2>
63 63
         {$tabs_content_html}
64 64
     </div>
65 65
     ";
66
-    }
66
+	}
67 67
 
68 68
 
69
-    /**
70
-     * display_admin_nav_tabs
71
-     * this returns the properly formatted tab html for EE_Admin_Pages.
72
-     * We are expecting an array of tabs in the following format
73
-     * array(
74
-     *    'nav_tab_name' => array(
75
-     *        'url' => 'url for tab',
76
-     *        'link_text' => 'tab text',
77
-     *        'css_class' => 'tab class' //including the nav-tab-active class if its active
78
-     *    )
79
-     * )
80
-     *
81
-     * @access public
82
-     * @static
83
-     * @param string[][] $nav_tabs tab array for nav tabs
84
-     * @return string
85
-     * @throws EE_Error
86
-     */
87
-    public static function display_admin_nav_tabs($nav_tabs = [])
88
-    {
89
-        if (empty($nav_tabs)) {
90
-            throw new EE_Error(
91
-                esc_html__('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso')
92
-            );
93
-        }
94
-        $tab_content = '';
95
-        foreach ($nav_tabs as $slug => $tab) {
96
-            $tab_content .= self::tab($slug, false, $tab['link_text'], $tab['url'], $tab['css_class']);
97
-        }
98
-        $aria_label = esc_attr__('Secondary menu', 'event_espresso');
99
-        return "
69
+	/**
70
+	 * display_admin_nav_tabs
71
+	 * this returns the properly formatted tab html for EE_Admin_Pages.
72
+	 * We are expecting an array of tabs in the following format
73
+	 * array(
74
+	 *    'nav_tab_name' => array(
75
+	 *        'url' => 'url for tab',
76
+	 *        'link_text' => 'tab text',
77
+	 *        'css_class' => 'tab class' //including the nav-tab-active class if its active
78
+	 *    )
79
+	 * )
80
+	 *
81
+	 * @access public
82
+	 * @static
83
+	 * @param string[][] $nav_tabs tab array for nav tabs
84
+	 * @return string
85
+	 * @throws EE_Error
86
+	 */
87
+	public static function display_admin_nav_tabs($nav_tabs = [])
88
+	{
89
+		if (empty($nav_tabs)) {
90
+			throw new EE_Error(
91
+				esc_html__('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso')
92
+			);
93
+		}
94
+		$tab_content = '';
95
+		foreach ($nav_tabs as $slug => $tab) {
96
+			$tab_content .= self::tab($slug, false, $tab['link_text'], $tab['url'], $tab['css_class']);
97
+		}
98
+		$aria_label = esc_attr__('Secondary menu', 'event_espresso');
99
+		return "
100 100
         <nav class='nav-tab-wrapper wp-clearfix' aria-label='{$aria_label}'>
101 101
             {$tab_content}
102 102
         </nav>
103 103
         ";
104
-    }
104
+	}
105 105
 
106 106
 
107
-    /**
108
-     * this simply returns a single tab given a tab name & content
109
-     *
110
-     * @param string      $name      name of tab
111
-     * @param bool        $active    true=tab active, false=tab not active
112
-     * @param bool|string $nice_name if string given then this value will be used for the tab link text.
113
-     * @param bool|string $url       If url given then tabs will be generated linking to the url.
114
-     * @param bool|string $css       If string given then the generated tab will include that as the class.
115
-     * @return string          html for tab
116
-     */
117
-    private static function tab($name, $active = false, $nice_name = false, $url = false, $css = false)
118
-    {
119
-        $nice_name = $nice_name ?: esc_html(ucwords(str_replace(['_', '-'], ' ', $name)));
120
-        $name      = self::generateTadID($name);
121
-        $class     = $css ? ' ' . esc_attr($css) : '';
122
-        $class     .= $active ? ' nav-tab-active' : '';
123
-        $url       = $url ?: '#' . esc_attr($name);
124
-        return "
107
+	/**
108
+	 * this simply returns a single tab given a tab name & content
109
+	 *
110
+	 * @param string      $name      name of tab
111
+	 * @param bool        $active    true=tab active, false=tab not active
112
+	 * @param bool|string $nice_name if string given then this value will be used for the tab link text.
113
+	 * @param bool|string $url       If url given then tabs will be generated linking to the url.
114
+	 * @param bool|string $css       If string given then the generated tab will include that as the class.
115
+	 * @return string          html for tab
116
+	 */
117
+	private static function tab($name, $active = false, $nice_name = false, $url = false, $css = false)
118
+	{
119
+		$nice_name = $nice_name ?: esc_html(ucwords(str_replace(['_', '-'], ' ', $name)));
120
+		$name      = self::generateTadID($name);
121
+		$class     = $css ? ' ' . esc_attr($css) : '';
122
+		$class     .= $active ? ' nav-tab-active' : '';
123
+		$url       = $url ?: '#' . esc_attr($name);
124
+		return "
125 125
         <a class='nav-tab{$class}' rel='{$name}' href='{$url}'>
126 126
             $nice_name
127 127
         </a>
128 128
         ";
129
-    }
129
+	}
130 130
 
131 131
 
132
-    /**
133
-     * @param string $tab_name
134
-     * @return string
135
-     * @since   4.10.14.p
136
-     */
137
-    private static function generateTadID($tab_name)
138
-    {
139
-        return 'ee-tab-' . esc_attr(str_replace(' ', '-', $tab_name));
140
-    }
132
+	/**
133
+	 * @param string $tab_name
134
+	 * @return string
135
+	 * @since   4.10.14.p
136
+	 */
137
+	private static function generateTadID($tab_name)
138
+	{
139
+		return 'ee-tab-' . esc_attr(str_replace(' ', '-', $tab_name));
140
+	}
141 141
 
142 142
 
143
-    /**
144
-     * this just returns the properly formatted tab content for our tab box.
145
-     *
146
-     * @param string $name        name of tab (used for selector)
147
-     * @param string $tab_content content of tab
148
-     * @param bool   $active
149
-     * @return string html for content area
150
-     */
151
-    private static function tab_content($name, $tab_content, $active = false)
152
-    {
153
-        $class = $active ? '' : ' hidden';
154
-        $name  = self::generateTadID($name);
155
-        return "
143
+	/**
144
+	 * this just returns the properly formatted tab content for our tab box.
145
+	 *
146
+	 * @param string $name        name of tab (used for selector)
147
+	 * @param string $tab_content content of tab
148
+	 * @param bool   $active
149
+	 * @return string html for content area
150
+	 */
151
+	private static function tab_content($name, $tab_content, $active = false)
152
+	{
153
+		$class = $active ? '' : ' hidden';
154
+		$name  = self::generateTadID($name);
155
+		return "
156 156
     <div class='nav-tab-content{$class}' id='{$name}'>
157 157
         {$tab_content}
158 158
         <div style='clear:both'></div>
159 159
     </div>";
160
-    }
160
+	}
161 161
 
162 162
 
163 163
 
164
-    /** HORIZONTAL TEXT LINKS **/
164
+	/** HORIZONTAL TEXT LINKS **/
165 165
 
166
-    /**
167
-     * This will take in an array of link items and spit out a formatted list of links that can be used to navigate to
168
-     * items. There is a corresponding js file that can be loaded to dynamically display containers with the same id as
169
-     * the href -ref.
170
-     *
171
-     * @param string[] $item_array      formatted array of items.  Format:
172
-     *                                  array(
173
-     *                                  'label' => esc_html__('localized label displayed'),
174
-     *                                  'class' => 'class_for_item',
175
-     *                                  'href' => '#some_item_id', //url/bookmark for item.  If you include a bookmark
176
-     *                                  the js will used this to show the container div.
177
-     *                                  'title' => esc_html__('localized text for the title attribute of the link'),
178
-     *                                  'slug' => 'slug_used_for_reference'
179
-     *                                  )
180
-     * @param string   $container_class class used for main container
181
-     * @param string   $sep             you can add in what is used as a separator between each link (or leave blank for
182
-     *                                  none)
183
-     * @param string   $default         You can include a string for the item that will receive the "item_display" class
184
-     *                                  for the js.
185
-     * @return string                  a html snippet of of all the formatted link elements.
186
-     */
187
-    public static function tab_text_links(array $item_array, $container_class = '', $sep = '|', $default = '')
188
-    {
189
-        $item_array = apply_filters('FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class);
190
-        if (! is_array($item_array) || empty($item_array)) {
191
-            return false; // get out we don't have even the basic thing we need!
192
-        }
166
+	/**
167
+	 * This will take in an array of link items and spit out a formatted list of links that can be used to navigate to
168
+	 * items. There is a corresponding js file that can be loaded to dynamically display containers with the same id as
169
+	 * the href -ref.
170
+	 *
171
+	 * @param string[] $item_array      formatted array of items.  Format:
172
+	 *                                  array(
173
+	 *                                  'label' => esc_html__('localized label displayed'),
174
+	 *                                  'class' => 'class_for_item',
175
+	 *                                  'href' => '#some_item_id', //url/bookmark for item.  If you include a bookmark
176
+	 *                                  the js will used this to show the container div.
177
+	 *                                  'title' => esc_html__('localized text for the title attribute of the link'),
178
+	 *                                  'slug' => 'slug_used_for_reference'
179
+	 *                                  )
180
+	 * @param string   $container_class class used for main container
181
+	 * @param string   $sep             you can add in what is used as a separator between each link (or leave blank for
182
+	 *                                  none)
183
+	 * @param string   $default         You can include a string for the item that will receive the "item_display" class
184
+	 *                                  for the js.
185
+	 * @return string                  a html snippet of of all the formatted link elements.
186
+	 */
187
+	public static function tab_text_links(array $item_array, $container_class = '', $sep = '|', $default = '')
188
+	{
189
+		$item_array = apply_filters('FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class);
190
+		if (! is_array($item_array) || empty($item_array)) {
191
+			return false; // get out we don't have even the basic thing we need!
192
+		}
193 193
 
194
-        $defaults        = [
195
-            'label' => esc_html__('Item', 'event_espresso'),
196
-            'class' => '',
197
-            'href'  => '',
198
-            'title' => esc_attr__('Link for Item', 'event_espresso'),
199
-            'slug'  => 'item_slug',
200
-        ];
201
-        $container_class = ! empty($container_class) ? ' ' . esc_attr($container_class) : '';
202
-        $list            = '';
203
-        $list_length     = count($item_array);
204
-        // if we're' adding separators, set $current to 1, otherwise set it to list length + 1
205
-        // then we'll increment $current while looping and only add separators if $current is < list length
206
-        // (if we aren't adding separators $current will always be > list length cuz it started at list length + 1)
207
-        $current = empty($sep) ? $list_length + 1 : 1;
208
-        foreach ($item_array as $item) {
209
-            $item          = wp_parse_args($item, $defaults);
210
-            $item['class'] .= $default === $item['slug'] ? ' item_display' : '';
211
-            $list          .= self::textLinkItem($item);
212
-            $list          .= $current < $list_length ? self::textLinkSeparator($sep) : '';
213
-            $current++;
214
-        }
194
+		$defaults        = [
195
+			'label' => esc_html__('Item', 'event_espresso'),
196
+			'class' => '',
197
+			'href'  => '',
198
+			'title' => esc_attr__('Link for Item', 'event_espresso'),
199
+			'slug'  => 'item_slug',
200
+		];
201
+		$container_class = ! empty($container_class) ? ' ' . esc_attr($container_class) : '';
202
+		$list            = '';
203
+		$list_length     = count($item_array);
204
+		// if we're' adding separators, set $current to 1, otherwise set it to list length + 1
205
+		// then we'll increment $current while looping and only add separators if $current is < list length
206
+		// (if we aren't adding separators $current will always be > list length cuz it started at list length + 1)
207
+		$current = empty($sep) ? $list_length + 1 : 1;
208
+		foreach ($item_array as $item) {
209
+			$item          = wp_parse_args($item, $defaults);
210
+			$item['class'] .= $default === $item['slug'] ? ' item_display' : '';
211
+			$list          .= self::textLinkItem($item);
212
+			$list          .= $current < $list_length ? self::textLinkSeparator($sep) : '';
213
+			$current++;
214
+		}
215 215
 
216
-        return "
216
+		return "
217 217
         <ul class='ee-text-links{$container_class}'>{$list}</ul>
218 218
         ";
219
-    }
219
+	}
220 220
 
221 221
 
222
-    /**
223
-     * @param string[] $item
224
-     * @return string
225
-     */
226
-    private static function textLinkItem(array $item)
227
-    {
228
-        $class = $item['class'] ? esc_attr($item['class']) : '';
229
-        $label = esc_html($item['label']);
230
-        $href  = $item['href'] ? esc_attr($item['href']) : '';
231
-        $title = esc_attr($item['title']);
222
+	/**
223
+	 * @param string[] $item
224
+	 * @return string
225
+	 */
226
+	private static function textLinkItem(array $item)
227
+	{
228
+		$class = $item['class'] ? esc_attr($item['class']) : '';
229
+		$label = esc_html($item['label']);
230
+		$href  = $item['href'] ? esc_attr($item['href']) : '';
231
+		$title = esc_attr($item['title']);
232 232
 
233 233
 
234
-        $link = ! empty($href)
235
-            ? "
234
+		$link = ! empty($href)
235
+			? "
236 236
             <a class='ee-text-link' href='#{$href}' title='{$title}'>
237 237
                 {$label}
238 238
             </a>
239 239
             "
240
-            : $label;
241
-        return "
240
+			: $label;
241
+		return "
242 242
         <li class='ee-text-link-li {$class}'>{$link}</li>
243 243
         ";
244
-    }
244
+	}
245 245
 
246 246
 
247
-    /**
248
-     * @param string $separator
249
-     * @return string
250
-     * @since   4.10.14.p
251
-     */
252
-    private static function textLinkSeparator($separator)
253
-    {
254
-        $separator = esc_html($separator);
255
-        return "
247
+	/**
248
+	 * @param string $separator
249
+	 * @return string
250
+	 * @since   4.10.14.p
251
+	 */
252
+	private static function textLinkSeparator($separator)
253
+	{
254
+		$separator = esc_html($separator);
255
+		return "
256 256
         <li class='ee-text-link-sep'>{$separator}</li>
257 257
         ";
258
-    }
258
+	}
259 259
 }
Please login to merge, or discard this patch.