Last active
August 29, 2015 14:09
-
-
Save elimn/a5843c2723a04866e593 to your computer and use it in GitHub Desktop.
MT | TEC | Adds the "WP Admin > Events: Upcoming" page, which only shows upcoming events
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 | |
// 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' | |
); | |
} | |
add_action( 'admin_menu', 'tribe_custom_admin_menu', 1 ); | |
// Adds Upcoming Events Page | |
function tribe_custom_events_search_orderby ( $orderby_sql ) { | |
global $ecp_apm; | |
if (!empty($_GET['upcoming-events']) && get_query_var('post_type') == TribeEvents::POSTTYPE) { | |
$ecp_apm->filters->add_active( | |
array('ecp_end_date' => | |
array( | |
'value' => date('Y-m-d'), | |
'is' => 'gte', | |
'is_date_field' => true | |
) | |
) | |
); | |
} | |
return $orderby_sql; | |
} | |
add_filter('posts_orderby', 'tribe_custom_events_search_orderby', 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment