PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / trunk
Shortcodes and extra features for Phlox theme vtrunk
2.17.21 2.17.20 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.6 1.0.9 1.1.0 1.3.0 1.3.1 1.3.10 1.3.14 1.3.2 1.3.3 1.3.6 1.4.0 1.4.1 1.4.2 1.5.0 1.5.2 1.6.0 1.6.2 1.6.4 1.7.0 1.7.2 2.10.0 2.10.1 2.10.3 2.10.5 2.10.7 2.10.8 2.10.9 2.11.0 2.11.1 2.11.2 2.12.0 2.14.0 2.15.0 2.15.2 2.15.4 2.15.5 2.15.6 2.15.7 2.15.8 2.15.9 2.16.0 2.16.1 2.16.2 2.16.3 2.16.4 2.17.0 2.17.1 2.17.12 2.17.13 2.17.14 2.17.15 2.17.16 2.17.2 2.17.3 2.17.4 2.17.5 2.17.6 2.17.8 2.17.9 2.4.12 2.4.13 2.4.14 2.4.16 2.4.18 2.4.19 2.4.9 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.14 2.5.15 2.5.16 2.5.17 2.5.19 2.5.2 2.5.20 2.5.3 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.10 2.6.12 2.6.13 2.6.14 2.6.15 2.6.16 2.6.17 2.6.19 2.6.2 2.6.20 2.6.4 2.6.5 2.6.7 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.9 2.9.0 2.9.12 2.9.14 2.9.15 2.9.16 2.9.17 2.9.18 2.9.19 2.9.2 2.9.20 2.9.21 2.9.22 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8
auxin-elements / includes / elements / popular-posts-widget.php
auxin-elements / includes / elements Last commit date
about-widget.php 5 months ago accordion-widget.php 1 month ago accordion.php 5 months ago attachment-url.php 5 months ago audio.php 5 months ago before-after.php 5 months ago button.php 5 months ago code.php 5 months ago contact-box.php 5 months ago contact-form.php 5 months ago custom-list.php 5 months ago divider.php 5 months ago dropcap.php 5 months ago facebook.php 5 months ago flickr.php 5 months ago gallery.php 5 months ago gmap.php 5 months ago highlight.php 5 months ago image.php 5 months ago instagram-feed.php 5 months ago latest-posts-slider.php 5 months ago popular-posts-widget.php 5 months ago products-grid.php 5 months ago quote.php 5 months ago recent-posts-grid-carousel.php 5 months ago recent-posts-land-style.php 5 months ago recent-posts-masonry.php 5 months ago recent-posts-tiles-carousel.php 5 months ago recent-posts-tiles.php 5 months ago recent-posts-timeline.php 5 months ago recent-posts-widget.php 5 months ago recent-products.php 5 months ago related-posts.php 8 years ago sample-element.php 5 months ago search.php 5 months ago socials-list.php 5 months ago staff.php 5 months ago tab-widget.php 5 months ago tabs.php 5 months ago testimonial.php 5 months ago text.php 5 months ago touch-slider.php 5 months ago video.php 5 months ago
popular-posts-widget.php
409 lines
1 <?php
2 /**
3 * Code highlighter element
4 *
5 *
6 * @package Auxin
7 * @license LICENSE.txt
8 * @author averta
9 * @link http://phlox.pro/
10 * @copyright (c) 2010-2026 averta
11 */
12
13 function auxin_get_popular_post_widget_master_array( $master_array ) {
14
15 $categories = get_terms([
16 'taxonomy' => 'category',
17 'orderby' => 'count',
18 'hide_empty' => false,
19 ]);
20 $categories_list = array( '' => __('All Categories', 'auxin-elements' ) );
21 foreach ( $categories as $key => $value ) {
22 $categories_list[$value->term_id] = $value->name;
23 }
24
25
26 $master_array['aux_popular_posts_widget'] = array(
27 'name' => __('Popular Posts Widget', 'auxin-elements' ),
28 'auxin_output_callback' => 'auxin_widget_popular_post_widget_callback',
29 'base' => 'aux_popular_posts_widget',
30 'description' => __('Shows popular and most commented posts with thumbnail.', 'auxin-elements' ),
31 'class' => 'aux-widget-popular-posts-widget',
32 'show_settings_on_create' => true,
33 'weight' => 1,
34 'is_widget' => true,
35 'is_shortcode' => false,
36 'category' => THEME_NAME,
37 'group' => '',
38 'admin_enqueue_js' => '',
39 'admin_enqueue_css' => '',
40 'front_enqueue_js' => '',
41 'front_enqueue_css' => '',
42 'icon' => 'aux-element aux-pb-icons-code',
43 'custom_markup' => '',
44 'js_view' => '',
45 'html_template' => '',
46 'deprecated' => '',
47 'content_element' => '',
48 'as_parent' => '',
49 'as_child' => '',
50 'params' => array(
51 array(
52 'heading' => __('Title','auxin-elements' ),
53 'description' => '',
54 'param_name' => 'title',
55 'type' => 'textfield',
56 'std' => '',
57 'value' => '',
58 'holder' => 'textfield',
59 'class' => 'title',
60 'admin_label' => true,
61 'dependency' => '',
62 'weight' => '',
63 'group' => '' ,
64 'edit_field_class' => ''
65 ),
66 array(
67 'heading' => __('Number of posts to show', 'auxin-elements'),
68 'description' => '',
69 'param_name' => 'num',
70 'type' => 'dropdown',
71 'def_value' => '4',
72 'holder' => '',
73 'class' => 'num',
74 'value' => array(
75 '1' => '1' , '2' => '2' , '3' => '3' ,
76 '4' => '4' , '5' => '5' , '6' => '6',
77 '7' => '7' , '8' => '8' , '9' => '9' ,
78 '10' => '10','11' => '11' ,'12' => '12'
79 ),
80 'admin_label' => true,
81 'dependency' => '',
82 'weight' => '',
83 'group' => '' ,
84 'edit_field_class' => ''
85 ),
86
87 array(
88 'heading' => __( 'Display popular tab', 'auxin-elements' ),
89 'description' => __( 'Enable it to display the most popular posts.', 'auxin-elements' ),
90 'param_name' => 'show_popular',
91 'type' => 'aux_switch',
92 'def_value' => '',
93 'value' => '1',
94 'holder' => '',
95 'class' => 'show_popular',
96 'admin_label' => true,
97 'dependency' => '',
98 'weight' => '',
99 'group' => '' ,
100 'edit_field_class' => ''
101 ),
102 array(
103 'heading' => __( 'Display recent tab', 'auxin-elements' ),
104 'description' => __( 'Enable it to display the most recent posts.', 'auxin-elements' ),
105 'param_name' => 'show_recent',
106 'type' => 'aux_switch',
107 'def_value' => '',
108 'value' => '1',
109 'holder' => '',
110 'class' => 'show_recent',
111 'admin_label' => true,
112 'dependency' => '',
113 'weight' => '',
114 'group' => '' ,
115 'edit_field_class' => ''
116 ),
117 array(
118 'heading' => __( 'Display comment tab', 'auxin-elements' ),
119 'description' => __( 'Enable it to display the most commented posts.', 'auxin-elements' ),
120 'param_name' => 'show_comment',
121 'type' => 'aux_switch',
122 'def_value' => '',
123 'value' => '1',
124 'holder' => '',
125 'class' => 'show_comment',
126 'admin_label' => true,
127 'dependency' => '',
128 'weight' => '',
129 'group' => '' ,
130 'edit_field_class' => ''
131 ),
132 array(
133 'heading' => __('Display image', 'auxin-elements' ),
134 'description' => __('Enable it to display images as well.','auxin-elements' ),
135 'param_name' => 'show_media',
136 'type' => 'aux_switch',
137 'def_value' => '',
138 'value' => '1',
139 'holder' => '',
140 'class' => 'show_media',
141 'admin_label' => true,
142 'dependency' => '',
143 'weight' => '',
144 'group' => '' ,
145 'edit_field_class' => ''
146 ),
147 array(
148 'heading' => __('Display excerpt','auxin-elements' ),
149 'description' => __('Enable it to display post summary instead of full content.','auxin-elements' ),
150 'param_name' => 'show_excerpt',
151 'type' => 'aux_switch',
152 'def_value' => '',
153 'value' => '1',
154 'holder' => '',
155 'class' => 'show_excerpt',
156 'admin_label' => 1,
157 'dependency' => '',
158 'weight' => '',
159 'group' => '' ,
160 'edit_field_class' => ''
161 ),
162 array(
163 'heading' => __('Display post date','auxin-elements' ),
164 'param_name' => 'show_date',
165 'type' => 'aux_switch',
166 'def_value' => '',
167 'value' => '1',
168 'holder' => '',
169 'class' => 'show_date',
170 'admin_label' => 1,
171 'dependency' => '',
172 'weight' => '',
173 'group' => '' ,
174 'edit_field_class' => ''
175 ),
176 array(
177 'heading' => __('Excerpt length','auxin-elements' ),
178 'description' => __('Specify summary content in character','auxin-elements' ),
179 'param_name' => 'excerpt_len',
180 'type' => 'textfield',
181 'value' => '60',
182 'holder' => 'textfield',
183 'class' => 'excerpt_len',
184 'admin_label' => 1,
185 'dependency' => '',
186 'weight' => '',
187 'group' => '' ,
188 'edit_field_class' => ''
189 ),
190 array(
191 'heading' => __('Order by', 'auxin-elements'),
192 'description' => '',
193 'param_name' => 'order_by',
194 'type' => 'dropdown',
195 'def_value' => 'date',
196 'holder' => 'dropdown',
197 'class' => 'order_by',
198 'value' => array (
199 'date' => __('Date', 'auxin-elements'),
200 'menu_order date' => __('Menu Order', 'auxin-elements'),
201 'title' => __('Title', 'auxin-elements'),
202 'ID' => __('ID', 'auxin-elements'),
203 'rand' => __('Random', 'auxin-elements'),
204 'comment_count' => __('Comments', 'auxin-elements'),
205 'modified' => __('Date Modified', 'auxin-elements'),
206 'author' => __('Author', 'auxin-elements'),
207 ),
208 'admin_label' => true,
209 'dependency' => '',
210 'weight' => '',
211 'group' => '' ,
212 'edit_field_class' => ''
213 ),
214 array(
215 'heading' => __('Order', 'auxin-elements'),
216 'description' => '',
217 'param_name' => 'order',
218 'type' => 'dropdown',
219 'def_value' => 'DESC',
220 'holder' => 'dropdown',
221 'class' => 'order',
222 'value' =>array (
223 'DESC' => __('Descending', 'auxin-elements'),
224 'ASC' => __('Ascending', 'auxin-elements'),
225 ),
226 'admin_label' => true,
227 'dependency' => '',
228 'weight' => '',
229 'group' => '' ,
230 'edit_field_class' => ''
231 ),
232 array(
233 'param_name' => 'cat',
234 'type' => 'dropdown',
235 'def_value' => 'default',
236 'holder' => 'dropdown',
237 'class' => 'cat',
238 'heading' => __('Categories', 'auxin-elements'),
239 'description' => __('specify a categories that you want.', 'auxin-elements' ),
240 'value' => $categories_list,
241 'admin_label' => true,
242 'dependency' => '',
243 'weight' => '',
244 'group' => '' ,
245 'edit_field_class' => ''
246 ),
247 // array(
248 // 'param_name' => 'tag',
249 // 'type' => 'dropdown',
250 // 'def_value' => '',
251 // 'holder' => '',
252 // 'class' => 'tag',
253 // 'heading' => __('Tags', 'auxin-elements'),
254 // 'description' => __('specify a tags that you want.', 'auxin-elements' ),
255 // 'value' => $tags_list,
256 // 'admin_label' => true,
257 // 'dependency' => '',
258 // 'weight' => '',
259 // 'group' => '' ,
260 // 'edit_field_class' => ''
261 // ),
262 array(
263 'heading' => __('Extra class name','auxin-elements' ),
264 'description' => __('If you wish to style particular content element differently, then use this field to add a class name and then refer to it in your css file.', 'auxin-elements' ),
265 'param_name' => 'extra_classes',
266 'type' => 'textfield',
267 'value' => '',
268 'def_value' => '',
269 'holder' => 'textfield',
270 'class' => 'extra_classes',
271 'admin_label' => true,
272 'dependency' => '',
273 'weight' => '',
274 'group' => '',
275 'edit_field_class' => ''
276 )
277 )
278 );
279
280 return $master_array;
281 }
282
283 add_filter( 'auxin_master_array_shortcodes', 'auxin_get_popular_post_widget_master_array', 10, 1 );
284
285
286
287
288 /**
289 * Element without loop and column
290 * The front-end output of this element is returned by the following function
291 *
292 * @param array $atts The array containing the parsed values from shortcode, it should be same as defined params above.
293 * @param string $shortcode_content The shorcode content
294 * @return string The output of element markup
295 */
296 function auxin_widget_popular_post_widget_callback( $atts, $shortcode_content = null ){
297
298 // Defining default attributes
299 $default_atts = array(
300 'title' => '', // header title
301 'num' => '4',
302
303 'show_recent' => 1,
304 'show_popular' => 1,
305 'show_comment' => 1,
306
307 'show_media' => 1,
308 'show_excerpt' => 1,
309 'show_date' => 1,
310 'excerpt_len' => '60',
311 'order' => 'desc',
312 'order_by' => 'date',
313 'cat' => '',
314 'tag' => '',
315 'extra_classes' => '',
316 'custom_el_id' => '',
317 'base_class' => 'aux-widget-popular-posts-widget'
318 );
319
320 // the parsed widget params
321 $result = auxin_get_widget_scafold( $atts, $default_atts, $shortcode_content );
322 $output = '';
323
324 // wp_query args to get recent posts
325 $recent_args = array(
326 'post_type' => 'post',
327 'orderby' => 'date',
328 'order' => 'desc',
329 'post_status' => 'publish',
330 'posts_per_page' => $result['parsed_atts']['num'],
331 'cat' => $result['parsed_atts']['cat'],
332 // 'tag_id' => $tag,
333 'ignore_sticky_posts' => 1
334 );
335
336 // wp_query args to get popular posts
337 $popular_args = array(
338 'post_type' => 'post',
339 'orderby' => 'comment_count',
340 'order' => 'desc',
341 'post_status' => 'publish',
342 'posts_per_page' => $result['parsed_atts']['num'],
343 'cat' => $result['parsed_atts']['cat'],
344 // 'tag_id' => $tag,
345 'ignore_sticky_posts' => 1
346 );
347
348 // wp_query args to get most commented posts
349 $comment_args = array(
350 'post_type' => 'post',
351 'orderby' => 'comment_count',
352 'order' => 'desc',
353 'post_status' => 'publish',
354 'posts_per_page' => $result['parsed_atts']['num'],
355 'cat' => $result['parsed_atts']['cat'],
356 // 'tag_id' => $tag,
357 'ignore_sticky_posts' => 1
358 );
359
360 // @TODO
361 $result['parsed_atts']['show_format'] = false;
362
363 $tabs_display = array(
364 $result['parsed_atts']['show_popular'],
365 $result['parsed_atts']['show_recent'],
366 $result['parsed_atts']['show_comment']
367 );
368
369 // count the number of enabled tabs
370 $tabs_count = 0;
371 foreach ( $tabs_display as $value) {
372 if( $value ){
373 $tabs_count++;
374 }
375 }
376
377 $widget_class = $tabs_count > 1 ? 'widget-tabs aux-stripe aux-fill' : '';
378
379 // widget header ------------------------------
380 $output .= $result['widget_header'];
381 $output .= $result['widget_title'];
382
383
384 $output .= '<div class="'. esc_attr( $widget_class ) .'"><div class="widget-inner">';
385
386 // only display tabs if more that one tab is enabled
387 if( $tabs_count > 1 ){
388 $output .= '<ul class="tabs">';
389 $output .= $result['parsed_atts']['show_popular'] ? '<li><a href="#">'. __( 'Popular', 'auxin-elements' ) .'</a></li>' : '';
390 $output .= $result['parsed_atts']['show_recent' ] ? '<li><a href="#">'. __( 'Recent' , 'auxin-elements' ) .'</a></li>' : '';
391 $output .= $result['parsed_atts']['show_comment'] ? '<li><a href="#">'. __( 'Comment', 'auxin-elements' ) .'</a></li>' : '';
392 $output .= '</ul>';
393 }
394 $output .= '<ul class="tabs-content">';
395 $output .= $result['parsed_atts']['show_popular'] ?
396 '<li>' . auxin_get_post_type_markup( $popular_args, 'templates/theme-parts/entry/widget-recent-post.php', $result['parsed_atts'] ) . '</li>' : '';
397 $output .= $result['parsed_atts']['show_recent' ] ?
398 '<li>' . auxin_get_post_type_markup( $recent_args , 'templates/theme-parts/entry/widget-recent-post.php', $result['parsed_atts'] ) . '</li>' : '';
399 $output .= $result['parsed_atts']['show_comment'] ?
400 '<li>' . auxin_get_post_type_markup( $comment_args, 'templates/theme-parts/entry/widget-recent-post.php', $result['parsed_atts'] ) . '</li>' : '';
401 $output .= '</ul>';
402 $output .= '</div></div>';
403
404 // widget footer ------------------------------
405 $output .= $result['widget_footer'];
406
407 return $output;
408 }
409