PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 2.17.4
Shortcodes and extra features for Phlox theme v2.17.4
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 1 year ago accordion.php 1 year ago audio.php 4 years ago before-after.php 3 years ago button.php 1 year ago carousel-navigation.php 4 years ago circle-chart.php 1 year ago contact-box.php 4 years ago contact-form.php 1 year ago custom-list.php 1 year ago divider.php 4 years ago gallery.php 1 year ago gmap.php 4 years ago heading-modern.php 1 year ago icon.php 1 year ago image.php 1 year ago mailchimp.php 1 year ago modern-button.php 1 year ago products-grid.php 1 year ago quote.php 1 year ago recent-comments.php 1 year ago recent-posts-grid-carousel.php 1 year ago recent-posts-land-style.php 1 year ago recent-posts-masonry.php 1 year ago recent-posts-tiles-carousel.php 1 year ago recent-posts-tiles.php 1 year ago recent-posts-timeline.php 1 year ago recent-products.php 1 year ago responsive-table.php 1 year ago search.php 4 years ago staff.php 1 year ago svg.php 1 year ago tabs.php 1 year ago testimonial.php 1 year ago text.php 1 year ago touch-slider.php 1 year ago video.php 4 years ago
recent-comments.php
449 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\Core\Kits\Documents\Tabs\Global_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 'global' => [
225 'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
226 ],
227 'selector' => '{{WRAPPER}} .entry-title'
228 )
229 );
230
231 $this->add_responsive_control(
232 'title_margin_bottom',
233 array(
234 'label' => __( 'Bottom space', 'auxin-elements' ),
235 'type' => Controls_Manager::SLIDER,
236 'range' => array(
237 'px' => array(
238 'max' => 100,
239 ),
240 ),
241 'selectors' => array(
242 '{{WRAPPER}} .entry-title' => 'margin-bottom: {{SIZE}}{{UNIT}};',
243 )
244 )
245 );
246
247 $this->end_controls_section();
248
249 /*-----------------------------------------------------------------------------------*/
250 /* info_style_section
251 /*-----------------------------------------------------------------------------------*/
252
253 $this->start_controls_section(
254 'info_style_section',
255 array(
256 'label' => __( 'Meta Info', 'auxin-elements' ),
257 'tab' => Controls_Manager::TAB_STYLE
258 )
259 );
260
261 $this->start_controls_tabs( 'info_colors' );
262
263 $this->start_controls_tab(
264 'info_color_normal',
265 array(
266 'label' => __( 'Normal' , 'auxin-elements' )
267 )
268 );
269
270 $this->add_control(
271 'info_color',
272 array(
273 'label' => __( 'Color', 'auxin-elements' ),
274 'type' => Controls_Manager::COLOR,
275 'selectors' => array(
276 '{{WRAPPER}} .entry-info a, {{WRAPPER}} .entry-info' => 'color: {{VALUE}};',
277 )
278 )
279 );
280
281 $this->end_controls_tab();
282
283 $this->start_controls_tab(
284 'info_color_hover',
285 array(
286 'label' => __( 'Hover' , 'auxin-elements' )
287 )
288 );
289
290 $this->add_control(
291 'info_hover_color',
292 array(
293 'label' => __( 'Color', 'auxin-elements' ),
294 'type' => Controls_Manager::COLOR,
295 'selectors' => array(
296 '{{WRAPPER}} .entry-info a:hover' => 'color: {{VALUE}};',
297 )
298 )
299 );
300
301 $this->end_controls_tab();
302
303 $this->end_controls_tabs();
304
305 $this->add_group_control(
306 Group_Control_Typography::get_type(),
307 array(
308 'name' => 'info_typography',
309 'global' => [
310 'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
311 ],
312 'selector' => '{{WRAPPER}} .entry-info, {{WRAPPER}} .entry-info a'
313 )
314 );
315
316 $this->add_responsive_control(
317 'info_margin_bottom',
318 array(
319 'label' => __( 'Bottom space', 'auxin-elements' ),
320 'type' => Controls_Manager::SLIDER,
321 'range' => array(
322 'px' => array(
323 'max' => 100
324 )
325 ),
326 'selectors' => array(
327 '{{WRAPPER}} .entry-info' => 'margin-bottom: {{SIZE}}{{UNIT}};'
328 )
329 )
330 );
331
332 $this->add_responsive_control(
333 'info_spacing_between',
334 array(
335 'label' => __( 'Space between metas', 'auxin-elements' ),
336 'type' => Controls_Manager::SLIDER,
337 'range' => array(
338 'px' => array(
339 'max' => 30
340 )
341 ),
342 'selectors' => array(
343 '{{WRAPPER}} .entry-info [class^="entry-"] + [class^="entry-"]:before, {{WRAPPER}} .entry-info .entry-tax a:after' =>
344 'margin-right: {{SIZE}}{{UNIT}}; margin-left: {{SIZE}}{{UNIT}};'
345 )
346 )
347 );
348
349 $this->end_controls_section();
350
351 }
352
353
354 /**
355 * Get recent comments.
356 *
357 * Retrieve 'RecentComments' widget query.
358 *
359 * @since 1.0.0
360 * @access public
361 *
362 * @return array Query.
363 */
364 public function get_comments( $args = array() ) {
365 // The Query
366 $comments_query = new WP_Comment_Query;
367 $comments = $comments_query->query( $args );
368 return $comments;
369 }
370
371 /**
372 * Render recentcomments widget output on the frontend.
373 *
374 * Written in PHP and used to generate the final HTML.
375 *
376 * @since 1.0.0
377 * @access protected
378 */
379 protected function render() {
380 $settings = $this->get_settings_for_display();
381 $query_args = array();
382
383 if( $settings['post_types'] !== 'all' ){
384 $query_args['post_type'] = $settings['post_types'];
385 }
386
387 if( isset( $settings['number'] ) ){
388 $query_args['number'] = $settings['number'];
389 }
390
391 $comments = auxin_get_comments( $query_args );
392
393 // Defining default attributes
394 $default_atts = array(
395 'title' => '',
396 'direction' => 'horizontal',
397 'size' => 'medium',
398
399 'extra_classes' => '',
400 'custom_el_id' => '',
401 'base_class' => 'aux-widget-recent-comments'
402 );
403
404 $result = auxin_get_widget_scafold( array(), $default_atts );
405 extract( $result['parsed_atts'] );
406
407 // widget header ------------------------------
408 echo wp_kses_post( $result['widget_header'] );
409 echo wp_kses_post( $result['widget_title'] );
410
411 if( empty( $comments ) ){
412 echo sprintf( '<p>%s<p>', esc_html__( 'No comments found!', 'auxin-elements' ) );
413 } else {
414 // widget output -----------------------
415 ob_start();
416 foreach ( $comments as $key => $comment ):
417 ?>
418 <div id="aux-comment-<?php echo esc_attr( $comment->comment_ID ); ?>" class="aux-comment">
419 <div class="entry-header">
420 <h3 class="entry-title aux-h3">
421 <a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>" title="<?php echo esc_attr( get_the_title( $comment->comment_post_ID ) ); ?>">
422 <?php echo wp_kses_post( get_the_title( $comment->comment_post_ID ) ); ?>
423 </a>
424 </h3>
425 </div>
426 <?php if( isset( $settings['show_info'] ) && auxin_is_true( $settings['show_info'] ) ) : ?>
427 <div class="entry-info">
428 <div class="entry-date">
429 <?php echo human_time_diff( strtotime( $comment->comment_date_gmt ) ) . ' ' . esc_html__( 'Ago', 'auxin-elements' ); ?>
430 </div>
431 <div class="entry-author">
432 <span class="meta-sep"><?php echo esc_html__( 'By', 'auxin-elements' ); ?></span>
433 <span class="author vcard"><?php echo esc_html( $comment->comment_author ); ?></span>
434 </div>
435 </div>
436 <?php endif; ?>
437 </div>
438 <?php
439 endforeach;
440 echo ob_get_clean();
441 }
442
443 // widget footer ------------------------------
444 echo wp_kses_post( $result['widget_footer'] );
445
446 }
447
448 }
449