Skip to content

Instantly share code, notes, and snippets.

@elimn
elimn / functions.php
Last active August 29, 2015 14:05 — forked from barryhughes/fast-forward-mini-cal.php
MT | TEC | Minicalendar widget > Show the month of the next upcoming event when current month is empty
<?php
/**
* Tries to force the minicalendar widget to show the month of the next upcoming event by default, rather
* than simply showing the current month (which might be empty).
*/
class Tribe_Advance_Minical
{
protected $target_date = false;
@elimn
elimn / functions.php
Last active August 29, 2015 14:08 — forked from kelly-tribe/alter-or-remove-heading.php
MT | TEC | Change Upcoming Events Title
<?php
add_filter('tribe_get_events_title', 'change_upcoming_events_title');
function change_upcoming_events_title($title) {
//We'll change the title on upcoming and map views
if (tribe_is_upcoming() or tribe_is_map() or tribe_is_photo()) return 'Upcoming Parties';
//In all other circumstances, leave the original title in place
return $title;
@elimn
elimn / functions.php
Last active August 29, 2015 14:09
MT | TEC | Set Events Category Default View
<?php
// Overrides every request for viewOption from TribeEvents::getOption()
function tribe_swap_default_category_view ($option, $default, $optionName) {
// For a list of acceptable views/values run print_r(tribe_events_enabled_views());
$default_events_view = 'month'; // The default view for the main page, venue, etc.
$default_category_view = 'list'; // The default view for any calendar category
@elimn
elimn / functions.php
Last active September 18, 2015 21:21
MT | TEC | Prepend category name(s) to event title
<?php
// Prepends category name(s) to the event titles
function tribe_events_title_include_cat ($title, $id) {
$separator = ' &raquo; '; // HTML Separator between categories and title
$cats = get_the_terms($id, 'tribe_events_cat');
$is_ajax = defined('DOING_AJAX') && DOING_AJAX;
$is_truly_admin = is_admin() && !$is_ajax;
@elimn
elimn / functions.php
Last active August 29, 2015 14:09
MT | TEC | Change all events to display as all day events
<?php
// Changes all events to display as all day events
function tribe_all_events_all_day ($output) {
if ( !is_admin() && tribe_is_event() ) {
$output = true;
}
return $output;
@elimn
elimn / functions.php
Last active August 29, 2015 14:09
MT | TEC | Selectively hide events from specific user roles
<?php
// Selectively hide events from specific user roles
function tribe_event_category_permissions ($wp_query) {
// Include all posts on admin views
if ( is_admin() ) return $wp_query;
$exclude_cats = array();
@elimn
elimn / functions.php
Last active August 29, 2015 14:09
MT | TEC | Allow "SQL_BIG_SELECTS", improving database performance on some MySQL configurations
<?php
// Allows "SQL_BIG_SELECTS", improving database performance on some MySQL configurations
function tribe_allow_large_joins(){
global $wpdb;
$wpdb->query('SET SQL_BIG_SELECTS=1');
}
add_action('init', 'tribe_allow_large_joins');
@elimn
elimn / functions.php
Last active August 29, 2015 14:09
MT | TEC | Adds the "WP Admin > Events: Upcoming" page, which only shows upcoming events
<?php
// Adds upcoming menu item to WP Admin Menu
function tribe_custom_admin_menu () {
add_submenu_page(
'/edit.php?post_type='.TribeEvents::POSTTYPE,
'Events: Upcoming',
'Events: Upcoming',
apply_filters( 'tribe_settings_req_cap', 'manage_options' ),
'edit.php?post_type='.TribeEvents::POSTTYPE.'&orderby=start-date&order=asc&upcoming-events=true'
@elimn
elimn / functions.php
Last active December 2, 2019 18:38
MT | TEC | Change past event views to reverse chronological order
<?php
// Changes past event views to reverse chronological order
function tribe_past_reverse_chronological ($post_object) {
$past_ajax = (defined( 'DOING_AJAX' ) && DOING_AJAX && $_REQUEST['tribe_event_display'] === 'past') ? true : false;
if(tribe_is_past() || $past_ajax) {
$post_object = array_reverse($post_object);
}
@elimn
elimn / tribe_custom_theme_text.php
Last active September 17, 2015 18:23
MT | TEC | Change the wording of any bit of text in WordPress
<?php
/*
* EXAMPLE OF CHANGING ANY TEXT (STRING) IN THE EVENTS CALENDAR
* See the codex to learn more about WP text domains:
* http://codex.wordpress.org/Translating_WordPress#Localization_Technology
* Example Tribe domains: 'tribe-events-calendar', 'tribe-events-calendar-pro'...
*/
function tribe_custom_theme_text ( $translations, $text, $domain ) {