Commit 1501b218 authored by Bruno Antunes Magrini's avatar Bruno Antunes Magrini

Separarate functions from view file on posts-list widget and most-read-posts-list

parent 1ebd9c62
......@@ -30,7 +30,11 @@ class MostReadPostsList extends PostsList {
$most_read_query = new \WP_Query($posts_query_args);
return [
'query' => $most_read_query,
'link' => (object) $instance['link']
'link' => (object) $instance['link'],
'show_excerpt' => $instance['show_excerpt'],
'hide_categories' => $instance['hide_categories'],
'css_classes' => $instance['css_class'],
'show_images' => $instance['show_images']
];
}
}
......
<?php
use guaraci\images;
$show_images = $instance['show_images'];
$show_excerpt = $instance['show_excerpt'];
$hide_categories = $instance['hide_categories'];
$css_classes = $instance['css_class'];
$i = 0;
?>
<div class="posts-list <?= $css_classes ?>">
......
......@@ -98,9 +98,15 @@ class PostsList extends \SiteOrigin_Widget {
function get_template_variables($instance, $args) {
$posts_query_args = siteorigin_widget_post_selector_process_query($instance['conteudo']);
$query = new \WP_Query($posts_query_args);
return [
'query_args' => $posts_query_args,
'link' => (object) $instance['link']
'query' => $query,
'link' => (object) $instance['link'],
'show_excerpt' => $instance['show_excerpt'],
'hide_categories' => $instance['hide_categories'],
'css_classes' => $instance['css_class'],
'show_images' => $instance['show_images']
];
}
}
......
<?php
use guaraci\images;
$show_images = $instance['show_images'];
$show_excerpt = $instance['show_excerpt'];
$hide_categories = $instance['hide_categories'];
$css_classes = $instance['css_class'];
$query = new WP_Query($query_args);
$link = $instance['link'];
$i = 0;
?>
<div class="posts-list <?= $css_classes ?>">
......@@ -57,9 +50,9 @@ $i = 0;
wp_reset_postdata();
?>
</div>
<?php if($link['url']): ?>
<?php if($link->url): ?>
<div class="read-more" >
<a class="read-more-link" href="<?= $link['url'] ?>" class="goto"><?= $link['label'] ?></a>
<a class="read-more-link" href="<?= $link->url ?>" class="goto"><?= $link->label ?></a>
</div>
<?php endif; ?>
</div>
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