PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 2.0.1
Admin Columns v2.0.1
7.0.19 2.3.5 2.4 2.4.1 2.4.10 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.6.1 2.5.6.2 2.5.6.3 2.5.6.4 3.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.7 3.1 3.1.1 3.1.10 3.1.2 3.1.3 3.1.5 3.2.3 3.2.7 3.3.1 3.4.1 3.4.6 3.4.8 4.0.1 4.0.3 4.1.6 4.2.2 4.2.5 4.3 4.3.2 4.4.1 4.4.4 4.4.5 4.5.5 4.6.1 4.7.18 4.7.19 4.7.20 4.7.7 7.0.13 7.0.14 7.0.16 trunk 1.0 1.1 1.1.3 1.2 1.2.1 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.5.1 1.4.6 1.4.6.1 1.4.6.2 1.4.6.3 1.4.6.4 1.4.7 1.4.8 1.4.9 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2 2.2.1 2.2.1.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.5.1 2.2.6 2.2.6.1 2.2.6.2 2.2.6.3 2.2.6.4 2.2.7 2.2.8 2.2.8.1 2.2.9 2.3.1 2.3.2 2.3.3
codepress-admin-columns / classes / column / comment / actions.php
codepress-admin-columns / classes / column / comment Last commit date
ID.php 12 years ago actions.php 12 years ago agent.php 12 years ago approved.php 12 years ago author-avatar.php 12 years ago author-email.php 12 years ago author-ip.php 12 years ago author-url.php 12 years ago author.php 12 years ago date-gmt.php 12 years ago date.php 12 years ago excerpt.php 12 years ago reply-to.php 12 years ago word-count.php 12 years ago
actions.php
126 lines
1 <?php
2
3 /**
4 * CPAC_Column_Actions
5 *
6 * @since 2.0.0
7 */
8 class CPAC_Column_Comment_Actions extends CPAC_Column {
9
10 function __construct( $storage_model ) {
11
12 // define properties
13 $this->properties['type'] = 'column-actions';
14 $this->properties['label'] = __( 'Actions', 'cpac' );
15
16 parent::__construct( $storage_model );
17 }
18
19 /**
20 * @see CPAC_Column::get_value()
21 * @since 2.0.0
22 */
23 function get_value( $id ) {
24
25 $comment = get_comment( $id );
26
27 return $this->get_column_value_actions( $comment );
28 }
29
30 /**
31 * Get column value of comments actions
32 *
33 * This part is copied from the Comments List Table class
34 *
35 * @since 1.4.2
36 */
37 private function get_column_value_actions( $comment ) {
38 global $post, $comment_status;
39
40 // set uased vars
41 $user_can = current_user_can( 'edit_comment', $comment->comment_ID );
42 $the_comment_status = wp_get_comment_status( $comment->comment_ID );
43
44 if ( $user_can ) {
45 $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
46 $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
47
48 $url = "comment.php?c=$comment->comment_ID";
49
50 $approve_url = esc_url( $url . "&action=approvecomment&$approve_nonce" );
51 $unapprove_url = esc_url( $url . "&action=unapprovecomment&$approve_nonce" );
52 $spam_url = esc_url( $url . "&action=spamcomment&$del_nonce" );
53 $unspam_url = esc_url( $url . "&action=unspamcomment&$del_nonce" );
54 $trash_url = esc_url( $url . "&action=trashcomment&$del_nonce" );
55 $untrash_url = esc_url( $url . "&action=untrashcomment&$del_nonce" );
56 $delete_url = esc_url( $url . "&action=deletecomment&$del_nonce" );
57 }
58
59 /** begin - copied from class-wp-comments-list-table */
60 if ( $user_can ) {
61 // preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash
62 $actions = array(
63 'approve' => '', 'unapprove' => '',
64 'reply' => '',
65 'quickedit' => '',
66 'edit' => '',
67 'spam' => '', 'unspam' => '',
68 'trash' => '', 'untrash' => '', 'delete' => ''
69 );
70
71 if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments
72 if ( 'approved' == $the_comment_status )
73 $actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=unapproved vim-u vim-destructive' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
74 else if ( 'unapproved' == $the_comment_status )
75 $actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=approved vim-a vim-destructive' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
76 } else {
77 $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>';
78 $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>';
79 }
80
81 if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {
82 $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>';
83 } elseif ( 'spam' == $the_comment_status ) {
84 $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>';
85 } elseif ( 'trash' == $the_comment_status ) {
86 $actions['untrash'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1 vim-z vim-destructive'>" . __( 'Restore' ) . '</a>';
87 }
88
89 if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) {
90 $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>';
91 } else {
92 $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>';
93 }
94
95 if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {
96 $actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . esc_attr__( 'Edit comment' ) . "'>". __( 'Edit' ) . '</a>';
97 $actions['quickedit'] = '<a onclick="commentReply.open( \''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\' );return false;" class="vim-q" title="'.esc_attr__( 'Quick Edit' ).'" href="#">' . __( 'Quick&nbsp;Edit' ) . '</a>';
98 $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>';
99 }
100
101 $actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );
102
103 $i = 0;
104 $result = '<div class="cp-row-actions">';
105 foreach ( $actions as $action => $link ) {
106 ++$i;
107 ( ( ( 'approve' == $action || 'unapprove' == $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
108
109 // Reply and quickedit need a hide-if-no-js span when not added with ajax
110 if ( ( 'reply' == $action || 'quickedit' == $action ) && ! defined('DOING_AJAX') )
111 $action .= ' hide-if-no-js';
112 elseif ( ( $action == 'untrash' && $the_comment_status == 'trash' ) || ( $action == 'unspam' && $the_comment_status == 'spam' ) ) {
113 if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) )
114 $action .= ' approve';
115 else
116 $action .= ' unapprove';
117 }
118
119 $result .= "<span class='$action'>$sep$link</span>";
120 }
121 $result .= '</div>';
122 }
123 return $result;
124 // end copied
125 }
126 }