Completed
Branch BUG-10881-schema-datetime-form... (b45ba9)
by
unknown
117:03 queued 104:49
created
core/helpers/EEH_Schema.helper.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -17,74 +17,74 @@  discard block
 block discarded – undo
17 17
 class EEH_Schema {
18 18
 
19 19
 
20
-    /**
21
-     * generates JSON-based linked data for an event
22
-     *
23
-     * @param EE_Event $event
24
-     * @throws EE_Error
25
-     */
26
-    public static function add_json_linked_data_for_event(EE_Event $event)
27
-    {
28
-    	//Check we have a valid datetime for the event
29
-    	if(! $event->primary_datetime() instanceof EE_Datetime) {
30
-    		return;
31
-    	}
32
-
33
-        $template_args = array(
34
-            'event_permalink' => '',
35
-            'event_name' => '',
36
-            'event_description' => '',
37
-            'event_start' => '',
38
-            'event_end' => '',
39
-            'currency' => '',
40
-            'event_tickets' => array(),
41
-            'venue_name' => '',
42
-            'venue_url' => '',
43
-            'venue_locality' => '',
44
-            'venue_region' => '',
45
-            'event_image' => '',
46
-        );
47
-        $template_args['event_permalink'] = $event->get_permalink();
48
-        $template_args['event_name'] = $event->name();
49
-        $template_args['event_description'] = wp_strip_all_tags($event->short_description(200));
50
-        // clone datetime so that date formats don't override those for the original datetime
51
-        $primary_datetime = clone $event->primary_datetime();
52
-        $template_args['event_start'] = $primary_datetime->start_date(DateTime::ATOM);
53
-        $template_args['event_end'] = $primary_datetime->end_date(DateTime::ATOM);
54
-        unset($primary_datetime);
55
-        $template_args['currency'] = EE_Registry::instance()->CFG->currency->code;
56
-        foreach ($event->tickets() as $original_ticket) {
57
-            // clone tickets so that date formats don't override those for the original ticket
58
-            $ticket= clone $original_ticket;
59
-            $ID = $ticket->ID();
60
-            $template_args['event_tickets'][$ID]['start_date'] = $ticket->start_date(DateTime::ATOM, null);
61
-            $template_args['event_tickets'][$ID]['end_date'] = $ticket->end_date(DateTime::ATOM, null);
62
-            $template_args['event_tickets'][$ID]['price'] = number_format(
63
-                $ticket->price(),
64
-                EE_Registry::instance()->CFG->currency->dec_plc,
65
-                EE_Registry::instance()->CFG->currency->dec_mrk,
66
-                EE_Registry::instance()->CFG->currency->thsnds
67
-            );
68
-            unset($ticket);
69
-        }
70
-        $VNU_ID = espresso_venue_id();
71
-        if ( ! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) {
72
-            $venue = EEH_Venue_View::get_venue($VNU_ID);
73
-            $template_args['venue_name'] = get_the_title($VNU_ID);
74
-            $template_args['venue_url'] = get_permalink($VNU_ID);
75
-            $template_args['venue_locality'] = $venue->city();
76
-            $template_args['venue_region'] = $venue->state_name();
77
-        }
78
-        $template_args['event_image'] = $event->feature_image_url();
79
-        $template_args = apply_filters(
80
-            'FHEE__EEH_Schema__add_json_linked_data_for_event__template_args',
81
-            $template_args,
82
-            $event,
83
-            $VNU_ID
84
-        );
85
-        extract($template_args, EXTR_OVERWRITE);
86
-        include EE_TEMPLATES . 'json_linked_data_for_event.template.php';
87
-    }
20
+	/**
21
+	 * generates JSON-based linked data for an event
22
+	 *
23
+	 * @param EE_Event $event
24
+	 * @throws EE_Error
25
+	 */
26
+	public static function add_json_linked_data_for_event(EE_Event $event)
27
+	{
28
+		//Check we have a valid datetime for the event
29
+		if(! $event->primary_datetime() instanceof EE_Datetime) {
30
+			return;
31
+		}
32
+
33
+		$template_args = array(
34
+			'event_permalink' => '',
35
+			'event_name' => '',
36
+			'event_description' => '',
37
+			'event_start' => '',
38
+			'event_end' => '',
39
+			'currency' => '',
40
+			'event_tickets' => array(),
41
+			'venue_name' => '',
42
+			'venue_url' => '',
43
+			'venue_locality' => '',
44
+			'venue_region' => '',
45
+			'event_image' => '',
46
+		);
47
+		$template_args['event_permalink'] = $event->get_permalink();
48
+		$template_args['event_name'] = $event->name();
49
+		$template_args['event_description'] = wp_strip_all_tags($event->short_description(200));
50
+		// clone datetime so that date formats don't override those for the original datetime
51
+		$primary_datetime = clone $event->primary_datetime();
52
+		$template_args['event_start'] = $primary_datetime->start_date(DateTime::ATOM);
53
+		$template_args['event_end'] = $primary_datetime->end_date(DateTime::ATOM);
54
+		unset($primary_datetime);
55
+		$template_args['currency'] = EE_Registry::instance()->CFG->currency->code;
56
+		foreach ($event->tickets() as $original_ticket) {
57
+			// clone tickets so that date formats don't override those for the original ticket
58
+			$ticket= clone $original_ticket;
59
+			$ID = $ticket->ID();
60
+			$template_args['event_tickets'][$ID]['start_date'] = $ticket->start_date(DateTime::ATOM, null);
61
+			$template_args['event_tickets'][$ID]['end_date'] = $ticket->end_date(DateTime::ATOM, null);
62
+			$template_args['event_tickets'][$ID]['price'] = number_format(
63
+				$ticket->price(),
64
+				EE_Registry::instance()->CFG->currency->dec_plc,
65
+				EE_Registry::instance()->CFG->currency->dec_mrk,
66
+				EE_Registry::instance()->CFG->currency->thsnds
67
+			);
68
+			unset($ticket);
69
+		}
70
+		$VNU_ID = espresso_venue_id();
71
+		if ( ! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) {
72
+			$venue = EEH_Venue_View::get_venue($VNU_ID);
73
+			$template_args['venue_name'] = get_the_title($VNU_ID);
74
+			$template_args['venue_url'] = get_permalink($VNU_ID);
75
+			$template_args['venue_locality'] = $venue->city();
76
+			$template_args['venue_region'] = $venue->state_name();
77
+		}
78
+		$template_args['event_image'] = $event->feature_image_url();
79
+		$template_args = apply_filters(
80
+			'FHEE__EEH_Schema__add_json_linked_data_for_event__template_args',
81
+			$template_args,
82
+			$event,
83
+			$VNU_ID
84
+		);
85
+		extract($template_args, EXTR_OVERWRITE);
86
+		include EE_TEMPLATES . 'json_linked_data_for_event.template.php';
87
+	}
88 88
 
89 89
 
90 90
 	/**
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 	 */
99 99
 	public static function location( $location = null ) {
100 100
 		return ! empty( $location ) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">'
101
-		                              . $location
102
-		                              . '</div>' : '';
101
+									  . $location
102
+									  . '</div>' : '';
103 103
 	}
104 104
 
105 105
 
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
 	 */
220 220
 	public static function postalCode( EEI_Address $obj_with_address = null ) {
221 221
 		return $obj_with_address->zip() !== null && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">'
222
-		                                                                              . $obj_with_address->zip()
223
-		                                                                              . '</span>' : '';
222
+																					  . $obj_with_address->zip()
223
+																					  . '</span>' : '';
224 224
 	}
225 225
 
226 226
 
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 		//Check the URL includes a scheme
255 255
 		$parsed_url = parse_url($url);
256 256
 		if ( empty($parsed_url['scheme']) ) {
257
-		    $url = 'http://' . ltrim($url, '/');
257
+			$url = 'http://' . ltrim($url, '/');
258 258
 		}
259 259
 
260 260
 		$atts = '';
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
4
-	exit( 'No direct script access allowed' );
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4
+	exit('No direct script access allowed');
5 5
 }
6 6
 
7 7
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
     public static function add_json_linked_data_for_event(EE_Event $event)
27 27
     {
28 28
     	//Check we have a valid datetime for the event
29
-    	if(! $event->primary_datetime() instanceof EE_Datetime) {
29
+    	if ( ! $event->primary_datetime() instanceof EE_Datetime) {
30 30
     		return;
31 31
     	}
32 32
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         $template_args['currency'] = EE_Registry::instance()->CFG->currency->code;
56 56
         foreach ($event->tickets() as $original_ticket) {
57 57
             // clone tickets so that date formats don't override those for the original ticket
58
-            $ticket= clone $original_ticket;
58
+            $ticket = clone $original_ticket;
59 59
             $ID = $ticket->ID();
60 60
             $template_args['event_tickets'][$ID]['start_date'] = $ticket->start_date(DateTime::ATOM, null);
61 61
             $template_args['event_tickets'][$ID]['end_date'] = $ticket->end_date(DateTime::ATOM, null);
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
             $VNU_ID
84 84
         );
85 85
         extract($template_args, EXTR_OVERWRITE);
86
-        include EE_TEMPLATES . 'json_linked_data_for_event.template.php';
86
+        include EE_TEMPLATES.'json_linked_data_for_event.template.php';
87 87
     }
88 88
 
89 89
 
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 	 * @param string $location
97 97
 	 * @return string
98 98
 	 */
99
-	public static function location( $location = null ) {
100
-		return ! empty( $location ) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">'
99
+	public static function location($location = null) {
100
+		return ! empty($location) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">'
101 101
 		                              . $location
102 102
 		                              . '</div>' : '';
103 103
 	}
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 	 * @param string $name
113 113
 	 * @return string
114 114
 	 */
115
-	public static function name( $name = null ) {
116
-		return ! empty( $name ) ? '<span itemprop="name">' . $name . '</span>' : '';
115
+	public static function name($name = null) {
116
+		return ! empty($name) ? '<span itemprop="name">'.$name.'</span>' : '';
117 117
 	}
118 118
 
119 119
 
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
 	 * @param EEI_Address $obj_with_address
127 127
 	 * @return string
128 128
 	 */
129
-	public static function streetAddress( EEI_Address $obj_with_address = null ) {
129
+	public static function streetAddress(EEI_Address $obj_with_address = null) {
130 130
 		return $obj_with_address->address() !== null && $obj_with_address->address() !== ''
131
-			? '<span itemprop="streetAddress">' . $obj_with_address->address() . '</span>' : '';
131
+			? '<span itemprop="streetAddress">'.$obj_with_address->address().'</span>' : '';
132 132
 	}
133 133
 
134 134
 
@@ -141,14 +141,14 @@  discard block
 block discarded – undo
141 141
 	 * @param EEI_Address $obj_with_address
142 142
 	 * @return string
143 143
 	 */
144
-	public static function postOfficeBoxNumber( EEI_Address $obj_with_address = null ) {
144
+	public static function postOfficeBoxNumber(EEI_Address $obj_with_address = null) {
145 145
 		// regex check for some form of PO Box or P.O. Box, etc, etc, etc
146
-		if ( preg_match(
146
+		if (preg_match(
147 147
 			"/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i",
148 148
 			$obj_with_address->address2()
149
-		) ) {
149
+		)) {
150 150
 			return $obj_with_address->address2() !== null && $obj_with_address->address2() !== ''
151
-				? '<span itemprop="postOfficeBoxNumber">' . $obj_with_address->address2() . '</span>' : '';
151
+				? '<span itemprop="postOfficeBoxNumber">'.$obj_with_address->address2().'</span>' : '';
152 152
 		} else {
153 153
 			return $obj_with_address->address2();
154 154
 		}
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
 	 * @param EEI_Address $obj_with_address
165 165
 	 * @return string
166 166
 	 */
167
-	public static function addressLocality( EEI_Address $obj_with_address = null ) {
167
+	public static function addressLocality(EEI_Address $obj_with_address = null) {
168 168
 		return $obj_with_address->city() !== null && $obj_with_address->city() !== ''
169
-			? '<span itemprop="addressLocality">' . $obj_with_address->city() . '</span>' : '';
169
+			? '<span itemprop="addressLocality">'.$obj_with_address->city().'</span>' : '';
170 170
 	}
171 171
 
172 172
 
@@ -179,10 +179,10 @@  discard block
 block discarded – undo
179 179
 	 * @param EEI_Address $obj_with_address
180 180
 	 * @return string
181 181
 	 */
182
-	public static function addressRegion( EEI_Address $obj_with_address = null ) {
182
+	public static function addressRegion(EEI_Address $obj_with_address = null) {
183 183
 		$state = $obj_with_address->state_name();
184
-		if ( ! empty( $state ) ) {
185
-			return '<span itemprop="addressRegion">' . $state . '</span>';
184
+		if ( ! empty($state)) {
185
+			return '<span itemprop="addressRegion">'.$state.'</span>';
186 186
 		} else {
187 187
 			return '';
188 188
 		}
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
 	 * @param EEI_Address $obj_with_address
199 199
 	 * @return string
200 200
 	 */
201
-	public static function addressCountry( EEI_Address $obj_with_address = null ) {
201
+	public static function addressCountry(EEI_Address $obj_with_address = null) {
202 202
 		$country = $obj_with_address->country_name();
203
-		if ( ! empty( $country ) ) {
204
-			return '<span itemprop="addressCountry">' . $country . '</span>';
203
+		if ( ! empty($country)) {
204
+			return '<span itemprop="addressCountry">'.$country.'</span>';
205 205
 		} else {
206 206
 			return '';
207 207
 		}
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	 * @param EEI_Address $obj_with_address
218 218
 	 * @return string
219 219
 	 */
220
-	public static function postalCode( EEI_Address $obj_with_address = null ) {
220
+	public static function postalCode(EEI_Address $obj_with_address = null) {
221 221
 		return $obj_with_address->zip() !== null && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">'
222 222
 		                                                                              . $obj_with_address->zip()
223 223
 		                                                                              . '</span>' : '';
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
 	 * @param string $phone_nmbr
234 234
 	 * @return string
235 235
 	 */
236
-	public static function telephone( $phone_nmbr = null ) {
237
-		return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">' . $phone_nmbr . '</span>'
236
+	public static function telephone($phone_nmbr = null) {
237
+		return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">'.$phone_nmbr.'</span>'
238 238
 			: '';
239 239
 	}
240 240
 
@@ -250,19 +250,19 @@  discard block
 block discarded – undo
250 250
 	 * @param array  $attributes - array of additional link attributes in  attribute_name => value pairs. ie: array( 'title' => 'click here', 'class' => 'link-class' )
251 251
 	 * @return string (link)
252 252
 	 */
253
-	public static function url( $url = null, $text = null, $attributes = array() ) {
253
+	public static function url($url = null, $text = null, $attributes = array()) {
254 254
 		//Check the URL includes a scheme
255 255
 		$parsed_url = parse_url($url);
256
-		if ( empty($parsed_url['scheme']) ) {
257
-		    $url = 'http://' . ltrim($url, '/');
256
+		if (empty($parsed_url['scheme'])) {
257
+		    $url = 'http://'.ltrim($url, '/');
258 258
 		}
259 259
 
260 260
 		$atts = '';
261
-		foreach ( $attributes as $attribute => $value ) {
262
-			$atts .= ' ' . $attribute . '="' . $value . '"';
261
+		foreach ($attributes as $attribute => $value) {
262
+			$atts .= ' '.$attribute.'="'.$value.'"';
263 263
 		}
264 264
 		$text = $text !== null && $text !== '' ? $text : $url;
265
-		return $url !== null && $url !== '' ? '<a itemprop="url" href="' . $url . '"' . $atts . '>' . $text . '</a>'
265
+		return $url !== null && $url !== '' ? '<a itemprop="url" href="'.$url.'"'.$atts.'>'.$text.'</a>'
266 266
 			: '';
267 267
 	}
268 268
 
Please login to merge, or discard this patch.