public function __construct($query = false, $posts_class = 'TimberPost')
{
add_action('pre_get_posts', array($this, 'fix_number_posts_wp_quirk'));
if ($posts_class) {
$this->_posts_class = $posts_class;
}
if (is_a($query, 'WP_Query')) {
// We got a full-fledged WP Query, look no further!
$the_query = $query;
} elseif (false === $query) {
// If query is explicitly set to false, use the main loop
global $wp_query;
$the_query =& $wp_query;
//if we're on a custom posts page?
$the_query = self::handle_maybe_custom_posts_page($the_query);
} elseif (Helper::is_array_assoc($query) || is_string($query) && strstr($query, '=')) {
// We have a regularly formed WP query string or array to use
$the_query = new \WP_Query($query);
} elseif (is_numeric($query) || is_string($query)) {
// We have what could be a post name or post ID to pull out
$the_query = self::get_query_from_string($query);
} elseif (is_array($query) && count($query) && (is_integer($query[0]) || is_string($query[0]))) {
// We have a list of pids (post IDs) to extract from
$the_query = self::get_query_from_array_of_ids($query);
} elseif (is_array($query) && empty($query)) {
// it's an empty array
$the_query = array();
} else {
Helper::error_log('I have failed you! in ' . basename(__FILE__) . '::' . __LINE__);
Helper::error_log($query);
// We have failed hard, at least let get something.
$the_query = new \WP_Query();
}
$this->_query = $the_query;
}