Advertisement
brook-tribe

Add WP Admin > Events: Upcoming

Jan 28th, 2014
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.22 KB | None | 0 0
  1. // Snippet now hosted here: https://gist.github.com/elimn/a5843c2723a04866e593
  2.  
  3. add_filter('posts_orderby', 'custom_events_search_orderby', 1);
  4. add_action( 'admin_menu', 'custom_admin_menu', 1 );
  5.  
  6. function custom_admin_menu () {
  7.         add_submenu_page(
  8.                 '/edit.php?post_type='.TribeEvents::POSTTYPE,
  9.                 'Events: Upcoming',
  10.                 'Events: Upcoming',
  11.                 apply_filters( 'tribe_settings_req_cap', 'manage_options' ),
  12.                 'edit.php?post_type='.TribeEvents::POSTTYPE.'&orderby=start-date&order=asc&upcoming-events=true'
  13.         );
  14. }
  15.  
  16. function custom_events_search_orderby ( $orderby_sql ) {
  17.         global $ecp_apm;
  18.  
  19.         if (!empty($_GET['upcoming-events']) && get_query_var('post_type') == TribeEvents::POSTTYPE) {
  20.                 $ecp_apm->filters->add_active(
  21.                         array('ecp_end_date' =>
  22.                                 array(
  23.                                         'value' => date('Y-m-d'),
  24.                                         'is' =>  'gte',
  25.                                         'is_date_field' => true
  26.                                 )
  27.                         )
  28.                 );
  29.         }
  30.  
  31.         return $orderby_sql;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement