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