Last active
June 10, 2019 18:01
-
-
Save RichardWallis/9b6885c592b3c67464d761fc3b2968a2 to your computer and use it in GitHub Desktop.
Event Espresso Schema.org 'Event' code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="application/ld+json"> | |
{ | |
"@context": "http://schema.org/", | |
"@type": "Event", | |
"name": "Test Event", | |
"startDate": "2019-12-31T10:00:00+00:00", | |
"endDate": "2019-12-31T10:15:00+00:00", | |
"description": "[raw_html_snippet id=\"event-text\"]", | |
"url": "https://smarttrees.co.uk/events/test-event/", | |
"offers": [ | |
{ | |
"@type": "Offer", | |
"url": "https://smarttrees.co.uk/events/test-event/", | |
"name": "", | |
"validFrom": "2019-05-03T11:14:00+01:00 ", | |
"validThrough": "2019-12-31T09:45:00+00:00 ", | |
"price": "10.00", | |
"priceCurrency": "GBP" | |
,"availability": "http://schema.org/InStock" | |
}, { | |
"@type": "Offer", | |
"url": "https://smarttrees.co.uk/events/test-event/", | |
"name": "", | |
"validFrom": "2019-05-03T11:14:00+01:00 ", | |
"validThrough": "2019-12-31T09:45:00+00:00 ", | |
"price": "2.50", | |
"priceCurrency": "GBP" | |
,"availability": "http://schema.org/InStock" | |
}, { | |
"@type": "Offer", | |
"url": "https://smarttrees.co.uk/events/test-event/", | |
"name": "", | |
"validFrom": "2019-05-03T11:15:00+01:00 ", | |
"validThrough": "2019-12-31T00:00:00+00:00 ", | |
"price": "2.50", | |
"priceCurrency": "GBP" | |
,"availability": "http://schema.org/InStock" | |
} ] } | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Inserted from function ee_event_schemaorg() in smarttrees plugin --> | |
<script type="application/ld+json"> | |
{ | |
"@context": "http://schema.org", | |
"@type": ["Event", "ChildrensEvent"], | |
"name": "Santa's Grotto Visit - Test Event", | |
"description": "Festive sleigh ride to Santa's Grotto - Walk through the Christmas tree lined Grotto, catching snowflakes and bubbles - Meet and stroke the reindeer and see the nativity scene - Make a wish in the wishing well with a magic coin, before being led by elves to visit Santa in his house - Talk with Santa and receive an age appropriate present", | |
"image": "https://smarttrees.co.uk/wp-content/uploads/2016/02/IMG_4838ps-768x512.jpg", | |
"location": { | |
"@type": "Place", | |
"name": "Smart Trees", | |
"address": { | |
"@type": "PostalAddress", | |
"addressCountry": "UK", | |
"addressLocality": "Pershore", | |
"addressRegion": "Worcestershire", | |
"postalCode": "WR10 2LZ", | |
"streetAddress": "Field Farm, Hill Furze Road" | |
} | |
}, | |
"url": "https://smarttrees.co.uk/events/test-event/", | |
"startDate": "2019-12-31T10:00", | |
"endDate": "2019-12-31T10:15", | |
"about": "/experience/grotto/", | |
"organizer": { | |
"@type": "Organization", | |
"name": "Smart Trees", | |
"url": "https://smarttrees.co.uk" | |
} | |
"offers": [ | |
{ | |
"@type": "Offer", | |
"name": "Accompanying Adult Ticket", | |
"description": "Adult ticket to accompany children through grotto. At least one adult must be responsible for and accompany each party through the Grotto.", | |
"price": "2.50", | |
"priceCurrency": "GBP", | |
"availability": "InStock", | |
"validFrom": "2019-05-03T11:14", | |
"validThrough": "2019-12-31T9:45", | |
"offeredBy": { | |
"@type": "Organization", | |
"name": "Smart Trees", | |
"url": "https://smarttrees.co.uk" | |
}, | |
"acceptedPaymentMethod": "CreditCard" | |
} | |
, | |
{ | |
"@type": "Offer", | |
"name": "Child Ticket", | |
"description": "Child Ticket to visit Santa. Includes one age appropriate present. At least one child receiving a present must be part of each party visiting the Grotto.", | |
"price": "10.00", | |
"priceCurrency": "GBP", | |
"availability": "InStock", | |
"validFrom": "2019-05-03T11:14", | |
"validThrough": "2019-12-31T9:45", | |
"offeredBy": { | |
"@type": "Organization", | |
"name": "Smart Trees", | |
"url": "https://smarttrees.co.uk" | |
}, | |
"acceptedPaymentMethod": "CreditCard" | |
} | |
, | |
{ | |
"@type": "Offer", | |
"name": "Child (without present)", | |
"description": "Child Ticket to visit Santa. Does not include present.", | |
"price": "2.50", | |
"priceCurrency": "GBP", | |
"availability": "InStock", | |
"validFrom": "2019-05-03T11:14", | |
"validThrough": "2019-12-31T9:45", | |
"offeredBy": { | |
"@type": "Organization", | |
"name": "Smart Trees", | |
"url": "https://smarttrees.co.uk" | |
}, | |
"acceptedPaymentMethod": "CreditCard" | |
} | |
, | |
{ | |
"@type": "Offer", | |
"name": "Accompanying Adult Ticket", | |
"description": "Accompanying Adult Ticket to visit Santa. At least one adult must be part of each party visiting the Grotto.", | |
"price": "2.50", | |
"priceCurrency": "GBP", | |
"availability": "InStock", | |
"validFrom": "2019-05-03T11:15", | |
"validThrough": "2019-12-31T0:00", | |
"offeredBy": { | |
"@type": "Organization", | |
"name": "Smart Trees", | |
"url": "https://smarttrees.co.uk" | |
}, | |
"acceptedPaymentMethod": "CreditCard" | |
} | |
] | |
} | |
</script> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Event Schema.org | |
function ee_event_schemaorg(){ | |
global $post; | |
$event = EEH_Event_View::get_event(); | |
$id = $event->id(); | |
?> | |
<!-- Inserted from function ee_event_schemaorg() in smarttrees plugin --> | |
<script type="application/ld+json"> | |
{ | |
"@context": "http://schema.org", | |
"@type": ["Event", "ChildrensEvent"], | |
"name": "Santa's Grotto Visit - <?php echo $event->name();?>", | |
"description": "Festive sleigh ride to Santa's Grotto - Walk through the Christmas tree lined Grotto, catching snowflakes and bubbles - Meet and stroke the reindeer and see the nativity scene - Make a wish in the wishing well with a magic coin, before being led by elves to visit Santa in his house - Talk with Santa and receive an age appropriate present", | |
"image": "https://smarttrees.co.uk/wp-content/uploads/2016/02/IMG_4838ps-768x512.jpg", | |
"location": { | |
"@type": "Place", | |
"name": "Smart Trees", | |
"address": { | |
"@type": "PostalAddress", | |
"addressCountry": "UK", | |
"addressLocality": "Pershore", | |
"addressRegion": "Worcestershire", | |
"postalCode": "WR10 2LZ", | |
"streetAddress": "Field Farm, Hill Furze Road" | |
} | |
}, | |
"url": "<?php espresso_event_link_url(); ?>", | |
"startDate": "<?php echo $event->primary_datetime()->start_date('Y-m-d\TG:i'); ?>", | |
"endDate": "<?php echo $event->primary_datetime()->end_date('Y-m-d\TG:i'); ?>", | |
"about": "/experience/grotto/", | |
"organizer": { | |
"@type": "Organization", | |
"name": "Smart Trees", | |
"url": "https://smarttrees.co.uk" | |
} | |
"offers": [ | |
<?php | |
$dts = EEH_Event_View::get_all_date_obj($id,true); | |
$first = true; | |
foreach($dts as $dt){ | |
$tickets = $dt->tickets(); | |
foreach($tickets as $ticket){ | |
if($first == true){ | |
$first = false; | |
}else{ | |
echo " ," . PHP_EOL; | |
} | |
echo " {" . PHP_EOL; | |
echo ' "@type": "Offer",' . PHP_EOL; | |
echo ' "name": "' . $ticket->name() . '",' . PHP_EOL; | |
echo ' "description": "' . $ticket->description() . '",' . PHP_EOL; | |
echo ' "price": "' . number_format( $ticket->price(), | |
EE_Registry::instance()->CFG->currency->dec_plc, | |
EE_Registry::instance()->CFG->currency->dec_mrk, | |
EE_Registry::instance()->CFG->currency->thsnds) . '",' . PHP_EOL; | |
echo ' "priceCurrency": "' . EE_Registry::instance()->CFG->currency->code . '",' . PHP_EOL; | |
echo ' "availability": "InStock",' . PHP_EOL; | |
echo ' "validFrom": "' . $ticket->get_i18n_datetime('TKT_start_date', 'Y-m-d\TG:i') . '",' . PHP_EOL; | |
echo ' "validThrough": "' . $ticket->get_i18n_datetime('TKT_end_date', 'Y-m-d\TG:i') . '",' . PHP_EOL; | |
echo ' "offeredBy": {' . PHP_EOL; | |
echo ' "@type": "Organization",' . PHP_EOL; | |
echo ' "name": "Smart Trees",' . PHP_EOL; | |
echo ' "url": "https://smarttrees.co.uk"' . PHP_EOL; | |
echo ' },' . PHP_EOL; | |
echo ' "acceptedPaymentMethod": "CreditCard"' . PHP_EOL; | |
echo " }" . PHP_EOL; | |
} | |
} | |
?> | |
] | |
} | |
</script> | |
<?php | |
} | |
add_action('AHEE_event_details_before_the_content','ee_event_schemaorg'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Event Schema.org | |
function ee_event_schemaorg(){ | |
global $post; | |
$event = EEH_Event_View::get_event(); | |
$id = $event->id(); | |
?> | |
<!-- Inserted from function ee_event_schemaorg() in smarttrees plugin --> | |
<script type="application/ld+json"> | |
{ | |
"@context": "http://schema.org", | |
"@type": ["Event", "ChildrensEvent"], | |
"name": "Santa's Grotto Visit - <?php echo $event->name();?>", | |
"description": "Festive sleigh ride to Santa's Grotto - Walk through the Christmas tree lined Grotto, catching snowflakes and bubbles - Meet and stroke the reindeer and see the nativity scene - Make a wish in the wishing well with a magic coin, before being led by elves to visit Santa in his house - Talk with Santa and receive an age appropriate present", | |
"image": "https://smarttrees.co.uk/wp-content/uploads/2016/02/IMG_4838ps-768x512.jpg", | |
"location": { | |
"@type": "Place", | |
"name": "Smart Trees", | |
"address": { | |
"@type": "PostalAddress", | |
"addressCountry": "UK", | |
"addressLocality": "Pershore", | |
"addressRegion": "Worcestershire", | |
"postalCode": "WR10 2LZ", | |
"streetAddress": "Field Farm, Hill Furze Road" | |
} | |
}, | |
"url": "<?php espresso_event_link_url(); ?>", | |
"startDate": "<?php echo $event->primary_datetime()->start_date('Y-m-d\TG:i'); ?>", | |
"endDate": "<?php echo $event->primary_datetime()->end_date('Y-m-d\TG:i'); ?>", | |
"about": "/experience/grotto/", | |
"organizer": "https://smarttrees.co.uk", | |
"offers": [ | |
<?php | |
$dts = EEH_Event_View::get_all_date_obj($id,true); | |
$first = true; | |
foreach($dts as $dt){ | |
$tickets = $dt->tickets(); | |
foreach($tickets as $ticket){ | |
if($first == true){ | |
$first = false; | |
}else{ | |
echo " ," . PHP_EOL; | |
} | |
echo " {" . PHP_EOL; | |
echo ' "@type": "Offer",' . PHP_EOL; | |
echo ' "name": "' . $ticket->name() . '",' . PHP_EOL; | |
echo ' "description": "' . $ticket->description() . '",' . PHP_EOL; | |
echo ' "price": "' . number_format( $ticket->price(), | |
EE_Registry::instance()->CFG->currency->dec_plc, | |
EE_Registry::instance()->CFG->currency->dec_mrk, | |
EE_Registry::instance()->CFG->currency->thsnds) . '",' . PHP_EOL; | |
echo ' "priceCurrency": "' . EE_Registry::instance()->CFG->currency->code . '",' . PHP_EOL; | |
echo ' "availability": "InStock",' . PHP_EOL; | |
echo ' "validFrom": "' . $ticket->get_i18n_datetime('TKT_start_date', 'Y-m-d\TG:i') . '",' . PHP_EOL; | |
echo ' "validThrough": "' . $ticket->get_i18n_datetime('TKT_end_date', 'Y-m-d\TG:i') . '",' . PHP_EOL; | |
echo ' "seller": {' . PHP_EOL; | |
echo ' "name": "Smart Trees",' . PHP_EOL; | |
echo ' "url": "https://smarttrees.co.uk"' . PHP_EOL; | |
echo ' },' . PHP_EOL; | |
echo ' "acceptedPaymentMethod": "CreditCard"' . PHP_EOL; | |
echo " }" . PHP_EOL; | |
} | |
} | |
?> | |
] | |
} | |
</script> | |
<?php | |
} | |
add_action('AHEE_event_details_before_the_content','ee_event_schemaorg'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment