PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 2.5.13
Shortcodes and extra features for Phlox theme v2.5.13
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 / elementor / widgets / recent-comments.php
auxin-elements / includes / elementor / widgets Last commit date
theme-elements 6 years ago accordion.php 6 years ago audio.php 6 years ago before-after.php 6 years ago button.php 6 years ago carousel-navigation.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 gallery.php 6 years ago gmap.php 6 years ago heading-modern.php 6 years ago icon.php 6 years ago image.php 6 years ago mailchimp.php 6 years ago modern-button.php 6 years ago quote.php 6 years ago recent-comments.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-products.php 6 years ago responsive-table.php 6 years ago search.php 6 years ago staff.php 6 years ago svg.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
recent-comments.php
445 lines
1 <?php
2 namespace Auxin\Plugin\CoreElements\Elementor\Elements;
3
4 use Elementor\Plugin;
5 use Elementor\Widget_Base;
6 use Elementor\Controls_Manager;
7 use Elementor\Group_Control_Typography;
8 use Elementor\Scheme_Typography;
9
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit; // Exit if accessed directly.
13 }
14
15 /**
16 * Elementor 'RecentComments' widget.
17 *
18 * Elementor widget that displays an 'RecentComments' with lightbox.
19 *
20 * @since 1.0.0
21 */
22 class RecentComments extends Widget_Base {
23
24 /**
25 * Get widget name.
26 *
27 * Retrieve 'RecentComments' widget name.
28 *
29 * @since 1.0.0
30 * @access public
31 *
32 * @return string Widget name.
33 */
34 public function get_name() {
35 return 'aux_recentcomments';
36 }
37
38 /**
39 * Get widget title.
40 *
41 * Retrieve 'RecentComments' widget title.
42 *
43 * @since 1.0.0
44 * @access public
45 *
46 * @return string Widget title.
47 */
48 public function get_title() {
49 return __('Recent Commented Posts', 'auxin-elements' );
50 }
51
52 /**
53 * Get widget icon.
54 *
55 * Retrieve 'RecentComments' widget icon.
56 *
57 * @since 1.0.0
58 * @access public
59 *
60 * @return string Widget icon.
61 */
62 public function get_icon() {
63 return 'eicon-comments auxin-badge';
64 }
65
66 /**
67 * Get recent comments.
68 *
69 * Retrieve 'RecentComments' widget query.
70 *
71 * @since 1.0.0
72 * @access public
73 *
74 * @return array Query.
75 */
76 public function get_post_types( $args = array() ) {
77 // Result variable
78 $result = array( 'all' => __( 'All Post Types', 'auxin-elements' ) );
79 // Get all public post types
80 $get_post_types = get_post_types( array(
81 'public' => true,
82 'exclude_from_search' => false
83 )
84 );
85 foreach ( $get_post_types as $key => $value ) {
86 $result[ $key ] = ucfirst( $value );
87 }
88
89 return $result;
90 }
91
92 /**
93 * Get widget categories.
94 *
95 * Retrieve 'RecentComments' widget icon.
96 *
97 * @since 1.0.0
98 * @access public
99 *
100 * @return string Widget icon.
101 */
102 public function get_categories() {
103 return array( 'auxin-core' );
104 }
105
106 /**
107 * Register 'RecentComments' widget controls.
108 *
109 * Adds different input fields to allow the user to change and customize the widget settings.
110 *
111 * @since 1.0.0
112 * @access protected
113 */
114 protected function _register_controls() {
115
116 /*-----------------------------------------------------------------------------------*/
117 /* Content TAB
118 /*-----------------------------------------------------------------------------------*/
119
120 $this->start_controls_section(
121 'general',
122 array(
123 'label' => __('General', 'auxin-elements' ),
124 )
125 );
126
127 $this->add_control(
128 'post_types',
129 array(
130 'label' => __( 'Post Types', 'auxin-elements' ),
131 'label_block' => true,
132 'type' => Controls_Manager::SELECT,
133 'default' => 0,
134 'options' => $this->get_post_types()
135 )
136 );
137
138 $this->add_control(
139 'number',
140 array(
141 'label' => __('Number of comments to show', 'auxin-elements'),
142 'label_block' => true,
143 'type' => Controls_Manager::NUMBER,
144 'default' => '8',
145 'min' => 1,
146 'step' => 1
147 )
148 );
149
150 $this->add_control(
151 'show_info',
152 array(
153 'label' => __('Display info','auxin-elements' ),
154 'type' => Controls_Manager::SWITCHER,
155 'label_on' => __( 'On', 'auxin-elements' ),
156 'label_off' => __( 'Off', 'auxin-elements' ),
157 'return_value' => 'yes',
158 'default' => 'yes'
159 )
160 );
161
162 $this->end_controls_section();
163
164 /*-----------------------------------------------------------------------------------*/
165 /* title_style_section
166 /*-----------------------------------------------------------------------------------*/
167
168 $this->start_controls_section(
169 'title_style_section',
170 array(
171 'label' => __( 'Title', 'auxin-elements' ),
172 'tab' => Controls_Manager::TAB_STYLE
173 )
174 );
175
176 $this->start_controls_tabs( 'title_colors' );
177
178 $this->start_controls_tab(
179 'title_color_normal',
180 array(
181 'label' => __( 'Normal' , 'auxin-elements' )
182 )
183 );
184
185 $this->add_control(
186 'title_color',
187 array(
188 'label' => __( 'Color', 'auxin-elements' ),
189 'type' => Controls_Manager::COLOR,
190 'selectors' => array(
191 '{{WRAPPER}} .entry-title a' => 'color: {{VALUE}};',
192 )
193 )
194 );
195
196 $this->end_controls_tab();
197
198 $this->start_controls_tab(
199 'title_color_hover',
200 array(
201 'label' => __( 'Hover' , 'auxin-elements' )
202 )
203 );
204
205 $this->add_control(
206 'title_hover_color',
207 array(
208 'label' => __( 'Color', 'auxin-elements' ),
209 'type' => Controls_Manager::COLOR,
210 'selectors' => array(
211 '{{WRAPPER}} .entry-title a:hover' => 'color: {{VALUE}};',
212 )
213 )
214 );
215
216 $this->end_controls_tab();
217
218 $this->end_controls_tabs();
219
220 $this->add_group_control(
221 Group_Control_Typography::get_type(),
222 array(
223 'name' => 'title_typography',
224 'scheme' => Scheme_Typography::TYPOGRAPHY_1,
225 'selector' => '{{WRAPPER}} .entry-title'
226 )
227 );
228
229 $this->add_responsive_control(
230 'title_margin_bottom',
231 array(
232 'label' => __( 'Bottom space', 'auxin-elements' ),
233 'type' => Controls_Manager::SLIDER,
234 'range' => array(
235 'px' => array(
236 'max' => 100,
237 ),
238 ),
239 'selectors' => array(
240 '{{WRAPPER}} .entry-title' => 'margin-bottom: {{SIZE}}{{UNIT}};',
241 )
242 )
243 );
244
245 $this->end_controls_section();
246
247 /*-----------------------------------------------------------------------------------*/
248 /* info_style_section
249 /*-----------------------------------------------------------------------------------*/
250
251 $this->start_controls_section(
252 'info_style_section',
253 array(
254 'label' => __( 'Meta Info', 'auxin-elements' ),
255 'tab' => Controls_Manager::TAB_STYLE
256 )
257 );
258
259 $this->start_controls_tabs( 'info_colors' );
260
261 $this->start_controls_tab(
262 'info_color_normal',
263 array(
264 'label' => __( 'Normal' , 'auxin-elements' )
265 )
266 );
267
268 $this->add_control(
269 'info_color',
270 array(
271 'label' => __( 'Color', 'auxin-elements' ),
272 'type' => Controls_Manager::COLOR,
273 'selectors' => array(
274 '{{WRAPPER}} .entry-info a, {{WRAPPER}} .entry-info' => 'color: {{VALUE}};',
275 )
276 )
277 );
278
279 $this->end_controls_tab();
280
281 $this->start_controls_tab(
282 'info_color_hover',
283 array(
284 'label' => __( 'Hover' , 'auxin-elements' )
285 )
286 );
287
288 $this->add_control(
289 'info_hover_color',
290 array(
291 'label' => __( 'Color', 'auxin-elements' ),
292 'type' => Controls_Manager::COLOR,
293 'selectors' => array(
294 '{{WRAPPER}} .entry-info a:hover' => 'color: {{VALUE}};',
295 )
296 )
297 );
298
299 $this->end_controls_tab();
300
301 $this->end_controls_tabs();
302
303 $this->add_group_control(
304 Group_Control_Typography::get_type(),
305 array(
306 'name' => 'info_typography',
307 'scheme' => Scheme_Typography::TYPOGRAPHY_1,
308 'selector' => '{{WRAPPER}} .entry-info, {{WRAPPER}} .entry-info a'
309 )
310 );
311
312 $this->add_responsive_control(
313 'info_margin_bottom',
314 array(
315 'label' => __( 'Bottom space', 'auxin-elements' ),
316 'type' => Controls_Manager::SLIDER,
317 'range' => array(
318 'px' => array(
319 'max' => 100
320 )
321 ),
322 'selectors' => array(
323 '{{WRAPPER}} .entry-info' => 'margin-bottom: {{SIZE}}{{UNIT}};'
324 )
325 )
326 );
327
328 $this->add_responsive_control(
329 'info_spacing_between',
330 array(
331 'label' => __( 'Space between metas', 'auxin-elements' ),
332 'type' => Controls_Manager::SLIDER,
333 'range' => array(
334 'px' => array(
335 'max' => 30
336 )
337 ),
338 'selectors' => array(
339 '{{WRAPPER}} .entry-info [class^="entry-"] + [class^="entry-"]:before, {{WRAPPER}} .entry-info .entry-tax a:after' =>
340 'margin-right: {{SIZE}}{{UNIT}}; margin-left: {{SIZE}}{{UNIT}};'
341 )
342 )
343 );
344
345 $this->end_controls_section();
346
347 }
348
349
350 /**
351 * Get recent comments.
352 *
353 * Retrieve 'RecentComments' widget query.
354 *
355 * @since 1.0.0
356 * @access public
357 *
358 * @return array Query.
359 */
360 public function get_comments( $args = array() ) {
361 // The Query
362 $comments_query = new WP_Comment_Query;
363 $comments = $comments_query->query( $args );
364 return $comments;
365 }
366
367 /**
368 * Render recentcomments widget output on the frontend.
369 *
370 * Written in PHP and used to generate the final HTML.
371 *
372 * @since 1.0.0
373 * @access protected
374 */
375 protected function render() {
376 $settings = $this->get_settings_for_display();
377 $query_args = array();
378
379 if( $settings['post_types'] !== 'all' ){
380 $query_args['post_type'] = $settings['post_types'];
381 }
382
383 if( isset( $settings['number'] ) ){
384 $query_args['number'] = $settings['number'];
385 }
386
387 $comments = auxin_get_comments( $query_args );
388
389 // Defining default attributes
390 $default_atts = array(
391 'title' => '',
392 'direction' => 'horizontal',
393 'size' => 'medium',
394
395 'extra_classes' => '',
396 'custom_el_id' => '',
397 'base_class' => 'aux-widget-recent-comments'
398 );
399
400 $result = auxin_get_widget_scafold( array(), $default_atts );
401 extract( $result['parsed_atts'] );
402
403 // widget header ------------------------------
404 echo $result['widget_header'];
405 echo $result['widget_title'];
406
407 if( empty( $comments ) ){
408 echo sprintf( '<p>%s<p>', __( 'No comments found!', 'auxin-elements' ) );
409 } else {
410 // widget output -----------------------
411 ob_start();
412 foreach ( $comments as $key => $comment ):
413 ?>
414 <div id="aux-comment-<?php echo esc_attr( $comment->comment_ID ); ?>" class="aux-comment">
415 <div class="entry-header">
416 <h3 class="entry-title aux-h3">
417 <a href="<?php echo get_comment_link( $comment->comment_ID ); ?>" title="<?php echo esc_attr( get_the_title( $comment->comment_post_ID ) ); ?>">
418 <?php echo get_the_title( $comment->comment_post_ID ); ?>
419 </a>
420 </h3>
421 </div>
422 <?php if( isset( $settings['show_info'] ) && auxin_is_true( $settings['show_info'] ) ) : ?>
423 <div class="entry-info">
424 <div class="entry-date">
425 <?php echo human_time_diff( strtotime( $comment->comment_date_gmt ) ) . ' ' . __( 'Ago', 'auxin-elements' ); ?>
426 </div>
427 <div class="entry-author">
428 <span class="meta-sep"><?php echo __( 'By', 'auxin-elements' ); ?></span>
429 <span class="author vcard"><?php echo esc_html( $comment->comment_author ); ?></span>
430 </div>
431 </div>
432 <?php endif; ?>
433 </div>
434 <?php
435 endforeach;
436 echo ob_get_clean();
437 }
438
439 // widget footer ------------------------------
440 echo $result['widget_footer'];
441
442 }
443
444 }
445