This is what I’m trying to do, but the new scope is not working. I tried changing the names of more of the things.
/* custom event scope: "this-week" */
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']=='this-week' ){
$start_date = date('Y-m-d',current_time('timestamp'));
$end_date = date('Y-m-d',strtotime("+7 day", current_time('timestamp')));
$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;
}
add_filter( 'em_get_scopes','my_em_scopes',1,1);
function my_em_scopes($scopes){
$my_scopes = array(
'this-week' => 'This week'
);
return $scopes + $my_scopes;
}
/* END event custom scope: "this-week" */
/* custom event scope: "thirty-days" */
add_filter( 'em_events_build_sql_conditions', 'my_em_scope_conditions',1,2);
function td_scope_conditions($conditions, $args){
if( !empty($args['scopetd']) && $args['scopetd']=='thirty-days' ){
$start_date = date('Y-m-d',current_time('timestamp'));
$end_date = date('Y-m-d',strtotime("+30 day", current_time('timestamp')));
$conditions['scopetd'] = " (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;
}
add_filter( 'td_scopes','td_scopes',1,1);
function td_scopes($scopestd){
$my_scopestd = array(
'thirty-days' => 'Thirty days'
);
return $scopestd + $my_scopestd;
}
/* END custom scope: "Thirty days" */
[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been damaged by the forum’s parser.]