The Quick Guide
- Create a folder called
widget-for-eventbrite-api
in your child theme
( if you don’t have a child theme, you can place this folder in wp-content ) - Copy a layout from the plugin template folder and rename your file keeping the name structure
layout_{yourtemplatename}.php
You can choose from the list of available layout templates to copy from the plugin:
- freemius-premium
- templates__free
- templates__premium_only
- freemius-premium
- Use the new template in your shortcode e.g.
[wfea layout="yourtemplatename"]
You can use existing template parts and loops or create your own. You can also override templates using the same file names, your files will take precedence over the plugin.
Understanding the Template Structure
Display Eventbrite events is broken down into three different categories: Layout, Loop, Parts
A custom layout will consist of the following:
- 1 layout file
- 1 loop file
- zero to many part files
- widget-eventbrite-api
- layout_yourtemplatename.php
- loops
- loop_yourtemplatename.php
- parts
Layout (REQUIRED)
A layout file must always exist in your widget-eventbrite-api
folder. Otherwise, your custom layout won't run.
This is the file the plugin looks for whenever the layout property is used in the shortcode.
[wfea layout="yourtemplatename"]
The above shortcode will try to find the layout_yourtemplatename.php
A layout template will have the following code. Change the values accordingly.
// This will be the class name for the event list container. $data->event->layout_class = 'your-class-name-here'; // change the value to your custom layout name. $data->event->layout_name = 'yourtemplatename';
Loop
This file is responsible for the display on each event. This is where you most-likely do the editing if you want to modify the html structure for each event.
The loop file is located under the loops folder. The filename should be preceeded by the word "loop_" followed by the custom template name. i.e loop_yourtemplatename.php
Parts
Parts folder is consists of multiple files. Each file contains event detail like Event header, date, venue, prices, availability, etc.
You don't necessarily need to create each files from the parts folder into your widget-eventbrite-api
folder unless you want to make changes.
Here's a list of the available part files from the plugin.
- templates__premium_only
- loops
- parts
- availability.php
- booknow.php
- content.php
- date.php
- date_time.php
- header.php
- location.php
- music_age_restriction.php
- music_door_time.php
- music_presented_by.php
- not_found.php
- prices.php
- search.php
- thumb_widget.php
- thumb.php
- title_widget.php
- venue.php
You can call a template file according to their filename using the `get_template_part` method from the $data->template_loader object.
echo $data->template_loader->get_template_part('availability');
Template Override
There are instances where you want to change something from the plugin's existing file.
For example, you want to make changes on the date.php
file. Below is how the current template structure of the plugin looks like. All you have to do is copy the date.php
file and paste it on your widget-for-eventbrite-api
folder with the same folder structure.
- templates__premium_only
- loops
- parts
- availability.php
- booknow.php
- content.php
- date.php
- date_time.php
- header.php
- location.php
- not_found.php
- prices.php
- search.php
- thumb_widget.php
- thumb.php
- title_widget.php
- venue.php
After pasting the file to your widget-for-eventbrite-api
folder. It should now look like this.
- widget-eventbrite-api
- layout_yourtemplatename.php
- loops
- loop_yourtemplatename.php
- parts
-
date.php
-
You should now be able to freely make any changes to the date.php
file.
Please also note that the template override can be done to any template files including the layouts and loops.
Data Structure
This section will help you understand the data structure that is passed to the template. The event data is logically held withing the $data->events
object.
$data->events contains the list of events. This works similarly to WordPress posts. To access the individual event data, we'll have to loop through the object.
while ( $data->events->have_posts() ) { $data->events->the_post(); // You can access all the Eventbrite event information // using the object $data->evens->post echo $data->events->post->post_title // You can use var_dump() to see all the available properties var_dump($data->events->post); }
Below is a sample data coming from Eventbrite API. The following data can be access through $data->events->post
Loading…
Summary list of available template functions
- get_age_restriction__premium_only() : false|string
- Get age restriction data - music promoters only
- get_booknow_link() : Url
- Get the booknow link
- get_calendar_fields__premium_only() : string
- Add to calendar data fields
- get_cta() : object
- Returns a Call to Action object for use in links amount of detail varies between free and premium
- get_door_time__premium_only() : false|string
- Get door time - music promoters only
- get_element() : false|mixed
- Generic get of element whether in an array or not to avoid templates having to code isset() etc
- get_event_classes__premium_only() : string
- Get a string suitable for including in a CSS class indicating status and locations to enable for instance styling colour by status or location
- get_event_eb_url() : Url
- Get the URL to an event's public viewing page on eventbrite.com.
- get_event_end() : object
- Get event end date object
- get_event_start() : object
- Get event start date object
- get_event_time() : string
- Returns formatted time string including start and end
- get_fb_share_href__premium_only() : Url
- Facebook share url
- get_gcal_href__premium_only() : Url
- Google calendar url
- get_location_display__premium_only() : string
- Get location in display format
- get_music_headliners__premium_only() : string
- Get music headliner artist names(s) - music promoters only
- get_music_performers_names__premium_only() : string
- Get music artist names(s) - music promoters only
- get_music_supporters__premium_only() : string
- Get music supporting artist names(s)
- get_original_booknow_link() : Url
- Default templates will use URL which is modified when targeting a single page this is for custom templates where part of the page wants to go direct to Evenbrite and part go to single page
- get_outlook_cal_href__premium_only() : Url
- Outlook calendar url
- get_popup_class__premium_only() : string
- Required in templates if on-site popup is required as it enqueues Eventbrite popup scripts
- get_presented_by__premium_only() : false|string
- Get 'presented by' text - music promoters only
- get_price_display__premium_only() : false|string
- Get price in display format
- get_section_attrs() : string
- Section attributes to be used in templates to take classes / ID/ style overrides
- get_ticket_availablity__premium_only() : false|string
- Get ticket availability text
- get_twitter_share_href__premium_only() : Url
- Twitter share url
- get_venue_name_display__premium_only() : string
- Get the venue display name -if it is online display Online
- get_yahoo_href__premium_only() : Url
- Yahoo calendar url
- is_l1__premium_only() : bool
- Checking if template is in level 1 plan or not
- is_l2__premium_only() : bool
- Checking if template is in level 2 plan or not
- is_popup_allowed__premium_only() : mixed|void
- Popup detection used in cal layouts only
- paginate_links__premium_only() : void
- Outputs the links to enable pagination ( if available ) into templates note this outputs - rather than returns - html
- register_template_dirs() : void
- This function is used when creating a plugin for a custom template
Detailed template functions descriptions
get_age_restriction__premium_only()
Get age restriction data - music promoters only
$data->utilities->get_age_restriction__premium_only( $args) : false|string
Parameters
Tags
Returns
false|string —false if no restrictions, otherwise string to display age restriction
get_booknow_link()
Get the booknow link
$data->utilities->get_booknow_link( $args) : Url
Parameters
Returns
Url —link to add to book now buttons
get_calendar_fields__premium_only()
Add to calendar data fields
$data->utilities->get_calendar_fields__premium_only( $args) : string
Parameters
Returns
string —html hidden inout with calendar data for forms
get_cta()
Returns a Call to Action object for use in links amount of detail varies between free and premium
$data->utilities->get_cta( $args) : object
Parameters
Returns
object —containing ->text ->availability_class ->class
get_door_time__premium_only()
Get door time - music promoters only
$data->utilities->get_door_time__premium_only( $args) : false|string
Parameters
Tags
Returns
false|string —false if not a music promoter, otherwise door time string
get_element()
Generic get of element whether in an array or not to avoid templates having to code isset() etc
$data->utilities->get_element( $key, $array) : false|mixed
Parameters
Returns
false|mixed —value of specified element, false if not in an array
get_event_classes__premium_only()
Get a string suitable for including in a CSS class indicating status and locations to enable for instance styling colour by status or location
$data->utilities->get_event_classes__premium_only() : string
Tags
Returns
string —classes for inclusion in class attribute
get_event_eb_url()
Get the URL to an event's public viewing page on eventbrite.com.
$data->utilities->get_event_eb_url([ $ext = null ]) : Url
Parameters
Returns
Url —URL for https://eventbrite.com event
get_event_end()
Get event end date object
$data->utilities->get_event_end() : object
Tags
Returns
object —Enddate object
get_event_start()
Get event start date object
$data->utilities->get_event_start() : object
Tags
Returns
object —StartDate object
get_event_time()
Returns formatted time string including start and end
$data->utilities->get_event_time([ $args = false ]) : string
Parameters
Tags
Returns
string —formatted time
get_fb_share_href__premium_only()
Facebook share url
$data->utilities->get_fb_share_href__premium_only( $args) : Url
Parameters
Returns
Url —Facebook share link
get_gcal_href__premium_only()
Google calendar url
$data->utilities->get_gcal_href__premium_only( $args) : Url
Parameters
Returns
Url —Google calendar share link
get_location_display__premium_only()
Get location in display format
$data->utilities->get_location_display__premium_only( $args) : string
Parameters
Tags
Returns
string —Location display name
get_music_headliners__premium_only()
Get music headliner artist names(s) - music promoters only
$data->utilities->get_music_headliners__premium_only() : string
Use in template e.g. $artists = $data->utilities->get_music_headliners__premium_only();
Returns
string —empty or a string, more than one act separated by ', '
get_music_performers_names__premium_only()
Get music artist names(s) - music promoters only
$data->utilities->get_music_performers_names__premium_only(mixed $type) : string
Parameters
- $type : mixed
Tags
Returns
string —empty or a string, more than one act separated by ', '
get_music_supporters__premium_only()
Get music supporting artist names(s)
$data->utilities->get_music_supporters__premium_only() : string
Use in template e.g. $artists = $data->utilities->get_music_supporters__premium_only();
Returns
string —empty or a string, more than one act separated by ', '
get_original_booknow_link()
Default templates will use URL which is modified when targeting a single page this is for custom templates where part of the page wants to go direct to Evenbrite and part go to single page
$data->utilities->get_original_booknow_link( $args) : Url
Parameters
Returns
Url —Eventbrite link unchanged
get_outlook_cal_href__premium_only()
Outlook calendar url
$data->utilities->get_outlook_cal_href__premium_only( $args) : Url
Parameters
Returns
Url —Outlook live calendar link
get_popup_class__premium_only()
Required in templates if on-site popup is required as it enqueues Eventbrite popup scripts
$data->utilities->get_popup_class__premium_only(mixed $args) : string
Parameters
- $args : mixed
Returns
string —the popup class
get_presented_by__premium_only()
Get 'presented by' text - music promoters only
$data->utilities->get_presented_by__premium_only( $args) : false|string
Parameters
Tags
Returns
false|string —false if not music presenter,otherwise 'presented by' string
get_price_display__premium_only()
Get price in display format
$data->utilities->get_price_display__premium_only() : false|string
Returns
false|string —get_section_attrs()
Section attributes to be used in templates to take classes / ID/ style overrides
$data->utilities->get_section_attrs( $data) : string
Parameters
Returns
string —get_ticket_availablity__premium_only()
Get ticket availability text
$data->utilities->get_ticket_availablity__premium_only( $args) : false|string
Parameters
Tags
Returns
false|string —get_twitter_share_href__premium_only()
Twitter share url
$data->utilities->get_twitter_share_href__premium_only( $args) : Url
Parameters
Returns
Url —get_venue_name_display__premium_only()
Get the venue display name -if it is online display Online
$data->utilities->get_venue_name_display__premium_only( $args) : string
Parameters
Returns
string —get_yahoo_href__premium_only()
Yahoo calendar url
$data->utilities->get_yahoo_href__premium_only( $args) : Url
Parameters
Returns
Url —is_l1__premium_only()
Checking if template is in level 1 plan or not
$data->utilities->is_l1__premium_only() : bool
Returns
bool —is_l2__premium_only()
Checking if template is in level 2 plan or not
$data->utilities->is_l2__premium_only() : bool
Returns
bool —is_popup_allowed__premium_only()
Popup detection used in cal layouts only
$data->utilities->is_popup_allowed__premium_only( $args) : mixed|void
Parameters
Tags
Returns
mixed|void —either false or the ID of the popup
paginate_links__premium_only()
Outputs the links to enable pagination ( if available ) into templates note this outputs - rather than returns - html
$data->utilities->paginate_links__premium_only( $args, $instance, $max_num_pages, $position) : void
Parameters
Returns
void —register_template_dirs()
This function is used when creating a plugin for a custom template
$data->utilities->register_template_dirs( $dir) : void
Parameters
Tags
Returns
void —Debugging
The event data is logically held in this object $data->events
and the best thing now is to inspect the data object structure and contents, if you have an IDE with debugging and breakpoints then use that to take a look at the data content, but if you have not don’t worry add this code to the top of your template and it will dump the structure and content to your browser console log ( remember to remove it before you go live )
function mydebug ($data) { echo "<script>\r\n//<![CDATA[\r\nif(!console){var console={log:function(){}}}"; $output = explode("\n", print_r($data, true)); foreach ($output as $line) { if (trim($line)) { $line = addslashes($line); echo "console.log(\"{$line}\");"; } } echo "\r\n//]]>\r\n</script>"; } mydebug($data->events);