Skip to content

Instantly share code, notes, and snippets.

View slimndap's full-sized avatar

Jeroen Schmit slimndap

View GitHub Profile
@slimndap
slimndap / wp-theatre-venue-city-filter.php
Last active August 29, 2015 14:23
Adds venue and city filters to event listings. Eg. [wpt_events venue="Ritz" city="El paso"]. For a full explanation see: http://www.slimndap.com/add-venue-and-city-filters-to-event-listings/.
/**
* Adds venue and city filters to the default options for event listings.
*
* @param array $defaults The current defaults.
* @return array The defaults with venue and city added.
*/
function add_venue_filter_to_events($defaults) {
$defaults['venue'] = false;
$defaults['city'] = false;
return $defaults;
@slimndap
slimndap / wp-theatre-add-doors-open-field.php
Created June 24, 2015 07:28
Adds a new 'Doors open' field to the event editor. For a more information see: http://www.slimndap.com/a-new-event-editor/.
/**
* Adds a 'Doors open' field to the event editor.
*
* Prepends the new field by filtering the current fields of the event editor
* using the 'wpt/event_editor/fields' hook.
*
* @param array $fields The current fields of the event editor.
* @param int $event_id The ID of the event being edited.
* @return array The new fields of the event editor.
*/
@slimndap
slimndap / wp-theatre-remove-event-editor-fields.php
Last active August 29, 2015 14:23
Removes 'End time' and all tickets field from the event editor.
/**
* Removes 'End time' and all tickets fields from the event editor.
*
* @param array $fields The current fields of the event editor.
* @param int $event_id The event being edited.
* @return array The new fields of the event editor.
*/
function remove_event_editor_fields($fields, $event_id) {
$new_fields = array();
@slimndap
slimndap / wp-theatre-show-production-events-dates-prices.php
Created July 6, 2015 09:46
Show dates and prices for the events of a production. Place this code inside your template (eg. single.php or sidebar.php) at the position that you would like the dates and prices to appear.
/*
* Show dates and prices for the events of this production.
*/
if ( is_singular( 'wp_theatre_prod' ) ) {
$production = new WPT_Production();
echo '<ul>';
foreach ( $production->events() as $event ) {
echo '<li>'.$event->startdate_html().$event->prices_html().'</li>';
}
@slimndap
slimndap / theater-012-demo.css
Last active August 29, 2015 14:25
The CSS for the Theater v0.12 demo.
.wpt_listing .wp_theatre_event .theater-012-demo {
position: relative;
margin: 0;
}
.wpt_listing .wp_theatre_event .theater-012-demo .event-info {
bottom: 0;
background-color: rgba(0, 0, 0, 0.2);
color: #fff;
width: 100%;
padding: 10px;
@slimndap
slimndap / wp-theatre-remove-enclogins-divs-from-date-and-time.php
Created July 28, 2015 11:11
Remove the enclosing divs from the HTML of the event startdate, starttime, enddate and endtime.
<?php
/**
* Removes the enclosing div from the event startdate HTML.
*
* @param string $html The HTML.
* @param array $filters The template filters.
* @param WPT_Event $event The event.
* @return string The HTML without enclosing divs.
*/
function wpt_remove_startdate_divs($html, $filters, $event) {
@slimndap
slimndap / wpt_event_editor_add_venue_url.php
Last active August 29, 2015 14:27
Adds a link to the venue to the location HTML output. See http://theater.slimndap.com/link-the-event-location-to-the-venue-website/ for the full article.
<?php
/**
* Adds a new 'Venue URL' field to the event editor.
*
* @param array $fields The current fields of the event editor.
* @return array The new fields of the event editor.
*/
function wpt_event_editor_add_venue_url_field($fields) {
$new_fields = array();
foreach($fields as $field) {
@slimndap
slimndap / wpt_escape_from_iframe.js
Created August 12, 2015 12:12
Prevent your users from getting stuck inside the tickets iframe/lightbox when they return from the ActiveTickets screens.
/* escape from iframe, when returning from ActiveTickets */
if (window.self !== window.top) {
top.location.href = location.href;
}
@slimndap
slimndap / wpt_activetickets_subtitle_field.php
Last active August 29, 2015 14:28
An example of how to import custom fields (in this case a subtitle) during with the ActiveTickets import, using the Theater for Wordpress plugin. You can show the subtitle in your listings like this: `[wpt_events]{{title|permalink}}{{subtitle}}[/wpt_events].
<?php
/**
* Adds the subtitle ActiveTickets field to a production on import.
*
* You can show the subtitle in your listings like this:
* [wpt_events]{{title|permalink}}{{subtitle}}[/wpt_events]
*
* You can add the subtitle to your template like this:
* $production = new WPT_Production();
@slimndap
slimndap / wpt_change_events_on_production_page_header.php
Created September 2, 2015 07:41
Changes the default Events header on the production details page.
<?php
/**
* Changes the default Events header on the production details page.
*
* @param string $header The default Events header.
* @return string The new Events header.
*/
function wpt_change_events_on_production_page_header($header) {
return '<h4>Showtimes</h4>';
}