@@ -12,274 +12,274 @@  | 
                                                    ||
| 12 | 12 |  { | 
                                                        
| 13 | 13 | |
| 14 | 14 | |
| 15 | - /**  | 
                                                        |
| 16 | - * generates JSON-based linked data for an event  | 
                                                        |
| 17 | - *  | 
                                                        |
| 18 | - * @param EE_Event $event  | 
                                                        |
| 19 | - * @throws EE_Error  | 
                                                        |
| 20 | - */  | 
                                                        |
| 21 | - public static function add_json_linked_data_for_event(EE_Event $event)  | 
                                                        |
| 22 | -    { | 
                                                        |
| 23 | - // Check we have a valid datetime for the event  | 
                                                        |
| 24 | -        if (! $event->primary_datetime() instanceof EE_Datetime) { | 
                                                        |
| 25 | - return;  | 
                                                        |
| 26 | - }  | 
                                                        |
| 27 | -  | 
                                                        |
| 28 | - $template_args = array(  | 
                                                        |
| 29 | - 'event_permalink' => '',  | 
                                                        |
| 30 | - 'event_name' => '',  | 
                                                        |
| 31 | - 'event_description' => '',  | 
                                                        |
| 32 | - 'event_start' => '',  | 
                                                        |
| 33 | - 'event_end' => '',  | 
                                                        |
| 34 | - 'currency' => '',  | 
                                                        |
| 35 | - 'event_tickets' => array(),  | 
                                                        |
| 36 | - 'venue_name' => '',  | 
                                                        |
| 37 | - 'venue_url' => '',  | 
                                                        |
| 38 | - 'venue_locality' => '',  | 
                                                        |
| 39 | - 'venue_region' => '',  | 
                                                        |
| 40 | - 'event_image' => '',  | 
                                                        |
| 41 | - );  | 
                                                        |
| 42 | - $template_args['event_permalink'] = $event->get_permalink();  | 
                                                        |
| 43 | - $template_args['event_name'] = $event->name();  | 
                                                        |
| 44 | - $template_args['event_description'] = wp_strip_all_tags($event->short_description(200));  | 
                                                        |
| 45 | - // clone datetime so that date formats don't override those for the original datetime  | 
                                                        |
| 46 | - $primary_datetime = clone $event->primary_datetime();  | 
                                                        |
| 47 | - $template_args['event_start'] = $primary_datetime->start_date(DateTime::ATOM);  | 
                                                        |
| 48 | - $template_args['event_end'] = $primary_datetime->end_date(DateTime::ATOM);  | 
                                                        |
| 49 | - unset($primary_datetime);  | 
                                                        |
| 50 | - $template_args['currency'] = EE_Registry::instance()->CFG->currency->code;  | 
                                                        |
| 51 | -        foreach ($event->tickets() as $original_ticket) { | 
                                                        |
| 52 | - // clone tickets so that date formats don't override those for the original ticket  | 
                                                        |
| 53 | - $ticket= clone $original_ticket;  | 
                                                        |
| 54 | - $ID = $ticket->ID();  | 
                                                        |
| 55 | - $template_args['event_tickets'][ $ID ]['start_date'] = $ticket->start_date(DateTime::ATOM, null);  | 
                                                        |
| 56 | - $template_args['event_tickets'][ $ID ]['end_date'] = $ticket->end_date(DateTime::ATOM, null);  | 
                                                        |
| 57 | - $template_args['event_tickets'][ $ID ]['price'] = number_format(  | 
                                                        |
| 58 | - $ticket->price(),  | 
                                                        |
| 59 | - EE_Registry::instance()->CFG->currency->dec_plc,  | 
                                                        |
| 60 | - EE_Registry::instance()->CFG->currency->dec_mrk,  | 
                                                        |
| 61 | - EE_Registry::instance()->CFG->currency->thsnds  | 
                                                        |
| 62 | - );  | 
                                                        |
| 63 | -            switch ($ticket->ticket_status()) { | 
                                                        |
| 64 | - case 'TKO':  | 
                                                        |
| 65 | - $availability = 'InStock';  | 
                                                        |
| 66 | - break;  | 
                                                        |
| 67 | - case 'TKS':  | 
                                                        |
| 68 | - $availability = 'SoldOut';  | 
                                                        |
| 69 | - break;  | 
                                                        |
| 70 | - default:  | 
                                                        |
| 71 | - $availability = null;  | 
                                                        |
| 72 | - break;  | 
                                                        |
| 73 | - }  | 
                                                        |
| 74 | - $template_args['event_tickets'][ $ID ]['availability'] = $availability;  | 
                                                        |
| 75 | - unset($ticket);  | 
                                                        |
| 76 | - }  | 
                                                        |
| 77 | - $VNU_ID = espresso_venue_id();  | 
                                                        |
| 78 | -        if (! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) { | 
                                                        |
| 79 | - $venue = EEH_Venue_View::get_venue($VNU_ID);  | 
                                                        |
| 80 | - $template_args['venue_name'] = get_the_title($VNU_ID);  | 
                                                        |
| 81 | - $template_args['venue_url'] = get_permalink($VNU_ID);  | 
                                                        |
| 82 | - $template_args['venue_locality'] = $venue->city();  | 
                                                        |
| 83 | - $template_args['venue_region'] = $venue->state_name();  | 
                                                        |
| 84 | - }  | 
                                                        |
| 85 | - $template_args['event_image'] = $event->feature_image_url();  | 
                                                        |
| 86 | - $template_args = apply_filters(  | 
                                                        |
| 87 | - 'FHEE__EEH_Schema__add_json_linked_data_for_event__template_args',  | 
                                                        |
| 88 | - $template_args,  | 
                                                        |
| 89 | - $event,  | 
                                                        |
| 90 | - $VNU_ID  | 
                                                        |
| 91 | - );  | 
                                                        |
| 92 | - extract($template_args, EXTR_OVERWRITE);  | 
                                                        |
| 93 | - include EE_TEMPLATES . 'json_linked_data_for_event.template.php';  | 
                                                        |
| 94 | - }  | 
                                                        |
| 95 | -  | 
                                                        |
| 96 | -  | 
                                                        |
| 97 | - /**  | 
                                                        |
| 98 | - * location  | 
                                                        |
| 99 | - * The location of the event, organization or action.  | 
                                                        |
| 100 | - * Should include the Venue name AND schema formatted address info  | 
                                                        |
| 101 | - *  | 
                                                        |
| 102 | - * @access public  | 
                                                        |
| 103 | - * @param string $location  | 
                                                        |
| 104 | - * @return string  | 
                                                        |
| 105 | - */  | 
                                                        |
| 106 | - public static function location($location = null)  | 
                                                        |
| 107 | -    { | 
                                                        |
| 108 | - return ! empty($location) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">'  | 
                                                        |
| 109 | - . $location  | 
                                                        |
| 110 | - . '</div>' : '';  | 
                                                        |
| 111 | - }  | 
                                                        |
| 112 | -  | 
                                                        |
| 113 | -  | 
                                                        |
| 114 | -  | 
                                                        |
| 115 | - /**  | 
                                                        |
| 116 | - * name  | 
                                                        |
| 117 | - * The name of the Event or Venue.  | 
                                                        |
| 118 | - *  | 
                                                        |
| 119 | - * @access public  | 
                                                        |
| 120 | - * @param string $name  | 
                                                        |
| 121 | - * @return string  | 
                                                        |
| 122 | - */  | 
                                                        |
| 123 | - public static function name($name = null)  | 
                                                        |
| 124 | -    { | 
                                                        |
| 125 | - return ! empty($name) ? '<span itemprop="name">' . $name . '</span>' : '';  | 
                                                        |
| 126 | - }  | 
                                                        |
| 127 | -  | 
                                                        |
| 128 | -  | 
                                                        |
| 129 | -  | 
                                                        |
| 130 | - /**  | 
                                                        |
| 131 | - * streetAddress  | 
                                                        |
| 132 | - * The street address. For example, 1600 Amphitheatre Pkwy.  | 
                                                        |
| 133 | - *  | 
                                                        |
| 134 | - * @access public  | 
                                                        |
| 135 | - * @param EEI_Address $obj_with_address  | 
                                                        |
| 136 | - * @return string  | 
                                                        |
| 137 | - */  | 
                                                        |
| 138 | - public static function streetAddress(EEI_Address $obj_with_address = null)  | 
                                                        |
| 139 | -    { | 
                                                        |
| 140 | - return $obj_with_address->address() !== null && $obj_with_address->address() !== ''  | 
                                                        |
| 141 | - ? '<span itemprop="streetAddress">' . $obj_with_address->address() . '</span>' : '';  | 
                                                        |
| 142 | - }  | 
                                                        |
| 143 | -  | 
                                                        |
| 144 | -  | 
                                                        |
| 145 | -  | 
                                                        |
| 146 | - /**  | 
                                                        |
| 147 | - * postOfficeBoxNumber  | 
                                                        |
| 148 | - * The post office box number for PO box addresses.  | 
                                                        |
| 149 | - *  | 
                                                        |
| 150 | - * @access public  | 
                                                        |
| 151 | - * @param EEI_Address $obj_with_address  | 
                                                        |
| 152 | - * @return string  | 
                                                        |
| 153 | - */  | 
                                                        |
| 154 | - public static function postOfficeBoxNumber(EEI_Address $obj_with_address = null)  | 
                                                        |
| 155 | -    { | 
                                                        |
| 156 | - // regex check for some form of PO Box or P.O. Box, etc, etc, etc  | 
                                                        |
| 157 | - if (preg_match(  | 
                                                        |
| 158 | - "/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i",  | 
                                                        |
| 159 | - $obj_with_address->address2()  | 
                                                        |
| 160 | -        ) ) { | 
                                                        |
| 161 | - return $obj_with_address->address2() !== null && $obj_with_address->address2() !== ''  | 
                                                        |
| 162 | - ? '<span itemprop="postOfficeBoxNumber">' . $obj_with_address->address2() . '</span>' : '';  | 
                                                        |
| 163 | -        } else { | 
                                                        |
| 164 | - return $obj_with_address->address2();  | 
                                                        |
| 165 | - }  | 
                                                        |
| 166 | - }  | 
                                                        |
| 167 | -  | 
                                                        |
| 168 | -  | 
                                                        |
| 169 | -  | 
                                                        |
| 170 | - /**  | 
                                                        |
| 171 | - * addressLocality  | 
                                                        |
| 172 | - * The locality (city, town, etc). For example, Mountain View.  | 
                                                        |
| 173 | - *  | 
                                                        |
| 174 | - * @access public  | 
                                                        |
| 175 | - * @param EEI_Address $obj_with_address  | 
                                                        |
| 176 | - * @return string  | 
                                                        |
| 177 | - */  | 
                                                        |
| 178 | - public static function addressLocality(EEI_Address $obj_with_address = null)  | 
                                                        |
| 179 | -    { | 
                                                        |
| 180 | - return $obj_with_address->city() !== null && $obj_with_address->city() !== ''  | 
                                                        |
| 181 | - ? '<span itemprop="addressLocality">' . $obj_with_address->city() . '</span>' : '';  | 
                                                        |
| 182 | - }  | 
                                                        |
| 183 | -  | 
                                                        |
| 184 | -  | 
                                                        |
| 185 | -  | 
                                                        |
| 186 | - /**  | 
                                                        |
| 187 | - * addressRegion  | 
                                                        |
| 188 | - * The region (state, province, etc). For example, CA.  | 
                                                        |
| 189 | - *  | 
                                                        |
| 190 | - * @access public  | 
                                                        |
| 191 | - * @param EEI_Address $obj_with_address  | 
                                                        |
| 192 | - * @return string  | 
                                                        |
| 193 | - */  | 
                                                        |
| 194 | - public static function addressRegion(EEI_Address $obj_with_address = null)  | 
                                                        |
| 195 | -    { | 
                                                        |
| 196 | - $state = $obj_with_address->state_name();  | 
                                                        |
| 197 | -        if (! empty($state)) { | 
                                                        |
| 198 | - return '<span itemprop="addressRegion">' . $state . '</span>';  | 
                                                        |
| 199 | -        } else { | 
                                                        |
| 200 | - return '';  | 
                                                        |
| 201 | - }  | 
                                                        |
| 202 | - }  | 
                                                        |
| 203 | -  | 
                                                        |
| 204 | -  | 
                                                        |
| 205 | -  | 
                                                        |
| 206 | - /**  | 
                                                        |
| 207 | - * addressCountry  | 
                                                        |
| 208 | - * The country. For example, USA. You can also provide the two-letter ISO 3166-1 alpha-2 country code.  | 
                                                        |
| 209 | - *  | 
                                                        |
| 210 | - * @access public  | 
                                                        |
| 211 | - * @param EEI_Address $obj_with_address  | 
                                                        |
| 212 | - * @return string  | 
                                                        |
| 213 | - */  | 
                                                        |
| 214 | - public static function addressCountry(EEI_Address $obj_with_address = null)  | 
                                                        |
| 215 | -    { | 
                                                        |
| 216 | - $country = $obj_with_address->country_name();  | 
                                                        |
| 217 | -        if (! empty($country)) { | 
                                                        |
| 218 | - return '<span itemprop="addressCountry">' . $country . '</span>';  | 
                                                        |
| 219 | -        } else { | 
                                                        |
| 220 | - return '';  | 
                                                        |
| 221 | - }  | 
                                                        |
| 222 | - }  | 
                                                        |
| 223 | -  | 
                                                        |
| 224 | -  | 
                                                        |
| 225 | -  | 
                                                        |
| 226 | - /**  | 
                                                        |
| 227 | - * postalCode  | 
                                                        |
| 228 | - * The postal code. For example, 94043.  | 
                                                        |
| 229 | - *  | 
                                                        |
| 230 | - * @access public  | 
                                                        |
| 231 | - * @param EEI_Address $obj_with_address  | 
                                                        |
| 232 | - * @return string  | 
                                                        |
| 233 | - */  | 
                                                        |
| 234 | - public static function postalCode(EEI_Address $obj_with_address = null)  | 
                                                        |
| 235 | -    { | 
                                                        |
| 236 | - return $obj_with_address->zip() !== null && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">'  | 
                                                        |
| 237 | - . $obj_with_address->zip()  | 
                                                        |
| 238 | - . '</span>' : '';  | 
                                                        |
| 239 | - }  | 
                                                        |
| 240 | -  | 
                                                        |
| 241 | -  | 
                                                        |
| 242 | -  | 
                                                        |
| 243 | - /**  | 
                                                        |
| 244 | - * telephone  | 
                                                        |
| 245 | - * The telephone number.  | 
                                                        |
| 246 | - *  | 
                                                        |
| 247 | - * @access public  | 
                                                        |
| 248 | - * @param string $phone_nmbr  | 
                                                        |
| 249 | - * @return string  | 
                                                        |
| 250 | - */  | 
                                                        |
| 251 | - public static function telephone($phone_nmbr = null)  | 
                                                        |
| 252 | -    { | 
                                                        |
| 253 | - return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">' . $phone_nmbr . '</span>'  | 
                                                        |
| 254 | - : '';  | 
                                                        |
| 255 | - }  | 
                                                        |
| 256 | -  | 
                                                        |
| 257 | -  | 
                                                        |
| 258 | -  | 
                                                        |
| 259 | - /**  | 
                                                        |
| 260 | - * URL  | 
                                                        |
| 261 | - * URL of the item as a clickable link  | 
                                                        |
| 262 | - *  | 
                                                        |
| 263 | - * @access public  | 
                                                        |
| 264 | - * @param string $url - the URL that the link will resolve to  | 
                                                        |
| 265 | - * @param string $text - the text that will be used for the visible link  | 
                                                        |
| 266 | - * @param array $attributes - array of additional link attributes in attribute_name => value pairs. ie: array( 'title' => 'click here', 'class' => 'link-class' )  | 
                                                        |
| 267 | - * @return string (link)  | 
                                                        |
| 268 | - */  | 
                                                        |
| 269 | - public static function url($url = null, $text = null, $attributes = array())  | 
                                                        |
| 270 | -    { | 
                                                        |
| 271 | - // Check the URL includes a scheme  | 
                                                        |
| 272 | - $parsed_url = parse_url($url);  | 
                                                        |
| 273 | -        if (empty($parsed_url['scheme'])) { | 
                                                        |
| 274 | - $url = 'http://' . ltrim($url, '/');  | 
                                                        |
| 275 | - }  | 
                                                        |
| 276 | -  | 
                                                        |
| 277 | - $atts = '';  | 
                                                        |
| 278 | -        foreach ($attributes as $attribute => $value) { | 
                                                        |
| 279 | - $atts .= ' ' . $attribute . '="' . $value . '"';  | 
                                                        |
| 280 | - }  | 
                                                        |
| 281 | - $text = $text !== null && $text !== '' ? $text : $url;  | 
                                                        |
| 282 | - return $url !== null && $url !== '' ? '<a itemprop="url" href="' . $url . '"' . $atts . '>' . $text . '</a>'  | 
                                                        |
| 283 | - : '';  | 
                                                        |
| 284 | - }  | 
                                                        |
| 15 | + /**  | 
                                                        |
| 16 | + * generates JSON-based linked data for an event  | 
                                                        |
| 17 | + *  | 
                                                        |
| 18 | + * @param EE_Event $event  | 
                                                        |
| 19 | + * @throws EE_Error  | 
                                                        |
| 20 | + */  | 
                                                        |
| 21 | + public static function add_json_linked_data_for_event(EE_Event $event)  | 
                                                        |
| 22 | +	{ | 
                                                        |
| 23 | + // Check we have a valid datetime for the event  | 
                                                        |
| 24 | +		if (! $event->primary_datetime() instanceof EE_Datetime) { | 
                                                        |
| 25 | + return;  | 
                                                        |
| 26 | + }  | 
                                                        |
| 27 | +  | 
                                                        |
| 28 | + $template_args = array(  | 
                                                        |
| 29 | + 'event_permalink' => '',  | 
                                                        |
| 30 | + 'event_name' => '',  | 
                                                        |
| 31 | + 'event_description' => '',  | 
                                                        |
| 32 | + 'event_start' => '',  | 
                                                        |
| 33 | + 'event_end' => '',  | 
                                                        |
| 34 | + 'currency' => '',  | 
                                                        |
| 35 | + 'event_tickets' => array(),  | 
                                                        |
| 36 | + 'venue_name' => '',  | 
                                                        |
| 37 | + 'venue_url' => '',  | 
                                                        |
| 38 | + 'venue_locality' => '',  | 
                                                        |
| 39 | + 'venue_region' => '',  | 
                                                        |
| 40 | + 'event_image' => '',  | 
                                                        |
| 41 | + );  | 
                                                        |
| 42 | + $template_args['event_permalink'] = $event->get_permalink();  | 
                                                        |
| 43 | + $template_args['event_name'] = $event->name();  | 
                                                        |
| 44 | + $template_args['event_description'] = wp_strip_all_tags($event->short_description(200));  | 
                                                        |
| 45 | + // clone datetime so that date formats don't override those for the original datetime  | 
                                                        |
| 46 | + $primary_datetime = clone $event->primary_datetime();  | 
                                                        |
| 47 | + $template_args['event_start'] = $primary_datetime->start_date(DateTime::ATOM);  | 
                                                        |
| 48 | + $template_args['event_end'] = $primary_datetime->end_date(DateTime::ATOM);  | 
                                                        |
| 49 | + unset($primary_datetime);  | 
                                                        |
| 50 | + $template_args['currency'] = EE_Registry::instance()->CFG->currency->code;  | 
                                                        |
| 51 | +		foreach ($event->tickets() as $original_ticket) { | 
                                                        |
| 52 | + // clone tickets so that date formats don't override those for the original ticket  | 
                                                        |
| 53 | + $ticket= clone $original_ticket;  | 
                                                        |
| 54 | + $ID = $ticket->ID();  | 
                                                        |
| 55 | + $template_args['event_tickets'][ $ID ]['start_date'] = $ticket->start_date(DateTime::ATOM, null);  | 
                                                        |
| 56 | + $template_args['event_tickets'][ $ID ]['end_date'] = $ticket->end_date(DateTime::ATOM, null);  | 
                                                        |
| 57 | + $template_args['event_tickets'][ $ID ]['price'] = number_format(  | 
                                                        |
| 58 | + $ticket->price(),  | 
                                                        |
| 59 | + EE_Registry::instance()->CFG->currency->dec_plc,  | 
                                                        |
| 60 | + EE_Registry::instance()->CFG->currency->dec_mrk,  | 
                                                        |
| 61 | + EE_Registry::instance()->CFG->currency->thsnds  | 
                                                        |
| 62 | + );  | 
                                                        |
| 63 | +			switch ($ticket->ticket_status()) { | 
                                                        |
| 64 | + case 'TKO':  | 
                                                        |
| 65 | + $availability = 'InStock';  | 
                                                        |
| 66 | + break;  | 
                                                        |
| 67 | + case 'TKS':  | 
                                                        |
| 68 | + $availability = 'SoldOut';  | 
                                                        |
| 69 | + break;  | 
                                                        |
| 70 | + default:  | 
                                                        |
| 71 | + $availability = null;  | 
                                                        |
| 72 | + break;  | 
                                                        |
| 73 | + }  | 
                                                        |
| 74 | + $template_args['event_tickets'][ $ID ]['availability'] = $availability;  | 
                                                        |
| 75 | + unset($ticket);  | 
                                                        |
| 76 | + }  | 
                                                        |
| 77 | + $VNU_ID = espresso_venue_id();  | 
                                                        |
| 78 | +		if (! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) { | 
                                                        |
| 79 | + $venue = EEH_Venue_View::get_venue($VNU_ID);  | 
                                                        |
| 80 | + $template_args['venue_name'] = get_the_title($VNU_ID);  | 
                                                        |
| 81 | + $template_args['venue_url'] = get_permalink($VNU_ID);  | 
                                                        |
| 82 | + $template_args['venue_locality'] = $venue->city();  | 
                                                        |
| 83 | + $template_args['venue_region'] = $venue->state_name();  | 
                                                        |
| 84 | + }  | 
                                                        |
| 85 | + $template_args['event_image'] = $event->feature_image_url();  | 
                                                        |
| 86 | + $template_args = apply_filters(  | 
                                                        |
| 87 | + 'FHEE__EEH_Schema__add_json_linked_data_for_event__template_args',  | 
                                                        |
| 88 | + $template_args,  | 
                                                        |
| 89 | + $event,  | 
                                                        |
| 90 | + $VNU_ID  | 
                                                        |
| 91 | + );  | 
                                                        |
| 92 | + extract($template_args, EXTR_OVERWRITE);  | 
                                                        |
| 93 | + include EE_TEMPLATES . 'json_linked_data_for_event.template.php';  | 
                                                        |
| 94 | + }  | 
                                                        |
| 95 | +  | 
                                                        |
| 96 | +  | 
                                                        |
| 97 | + /**  | 
                                                        |
| 98 | + * location  | 
                                                        |
| 99 | + * The location of the event, organization or action.  | 
                                                        |
| 100 | + * Should include the Venue name AND schema formatted address info  | 
                                                        |
| 101 | + *  | 
                                                        |
| 102 | + * @access public  | 
                                                        |
| 103 | + * @param string $location  | 
                                                        |
| 104 | + * @return string  | 
                                                        |
| 105 | + */  | 
                                                        |
| 106 | + public static function location($location = null)  | 
                                                        |
| 107 | +	{ | 
                                                        |
| 108 | + return ! empty($location) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">'  | 
                                                        |
| 109 | + . $location  | 
                                                        |
| 110 | + . '</div>' : '';  | 
                                                        |
| 111 | + }  | 
                                                        |
| 112 | +  | 
                                                        |
| 113 | +  | 
                                                        |
| 114 | +  | 
                                                        |
| 115 | + /**  | 
                                                        |
| 116 | + * name  | 
                                                        |
| 117 | + * The name of the Event or Venue.  | 
                                                        |
| 118 | + *  | 
                                                        |
| 119 | + * @access public  | 
                                                        |
| 120 | + * @param string $name  | 
                                                        |
| 121 | + * @return string  | 
                                                        |
| 122 | + */  | 
                                                        |
| 123 | + public static function name($name = null)  | 
                                                        |
| 124 | +	{ | 
                                                        |
| 125 | + return ! empty($name) ? '<span itemprop="name">' . $name . '</span>' : '';  | 
                                                        |
| 126 | + }  | 
                                                        |
| 127 | +  | 
                                                        |
| 128 | +  | 
                                                        |
| 129 | +  | 
                                                        |
| 130 | + /**  | 
                                                        |
| 131 | + * streetAddress  | 
                                                        |
| 132 | + * The street address. For example, 1600 Amphitheatre Pkwy.  | 
                                                        |
| 133 | + *  | 
                                                        |
| 134 | + * @access public  | 
                                                        |
| 135 | + * @param EEI_Address $obj_with_address  | 
                                                        |
| 136 | + * @return string  | 
                                                        |
| 137 | + */  | 
                                                        |
| 138 | + public static function streetAddress(EEI_Address $obj_with_address = null)  | 
                                                        |
| 139 | +	{ | 
                                                        |
| 140 | + return $obj_with_address->address() !== null && $obj_with_address->address() !== ''  | 
                                                        |
| 141 | + ? '<span itemprop="streetAddress">' . $obj_with_address->address() . '</span>' : '';  | 
                                                        |
| 142 | + }  | 
                                                        |
| 143 | +  | 
                                                        |
| 144 | +  | 
                                                        |
| 145 | +  | 
                                                        |
| 146 | + /**  | 
                                                        |
| 147 | + * postOfficeBoxNumber  | 
                                                        |
| 148 | + * The post office box number for PO box addresses.  | 
                                                        |
| 149 | + *  | 
                                                        |
| 150 | + * @access public  | 
                                                        |
| 151 | + * @param EEI_Address $obj_with_address  | 
                                                        |
| 152 | + * @return string  | 
                                                        |
| 153 | + */  | 
                                                        |
| 154 | + public static function postOfficeBoxNumber(EEI_Address $obj_with_address = null)  | 
                                                        |
| 155 | +	{ | 
                                                        |
| 156 | + // regex check for some form of PO Box or P.O. Box, etc, etc, etc  | 
                                                        |
| 157 | + if (preg_match(  | 
                                                        |
| 158 | + "/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i",  | 
                                                        |
| 159 | + $obj_with_address->address2()  | 
                                                        |
| 160 | +		) ) { | 
                                                        |
| 161 | + return $obj_with_address->address2() !== null && $obj_with_address->address2() !== ''  | 
                                                        |
| 162 | + ? '<span itemprop="postOfficeBoxNumber">' . $obj_with_address->address2() . '</span>' : '';  | 
                                                        |
| 163 | +		} else { | 
                                                        |
| 164 | + return $obj_with_address->address2();  | 
                                                        |
| 165 | + }  | 
                                                        |
| 166 | + }  | 
                                                        |
| 167 | +  | 
                                                        |
| 168 | +  | 
                                                        |
| 169 | +  | 
                                                        |
| 170 | + /**  | 
                                                        |
| 171 | + * addressLocality  | 
                                                        |
| 172 | + * The locality (city, town, etc). For example, Mountain View.  | 
                                                        |
| 173 | + *  | 
                                                        |
| 174 | + * @access public  | 
                                                        |
| 175 | + * @param EEI_Address $obj_with_address  | 
                                                        |
| 176 | + * @return string  | 
                                                        |
| 177 | + */  | 
                                                        |
| 178 | + public static function addressLocality(EEI_Address $obj_with_address = null)  | 
                                                        |
| 179 | +	{ | 
                                                        |
| 180 | + return $obj_with_address->city() !== null && $obj_with_address->city() !== ''  | 
                                                        |
| 181 | + ? '<span itemprop="addressLocality">' . $obj_with_address->city() . '</span>' : '';  | 
                                                        |
| 182 | + }  | 
                                                        |
| 183 | +  | 
                                                        |
| 184 | +  | 
                                                        |
| 185 | +  | 
                                                        |
| 186 | + /**  | 
                                                        |
| 187 | + * addressRegion  | 
                                                        |
| 188 | + * The region (state, province, etc). For example, CA.  | 
                                                        |
| 189 | + *  | 
                                                        |
| 190 | + * @access public  | 
                                                        |
| 191 | + * @param EEI_Address $obj_with_address  | 
                                                        |
| 192 | + * @return string  | 
                                                        |
| 193 | + */  | 
                                                        |
| 194 | + public static function addressRegion(EEI_Address $obj_with_address = null)  | 
                                                        |
| 195 | +	{ | 
                                                        |
| 196 | + $state = $obj_with_address->state_name();  | 
                                                        |
| 197 | +		if (! empty($state)) { | 
                                                        |
| 198 | + return '<span itemprop="addressRegion">' . $state . '</span>';  | 
                                                        |
| 199 | +		} else { | 
                                                        |
| 200 | + return '';  | 
                                                        |
| 201 | + }  | 
                                                        |
| 202 | + }  | 
                                                        |
| 203 | +  | 
                                                        |
| 204 | +  | 
                                                        |
| 205 | +  | 
                                                        |
| 206 | + /**  | 
                                                        |
| 207 | + * addressCountry  | 
                                                        |
| 208 | + * The country. For example, USA. You can also provide the two-letter ISO 3166-1 alpha-2 country code.  | 
                                                        |
| 209 | + *  | 
                                                        |
| 210 | + * @access public  | 
                                                        |
| 211 | + * @param EEI_Address $obj_with_address  | 
                                                        |
| 212 | + * @return string  | 
                                                        |
| 213 | + */  | 
                                                        |
| 214 | + public static function addressCountry(EEI_Address $obj_with_address = null)  | 
                                                        |
| 215 | +	{ | 
                                                        |
| 216 | + $country = $obj_with_address->country_name();  | 
                                                        |
| 217 | +		if (! empty($country)) { | 
                                                        |
| 218 | + return '<span itemprop="addressCountry">' . $country . '</span>';  | 
                                                        |
| 219 | +		} else { | 
                                                        |
| 220 | + return '';  | 
                                                        |
| 221 | + }  | 
                                                        |
| 222 | + }  | 
                                                        |
| 223 | +  | 
                                                        |
| 224 | +  | 
                                                        |
| 225 | +  | 
                                                        |
| 226 | + /**  | 
                                                        |
| 227 | + * postalCode  | 
                                                        |
| 228 | + * The postal code. For example, 94043.  | 
                                                        |
| 229 | + *  | 
                                                        |
| 230 | + * @access public  | 
                                                        |
| 231 | + * @param EEI_Address $obj_with_address  | 
                                                        |
| 232 | + * @return string  | 
                                                        |
| 233 | + */  | 
                                                        |
| 234 | + public static function postalCode(EEI_Address $obj_with_address = null)  | 
                                                        |
| 235 | +	{ | 
                                                        |
| 236 | + return $obj_with_address->zip() !== null && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">'  | 
                                                        |
| 237 | + . $obj_with_address->zip()  | 
                                                        |
| 238 | + . '</span>' : '';  | 
                                                        |
| 239 | + }  | 
                                                        |
| 240 | +  | 
                                                        |
| 241 | +  | 
                                                        |
| 242 | +  | 
                                                        |
| 243 | + /**  | 
                                                        |
| 244 | + * telephone  | 
                                                        |
| 245 | + * The telephone number.  | 
                                                        |
| 246 | + *  | 
                                                        |
| 247 | + * @access public  | 
                                                        |
| 248 | + * @param string $phone_nmbr  | 
                                                        |
| 249 | + * @return string  | 
                                                        |
| 250 | + */  | 
                                                        |
| 251 | + public static function telephone($phone_nmbr = null)  | 
                                                        |
| 252 | +	{ | 
                                                        |
| 253 | + return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">' . $phone_nmbr . '</span>'  | 
                                                        |
| 254 | + : '';  | 
                                                        |
| 255 | + }  | 
                                                        |
| 256 | +  | 
                                                        |
| 257 | +  | 
                                                        |
| 258 | +  | 
                                                        |
| 259 | + /**  | 
                                                        |
| 260 | + * URL  | 
                                                        |
| 261 | + * URL of the item as a clickable link  | 
                                                        |
| 262 | + *  | 
                                                        |
| 263 | + * @access public  | 
                                                        |
| 264 | + * @param string $url - the URL that the link will resolve to  | 
                                                        |
| 265 | + * @param string $text - the text that will be used for the visible link  | 
                                                        |
| 266 | + * @param array $attributes - array of additional link attributes in attribute_name => value pairs. ie: array( 'title' => 'click here', 'class' => 'link-class' )  | 
                                                        |
| 267 | + * @return string (link)  | 
                                                        |
| 268 | + */  | 
                                                        |
| 269 | + public static function url($url = null, $text = null, $attributes = array())  | 
                                                        |
| 270 | +	{ | 
                                                        |
| 271 | + // Check the URL includes a scheme  | 
                                                        |
| 272 | + $parsed_url = parse_url($url);  | 
                                                        |
| 273 | +		if (empty($parsed_url['scheme'])) { | 
                                                        |
| 274 | + $url = 'http://' . ltrim($url, '/');  | 
                                                        |
| 275 | + }  | 
                                                        |
| 276 | +  | 
                                                        |
| 277 | + $atts = '';  | 
                                                        |
| 278 | +		foreach ($attributes as $attribute => $value) { | 
                                                        |
| 279 | + $atts .= ' ' . $attribute . '="' . $value . '"';  | 
                                                        |
| 280 | + }  | 
                                                        |
| 281 | + $text = $text !== null && $text !== '' ? $text : $url;  | 
                                                        |
| 282 | + return $url !== null && $url !== '' ? '<a itemprop="url" href="' . $url . '"' . $atts . '>' . $text . '</a>'  | 
                                                        |
| 283 | + : '';  | 
                                                        |
| 284 | + }  | 
                                                        |
| 285 | 285 | }  | 
                                                        
@@ -21,7 +21,7 @@ discard block  | 
                                                    ||
| 21 | 21 | public static function add_json_linked_data_for_event(EE_Event $event)  | 
                                                        
| 22 | 22 |      { | 
                                                        
| 23 | 23 | // Check we have a valid datetime for the event  | 
                                                        
| 24 | -        if (! $event->primary_datetime() instanceof EE_Datetime) { | 
                                                        |
| 24 | +        if ( ! $event->primary_datetime() instanceof EE_Datetime) { | 
                                                        |
| 25 | 25 | return;  | 
                                                        
| 26 | 26 | }  | 
                                                        
| 27 | 27 | |
@@ -50,11 +50,11 @@ discard block  | 
                                                    ||
| 50 | 50 | $template_args['currency'] = EE_Registry::instance()->CFG->currency->code;  | 
                                                        
| 51 | 51 |          foreach ($event->tickets() as $original_ticket) { | 
                                                        
| 52 | 52 | // clone tickets so that date formats don't override those for the original ticket  | 
                                                        
| 53 | - $ticket= clone $original_ticket;  | 
                                                        |
| 53 | + $ticket = clone $original_ticket;  | 
                                                        |
| 54 | 54 | $ID = $ticket->ID();  | 
                                                        
| 55 | - $template_args['event_tickets'][ $ID ]['start_date'] = $ticket->start_date(DateTime::ATOM, null);  | 
                                                        |
| 56 | - $template_args['event_tickets'][ $ID ]['end_date'] = $ticket->end_date(DateTime::ATOM, null);  | 
                                                        |
| 57 | - $template_args['event_tickets'][ $ID ]['price'] = number_format(  | 
                                                        |
| 55 | + $template_args['event_tickets'][$ID]['start_date'] = $ticket->start_date(DateTime::ATOM, null);  | 
                                                        |
| 56 | + $template_args['event_tickets'][$ID]['end_date'] = $ticket->end_date(DateTime::ATOM, null);  | 
                                                        |
| 57 | + $template_args['event_tickets'][$ID]['price'] = number_format(  | 
                                                        |
| 58 | 58 | $ticket->price(),  | 
                                                        
| 59 | 59 | EE_Registry::instance()->CFG->currency->dec_plc,  | 
                                                        
| 60 | 60 | EE_Registry::instance()->CFG->currency->dec_mrk,  | 
                                                        
@@ -71,11 +71,11 @@ discard block  | 
                                                    ||
| 71 | 71 | $availability = null;  | 
                                                        
| 72 | 72 | break;  | 
                                                        
| 73 | 73 | }  | 
                                                        
| 74 | - $template_args['event_tickets'][ $ID ]['availability'] = $availability;  | 
                                                        |
| 74 | + $template_args['event_tickets'][$ID]['availability'] = $availability;  | 
                                                        |
| 75 | 75 | unset($ticket);  | 
                                                        
| 76 | 76 | }  | 
                                                        
| 77 | 77 | $VNU_ID = espresso_venue_id();  | 
                                                        
| 78 | -        if (! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) { | 
                                                        |
| 78 | +        if ( ! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) { | 
                                                        |
| 79 | 79 | $venue = EEH_Venue_View::get_venue($VNU_ID);  | 
                                                        
| 80 | 80 | $template_args['venue_name'] = get_the_title($VNU_ID);  | 
                                                        
| 81 | 81 | $template_args['venue_url'] = get_permalink($VNU_ID);  | 
                                                        
@@ -90,7 +90,7 @@ discard block  | 
                                                    ||
| 90 | 90 | $VNU_ID  | 
                                                        
| 91 | 91 | );  | 
                                                        
| 92 | 92 | extract($template_args, EXTR_OVERWRITE);  | 
                                                        
| 93 | - include EE_TEMPLATES . 'json_linked_data_for_event.template.php';  | 
                                                        |
| 93 | + include EE_TEMPLATES.'json_linked_data_for_event.template.php';  | 
                                                        |
| 94 | 94 | }  | 
                                                        
| 95 | 95 | |
| 96 | 96 | |
@@ -122,7 +122,7 @@ discard block  | 
                                                    ||
| 122 | 122 | */  | 
                                                        
| 123 | 123 | public static function name($name = null)  | 
                                                        
| 124 | 124 |      { | 
                                                        
| 125 | - return ! empty($name) ? '<span itemprop="name">' . $name . '</span>' : '';  | 
                                                        |
| 125 | + return ! empty($name) ? '<span itemprop="name">'.$name.'</span>' : '';  | 
                                                        |
| 126 | 126 | }  | 
                                                        
| 127 | 127 | |
| 128 | 128 | |
@@ -138,7 +138,7 @@ discard block  | 
                                                    ||
| 138 | 138 | public static function streetAddress(EEI_Address $obj_with_address = null)  | 
                                                        
| 139 | 139 |      { | 
                                                        
| 140 | 140 | return $obj_with_address->address() !== null && $obj_with_address->address() !== ''  | 
                                                        
| 141 | - ? '<span itemprop="streetAddress">' . $obj_with_address->address() . '</span>' : '';  | 
                                                        |
| 141 | + ? '<span itemprop="streetAddress">'.$obj_with_address->address().'</span>' : '';  | 
                                                        |
| 142 | 142 | }  | 
                                                        
| 143 | 143 | |
| 144 | 144 | |
@@ -157,9 +157,9 @@ discard block  | 
                                                    ||
| 157 | 157 | if (preg_match(  | 
                                                        
| 158 | 158 | "/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i",  | 
                                                        
| 159 | 159 | $obj_with_address->address2()  | 
                                                        
| 160 | -        ) ) { | 
                                                        |
| 160 | +        )) { | 
                                                        |
| 161 | 161 | return $obj_with_address->address2() !== null && $obj_with_address->address2() !== ''  | 
                                                        
| 162 | - ? '<span itemprop="postOfficeBoxNumber">' . $obj_with_address->address2() . '</span>' : '';  | 
                                                        |
| 162 | + ? '<span itemprop="postOfficeBoxNumber">'.$obj_with_address->address2().'</span>' : '';  | 
                                                        |
| 163 | 163 |          } else { | 
                                                        
| 164 | 164 | return $obj_with_address->address2();  | 
                                                        
| 165 | 165 | }  | 
                                                        
@@ -178,7 +178,7 @@ discard block  | 
                                                    ||
| 178 | 178 | public static function addressLocality(EEI_Address $obj_with_address = null)  | 
                                                        
| 179 | 179 |      { | 
                                                        
| 180 | 180 | return $obj_with_address->city() !== null && $obj_with_address->city() !== ''  | 
                                                        
| 181 | - ? '<span itemprop="addressLocality">' . $obj_with_address->city() . '</span>' : '';  | 
                                                        |
| 181 | + ? '<span itemprop="addressLocality">'.$obj_with_address->city().'</span>' : '';  | 
                                                        |
| 182 | 182 | }  | 
                                                        
| 183 | 183 | |
| 184 | 184 | |
@@ -194,8 +194,8 @@ discard block  | 
                                                    ||
| 194 | 194 | public static function addressRegion(EEI_Address $obj_with_address = null)  | 
                                                        
| 195 | 195 |      { | 
                                                        
| 196 | 196 | $state = $obj_with_address->state_name();  | 
                                                        
| 197 | -        if (! empty($state)) { | 
                                                        |
| 198 | - return '<span itemprop="addressRegion">' . $state . '</span>';  | 
                                                        |
| 197 | +        if ( ! empty($state)) { | 
                                                        |
| 198 | + return '<span itemprop="addressRegion">'.$state.'</span>';  | 
                                                        |
| 199 | 199 |          } else { | 
                                                        
| 200 | 200 | return '';  | 
                                                        
| 201 | 201 | }  | 
                                                        
@@ -214,8 +214,8 @@ discard block  | 
                                                    ||
| 214 | 214 | public static function addressCountry(EEI_Address $obj_with_address = null)  | 
                                                        
| 215 | 215 |      { | 
                                                        
| 216 | 216 | $country = $obj_with_address->country_name();  | 
                                                        
| 217 | -        if (! empty($country)) { | 
                                                        |
| 218 | - return '<span itemprop="addressCountry">' . $country . '</span>';  | 
                                                        |
| 217 | +        if ( ! empty($country)) { | 
                                                        |
| 218 | + return '<span itemprop="addressCountry">'.$country.'</span>';  | 
                                                        |
| 219 | 219 |          } else { | 
                                                        
| 220 | 220 | return '';  | 
                                                        
| 221 | 221 | }  | 
                                                        
@@ -250,7 +250,7 @@ discard block  | 
                                                    ||
| 250 | 250 | */  | 
                                                        
| 251 | 251 | public static function telephone($phone_nmbr = null)  | 
                                                        
| 252 | 252 |      { | 
                                                        
| 253 | - return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">' . $phone_nmbr . '</span>'  | 
                                                        |
| 253 | + return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">'.$phone_nmbr.'</span>'  | 
                                                        |
| 254 | 254 | : '';  | 
                                                        
| 255 | 255 | }  | 
                                                        
| 256 | 256 | |
@@ -271,15 +271,15 @@ discard block  | 
                                                    ||
| 271 | 271 | // Check the URL includes a scheme  | 
                                                        
| 272 | 272 | $parsed_url = parse_url($url);  | 
                                                        
| 273 | 273 |          if (empty($parsed_url['scheme'])) { | 
                                                        
| 274 | - $url = 'http://' . ltrim($url, '/');  | 
                                                        |
| 274 | + $url = 'http://'.ltrim($url, '/');  | 
                                                        |
| 275 | 275 | }  | 
                                                        
| 276 | 276 | |
| 277 | 277 | $atts = '';  | 
                                                        
| 278 | 278 |          foreach ($attributes as $attribute => $value) { | 
                                                        
| 279 | - $atts .= ' ' . $attribute . '="' . $value . '"';  | 
                                                        |
| 279 | + $atts .= ' '.$attribute.'="'.$value.'"';  | 
                                                        |
| 280 | 280 | }  | 
                                                        
| 281 | 281 | $text = $text !== null && $text !== '' ? $text : $url;  | 
                                                        
| 282 | - return $url !== null && $url !== '' ? '<a itemprop="url" href="' . $url . '"' . $atts . '>' . $text . '</a>'  | 
                                                        |
| 282 | + return $url !== null && $url !== '' ? '<a itemprop="url" href="'.$url.'"'.$atts.'>'.$text.'</a>'  | 
                                                        |
| 283 | 283 | : '';  | 
                                                        
| 284 | 284 | }  | 
                                                        
| 285 | 285 | }  | 
                                                        
@@ -24,7 +24,7 @@ discard block  | 
                                                    ||
| 24 | 24 | "url": "<?php echo $event_permalink; ?>",  | 
                                                        
| 25 | 25 | "offers": [  | 
                                                        
| 26 | 26 | <?php  | 
                                                        
| 27 | -    foreach ($event_tickets as $ticket) {?> | 
                                                        |
| 27 | +	foreach ($event_tickets as $ticket) {?> | 
                                                        |
| 28 | 28 |      { | 
                                                        
| 29 | 29 | "@type": "Offer",  | 
                                                        
| 30 | 30 | "url": "<?php echo $event_permalink; ?>",  | 
                                                        
@@ -33,17 +33,17 @@ discard block  | 
                                                    ||
| 33 | 33 | "price": "<?php echo $ticket['price']; ?>",  | 
                                                        
| 34 | 34 | "priceCurrency": "<?php echo $currency; ?>"  | 
                                                        
| 35 | 35 |          <?php if (isset($ticket['availability'])) { | 
                                                        
| 36 | - ?>,"availability": "http://schema.org/<?php echo $ticket['availability']; ?>"  | 
                                                        |
| 36 | + ?>,"availability": "http://schema.org/<?php echo $ticket['availability']; ?>"  | 
                                                        |
| 37 | 37 | <?php } ?>  | 
                                                        
| 38 | 38 | }<?php  | 
                                                        
| 39 | -    if (is_array($event_tickets) && end($event_tickets) !== $ticket) { | 
                                                        |
| 40 | - echo ',';  | 
                                                        |
| 41 | - }  | 
                                                        |
| 42 | - }  | 
                                                        |
| 43 | - ?>  | 
                                                        |
| 39 | +	if (is_array($event_tickets) && end($event_tickets) !== $ticket) { | 
                                                        |
| 40 | + echo ',';  | 
                                                        |
| 41 | + }  | 
                                                        |
| 42 | + }  | 
                                                        |
| 43 | + ?>  | 
                                                        |
| 44 | 44 | ]<?php  | 
                                                        
| 45 | -    if ($venue_name) { | 
                                                        |
| 46 | - ?>,  | 
                                                        |
| 45 | +	if ($venue_name) { | 
                                                        |
| 46 | + ?>,  | 
                                                        |
| 47 | 47 |    "location": { | 
                                                        
| 48 | 48 | "@type": "Place",  | 
                                                        
| 49 | 49 | "name": <?php echo wp_json_encode($venue_name); ?>,  | 
                                                        
@@ -55,13 +55,13 @@ discard block  | 
                                                    ||
| 55 | 55 | }  | 
                                                        
| 56 | 56 | }  | 
                                                        
| 57 | 57 | <?php  | 
                                                        
| 58 | - } ?>  | 
                                                        |
| 58 | + } ?>  | 
                                                        |
| 59 | 59 | <?php  | 
                                                        
| 60 | -    if ($event_image) { | 
                                                        |
| 61 | - ?>,  | 
                                                        |
| 60 | +	if ($event_image) { | 
                                                        |
| 61 | + ?>,  | 
                                                        |
| 62 | 62 | "image": "<?php echo $event_image; ?>"  | 
                                                        
| 63 | 63 | <?php  | 
                                                        
| 64 | - } ?>  | 
                                                        |
| 64 | + } ?>  | 
                                                        |
| 65 | 65 |      <?php do_action('AHEE__json_linked_data_for_event__template'); ?> | 
                                                        
| 66 | 66 | }  | 
                                                        
| 67 | 67 | |