Skip to content

Instantly share code, notes, and snippets.

<?php
/*
* Adds the placeholder {thumbnail:linked} for the shortcode [tribe_event_inline]
* To be used as a new variable that outputs the thumbnail with a link to the event
*
* Author: Barry Hughes
*/
function do_linked_thumb_placeholder( $event_id ) {
return '<a href="' . get_permalink( $event_id ) . '">' . tribe_event_featured_image( $event_id, 'full', false ) . '</a>';
<?php
/*
* Shows the event for the first day and remove it from the rest in a multi-day event.
* Limited to month view only
*
* Author: Barry Hughes
*/
function reduce_month_view_single_events( $events ) {
static $rendered_ids = array();
@vicskf
vicskf / functions.php
Last active May 11, 2017 01:20
TEC Filter Bar > Tribe hide timeofday option from filter
<?php
/* Tribe hide timeofday option from filter */
function tribe_modify_category_filter ( $values, $slug ) {
if ( $slug != 'timeofday' ) return $values;
foreach ( $values as $key => $value ) {
if ( $value['value'] == '17-21' ) {
@vicskf
vicskf / functions.php
Created April 21, 2017 04:08
Does not show past events from The Events Calendar
<?php
/*
* Does not show past events from The Events Calendar
*/
add_filter('tribe_events_pre_get_posts', 'filter_tribe_all_occurences', 100);
function filter_tribe_all_occurences ($wp_query) {
if ( !is_admin() ) {
@vicskf
vicskf / functions.php
Last active May 11, 2017 01:19
Filters the upload size limit for community events submission form only
<?php
/**
* Filters the upload size limit for community events submission form only
*
* @param string $size Upload size limit (in bytes).
* @return int Filtered size limit.
*/
function set_max_upload_size_limit_community_events_submission($size){
if ( tribe_is_community_edit_event_page() ){
@vicskf
vicskf / functions.php
Created May 10, 2017 16:25
TEC > Orders Related Events by Event Start Date
<?php
/*
* Orders Related Events by Event Start Date
*/
function tribe_related_posts_args_limiter ( $args = array() ) {
$args['meta_key'] = '_EventStartDate';
$args['orderby'] = 'meta_value';
return $args;
}
add_filter( 'tribe_related_posts_args', 'tribe_related_posts_args_limiter', 10, 1 );
@vicskf
vicskf / functions.php
Created May 25, 2017 17:22
TEC > Community Events > Custom require Event Cost allowing 0 (zero) as value for free events.
<?php
/* Custom Event Cost validation */
function tribe_custom_event_cost_validation ( $valid, $submission, $class ) {
/* Prevents submit and adds error message if cost is empty and different than '0' */
if ( empty( $submission['EventCost'] ) && $submission['EventCost'] != '0' ) {
$valid = false;
$message = __( '%s is required', 'tribe-events-community' );
@vicskf
vicskf / functions.php
Last active June 13, 2017 02:45
TEC - Adds day headers between events in the loop when the day has changed
<?php
/**
* Adds day headers between events in the loop when the day has changed
*
**/
add_filter( 'tribe_events_list_the_date_headers', 'the_date_headers_add_day_header_separator', 10, 1 );
function the_date_headers_add_day_header_separator ( $html ){
@vicskf
vicskf / functions.php
Created July 18, 2017 23:35
TEC Filter Bar > Tribe hide dayofweek options from filter Bar
<?php
/* Tribe hide dayofweek option from filter */
function tribe_modify_category_filter ( $values, $slug ) {
if ( $slug != 'dayofweek' ) return $values;
foreach ( $values as $key => $value ) {
// If Monday, Tuesday or Wednesday then unset the values
if ( $value['value'] == '2' || $value['value'] == '3' || $value['value'] == '4') {
@vicskf
vicskf / functions.php
Created July 28, 2017 02:46
Add venue name to WooCommerce order item if it's a tribe ticket
<?php
add_action( 'woocommerce_order_item_meta_start', 'add_venue_to_order', 101, 4 );
function add_venue_to_order( $item_id, $item, $order, $plain_text = '' ){
$wootix = Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance();
$item_data = $item->get_data();
$event = $wootix->get_event_for_ticket( $item_data['product_id'] );
//get event venue
$event_venue = tribe_get_venue( $event );
// Show event Venue Name if this ticket is for a tribe event.