Advertisement
Guest User

Untitled

a guest
Feb 14th, 2012
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.48 KB | None | 0 0
  1.             if ( is_array($scope) ) {
  2.                 //This is an array, let's split it up
  3.                 $date_start = strtotime($scope[0]);
  4.                 $date_end = strtotime($scope[1]);
  5.                 if( !empty($date_start) && empty($date_end) ){
  6.                     //do a from till infinity
  7.                     if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
  8.                         $query[] = array( 'key' => '_start_ts', 'value' => $date_start, 'compare' => '>=' );
  9.                     } else {
  10.                         $query[] = array( 'key' => '_end_ts', 'value' => $date_start, 'compare' => '>=' );
  11.                     }
  12.                 }elseif( empty($date_start) && !empty($date_end) ){
  13.                     //do past till $date_end
  14.                     if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
  15.                         $query[] = array( 'key' => '_start_ts', 'value' => $date_end, 'compare' => '<' );
  16.                     }else{
  17.                         $query[] = array( 'key' => '_end_ts', 'value' => $date_end, 'compare' => '<' );
  18.                     }
  19.                 }else{
  20.                     //date range
  21.                     if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
  22.                         $query[] = array( 'key' => '_start_ts', 'value' => array($date_start,$date_end), 'type' => 'numeric', 'compare' => 'BETWEEN');
  23.                     } else {
  24.                         $query[] = array( 'key' => '_start_ts', 'value' => $date_end, 'compare' => '<=' );
  25.                         $query[] = array( 'key' => '_end_ts', 'value' => $date_start, 'compare' => '>=' );
  26.                     }
  27.                 }
  28.             } elseif ( preg_match ( "/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $scope ) ) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement