eventsmanager

list from today until the end of the year

May 11th, 2015
388
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*Custom event scope to show current date until end of the year*/
  2. /* usage: [events_list scope="now-yearend"] */
  3.  
  4. add_filter( 'em_get_scopes','my_em_scopes',1,1);
  5. function my_em_scopes($scopes){
  6. $my_scopes = array(
  7. 'now-yearend' => 'Today until end of the year'
  8. );
  9. return $scopes + $my_scopes;
  10. }
  11.  
  12. add_filter( 'em_events_build_sql_conditions', 'my_em_scope_conditions',1,2);
  13. function my_em_scope_conditions($conditions, $args){
  14. if( !empty($args['scope']) && $args['scope']=='now-yearend' ){
  15. $start_date = date('Y-m-d',current_time('timestamp'));
  16. $end_date = date('Y-12-31');
  17. $conditions['scope'] = " (event_start_date BETWEEN CAST('$start_date' AS DATE) AND CAST('$end_date' AS DATE)) OR (event_end_date BETWEEN CAST('$end_date' AS DATE) AND CAST('$start_date' AS DATE))";
  18. }
  19. return $conditions;
  20. }
RAW Paste Data