Created
January 24, 2018 17:25
-
-
Save anonymous/d0b2bc20066d05c54dbd1227c8844567 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Exit if accessed directly | |
if ( !defined( 'ABSPATH' ) ) exit; | |
// BEGIN ENQUEUE PARENT ACTION | |
// AUTO GENERATED - Do not modify or remove comment markers above or below: | |
// END ENQUEUE PARENT ACTION | |
function mf_child_theme_enqueue_styles() { | |
$parent_style = 'mf_parent_style'; | |
$parent_base_dir = 'mf'; | |
wp_enqueue_style( $parent_style, | |
get_template_directory_uri() . '/style.css', | |
array(), | |
wp_get_theme( $parent_base_dir ) ? wp_get_theme( $parent_base_dir )->get('Version') : '' | |
); | |
wp_enqueue_style( $parent_style . '_child_style', | |
get_stylesheet_directory_uri() . '/style.css', | |
array( $parent_style ), | |
wp_get_theme()->get('Version') | |
); | |
} | |
/* | |
* 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 ( $translation, $text, $domain ) { | |
// Put your custom text here in a key => value pair | |
// Example: 'Text you want to change' => 'This is what it will be changed to' | |
// The text you want to change is the key, and it is case-sensitive | |
// The text you want to change it to is the value | |
// You can freely add or remove key => values, but make sure to separate them with a comma | |
$custom_text = array( | |
'Events From' => 'Junkets From', | |
'+ Export Events' => '+ Export Junkets', | |
); | |
// If this text domain starts with "tribe-", "the-events-", or "event-" and we have replacement text | |
if( (strpos($domain, 'tribe-') === 0 || strpos($domain, 'the-events-') === 0 || strpos($domain, 'event-') === 0) && array_key_exists($translation, $custom_text) ) { | |
$translation = $custom_text[$translation]; | |
} | |
return $translation; | |
} | |
add_filter('gettext', 'tribe_custom_theme_text', 20, 3); | |
/* | |
* Alters event's archive titles | |
*/ | |
function tribe_alter_event_archive_titles ( $original_recipe_title, $depth ) { | |
// Modify the titles here | |
// Some of these include %1$s and %2$s, these will be replaced with relevant dates | |
$title_upcoming = 'Upcoming Junkets'; // List View: Upcoming events | |
$title_past = 'Past Junkets'; // List view: Past events | |
$title_range = 'Junkets for %1$s - %2$s'; // List view: range of dates being viewed | |
$title_month = 'Junkets for %1$s'; // Month View, %1$s = the name of the month | |
$title_day = 'Junkets for %1$s'; // Day View, %1$s = the day | |
$title_all = 'All junkets for %s'; // showing all recurrences of an event, %s = event title | |
$title_week = 'Junkets for week of %s'; // Week view | |
// Don't modify anything below this unless you know what it does | |
global $wp_query; | |
$tribe_ecp = Tribe__Events__Main::instance(); | |
$date_format = apply_filters( 'tribe_events_pro_page_title_date_format', tribe_get_date_format( true ) ); | |
// Default Title | |
$title = $title_upcoming; | |
// If there's a date selected in the tribe bar, show the date range of the currently showing events | |
if ( isset( $_REQUEST['tribe-bar-date'] ) && $wp_query->have_posts() ) { | |
if ( $wp_query->get( 'paged' ) > 1 ) { | |
// if we're on page 1, show the selected tribe-bar-date as the first date in the range | |
$first_event_date = tribe_get_start_date( $wp_query->posts[0], false ); | |
} else { | |
//otherwise show the start date of the first event in the results | |
$first_event_date = tribe_event_format_date( $_REQUEST['tribe-bar-date'], false ); | |
} | |
$last_event_date = tribe_get_end_date( $wp_query->posts[ count( $wp_query->posts ) - 1 ], false ); | |
$title = sprintf( $title_range, $first_event_date, $last_event_date ); | |
} elseif ( tribe_is_past() ) { | |
$title = $title_past; | |
} | |
// Month view title | |
if ( tribe_is_month() ) { | |
$title = sprintf( | |
$title_month, | |
date_i18n( tribe_get_option( 'monthAndYearFormat', 'F Y' ), strtotime( tribe_get_month_view_date() ) ) | |
); | |
} | |
// Day view title | |
if ( tribe_is_day() ) { | |
$title = sprintf( | |
$title_day, | |
date_i18n( tribe_get_date_format( true ), strtotime( $wp_query->get( 'start_date' ) ) ) | |
); | |
} | |
// All recurrences of an event | |
if ( function_exists('tribe_is_showing_all') && tribe_is_showing_all() ) { | |
$title = sprintf( $title_all, get_the_title() ); | |
} | |
// Week view title | |
if ( function_exists('tribe_is_week') && tribe_is_week() ) { | |
$title = sprintf( | |
$title_week, | |
date_i18n( $date_format, strtotime( tribe_get_first_week_day( $wp_query->get( 'start_date' ) ) ) ) | |
); | |
} | |
if ( is_tax( $tribe_ecp->get_event_taxonomy() ) && $depth ) { | |
$cat = get_queried_object(); | |
$title = '<a href="' . esc_url( tribe_get_events_link() ) . '">' . $title . '</a>'; | |
$title .= ' › ' . $cat->name; | |
} | |
return $title; | |
} | |
add_filter( 'tribe_get_events_title', 'tribe_alter_event_archive_titles', 11, 2 ); | |
// Changes the escerpt length for events to 100 words | |
function custom_excerpt_length( $length ) { | |
if( tribe_is_event() && is_archive() ) { | |
return 300; | |
} | |
} | |
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 ); | |
add_action( 'wp_enqueue_scripts', 'mf_child_theme_enqueue_styles' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment