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