← All changes
|
modules/recent-comments/widgets/recent-comments.php
+40
-23
4.0.9
→
4.5.6
View file →
| @@ -382,9 +382,10 @@ | ||
| 382 | 382 | 'default' => ' @ ', |
| 383 | 383 | 'placeholder' => __( 'Enter your text', 'ultimate-post-kit' ), |
| 384 | 384 | 'label_block' => false, |
| 385 | 385 | 'condition' => [ |
| 386 | - 'show_author' => 'yes' | |
| 386 | + 'show_author' => 'yes', | |
| 387 | + 'show_title' => 'yes', | |
| 387 | 388 | ] |
| 388 | 389 | ] |
| 389 | 390 | ); |
| 390 | 391 | |
| @@ -506,8 +507,12 @@ | ||
| 506 | 507 | ], |
| 507 | 508 | [ |
| 508 | 509 | 'name' => 'show_date', |
| 509 | 510 | 'value' => 'yes' |
| 511 | + ], | |
| 512 | + [ | |
| 513 | + 'name' => 'show_title', | |
| 514 | + 'value' => 'yes' | |
| 510 | 515 | ] |
| 511 | 516 | ] |
| 512 | 517 | ], |
| 513 | 518 | ] |
| @@ -834,32 +839,39 @@ | ||
| 834 | 839 | <div <?php $this->print_render_attribute_string('grid-wrap'); ?>> |
| 835 | 840 | <?php |
| 836 | 841 | foreach ($comments as $comment) { |
| 837 | 842 | $title = get_the_title($comment->comment_post_ID); |
| 838 | - $comment_id = $comment->comment_ID; | |
| 839 | - $content = wp_trim_words($comment->comment_content, $settings['excerpt_limit']); | |
| 840 | - $avatar = get_avatar($comment->comment_author_email, $size = $settings['avatar_size']); | |
| 843 | + $comment_id = absint( $comment->comment_ID ); | |
| 844 | + $content = wp_trim_words($comment->comment_content, absint( $settings['excerpt_limit'] )); | |
| 845 | + $avatar = get_avatar($comment->comment_author_email, absint( $settings['avatar_size'] )); | |
| 841 | 846 | $author = $comment->comment_author; |
| 842 | 847 | $date = get_comment_date('F j, Y \a\t g:i a', $comment_id); |
| 848 | + $author_key = 'upk-author-' . $comment_id; | |
| 849 | + $show_author = ( 'yes' === $settings['show_author'] ); | |
| 850 | + $show_title = ( 'yes' === $settings['show_title'] ); | |
| 851 | + $show_date = ( 'yes' === $settings['show_date'] ); | |
| 852 | + $show_link = $show_author || $show_title; | |
| 843 | 853 | |
| 844 | - $this->add_render_attribute( | |
| 845 | - 'upk-author', | |
| 846 | - [ | |
| 847 | - 'class' => 'upk-author-name', | |
| 848 | - 'href' => esc_url(get_permalink($comment->comment_post_ID)) . '#comment-' . $comment_id, | |
| 849 | - 'target' => '_blank' | |
| 850 | - ], | |
| 851 | - null, | |
| 852 | - true | |
| 853 | - ); | |
| 854 | + if ( $show_link ) { | |
| 855 | + $this->add_render_attribute( | |
| 856 | + $author_key, | |
| 857 | + [ | |
| 858 | + 'class' => 'upk-author-name', | |
| 859 | + 'href' => esc_url( get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment_id ), | |
| 860 | + 'target' => '_blank' | |
| 861 | + ], | |
| 862 | + null, | |
| 863 | + true | |
| 864 | + ); | |
| 865 | + } | |
| 854 | 866 | |
| 855 | 867 | ?> |
| 856 | 868 | <div class="upk-item"> |
| 857 | 869 | |
| 858 | - <?php if ($settings['show_author'] or $settings['show_date']) : ?> | |
| 870 | + <?php if ( $show_author || $show_date || $show_title ) : ?> | |
| 859 | 871 | <div class="upk-meta upk-flex-inline upk-flex-middle"> |
| 860 | 872 | |
| 861 | - <?php if ($settings['show_author']) : ?> | |
| 873 | + <?php if ( $show_author ) : ?> | |
| 862 | 874 | <div class="upk-avatar"> |
| 863 | 875 | <?php $this->get_html_output($avatar); ?> |
| 864 | 876 | </div> |
| 865 | 877 | <?php endif; ?> |
| @@ -864,19 +876,24 @@ | ||
| 864 | 876 | </div> |
| 865 | 877 | <?php endif; ?> |
| 866 | 878 | |
| 867 | 879 | <div class="upk-author-info"> |
| 868 | - <?php if ($settings['show_author']) : ?> | |
| 869 | - <a <?php $this->print_render_attribute_string('upk-author'); ?>> | |
| 870 | - <?php echo esc_html($author); ?> | |
| 871 | - <?php if ($settings['show_title']) : ?> | |
| 872 | - <?php echo esc_html($settings['author_middle_text']); ?> | |
| 873 | - <?php echo esc_html($title) ?> | |
| 880 | + <?php if ( $show_link ) : ?> | |
| 881 | + <a <?php $this->print_render_attribute_string( $author_key ); ?>> | |
| 882 | + <?php if ( $show_author ) : ?> | |
| 883 | + <?php echo esc_html( $author ); ?> | |
| 874 | 884 | <?php endif; ?> |
| 885 | + | |
| 886 | + <?php if ( $show_title ) : ?> | |
| 887 | + <?php if ( $show_author ) : ?> | |
| 888 | + <?php echo esc_html( $settings['author_middle_text'] ); ?> | |
| 889 | + <?php endif; ?> | |
| 890 | + <?php echo esc_html( $title ); ?> | |
| 891 | + <?php endif; ?> | |
| 875 | 892 | </a> |
| 876 | 893 | <?php endif; ?> |
| 877 | 894 | |
| 878 | - <?php if ($settings['show_date']) : ?> | |
| 895 | + <?php if ( $show_date ) : ?> | |
| 879 | 896 | <div class="upk-date"><?php echo esc_html($date); ?></div> |
| 880 | 897 | <?php endif; ?> |
| 881 | 898 | </div> |
| 882 | 899 | |