WordPress.org

Make WordPress Core

Changeset 16361


Ignore:
Timestamp:
11/13/2010 11:47:14 PM (9 years ago)
Author:
scribu
Message:

Rework WP_MS_Themes_List_Table column display. Props ocean90. See #15318

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-ms-themes-list-table.php

    r16335 r16361  
    251251
    252252    function display_rows() {
     253        foreach ( $this->items as $key => $theme )
     254            $this->single_row( $key, $theme );
     255    }
     256
     257    function single_row( $key, $theme ) {
    253258        global $status, $page, $s;
    254259
    255260        $context = $status;
    256        
     261
    257262        if ( $this->is_site_themes )
    258263            $url = "site-themes.php?id={$this->site_id}&";
     
    260265            $url = 'themes.php?';
    261266
    262         foreach ( $this->items as $key => $theme ) {
    263             // preorder
    264             $actions = array(
    265                 'enable' => '',
    266                 'disable' => '',
    267                 'edit' => ''
    268             );
    269            
    270             $theme_key = esc_html( $theme['Stylesheet'] );
    271 
    272             if ( empty( $theme['enabled'] ) )
    273                     $actions['enable'] = '<a href="' . wp_nonce_url($url . 'action=enable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'enable-theme_' . $theme_key) . '" title="' . __('Enable this theme') . '" class="edit">' . __('Enable') . '</a>';
    274             else
    275                     $actions['disable'] = '<a href="' . wp_nonce_url($url . 'action=disable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'disable-theme_' . $theme_key) . '" title="' . __('Disable this theme') . '">' . __('Disable') . '</a>';
    276            
    277             if ( current_user_can('edit_themes') )
    278                 $actions['edit'] = '<a href="theme-editor.php?theme=' . $theme['Name'] . '" title="' . __('Open this theme in the Theme Editor') . '" class="edit">' . __('Edit') . '</a>';
    279 
    280             $actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme_key, $theme, $context );
    281             $actions = apply_filters( "theme_action_links_$theme_key", $actions, $theme_key, $theme, $context );
    282 
    283             $class = empty( $theme['enabled'] ) ? 'inactive' : 'active';
    284             $checkbox = "<input type='checkbox' name='checked[]' value='" . esc_attr( $theme_key ) . "' />";
    285 
    286             $description = '<p>' . $theme['Description'] . '</p>';
    287             $theme_name = $theme['Name'];
    288 
    289 
    290             $id = sanitize_title( $theme_name );
    291 
    292             echo "
    293         <tr id='$id' class='$class'>
    294             <th scope='row' class='check-column'>$checkbox</th>
    295             <td class='theme-title'><strong>$theme_name</strong></td>
    296             <td class='desc'>$description</td>
    297         </tr>
    298         <tr class='$class second'>
    299             <td></td>
    300             <td class='theme-title'>";
    301 
    302             echo $this->row_actions( $actions, true );
    303 
    304             echo "</td>
    305             <td class='desc'>";
    306             $theme_meta = array();
    307             if ( !empty( $theme['Version'] ) )
    308                 $theme_meta[] = sprintf( __( 'Version %s' ), $theme['Version'] );
    309             if ( !empty( $theme['Author'] ) ) {
    310                 $author = $theme['Author'];
    311                 if ( !empty( $theme['Author URI'] ) )
    312                     $author = '<a href="' . $theme['Author URI'] . '" title="' . __( 'Visit author homepage' ) . '">' . $theme['Author'] . '</a>';
    313                 $theme_meta[] = sprintf( __( 'By %s' ), $author );
    314             }
    315             if ( !empty( $theme['Theme URI'] ) )
    316                 $theme_meta[] = '<a href="' . $theme['Theme URI'] . '" title="' . __( 'Visit theme homepage' ) . '">' . __( 'Visit Theme Site' ) . '</a>';
    317 
    318             $theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $theme_key, $theme, $status );
    319             echo implode( ' | ', $theme_meta );
    320             echo "</td>
    321         </tr>\n";
    322 
    323             do_action( 'after_theme_row', $theme_key, $theme, $status );
    324             do_action( "after_theme_row_$theme_key", $theme_key, $theme, $status );
    325         }
     267        // preorder
     268        $actions = array(
     269            'enable' => '',
     270            'disable' => '',
     271            'edit' => ''
     272        );
     273
     274        $theme_key = esc_html( $theme['Stylesheet'] );
     275
     276        if ( empty( $theme['enabled'] ) )
     277            $actions['enable'] = '<a href="' . wp_nonce_url($url . 'action=enable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'enable-theme_' . $theme_key) . '" title="' . __('Enable this theme') . '" class="edit">' . __('Enable') . '</a>';
     278        else
     279            $actions['disable'] = '<a href="' . wp_nonce_url($url . 'action=disable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'disable-theme_' . $theme_key) . '" title="' . __('Disable this theme') . '">' . __('Disable') . '</a>';
     280
     281        if ( current_user_can('edit_themes') )
     282            $actions['edit'] = '<a href="theme-editor.php?theme=' . $theme['Name'] . '" title="' . __('Open this theme in the Theme Editor') . '" class="edit">' . __('Edit') . '</a>';
     283
     284        $actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme_key, $theme, $context );
     285        $actions = apply_filters( "theme_action_links_$theme_key", $actions, $theme_key, $theme, $context );
     286
     287        $class = empty( $theme['enabled'] ) ? 'inactive' : 'active';
     288        $checkbox_id = md5($theme['Name']) . "_checkbox";
     289        $checkbox = "<input type='checkbox' name='checked[]' value='" . esc_attr( $theme_key ) . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $theme['Name'] . "</label>";
     290
     291        $description = '<p>' . $theme['Description'] . '</p>';
     292        $theme_name = $theme['Name'];
     293
     294        $id = sanitize_title( $theme_name );
     295
     296        echo "<tr id='$id' class='$class'>";
     297
     298        list( $columns, $hidden ) = $this->get_column_info();
     299
     300        foreach ( $columns as $column_name => $column_display_name ) {
     301            $style = '';
     302            if ( in_array( $column_name, $hidden ) )
     303                $style = ' style="display:none;"';
     304
     305            switch ( $column_name ) {
     306                case 'cb':
     307                    echo "<th scope='row' class='check-column'>$checkbox</th>";
     308                    break;
     309                case 'name':
     310                    echo "<td class='theme-title'$style><strong>$theme_name</strong>";
     311                    echo $this->row_actions( $actions, true );
     312                    echo "</td>";
     313                    break;
     314                case 'description':
     315                    echo "<td class='column-description desc'$style>
     316                        <div class='theme-description'>$description</div>
     317                        <div class='$class second theme-version-author-uri'>";
     318
     319                    $theme_meta = array();
     320                    if ( !empty( $theme['Version'] ) )
     321                        $theme_meta[] = sprintf( __( 'Version %s' ), $theme['Version'] );
     322                    if ( !empty( $theme['Author'] ) ) {
     323                        $author = $theme['Author'];
     324                        if ( !empty( $theme['Author URI'] ) )
     325                            $author = '<a href="' . $theme['Author URI'] . '" title="' . __( 'Visit author homepage' ) . '">' . $theme['Author'] . '</a>';
     326                        $theme_meta[] = sprintf( __( 'By %s' ), $author );
     327                    }
     328                    if ( !empty( $theme['Theme URI'] ) )
     329                        $theme_meta[] = '<a href="' . $theme['Theme URI'] . '" title="' . __( 'Visit theme homepage' ) . '">' . __( 'Visit Theme Site' ) . '</a>';
     330
     331                    $theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $theme_key, $theme, $status );
     332                    echo implode( ' | ', $theme_meta );
     333
     334                    echo "</div></td>";
     335                    break; 
     336                    break;
     337                default:
     338                    echo "<td class='$column_name column-$column_name'$style>";
     339                    do_action( 'manage_themes_custom_column', $column_name, $theme_key, $theme );
     340                    echo "</td>";
     341            }
     342        }
     343
     344        echo "</tr>";
     345
     346        do_action( 'after_theme_row', $theme_key, $theme, $status );
     347        do_action( "after_theme_row_$theme_key", $theme_key, $theme, $status );
    326348    }
    327349}
     350
    328351?>
Note: See TracChangeset for help on using the changeset viewer.