PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 2.15.2
Shortcodes and extra features for Phlox theme v2.15.2
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 3 years ago accordion-widget.php 3 years ago accordion.php 3 years ago attachment-url.php 3 years ago audio.php 3 years ago before-after.php 3 years ago button.php 3 years ago code.php 3 years ago contact-box.php 3 years ago contact-form.php 3 years ago custom-list.php 3 years ago divider.php 3 years ago dropcap.php 3 years ago facebook.php 3 years ago flickr.php 3 years ago gallery.php 3 years ago gmap.php 3 years ago highlight.php 3 years ago image.php 3 years ago instagram-feed.php 3 years ago latest-posts-slider.php 3 years ago popular-posts-widget.php 3 years ago products-grid.php 2 years ago quote.php 3 years ago recent-posts-grid-carousel.php 2 years ago recent-posts-land-style.php 2 years ago recent-posts-masonry.php 2 years ago recent-posts-tiles-carousel.php 2 years ago recent-posts-tiles.php 2 years ago recent-posts-timeline.php 2 years ago recent-posts-widget.php 3 years ago recent-products.php 2 years ago related-posts.php 8 years ago sample-element.php 3 years ago search.php 3 years ago socials-list.php 3 years ago staff.php 3 years ago tab-widget.php 3 years ago tabs.php 3 years ago testimonial.php 3 years ago text.php 3 years ago touch-slider.php 3 years ago video.php 3 years ago
popular-posts-widget.php
405 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-2023 averta
11 */
12
13 function auxin_get_popular_post_widget_master_array( $master_array ) {
14
15 $categories = get_terms( 'category', 'orderby=count&hide_empty=0' );
16 $categories_list = array( '' => __('All Categories', 'auxin-elements' ) );
17 foreach ( $categories as $key => $value ) {
18 $categories_list[$value->term_id] = $value->name;
19 }
20
21
22 $master_array['aux_popular_posts_widget'] = array(
23 'name' => __('Popular Posts Widget', 'auxin-elements' ),
24 'auxin_output_callback' => 'auxin_widget_popular_post_widget_callback',
25 'base' => 'aux_popular_posts_widget',
26 'description' => __('Shows popular and most commented posts with thumbnail.', 'auxin-elements' ),
27 'class' => 'aux-widget-popular-posts-widget',
28 'show_settings_on_create' => true,
29 'weight' => 1,
30 'is_widget' => true,
31 'is_shortcode' => false,
32 'category' => THEME_NAME,
33 'group' => '',
34 'admin_enqueue_js' => '',
35 'admin_enqueue_css' => '',
36 'front_enqueue_js' => '',
37 'front_enqueue_css' => '',
38 'icon' => 'aux-element aux-pb-icons-code',
39 'custom_markup' => '',
40 'js_view' => '',
41 'html_template' => '',
42 'deprecated' => '',
43 'content_element' => '',
44 'as_parent' => '',
45 'as_child' => '',
46 'params' => array(
47 array(
48 'heading' => __('Title','auxin-elements' ),
49 'description' => '',
50 'param_name' => 'title',
51 'type' => 'textfield',
52 'std' => '',
53 'value' => '',
54 'holder' => 'textfield',
55 'class' => 'title',
56 'admin_label' => true,
57 'dependency' => '',
58 'weight' => '',
59 'group' => '' ,
60 'edit_field_class' => ''
61 ),
62 array(
63 'heading' => __('Number of posts to show', 'auxin-elements'),
64 'description' => '',
65 'param_name' => 'num',
66 'type' => 'dropdown',
67 'def_value' => '4',
68 'holder' => '',
69 'class' => 'num',
70 'value' => array(
71 '1' => '1' , '2' => '2' , '3' => '3' ,
72 '4' => '4' , '5' => '5' , '6' => '6',
73 '7' => '7' , '8' => '8' , '9' => '9' ,
74 '10' => '10','11' => '11' ,'12' => '12'
75 ),
76 'admin_label' => true,
77 'dependency' => '',
78 'weight' => '',
79 'group' => '' ,
80 'edit_field_class' => ''
81 ),
82
83 array(
84 'heading' => __( 'Display popular tab', 'auxin-elements' ),
85 'description' => __( 'Enable it to display the most popular posts.', 'auxin-elements' ),
86 'param_name' => 'show_popular',
87 'type' => 'aux_switch',
88 'def_value' => '',
89 'value' => '1',
90 'holder' => '',
91 'class' => 'show_popular',
92 'admin_label' => true,
93 'dependency' => '',
94 'weight' => '',
95 'group' => '' ,
96 'edit_field_class' => ''
97 ),
98 array(
99 'heading' => __( 'Display recent tab', 'auxin-elements' ),
100 'description' => __( 'Enable it to display the most recent posts.', 'auxin-elements' ),
101 'param_name' => 'show_recent',
102 'type' => 'aux_switch',
103 'def_value' => '',
104 'value' => '1',
105 'holder' => '',
106 'class' => 'show_recent',
107 'admin_label' => true,
108 'dependency' => '',
109 'weight' => '',
110 'group' => '' ,
111 'edit_field_class' => ''
112 ),
113 array(
114 'heading' => __( 'Display comment tab', 'auxin-elements' ),
115 'description' => __( 'Enable it to display the most commented posts.', 'auxin-elements' ),
116 'param_name' => 'show_comment',
117 'type' => 'aux_switch',
118 'def_value' => '',
119 'value' => '1',
120 'holder' => '',
121 'class' => 'show_comment',
122 'admin_label' => true,
123 'dependency' => '',
124 'weight' => '',
125 'group' => '' ,
126 'edit_field_class' => ''
127 ),
128 array(
129 'heading' => __('Display image', 'auxin-elements' ),
130 'description' => __('Enable it to display images as well.','auxin-elements' ),
131 'param_name' => 'show_media',
132 'type' => 'aux_switch',
133 'def_value' => '',
134 'value' => '1',
135 'holder' => '',
136 'class' => 'show_media',
137 'admin_label' => true,
138 'dependency' => '',
139 'weight' => '',
140 'group' => '' ,
141 'edit_field_class' => ''
142 ),
143 array(
144 'heading' => __('Display excerpt','auxin-elements' ),
145 'description' => __('Enable it to display post summary instead of full content.','auxin-elements' ),
146 'param_name' => 'show_excerpt',
147 'type' => 'aux_switch',
148 'def_value' => '',
149 'value' => '1',
150 'holder' => '',
151 'class' => 'show_excerpt',
152 'admin_label' => 1,
153 'dependency' => '',
154 'weight' => '',
155 'group' => '' ,
156 'edit_field_class' => ''
157 ),
158 array(
159 'heading' => __('Display post date','auxin-elements' ),
160 'param_name' => 'show_date',
161 'type' => 'aux_switch',
162 'def_value' => '',
163 'value' => '1',
164 'holder' => '',
165 'class' => 'show_date',
166 'admin_label' => 1,
167 'dependency' => '',
168 'weight' => '',
169 'group' => '' ,
170 'edit_field_class' => ''
171 ),
172 array(
173 'heading' => __('Excerpt length','auxin-elements' ),
174 'description' => __('Specify summary content in character','auxin-elements' ),
175 'param_name' => 'excerpt_len',
176 'type' => 'textfield',
177 'value' => '60',
178 'holder' => 'textfield',
179 'class' => 'excerpt_len',
180 'admin_label' => 1,
181 'dependency' => '',
182 'weight' => '',
183 'group' => '' ,
184 'edit_field_class' => ''
185 ),
186 array(
187 'heading' => __('Order by', 'auxin-elements'),
188 'description' => '',
189 'param_name' => 'order_by',
190 'type' => 'dropdown',
191 'def_value' => 'date',
192 'holder' => 'dropdown',
193 'class' => 'order_by',
194 'value' => array (
195 'date' => __('Date', 'auxin-elements'),
196 'menu_order date' => __('Menu Order', 'auxin-elements'),
197 'title' => __('Title', 'auxin-elements'),
198 'ID' => __('ID', 'auxin-elements'),
199 'rand' => __('Random', 'auxin-elements'),
200 'comment_count' => __('Comments', 'auxin-elements'),
201 'modified' => __('Date Modified', 'auxin-elements'),
202 'author' => __('Author', 'auxin-elements'),
203 ),
204 'admin_label' => true,
205 'dependency' => '',
206 'weight' => '',
207 'group' => '' ,
208 'edit_field_class' => ''
209 ),
210 array(
211 'heading' => __('Order', 'auxin-elements'),
212 'description' => '',
213 'param_name' => 'order',
214 'type' => 'dropdown',
215 'def_value' => 'DESC',
216 'holder' => 'dropdown',
217 'class' => 'order',
218 'value' =>array (
219 'DESC' => __('Descending', 'auxin-elements'),
220 'ASC' => __('Ascending', 'auxin-elements'),
221 ),
222 'admin_label' => true,
223 'dependency' => '',
224 'weight' => '',
225 'group' => '' ,
226 'edit_field_class' => ''
227 ),
228 array(
229 'param_name' => 'cat',
230 'type' => 'dropdown',
231 'def_value' => 'default',
232 'holder' => 'dropdown',
233 'class' => 'cat',
234 'heading' => __('Categories', 'auxin-elements'),
235 'description' => __('specify a categories that you want.', 'auxin-elements' ),
236 'value' => $categories_list,
237 'admin_label' => true,
238 'dependency' => '',
239 'weight' => '',
240 'group' => '' ,
241 'edit_field_class' => ''
242 ),
243 // array(
244 // 'param_name' => 'tag',
245 // 'type' => 'dropdown',
246 // 'def_value' => '',
247 // 'holder' => '',
248 // 'class' => 'tag',
249 // 'heading' => __('Tags', 'auxin-elements'),
250 // 'description' => __('specify a tags that you want.', 'auxin-elements' ),
251 // 'value' => $tags_list,
252 // 'admin_label' => true,
253 // 'dependency' => '',
254 // 'weight' => '',
255 // 'group' => '' ,
256 // 'edit_field_class' => ''
257 // ),
258 array(
259 'heading' => __('Extra class name','auxin-elements' ),
260 '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' ),
261 'param_name' => 'extra_classes',
262 'type' => 'textfield',
263 'value' => '',
264 'def_value' => '',
265 'holder' => 'textfield',
266 'class' => 'extra_classes',
267 'admin_label' => true,
268 'dependency' => '',
269 'weight' => '',
270 'group' => '',
271 'edit_field_class' => ''
272 )
273 )
274 );
275
276 return $master_array;
277 }
278
279 add_filter( 'auxin_master_array_shortcodes', 'auxin_get_popular_post_widget_master_array', 10, 1 );
280
281
282
283
284 /**
285 * Element without loop and column
286 * The front-end output of this element is returned by the following function
287 *
288 * @param array $atts The array containing the parsed values from shortcode, it should be same as defined params above.
289 * @param string $shortcode_content The shorcode content
290 * @return string The output of element markup
291 */
292 function auxin_widget_popular_post_widget_callback( $atts, $shortcode_content = null ){
293
294 // Defining default attributes
295 $default_atts = array(
296 'title' => '', // header title
297 'num' => '4',
298
299 'show_recent' => 1,
300 'show_popular' => 1,
301 'show_comment' => 1,
302
303 'show_media' => 1,
304 'show_excerpt' => 1,
305 'show_date' => 1,
306 'excerpt_len' => '60',
307 'order' => 'desc',
308 'order_by' => 'date',
309 'cat' => '',
310 'tag' => '',
311 'extra_classes' => '',
312 'custom_el_id' => '',
313 'base_class' => 'aux-widget-popular-posts-widget'
314 );
315
316 // the parsed widget params
317 $result = auxin_get_widget_scafold( $atts, $default_atts, $shortcode_content );
318 $output = '';
319
320 // wp_query args to get recent posts
321 $recent_args = array(
322 'post_type' => 'post',
323 'orderby' => 'date',
324 'order' => 'desc',
325 'post_status' => 'publish',
326 'posts_per_page' => $result['parsed_atts']['num'],
327 'cat' => $result['parsed_atts']['cat'],
328 // 'tag_id' => $tag,
329 'ignore_sticky_posts' => 1
330 );
331
332 // wp_query args to get popular posts
333 $popular_args = array(
334 'post_type' => 'post',
335 'orderby' => 'comment_count',
336 'order' => 'desc',
337 'post_status' => 'publish',
338 'posts_per_page' => $result['parsed_atts']['num'],
339 'cat' => $result['parsed_atts']['cat'],
340 // 'tag_id' => $tag,
341 'ignore_sticky_posts' => 1
342 );
343
344 // wp_query args to get most commented posts
345 $comment_args = array(
346 'post_type' => 'post',
347 'orderby' => 'comment_count',
348 'order' => 'desc',
349 'post_status' => 'publish',
350 'posts_per_page' => $result['parsed_atts']['num'],
351 'cat' => $result['parsed_atts']['cat'],
352 // 'tag_id' => $tag,
353 'ignore_sticky_posts' => 1
354 );
355
356 // @TODO
357 $result['parsed_atts']['show_format'] = false;
358
359 $tabs_display = array(
360 $result['parsed_atts']['show_popular'],
361 $result['parsed_atts']['show_recent'],
362 $result['parsed_atts']['show_comment']
363 );
364
365 // count the number of enabled tabs
366 $tabs_count = 0;
367 foreach ( $tabs_display as $value) {
368 if( $value ){
369 $tabs_count++;
370 }
371 }
372
373 $widget_class = $tabs_count > 1 ? 'widget-tabs aux-stripe aux-fill' : '';
374
375 // widget header ------------------------------
376 $output .= $result['widget_header'];
377 $output .= $result['widget_title'];
378
379
380 $output .= '<div class="'. esc_attr( $widget_class ) .'"><div class="widget-inner">';
381
382 // only display tabs if more that one tab is enabled
383 if( $tabs_count > 1 ){
384 $output .= '<ul class="tabs">';
385 $output .= $result['parsed_atts']['show_popular'] ? '<li><a href="#">'. __( 'Popular', 'auxin-elements' ) .'</a></li>' : '';
386 $output .= $result['parsed_atts']['show_recent' ] ? '<li><a href="#">'. __( 'Recent' , 'auxin-elements' ) .'</a></li>' : '';
387 $output .= $result['parsed_atts']['show_comment'] ? '<li><a href="#">'. __( 'Comment', 'auxin-elements' ) .'</a></li>' : '';
388 $output .= '</ul>';
389 }
390 $output .= '<ul class="tabs-content">';
391 $output .= $result['parsed_atts']['show_popular'] ?
392 '<li>' . auxin_get_post_type_markup( $popular_args, 'templates/theme-parts/entry/widget-recent-post.php', $result['parsed_atts'] ) . '</li>' : '';
393 $output .= $result['parsed_atts']['show_recent' ] ?
394 '<li>' . auxin_get_post_type_markup( $recent_args , 'templates/theme-parts/entry/widget-recent-post.php', $result['parsed_atts'] ) . '</li>' : '';
395 $output .= $result['parsed_atts']['show_comment'] ?
396 '<li>' . auxin_get_post_type_markup( $comment_args, 'templates/theme-parts/entry/widget-recent-post.php', $result['parsed_atts'] ) . '</li>' : '';
397 $output .= '</ul>';
398 $output .= '</div></div>';
399
400 // widget footer ------------------------------
401 $output .= $result['widget_footer'];
402
403 return $output;
404 }
405