- Timestamp:
- 05/29/2015 02:40:52 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-comments-list-table.php
r32642 r32644 358 358 } 359 359 360 /** 361 * Get name of default primary column 362 * 363 * @since 4.3.0 364 * @access protected 365 * 366 * @return string 367 */ 368 protected function get_default_primary_column_name() { 369 return 'comment'; 370 } 371 360 372 public function display() { 361 373 wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' ); … … 414 426 $this->single_row_columns( $comment ); 415 427 echo "</tr>\n"; 428 } 429 430 /** 431 * Generate and display row actions links 432 * 433 * @since 4.3.0 434 * @access protected 435 * 436 * @param object $comment Comment being acted upon 437 * @param string $column_name Current column name 438 * @param string $primary Primary column name 439 * 440 * @return string 441 */ 442 protected function handle_row_actions( $comment, $column_name, $primary ) { 443 global $comment_status; 444 445 if ( ! $this->user_can ) { 446 return; 447 448 } 449 450 $post = get_post(); 451 452 $the_comment_status = wp_get_comment_status( $comment->comment_ID ); 453 454 $out = ''; 455 456 if( $primary === $column_name ) { 457 $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) ); 458 $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) ); 459 460 $url = "comment.php?c=$comment->comment_ID"; 461 462 $approve_url = esc_url( $url . "&action=approvecomment&$approve_nonce" ); 463 $unapprove_url = esc_url( $url . "&action=unapprovecomment&$approve_nonce" ); 464 $spam_url = esc_url( $url . "&action=spamcomment&$del_nonce" ); 465 $unspam_url = esc_url( $url . "&action=unspamcomment&$del_nonce" ); 466 $trash_url = esc_url( $url . "&action=trashcomment&$del_nonce" ); 467 $untrash_url = esc_url( $url . "&action=untrashcomment&$del_nonce" ); 468 $delete_url = esc_url( $url . "&action=deletecomment&$del_nonce" ); 469 470 // Preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash. 471 $actions = array( 472 'approve' => '', 'unapprove' => '', 473 'reply' => '', 474 'quickedit' => '', 475 'edit' => '', 476 'spam' => '', 'unspam' => '', 477 'trash' => '', 'untrash' => '', 'delete' => '' 478 ); 479 480 // Not looking at all comments. 481 if ( $comment_status && 'all' != $comment_status ) { 482 if ( 'approved' == $the_comment_status ) { 483 $actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved' class='vim-u vim-destructive' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; 484 } elseif ( 'unapproved' == $the_comment_status ) { 485 $actions['approve'] = "<a href='$approve_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved' class='vim-a vim-destructive' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; 486 } 487 } else { 488 $actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; 489 $actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' class='vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; 490 } 491 492 if ( 'spam' != $the_comment_status ) { 493 $actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>'; 494 } elseif ( 'spam' == $the_comment_status ) { 495 $actions['unspam'] = "<a href='$unspam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:66cc66:unspam=1' class='vim-z vim-destructive'>" . _x( 'Not Spam', 'comment' ) . '</a>'; 496 } 497 498 if ( 'trash' == $the_comment_status ) { 499 $actions['untrash'] = "<a href='$untrash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1' class='vim-z vim-destructive'>" . __( 'Restore' ) . '</a>'; 500 } 501 502 if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) { 503 $actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::delete=1' class='delete vim-d vim-destructive'>" . __( 'Delete Permanently' ) . '</a>'; 504 } else { 505 $actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>'; 506 } 507 508 if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) { 509 $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . esc_attr__( 'Edit comment' ) . "'>". __( 'Edit' ) . '</a>'; 510 511 $format = '<a data-comment-id="%d" data-post-id="%d" data-action="%s" class="%s" title="%s" href="#">%s</a>'; 512 513 $actions['quickedit'] = sprintf( $format, $comment->comment_ID, $post->ID, 'edit', 'vim-q comment-inline',esc_attr__( 'Edit this item inline' ), __( 'Quick Edit' ) ); 514 515 $actions['reply'] = sprintf( $format, $comment->comment_ID, $post->ID, 'replyto', 'vim-r comment-inline', esc_attr__( 'Reply to this comment' ), __( 'Reply' ) ); 516 } 517 518 /** This filter is documented in wp-admin/includes/dashboard.php */ 519 $actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment ); 520 521 $i = 0; 522 $out .= '<div class="row-actions">'; 523 foreach ( $actions as $action => $link ) { 524 ++$i; 525 ( ( ( 'approve' == $action || 'unapprove' == $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; 526 527 // Reply and quickedit need a hide-if-no-js span when not added with ajax 528 if ( ( 'reply' == $action || 'quickedit' == $action ) && ! defined('DOING_AJAX') ) 529 $action .= ' hide-if-no-js'; 530 elseif ( ( $action == 'untrash' && $the_comment_status == 'trash' ) || ( $action == 'unspam' && $the_comment_status == 'spam' ) ) { 531 if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) ) 532 $action .= ' approve'; 533 else 534 $action .= ' unapprove'; 535 } 536 537 $out .= "<span class='$action'>$sep$link</span>"; 538 } 539 $out .= '</div>'; 540 } 541 542 return $out; 416 543 } 417 544 … … 470 597 <?php 471 598 } 472 473 if ( $this->user_can ) {474 $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );475 $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );476 477 $url = "comment.php?c=$comment->comment_ID";478 479 $approve_url = esc_url( $url . "&action=approvecomment&$approve_nonce" );480 $unapprove_url = esc_url( $url . "&action=unapprovecomment&$approve_nonce" );481 $spam_url = esc_url( $url . "&action=spamcomment&$del_nonce" );482 $unspam_url = esc_url( $url . "&action=unspamcomment&$del_nonce" );483 $trash_url = esc_url( $url . "&action=trashcomment&$del_nonce" );484 $untrash_url = esc_url( $url . "&action=untrashcomment&$del_nonce" );485 $delete_url = esc_url( $url . "&action=deletecomment&$del_nonce" );486 487 // Preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash.488 $actions = array(489 'approve' => '', 'unapprove' => '',490 'reply' => '',491 'quickedit' => '',492 'edit' => '',493 'spam' => '', 'unspam' => '',494 'trash' => '', 'untrash' => '', 'delete' => ''495 );496 497 // Not looking at all comments.498 if ( $comment_status && 'all' != $comment_status ) {499 if ( 'approved' == $the_comment_status ) {500 $actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved' class='vim-u vim-destructive' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';501 } elseif ( 'unapproved' == $the_comment_status ) {502 $actions['approve'] = "<a href='$approve_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved' class='vim-a vim-destructive' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';503 }504 } else {505 $actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';506 $actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' class='vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';507 }508 509 if ( 'spam' != $the_comment_status ) {510 $actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';511 } elseif ( 'spam' == $the_comment_status ) {512 $actions['unspam'] = "<a href='$unspam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:66cc66:unspam=1' class='vim-z vim-destructive'>" . _x( 'Not Spam', 'comment' ) . '</a>';513 }514 515 if ( 'trash' == $the_comment_status ) {516 $actions['untrash'] = "<a href='$untrash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1' class='vim-z vim-destructive'>" . __( 'Restore' ) . '</a>';517 }518 519 if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) {520 $actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::delete=1' class='delete vim-d vim-destructive'>" . __( 'Delete Permanently' ) . '</a>';521 } else {522 $actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';523 }524 525 if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {526 $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . esc_attr__( 'Edit comment' ) . "'>". __( 'Edit' ) . '</a>';527 528 $format = '<a data-comment-id="%d" data-post-id="%d" data-action="%s" class="%s" title="%s" href="#">%s</a>';529 530 $actions['quickedit'] = sprintf( $format, $comment->comment_ID, $post->ID, 'edit', 'vim-q comment-inline',esc_attr__( 'Edit this item inline' ), __( 'Quick Edit' ) );531 532 $actions['reply'] = sprintf( $format, $comment->comment_ID, $post->ID, 'replyto', 'vim-r comment-inline', esc_attr__( 'Reply to this comment' ), __( 'Reply' ) );533 }534 535 /** This filter is documented in wp-admin/includes/dashboard.php */536 $actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );537 538 $i = 0;539 echo '<div class="row-actions">';540 foreach ( $actions as $action => $link ) {541 ++$i;542 ( ( ( 'approve' == $action || 'unapprove' == $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';543 544 // Reply and quickedit need a hide-if-no-js span when not added with ajax545 if ( ( 'reply' == $action || 'quickedit' == $action ) && ! defined('DOING_AJAX') )546 $action .= ' hide-if-no-js';547 elseif ( ( $action == 'untrash' && $the_comment_status == 'trash' ) || ( $action == 'unspam' && $the_comment_status == 'spam' ) ) {548 if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) )549 $action .= ' approve';550 else551 $action .= ' unapprove';552 }553 554 echo "<span class='$action'>$sep$link</span>";555 }556 echo '</div>';557 }558 599 } 559 600
Note: See TracChangeset
for help on using the changeset viewer.