Commit 83a72b77 authored by Isaque Melo's avatar Isaque Melo

Ignores post widget date parameters

parent ab4c7979
......@@ -11,23 +11,31 @@ if(!class_exists('\\AjaxPageviews')){
return;
}
class MostReadPostsList extends PostsList {
function __construct() {
parent::__construct('most-read-posts-list', 'Lista de posts Mais lidos', '', '', '', plugin_dir_path(__FILE__));
}
function get_template_variables($instance, $args) {
if (isset($instance['conteudo'])) {
parse_str($instance['conteudo'], $conteudo);
$date = json_decode($conteudo['date_query']);
function __construct() {
parent::__construct('most-read-posts-list', 'Lista de posts Mais lidos', '', '', '', plugin_dir_path(__FILE__));
}
$posts_query_args = siteorigin_widget_post_selector_process_query($instance['conteudo']);
$most_read = \AjaxPageviews::get_top_viewed(1000, ['post_type' => $conteudo['post_type'], 'from' => $date->after]);
$ids = array();
foreach ($most_read as $post => $value) {
array_push($ids, $value->post_id);
}
$posts_query_args['post__in'] = $ids;
$posts_query_args['orderby'] = 'post__in';
$most_read_query = new \WP_Query($posts_query_args);
function get_template_variables($instance, $args) {
if (isset($instance['conteudo'])) {
parse_str($instance['conteudo'], $conteudo);
}
$posts_query_args = siteorigin_widget_post_selector_process_query($instance['conteudo']);
$date = $posts_query_args['date_query'];
$posts_query_args['date_query'] = null;
$most_read = \AjaxPageviews::get_top_viewed(1000, ['post_type' => $conteudo['post_type'], 'from' => $date['after']]);
//var_dump($most_read);
$ids = array();
foreach ($most_read as $post => $value) {
array_push($ids, $value->post_id);
}
$posts_query_args['post__in'] = $ids;
$posts_query_args['orderby'] = 'post__in';
$most_read_query = new \WP_Query($posts_query_args);
return [
'query' => $most_read_query,
'link' => (object) $instance['link'],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment