Skip to content

Instantly share code, notes, and snippets.

View slimndap's full-sized avatar

Jeroen Schmit slimndap

View GitHub Profile
@slimndap
slimndap / wpt_add_director_label.php
Created October 18, 2015 19:40
Add a 'Director: ' label in front of a custom 'director' production field. For use inside the functions.php of your theme.
<?php
/*
* Adds a 'Director: ' label in front of a custom 'director' production field.
* @param string $value The value for the 'director' field.
* @param string $field The custom field name.
* @param WPT_Production $production The production.
* @return string The updated value for the 'director' field.
*/
function wpt_add_director_label($value, $field, $production) {
if (!empty($value)) {
@slimndap
slimndap / wpt_customize_tickets_lightbox.php
Created September 2, 2015 14:34
Add this to the functions.php of your theme to set the dimensions of your popup to 1000 x 600 pixels and disable the popup for screens below a width of 480 pixels.
<?php
/**
* Sets the dimensions of the tickets lightbox to 1000 x 600 pixels and
* disables the lightbox for screens below a width of 480 pixels.
*
* @param array $args The default settings for the tickets lightbox.
* @return array The new settings.
*/
function wpt_customize_tickets_lightbox($args) {
$args['width'] = 1000;
@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>';
}
@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_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_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 / 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 / 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-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 / 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();