Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeroen Schmit slimndap

View GitHub Profile
@slimndap
slimndap / wpt_customize_tickets_lightbox.php
Created Sep 2, 2015
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.
View wpt_customize_tickets_lightbox.php
<?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_add_director_label.php
Created Oct 18, 2015
Add a 'Director: ' label in front of a custom 'director' production field. For use inside the functions.php of your theme.
View wpt_add_director_label.php
<?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_add_long_excerpt.php
Created Oct 22, 2015
Increase the size of generated excerpts in the Theater for WordPress plugin to 50 characters.
View wpt_add_long_excerpt.php
<?php
/*
* Increase the size of generated excerpts to 50 characters.
* @param string $excerpt The current excerpt.
* @param WPT_Production $production The production.
* @return string The updated excerpt.
*/
function wpt_excerpt_long($excerpt, $production) {
$excerpt = $production->post()->post_excerpt;
if (empty($excerpt)) {
@slimndap
slimndap / import-activetickets-longtext.php
Last active Mar 2, 2016
Imports the 'LongText' for a newly created production from ActiveTickets. For use with the ActiveTickets for WordPress plugin http://theater.slimndap.com/downloads/activetickets-for-wordpress/.
View import-activetickets-longtext.php
<?php
/**
* Imports the 'LongText' for a newly created production from ActiveTickets.
*
* By default, ActiveTicket for WordPress only imports the 'ShortText'.
* Importing the 'LongText' requires an extra API call for every production during the import,
* which may cause a higher load on the server.
*
* @param WPT_Production $production The production.
* @param object $activetickets_program The production data from ActiveTickets.
@slimndap
slimndap / replace-venue-input-with-dropdown.php
Last active Jan 28, 2016
Replaces the venue input in the event editor with a dropdown. Place this code inside the functions.php of your theme.
View replace-venue-input-with-dropdown.php
<?php
/**
* Replaces the venue input in the event editor with a dropdown.
*
* @param string $html The default venue input HTML.
* @param mixed $field The venue field.
* @param int $event_id The ID of the event.
* @return string The vnue dropwdown HTML.
*/
function wpt_event_editor_get_venue_dropdown_html($html, $field, $event_id) {
@slimndap
slimndap / wpt_structured_data_set_location_name.php
Last active Feb 6, 2016
Filter the venue name inside structured event data and always set it to the name of your theater. Place the code inside the functions.php of your theme. For use with the Rich Snippets for Theater plugin (http://theater.slimndap.com/downloads/rich-snippets-theater/).
View wpt_structured_data_set_location_name.php
<?php
/**
* Sets the venue to a fixed value inside structured event data.
*
* @param string $name The original venue value.
* @param WPT_Event $event The event.
* @return string The new venue value.
*/
function wpt_structured_data_set_location_name($name, $event) {
@slimndap
slimndap / get_current_event_html.php
Last active Feb 19, 2017
Adds a [current_event] shortcode that displays the event that is currently on.
View get_current_event_html.php
<?php
/**
* Get the HTML to display the current event.
*
* @param array $args The shortcode arguments.
* @param string $template The shortcode template.
* @return string
*/
function get_current_event_html( $args, $template = false ) {
global $wp_theatre;
@slimndap
slimndap / add_class_to_tickets_buttons.php
Created Mar 4, 2017
How to add an extra CSS class to tickets buttons, using the Theater for WordPress plugin.
View add_class_to_tickets_buttons.php
<?php
/**
* Adds an 'art-button' CSS class to the tickets buttons of events.
*
* @param array $classes The current CSS classes of tickets buttons.
* @param WPT_Event $event The event that the button belongs to.
* @return array The new CSS classes.
*/
function add_class_to_tickets_buttons( $classes, $event ) {
@slimndap
slimndap / theregal_import_PreShowStartTime.php
Last active Jun 2, 2017
Changes the event date of Veezi films from 'FeatureStartTime' to 'PreShowStartTime'. For use with the Veezi for WordPress plugin (https://wp.theater/downloads/veezi-wordpress/).
View theregal_import_PreShowStartTime.php
<?php
/**
* Changes the event date of Veezi films from 'FeatureStartTime' to 'PreShowStartTime'.
*
* @param array $event_args The current event arguments.
* @param object $veezi_event The event from the Veezi feed.
* @param int $production_id The ID of the parent production.
* @return array The updated event arguments.
*/
function theregal_import_PreShowStartTime( $event_args, $veezi_event, $production_id ) {
@slimndap
slimndap / set_default_month.php
Last active Jun 15, 2017
Sets the default month for the events page to the first month that has event dates.
View set_default_month.php
<?php
/**
* Sets the default month for the events page to the first month.
*
* @return void
*/
public function set_default_month() {
global $wp_query;
global $wp_theatre;
if (