Ticket #25408: 25408.4.diff
File 25408.4.diff, 65.5 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/class-wp-comments-list-table.php
323 323 ); 324 324 } 325 325 326 /** 327 * Get name of default primary column 328 * 329 * @since 4.3 330 * @access protected 331 * 332 * @return string 333 */ 334 protected function get_default_primary_column_name() { 335 return 'comment'; 336 } 337 326 338 public function display() { 327 339 wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' ); 328 340 … … 375 387 echo "</tr>\n"; 376 388 } 377 389 378 public function column_cb( $comment ) { 379 if ( $this->user_can ) { ?> 380 <label class="screen-reader-text" for="cb-select-<?php echo $comment->comment_ID; ?>"><?php _e( 'Select comment' ); ?></label> 381 <input id="cb-select-<?php echo $comment->comment_ID; ?>" type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /> 382 <?php 390 /** 391 * Generate and display row actions links 392 * 393 * @since 4.3 394 * @access protected 395 * 396 * @param object $comment Comment being acted upon 397 * @param string $column_name Current column name 398 * @param string $primary Primary column name 399 * 400 * @return string 401 */ 402 protected function handle_row_actions( $comment, $column_name, $primary ) { 403 global $comment_status; 404 405 if ( ! $this->user_can) { 406 return; 383 407 } 384 }385 408 386 public function column_comment( $comment ) {387 global $comment_status;388 409 $post = get_post(); 389 410 390 $comment_url = esc_url( get_comment_link( $comment->comment_ID ) );391 411 $the_comment_status = wp_get_comment_status( $comment->comment_ID ); 392 412 393 echo '<div class="comment-author">';394 $ this->column_author( $comment);395 echo '</div>';413 if( $primary === $column_name ) { 414 $del_nonce = esc_html('_wpnonce=' . wp_create_nonce("delete-comment_$comment->comment_ID")); 415 $approve_nonce = esc_html('_wpnonce=' . wp_create_nonce("approve-comment_$comment->comment_ID")); 396 416 397 echo '<div class="submitted-on">';398 /* translators: 2: comment date, 3: comment time */399 printf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>' ), $comment_url,400 /* translators: comment date format. See http://php.net/date */401 get_comment_date( __( 'Y/m/d' ) ),402 get_comment_date( get_option( 'time_format' ) )403 );404 405 if ( $comment->comment_parent ) {406 $parent = get_comment( $comment->comment_parent );407 $parent_link = esc_url( get_comment_link( $comment->comment_parent ) );408 $name = get_comment_author( $parent->comment_ID );409 printf( ' | '.__( 'In reply to <a href="%1$s">%2$s</a>.' ), $parent_link, $name );410 }411 412 echo '</div>';413 comment_text();414 if ( $this->user_can ) { ?>415 <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">416 <textarea class="comment" rows="1" cols="1"><?php417 /** This filter is documented in wp-admin/includes/comment.php */418 echo esc_textarea( apply_filters( 'comment_edit_pre', $comment->comment_content ) );419 ?></textarea>420 <div class="author-email"><?php echo esc_attr( $comment->comment_author_email ); ?></div>421 <div class="author"><?php echo esc_attr( $comment->comment_author ); ?></div>422 <div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div>423 <div class="comment_status"><?php echo $comment->comment_approved; ?></div>424 </div>425 <?php426 }427 428 if ( $this->user_can ) {429 $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );430 $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );431 432 417 $url = "comment.php?c=$comment->comment_ID"; 433 418 434 $approve_url = esc_url( $url . "&action=approvecomment&$approve_nonce");435 $unapprove_url = esc_url( $url . "&action=unapprovecomment&$approve_nonce");436 $spam_url = esc_url( $url . "&action=spamcomment&$del_nonce");437 $unspam_url = esc_url( $url . "&action=unspamcomment&$del_nonce");438 $trash_url = esc_url( $url . "&action=trashcomment&$del_nonce");439 $untrash_url = esc_url( $url . "&action=untrashcomment&$del_nonce");440 $delete_url = esc_url( $url . "&action=deletecomment&$del_nonce");419 $approve_url = esc_url($url . "&action=approvecomment&$approve_nonce"); 420 $unapprove_url = esc_url($url . "&action=unapprovecomment&$approve_nonce"); 421 $spam_url = esc_url($url . "&action=spamcomment&$del_nonce"); 422 $unspam_url = esc_url($url . "&action=unspamcomment&$del_nonce"); 423 $trash_url = esc_url($url . "&action=trashcomment&$del_nonce"); 424 $untrash_url = esc_url($url . "&action=untrashcomment&$del_nonce"); 425 $delete_url = esc_url($url . "&action=deletecomment&$del_nonce"); 441 426 442 427 // Preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash. 443 428 $actions = array( … … 450 435 ); 451 436 452 437 // Not looking at all comments. 453 if ( $comment_status && 'all' != $comment_status) {454 if ( 'approved' == $the_comment_status) {455 $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>';456 } elseif ( 'unapproved' == $the_comment_status) {457 $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>';438 if ($comment_status && 'all' != $comment_status) { 439 if ('approved' == $the_comment_status) { 440 $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>'; 441 } elseif ('unapproved' == $the_comment_status) { 442 $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>'; 458 443 } 459 444 } else { 460 $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>';461 $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>';445 $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>'; 446 $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>'; 462 447 } 463 448 464 if ( 'spam' != $the_comment_status ) { 465 $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>'; 466 } elseif ( 'spam' == $the_comment_status ) { 467 $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>'; 449 if ('spam' != $the_comment_status) { 450 $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 */ 451 _x('Spam', 'verb') . '</a>'; 452 } elseif ('spam' == $the_comment_status) { 453 $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>'; 468 454 } 469 455 470 if ( 'trash' == $the_comment_status) {471 $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>';456 if ('trash' == $the_comment_status) { 457 $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>'; 472 458 } 473 459 474 if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS) {475 $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>';460 if ('spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS) { 461 $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>'; 476 462 } else { 477 $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>';463 $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>'; 478 464 } 479 465 480 if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status) {481 $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . esc_attr__( 'Edit comment' ) . "'>". __( 'Edit') . '</a>';466 if ('spam' != $the_comment_status && 'trash' != $the_comment_status) { 467 $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . esc_attr__('Edit comment') . "'>" . __('Edit') . '</a>'; 482 468 483 469 $format = '<a data-comment-id="%d" data-post-id="%d" data-action="%s" class="%s" title="%s" href="#">%s</a>'; 484 470 485 $actions['quickedit'] = sprintf( $format, $comment->comment_ID, $post->ID, 'edit', 'vim-q comment-inline',esc_attr__( 'Edit this item inline' ), __( 'Quick Edit' ));471 $actions['quickedit'] = sprintf($format, $comment->comment_ID, $post->ID, 'edit', 'vim-q comment-inline', esc_attr__('Edit this item inline'), __('Quick Edit')); 486 472 487 $actions['reply'] = sprintf( $format, $comment->comment_ID, $post->ID, 'replyto', 'vim-r comment-inline', esc_attr__( 'Reply to this comment' ), __( 'Reply' ));473 $actions['reply'] = sprintf($format, $comment->comment_ID, $post->ID, 'replyto', 'vim-r comment-inline', esc_attr__('Reply to this comment'), __('Reply')); 488 474 } 489 475 490 476 /** This filter is documented in wp-admin/includes/dashboard.php */ 491 $actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment);477 $actions = apply_filters('comment_row_actions', array_filter($actions), $comment); 492 478 493 479 $i = 0; 494 480 echo '<div class="row-actions">'; 495 foreach ( $actions as $action => $link) {481 foreach ($actions as $action => $link) { 496 482 ++$i; 497 ( ( ( 'approve' == $action || 'unapprove' == $action ) && 2 === $i ) || 1 === $i) ? $sep = '' : $sep = ' | ';483 ((('approve' == $action || 'unapprove' == $action) && 2 === $i) || 1 === $i) ? $sep = '' : $sep = ' | '; 498 484 499 485 // Reply and quickedit need a hide-if-no-js span when not added with ajax 500 if ( ( 'reply' == $action || 'quickedit' == $action ) && ! defined('DOING_AJAX'))486 if (('reply' == $action || 'quickedit' == $action) && !defined('DOING_AJAX')) 501 487 $action .= ' hide-if-no-js'; 502 elseif ( ( $action == 'untrash' && $the_comment_status == 'trash' ) || ( $action == 'unspam' && $the_comment_status == 'spam' )) {503 if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ))488 elseif (($action == 'untrash' && $the_comment_status == 'trash') || ($action == 'unspam' && $the_comment_status == 'spam')) { 489 if ('1' == get_comment_meta($comment->comment_ID, '_wp_trash_meta_status', true)) 504 490 $action .= ' approve'; 505 491 else 506 492 $action .= ' unapprove'; … … 512 498 } 513 499 } 514 500 501 public function column_cb( $comment ) { 502 if ( $this->user_can ) { ?> 503 <label class="screen-reader-text" for="cb-select-<?php echo $comment->comment_ID; ?>"><?php _e( 'Select comment' ); ?></label> 504 <input id="cb-select-<?php echo $comment->comment_ID; ?>" type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /> 505 <?php 506 } 507 } 508 509 public function column_comment( $comment ) { 510 global $comment_status; 511 $post = get_post(); 512 513 $comment_url = esc_url( get_comment_link( $comment->comment_ID ) ); 514 $the_comment_status = wp_get_comment_status( $comment->comment_ID ); 515 516 echo '<div class="comment-author">'; 517 $this->column_author( $comment ); 518 echo '</div>'; 519 520 echo '<div class="submitted-on">'; 521 /* translators: 2: comment date, 3: comment time */ 522 printf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>' ), $comment_url, 523 /* translators: comment date format. See http://php.net/date */ 524 get_comment_date( __( 'Y/m/d' ) ), 525 get_comment_date( get_option( 'time_format' ) ) 526 ); 527 528 if ( $comment->comment_parent ) { 529 $parent = get_comment( $comment->comment_parent ); 530 $parent_link = esc_url( get_comment_link( $comment->comment_parent ) ); 531 $name = get_comment_author( $parent->comment_ID ); 532 printf( ' | '.__( 'In reply to <a href="%1$s">%2$s</a>.' ), $parent_link, $name ); 533 } 534 535 echo '</div>'; 536 comment_text(); 537 if ( $this->user_can ) { ?> 538 <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden"> 539 <textarea class="comment" rows="1" cols="1"><?php 540 /** This filter is documented in wp-admin/includes/comment.php */ 541 echo esc_textarea( apply_filters( 'comment_edit_pre', $comment->comment_content ) ); 542 ?></textarea> 543 <div class="author-email"><?php echo esc_attr( $comment->comment_author_email ); ?></div> 544 <div class="author"><?php echo esc_attr( $comment->comment_author ); ?></div> 545 <div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div> 546 <div class="comment_status"><?php echo $comment->comment_approved; ?></div> 547 </div> 548 <?php 549 } 550 } 551 515 552 public function column_author( $comment ) { 516 553 global $comment_status; 517 554 -
src/wp-admin/includes/class-wp-list-table.php
792 792 } 793 793 794 794 /** 795 * Get name of default primary column 796 * 797 * @since 4.3 798 * @access protected 799 * 800 * @return string 801 */ 802 protected function get_default_primary_column_name() { 803 return ''; 804 } 805 806 /** 807 * Get name of primary column. 808 * 809 * @since 4.3 810 * @access protected 811 * 812 * @return string Filtered name of primary column 813 */ 814 protected function get_primary_column_name() { 815 $columns = $this->get_columns(); 816 $default = $this->get_default_primary_column_name(); 817 /** 818 * Filter the name of the primary column for the current list table. 819 * 820 * @since 4.3 821 * 822 * @param string $default Column name default for the specific list table (eg: 'name') 823 * @param string $context Screen ID for specific list table (eg: 'plugins') 824 */ 825 $column = apply_filters( 'list_table_primary_column', $default, $this->screen->id ); 826 827 if ( empty( $column ) || ! isset( $columns[ $column ] ) ) { 828 $column = $default; 829 } 830 831 return $column; 832 } 833 834 /** 795 835 * Get a list of all, hidden and sortable columns, with filter applied 796 836 * 797 837 * @since 3.1.0 … … 831 871 $sortable[$id] = $data; 832 872 } 833 873 834 $this->_column_headers = array( $columns, $hidden, $sortable ); 874 $primary = $this->get_primary_column_name(); 875 $this->_column_headers = array( $columns, $hidden, $sortable, $primary ); 835 876 836 877 return $this->_column_headers; 837 878 } … … 1059 1100 * @param object $item The current item 1060 1101 */ 1061 1102 protected function single_row_columns( $item ) { 1062 list( $columns, $hidden ) = $this->get_column_info();1103 list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); 1063 1104 1064 1105 foreach ( $columns as $column_name => $column_display_name ) { 1065 $class = "class='$column_name column-$column_name'"; 1106 $classes = "$column_name column-$column_name"; 1107 if ( $primary === $column_name ) { 1108 $classes .= ' has-row-actions'; 1109 } 1066 1110 1067 1111 $style = ''; 1068 if ( in_array( $column_name, $hidden ) ) 1112 if ( in_array( $column_name, $hidden ) ) { 1069 1113 $style = ' style="display:none;"'; 1114 } 1070 1115 1071 $attributes = " $class$style";1116 $attributes = "class='$classes'$style"; 1072 1117 1073 1118 if ( 'cb' == $column_name ) { 1074 1119 echo '<th scope="row" class="check-column">'; … … 1078 1123 elseif ( method_exists( $this, 'column_' . $column_name ) ) { 1079 1124 echo "<td $attributes>"; 1080 1125 echo call_user_func( array( $this, 'column_' . $column_name ), $item ); 1126 echo $this->handle_row_actions( $item, $column_name, $primary ); 1081 1127 echo "</td>"; 1082 1128 } 1083 1129 else { … … 1089 1135 } 1090 1136 1091 1137 /** 1138 * Generate and display row actions links 1139 * 1140 * @since 4.3 1141 * @access protected 1142 * 1143 * @param object $item Item being acted upon 1144 * @param string $column_name Current column name 1145 * @param string $primary Primary column name 1146 * 1147 * @return string 1148 */ 1149 protected function handle_row_actions( $item, $column_name, $primary ) { 1150 return ''; 1151 } 1152 1153 /** 1092 1154 * Handle an incoming ajax request (called from admin-ajax.php) 1093 1155 * 1094 1156 * @since 3.1.0 -
src/wp-admin/includes/class-wp-media-list-table.php
288 288 <tr id="post-<?php echo $post->ID; ?>" class="<?php echo trim( ' author-' . $post_owner . ' status-' . $post->post_status ); ?>"> 289 289 <?php 290 290 291 list( $columns, $hidden ) = $this->get_column_info(); 291 list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); 292 292 293 foreach ( $columns as $column_name => $column_display_name ) { 293 $class = "class='$column_name column-$column_name'"; 294 $classes = "$column_name column-$column_name"; 295 if ( $primary === $column_name ) { 296 $classes .= ' has-row-actions'; 297 } 294 298 295 299 $style = ''; 296 if ( in_array( $column_name, $hidden ) ) 300 if ( in_array( $column_name, $hidden ) ) { 297 301 $style = ' style="display:none;"'; 302 } 298 303 299 $attributes = $class . $style;304 $attributes = "class='$classes'$style"; 300 305 301 306 switch ( $column_name ) { 302 307 … … 345 350 _media_states( $post ); ?></strong> 346 351 <p class="filename"><?php echo wp_basename( $post->guid ); ?></p> 347 352 <?php 348 echo $this->row_actions( $this->_get_row_actions( $post, $att_title ) ); 353 if( $primary === $column_name ) { 354 echo $this->row_actions( $this->_get_row_actions( $post, $att_title ) ); 355 } 349 356 ?> 350 357 </td> 351 358 <?php … … 358 365 esc_url( add_query_arg( array( 'author' => get_the_author_meta('ID') ), 'upload.php' ) ), 359 366 get_the_author() 360 367 ); 368 369 if( $primary === $column_name ) { 370 echo $this->row_actions( $this->_get_row_actions( $post, $att_title ) ); 371 } 361 372 ?></td> 362 373 <?php 363 374 break; … … 364 375 365 376 case 'desc': 366 377 ?> 367 <td <?php echo $attributes ?>><?php echo has_excerpt() ? $post->post_excerpt : ''; ?> </td>378 <td <?php echo $attributes ?>><?php echo has_excerpt() ? $post->post_excerpt : ''; ?> 368 379 <?php 380 if( $primary === $column_name ) { 381 echo $this->row_actions( $this->_get_row_actions( $post, $att_title ) ); 382 } 383 echo '</td>'; 369 384 break; 370 385 371 386 case 'date': … … 384 399 } 385 400 } 386 401 ?> 387 <td <?php echo $attributes ?>><?php echo $h_time ?> </td>402 <td <?php echo $attributes ?>><?php echo $h_time ?> 388 403 <?php 404 if( $primary === $column_name ) { 405 echo $this->row_actions( $this->_get_row_actions( $post, $att_title ) ); 406 } 407 echo '</td>'; 389 408 break; 390 409 391 410 case 'parent': … … 414 433 '_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] ) 415 434 ), 'upload.php' ); ?> 416 435 <a class="hide-if-no-js detach-from-parent" href="<?php echo $detach_url ?>"><?php _e( 'Detach' ); ?></a> 417 <?php endif; ?> 418 </td> 419 <?php 436 <?php endif; 420 437 } else { 421 438 ?> 422 439 <td <?php echo $attributes ?>><?php _e( '(Unattached)' ); ?><br /> … … 425 442 onclick="findPosts.open( 'media[]','<?php echo $post->ID ?>' ); return false;" 426 443 href="#the-list"> 427 444 <?php _e( 'Attach' ); ?></a> 428 <?php } ?></td> 429 <?php 445 <?php } 430 446 } 447 448 if( $primary === $column_name ) { 449 echo $this->row_actions( $this->_get_row_actions( $post, $att_title ) ); 450 } 451 echo '</td>'; 431 452 break; 432 453 433 454 case 'comments': … … 474 495 } else { 475 496 echo '—'; 476 497 } 498 if( $primary === $column_name ) { 499 echo $this->row_actions( $this->_get_row_actions( $post, $att_title ) ); 500 } 477 501 echo '</td>'; 478 502 break; 479 503 } … … 490 514 * @param int $post_id Attachment ID. 491 515 */ 492 516 do_action( 'manage_media_custom_column', $column_name, $post->ID ); 517 518 if( $primary === $column_name ) { 519 echo $this->row_actions( $this->_get_row_actions( $post, $att_title ) ); 520 } 493 521 ?></td> 494 522 <?php 495 523 break; … … 501 529 } 502 530 503 531 /** 532 * Get name of default primary column 533 * 534 * @since 4.3 535 * @access protected 536 * 537 * @return string 538 */ 539 protected function get_default_primary_column_name() { 540 return 'title'; 541 } 542 543 /** 504 544 * @param WP_Post $post 505 545 * @param string $att_title 506 546 */ -
src/wp-admin/includes/class-wp-ms-sites-list-table.php
234 234 235 235 $blogname = ( is_subdomain_install() ) ? str_replace( '.' . get_current_site()->domain, '', $blog['domain'] ) : $blog['path']; 236 236 237 list( $columns, $hidden ) = $this->get_column_info();237 list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); 238 238 239 239 foreach ( $columns as $column_name => $column_display_name ) { 240 $classes = "$column_name column-$column_name"; 241 if ( $primary === $column_name ) { 242 $classes .= ' has-row-actions'; 243 } 244 240 245 $style = ''; 241 if ( in_array( $column_name, $hidden ) ) 246 if ( in_array( $column_name, $hidden ) ) { 242 247 $style = ' style="display:none;"'; 248 } 243 249 250 $attributes = "class='$classes'$style"; 251 244 252 switch ( $column_name ) { 245 253 case 'cb': ?> 246 254 <th scope="row" class="check-column"> … … 260 268 break; 261 269 262 270 case 'blogname': 263 echo "<td class='column-$column_name $column_name'$style>"; ?> 264 <a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname . $blog_state; ?></a> 265 <?php 266 if ( 'list' != $mode ) { 267 switch_to_blog( $blog['blog_id'] ); 268 /* translators: 1: site name, 2: site tagline. */ 269 echo '<p>' . sprintf( __( '%1$s – <em>%2$s</em>' ), get_option( 'blogname' ), get_option( 'blogdescription ' ) ) . '</p>'; 270 restore_current_blog(); 271 } 272 273 // Preordered. 274 $actions = array( 275 'edit' => '', 'backend' => '', 276 'activate' => '', 'deactivate' => '', 277 'archive' => '', 'unarchive' => '', 278 'spam' => '', 'unspam' => '', 279 'delete' => '', 280 'visit' => '', 281 ); 282 283 $actions['edit'] = '<span class="edit"><a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a></span>'; 284 $actions['backend'] = "<span class='backend'><a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a></span>'; 285 if ( get_current_site()->blog_id != $blog['blog_id'] ) { 286 if ( get_blog_status( $blog['blog_id'], 'deleted' ) == '1' ) 287 $actions['activate'] = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=activateblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to activate the site %s' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Activate' ) . '</a></span>'; 288 else 289 $actions['deactivate'] = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deactivateblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to deactivate the site %s' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Deactivate' ) . '</a></span>'; 290 291 if ( get_blog_status( $blog['blog_id'], 'archived' ) == '1' ) 292 $actions['unarchive'] = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unarchiveblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to unarchive the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Unarchive' ) . '</a></span>'; 293 else 294 $actions['archive'] = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=archiveblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to archive the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Archive', 'verb; site' ) . '</a></span>'; 295 296 if ( get_blog_status( $blog['blog_id'], 'spam' ) == '1' ) 297 $actions['unspam'] = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unspamblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to unspam the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Not Spam', 'site' ) . '</a></span>'; 298 else 299 $actions['spam'] = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=spamblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to mark the site %s as spam.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Spam', 'site' ) . '</a></span>'; 300 301 if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) 302 $actions['delete'] = '<span class="delete"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deleteblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to delete the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Delete' ) . '</a></span>'; 303 } 304 305 $actions['visit'] = "<span class='view'><a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a></span>'; 306 307 /** 308 * Filter the action links displayed for each site in the Sites list table. 309 * 310 * The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by 311 * default for each site. The site's status determines whether to show the 312 * 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and 313 * 'Not Spam' or 'Spam' link for each site. 314 * 315 * @since 3.1.0 316 * 317 * @param array $actions An array of action links to be displayed. 318 * @param int $blog_id The site ID. 319 * @param string $blogname Site path, formatted depending on whether it is a sub-domain 320 * or subdirectory multisite install. 321 */ 322 $actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname ); 323 echo $this->row_actions( $actions ); 271 echo "<td $attributes>"; ?> 272 <a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname . $blog_state; ?></a> 273 <?php 274 if ( 'list' != $mode ) { 275 switch_to_blog( $blog['blog_id'] ); 276 /* translators: 1: site name, 2: site tagline. */ 277 echo '<p>' . sprintf( __( '%1$s – <em>%2$s</em>' ), get_option( 'blogname' ), get_option( 'blogdescription ' ) ) . '</p>'; 278 restore_current_blog(); 279 } 280 echo $this->handle_row_actions( $blog, $column_name, $primary ); 324 281 ?> 325 282 </td> 326 283 <?php … … 327 284 break; 328 285 329 286 case 'lastupdated': 330 echo "<td class='$column_name column-$column_name'$style>"; 331 echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] ); ?> 287 echo "<td $attributes>"; 288 echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] ); 289 echo $this->handle_row_actions( $blog, $column_name, $primary ); 290 ?> 332 291 </td> 333 292 <?php 334 293 break; 335 294 case 'registered': 336 echo "<td class='$column_name column-$column_name'$style>";295 echo "<td $attributes>"; 337 296 if ( $blog['registered'] == '0000-00-00 00:00:00' ) 338 297 echo '—'; 339 298 else 340 299 echo mysql2date( $date, $blog['registered'] ); 300 echo $this->handle_row_actions( $blog, $column_name, $primary ); 341 301 ?> 342 302 </td> 343 303 <?php 344 304 break; 345 305 case 'users': 346 echo "<td class='$column_name column-$column_name'$style>";306 echo "<td $attributes>"; 347 307 $blogusers = get_users( array( 'blog_id' => $blog['blog_id'], 'number' => 6) ); 348 308 if ( is_array( $blogusers ) ) { 349 309 $blogusers_warning = ''; … … 360 320 if ( $blogusers_warning != '' ) 361 321 echo '<strong>' . $blogusers_warning . '</strong><br />'; 362 322 } 323 324 echo $this->handle_row_actions( $blog, $column_name, $primary ); 363 325 ?> 364 326 </td> 365 327 <?php … … 367 329 368 330 case 'plugins': ?> 369 331 <?php if ( has_filter( 'wpmublogsaction' ) ) { 370 echo "<td class='$column_name column-$column_name'$style>";332 echo "<td $attributes>"; 371 333 /** 372 334 * Fires inside the auxiliary 'Actions' column of the Sites list table. 373 335 * … … 377 339 * 378 340 * @param int $blog_id The site ID. 379 341 */ 380 do_action( 'wpmublogsaction', $blog['blog_id'] ); ?> 342 do_action( 'wpmublogsaction', $blog['blog_id'] ); 343 344 echo $this->handle_row_actions( $blog, $column_name, $primary ); 345 ?> 381 346 </td> 382 347 <?php } 383 348 break; 384 349 385 350 default: 386 echo "<td class='$column_name column-$column_name'$style>";351 echo "<td $attributes>"; 387 352 /** 388 353 * Fires for each registered custom column in the Sites list table. 389 354 * … … 393 358 * @param int $blog_id The site ID. 394 359 */ 395 360 do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] ); 361 362 echo $this->handle_row_actions( $blog, $column_name, $primary ); 396 363 echo "</td>"; 397 364 break; 398 365 } … … 402 369 <?php 403 370 } 404 371 } 372 373 /** 374 * Get name of default primary column 375 * 376 * @since 4.3 377 * @access protected 378 * 379 * @return string 380 */ 381 protected function get_default_primary_column_name() { 382 return 'blogname'; 383 } 384 385 /** 386 * Generate and display row actions links 387 * 388 * @since 4.3 389 * @access protected 390 * 391 * @param object $blog Blog being acted upon 392 * @param string $column_name Current column name 393 * @param string $primary Primary column name 394 * 395 * @return string 396 */ 397 function handle_row_actions( $blog, $column_name, $primary ) { 398 global $current_site; 399 400 if ( $primary === $column_name ) { 401 $blogname = ( is_subdomain_install() ) ? str_replace( '.'.$current_site->domain, '', $blog['domain'] ) : $blog['path']; 402 403 // Preordered. 404 $actions = array( 405 'edit' => '', 'backend' => '', 406 'activate' => '', 'deactivate' => '', 407 'archive' => '', 'unarchive' => '', 408 'spam' => '', 'unspam' => '', 409 'delete' => '', 410 'visit' => '', 411 ); 412 413 $actions['edit'] = '<span class="edit"><a href="' . esc_url(network_admin_url('site-info.php?id=' . $blog['blog_id'])) . '">' . __('Edit') . '</a></span>'; 414 $actions['backend'] = "<span class='backend'><a href='" . esc_url(get_admin_url($blog['blog_id'])) . "' class='edit'>" . __('Dashboard') . '</a></span>'; 415 if (get_current_site()->blog_id != $blog['blog_id']) { 416 if (get_blog_status($blog['blog_id'], 'deleted') == '1') 417 $actions['activate'] = '<span class="activate"><a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&action2=activateblog&id=' . $blog['blog_id'] . '&msg=' . urlencode(sprintf(__('You are about to activate the site %s'), $blogname))), 'confirm')) . '">' . __('Activate') . '</a></span>'; 418 else 419 $actions['deactivate'] = '<span class="activate"><a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&action2=deactivateblog&id=' . $blog['blog_id'] . '&msg=' . urlencode(sprintf(__('You are about to deactivate the site %s'), $blogname))), 'confirm')) . '">' . __('Deactivate') . '</a></span>'; 420 421 if (get_blog_status($blog['blog_id'], 'archived') == '1') 422 $actions['unarchive'] = '<span class="archive"><a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&action2=unarchiveblog&id=' . $blog['blog_id'] . '&msg=' . urlencode(sprintf(__('You are about to unarchive the site %s.'), $blogname))), 'confirm')) . '">' . __('Unarchive') . '</a></span>'; 423 else 424 $actions['archive'] = '<span class="archive"><a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&action2=archiveblog&id=' . $blog['blog_id'] . '&msg=' . urlencode(sprintf(__('You are about to archive the site %s.'), $blogname))), 'confirm')) . '">' . _x('Archive', 'verb; site') . '</a></span>'; 425 426 if (get_blog_status($blog['blog_id'], 'spam') == '1') 427 $actions['unspam'] = '<span class="spam"><a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&action2=unspamblog&id=' . $blog['blog_id'] . '&msg=' . urlencode(sprintf(__('You are about to unspam the site %s.'), $blogname))), 'confirm')) . '">' . _x('Not Spam', 'site') . '</a></span>'; 428 else 429 $actions['spam'] = '<span class="spam"><a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&action2=spamblog&id=' . $blog['blog_id'] . '&msg=' . urlencode(sprintf(__('You are about to mark the site %s as spam.'), $blogname))), 'confirm')) . '">' . _x('Spam', 'site') . '</a></span>'; 430 431 if (current_user_can('delete_site', $blog['blog_id'])) 432 $actions['delete'] = '<span class="delete"><a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&action2=deleteblog&id=' . $blog['blog_id'] . '&msg=' . urlencode(sprintf(__('You are about to delete the site %s.'), $blogname))), 'confirm')) . '">' . __('Delete') . '</a></span>'; 433 } 434 435 $actions['visit'] = "<span class='view'><a href='" . esc_url(get_home_url($blog['blog_id'], '/')) . "' rel='permalink'>" . __('Visit') . '</a></span>'; 436 437 /** 438 * Filter the action links displayed for each site in the Sites list table. 439 * 440 * The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by 441 * default for each site. The site's status determines whether to show the 442 * 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and 443 * 'Not Spam' or 'Spam' link for each site. 444 * 445 * @since 3.1.0 446 * 447 * @param array $actions An array of action links to be displayed. 448 * @param int $blog_id The site ID. 449 * @param string $blogname Site path, formatted depending on whether it is a sub-domain 450 * or subdirectory multisite install. 451 */ 452 $actions = apply_filters('manage_sites_action_links', array_filter($actions), $blog['blog_id'], $blogname); 453 return $this->row_actions($actions); 454 } 455 } 405 456 } -
src/wp-admin/includes/class-wp-ms-themes-list-table.php
215 215 ); 216 216 } 217 217 218 /** 219 * Get name of default primary column 220 * 221 * @since 4.3 222 * @access protected 223 * 224 * @return string 225 */ 226 protected function get_default_primary_column_name() { 227 return 'name'; 228 } 229 218 230 protected function get_views() { 219 231 global $totals, $status; 220 232 … … 375 387 376 388 echo "<tr id='$id' class='$class'>"; 377 389 378 list( $columns, $hidden ) = $this->get_column_info();390 list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); 379 391 380 392 foreach ( $columns as $column_name => $column_display_name ) { 381 393 $style = ''; … … 388 400 break; 389 401 case 'name': 390 402 echo "<td class='theme-title'$style><strong>" . $theme->display('Name') . "</strong>"; 391 echo $this->row_actions( $actions, true ); 403 if ( $primary === $column_name ) { 404 echo $this->row_actions($actions, true); 405 } 392 406 echo "</td>"; 393 407 break; 394 408 case 'description': … … 426 440 $theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $stylesheet, $theme, $status ); 427 441 echo implode( ' | ', $theme_meta ); 428 442 429 echo "</div></td>"; 443 echo '</div>'; 444 if ( $primary === $column_name ) { 445 echo $this->row_actions($actions, true); 446 } 447 echo '</td>'; 430 448 break; 431 449 432 450 default: … … 442 460 * @param WP_Theme $theme Current WP_Theme object. 443 461 */ 444 462 do_action( 'manage_themes_custom_column', $column_name, $stylesheet, $theme ); 463 464 if ( $primary === $column_name ) { 465 echo $this->row_actions($actions, true); 466 } 445 467 echo "</td>"; 446 468 } 447 469 } -
src/wp-admin/includes/class-wp-ms-users-list-table.php
164 164 <tr class="<?php echo trim( $class ); ?>"> 165 165 <?php 166 166 167 list( $columns, $hidden ) = $this->get_column_info();167 list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); 168 168 169 169 foreach ( $columns as $column_name => $column_display_name ) : 170 $class = "class='$column_name column-$column_name'"; 170 $classes = "$column_name column-$column_name"; 171 if ( $primary === $column_name ) { 172 $classes .= ' has-row-actions'; 173 } 171 174 172 175 $style = ''; 173 if ( in_array( $column_name, $hidden ) ) 176 if ( in_array( $column_name, $hidden ) ) { 174 177 $style = ' style="display:none;"'; 178 } 175 179 176 $attributes = " $class$style";180 $attributes = "class='$classes'$style"; 177 181 178 182 switch ( $column_name ) { 179 183 case 'cb': ?> … … 193 197 if ( in_array( $user->user_login, $super_admins ) ) 194 198 echo ' - ' . __( 'Super Admin' ); 195 199 ?></strong> 196 <br/>197 <?php198 $actions = array();199 $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';200 201 if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins ) ) {202 $actions['delete'] = '<a href="' . $delete = esc_url( network_admin_url( add_query_arg( '_wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'users.php', 'deleteuser' ) . '&action=deleteuser&id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>';203 }204 205 /**206 * Filter the action links displayed under each user207 * in the Network Admin Users list table.208 *209 * @since 3.2.0210 *211 * @param array $actions An array of action links to be displayed.212 * Default 'Edit', 'Delete'.213 * @param WP_User $user WP_User object.214 */215 $actions = apply_filters( 'ms_user_row_actions', $actions, $user );216 echo $this->row_actions( $actions );217 ?>218 </td>219 200 <?php 220 201 break; 221 202 222 203 case 'name': 223 echo "<td $attributes>$user->first_name $user->last_name </td>";204 echo "<td $attributes>$user->first_name $user->last_name"; 224 205 break; 225 206 226 207 case 'email': 227 echo "<td $attributes><a href='mailto:$user->user_email'>$user->user_email</a> </td>";208 echo "<td $attributes><a href='mailto:$user->user_email'>$user->user_email</a>"; 228 209 break; 229 210 230 211 case 'registered': … … 233 214 else 234 215 $date = __( 'Y/m/d g:i:s a' ); 235 216 236 echo "<td $attributes>" . mysql2date( $date, $user->user_registered ) . "</td>";217 echo "<td $attributes>" . mysql2date( $date, $user->user_registered ); 237 218 break; 238 219 239 220 case 'blogs': … … 286 267 } 287 268 } 288 269 ?> 289 </td>290 270 <?php 291 271 break; 292 272 … … 294 274 echo "<td $attributes>"; 295 275 /** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */ 296 276 echo apply_filters( 'manage_users_custom_column', '', $column_name, $user->ID ); 297 echo "</td>";298 277 break; 299 278 } 279 280 echo $this->handle_row_actions( $user, $column_name, $primary ); 281 echo '</td>'; 300 282 endforeach 301 283 ?> 302 284 </tr> … … 303 285 <?php 304 286 } 305 287 } 288 289 /** 290 * Get name of default primary column 291 * 292 * @since 4.3 293 * @access protected 294 * 295 * @return string 296 */ 297 protected function get_default_primary_column_name() { 298 return 'username'; 299 } 300 301 /** 302 * Generate and display row actions links 303 * 304 * @since 4.3 305 * @access protected 306 * 307 * @param object $user User being acted upon 308 * @param string $column_name Current column name 309 * @param string $primary Primary column name 310 * 311 * @return string 312 */ 313 protected function handle_row_actions( $user, $column_name, $primary ) { 314 $super_admins = get_super_admins(); 315 $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) ); 316 317 if ( $primary === $column_name ) { 318 $actions = array(); 319 $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>'; 320 321 if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins ) ) { 322 $actions['delete'] = '<a href="' . $delete = esc_url( network_admin_url( add_query_arg( '_wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'users.php', 'deleteuser' ) . '&action=deleteuser&id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>'; 323 } 324 325 /** 326 * Filter the action links displayed under each user 327 * in the Network Admin Users list table. 328 * 329 * @since 3.2.0 330 * 331 * @param array $actions An array of action links to be displayed. 332 * Default 'Edit', 'Delete'. 333 * @param WP_User $user WP_User object. 334 */ 335 $actions = apply_filters( 'ms_user_row_actions', $actions, $user ); 336 return $this->row_actions( $actions ); 337 } 338 } 306 339 } -
src/wp-admin/includes/class-wp-plugins-list-table.php
301 301 add_query_arg('plugin_status', $type, 'plugins.php'), 302 302 ( $type == $status ) ? ' class="current"' : '', 303 303 sprintf( $text, number_format_i18n( $count ) ) 304 304 ); 305 305 } 306 306 } 307 307 … … 451 451 $actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&checked[]=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'bulk-plugins') . '" title="' . esc_attr__('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>'; 452 452 } // end if $is_active 453 453 454 454 } // end if $screen->in_admin( 'network' ) 455 455 456 456 if ( ( ! is_multisite() || $screen->in_admin( 'network' ) ) && current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) ) 457 457 $actions['edit'] = '<a href="plugin-editor.php?file=' . $plugin_file . '" title="' . esc_attr__('Open this file in the Plugin Editor') . '" class="edit">' . __('Edit') . '</a>'; … … 531 531 $plugin_slug 532 532 ); 533 533 534 list( $columns, $hidden ) = $this->get_column_info();534 list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); 535 535 536 $extra_class = ' has-row-actions'; 537 536 538 foreach ( $columns as $column_name => $column_display_name ) { 537 539 $style = ''; 538 if ( in_array( $column_name, $hidden ) ) 540 if ( in_array( $column_name, $hidden ) ) { 539 541 $style = ' style="display:none;"'; 542 } 540 543 541 544 switch ( $column_name ) { 542 545 case 'cb': … … 543 546 echo "<th scope='row' class='check-column'>$checkbox</th>"; 544 547 break; 545 548 case 'name': 546 echo "<td class='plugin-title'$style><strong>$plugin_name</strong>"; 547 echo $this->row_actions( $actions, true ); 549 if ( $primary === $column_name || ! isset( $columns[ $primary ] ) ) { 550 echo "<td class='plugin-title $extra_class'$style><strong>$plugin_name</strong>"; 551 echo $this->row_actions( $actions, true ); 552 } else { 553 echo "<td class='plugin-title'$style><strong>$plugin_name</strong>"; 554 } 548 555 echo "</td>"; 549 556 break; 550 557 case 'description': 551 echo "<td class='column-description desc'$style> 558 $classes = 'column-description desc'; 559 if ( $primary === $column_name ) { 560 $classes .= " $extra_class"; 561 } 562 563 echo "<td class='$classes'$style> 552 564 <div class='plugin-description'>$description</div> 553 565 <div class='$class second plugin-version-author-uri'>"; 554 566 … … 595 607 $plugin_meta = apply_filters( 'plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $status ); 596 608 echo implode( ' | ', $plugin_meta ); 597 609 610 if ( $primary === $column_name ) { 611 echo $this->row_actions( $actions, true ); 612 } 598 613 echo "</div></td>"; 599 614 break; 600 615 default: 601 echo "<td class='$column_name column-$column_name'$style>"; 616 $classes = "$column_name column-$column_name$class"; 617 if ( $primary === $column_name ) { 618 $classes .= " $extra_class"; 619 } 602 620 621 echo "<td class='$classes'$style>"; 622 603 623 /** 604 624 * Fires inside each custom column of the Plugins list table. 605 625 * … … 610 630 * @param array $plugin_data An array of plugin data. 611 631 */ 612 632 do_action( 'manage_plugins_custom_column', $column_name, $plugin_file, $plugin_data ); 633 634 if ( $primary === $column_name ) { 635 echo $this->row_actions( $actions, true ); 636 } 613 637 echo "</td>"; 614 638 } 615 639 } … … 645 669 */ 646 670 do_action( "after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $status ); 647 671 } 648 } 672 673 /** 674 * Get name of default primary column for this specific list table. 675 * 676 * @since 4.3 677 * @access protected 678 * 679 * @return string 680 */ 681 protected function get_default_primary_column_name() { 682 return 'desc'; 683 } 684 } 685 No newline at end of file -
src/wp-admin/includes/class-wp-posts-list-table.php
665 665 <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>"> 666 666 <?php 667 667 668 list( $columns, $hidden ) = $this->get_column_info();668 list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); 669 669 670 670 foreach ( $columns as $column_name => $column_display_name ) { 671 $class = "class=\"$column_name column-$column_name\""; 671 $classes = "$column_name column-$column_name"; 672 if ( $primary === $column_name ) { 673 $classes .= ' has-row-actions'; 674 } 672 675 673 676 $style = ''; 674 if ( in_array( $column_name, $hidden ) ) 677 if ( in_array( $column_name, $hidden ) ) { 675 678 $style = ' style="display:none;"'; 679 } 676 680 677 $attributes = " $class$style";681 $attributes = "class='$classes'$style"; 678 682 679 683 switch ( $column_name ) { 680 684 … … 696 700 break; 697 701 698 702 case 'title': 699 $attributes = 'class="post-title page-title column-title"' . $style; 703 $classes .= ' page-title'; // Special addition for title column 704 $attributes = "class='$classes'$style"; 700 705 if ( $this->hierarchical_display ) { 701 706 if ( 0 == $level && (int) $post->post_parent > 0 ) { 702 707 // Sent level 0 by accident, by default, or because we don't know the actual level. … … 753 758 if ( ! $this->hierarchical_display && 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) ) 754 759 the_excerpt(); 755 760 756 $actions = array(); 757 if ( $can_edit_post && 'trash' != $post->post_status ) { 758 $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID ) . '" title="' . esc_attr__( 'Edit this item' ) . '">' . __( 'Edit' ) . '</a>'; 759 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr__( 'Edit this item inline' ) . '">' . __( 'Quick Edit' ) . '</a>'; 760 } 761 if ( current_user_can( 'delete_post', $post->ID ) ) { 762 if ( 'trash' == $post->post_status ) 763 $actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash' ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>"; 764 elseif ( EMPTY_TRASH_DAYS ) 765 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash' ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>"; 766 if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS ) 767 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently' ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>"; 768 } 769 if ( $post_type_object->public ) { 770 if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) { 771 if ( $can_edit_post ) { 772 $preview_link = set_url_scheme( get_permalink( $post->ID ) ); 773 /** This filter is documented in wp-admin/includes/meta-boxes.php */ 774 $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post ); 775 $actions['view'] = '<a href="' . esc_url( $preview_link ) . '" title="' . esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>'; 776 } 777 } elseif ( 'trash' != $post->post_status ) { 778 $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View “%s”' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>'; 779 } 780 } 761 echo $this->handle_row_actions( $post, $column_name, $primary ); 781 762 782 if ( is_post_type_hierarchical( $post->post_type ) ) {783 784 /**785 * Filter the array of row action links on the Pages list table.786 *787 * The filter is evaluated only for hierarchical post types.788 *789 * @since 2.8.0790 *791 * @param array $actions An array of row action links. Defaults are792 * 'Edit', 'Quick Edit', 'Restore, 'Trash',793 * 'Delete Permanently', 'Preview', and 'View'.794 * @param WP_Post $post The post object.795 */796 $actions = apply_filters( 'page_row_actions', $actions, $post );797 } else {798 799 /**800 * Filter the array of row action links on the Posts list table.801 *802 * The filter is evaluated only for non-hierarchical post types.803 *804 * @since 2.8.0805 *806 * @param array $actions An array of row action links. Defaults are807 * 'Edit', 'Quick Edit', 'Restore, 'Trash',808 * 'Delete Permanently', 'Preview', and 'View'.809 * @param WP_Post $post The post object.810 */811 $actions = apply_filters( 'post_row_actions', $actions, $post );812 }813 814 echo $this->row_actions( $actions );815 816 763 get_inline_data( $post ); 817 764 echo '</td>'; 818 765 break; … … 868 815 } else { 869 816 _e( 'Last Modified' ); 870 817 } 818 echo $this->handle_row_actions( $post, $column_name, $primary ); 871 819 echo '</td>'; 872 820 break; 873 821 … … 879 827 880 828 $this->comments_bubble( $post->ID, $pending_comments ); 881 829 ?> 882 </div>< /td>830 </div><?php echo $this->handle_row_actions( $post, $column_name, $primary ); ?></td> 883 831 <?php 884 832 break; 885 833 … … 890 838 esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'author' => get_the_author_meta( 'ID' ) ), 'edit.php' )), 891 839 get_the_author() 892 840 ); 841 echo $this->handle_row_actions( $post, $column_name, $primary ); 893 842 ?></td> 894 843 <?php 895 844 break; … … 930 879 } else { 931 880 echo '—'; 932 881 } 882 echo $this->handle_row_actions( $post, $column_name, $primary ); 933 883 echo '</td>'; 934 884 break; 935 885 } … … 976 926 * @param int $post_id The current post ID. 977 927 */ 978 928 do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID ); 929 echo $this->handle_row_actions( $post, $column_name, $primary ); 979 930 ?></td> 980 931 <?php 981 932 break; … … 988 939 } 989 940 990 941 /** 942 * Get name of default primary column 943 * 944 * @since 4.3 945 * @access protected 946 * 947 * @return string 948 */ 949 protected function get_default_primary_column_name() { 950 return( 'author' ); 951 } 952 953 /** 954 * Generate and display row actions links 955 * 956 * @since 4.3 957 * @access protected 958 * 959 * @param object $post Post being acted upon 960 * @param string $column_name Current column name 961 * @param string $primary Primary column name 962 * 963 * @return string 964 */ 965 protected function handle_row_actions( $post, $column_name, $primary ) { 966 $title = _draft_or_post_title(); 967 968 if ( $primary === $column_name ) { 969 $post_type_object = get_post_type_object( $post->post_type ); 970 $can_edit_post = current_user_can( 'edit_post', $post->ID ); 971 $actions = array(); 972 973 if ($can_edit_post && 'trash' != $post->post_status) { 974 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID) . '" title="' . esc_attr__('Edit this item') . '">' . __('Edit') . '</a>'; 975 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr__('Edit this item inline') . '">' . __('Quick Edit') . '</a>'; 976 } 977 978 if (current_user_can('delete_post', $post->ID)) { 979 if ('trash' == $post->post_status) 980 $actions['untrash'] = "<a title='" . esc_attr__('Restore this item from the Trash') . "' href='" . wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link . '&action=untrash', $post->ID)), 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>"; 981 elseif (EMPTY_TRASH_DAYS) 982 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__('Move this item to the Trash') . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Trash') . "</a>"; 983 if ('trash' == $post->post_status || !EMPTY_TRASH_DAYS) 984 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__('Delete this item permanently') . "' href='" . get_delete_post_link($post->ID, '', true) . "'>" . __('Delete Permanently') . "</a>"; 985 } 986 987 if ($post_type_object->public) { 988 if (in_array($post->post_status, array('pending', 'draft', 'future'))) { 989 if ($can_edit_post) { 990 $preview_link = set_url_scheme(get_permalink($post->ID)); 991 /** This filter is documented in wp-admin/includes/meta-boxes.php */ 992 $preview_link = apply_filters('preview_post_link', add_query_arg('preview', 'true', $preview_link), $post); 993 $actions['view'] = '<a href="' . esc_url($preview_link) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>'; 994 } 995 } elseif ('trash' != $post->post_status) { 996 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>'; 997 } 998 } 999 1000 if (is_post_type_hierarchical($post->post_type)) { 1001 1002 /** 1003 * Filter the array of row action links on the Pages list table. 1004 * 1005 * The filter is evaluated only for hierarchical post types. 1006 * 1007 * @since 2.8.0 1008 * 1009 * @param array $actions An array of row action links. Defaults are 1010 * 'Edit', 'Quick Edit', 'Restore, 'Trash', 1011 * 'Delete Permanently', 'Preview', and 'View'. 1012 * @param WP_Post $post The post object. 1013 */ 1014 $actions = apply_filters('page_row_actions', $actions, $post); 1015 } else { 1016 1017 /** 1018 * Filter the array of row action links on the Posts list table. 1019 * 1020 * The filter is evaluated only for non-hierarchical post types. 1021 * 1022 * @since 2.8.0 1023 * 1024 * @param array $actions An array of row action links. Defaults are 1025 * 'Edit', 'Quick Edit', 'Restore, 'Trash', 1026 * 'Delete Permanently', 'Preview', and 'View'. 1027 * @param WP_Post $post The post object. 1028 */ 1029 $actions = apply_filters('post_row_actions', $actions, $post); 1030 } 1031 1032 return $this->row_actions($actions); 1033 } 1034 } 1035 1036 /** 991 1037 * Outputs the hidden row displayed when inline editing 992 1038 * 993 1039 * @since 3.1.0 -
src/wp-admin/includes/class-wp-terms-list-table.php
302 302 */ 303 303 public function column_name( $tag ) { 304 304 $taxonomy = $this->screen->taxonomy; 305 $tax = get_taxonomy( $taxonomy );306 305 307 $default_term = get_option( 'default_' . $taxonomy );308 309 306 $pad = str_repeat( '— ', max( 0, $this->level ) ); 310 307 311 308 /** … … 328 325 329 326 $out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit “%s”' ), $name ) ) . '">' . $name . '</a></strong><br />'; 330 327 331 $actions = array();332 if ( current_user_can( $tax->cap->edit_terms ) ) {333 $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';334 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __( 'Quick Edit' ) . '</a>';335 }336 if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )337 $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url( "edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) . "'>" . __( 'Delete' ) . "</a>";338 if ( $tax->public )339 $actions['view'] = '<a href="' . get_term_link( $tag ) . '">' . __( 'View' ) . '</a>';340 341 /**342 * Filter the action links displayed for each term in the Tags list table.343 *344 * @since 2.8.0345 * @deprecated 3.0.0 Use {$taxonomy}_row_actions instead.346 *347 * @param array $actions An array of action links to be displayed. Default348 * 'Edit', 'Quick Edit', 'Delete', and 'View'.349 * @param object $tag Term object.350 */351 $actions = apply_filters( 'tag_row_actions', $actions, $tag );352 353 /**354 * Filter the action links displayed for each term in the terms list table.355 *356 * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.357 *358 * @since 3.0.0359 *360 * @param array $actions An array of action links to be displayed. Default361 * 'Edit', 'Quick Edit', 'Delete', and 'View'.362 * @param object $tag Term object.363 */364 $actions = apply_filters( "{$taxonomy}_row_actions", $actions, $tag );365 366 $out .= $this->row_actions( $actions );367 328 $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">'; 368 329 $out .= '<div class="name">' . $qe_data->name . '</div>'; 369 330 … … 375 336 } 376 337 377 338 /** 339 * Get name of default primary column 340 * 341 * @since 4.3 342 * @access protected 343 * 344 * @return string 345 */ 346 protected function get_default_primary_column_name() { 347 return 'name'; 348 } 349 350 /** 351 * Generate and display row actions links 352 * 353 * @since 4.3 354 * @access protected 355 * 356 * @param object $tag Tag being acted upon 357 * @param string $column_name Current column name 358 * @param string $primary Primary column name 359 * 360 * @return string 361 */ 362 protected function handle_row_actions( $tag, $column_name, $primary ) { 363 $taxonomy = $this->screen->taxonomy; 364 $tax = get_taxonomy( $taxonomy ); 365 $default_term = get_option( 'default_' . $taxonomy ); 366 367 $edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) ); 368 369 if ( $primary === $column_name ) { 370 $actions = array(); 371 if ( current_user_can( $tax->cap->edit_terms ) ) { 372 $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>'; 373 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __( 'Quick Edit' ) . '</a>'; 374 } 375 if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term ) 376 $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url( "edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) . "'>" . __( 'Delete' ) . "</a>"; 377 if ( $tax->public ) 378 $actions['view'] = '<a href="' . get_term_link( $tag ) . '">' . __( 'View' ) . '</a>'; 379 380 /** 381 * Filter the action links displayed for each term in the Tags list table. 382 * 383 * @since 2.8.0 384 * @deprecated 3.0.0 Use {$taxonomy}_row_actions instead. 385 * 386 * @param array $actions An array of action links to be displayed. Default 387 * 'Edit', 'Quick Edit', 'Delete', and 'View'. 388 * @param object $tag Term object. 389 */ 390 $actions = apply_filters( 'tag_row_actions', $actions, $tag ); 391 392 /** 393 * Filter the action links displayed for each term in the terms list table. 394 * 395 * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug. 396 * 397 * @since 3.0.0 398 * 399 * @param array $actions An array of action links to be displayed. Default 400 * 'Edit', 'Quick Edit', 'Delete', and 'View'. 401 * @param object $tag Term object. 402 */ 403 $actions = apply_filters( "{$taxonomy}_row_actions", $actions, $tag ); 404 405 return $this->row_actions( $actions ); 406 } 407 } 408 409 /** 378 410 * @param object $tag 379 411 * @return string 380 412 */ -
src/wp-admin/includes/class-wp-users-list-table.php
384 384 * @param WP_User $user_object WP_User object for the currently-listed user. 385 385 */ 386 386 $actions = apply_filters( 'user_row_actions', $actions, $user_object ); 387 $edit .= $this->row_actions( $actions );388 387 389 388 // Set up the checkbox ( because the user is editable, otherwise it's empty ) 390 389 $checkbox = '<label class="screen-reader-text" for="user_' . $user_object->ID . '">' . sprintf( __( 'Select %s' ), $user_object->user_login ) . '</label>' … … 398 397 399 398 $r = "<tr id='user-$user_object->ID'>"; 400 399 401 list( $columns, $hidden ) = $this->get_column_info();400 list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); 402 401 403 402 foreach ( $columns as $column_name => $column_display_name ) { 404 $class = "class=\"$column_name column-$column_name\""; 403 $classes = "$column_name column-$column_name"; 404 if ( $primary === $column_name ) { 405 $classes .= ' has-row-actions'; 406 } 405 407 406 408 $style = ''; 407 if ( in_array( $column_name, $hidden ) ) 409 if ( in_array( $column_name, $hidden ) ) { 408 410 $style = ' style="display:none;"'; 411 } 409 412 410 $attributes = " $class$style";413 $attributes = "class='$classes'$style"; 411 414 412 415 switch ( $column_name ) { 413 416 case 'cb': … … 414 417 $r .= "<th scope='row' class='check-column'>$checkbox</th>"; 415 418 break; 416 419 case 'username': 417 $r .= "<td $attributes>$avatar $edit </td>";420 $r .= "<td $attributes>$avatar $edit"; 418 421 break; 419 422 case 'name': 420 $r .= "<td $attributes>$user_object->first_name $user_object->last_name </td>";423 $r .= "<td $attributes>$user_object->first_name $user_object->last_name"; 421 424 break; 422 425 case 'email': 423 $r .= "<td $attributes><a href='mailto:$email' title='" . esc_attr( sprintf( __( 'E-mail: %s' ), $email ) ) . "'>$email</a> </td>";426 $r .= "<td $attributes><a href='mailto:$email' title='" . esc_attr( sprintf( __( 'E-mail: %s' ), $email ) ) . "'>$email</a>"; 424 427 break; 425 428 case 'role': 426 $r .= "<td $attributes>$role_name </td>";429 $r .= "<td $attributes>$role_name"; 427 430 break; 428 431 case 'posts': 429 432 $attributes = 'class="posts column-posts num"' . $style; … … 435 438 } else { 436 439 $r .= 0; 437 440 } 438 $r .= "</td>";439 441 break; 440 442 default: 441 443 $r .= "<td $attributes>"; … … 450 452 * @param int $user_id ID of the currently-listed user. 451 453 */ 452 454 $r .= apply_filters( 'manage_users_custom_column', '', $column_name, $user_object->ID ); 453 $r .= "</td>";454 455 } 456 457 if ( $primary === $column_name ) { 458 $r .= $this->row_actions( $actions ); 459 } 460 $r .= "</td>"; 455 461 } 456 462 $r .= '</tr>'; 457 463 458 464 return $r; 459 465 } 466 467 /** 468 * Get name of default primary column 469 * 470 * @since 4.3 471 * @access protected 472 * 473 * @return string 474 */ 475 protected function get_default_primary_column_name() { 476 return 'username'; 477 } 460 478 }