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