Make WordPress Core

Changeset 32644


Ignore:
Timestamp:
05/29/2015 02:40:52 AM (11 years ago)
Author:
helen
Message:

List tables: introduce the concept of a "primary" column.

This becomes the column that contains the row actions, and allows for a more flexibility, particularly with custom post types and list tables. To (re)define the primary column, use the list_table_primary_column filter, which receives the column name and the screen ID as arguments.

props stephdau, DaveAl, jesin.
see #25408.

Location:
trunk/src/wp-admin/includes
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-comments-list-table.php

    r32642 r32644  
    358358        }
    359359
     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
    360372        public function display() {
    361373                wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
     
    414426                $this->single_row_columns( $comment );
    415427                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&amp;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&amp;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&amp;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&nbsp;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;
    416543        }
    417544
     
    470597                <?php
    471598                }
    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&amp;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&amp;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&amp;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&nbsp;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 ajax
    545                                 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                                         else
    551                                                 $action .= ' unapprove';
    552                                 }
    553 
    554                                 echo "<span class='$action'>$sep$link</span>";
    555                         }
    556                         echo '</div>';
    557                 }
    558599        }
    559600
  • trunk/src/wp-admin/includes/class-wp-links-list-table.php

    r32642 r32644  
    122122
    123123        /**
     124         * Get name of default primary column
     125         *
     126         * @since 4.3.0
     127         * @access protected
     128         *
     129         * @return string
     130         */
     131        protected function get_default_primary_column_name() {
     132                return 'name';
     133        }
     134
     135        /**
    124136         *
    125137         * @global int $cat_id
     
    143155<?php
    144156
    145                         list( $columns, $hidden ) = $this->get_column_info();
     157                        list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
    146158
    147159                        foreach ( $columns as $column_name => $column_display_name ) {
    148                                 $class = "class='column-$column_name'";
     160                                $classes = "$column_name column-$column_name";
     161                                if ( $primary === $column_name ) {
     162                                        $classes .= ' has-row-actions column-primary';
     163                                }
    149164
    150165                                $style = '';
    151                                 if ( in_array( $column_name, $hidden ) )
     166                                if ( in_array( $column_name, $hidden ) ) {
    152167                                        $style = ' style="display:none;"';
    153 
    154                                 $attributes = $class . $style;
    155 
    156                                 switch ( $column_name ) {
    157                                         case 'cb': ?>
    158                                                 <th scope="row" class="check-column">
    159                                                         <label class="screen-reader-text" for="cb-select-<?php echo $link->link_id; ?>"><?php echo sprintf( __( 'Select %s' ), $link->link_name ); ?></label>
    160                                                         <input type="checkbox" name="linkcheck[]" id="cb-select-<?php echo $link->link_id; ?>" value="<?php echo esc_attr( $link->link_id ); ?>" />
    161                                                 </th>
    162                                                 <?php
    163                                                 break;
    164 
    165                                         case 'name':
    166                                                 echo "<td $attributes><strong><a class='row-title' href='$edit_link' title='" . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $link->link_name ) ) . "'>$link->link_name</a></strong><br />";
    167 
    168                                                 $actions = array();
    169                                                 $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
    170                                                 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id ) . "' onclick=\"if ( confirm( '" . esc_js( sprintf( __( "You are about to delete this link '%s'\n  'Cancel' to stop, 'OK' to delete." ), $link->link_name ) ) . "' ) ) { return true;}return false;\">" . __( 'Delete' ) . "</a>";
    171                                                 echo $this->row_actions( $actions );
    172 
    173                                                 echo '</td>';
    174                                                 break;
    175                                         case 'url':
    176                                                 echo "<td $attributes><a href='$link->link_url' title='". esc_attr( sprintf( __( 'Visit %s' ), $link->link_name ) )."'>$short_url</a></td>";
    177                                                 break;
    178                                         case 'categories':
    179                                                 ?><td <?php echo $attributes ?>><?php
    180                                                 $cat_names = array();
    181                                                 foreach ( $link->link_category as $category ) {
    182                                                         $cat = get_term( $category, 'link_category', OBJECT, 'display' );
    183                                                         if ( is_wp_error( $cat ) )
    184                                                                 echo $cat->get_error_message();
    185                                                         $cat_name = $cat->name;
    186                                                         if ( $cat_id != $category )
    187                                                                 $cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>";
    188                                                         $cat_names[] = $cat_name;
    189                                                 }
    190                                                 echo implode( ', ', $cat_names );
    191                                                 ?></td><?php
    192                                                 break;
    193                                         case 'rel':
    194                                                 ?><td <?php echo $attributes ?>><?php echo empty( $link->link_rel ) ? '<br />' : $link->link_rel; ?></td><?php
    195                                                 break;
    196                                         case 'visible':
    197                                                 ?><td <?php echo $attributes ?>><?php echo $visible; ?></td><?php
    198                                                 break;
    199                                         case 'rating':
    200                                                 ?><td <?php echo $attributes ?>><?php echo $rating; ?></td><?php
    201                                                 break;
    202                                         default:
    203                                                 ?>
    204                                                 <td <?php echo $attributes ?>><?php
     168                                }
     169
     170                                $attributes = "class='$classes'$style";
     171
     172                                if ( 'cb' === $column_name ) {
     173                                        ?>
     174                                        <th scope="row" class="check-column">
     175                                                <label class="screen-reader-text" for="cb-select-<?php echo $link->link_id; ?>"><?php echo sprintf( __( 'Select %s' ), $link->link_name ); ?></label>
     176                                                <input type="checkbox" name="linkcheck[]" id="cb-select-<?php echo $link->link_id; ?>" value="<?php echo esc_attr( $link->link_id ); ?>" />
     177                                        </th>
     178                                        <?php
     179                                } else {
     180                                        echo "<td $attributes>";
     181
     182                                        switch ( $column_name ) {
     183                                                case 'name':
     184                                                        echo "<strong><a class='row-title' href='$edit_link' title='" . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $link->link_name ) ) . "'>$link->link_name</a></strong><br />";
     185                                                        break;
     186                                                case 'url':
     187                                                        echo "<a href='$link->link_url' title='". esc_attr( sprintf( __( 'Visit %s' ), $link->link_name ) )."'>$short_url</a>";
     188                                                        break;
     189                                                case 'categories':
     190                                                        $cat_names = array();
     191                                                        foreach ( $link->link_category as $category ) {
     192                                                                $cat = get_term( $category, 'link_category', OBJECT, 'display' );
     193                                                                if ( is_wp_error( $cat ) )
     194                                                                        echo $cat->get_error_message();
     195                                                                $cat_name = $cat->name;
     196                                                                if ( $cat_id != $category )
     197                                                                        $cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>";
     198                                                                $cat_names[] = $cat_name;
     199                                                        }
     200                                                        echo implode( ', ', $cat_names );
     201                                                        break;
     202                                                case 'rel':
     203                                                        echo empty( $link->link_rel ) ? '<br />' : $link->link_rel;
     204                                                        break;
     205                                                case 'visible':
     206                                                        echo $visible;
     207                                                        break;
     208                                                case 'rating':
     209                                                        echo $rating;
     210                                                        break;
     211                                                default:
    205212                                                        /**
    206213                                                         * Fires for each registered custom link column.
     
    212219                                                         */
    213220                                                        do_action( 'manage_link_custom_column', $column_name, $link->link_id );
    214                                                 ?></td>
    215                                                 <?php
    216                                                 break;
     221                                                        break;
     222                                        }
     223
     224                                        echo $this->handle_row_actions( $link, $column_name, $primary );
     225                                        echo '</td>';
    217226                                }
    218227                        }
     
    222231                }
    223232        }
     233
     234        /**
     235         * Generate and display row actions links
     236         *
     237         * @since 4.3
     238         * @access protected
     239         *
     240         * @param object $link Link being acted upon
     241         * @param string $column_name Current column name
     242         * @param string $primary Primary column name
     243         *
     244         * @return string
     245         */
     246        protected function handle_row_actions( $link, $column_name, $primary ) {
     247                if( $primary === $column_name ) {
     248                        $edit_link = get_edit_bookmark_link( $link );
     249
     250                        $actions = array();
     251                        $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
     252                        $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id) . "' onclick=\"if ( confirm( '" . esc_js(sprintf(__("You are about to delete this link '%s'\n  'Cancel' to stop, 'OK' to delete."), $link->link_name)) . "' ) ) { return true;}return false;\">" . __('Delete') . "</a>";
     253                        return $this->row_actions($actions);
     254                }
     255        }
    224256}
  • trunk/src/wp-admin/includes/class-wp-list-table.php

    r32642 r32644  
    796796
    797797        /**
     798         * Get name of default primary column
     799         *
     800         * @since 4.3.0
     801         * @access protected
     802         *
     803         * @return string
     804         */
     805        protected function get_default_primary_column_name() {
     806                return '';
     807        }
     808
     809        /**
     810         * Get name of primary column.
     811         *
     812         * @since 4.3.0
     813         * @access protected
     814         *
     815         * @return string Filtered name of primary column
     816         */
     817        protected function get_primary_column_name() {
     818                $columns = $this->get_columns();
     819                $default = $this->get_default_primary_column_name();
     820                /**
     821                 * Filter the name of the primary column for the current list table, with context as argument (eg: 'plugins').
     822                 *
     823                 * @since 4.3.0
     824                 *
     825                 * @param string $default Column name default for the specific list table (eg: 'name')
     826                 * @param string $context Screen ID for specific list table (eg: 'plugins')
     827                 */
     828                $column  = apply_filters( 'list_table_primary_column', $default, $this->screen->id );
     829
     830                if ( empty( $column ) || ! isset( $columns[ $column ] ) ) {
     831                        $column = $default;
     832                }
     833
     834                return $column;
     835        }
     836
     837        /**
    798838         * Get a list of all, hidden and sortable columns, with filter applied
    799839         *
     
    835875                }
    836876
    837                 $this->_column_headers = array( $columns, $hidden, $sortable );
     877                $primary = $this->get_primary_column_name();
     878                $this->_column_headers = array( $columns, $hidden, $sortable, $primary );
    838879
    839880                return $this->_column_headers;
     
    10631104         */
    10641105        protected function single_row_columns( $item ) {
    1065                 list( $columns, $hidden ) = $this->get_column_info();
     1106                list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
    10661107
    10671108                foreach ( $columns as $column_name => $column_display_name ) {
    1068                         $class = "class='$column_name column-$column_name'";
     1109                        $classes = "$column_name column-$column_name";
     1110                        if ( $primary === $column_name ) {
     1111                                $classes .= ' has-row-actions column-primary';
     1112                        }
    10691113
    10701114                        $style = '';
    1071                         if ( in_array( $column_name, $hidden ) )
     1115                        if ( in_array( $column_name, $hidden ) ) {
    10721116                                $style = ' style="display:none;"';
    1073 
    1074                         $attributes = "$class$style";
     1117                        }
     1118
     1119                        $attributes = "class='$classes'$style";
    10751120
    10761121                        if ( 'cb' == $column_name ) {
     
    10821127                                echo "<td $attributes>";
    10831128                                echo call_user_func( array( $this, 'column_' . $column_name ), $item );
     1129                                echo $this->handle_row_actions( $item, $column_name, $primary );
    10841130                                echo "</td>";
    10851131                        }
     
    10871133                                echo "<td $attributes>";
    10881134                                echo $this->column_default( $item, $column_name );
     1135                                echo $this->handle_row_actions( $item, $column_name, $primary );
    10891136                                echo "</td>";
    10901137                        }
    10911138                }
    10921139        }
     1140
     1141        /**
     1142         * Generate and display row actions links
     1143         *
     1144         * @since 4.3.0
     1145         * @access protected
     1146         *
     1147         * @param object $item Item being acted upon
     1148         * @param string $column_name Current column name
     1149         * @param string $primary Primary column name
     1150         *
     1151         * @return string
     1152         */
     1153        protected function handle_row_actions( $item, $column_name, $primary ) {
     1154                return '';
     1155        }
    10931156
    10941157        /**
  • trunk/src/wp-admin/includes/class-wp-media-list-table.php

    r32642 r32644  
    309309<?php
    310310
    311 list( $columns, $hidden ) = $this->get_column_info();
     311list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
     312
    312313foreach ( $columns as $column_name => $column_display_name ) {
    313         $class = "class='$column_name column-$column_name'";
     314        $classes = "$column_name column-$column_name";
     315        if ( $primary === $column_name ) {
     316                $classes .= ' has-row-actions column-primary';
     317        }
    314318
    315319        $style = '';
    316         if ( in_array( $column_name, $hidden ) )
     320        if ( in_array( $column_name, $hidden ) ) {
    317321                $style = ' style="display:none;"';
    318 
    319         $attributes = $class . $style;
    320 
    321         switch ( $column_name ) {
    322 
    323         case 'cb':
     322        }
     323
     324        $attributes = "class='$classes'$style";
     325
     326        if ( 'cb' === $column_name ) {
    324327?>
    325328                <th scope="row" class="check-column">
     
    330333                </th>
    331334<?php
    332                 break;
    333 
    334         case 'icon':
    335                 list( $mime ) = explode( '/', $post->post_mime_type );
    336                 $attributes = 'class="column-icon media-icon ' . $mime . '-icon"' . $style;
    337 ?>
    338                 <td <?php echo $attributes ?>><?php
    339                         if ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) {
    340                                 if ( $this->is_trash || ! $user_can_edit ) {
    341                                         echo $thumb;
     335        } else {
     336                echo "<td $attributes>";
     337
     338                switch ( $column_name ) {
     339                        case 'icon':
     340                                list( $mime ) = explode( '/', $post->post_mime_type );
     341                                $attributes = 'class="column-icon media-icon ' . $mime . '-icon"' . $style;
     342
     343                                if ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) {
     344                                        if ( $this->is_trash || ! $user_can_edit ) {
     345                                                echo $thumb;
     346                                        } else { ?>
     347                                        <a href="<?php echo get_edit_post_link( $post->ID ); ?>" title="<?php echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $att_title ) ); ?>">
     348                                                <?php echo $thumb; ?>
     349                                        </a><?php
     350                                        }
     351                                }
     352                                break;
     353
     354                        case 'title':
     355?>
     356                                        <strong>
     357                                        <?php if ( $this->is_trash || ! $user_can_edit ) {
     358                                                echo $att_title;
     359                                        } else { ?>
     360                                        <a href="<?php echo get_edit_post_link( $post->ID ); ?>"
     361                                                title="<?php echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $att_title ) ); ?>">
     362                                                <?php echo $att_title; ?></a>
     363                                        <?php }
     364                                        _media_states( $post ); ?></strong>
     365                                        <p class="filename"><?php echo wp_basename( $post->guid ); ?></p>
     366<?php
     367                                break;
     368
     369                        case 'author':
     370                                printf( '<a href="%s">%s</a>',
     371                                        esc_url( add_query_arg( array( 'author' => get_the_author_meta('ID') ), 'upload.php' ) ),
     372                                        get_the_author()
     373                                );
     374
     375                                break;
     376
     377                        case 'desc':
     378                                echo has_excerpt() ? $post->post_excerpt : '';
     379                                break;
     380
     381                        case 'date':
     382                                if ( '0000-00-00 00:00:00' == $post->post_date ) {
     383                                        $h_time = __( 'Unpublished' );
    342384                                } else {
    343 ?>
    344                                 <a href="<?php echo get_edit_post_link( $post->ID ); ?>" title="<?php echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $att_title ) ); ?>">
    345                                         <?php echo $thumb; ?>
    346                                 </a>
    347 
    348 <?php                   }
    349                         }
    350 ?>
    351                 </td>
    352 <?php
    353                 break;
    354 
    355         case 'title':
    356 ?>
    357                 <td <?php echo $attributes ?>><strong>
    358                         <?php if ( $this->is_trash || ! $user_can_edit ) {
    359                                 echo $att_title;
    360                         } else { ?>
    361                         <a href="<?php echo get_edit_post_link( $post->ID ); ?>"
    362                                 title="<?php echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $att_title ) ); ?>">
    363                                 <?php echo $att_title; ?></a>
    364                         <?php };
    365                         _media_states( $post ); ?></strong>
    366                         <p class="filename"><?php echo wp_basename( $post->guid ); ?></p>
    367 <?php
    368                 echo $this->row_actions( $this->_get_row_actions( $post, $att_title ) );
    369 ?>
    370                 </td>
    371 <?php
    372                 break;
    373 
    374         case 'author':
    375 ?>
    376                 <td <?php echo $attributes ?>><?php
    377                         printf( '<a href="%s">%s</a>',
    378                                 esc_url( add_query_arg( array( 'author' => get_the_author_meta('ID') ), 'upload.php' ) ),
    379                                 get_the_author()
    380                         );
    381                 ?></td>
    382 <?php
    383                 break;
    384 
    385         case 'desc':
    386 ?>
    387                 <td <?php echo $attributes ?>><?php echo has_excerpt() ? $post->post_excerpt : ''; ?></td>
    388 <?php
    389                 break;
    390 
    391         case 'date':
    392                 if ( '0000-00-00 00:00:00' == $post->post_date ) {
    393                         $h_time = __( 'Unpublished' );
    394                 } else {
    395                         $m_time = $post->post_date;
    396                         $time = get_post_time( 'G', true, $post, false );
    397                         if ( ( abs( $t_diff = time() - $time ) ) < DAY_IN_SECONDS ) {
    398                                 if ( $t_diff < 0 )
    399                                         $h_time = sprintf( __( '%s from now' ), human_time_diff( $time ) );
     385                                        $m_time = $post->post_date;
     386                                        $time = get_post_time( 'G', true, $post, false );
     387                                        if ( ( abs( $t_diff = time() - $time ) ) < DAY_IN_SECONDS ) {
     388                                                if ( $t_diff < 0 )
     389                                                        $h_time = sprintf( __( '%s from now' ), human_time_diff( $time ) );
     390                                                else
     391                                                        $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
     392                                        } else {
     393                                                $h_time = mysql2date( __( 'Y/m/d' ), $m_time );
     394                                        }
     395                                }
     396
     397                                echo $h_time;
     398                                break;
     399
     400                        case 'parent':
     401                                if ( $post->post_parent > 0 )
     402                                        $parent = get_post( $post->post_parent );
    400403                                else
    401                                         $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
    402                         } else {
    403                                 $h_time = mysql2date( __( 'Y/m/d' ), $m_time );
    404                         }
    405                 }
    406 ?>
    407                 <td <?php echo $attributes ?>><?php echo $h_time ?></td>
    408 <?php
    409                 break;
    410 
    411         case 'parent':
    412                 if ( $post->post_parent > 0 )
    413                         $parent = get_post( $post->post_parent );
    414                 else
    415                         $parent = false;
    416 
    417                 if ( $parent ) {
    418                         $title = _draft_or_post_title( $post->post_parent );
    419                         $parent_type = get_post_type_object( $parent->post_type );
    420 ?>
    421                         <td <?php echo $attributes ?>><strong>
    422                                 <?php if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) { ?>
    423                                         <a href="<?php echo get_edit_post_link( $post->post_parent ); ?>">
    424                                                 <?php echo $title ?></a><?php
     404                                        $parent = false;
     405
     406                                if ( $parent ) {
     407                                        $title = _draft_or_post_title( $post->post_parent );
     408                                        $parent_type = get_post_type_object( $parent->post_type );
     409                ?>
     410                                        <strong>
     411                                        <?php if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) { ?>
     412                                                <a href="<?php echo get_edit_post_link( $post->post_parent ); ?>">
     413                                                        <?php echo $title ?></a><?php
     414                                        } else {
     415                                                echo $title;
     416                                        } ?></strong>,
     417                                        <?php echo get_the_time( __( 'Y/m/d' ) ); ?><br />
     418                                        <?php
     419                                        if ( $user_can_edit ):
     420                                                $detach_url = add_query_arg( array(
     421                                                        'parent_post_id' => $post->post_parent,
     422                                                        'media[]' => $post->ID,
     423                                                        '_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] )
     424                                                ), 'upload.php' ); ?>
     425                                        <a class="hide-if-no-js detach-from-parent" href="<?php echo $detach_url ?>"><?php _e( 'Detach' ); ?></a>
     426                                        <?php endif;
    425427                                } else {
    426                                         echo $title;
    427                                 } ?></strong>,
    428                                 <?php echo get_the_time( __( 'Y/m/d' ) ); ?><br />
    429                                 <?php
    430                                 if ( $user_can_edit ):
    431                                         $detach_url = add_query_arg( array(
    432                                                 'parent_post_id' => $post->post_parent,
    433                                                 'media[]' => $post->ID,
    434                                                 '_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] )
    435                                         ), 'upload.php' ); ?>
    436                                 <a class="hide-if-no-js detach-from-parent" href="<?php echo $detach_url ?>"><?php _e( 'Detach' ); ?></a>
    437                                 <?php endif; ?>
    438                         </td>
    439 <?php
    440                 } else {
    441 ?>
    442                         <td <?php echo $attributes ?>><?php _e( '(Unattached)' ); ?><br />
    443                         <?php if ( $user_can_edit ) { ?>
    444                                 <a class="hide-if-no-js"
    445                                         onclick="findPosts.open( 'media[]','<?php echo $post->ID ?>' ); return false;"
    446                                         href="#the-list">
    447                                         <?php _e( 'Attach' ); ?></a>
    448                         <?php } ?></td>
    449 <?php
    450                 }
    451                 break;
    452 
    453         case 'comments':
    454                 $attributes = 'class="comments column-comments num"' . $style;
    455 ?>
    456                 <td <?php echo $attributes ?>>
    457                         <div class="post-com-count-wrapper">
    458 <?php
    459                 $pending_comments = get_pending_comments_num( $post->ID );
    460 
    461                 $this->comments_bubble( $post->ID, $pending_comments );
    462 ?>
    463                         </div>
    464                 </td>
    465 <?php
    466                 break;
    467 
    468         default:
    469                 if ( 'categories' == $column_name )
    470                         $taxonomy = 'category';
    471                 elseif ( 'tags' == $column_name )
    472                         $taxonomy = 'post_tag';
    473                 elseif ( 0 === strpos( $column_name, 'taxonomy-' ) )
    474                         $taxonomy = substr( $column_name, 9 );
    475                 else
    476                         $taxonomy = false;
    477 
    478                 if ( $taxonomy ) {
    479                         echo '<td ' . $attributes . '>';
    480                         if ( $terms = get_the_terms( $post->ID, $taxonomy ) ) {
    481                                 $out = array();
    482                                 foreach ( $terms as $t ) {
    483                                         $posts_in_term_qv = array();
    484                                         $posts_in_term_qv['taxonomy'] = $taxonomy;
    485                                         $posts_in_term_qv['term'] = $t->slug;
    486 
    487                                         $out[] = sprintf( '<a href="%s">%s</a>',
    488                                                 esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ),
    489                                                 esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) )
    490                                         );
    491                                 }
    492                                 /* translators: used between list items, there is a space after the comma */
    493                                 echo join( __( ', ' ), $out );
    494                         } else {
    495                                 echo '&#8212;';
    496                         }
    497                         echo '</td>';
    498                         break;
    499                 }
    500 ?>
    501                 <td <?php echo $attributes ?>><?php
    502                         /**
    503                          * Fires for each custom column in the Media list table.
    504                          *
    505                          * Custom columns are registered using the 'manage_media_columns' filter.
    506                          *
    507                          * @since 2.5.0
    508                          *
    509                          * @param string $column_name Name of the custom column.
    510                          * @param int    $post_id     Attachment ID.
    511                          */
    512                         do_action( 'manage_media_custom_column', $column_name, $post->ID );
    513                 ?></td>
    514 <?php
    515                 break;
     428                                        _e( '(Unattached)' ); ?><br />
     429                                        <?php if ( $user_can_edit ) { ?>
     430                                                <a class="hide-if-no-js"
     431                                                        onclick="findPosts.open( 'media[]','<?php echo $post->ID ?>' ); return false;"
     432                                                        href="#the-list">
     433                                                        <?php _e( 'Attach' ); ?></a>
     434                                        <?php }
     435                                }
     436
     437                                break;
     438
     439                        case 'comments':
     440                                echo '<div class="post-com-count-wrapper">';
     441
     442                                $pending_comments = get_pending_comments_num( $post->ID );
     443                                $this->comments_bubble( $post->ID, $pending_comments );
     444
     445                                echo '</div>';
     446
     447                                break;
     448
     449                        default:
     450                                if ( 'categories' == $column_name )
     451                                        $taxonomy = 'category';
     452                                elseif ( 'tags' == $column_name )
     453                                        $taxonomy = 'post_tag';
     454                                elseif ( 0 === strpos( $column_name, 'taxonomy-' ) )
     455                                        $taxonomy = substr( $column_name, 9 );
     456                                else
     457                                        $taxonomy = false;
     458
     459                                if ( $taxonomy ) {
     460                                        if ( $terms = get_the_terms( $post->ID, $taxonomy ) ) {
     461                                                $out = array();
     462                                                foreach ( $terms as $t ) {
     463                                                        $posts_in_term_qv = array();
     464                                                        $posts_in_term_qv['taxonomy'] = $taxonomy;
     465                                                        $posts_in_term_qv['term'] = $t->slug;
     466
     467                                                        $out[] = sprintf( '<a href="%s">%s</a>',
     468                                                                esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ),
     469                                                                esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) )
     470                                                        );
     471                                                }
     472                                                /* translators: used between list items, there is a space after the comma */
     473                                                echo join( __( ', ' ), $out );
     474                                        } else {
     475                                                echo '&#8212;';
     476                                        }
     477
     478                                        break;
     479                                }
     480
     481                                /**
     482                                 * Fires for each custom column in the Media list table.
     483                                 *
     484                                 * Custom columns are registered using the 'manage_media_columns' filter.
     485                                 *
     486                                 * @since 2.5.0
     487                                 *
     488                                 * @param string $column_name Name of the custom column.
     489                                 * @param int    $post_id     Attachment ID.
     490                                 */
     491                                do_action( 'manage_media_custom_column', $column_name, $post->ID );
     492                                break;
     493                }
     494
     495                if( $primary === $column_name ) {
     496                        echo $this->row_actions( $this->_get_row_actions( $post, $att_title ) );
     497                }
     498               
     499                echo '</td>';
    516500        }
    517501}
     
    519503        </tr>
    520504<?php endwhile;
     505        }
     506
     507        /**
     508         * Get name of default primary column
     509         *
     510         * @since 4.3.0
     511         * @access protected
     512         *
     513         * @return string
     514         */
     515        protected function get_default_primary_column_name() {
     516                return 'title';
    521517        }
    522518
  • trunk/src/wp-admin/includes/class-wp-ms-sites-list-table.php

    r32642 r32644  
    247247                        $blogname = ( is_subdomain_install() ) ? str_replace( '.' . get_current_site()->domain, '', $blog['domain'] ) : $blog['path'];
    248248
    249                         list( $columns, $hidden ) = $this->get_column_info();
     249                        list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
    250250
    251251                        foreach ( $columns as $column_name => $column_display_name ) {
     252                                $classes = "$column_name column-$column_name";
     253                                if ( $primary === $column_name ) {
     254                                        $classes .= ' has-row-actions column-primary';
     255                                }
     256
    252257                                $style = '';
    253                                 if ( in_array( $column_name, $hidden ) )
     258                                if ( in_array( $column_name, $hidden ) ) {
    254259                                        $style = ' style="display:none;"';
    255 
    256                                 switch ( $column_name ) {
    257                                         case 'cb': ?>
    258                                                 <th scope="row" class="check-column">
    259                                                         <?php if ( ! is_main_site( $blog['blog_id'] ) ) : ?>
    260                                                         <label class="screen-reader-text" for="blog_<?php echo $blog['blog_id']; ?>"><?php printf( __( 'Select %s' ), $blogname ); ?></label>
    261                                                         <input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ) ?>" />
    262                                                         <?php endif; ?>
    263                                                 </th>
    264                                         <?php
    265                                         break;
    266 
    267                                         case 'id':?>
    268                                                 <th scope="row">
    269                                                         <?php echo $blog['blog_id'] ?>
    270                                                 </th>
    271                                         <?php
    272                                         break;
    273 
    274                                         case 'blogname':
    275                                                 echo "<td class='column-$column_name $column_name'$style>"; ?>
     260                                }
     261
     262                                $attributes = "class='$classes'$style";
     263
     264                                if ( 'cb' === $column_name ) {
     265?>
     266                                <th scope="row" class="check-column">
     267                                        <?php if ( ! is_main_site( $blog['blog_id'] ) ) : ?>
     268                                        <label class="screen-reader-text" for="blog_<?php echo $blog['blog_id']; ?>"><?php printf( __( 'Select %s' ), $blogname ); ?></label>
     269                                        <input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ) ?>" />
     270                                        <?php endif; ?>
     271                                </th>
     272<?php
     273                                } elseif ( 'id' === $column_name ) {
     274?>
     275                                <th scope="row">
     276                                        <?php echo $blog['blog_id'] ?>
     277                                </th>
     278<?php
     279                                } else {
     280                                        echo "<td $attributes>";
     281
     282                                        switch ( $column_name ) {
     283                                                case 'blogname':
     284                                                        ?>
    276285                                                        <a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname . $blog_state; ?></a>
    277286                                                        <?php
     
    282291                                                                restore_current_blog();
    283292                                                        }
    284 
    285                                                         // Preordered.
    286                                                         $actions = array(
    287                                                                 'edit' => '', 'backend' => '',
    288                                                                 'activate' => '', 'deactivate' => '',
    289                                                                 'archive' => '', 'unarchive' => '',
    290                                                                 'spam' => '', 'unspam' => '',
    291                                                                 'delete' => '',
    292                                                                 'visit' => '',
    293                                                         );
    294 
    295                                                         $actions['edit']        = '<span class="edit"><a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a></span>';
    296                                                         $actions['backend']     = "<span class='backend'><a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a></span>';
    297                                                         if ( get_current_site()->blog_id != $blog['blog_id'] ) {
    298                                                                 if ( $blog['deleted'] == '1' ) {
    299                                                                         $actions['activate']   = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to activate the site %s' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Activate' ) . '</a></span>';
    300                                                                 } else {
    301                                                                         $actions['deactivate'] = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=deactivateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to deactivate the site %s' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Deactivate' ) . '</a></span>';
    302                                                                 }
    303 
    304                                                                 if ( $blog['archived'] == '1' ) {
    305                                                                         $actions['unarchive'] = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unarchiveblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to unarchive the site %s.' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Unarchive' ) . '</a></span>';
    306                                                                 } else {
    307                                                                         $actions['archive']   = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to archive the site %s.' ), $blogname ) ) ), 'confirm' ) ) . '">' . _x( 'Archive', 'verb; site' ) . '</a></span>';
    308                                                                 }
    309 
    310                                                                 if ( $blog['spam'] == '1' ) {
    311                                                                         $actions['unspam'] = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to unspam the site %s.' ), $blogname ) ) ), 'confirm' ) ) . '">' . _x( 'Not Spam', 'site' ) . '</a></span>';
    312                                                                 } else {
    313                                                                         $actions['spam']   = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to mark the site %s as spam.' ), $blogname ) ) ), 'confirm' ) ) . '">' . _x( 'Spam', 'site' ) . '</a></span>';
    314                                                                 }
    315 
    316                                                                 if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) {
    317                                                                         $actions['delete'] = '<span class="delete"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to delete the site %s.' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Delete' ) . '</a></span>';
    318                                                                 }
     293                                                break;
     294
     295                                                case 'lastupdated':
     296                                                        echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] );
     297                                                break;
     298
     299                                                case 'registered':
     300                                                        if ( $blog['registered'] == '0000-00-00 00:00:00' ) {
     301                                                                echo '&#x2014;';
     302                                                        } else {
     303                                                                echo mysql2date( $date, $blog['registered'] );
    319304                                                        }
    320 
    321                                                         $actions['visit']       = "<span class='view'><a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a></span>';
    322 
    323                                                         /**
    324                                                          * Filter the action links displayed for each site in the Sites list table.
    325                                                          *
    326                                                          * The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by
    327                                                          * default for each site. The site's status determines whether to show the
    328                                                          * 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and
    329                                                          * 'Not Spam' or 'Spam' link for each site.
    330                                                          *
    331                                                          * @since 3.1.0
    332                                                          *
    333                                                          * @param array  $actions  An array of action links to be displayed.
    334                                                          * @param int    $blog_id  The site ID.
    335                                                          * @param string $blogname Site path, formatted depending on whether it is a sub-domain
    336                                                          *                         or subdirectory multisite install.
    337                                                          */
    338                                                         $actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname );
    339                                                         echo $this->row_actions( $actions );
    340                                         ?>
    341                                                 </td>
    342                                         <?php
    343                                         break;
    344 
    345                                         case 'lastupdated':
    346                                                 echo "<td class='$column_name column-$column_name'$style>";
    347                                                         echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] ); ?>
    348                                                 </td>
    349                                         <?php
    350                                         break;
    351                                 case 'registered':
    352                                                 echo "<td class='$column_name column-$column_name'$style>";
    353                                                 if ( $blog['registered'] == '0000-00-00 00:00:00' )
    354                                                         echo '&#x2014;';
    355                                                 else
    356                                                         echo mysql2date( $date, $blog['registered'] );
    357                                                 ?>
    358                                                 </td>
    359                                         <?php
    360                                         break;
    361                                 case 'users':
    362                                                 echo "<td class='$column_name column-$column_name'$style>";
     305                                                break;
     306
     307                                                case 'users':
    363308                                                        $blogusers = get_users( array( 'blog_id' => $blog['blog_id'], 'number' => 6) );
    364309                                                        if ( is_array( $blogusers ) ) {
     
    377322                                                                        echo '<strong>' . $blogusers_warning . '</strong><br />';
    378323                                                        }
    379                                                         ?>
    380                                                 </td>
    381                                         <?php
    382                                         break;
    383 
    384                                 case 'plugins': ?>
    385                                         <?php if ( has_filter( 'wpmublogsaction' ) ) {
    386                                         echo "<td class='$column_name column-$column_name'$style>";
    387                                                 /**
    388                                                  * Fires inside the auxiliary 'Actions' column of the Sites list table.
    389                                                  *
    390                                                  * By default this column is hidden unless something is hooked to the action.
    391                                                  *
    392                                                  * @since MU
    393                                                  *
    394                                                  * @param int $blog_id The site ID.
    395                                                  */
    396                                                 do_action( 'wpmublogsaction', $blog['blog_id'] ); ?>
    397                                         </td>
    398                                         <?php }
    399                                         break;
    400 
    401                                 default:
    402                                         echo "<td class='$column_name column-$column_name'$style>";
    403                                         /**
    404                                          * Fires for each registered custom column in the Sites list table.
    405                                          *
    406                                          * @since 3.1.0
    407                                          *
    408                                          * @param string $column_name The name of the column to display.
    409                                          * @param int    $blog_id     The site ID.
    410                                          */
    411                                         do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] );
    412                                         echo "</td>";
    413                                         break;
     324                                                break;
     325
     326                                                case 'plugins':
     327                                                        if ( has_filter( 'wpmublogsaction' ) ) {
     328                                                                /**
     329                                                                 * Fires inside the auxiliary 'Actions' column of the Sites list table.
     330                                                                 *
     331                                                                 * By default this column is hidden unless something is hooked to the action.
     332                                                                 *
     333                                                                 * @since MU
     334                                                                 *
     335                                                                 * @param int $blog_id The site ID.
     336                                                                 */
     337                                                                do_action( 'wpmublogsaction', $blog['blog_id'] );
     338                                                        }
     339                                                break;
     340
     341                                                default:
     342                                                        /**
     343                                                         * Fires for each registered custom column in the Sites list table.
     344                                                         *
     345                                                         * @since 3.1.0
     346                                                         *
     347                                                         * @param string $column_name The name of the column to display.
     348                                                         * @param int    $blog_id     The site ID.
     349                                                         */
     350                                                        do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] );
     351                                                break;
     352                                        }
     353
     354                                        echo $this->handle_row_actions( $blog, $column_name, $primary );
     355                                        echo '</td>';
    414356                                }
    415357                        }
     
    419361                }
    420362        }
     363
     364        /**
     365         * Get name of default primary column
     366         *
     367         * @since 4.3.0
     368         * @access protected
     369         *
     370         * @return string
     371         */
     372        protected function get_default_primary_column_name() {
     373                return 'blogname';
     374        }
     375
     376        /**
     377         * Generate and display row actions links
     378         *
     379         * @since 4.3.0
     380         * @access protected
     381         *
     382         * @param object $blog Blog being acted upon
     383         * @param string $column_name Current column name
     384         * @param string $primary Primary column name
     385         *
     386         * @return string
     387         */
     388        protected function handle_row_actions( $blog, $column_name, $primary ) {
     389                global $current_site;
     390
     391                if ( $primary === $column_name ) {
     392                        $blogname = ( is_subdomain_install() ) ? str_replace( '.'.$current_site->domain, '', $blog['domain'] ) : $blog['path'];
     393
     394                        // Preordered.
     395                        $actions = array(
     396                                'edit' => '', 'backend' => '',
     397                                'activate' => '', 'deactivate' => '',
     398                                'archive' => '', 'unarchive' => '',
     399                                'spam' => '', 'unspam' => '',
     400                                'delete' => '',
     401                                'visit' => '',
     402                        );
     403
     404                        $actions['edit']        = '<span class="edit"><a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a></span>';
     405                        $actions['backend']     = "<span class='backend'><a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a></span>';
     406                        if ( get_current_site()->blog_id != $blog['blog_id'] ) {
     407                                if ( $blog['deleted'] == '1' ) {
     408                                        $actions['activate']   = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to activate the site %s' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Activate' ) . '</a></span>';
     409                                } else {
     410                                        $actions['deactivate'] = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=deactivateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to deactivate the site %s' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Deactivate' ) . '</a></span>';
     411                                }
     412
     413                                if ( $blog['archived'] == '1' ) {
     414                                        $actions['unarchive'] = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unarchiveblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to unarchive the site %s.' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Unarchive' ) . '</a></span>';
     415                                } else {
     416                                        $actions['archive']   = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to archive the site %s.' ), $blogname ) ) ), 'confirm' ) ) . '">' . _x( 'Archive', 'verb; site' ) . '</a></span>';
     417                                }
     418
     419                                if ( $blog['spam'] == '1' ) {
     420                                        $actions['unspam'] = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to unspam the site %s.' ), $blogname ) ) ), 'confirm' ) ) . '">' . _x( 'Not Spam', 'site' ) . '</a></span>';
     421                                } else {
     422                                        $actions['spam']   = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to mark the site %s as spam.' ), $blogname ) ) ), 'confirm' ) ) . '">' . _x( 'Spam', 'site' ) . '</a></span>';
     423                                }
     424
     425                                if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) {
     426                                        $actions['delete'] = '<span class="delete"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to delete the site %s.' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Delete' ) . '</a></span>';
     427                                }
     428                        }
     429
     430                        $actions['visit']       = "<span class='view'><a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a></span>';
     431
     432                        /**
     433                         * Filter the action links displayed for each site in the Sites list table.
     434                         *
     435                         * The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by
     436                         * default for each site. The site's status determines whether to show the
     437                         * 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and
     438                         * 'Not Spam' or 'Spam' link for each site.
     439                         *
     440                         * @since 3.1.0
     441                         *
     442                         * @param array  $actions  An array of action links to be displayed.
     443                         * @param int    $blog_id  The site ID.
     444                         * @param string $blogname Site path, formatted depending on whether it is a sub-domain
     445                         *                         or subdirectory multisite install.
     446                         */
     447                        $actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname );
     448                        return $this->row_actions( $actions );
     449                }
     450        }
    421451}
  • trunk/src/wp-admin/includes/class-wp-ms-themes-list-table.php

    r32642 r32644  
    231231
    232232        /**
     233         * Get name of default primary column
     234         *
     235         * @since 4.3.0
     236         * @access protected
     237         *
     238         * @return string
     239         */
     240        protected function get_default_primary_column_name() {
     241                return 'name';
     242        }
     243
     244        /**
    233245         *
    234246         * @global array $totals
     
    401413                echo "<tr id='$id' class='$class'>";
    402414
    403                 list( $columns, $hidden ) = $this->get_column_info();
     415                list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
    404416
    405417                foreach ( $columns as $column_name => $column_display_name ) {
     
    414426                                case 'name':
    415427                                        echo "<td class='theme-title'$style><strong>" . $theme->display('Name') . "</strong>";
    416                                         echo $this->row_actions( $actions, true );
     428                                        if ( $primary === $column_name ) {
     429                                                echo $this->row_actions($actions, true);
     430                                        }
    417431                                        echo "</td>";
    418432                                        break;
     
    452466                                        echo implode( ' | ', $theme_meta );
    453467
    454                                         echo "</div></td>";
     468                                        echo '</div>';
     469                                        if ( $primary === $column_name ) {
     470                                                echo $this->row_actions($actions, true);
     471                                        }
     472                                        echo '</td>';
    455473                                        break;
    456474
     
    468486                                         */
    469487                                        do_action( 'manage_themes_custom_column', $column_name, $stylesheet, $theme );
     488
     489                                        if ( $primary === $column_name ) {
     490                                                echo $this->row_actions($actions, true);
     491                                        }
    470492                                        echo "</td>";
    471493                        }
  • trunk/src/wp-admin/includes/class-wp-ms-users-list-table.php

    r32642 r32644  
    181181                        <?php
    182182
    183                         list( $columns, $hidden ) = $this->get_column_info();
     183                        list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
    184184
    185185                        foreach ( $columns as $column_name => $column_display_name ) :
    186                                 $class = "class='$column_name column-$column_name'";
     186                                $classes = "$column_name column-$column_name";
     187                                if ( $primary === $column_name || 'blogs' === $column_name ) {
     188                                        $classes .= ' has-row-actions';
     189                                }
     190
     191                                if ( $primary === $column_name ) {
     192                                        $classes .= ' column-primary';
     193                                }
    187194
    188195                                $style = '';
    189                                 if ( in_array( $column_name, $hidden ) )
     196                                if ( in_array( $column_name, $hidden ) ) {
    190197                                        $style = ' style="display:none;"';
    191 
    192                                 $attributes = "$class$style";
    193 
    194                                 switch ( $column_name ) {
    195                                         case 'cb': ?>
    196                                                 <th scope="row" class="check-column">
    197                                                         <label class="screen-reader-text" for="blog_<?php echo $user->ID; ?>"><?php echo sprintf( __( 'Select %s' ), $user->user_login ); ?></label>
    198                                                         <input type="checkbox" id="blog_<?php echo $user->ID ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ) ?>" />
    199                                                 </th>
     198                                }
     199
     200                                $attributes = "class='$classes'$style";
     201
     202                                if ( 'cb' === $column_name ){
     203                                        ?>
     204                                        <th scope="row" class="check-column">
     205                                                <label class="screen-reader-text" for="blog_<?php echo $user->ID; ?>"><?php echo sprintf( __( 'Select %s' ), $user->user_login ); ?></label>
     206                                                <input type="checkbox" id="blog_<?php echo $user->ID ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ) ?>" />
     207                                        </th>
    200208                                        <?php
    201                                         break;
    202 
    203                                         case 'username':
    204                                                 $avatar = get_avatar( $user->user_email, 32 );
    205                                                 $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
    206 
    207                                                 echo "<td $attributes>"; ?>
    208                                                         <?php echo $avatar; ?><strong><a href="<?php echo $edit_link; ?>" class="edit"><?php echo $user->user_login; ?></a><?php
     209                                } else {
     210                                        echo "<td $attributes>";
     211                                       
     212                                        switch ( $column_name ) {
     213                                                case 'username':
     214                                                        $avatar = get_avatar( $user->user_email, 32 );
     215                                                        $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
     216
     217                                                        echo $avatar; ?><strong><a href="<?php echo $edit_link; ?>" class="edit"><?php echo $user->user_login; ?></a><?php
    209218                                                        if ( in_array( $user->user_login, $super_admins ) )
    210219                                                                echo ' - ' . __( 'Super Admin' );
    211220                                                        ?></strong>
    212                                                         <br/>
    213                                                         <?php
    214                                                                 $actions = array();
    215                                                                 $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
    216 
    217                                                                 if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins ) ) {
    218                                                                         $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' ) . '&amp;action=deleteuser&amp;id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>';
    219                                                                 }
    220 
    221                                                                 /**
    222                                                                  * Filter the action links displayed under each user
    223                                                                  * in the Network Admin Users list table.
    224                                                                  *
    225                                                                  * @since 3.2.0
    226                                                                  *
    227                                                                  * @param array   $actions An array of action links to be displayed.
    228                                                                  *                         Default 'Edit', 'Delete'.
    229                                                                  * @param WP_User $user    WP_User object.
    230                                                                  */
    231                                                                 $actions = apply_filters( 'ms_user_row_actions', $actions, $user );
    232                                                                 echo $this->row_actions( $actions );
    233                                                         ?>
    234                                                 </td>
    235                                         <?php
    236                                         break;
    237 
    238                                         case 'name':
    239                                                 echo "<td $attributes>$user->first_name $user->last_name</td>";
    240                                         break;
    241 
    242                                         case 'email':
    243                                                 echo "<td $attributes><a href='mailto:$user->user_email'>$user->user_email</a></td>";
    244                                         break;
    245 
    246                                         case 'registered':
    247                                                 if ( 'list' == $mode )
    248                                                         $date = __( 'Y/m/d' );
    249                                                 else
    250                                                         $date = __( 'Y/m/d g:i:s a' );
    251 
    252                                                 echo "<td $attributes>" . mysql2date( $date, $user->user_registered ) . "</td>";
    253                                         break;
    254 
    255                                         case 'blogs':
    256                                                 $blogs = get_blogs_of_user( $user->ID, true );
    257                                                 echo "<td $attributes>";
     221                                                <?php
     222                                                break;
     223
     224                                                case 'name':
     225                                                        echo "$user->first_name $user->last_name";
     226                                                break;
     227
     228                                                case 'email':
     229                                                        echo "<a href='mailto:$user->user_email'>$user->user_email</a>";
     230                                                break;
     231
     232                                                case 'registered':
     233                                                        if ( 'list' == $mode )
     234                                                                $date = __( 'Y/m/d' );
     235                                                        else
     236                                                                $date = __( 'Y/m/d g:i:s a' );
     237
     238                                                        echo mysql2date( $date, $user->user_registered );
     239                                                break;
     240
     241                                                case 'blogs':
     242                                                        $blogs = get_blogs_of_user( $user->ID, true );
    258243                                                        if ( is_array( $blogs ) ) {
    259244                                                                foreach ( (array) $blogs as $key => $val ) {
     
    306291                                                                }
    307292                                                        }
    308                                                         ?>
    309                                                 </td>
    310                                         <?php
    311                                         break;
    312 
    313                                         default:
    314                                                 echo "<td $attributes>";
    315                                                 /** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */
    316                                                 echo apply_filters( 'manage_users_custom_column', '', $column_name, $user->ID );
    317                                                 echo "</td>";
    318                                         break;
     293                                                break;
     294
     295                                                default:
     296                                                        /** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */
     297                                                        echo apply_filters( 'manage_users_custom_column', '', $column_name, $user->ID );
     298                                                break;
     299                                        }
     300
     301                                        echo $this->handle_row_actions( $user, $column_name, $primary );
     302                                        echo '</td>';
    319303                                }
    320304                        endforeach
     
    324308                }
    325309        }
     310
     311        /**
     312         * Get name of default primary column
     313         *
     314         * @since 4.3.0
     315         * @access protected
     316         *
     317         * @return string
     318         */
     319        protected function get_default_primary_column_name() {
     320                return 'username';
     321        }
     322
     323        /**
     324         * Generate and display row actions links
     325         *
     326         * @since 4.3.0
     327         * @access protected
     328         *
     329         * @param object $user User being acted upon
     330         * @param string $column_name Current column name
     331         * @param string $primary Primary column name
     332         *
     333         * @return string
     334         */
     335        protected function handle_row_actions( $user, $column_name, $primary ) {
     336                $super_admins = get_super_admins();
     337                $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
     338
     339                if ( $primary === $column_name ) {
     340                        $actions = array();
     341                        $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
     342
     343                        if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins ) ) {
     344                                $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' ) . '&amp;action=deleteuser&amp;id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>';
     345                        }
     346
     347                        /**
     348                         * Filter the action links displayed under each user
     349                         * in the Network Admin Users list table.
     350                         *
     351                         * @since 3.2.0
     352                         *
     353                         * @param array   $actions An array of action links to be displayed.
     354                         *                         Default 'Edit', 'Delete'.
     355                         * @param WP_User $user    WP_User object.
     356                         */
     357                        $actions = apply_filters( 'ms_user_row_actions', $actions, $user );
     358                        return $this->row_actions( $actions );
     359                }
     360        }
    326361}
  • trunk/src/wp-admin/includes/class-wp-plugins-list-table.php

    r32642 r32644  
    569569                );
    570570
    571                 list( $columns, $hidden ) = $this->get_column_info();
     571                list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
     572
     573                $extra_class = ' has-row-actions column-primary';
    572574
    573575                foreach ( $columns as $column_name => $column_display_name ) {
    574576                        $style = '';
    575                         if ( in_array( $column_name, $hidden ) )
     577                        if ( in_array( $column_name, $hidden ) ) {
    576578                                $style = ' style="display:none;"';
     579                        }
    577580
    578581                        switch ( $column_name ) {
     
    581584                                        break;
    582585                                case 'name':
    583                                         echo "<td class='plugin-title'$style><strong>$plugin_name</strong>";
    584                                         echo $this->row_actions( $actions, true );
     586                                        if ( $primary === $column_name || ! isset( $columns[ $primary ] ) ) {
     587                                                echo "<td class='plugin-title $extra_class'$style><strong>$plugin_name</strong>";
     588                                                echo $this->row_actions( $actions, true );
     589                                        } else {
     590                                                echo "<td class='plugin-title'$style><strong>$plugin_name</strong>";
     591                                        }
    585592                                        echo "</td>";
    586593                                        break;
    587594                                case 'description':
    588                                         echo "<td class='column-description desc'$style>
     595                                        $classes = 'column-description desc';
     596                                        if ( $primary === $column_name ) {
     597                                                $classes .= " $extra_class";
     598                                        }
     599
     600                                        echo "<td class='$classes'$style>
    589601                                                <div class='plugin-description'>$description</div>
    590602                                                <div class='$class second plugin-version-author-uri'>";
     
    633645                                        echo implode( ' | ', $plugin_meta );
    634646
     647                                        if ( $primary === $column_name ) {
     648                                                echo $this->row_actions( $actions, true );
     649                                        }
    635650                                        echo "</div></td>";
    636651                                        break;
    637652                                default:
    638                                         echo "<td class='$column_name column-$column_name'$style>";
     653                                        $classes = "$column_name column-$column_name$class";
     654                                        if ( $primary === $column_name ) {
     655                                                $classes .= " $extra_class";
     656                                        }
     657
     658                                        echo "<td class='$classes'$style>";
    639659
    640660                                        /**
     
    648668                                         */
    649669                                        do_action( 'manage_plugins_custom_column', $column_name, $plugin_file, $plugin_data );
     670
     671                                        if ( $primary === $column_name ) {
     672                                                echo $this->row_actions( $actions, true );
     673                                        }
    650674                                        echo "</td>";
    651675                        }
     
    683707                do_action( "after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $status );
    684708        }
     709
     710        /**
     711         * Get name of default primary column for this specific list table.
     712         *
     713         * @since 4.3.0
     714         * @access protected
     715         *
     716         * @return string
     717         */
     718        protected function get_default_primary_column_name() {
     719                return 'plugin';
     720        }
    685721}
  • trunk/src/wp-admin/includes/class-wp-posts-list-table.php

    r32642 r32644  
    685685        <?php
    686686
    687                 list( $columns, $hidden ) = $this->get_column_info();
     687                list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
    688688
    689689                foreach ( $columns as $column_name => $column_display_name ) {
    690                         $class = "class=\"$column_name column-$column_name\"";
     690                        $classes = "$column_name column-$column_name";
     691                        if ( $primary === $column_name ) {
     692                                $classes .= ' has-row-actions column-primary';
     693                        }
    691694
    692695                        $style = '';
    693                         if ( in_array( $column_name, $hidden ) )
     696                        if ( in_array( $column_name, $hidden ) ) {
    694697                                $style = ' style="display:none;"';
    695 
    696                         $attributes = "$class$style";
     698                        }
     699
     700                        $attributes = "class='$classes'$style";
    697701
    698702                        switch ( $column_name ) {
     
    716720
    717721                        case 'title':
    718                                 $attributes = 'class="post-title page-title column-title"' . $style;
     722                                $classes .= ' page-title'; // Special addition for title column
     723                                $attributes = "class='$classes'$style";
    719724                                if ( $this->hierarchical_display ) {
    720725                                        if ( 0 == $level && (int) $post->post_parent > 0 ) {
     
    773778                                                the_excerpt();
    774779
    775                                 $actions = array();
    776                                 if ( $can_edit_post && 'trash' != $post->post_status ) {
    777                                         $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID ) . '" title="' . esc_attr__( 'Edit this item' ) . '">' . __( 'Edit' ) . '</a>';
    778                                         $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr__( 'Edit this item inline' ) . '">' . __( 'Quick&nbsp;Edit' ) . '</a>';
    779                                 }
    780                                 if ( current_user_can( 'delete_post', $post->ID ) ) {
    781                                         if ( 'trash' == $post->post_status )
    782                                                 $actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash' ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
    783                                         elseif ( EMPTY_TRASH_DAYS )
    784                                                 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash' ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
    785                                         if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
    786                                                 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently' ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
    787                                 }
    788                                 if ( $post_type_object->public ) {
    789                                         if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
    790                                                 if ( $can_edit_post ) {
    791                                                         $preview_link = set_url_scheme( get_permalink( $post->ID ) );
    792                                                         /** This filter is documented in wp-admin/includes/meta-boxes.php */
    793                                                         $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post );
    794                                                         $actions['view'] = '<a href="' . esc_url( $preview_link ) . '" title="' . esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>';
    795                                                 }
    796                                         } elseif ( 'trash' != $post->post_status ) {
    797                                                 $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
    798                                         }
    799                                 }
    800 
    801                                 if ( is_post_type_hierarchical( $post->post_type ) ) {
    802 
    803                                         /**
    804                                          * Filter the array of row action links on the Pages list table.
    805                                          *
    806                                          * The filter is evaluated only for hierarchical post types.
    807                                          *
    808                                          * @since 2.8.0
    809                                          *
    810                                          * @param array   $actions An array of row action links. Defaults are
    811                                          *                         'Edit', 'Quick Edit', 'Restore, 'Trash',
    812                                          *                         'Delete Permanently', 'Preview', and 'View'.
    813                                          * @param WP_Post $post    The post object.
    814                                          */
    815                                         $actions = apply_filters( 'page_row_actions', $actions, $post );
    816                                 } else {
    817 
    818                                         /**
    819                                          * Filter the array of row action links on the Posts list table.
    820                                          *
    821                                          * The filter is evaluated only for non-hierarchical post types.
    822                                          *
    823                                          * @since 2.8.0
    824                                          *
    825                                          * @param array   $actions An array of row action links. Defaults are
    826                                          *                         'Edit', 'Quick Edit', 'Restore, 'Trash',
    827                                          *                         'Delete Permanently', 'Preview', and 'View'.
    828                                          * @param WP_Post $post    The post object.
    829                                          */
    830                                         $actions = apply_filters( 'post_row_actions', $actions, $post );
    831                                 }
    832 
    833                                 echo $this->row_actions( $actions );
     780                                echo $this->handle_row_actions( $post, $column_name, $primary );
    834781
    835782                                get_inline_data( $post );
     
    888835                                        _e( 'Last Modified' );
    889836                                }
     837                                echo $this->handle_row_actions( $post, $column_name, $primary );
    890838                                echo '</td>';
    891839                        break;
     
    899847                                $this->comments_bubble( $post->ID, $pending_comments );
    900848                        ?>
    901                         </div></td>
     849                        </div><?php echo $this->handle_row_actions( $post, $column_name, $primary ); ?></td>
    902850                        <?php
    903851                        break;
     
    910858                                        get_the_author()
    911859                                );
     860                                echo $this->handle_row_actions( $post, $column_name, $primary );
    912861                        ?></td>
    913862                        <?php
     
    950899                                                echo '&#8212;';
    951900                                        }
     901                                        echo $this->handle_row_actions( $post, $column_name, $primary );
    952902                                        echo '</td>';
    953903                                        break;
     
    996946                                 */
    997947                                do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID );
     948                                echo $this->handle_row_actions( $post, $column_name, $primary );
    998949                        ?></td>
    999950                        <?php
     
    1005956        <?php
    1006957                $GLOBALS['post'] = $global_post;
     958        }
     959
     960        /**
     961         * Get name of default primary column
     962         *
     963         * @since 4.3.0
     964         * @access protected
     965         *
     966         * @return string
     967         */
     968        protected function get_default_primary_column_name() {
     969                return( 'title' );
     970        }
     971
     972        /**
     973         * Generate and display row actions links
     974         *
     975         * @since 4.3.0
     976         * @access protected
     977         *
     978         * @param object $post Post being acted upon
     979         * @param string $column_name Current column name
     980         * @param string $primary Primary column name
     981         *
     982         * @return string
     983         */
     984        protected function handle_row_actions( $post, $column_name, $primary ) {
     985                $title = _draft_or_post_title();
     986
     987                if ( $primary === $column_name ) {
     988                        $post_type_object = get_post_type_object( $post->post_type );
     989                        $can_edit_post = current_user_can( 'edit_post', $post->ID );
     990                        $actions = array();
     991
     992                        if ( $can_edit_post && 'trash' != $post->post_status ) {
     993                                $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID ) . '" title="' . esc_attr__( 'Edit this item' ) . '">' . __( 'Edit' ) . '</a>';
     994                                $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr__( 'Edit this item inline' ) . '">' . __( 'Quick&nbsp;Edit' ) . '</a>';
     995                        }
     996
     997                        if ( current_user_can( 'delete_post', $post->ID ) ) {
     998                                if ( 'trash' == $post->post_status )
     999                                        $actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash' ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
     1000                                elseif ( EMPTY_TRASH_DAYS )
     1001                                        $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash' ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
     1002                                if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
     1003                                        $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently' ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
     1004                        }
     1005
     1006                        if ( $post_type_object->public ) {
     1007                                if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
     1008                                        if ( $can_edit_post ) {
     1009                                                $preview_link = set_url_scheme( get_permalink( $post->ID ) );
     1010                                                /** This filter is documented in wp-admin/includes/meta-boxes.php */
     1011                                                $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post );
     1012                                                $actions['view'] = '<a href="' . esc_url( $preview_link ) . '" title="' . esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>';
     1013                                        }
     1014                                } elseif ( 'trash' != $post->post_status ) {
     1015                                        $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
     1016                                }
     1017                        }
     1018
     1019                        if ( is_post_type_hierarchical( $post->post_type ) ) {
     1020
     1021                                /**
     1022                                 * Filter the array of row action links on the Pages list table.
     1023                                 *
     1024                                 * The filter is evaluated only for hierarchical post types.
     1025                                 *
     1026                                 * @since 2.8.0
     1027                                 *
     1028                                 * @param array $actions An array of row action links. Defaults are
     1029                                 *                         'Edit', 'Quick Edit', 'Restore, 'Trash',
     1030                                 *                         'Delete Permanently', 'Preview', and 'View'.
     1031                                 * @param WP_Post $post The post object.
     1032                                 */
     1033                                $actions = apply_filters( 'page_row_actions', $actions, $post );
     1034                        } else {
     1035
     1036                                /**
     1037                                 * Filter the array of row action links on the Posts list table.
     1038                                 *
     1039                                 * The filter is evaluated only for non-hierarchical post types.
     1040                                 *
     1041                                 * @since 2.8.0
     1042                                 *
     1043                                 * @param array $actions An array of row action links. Defaults are
     1044                                 *                         'Edit', 'Quick Edit', 'Restore, 'Trash',
     1045                                 *                         'Delete Permanently', 'Preview', and 'View'.
     1046                                 * @param WP_Post $post The post object.
     1047                                 */
     1048                                $actions = apply_filters( 'post_row_actions', $actions, $post );
     1049                        }
     1050
     1051                        return $this->row_actions( $actions );
     1052                }
    10071053        }
    10081054
  • trunk/src/wp-admin/includes/class-wp-terms-list-table.php

    r32642 r32644  
    308308        public function column_name( $tag ) {
    309309                $taxonomy = $this->screen->taxonomy;
    310                 $tax = get_taxonomy( $taxonomy );
    311 
    312                 $default_term = get_option( 'default_' . $taxonomy );
    313310
    314311                $pad = str_repeat( '&#8212; ', max( 0, $this->level ) );
     
    334331                $out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $name ) ) . '">' . $name . '</a></strong><br />';
    335332
    336                 $actions = array();
    337                 if ( current_user_can( $tax->cap->edit_terms ) ) {
    338                         $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
    339                         $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __( 'Quick&nbsp;Edit' ) . '</a>';
    340                 }
    341                 if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
    342                         $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url( "edit-tags.php?action=delete&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) . "'>" . __( 'Delete' ) . "</a>";
    343                 if ( $tax->public )
    344                         $actions['view'] = '<a href="' . get_term_link( $tag ) . '">' . __( 'View' ) . '</a>';
    345 
    346                 /**
    347                  * Filter the action links displayed for each term in the Tags list table.
    348                  *
    349                  * @since 2.8.0
    350                  * @deprecated 3.0.0 Use {$taxonomy}_row_actions instead.
    351                  *
    352                  * @param array  $actions An array of action links to be displayed. Default
    353                  *                        'Edit', 'Quick Edit', 'Delete', and 'View'.
    354                  * @param object $tag     Term object.
    355                  */
    356                 $actions = apply_filters( 'tag_row_actions', $actions, $tag );
    357 
    358                 /**
    359                  * Filter the action links displayed for each term in the terms list table.
    360                  *
    361                  * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
    362                  *
    363                  * @since 3.0.0
    364                  *
    365                  * @param array  $actions An array of action links to be displayed. Default
    366                  *                        'Edit', 'Quick Edit', 'Delete', and 'View'.
    367                  * @param object $tag     Term object.
    368                  */
    369                 $actions = apply_filters( "{$taxonomy}_row_actions", $actions, $tag );
    370 
    371                 $out .= $this->row_actions( $actions );
    372333                $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
    373334                $out .= '<div class="name">' . $qe_data->name . '</div>';
     
    378339
    379340                return $out;
     341        }
     342
     343        /**
     344         * Get name of default primary column
     345         *
     346         * @since 4.3.0
     347         * @access protected
     348         *
     349         * @return string
     350         */
     351        protected function get_default_primary_column_name() {
     352                return 'name';
     353        }
     354
     355        /**
     356         * Generate and display row actions links
     357         *
     358         * @since 4.3.0
     359         * @access protected
     360         *
     361         * @param object $tag Tag being acted upon
     362         * @param string $column_name Current column name
     363         * @param string $primary Primary column name
     364         *
     365         * @return string
     366         */
     367        protected function handle_row_actions( $tag, $column_name, $primary ) {
     368                $taxonomy = $this->screen->taxonomy;
     369                $tax = get_taxonomy( $taxonomy );
     370                $default_term = get_option( 'default_' . $taxonomy );
     371
     372                $edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) );
     373
     374                if ( $primary === $column_name ) {
     375                        $actions = array();
     376                        if ( current_user_can( $tax->cap->edit_terms ) ) {
     377                                $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
     378                                $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __( 'Quick&nbsp;Edit' ) . '</a>';
     379                        }
     380                        if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
     381                                $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url( "edit-tags.php?action=delete&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) . "'>" . __( 'Delete' ) . "</a>";
     382                        if ( $tax->public )
     383                                $actions['view'] = '<a href="' . get_term_link( $tag ) . '">' . __( 'View' ) . '</a>';
     384
     385                        /**
     386                         * Filter the action links displayed for each term in the Tags list table.
     387                         *
     388                         * @since 2.8.0
     389                         * @deprecated 3.0.0 Use {$taxonomy}_row_actions instead.
     390                         *
     391                         * @param array  $actions An array of action links to be displayed. Default
     392                         *                        'Edit', 'Quick Edit', 'Delete', and 'View'.
     393                         * @param object $tag     Term object.
     394                         */
     395                        $actions = apply_filters( 'tag_row_actions', $actions, $tag );
     396
     397                        /**
     398                         * Filter the action links displayed for each term in the terms list table.
     399                         *
     400                         * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
     401                         *
     402                         * @since 3.0.0
     403                         *
     404                         * @param array  $actions An array of action links to be displayed. Default
     405                         *                        'Edit', 'Quick Edit', 'Delete', and 'View'.
     406                         * @param object $tag     Term object.
     407                         */
     408                        $actions = apply_filters( "{$taxonomy}_row_actions", $actions, $tag );
     409
     410                        return $this->row_actions( $actions );
     411                }
    380412        }
    381413
  • trunk/src/wp-admin/includes/class-wp-users-list-table.php

    r32642 r32644  
    390390                         */
    391391                        $actions = apply_filters( 'user_row_actions', $actions, $user_object );
    392                         $edit .= $this->row_actions( $actions );
    393392
    394393                        // Set up the checkbox ( because the user is editable, otherwise it's empty )
     
    404403                $r = "<tr id='user-$user_object->ID'>";
    405404
    406                 list( $columns, $hidden ) = $this->get_column_info();
     405                list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
    407406
    408407                foreach ( $columns as $column_name => $column_display_name ) {
    409                         $class = "class=\"$column_name column-$column_name\"";
     408                        $classes = "$column_name column-$column_name";
     409                        if ( $primary === $column_name ) {
     410                                $classes .= ' has-row-actions column-primary';
     411                        }
    410412
    411413                        $style = '';
    412                         if ( in_array( $column_name, $hidden ) )
     414                        if ( in_array( $column_name, $hidden ) ) {
    413415                                $style = ' style="display:none;"';
    414 
    415                         $attributes = "$class$style";
    416 
    417                         switch ( $column_name ) {
    418                                 case 'cb':
    419                                         $r .= "<th scope='row' class='check-column'>$checkbox</th>";
    420                                         break;
    421                                 case 'username':
    422                                         $r .= "<td $attributes>$avatar $edit</td>";
    423                                         break;
    424                                 case 'name':
    425                                         $r .= "<td $attributes>$user_object->first_name $user_object->last_name</td>";
    426                                         break;
    427                                 case 'email':
    428                                         $r .= "<td $attributes><a href='mailto:$email' title='" . esc_attr( sprintf( __( 'E-mail: %s' ), $email ) ) . "'>$email</a></td>";
    429                                         break;
    430                                 case 'role':
    431                                         $r .= "<td $attributes>$role_name</td>";
    432                                         break;
    433                                 case 'posts':
    434                                         $attributes = 'class="posts column-posts num"' . $style;
    435                                         $r .= "<td $attributes>";
    436                                         if ( $numposts > 0 ) {
    437                                                 $r .= "<a href='edit.php?author=$user_object->ID' title='" . esc_attr__( 'View posts by this author' ) . "' class='edit'>";
    438                                                 $r .= $numposts;
    439                                                 $r .= '</a>';
    440                                         } else {
    441                                                 $r .= 0;
    442                                         }
    443                                         $r .= "</td>";
    444                                         break;
    445                                 default:
    446                                         $r .= "<td $attributes>";
    447 
    448                                         /**
    449                                          * Filter the display output of custom columns in the Users list table.
    450                                          *
    451                                          * @since 2.8.0
    452                                          *
    453                                          * @param string $output      Custom column output. Default empty.
    454                                          * @param string $column_name Column name.
    455                                          * @param int    $user_id     ID of the currently-listed user.
    456                                          */
    457                                         $r .= apply_filters( 'manage_users_custom_column', '', $column_name, $user_object->ID );
    458                                         $r .= "</td>";
     416                        }
     417
     418                        $attributes = "class='$classes'$style";
     419
     420                        if ( 'cb' === $column_name ) {
     421                                $r .= "<th scope='row' class='check-column'>$checkbox</th>";
     422                        } else {
     423                                $r .= "<td $attributes>";
     424                                switch ( $column_name ) {
     425                                        case 'username':
     426                                                $r .= "$avatar $edit";
     427                                                break;
     428                                        case 'name':
     429                                                $r .= "$user_object->first_name $user_object->last_name";
     430                                                break;
     431                                        case 'email':
     432                                                $r .= "<a href='mailto:$email' title='" . esc_attr( sprintf( __( 'E-mail: %s' ), $email ) ) . "'>$email</a>";
     433                                                break;
     434                                        case 'role':
     435                                                $r .= $role_name;
     436                                                break;
     437                                        case 'posts':
     438                                                $attributes = 'class="posts column-posts num"' . $style;
     439                                                $r .= "";
     440                                                if ( $numposts > 0 ) {
     441                                                        $r .= "<a href='edit.php?author=$user_object->ID' title='" . esc_attr__( 'View posts by this author' ) . "' class='edit'>";
     442                                                        $r .= $numposts;
     443                                                        $r .= '</a>';
     444                                                } else {
     445                                                        $r .= 0;
     446                                                }
     447                                                break;
     448                                        default:
     449                                                /**
     450                                                 * Filter the display output of custom columns in the Users list table.
     451                                                 *
     452                                                 * @since 2.8.0
     453                                                 *
     454                                                 * @param string $output      Custom column output. Default empty.
     455                                                 * @param string $column_name Column name.
     456                                                 * @param int    $user_id     ID of the currently-listed user.
     457                                                 */
     458                                                $r .= apply_filters( 'manage_users_custom_column', '', $column_name, $user_object->ID );
     459                                }
     460
     461                                if ( $primary === $column_name ) {
     462                                        $r .= $this->row_actions( $actions );
     463                                }
     464                                $r .= "</td>";
    459465                        }
    460466                }
     
    463469                return $r;
    464470        }
     471
     472        /**
     473         * Get name of default primary column
     474         *
     475         * @since 4.3.0
     476         * @access protected
     477         *
     478         * @return string
     479         */
     480        protected function get_default_primary_column_name() {
     481                return 'username';
     482        }
    465483}
Note: See TracChangeset for help on using the changeset viewer.