ID.php
10 years ago
actions.php
10 years ago
agent.php
10 years ago
approved.php
10 years ago
author-avatar.php
10 years ago
author-email.php
10 years ago
author-ip.php
10 years ago
author-name.php
10 years ago
author-url.php
10 years ago
author.php
10 years ago
date-gmt.php
10 years ago
date.php
10 years ago
excerpt.php
10 years ago
post.php
10 years ago
reply-to.php
10 years ago
type.php
10 years ago
user.php
10 years ago
word-count.php
10 years ago
actions.php
108 lines
| 1 | <?php |
| 2 | /** |
| 3 | * CPAC_Column_Actions |
| 4 | * |
| 5 | * @since 2.0 |
| 6 | */ |
| 7 | class CPAC_Column_Comment_Actions extends CPAC_Column_Actions { |
| 8 | |
| 9 | /** |
| 10 | * @see CPAC_Column_Actions::get_actions() |
| 11 | * @since 2.3.4 |
| 12 | */ |
| 13 | public function get_actions( $id ) { |
| 14 | |
| 15 | global $post, $comment_status; |
| 16 | |
| 17 | $comment = get_comment( $id ); |
| 18 | |
| 19 | // set uased vars |
| 20 | $user_can = current_user_can( 'edit_comment', $comment->comment_ID ); |
| 21 | $the_comment_status = wp_get_comment_status( $comment->comment_ID ); |
| 22 | |
| 23 | if ( $user_can ) { |
| 24 | $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) ); |
| 25 | $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) ); |
| 26 | |
| 27 | $url = "comment.php?c=$comment->comment_ID"; |
| 28 | |
| 29 | $approve_url = esc_url( $url . "&action=approvecomment&$approve_nonce" ); |
| 30 | $unapprove_url = esc_url( $url . "&action=unapprovecomment&$approve_nonce" ); |
| 31 | $spam_url = esc_url( $url . "&action=spamcomment&$del_nonce" ); |
| 32 | $unspam_url = esc_url( $url . "&action=unspamcomment&$del_nonce" ); |
| 33 | $trash_url = esc_url( $url . "&action=trashcomment&$del_nonce" ); |
| 34 | $untrash_url = esc_url( $url . "&action=untrashcomment&$del_nonce" ); |
| 35 | $delete_url = esc_url( $url . "&action=deletecomment&$del_nonce" ); |
| 36 | } |
| 37 | |
| 38 | /** begin - copied from class-wp-comments-list-table */ |
| 39 | if ( $user_can ) { |
| 40 | // preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash |
| 41 | $actions = array( |
| 42 | 'approve' => '', 'unapprove' => '', |
| 43 | 'reply' => '', |
| 44 | 'quickedit' => '', |
| 45 | 'edit' => '', |
| 46 | 'spam' => '', 'unspam' => '', |
| 47 | 'trash' => '', 'untrash' => '', 'delete' => '' |
| 48 | ); |
| 49 | |
| 50 | if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments |
| 51 | if ( 'approved' == $the_comment_status ) |
| 52 | $actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved vim-u vim-destructive' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; |
| 53 | else if ( 'unapproved' == $the_comment_status ) |
| 54 | $actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved vim-a vim-destructive' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; |
| 55 | } else { |
| 56 | $actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; |
| 57 | $actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; |
| 58 | } |
| 59 | |
| 60 | if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) { |
| 61 | $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>'; |
| 62 | } elseif ( 'spam' == $the_comment_status ) { |
| 63 | $actions['unspam'] = "<a href='$unspam_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:unspam=1 vim-z vim-destructive'>" . _x( 'Not Spam', 'comment' ) . '</a>'; |
| 64 | } elseif ( 'trash' == $the_comment_status ) { |
| 65 | $actions['untrash'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1 vim-z vim-destructive'>" . __( 'Restore' ) . '</a>'; |
| 66 | } |
| 67 | |
| 68 | if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) { |
| 69 | $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::delete=1 delete vim-d vim-destructive'>" . __( 'Delete Permanently' ) . '</a>'; |
| 70 | } else { |
| 71 | $actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>'; |
| 72 | } |
| 73 | |
| 74 | if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) { |
| 75 | $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . esc_attr__( 'Edit comment' ) . "'>". __( 'Edit' ) . '</a>'; |
| 76 | $actions['quickedit'] = '<a onclick="commentReply.open( \''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\' );return false;" class="vim-q" title="'.esc_attr__( 'Quick Edit' ).'" href="#">' . __( 'Quick Edit' ) . '</a>'; |
| 77 | $actions['reply'] = '<a onclick="commentReply.open( \''.$comment->comment_ID.'\',\''.$post->ID.'\' );return false;" class="vim-r" title="'.esc_attr__( 'Reply to this comment' ).'" href="#">' . __( 'Reply' ) . '</a>'; |
| 78 | } |
| 79 | |
| 80 | $actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment ); |
| 81 | $actions_copy = $actions; |
| 82 | $actions = array(); |
| 83 | |
| 84 | foreach ( $actions_copy as $action => $link ) { |
| 85 | $action_append = ''; |
| 86 | |
| 87 | // Reply and quickedit need a hide-if-no-js span when not added with ajax |
| 88 | if ( ( 'reply' == $action || 'quickedit' == $action ) && ! defined('DOING_AJAX') ) { |
| 89 | $action_append .= ' hide-if-no-js'; |
| 90 | } |
| 91 | elseif ( ( $action == 'untrash' && $the_comment_status == 'trash' ) || ( $action == 'unspam' && $the_comment_status == 'spam' ) ) { |
| 92 | if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) ) { |
| 93 | $action_append .= ' approve'; |
| 94 | } |
| 95 | else { |
| 96 | $action_append .= ' unapprove'; |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | $action .= $action_append; |
| 101 | $actions[ $action ] = $link; |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | return $actions; |
| 106 | } |
| 107 | |
| 108 | } |