Created
July 18, 2014 02:31
-
-
Save joelworsham/d5b580c888fa7d602bd9 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 | |
/* | |
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