Skip to content

Instantly share code, notes, and snippets.

@joelworsham
Created July 18, 2014 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelworsham/d5b580c888fa7d602bd9 to your computer and use it in GitHub Desktop.
Save joelworsham/d5b580c888fa7d602bd9 to your computer and use it in GitHub Desktop.
<?php
/*
Plugin Name: test
*/
function test_filter( $test ) {
$current_day = intval( date( 'j' ) );
$change = false;
$new_array = array();
$array = explode( ' ', $test );
foreach ( $array as $key => $obj ) {
if ( strpos($obj,'tribe-event-day') !== false ) {
preg_match_all('/\d+/', $obj, $matches);
$n_pre = $matches[0];
$n = intval( $n_pre[0] );
if ( $n < $current_day + 3 ) $change = true;
}
}
if ( $change ) {
foreach ( $array as $key => $obj ) {
if ( strpos($obj,'tribe-events-future') !== false || strpos($obj,'tribe-events-present') !== false ) {
$array[$key] = 'tribes-events-past';
}
}
}
$final_output = implode( ' ', $array );
return $final_output;
}
add_filter( 'tribe_events_the_month_day_class', 'test_filter' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment