eventsmanager

Custom Scope Today Only

Jun 12th, 2020
138
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Usage: [events_list scope="today-only"]
  3. */
  4.  
  5. add_filter( 'em_get_scopes','my_em_today_scopes',1,1);
  6. function my_em_today_scopes($scopes){
  7. $my_scopes = array(
  8. 'today-only' => 'Today Only'
  9. );
  10. return $scopes + $my_scopes;
  11. }
  12.  
  13. add_filter( 'em_events_build_sql_conditions', 'my_em_today_scope_conditions',100,2);
  14. function my_em_today_scope_conditions($conditions, $args){
  15. if( !empty($args['scope']) && $args['scope']=='today-only' ){
  16. $date_today = date('Y-m-d',current_time('timestamp'));
  17. $conditions['scope'] = " (event_start_date = CAST('".$date_today."' AS DATE) AND event_end_date <= CAST('".$date_today."' AS DATE))";
  18. }
  19. return $conditions;
  20. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×