Example #1
0
 /**
  * Initialize class
  * @param array $args
  * @access public
  * @since  2.0
  */
 public function __construct($args = array())
 {
     $paged = get_query_var('paged') ? get_query_var('paged') : 1;
     if (isset($args['post_parent'])) {
         $post_parent = $args['post_parent'];
     } else {
         $post_parent = get_query_var('parent') ? get_query_var('parent') : false;
     }
     $defaults = array('showposts' => ap_opt('question_per_page'), 'paged' => $paged);
     $args['post_status'][] = 'publish';
     $args['post_status'][] = 'closed';
     if ($post_parent) {
         $this->args['post_parent'] = $post_parent;
     }
     $this->args = wp_parse_args($args, $defaults);
     if (get_query_var('ap_s') != '') {
         $this->args['s'] = sanitize_text_field(get_query_var('ap_s'));
     }
     if (isset($this->args['sortby'])) {
         $this->orderby_questions();
     }
     $this->args['post_type'] = 'question';
     $args = $this->args;
     /**
      * Initialize parent class
      */
     parent::__construct($args);
 }
Example #2
0
 /**
  * Initialize class
  * @param array $args Query arguments.
  * @access public
  * @since  2.0
  */
 public function __construct($args = array())
 {
     global $answers;
     $paged = get_query_var('paged') ? get_query_var('paged') : 1;
     $defaults = array('question_id' => get_question_id(), 'ap_answers_query' => true, 'showposts' => ap_opt('answers_per_page'), 'paged' => $paged, 'only_best_answer' => false, 'include_best_answer' => false);
     $args['post_status'][] = 'publish';
     $args['post_status'][] = 'closed';
     $this->args = wp_parse_args($args, $defaults);
     if (isset($this->args['question_id'])) {
         $question_id = $this->args['question_id'];
     }
     if (!empty($question_id)) {
         $this->args['post_parent'] = $question_id;
     }
     if (isset($this->args['sortby'])) {
         $this->orderby_answers();
     }
     // Check if requesting only for best Answer
     if (isset($this->args['only_best_answer']) && $this->args['only_best_answer']) {
         $this->args['meta_query'] = array(array('key' => ANSPRESS_BEST_META, 'type' => 'BOOLEAN', 'compare' => '=', 'value' => '1'));
     }
     $this->args['post_type'] = 'answer';
     $args = $this->args;
     /**
      * Initialize parent class
      */
     parent::__construct($args);
 }
 function __construct($args)
 {
     $this->args = $args;
     add_filter('posts_fields', array($this, 'posts_fields'));
     add_filter('posts_orderby', array($this, 'posts_orderby'));
     parent::__construct($args);
     remove_filter('posts_fields', array($this, 'posts_fields'));
     remove_filter('posts_orderby', array($this, 'posts_orderby'));
 }
Example #4
0
 /**
  * Class constructor
  *
  * @param array|string $query_args
  *
  * @access public
  */
 public function __construct($query_args = null)
 {
     if (isset($query_args['post_type']) && $query_args['post_type'] instanceof PostTypeInterface) {
         $this->setPostType($query_args['post_type']);
         unset($query_args['post_type']);
     }
     if (isset($query_args['meta_box'])) {
         $this->setMetaBox($query_args['meta_box']);
     }
     parent::__construct($query_args);
 }
Example #5
0
 /**
  * Constructor
  *
  * @param int $post_id
  *
  * @return object WP_Query
  */
 function __construct($post_id, $args = array())
 {
     $this->post = get_post($post_id);
     $defaults = array('post_type' => $this->post->post_type, 'posts_per_page' => 5, 'post__not_in' => array($post_id));
     $this->args = wp_parse_args($args, $defaults);
     $related = $this->get_related($this->post->ID);
     if ($related) {
         parent::__construct(wp_parse_args(array('post__in' => $related, 'orderby' => 'post__in'), $this->args));
     } else {
         parent::__construct(array());
     }
 }
 /**
  * The constructor
  *
  * @since  0.0.1
  * @param  array $args
  * @return object WP_Query
  */
 public function __construct($args = array())
 {
     $this->args = $args;
     // If posts_per_page is -1, then there's no limit set,
     // but we do need a limit to be able to keep the order of UNION sub-queries:
     // @see http://stackoverflow.com/a/7587423/2078474
     if (isset($this->args['posts_per_page']) && '-1' == $this->args['posts_per_page']) {
         $this->args['posts_per_page'] = 999999;
     }
     // Remove SQL_CALC_FOUND_ROWS from the SQL query:
     $this->args['no_found_rows'] = 1;
     // Create an empty query:
     add_filter('posts_request', array($this, 'posts_request'), PHP_INT_MAX);
     // Call the parent WP_Query constructor:
     parent::__construct($this->args);
 }
 function GuestParties()
 {
     parent::__construct(array('post_type' => 'wedding_guests', 'nopaging' => true));
     foreach ($this->posts as $post) {
         $post->guests = new GuestParty($post->ID);
         $this->total_guests += $post->guests->num_guests;
         $this->attending_wedding += $post->guests->attending_wedding;
         $this->attending_dinner += $post->guests->attending_dinner;
     }
     $this->parties = $this->posts;
     $do_not_unset = array('total_guests', 'parties', 'attending_wedding', 'attending_dinner');
     foreach ($this as $key => $val) {
         if (!in_array($key, $do_not_unset)) {
             unset($this->{$key});
         }
     }
 }
 /**
  * The constructor
  *
  * @since  0.0.1
  * @param  array $args
  * @return object WP_Query
  */
 public function __construct($args = array())
 {
     // Default setup:
     $defaults = array('posts_per_page' => 10, 'paged' => 1, 'union' => 'UNION', 'args' => array());
     $this->args = wp_parse_args($args, $defaults);
     // Make sure paged > 0:
     $this->args['paged'] = 0 < $this->args['paged'] ? $this->args['paged'] : 1;
     // Make sure offset >= 0:
     $this->args['offset'] = isset($this->args['offset']) ? (int) $this->args['offset'] : 0;
     // Make sure we have UNION or UNION ALL:
     $this->args['union'] = !in_array(strtoupper($this->args['union']), array('UNION', 'UNION ALL')) ? $this->args['union'] : 'UNION';
     // Setup SQL generation:
     add_filter('posts_request', array($this, 'posts_request'), PHP_INT_MAX);
     // Setup SQL generation:
     add_filter('posts_orderby', array($this, 'posts_orderby'), PHP_INT_MAX);
     // Setup parent WP_Query constructor:
     $parents_args = array();
     // posts_per_page:
     if (isset($this->args['posts_per_page'])) {
         $parents_args['posts_per_page'] = $this->args['posts_per_page'];
     }
     // order:
     if (isset($this->args['order'])) {
         $parents_args['order'] = $this->args['order'];
     }
     // orderby:
     if (isset($this->args['orderby'])) {
         $parents_args['orderby'] = $this->args['orderby'];
     }
     // offset:
     if (isset($this->args['offset'])) {
         $parents_args['offset'] = $this->args['offset'];
     }
     // paged:
     if (isset($this->args['paged'])) {
         $parents_args['paged'] = $this->args['paged'];
     }
     // Call the parent WP_Query constructor:
     parent::__construct($parents_args);
 }
Example #9
0
 /**
  * Build the query args.
  *
  * @since 1.0.0
  * @uses p2p_type()
  *
  * @todo Add context arg.
  * @see audiotheme_gig_query()
  *
  * @param array $args WP_Query args.
  */
 public function __construct($args = array())
 {
     $args = wp_parse_args($args, array('post_status' => 'publish', 'posts_per_page' => get_option('posts_per_page'), 'meta_key' => '_audiotheme_gig_datetime', 'orderby' => 'meta_value', 'order' => 'asc', 'ignore_sticky_posts' => true, 'meta_query' => array(array('key' => '_audiotheme_gig_datetime', 'value' => date('Y-m-d', current_time('timestamp')), 'compare' => '>=', 'type' => 'DATETIME'))));
     $args = apply_filters('audiotheme_gig_query_args', $args);
     $args['post_type'] = 'audiotheme_gig';
     parent::__construct($args);
     p2p_type('audiotheme_venue_to_gig')->each_connected($this);
 }
 public function __construct($query = '')
 {
     parent::__construct($query);
     $this->posts = array();
     $this->query($query);
 }
 /**
  * Extend WP_Query with some predefined defaults to query
  * only campaign items.
  *
  * @since Astoundify Crowdfunding 0.1-alpha
  *
  * @param array $args
  * @return void
  */
 function __construct($args = array())
 {
     $defaults = array('post_type' => array('download'), 'posts_per_page' => get_option('posts_per_page'));
     $args = wp_parse_args($args, $defaults);
     parent::__construct($args);
 }
 /**
  * EE_Event_List_Query Constructor	 *
  * sets up a WordPress query
  *
  * @param array $args
  * @return \EE_Event_List_Query
  */
 function __construct($args = array())
 {
     //		printr( $args, '$args  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
     // incoming args could be a mix of WP query args + EE shortcode args
     foreach ($args as $key => $value) {
         $property = '_' . $key;
         // if the arg is a property of this class, then it's an EE shortcode arg
         if (EEH_Class_Tools::has_property($this, $property)) {
             // set the property value
             $this->{$property} = $value;
             // then remove it from the array of args that will later be passed to WP_Query()
             unset($args[$key]);
         }
     }
     // setup the events list query
     EE_Registry::instance()->load_helper('Event_Query');
     EEH_Event_Query::filter_query_parts();
     EEH_Event_Query::set_query_params($this->_month, $this->_category_slug, $this->_show_expired, $this->_order_by, $this->_sort);
     // first off, let's remove any filters from previous queries
     remove_filter('FHEE__archive_espresso_events_template__upcoming_events_h1', array($this, 'event_list_title'));
     remove_all_filters('FHEE__content_espresso_events__event_class');
     // Event List Title ?
     add_filter('FHEE__archive_espresso_events_template__upcoming_events_h1', array($this, 'event_list_title'), 10, 1);
     // add the css class
     add_filter('FHEE__content_espresso_events__event_class', array($this, 'event_list_css'), 10, 1);
     // the current "page" we are viewing
     $paged = max(1, get_query_var('paged'));
     // Force these args
     $args = array_merge($args, array('post_type' => 'espresso_events', 'posts_per_page' => $this->_limit, 'update_post_term_cache' => FALSE, 'update_post_meta_cache' => FALSE, 'paged' => $paged, 'offset' => ($paged - 1) * $this->_limit));
     // run the query
     parent::__construct($args);
 }
Example #13
0
 function __construct($query = '')
 {
     parent::__construct($query);
 }
 public function __construct($query = '')
 {
     $this->post_type = mpp_get_gallery_post_type();
     parent::__construct($query);
 }
Example #15
0
 public function __construct($query)
 {
     global $wpdb;
     $query = (array) $query;
     $key = md5(json_encode($query));
     $this->key_string = 'mdf_pcache_' . $key;
     $this->cache_table = $wpdb->prefix . 'postmeta';
     //***
     $value = $this->get_cache_value();
     if (!empty($value) and is_array($value)) {
         $this->posts_ids = $value;
         $query['post__in'] = $this->posts_ids;
         //unset($query['posts_per_page']);
         //unset($query['orderby']);
         //unset($query['order']);
         unset($query['meta_query']);
         unset($query['tax_query']);
         //unset($query['paged']);
         //modified $query
         parent::__construct($query);
         $this->found_posts = 13;
         //$this->post_count=13;
         $this->max_num_pages = 2;
     } else {
         parent::__construct($query);
         $this->posts_ids = wp_list_pluck($this->posts, 'ID');
         $this->set_cache_value();
     }
 }
 function __construct($args = array(), $stats = 'total')
 {
     global $wpdb;
     $this->stats = $stats;
     $this->stats_table = $stats == 'today' ? $wpdb->cp_ad_pop_daily : $wpdb->cp_ad_pop_total;
     $this->today_date = date('Y-m-d', current_time('timestamp'));
     $defaults = array('post_type' => APP_POST_TYPE, 'post_status' => 'publish', 'paged' => get_query_var('paged') ? get_query_var('paged') : 1, 'suppress_filters' => false);
     $args = wp_parse_args($args, $defaults);
     $args = apply_filters('cp_popular_posts_args', $args);
     add_filter('posts_join', array($this, 'posts_join'));
     add_filter('posts_where', array($this, 'posts_where'));
     add_filter('posts_orderby', array($this, 'posts_orderby'));
     parent::__construct($args);
     // remove filters to don't affect any other queries
     remove_filter('posts_join', array($this, 'posts_join'));
     remove_filter('posts_where', array($this, 'posts_where'));
     remove_filter('posts_orderby', array($this, 'posts_orderby'));
 }
 /**
  * @param array $args
  */
 function __construct($args = array())
 {
     // incoming args could be a mix of WP query args + EE shortcode args
     foreach ($args as $key => $value) {
         $property = '_' . $key;
         // if the arg is a property of this class, then it's an EE shortcode arg
         if (property_exists($this, $property)) {
             // set the property value
             $this->{$property} = $value;
             // then remove it from the array of args that will later be passed to WP_Query()
             unset($args[$key]);
         }
     }
     // parse orderby attribute
     if ($this->_order_by !== NULL) {
         $this->_order_by = explode(',', $this->_order_by);
         $this->_order_by = array_map('trim', $this->_order_by);
     }
     $this->_sort = in_array($this->_sort, array('ASC', 'asc', 'DESC', 'desc')) ? strtoupper($this->_sort) : 'ASC';
     // setup the events list query
     EE_Registry::instance()->load_helper('Event_Query');
     //add query filters
     EEH_Event_Query::add_query_filters();
     // set params that will get used by the filters
     EEH_Event_Query::set_query_params($this->_month, $this->_category_slug, $this->_show_expired, $this->_order_by, $this->_sort);
     // the current "page" we are viewing
     $paged = max(1, get_query_var('paged'));
     // Force these args
     $args = array_merge($args, array('post_type' => 'espresso_events', 'posts_per_page' => $this->_limit, 'update_post_term_cache' => FALSE, 'update_post_meta_cache' => FALSE, 'paged' => $paged, 'offset' => ($paged - 1) * $this->_limit));
     // run the query
     parent::__construct($args);
 }
Example #18
0
 function __construct($args = array())
 {
     add_filter('custom_meta_query', array($this, 'custom_meta_query'));
     parent::__construct($args);
 }
 public function __construct($args = array())
 {
     $args = array_merge($args, array('post_type' => CFS_LFQ_POST_TYPE));
     /*==================================================
           Remove the add_filter('pre_get_posts').
       ================================================== */
     remove_filter('posts_fields', 'event_fields', 10, 2);
     remove_filter('posts_join', 'event_join', 10, 2);
     remove_filter('posts_where', 'event_where', 10, 2);
     remove_filter('posts_where', 'calendar_where', 10, 2);
     remove_filter('posts_orderby', 'event_orderby', 10, 2);
     remove_filter('post_limits', 'event_limits', 10, 2);
     remove_filter('posts_groupby', 'event_groupby', 10, 2);
     add_filter('posts_fields', 'event_fields', 10, 2);
     add_filter('posts_join', 'event_join', 10, 2);
     if ($args['calendar']) {
         add_filter('posts_where', 'calendar_where', 10, 2);
     } else {
         add_filter('posts_where', 'event_where', 10, 2);
     }
     add_filter('posts_orderby', 'event_orderby', 10, 2);
     add_filter('post_limits', 'event_limits', 10, 2);
     //    add_filter('posts_groupby', 'event_groupby',10, 2);
     parent::__construct($args);
     // Make sure these filters don't affect any other queries
     remove_filter('posts_fields', 'event_fields', 10, 2);
     remove_filter('posts_join', 'event_join', 10, 2);
     remove_filter('posts_where', 'event_where', 10, 2);
     remove_filter('posts_where', 'calendar_where', 10, 2);
     remove_filter('posts_orderby', 'event_orderby', 10, 2);
     remove_filter('post_limits', 'event_limits', 10, 2);
     //    remove_filter('posts_groupby', 'event_groupby', 10, 2);
 }