Ticket #36208: 36208.6.patch
File 36208.6.patch, 25.3 KB (added by , 22 months ago) |
---|
-
src/wp-admin/includes/class-wp-comments-list-table.php
diff --git src/wp-admin/includes/class-wp-comments-list-table.php src/wp-admin/includes/class-wp-comments-list-table.php index 1b288786cd..34486f5bf2 100644
class WP_Comments_List_Table extends WP_List_Table { 24 24 25 25 private $user_can; 26 26 27 /** 28 * Whether the comment's post post type is registered or not. 29 * 30 * @since 6.2.0 31 * @var bool 32 */ 33 private $is_post_type_registered = true; 34 27 35 /** 28 36 * Constructor. 29 37 * … … class WP_Comments_List_Table extends WP_List_Table { 633 641 634 642 if ( $comment->comment_post_ID > 0 ) { 635 643 $post = get_post( $comment->comment_post_ID ); 644 645 // Check whether the post type is still registered. 646 $this->is_post_type_registered = null !== get_post_type_object( $post->post_type ); 636 647 } 637 648 638 649 $this->user_can = current_user_can( 'edit_comment', $comment->comment_ID ); … … class WP_Comments_List_Table extends WP_List_Table { 681 692 682 693 $url = "comment.php?c=$comment->comment_ID"; 683 694 684 $approve_url = esc_url( $url . "&action=approvecomment&$approve_nonce" );685 $unapprove_url = esc_url( $url . "&action=unapprovecomment&$approve_nonce" );686 $spam_url = esc_url( $url . "&action=spamcomment&$del_nonce" );687 $unspam_url = esc_url( $url . "&action=unspamcomment&$del_nonce" );688 $trash_url = esc_url( $url . "&action=trashcomment&$del_nonce" );689 $untrash_url = esc_url( $url . "&action=untrashcomment&$del_nonce" );690 $delete_url = esc_url( $url . "&action=deletecomment&$del_nonce" );691 692 695 // Preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash. 693 696 $actions = array( 694 697 'approve' => '', … … class WP_Comments_List_Table extends WP_List_Table { 703 706 'delete' => '', 704 707 ); 705 708 706 // Not looking at all comments. 707 if ( $comment_status && 'all' !== $comment_status ) { 708 if ( 'approved' === $the_comment_status ) { 709 $actions['unapprove'] = sprintf( 710 '<a href="%s" data-wp-lists="%s" class="vim-u vim-destructive aria-button-if-js" aria-label="%s">%s</a>', 711 $unapprove_url, 712 "delete:the-comment-list:comment-{$comment->comment_ID}:e7e7d3:action=dim-comment&new=unapproved", 713 esc_attr__( 'Unapprove this comment' ), 714 __( 'Unapprove' ) 715 ); 716 } elseif ( 'unapproved' === $the_comment_status ) { 709 $delete_url = esc_url( $url . "&action=deletecomment&$del_nonce" ); 710 $delete_action_link = sprintf( 711 '<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>', 712 $delete_url, 713 "delete:the-comment-list:comment-{$comment->comment_ID}::delete=1", 714 esc_attr__( 'Delete this comment permanently' ), 715 __( 'Delete Permanently' ) 716 ); 717 718 if ( ! $this->is_post_type_registered ) { 719 $actions['delete'] = $delete_action_link; 720 } else { 721 $approve_url = esc_url( $url . "&action=approvecomment&$approve_nonce" ); 722 $unapprove_url = esc_url( $url . "&action=unapprovecomment&$approve_nonce" ); 723 $spam_url = esc_url( $url . "&action=spamcomment&$del_nonce" ); 724 $unspam_url = esc_url( $url . "&action=unspamcomment&$del_nonce" ); 725 $trash_url = esc_url( $url . "&action=trashcomment&$del_nonce" ); 726 $untrash_url = esc_url( $url . "&action=untrashcomment&$del_nonce" ); 727 728 // Not looking at all comments. 729 if ( $comment_status && 'all' !== $comment_status ) { 730 if ( 'approved' === $the_comment_status ) { 731 $actions['unapprove'] = sprintf( 732 '<a href="%s" data-wp-lists="%s" class="vim-u vim-destructive aria-button-if-js" aria-label="%s">%s</a>', 733 $unapprove_url, 734 "delete:the-comment-list:comment-{$comment->comment_ID}:e7e7d3:action=dim-comment&new=unapproved", 735 esc_attr__( 'Unapprove this comment' ), 736 __( 'Unapprove' ) 737 ); 738 } elseif ( 'unapproved' === $the_comment_status ) { 739 $actions['approve'] = sprintf( 740 '<a href="%s" data-wp-lists="%s" class="vim-a vim-destructive aria-button-if-js" aria-label="%s">%s</a>', 741 $approve_url, 742 "delete:the-comment-list:comment-{$comment->comment_ID}:e7e7d3:action=dim-comment&new=approved", 743 esc_attr__( 'Approve this comment' ), 744 __( 'Approve' ) 745 ); 746 } 747 } else { 717 748 $actions['approve'] = sprintf( 718 '<a href="%s" data-wp-lists="%s" class="vim-a vim-destructivearia-button-if-js" aria-label="%s">%s</a>',749 '<a href="%s" data-wp-lists="%s" class="vim-a aria-button-if-js" aria-label="%s">%s</a>', 719 750 $approve_url, 720 "d elete:the-comment-list:comment-{$comment->comment_ID}:e7e7d3:action=dim-comment&new=approved",751 "dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=approved", 721 752 esc_attr__( 'Approve this comment' ), 722 753 __( 'Approve' ) 723 754 ); 755 756 $actions['unapprove'] = sprintf( 757 '<a href="%s" data-wp-lists="%s" class="vim-u aria-button-if-js" aria-label="%s">%s</a>', 758 $unapprove_url, 759 "dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=unapproved", 760 esc_attr__( 'Unapprove this comment' ), 761 __( 'Unapprove' ) 762 ); 724 763 } 725 } else {726 $actions['approve'] = sprintf(727 '<a href="%s" data-wp-lists="%s" class="vim-a aria-button-if-js" aria-label="%s">%s</a>',728 $approve_url,729 "dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=approved",730 esc_attr__( 'Approve this comment' ),731 __( 'Approve' )732 );733 764 734 $actions['unapprove'] = sprintf( 735 '<a href="%s" data-wp-lists="%s" class="vim-u aria-button-if-js" aria-label="%s">%s</a>', 736 $unapprove_url, 737 "dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=unapproved", 738 esc_attr__( 'Unapprove this comment' ), 739 __( 'Unapprove' ) 740 ); 741 } 765 if ( 'spam' !== $the_comment_status ) { 766 $actions['spam'] = sprintf( 767 '<a href="%s" data-wp-lists="%s" class="vim-s vim-destructive aria-button-if-js" aria-label="%s">%s</a>', 768 $spam_url, 769 "delete:the-comment-list:comment-{$comment->comment_ID}::spam=1", 770 esc_attr__( 'Mark this comment as spam' ), 771 /* translators: "Mark as spam" link. */ 772 _x( 'Spam', 'verb' ) 773 ); 774 } elseif ( 'spam' === $the_comment_status ) { 775 $actions['unspam'] = sprintf( 776 '<a href="%s" data-wp-lists="%s" class="vim-z vim-destructive aria-button-if-js" aria-label="%s">%s</a>', 777 $unspam_url, 778 "delete:the-comment-list:comment-{$comment->comment_ID}:66cc66:unspam=1", 779 esc_attr__( 'Restore this comment from the spam' ), 780 _x( 'Not Spam', 'comment' ) 781 ); 782 } 742 783 743 if ( 'spam' !== $the_comment_status ) { 744 $actions['spam'] = sprintf( 745 '<a href="%s" data-wp-lists="%s" class="vim-s vim-destructive aria-button-if-js" aria-label="%s">%s</a>', 746 $spam_url, 747 "delete:the-comment-list:comment-{$comment->comment_ID}::spam=1", 748 esc_attr__( 'Mark this comment as spam' ), 749 /* translators: "Mark as spam" link. */ 750 _x( 'Spam', 'verb' ) 751 ); 752 } elseif ( 'spam' === $the_comment_status ) { 753 $actions['unspam'] = sprintf( 754 '<a href="%s" data-wp-lists="%s" class="vim-z vim-destructive aria-button-if-js" aria-label="%s">%s</a>', 755 $unspam_url, 756 "delete:the-comment-list:comment-{$comment->comment_ID}:66cc66:unspam=1", 757 esc_attr__( 'Restore this comment from the spam' ), 758 _x( 'Not Spam', 'comment' ) 759 ); 760 } 784 if ( 'trash' === $the_comment_status ) { 785 $actions['untrash'] = sprintf( 786 '<a href="%s" data-wp-lists="%s" class="vim-z vim-destructive aria-button-if-js" aria-label="%s">%s</a>', 787 $untrash_url, 788 "delete:the-comment-list:comment-{$comment->comment_ID}:66cc66:untrash=1", 789 esc_attr__( 'Restore this comment from the Trash' ), 790 __( 'Restore' ) 791 ); 792 } 761 793 762 if ( 'trash' === $the_comment_status ) { 763 $actions['untrash'] = sprintf( 764 '<a href="%s" data-wp-lists="%s" class="vim-z vim-destructive aria-button-if-js" aria-label="%s">%s</a>', 765 $untrash_url, 766 "delete:the-comment-list:comment-{$comment->comment_ID}:66cc66:untrash=1", 767 esc_attr__( 'Restore this comment from the Trash' ), 768 __( 'Restore' ) 769 ); 770 } 794 if ( 'spam' === $the_comment_status || 'trash' === $the_comment_status || ! EMPTY_TRASH_DAYS ) { 795 $actions['delete'] = $delete_action_link; 796 } else { 797 $actions['trash'] = sprintf( 798 '<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>', 799 $trash_url, 800 "delete:the-comment-list:comment-{$comment->comment_ID}::trash=1", 801 esc_attr__( 'Move this comment to the Trash' ), 802 _x( 'Trash', 'verb' ) 803 ); 804 } 771 805 772 if ( 'spam' === $the_comment_status || 'trash' === $the_comment_status || ! EMPTY_TRASH_DAYS ) { 773 $actions['delete'] = sprintf( 774 '<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>', 775 $delete_url, 776 "delete:the-comment-list:comment-{$comment->comment_ID}::delete=1", 777 esc_attr__( 'Delete this comment permanently' ), 778 __( 'Delete Permanently' ) 779 ); 780 } else { 781 $actions['trash'] = sprintf( 782 '<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>', 783 $trash_url, 784 "delete:the-comment-list:comment-{$comment->comment_ID}::trash=1", 785 esc_attr__( 'Move this comment to the Trash' ), 786 _x( 'Trash', 'verb' ) 787 ); 788 } 806 if ( 'spam' !== $the_comment_status && 'trash' !== $the_comment_status ) { 807 $actions['edit'] = sprintf( 808 '<a href="%s" aria-label="%s">%s</a>', 809 "comment.php?action=editcomment&c={$comment->comment_ID}", 810 esc_attr__( 'Edit this comment' ), 811 __( 'Edit' ) 812 ); 789 813 790 if ( 'spam' !== $the_comment_status && 'trash' !== $the_comment_status ) { 791 $actions['edit'] = sprintf( 792 '<a href="%s" aria-label="%s">%s</a>', 793 "comment.php?action=editcomment&c={$comment->comment_ID}", 794 esc_attr__( 'Edit this comment' ), 795 __( 'Edit' ) 796 ); 814 $format = '<button type="button" data-comment-id="%d" data-post-id="%d" data-action="%s" class="%s button-link" aria-expanded="false" aria-label="%s">%s</button>'; 797 815 798 $format = '<button type="button" data-comment-id="%d" data-post-id="%d" data-action="%s" class="%s button-link" aria-expanded="false" aria-label="%s">%s</button>'; 816 $actions['quickedit'] = sprintf( 817 $format, 818 $comment->comment_ID, 819 $comment->comment_post_ID, 820 'edit', 821 'vim-q comment-inline', 822 esc_attr__( 'Quick edit this comment inline' ), 823 __( 'Quick Edit' ) 824 ); 799 825 800 $actions['quickedit'] = sprintf( 801 $format, 802 $comment->comment_ID, 803 $comment->comment_post_ID, 804 'edit', 805 'vim-q comment-inline', 806 esc_attr__( 'Quick edit this comment inline' ), 807 __( 'Quick Edit' ) 808 ); 826 $actions['reply'] = sprintf( 827 $format, 828 $comment->comment_ID, 829 $comment->comment_post_ID, 830 'replyto', 831 'vim-r comment-inline', 832 esc_attr__( 'Reply to this comment' ), 833 __( 'Reply' ) 834 ); 835 } 809 836 810 $actions['reply'] = sprintf( 811 $format, 812 $comment->comment_ID, 813 $comment->comment_post_ID, 814 'replyto', 815 'vim-r comment-inline', 816 esc_attr__( 'Reply to this comment' ), 817 __( 'Reply' ) 818 ); 837 /** This filter is documented in wp-admin/includes/dashboard.php */ 838 $actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment ); 819 839 } 820 840 821 /** This filter is documented in wp-admin/includes/dashboard.php */822 $actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );823 824 841 $always_visible = false; 825 842 826 843 $mode = get_user_setting( 'posts_list_mode', 'list' ); … … class WP_Comments_List_Table extends WP_List_Table { 838 855 839 856 if ( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i ) 840 857 || 1 === $i 858 || ! $this->is_post_type_registered 841 859 ) { 842 860 $separator = ''; 843 861 } else { … … class WP_Comments_List_Table extends WP_List_Table { 876 894 // Restores the more descriptive, specific name for use within this method. 877 895 $comment = $item; 878 896 879 if ( $this->user_can ) {897 if ( $this->user_can && $this->is_post_type_registered ) { 880 898 ?> 881 899 <label class="screen-reader-text" for="cb-select-<?php echo $comment->comment_ID; ?>"><?php _e( 'Select comment' ); ?></label> 882 900 <input id="cb-select-<?php echo $comment->comment_ID; ?>" type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /> … … class WP_Comments_List_Table extends WP_List_Table { 997 1015 998 1016 echo '<div class="submitted-on">'; 999 1017 1000 if ( 'approved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_post_ID ) ) {1018 if ( 'approved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_post_ID ) && $this->is_post_type_registered ) { 1001 1019 printf( 1002 1020 '<a href="%s">%s</a>', 1003 1021 esc_url( get_comment_link( $comment ) ), … … class WP_Comments_List_Table extends WP_List_Table { 1028 1046 $this->pending_count[ $post->ID ] = $pending_comments; 1029 1047 } 1030 1048 1031 if ( current_user_can( 'edit_post', $post->ID ) ) {1049 if ( $this->is_post_type_registered && current_user_can( 'edit_post', $post->ID ) ) { 1032 1050 $post_link = "<a href='" . get_edit_post_link( $post->ID ) . "' class='comments-edit-item-link'>"; 1033 1051 $post_link .= esc_html( get_the_title( $post->ID ) ) . '</a>'; 1034 1052 } else { 1035 $post_link = esc_html( get_the_title( $post->ID ) ); 1053 $post_link = '<p>' . esc_html( get_the_title( $post->ID ) ) . '</p>'; 1054 1055 if ( ! $this->is_post_type_registered ) { 1056 /* Translators: %s. The comment's post post type name */ 1057 $post_link .= '<p class="description">' . sprintf( esc_html__( '(The %s post type is not available)' ), '<code>' . esc_html( $post->post_type ) . '</code>' ) . '</p>'; 1058 } 1036 1059 } 1037 1060 1038 1061 echo '<div class="response-links">'; … … class WP_Comments_List_Table extends WP_List_Table { 1046 1069 1047 1070 echo $post_link; 1048 1071 1049 $post_type_object = get_post_type_object( $post->post_type ); 1050 echo "<a href='" . get_permalink( $post->ID ) . "' class='comments-view-item-link'>" . $post_type_object->labels->view_item . '</a>'; 1051 1052 echo '<span class="post-com-count-wrapper post-com-count-', $post->ID, '">'; 1053 $this->comments_bubble( $post->ID, $pending_comments ); 1054 echo '</span> '; 1072 // Only display the view item link & the comments bubble if the post type is still registered. 1073 if ( $this->is_post_type_registered ) { 1074 $post_type_object = get_post_type_object( $post->post_type ); 1075 echo "<a href='" . get_permalink( $post->ID ) . "' class='comments-view-item-link'>" . $post_type_object->labels->view_item . '</a>'; 1076 echo '<span class="post-com-count-wrapper post-com-count-', $post->ID, '">'; 1077 $this->comments_bubble( $post->ID, $pending_comments ); 1078 echo '</span> '; 1079 } 1055 1080 1056 1081 echo '</div>'; 1057 1082 } -
src/wp-admin/includes/dashboard.php
diff --git src/wp-admin/includes/dashboard.php src/wp-admin/includes/dashboard.php index 4c1f1f6797..b504f4c338 100644
function wp_dashboard_recent_drafts( $drafts = false ) { 688 688 function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { 689 689 $GLOBALS['comment'] = clone $comment; 690 690 691 $comment_post_link = ''; 692 $is_post_type_registered = true; 693 691 694 if ( $comment->comment_post_ID > 0 ) { 692 $comment_post_title = _draft_or_post_title( $comment->comment_post_ID ); 693 $comment_post_url = get_the_permalink( $comment->comment_post_ID ); 694 $comment_post_link = '<a href="' . esc_url( $comment_post_url ) . '">' . $comment_post_title . '</a>'; 695 } else { 696 $comment_post_link = ''; 695 $post = get_post( $comment->comment_post_ID ); 696 697 // Check whether the post type is still registered. 698 $is_post_type_registered = null !== get_post_type_object( $post->post_type ); 699 700 if ( $is_post_type_registered ) { 701 $comment_post_title = _draft_or_post_title( $post ); 702 $comment_post_url = get_the_permalink( $comment->comment_post_ID ); 703 $comment_post_link = '<a href="' . esc_url( $comment_post_url ) . '">' . $comment_post_title . '</a>'; 704 } else { 705 $comment_post_link = sprintf( 706 /* Translators: 1. The comment's post post title. 2. The comment's post post type name */ 707 esc_html__( '%1$s (The %2$s post type is not available)' ), 708 esc_html( get_the_title( $post->ID ) ), 709 '<code>' . esc_html( $post->post_type ) . '</code>' 710 ); 711 } 697 712 } 698 713 699 714 $actions_string = ''; … … function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { 713 728 $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) ); 714 729 $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) ); 715 730 716 $approve_url = esc_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" ); 717 $unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" ); 718 $spam_url = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); 719 $trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); 720 $delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); 721 722 $actions['approve'] = sprintf( 723 '<a href="%s" data-wp-lists="%s" class="vim-a aria-button-if-js" aria-label="%s">%s</a>', 724 $approve_url, 725 "dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=approved", 726 esc_attr__( 'Approve this comment' ), 727 __( 'Approve' ) 731 $delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); 732 $delete_action_link = sprintf( 733 '<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>', 734 $delete_url, 735 "delete:the-comment-list:comment-{$comment->comment_ID}::trash=1", 736 esc_attr__( 'Delete this comment permanently' ), 737 __( 'Delete Permanently' ) 728 738 ); 729 739 730 $actions['unapprove'] = sprintf( 731 '<a href="%s" data-wp-lists="%s" class="vim-u aria-button-if-js" aria-label="%s">%s</a>', 732 $unapprove_url, 733 "dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=unapproved", 734 esc_attr__( 'Unapprove this comment' ), 735 __( 'Unapprove' ) 736 ); 737 738 $actions['edit'] = sprintf( 739 '<a href="%s" aria-label="%s">%s</a>', 740 "comment.php?action=editcomment&c={$comment->comment_ID}", 741 esc_attr__( 'Edit this comment' ), 742 __( 'Edit' ) 743 ); 740 if ( ! $is_post_type_registered ) { 741 $actions['delete'] = $delete_action_link; 742 } else { 743 $approve_url = esc_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" ); 744 $unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" ); 745 $spam_url = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); 746 $trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); 747 748 $actions['approve'] = sprintf( 749 '<a href="%s" data-wp-lists="%s" class="vim-a aria-button-if-js" aria-label="%s">%s</a>', 750 $approve_url, 751 "dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=approved", 752 esc_attr__( 'Approve this comment' ), 753 __( 'Approve' ) 754 ); 744 755 745 $actions['reply'] = sprintf(746 '<button type="button" onclick="window.commentReply && commentReply.open(\'%s\',\'%s\');" class="vim-r button-link hide-if-no-js" aria-label="%s">%s</button>',747 $comment->comment_ID,748 $comment->comment_post_ID,749 esc_attr__( 'Reply tothis comment' ),750 __( 'Reply' )751 );756 $actions['unapprove'] = sprintf( 757 '<a href="%s" data-wp-lists="%s" class="vim-u aria-button-if-js" aria-label="%s">%s</a>', 758 $unapprove_url, 759 "dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=unapproved", 760 esc_attr__( 'Unapprove this comment' ), 761 __( 'Unapprove' ) 762 ); 752 763 753 $actions['spam'] = sprintf( 754 '<a href="%s" data-wp-lists="%s" class="vim-s vim-destructive aria-button-if-js" aria-label="%s">%s</a>', 755 $spam_url, 756 "delete:the-comment-list:comment-{$comment->comment_ID}::spam=1", 757 esc_attr__( 'Mark this comment as spam' ), 758 /* translators: "Mark as spam" link. */ 759 _x( 'Spam', 'verb' ) 760 ); 764 $actions['edit'] = sprintf( 765 '<a href="%s" aria-label="%s">%s</a>', 766 "comment.php?action=editcomment&c={$comment->comment_ID}", 767 esc_attr__( 'Edit this comment' ), 768 __( 'Edit' ) 769 ); 761 770 762 if ( ! EMPTY_TRASH_DAYS ) { 763 $actions['delete'] = sprintf( 764 '<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>', 765 $delete_url, 766 "delete:the-comment-list:comment-{$comment->comment_ID}::trash=1", 767 esc_attr__( 'Delete this comment permanently' ), 768 __( 'Delete Permanently' ) 771 $actions['reply'] = sprintf( 772 '<button type="button" onclick="window.commentReply && commentReply.open(\'%s\',\'%s\');" class="vim-r button-link hide-if-no-js" aria-label="%s">%s</button>', 773 $comment->comment_ID, 774 $comment->comment_post_ID, 775 esc_attr__( 'Reply to this comment' ), 776 __( 'Reply' ) 769 777 ); 770 } else { 771 $actions['trash'] = sprintf( 772 '<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>', 773 $trash_url, 774 "delete:the-comment-list:comment-{$comment->comment_ID}::trash=1", 775 esc_attr__( 'Move this comment to the Trash' ), 776 _x( 'Trash', 'verb' ) 778 779 $actions['spam'] = sprintf( 780 '<a href="%s" data-wp-lists="%s" class="vim-s vim-destructive aria-button-if-js" aria-label="%s">%s</a>', 781 $spam_url, 782 "delete:the-comment-list:comment-{$comment->comment_ID}::spam=1", 783 esc_attr__( 'Mark this comment as spam' ), 784 /* translators: "Mark as spam" link. */ 785 _x( 'Spam', 'verb' ) 777 786 ); 778 }779 787 780 $actions['view'] = sprintf( 781 '<a class="comment-link" href="%s" aria-label="%s">%s</a>', 782 esc_url( get_comment_link( $comment ) ), 783 esc_attr__( 'View this comment' ), 784 __( 'View' ) 785 ); 788 if ( ! EMPTY_TRASH_DAYS ) { 789 $actions['delete'] = $delete_action_link; 790 } else { 791 $actions['trash'] = sprintf( 792 '<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>', 793 $trash_url, 794 "delete:the-comment-list:comment-{$comment->comment_ID}::trash=1", 795 esc_attr__( 'Move this comment to the Trash' ), 796 _x( 'Trash', 'verb' ) 797 ); 798 } 786 799 787 /** 788 * Filters the action links displayed for each comment in the 'Recent Comments' 789 * dashboard widget. 790 * 791 * @since 2.6.0 792 * 793 * @param string[] $actions An array of comment actions. Default actions include: 794 * 'Approve', 'Unapprove', 'Edit', 'Reply', 'Spam', 795 * 'Delete', and 'Trash'. 796 * @param WP_Comment $comment The comment object. 797 */ 798 $actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment ); 800 $actions['view'] = sprintf( 801 '<a class="comment-link" href="%s" aria-label="%s">%s</a>', 802 esc_url( get_comment_link( $comment ) ), 803 esc_attr__( 'View this comment' ), 804 __( 'View' ) 805 ); 806 807 /** 808 * Filters the action links displayed for each comment in the 'Recent Comments' 809 * dashboard widget. 810 * 811 * @since 2.6.0 812 * 813 * @param string[] $actions An array of comment actions. Default actions include: 814 * 'Approve', 'Unapprove', 'Edit', 'Reply', 'Spam', 815 * 'Delete', and 'Trash'. 816 * @param WP_Comment $comment The comment object. 817 */ 818 $actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment ); 819 } 799 820 800 821 $i = 0; 801 822 … … function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { 804 825 805 826 if ( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i ) 806 827 || 1 === $i 828 || ! $is_post_type_registered 807 829 ) { 808 830 $separator = ''; 809 831 } else { … … function wp_dashboard_recent_comments( $total_items = 5 ) { 1070 1092 } 1071 1093 1072 1094 foreach ( $possible as $comment ) { 1073 if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) ) { 1095 $is_post_type_registered = true; 1096 1097 if ( $comment->comment_post_ID > 0 ) { 1098 $post = get_post( $comment->comment_post_ID ); 1099 $is_post_type_registered = null !== get_post_type_object( $post->post_type ); 1100 } 1101 1102 $can_read = ! $is_post_type_registered ? current_user_can( 'edit_others_posts' ) : current_user_can( 'read_post', $comment->comment_post_ID ); 1103 1104 if ( ! $can_read ) { 1074 1105 continue; 1075 1106 } 1076 1107 -
src/wp-includes/capabilities.php
diff --git src/wp-includes/capabilities.php src/wp-includes/capabilities.php index d06887a2bb..37f9752aa7 100644
function map_meta_cap( $cap, $user_id, ...$args ) { 571 571 * Fall back to the edit_posts capability, instead. 572 572 */ 573 573 if ( $post ) { 574 $caps = map_meta_cap( 'edit_post', $user_id, $post->ID);574 $caps = get_post_type_object( $post->post_type ) ? map_meta_cap( 'edit_post', $user_id, $post->ID ) : array( 'edit_others_posts' ); 575 575 } else { 576 576 $caps = map_meta_cap( 'edit_posts', $user_id ); 577 577 }