Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Custom event scope to show current date until end of the year*/
- /* usage: [events_list scope="now-yearend"] */
- add_filter( 'em_get_scopes','my_em_scopes',1,1);
- function my_em_scopes($scopes){
- $my_scopes = array(
- 'now-yearend' => 'Today until end of the year'
- );
- return $scopes + $my_scopes;
- }
- add_filter( 'em_events_build_sql_conditions', 'my_em_scope_conditions',1,2);
- function my_em_scope_conditions($conditions, $args){
- if( !empty($args['scope']) && $args['scope']=='now-yearend' ){
- $start_date = date('Y-m-d',current_time('timestamp'));
- $end_date = date('Y-12-31');
- $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))";
- }
- return $conditions;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement