Completed
Branch BUG-10525-schema-fatal-no-date... (4e3b3b)
by
unknown
15:56 queued 11s
created
core/helpers/EEH_Schema.helper.php 2 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -17,67 +17,67 @@  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
-     */
25
-    public static function add_json_linked_data_for_event(\EE_Event $event)
26
-    {
27
-    	//Check we have a valid datetime for the event
28
-    	if(! $event->primary_datetime() instanceof EE_Datetime) {
29
-    		return;
30
-    	}
31
-
32
-        $template_args = array(
33
-            'event_permalink' => '',
34
-            'event_name' => '',
35
-            'event_description' => '',
36
-            'event_start' => '',
37
-            'event_end' => '',
38
-            'currency' => '',
39
-            'event_tickets' => array(),
40
-            'venue_name' => '',
41
-            'venue_url' => '',
42
-            'venue_locality' => '',
43
-            'venue_region' => '',
44
-            'event_image' => '',
45
-        );
46
-        $template_args['event_permalink'] = $event->get_permalink();
47
-        $template_args['event_name'] = $event->name();
48
-        $template_args['event_description'] = wp_strip_all_tags($event->short_description(200));
49
-        $template_args['event_start'] = $event->primary_datetime()->start_date(DateTime::ATOM);
50
-        $template_args['event_end'] = $event->primary_datetime()->end_date(DateTime::ATOM);
51
-        $template_args['currency'] = EE_Registry::instance()->CFG->currency->code;
52
-        foreach ($event->tickets() as $ticket) {
53
-            $ID = $ticket->ID();
54
-            $template_args['event_tickets'][$ID]['start_date'] = $ticket->start_date(DateTime::ATOM, null);
55
-            $template_args['event_tickets'][$ID]['end_date'] = $ticket->end_date(DateTime::ATOM, null);
56
-            $template_args['event_tickets'][$ID]['price'] = number_format(
57
-                $ticket->price(),
58
-                EE_Registry::instance()->CFG->currency->dec_plc,
59
-                EE_Registry::instance()->CFG->currency->dec_mrk,
60
-                EE_Registry::instance()->CFG->currency->thsnds
61
-            );
62
-        }
63
-        $VNU_ID = espresso_venue_id();
64
-        if ( ! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) {
65
-            $venue = EEH_Venue_View::get_venue($VNU_ID);
66
-            $template_args['venue_name'] = get_the_title($VNU_ID);
67
-            $template_args['venue_url'] = get_permalink($VNU_ID);
68
-            $template_args['venue_locality'] = $venue->city();
69
-            $template_args['venue_region'] = $venue->state_name();
70
-        }
71
-        $template_args['event_image'] = $event->feature_image_url();
72
-        $template_args = apply_filters(
73
-            'FHEE__EEH_Schema__add_json_linked_data_for_event__template_args',
74
-            $template_args,
75
-            $event,
76
-            $VNU_ID
77
-        );
78
-        extract($template_args, EXTR_OVERWRITE);
79
-        include EE_TEMPLATES . 'json_linked_data_for_event.template.php';
80
-    }
20
+	/**
21
+	 * generates JSON-based linked data for an event
22
+	 *
23
+	 * @param \EE_Event $event
24
+	 */
25
+	public static function add_json_linked_data_for_event(\EE_Event $event)
26
+	{
27
+		//Check we have a valid datetime for the event
28
+		if(! $event->primary_datetime() instanceof EE_Datetime) {
29
+			return;
30
+		}
31
+
32
+		$template_args = array(
33
+			'event_permalink' => '',
34
+			'event_name' => '',
35
+			'event_description' => '',
36
+			'event_start' => '',
37
+			'event_end' => '',
38
+			'currency' => '',
39
+			'event_tickets' => array(),
40
+			'venue_name' => '',
41
+			'venue_url' => '',
42
+			'venue_locality' => '',
43
+			'venue_region' => '',
44
+			'event_image' => '',
45
+		);
46
+		$template_args['event_permalink'] = $event->get_permalink();
47
+		$template_args['event_name'] = $event->name();
48
+		$template_args['event_description'] = wp_strip_all_tags($event->short_description(200));
49
+		$template_args['event_start'] = $event->primary_datetime()->start_date(DateTime::ATOM);
50
+		$template_args['event_end'] = $event->primary_datetime()->end_date(DateTime::ATOM);
51
+		$template_args['currency'] = EE_Registry::instance()->CFG->currency->code;
52
+		foreach ($event->tickets() as $ticket) {
53
+			$ID = $ticket->ID();
54
+			$template_args['event_tickets'][$ID]['start_date'] = $ticket->start_date(DateTime::ATOM, null);
55
+			$template_args['event_tickets'][$ID]['end_date'] = $ticket->end_date(DateTime::ATOM, null);
56
+			$template_args['event_tickets'][$ID]['price'] = number_format(
57
+				$ticket->price(),
58
+				EE_Registry::instance()->CFG->currency->dec_plc,
59
+				EE_Registry::instance()->CFG->currency->dec_mrk,
60
+				EE_Registry::instance()->CFG->currency->thsnds
61
+			);
62
+		}
63
+		$VNU_ID = espresso_venue_id();
64
+		if ( ! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) {
65
+			$venue = EEH_Venue_View::get_venue($VNU_ID);
66
+			$template_args['venue_name'] = get_the_title($VNU_ID);
67
+			$template_args['venue_url'] = get_permalink($VNU_ID);
68
+			$template_args['venue_locality'] = $venue->city();
69
+			$template_args['venue_region'] = $venue->state_name();
70
+		}
71
+		$template_args['event_image'] = $event->feature_image_url();
72
+		$template_args = apply_filters(
73
+			'FHEE__EEH_Schema__add_json_linked_data_for_event__template_args',
74
+			$template_args,
75
+			$event,
76
+			$VNU_ID
77
+		);
78
+		extract($template_args, EXTR_OVERWRITE);
79
+		include EE_TEMPLATES . 'json_linked_data_for_event.template.php';
80
+	}
81 81
 
82 82
 
83 83
 	/**
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public static function location( $location = null ) {
93 93
 		return ! empty( $location ) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">'
94
-		                              . $location
95
-		                              . '</div>' : '';
94
+									  . $location
95
+									  . '</div>' : '';
96 96
 	}
97 97
 
98 98
 
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
 	 */
213 213
 	public static function postalCode( EEI_Address $obj_with_address = null ) {
214 214
 		return $obj_with_address->zip() !== null && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">'
215
-		                                                                              . $obj_with_address->zip()
216
-		                                                                              . '</span>' : '';
215
+																					  . $obj_with_address->zip()
216
+																					  . '</span>' : '';
217 217
 	}
218 218
 
219 219
 
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 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
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     public static function add_json_linked_data_for_event(\EE_Event $event)
26 26
     {
27 27
     	//Check we have a valid datetime for the event
28
-    	if(! $event->primary_datetime() instanceof EE_Datetime) {
28
+    	if ( ! $event->primary_datetime() instanceof EE_Datetime) {
29 29
     		return;
30 30
     	}
31 31
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
             $VNU_ID
77 77
         );
78 78
         extract($template_args, EXTR_OVERWRITE);
79
-        include EE_TEMPLATES . 'json_linked_data_for_event.template.php';
79
+        include EE_TEMPLATES.'json_linked_data_for_event.template.php';
80 80
     }
81 81
 
82 82
 
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 	 * @param string $location
90 90
 	 * @return string
91 91
 	 */
92
-	public static function location( $location = null ) {
93
-		return ! empty( $location ) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">'
92
+	public static function location($location = null) {
93
+		return ! empty($location) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">'
94 94
 		                              . $location
95 95
 		                              . '</div>' : '';
96 96
 	}
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 	 * @param string $name
106 106
 	 * @return string
107 107
 	 */
108
-	public static function name( $name = null ) {
109
-		return ! empty( $name ) ? '<span itemprop="name">' . $name . '</span>' : '';
108
+	public static function name($name = null) {
109
+		return ! empty($name) ? '<span itemprop="name">'.$name.'</span>' : '';
110 110
 	}
111 111
 
112 112
 
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
 	 * @param EEI_Address $obj_with_address
120 120
 	 * @return string
121 121
 	 */
122
-	public static function streetAddress( EEI_Address $obj_with_address = null ) {
122
+	public static function streetAddress(EEI_Address $obj_with_address = null) {
123 123
 		return $obj_with_address->address() !== null && $obj_with_address->address() !== ''
124
-			? '<span itemprop="streetAddress">' . $obj_with_address->address() . '</span>' : '';
124
+			? '<span itemprop="streetAddress">'.$obj_with_address->address().'</span>' : '';
125 125
 	}
126 126
 
127 127
 
@@ -134,14 +134,14 @@  discard block
 block discarded – undo
134 134
 	 * @param EEI_Address $obj_with_address
135 135
 	 * @return string
136 136
 	 */
137
-	public static function postOfficeBoxNumber( EEI_Address $obj_with_address = null ) {
137
+	public static function postOfficeBoxNumber(EEI_Address $obj_with_address = null) {
138 138
 		// regex check for some form of PO Box or P.O. Box, etc, etc, etc
139
-		if ( preg_match(
139
+		if (preg_match(
140 140
 			"/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i",
141 141
 			$obj_with_address->address2()
142
-		) ) {
142
+		)) {
143 143
 			return $obj_with_address->address2() !== null && $obj_with_address->address2() !== ''
144
-				? '<span itemprop="postOfficeBoxNumber">' . $obj_with_address->address2() . '</span>' : '';
144
+				? '<span itemprop="postOfficeBoxNumber">'.$obj_with_address->address2().'</span>' : '';
145 145
 		} else {
146 146
 			return $obj_with_address->address2();
147 147
 		}
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
 	 * @param EEI_Address $obj_with_address
158 158
 	 * @return string
159 159
 	 */
160
-	public static function addressLocality( EEI_Address $obj_with_address = null ) {
160
+	public static function addressLocality(EEI_Address $obj_with_address = null) {
161 161
 		return $obj_with_address->city() !== null && $obj_with_address->city() !== ''
162
-			? '<span itemprop="addressLocality">' . $obj_with_address->city() . '</span>' : '';
162
+			? '<span itemprop="addressLocality">'.$obj_with_address->city().'</span>' : '';
163 163
 	}
164 164
 
165 165
 
@@ -172,10 +172,10 @@  discard block
 block discarded – undo
172 172
 	 * @param EEI_Address $obj_with_address
173 173
 	 * @return string
174 174
 	 */
175
-	public static function addressRegion( EEI_Address $obj_with_address = null ) {
175
+	public static function addressRegion(EEI_Address $obj_with_address = null) {
176 176
 		$state = $obj_with_address->state_name();
177
-		if ( ! empty( $state ) ) {
178
-			return '<span itemprop="addressRegion">' . $state . '</span>';
177
+		if ( ! empty($state)) {
178
+			return '<span itemprop="addressRegion">'.$state.'</span>';
179 179
 		} else {
180 180
 			return '';
181 181
 		}
@@ -191,10 +191,10 @@  discard block
 block discarded – undo
191 191
 	 * @param EEI_Address $obj_with_address
192 192
 	 * @return string
193 193
 	 */
194
-	public static function addressCountry( EEI_Address $obj_with_address = null ) {
194
+	public static function addressCountry(EEI_Address $obj_with_address = null) {
195 195
 		$country = $obj_with_address->country_name();
196
-		if ( ! empty( $country ) ) {
197
-			return '<span itemprop="addressCountry">' . $country . '</span>';
196
+		if ( ! empty($country)) {
197
+			return '<span itemprop="addressCountry">'.$country.'</span>';
198 198
 		} else {
199 199
 			return '';
200 200
 		}
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 * @param EEI_Address $obj_with_address
211 211
 	 * @return string
212 212
 	 */
213
-	public static function postalCode( EEI_Address $obj_with_address = null ) {
213
+	public static function postalCode(EEI_Address $obj_with_address = null) {
214 214
 		return $obj_with_address->zip() !== null && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">'
215 215
 		                                                                              . $obj_with_address->zip()
216 216
 		                                                                              . '</span>' : '';
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 	 * @param string $phone_nmbr
227 227
 	 * @return string
228 228
 	 */
229
-	public static function telephone( $phone_nmbr = null ) {
230
-		return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">' . $phone_nmbr . '</span>'
229
+	public static function telephone($phone_nmbr = null) {
230
+		return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">'.$phone_nmbr.'</span>'
231 231
 			: '';
232 232
 	}
233 233
 
@@ -243,13 +243,13 @@  discard block
 block discarded – undo
243 243
 	 * @param array  $attributes - array of additional link attributes in  attribute_name => value pairs. ie: array( 'title' => 'click here', 'class' => 'link-class' )
244 244
 	 * @return string (link)
245 245
 	 */
246
-	public static function url( $url = null, $text = null, $attributes = array() ) {
246
+	public static function url($url = null, $text = null, $attributes = array()) {
247 247
 		$atts = '';
248
-		foreach ( $attributes as $attribute => $value ) {
249
-			$atts .= ' ' . $attribute . '="' . $value . '"';
248
+		foreach ($attributes as $attribute => $value) {
249
+			$atts .= ' '.$attribute.'="'.$value.'"';
250 250
 		}
251 251
 		$text = $text !== null && $text !== '' ? $text : $url;
252
-		return $url !== null && $url !== '' ? '<a itemprop="url" href="' . $url . '"' . $atts . '>' . $text . '</a>'
252
+		return $url !== null && $url !== '' ? '<a itemprop="url" href="'.$url.'"'.$atts.'>'.$text.'</a>'
253 253
 			: '';
254 254
 	}
255 255
 
Please login to merge, or discard this patch.