Make WordPress Core

Changeset 16113


Ignore:
Timestamp:
10/31/2010 09:37:15 AM (16 years ago)
Author:
westi
Message:

First pass at a new Network Admins page for Theme enable/disable/upgrade. See #14897 props PeteMall.

Location:
trunk/wp-admin
Files:
1 added
2 edited

Legend:

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

    r16110 r16113  
    851851                'WP_Links_Table' => 'links', 'WP_Sites_Table' => 'sites', 'WP_MS_Users_Table' => 'ms-users',
    852852                'WP_Plugins_Table' => 'plugins', 'WP_Plugin_Install_Table' => 'plugin-install', 'WP_Themes_Table' => 'themes',
    853                 'WP_Theme_Install_Table' => 'theme-install' );
     853                'WP_Theme_Install_Table' => 'theme-install', 'WP_MS_Themes_Table' => 'ms-themes' );
    854854
    855855        if ( isset( $core_classes[ $class ] ) ) {
  • trunk/wp-admin/network/themes.php

    r16061 r16113  
    55 * @package WordPress
    66 * @subpackage Multisite
    7  * @since 3.0.0
     7 * @since 3.1.0
    88 */
    99
    1010require_once( './admin.php' );
    1111
    12 if ( ! current_user_can( 'manage_network_themes' ) )
    13         wp_die( __( 'You do not have permission to access this page.' ) );
     12$wp_list_table = get_list_table('WP_MS_Themes_Table');
     13$wp_list_table->check_permissions();
    1414
    15 $title = __( 'Network Themes' );
     15$action = $wp_list_table->current_action();
     16
     17$plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : '';
     18$s = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
     19
     20// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
     21$_SERVER['REQUEST_URI'] = remove_query_arg(array('error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce'), $_SERVER['REQUEST_URI']);
     22
     23if ( $action ) {
     24        $allowed_themes = get_site_option( 'allowedthemes' );   
     25        switch ( $action ) {
     26                case 'network-enable':
     27                        $allowed_themes[ $_GET['theme'] ] = 1;
     28                        update_site_option( 'allowedthemes', $allowed_themes );
     29                        wp_redirect( wp_get_referer() ); // @todo add_query_arg for update message
     30                        exit;                   
     31                        break;
     32                case 'network-disable':
     33                        unset( $allowed_themes[ $_GET['theme'] ] );
     34                        update_site_option( 'allowedthemes', $allowed_themes );
     35                        wp_redirect( wp_get_referer() ); // @todo add_query_arg for update message
     36                        exit;
     37                        break;
     38                case 'network-enable-selected':
     39                        check_admin_referer('bulk-plugins');
     40
     41                        $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
     42                        if ( empty($themes) ) {
     43                                wp_redirect( wp_get_referer() );
     44                                exit;
     45                        }                                               
     46                        foreach( (array) $themes as $theme )
     47                                $allowed_themes[ $theme ] = 1;
     48                        update_site_option( 'allowedthemes', $allowed_themes );
     49                        break;
     50                        case 'network-disable-selected':
     51                                check_admin_referer('bulk-plugins');
     52
     53                                $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
     54                                if ( empty($themes) ) {
     55                                        wp_redirect( wp_get_referer() );
     56                                        exit;
     57                                }                                               
     58                                foreach( (array) $themes as $theme )
     59                                        unset( $allowed_themes[ $theme ] );
     60                                update_site_option( 'allowedthemes', $allowed_themes );
     61                                break;
     62
     63        }
     64}
     65
     66$wp_list_table->prepare_items();
     67
     68add_screen_option( 'per_page', array('label' => _x( 'Themes', 'themes per page (screen options)' ), 'default' => 999) );
     69
     70$title = __('Themes');
    1671$parent_file = 'themes.php';
    1772
    18 add_contextual_help($current_screen,
    19         '<p>' . __('This screen enables and disables the inclusion of themes available to choose in the Appearance menu for each site. It does not activate or deactivate which theme a site is currently using.') . '</p>' .
    20         '<p>' . __('If the network admin disables a theme that is in use, it can still remain selected on that site. If another theme is chosen, the disabled theme will not appear in the site&#8217;s Appearance > Themes screen.') . '</p>' .
    21         '<p>' . __('Themes can be enabled on a site by site basis by the network admin on the Edit Site screen you go to via the Edit action link on the Sites screen.') . '</p>' .
    22         '<p><strong>' . __('For more information:') . '</strong></p>' .
    23         '<p>' . __('<a href="http://codex.wordpress.org/Super_Admin_Themes_SubPanel" target="_blank">Documentation on Network Themes</a>') . '</p>' .
    24         '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
    25 );
     73require_once(ABSPATH . 'wp-admin/admin-header.php');
    2674
    27 require_once( '../admin-header.php' );
     75?>
    2876
    29 if ( isset( $_GET['updated'] ) ) {
    30         ?>
    31         <div id="message" class="updated"><p><?php _e( 'Site themes saved.' ) ?></p></div>
    32         <?php
    33 }
     77<div class="wrap">
     78<?php screen_icon('themes'); ?>
     79<h2><?php echo esc_html( $title ); if ( current_user_can('install_themes') ) { ?> <a href="theme-install.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'theme'); ?></a><?php } ?></h2>
     80<p><?php _e( 'Themes must be enabled for your network before they will be available to individual sites.' ) ?></p>
    3481
    35 $themes = get_themes();
    36 $allowed_themes = get_site_allowed_themes();
    37 ?>
    38 <div class="wrap">
    39         <form action="<?php echo esc_url( network_admin_url( 'edit.php?action=updatethemes' ) ); ?>" method="post">
    40                 <?php screen_icon(); ?>
    41                 <h2><?php _e( 'Network Themes' ) ?></h2>
    42                 <p><?php _e( 'Themes must be enabled for your network before they will be available to individual sites.' ) ?></p>
    43                 <?php submit_button( __( 'Apply Changes' ), '', '' ); ?>
    44                 <table class="widefat">
    45                         <thead>
    46                                 <tr>
    47                                         <th style="width:15%;"><?php _e( 'Enable' ) ?></th>
    48                                         <th style="width:25%;"><?php _e( 'Theme' ) ?></th>
    49                                         <th style="width:10%;"><?php _e( 'Version' ) ?></th>
    50                                         <th style="width:60%;"><?php _e( 'Description' ) ?></th>
    51                                 </tr>
    52                         </thead>
    53                         <tbody id="plugins">
    54                         <?php
    55                         $total_theme_count = $activated_themes_count = 0;
    56                         $class = '';
    57                         foreach ( (array) $themes as $key => $theme ) {
    58                                 $total_theme_count++;
    59                                 $theme_key = esc_html( $theme['Stylesheet'] );
    60                                 $class = ( 'alt' == $class ) ? '' : 'alt';
    61                                 $class1 = $enabled = $disabled = '';
    62                                 $enabled = $disabled = false;
     82<form method="get" action="">
     83<p class="search-box">
     84        <label class="screen-reader-text" for="theme-search-input"><?php _e( 'Search Themes' ); ?>:</label>
     85        <input type="text" id="theme-search-input" name="s" value="<?php _admin_search_query(); ?>" />
     86        <?php submit_button( __( 'Search Installed Themes' ), 'button', '', false ); ?>
     87</p>
     88</form>
    6389
    64                                 if ( isset( $allowed_themes[$theme_key] ) == true ) {
    65                                         $enabled = true;
    66                                         $activated_themes_count++;
    67                                         $class1 = 'active';
    68                                 } else {
    69                                         $disabled = true;
    70                                 }
    71                                 ?>
    72                                 <tr valign="top" class="<?php echo $class . ' ' . $class1; ?>">
    73                                         <td>
    74                                                 <label><input name="theme[<?php echo $theme_key ?>]" type="radio" id="enabled_<?php echo $theme_key ?>" value="enabled" <?php checked( $enabled ) ?> /> <?php _e( 'Yes' ) ?></label>
    75                                                 &nbsp;&nbsp;&nbsp;
    76                                                 <label><input name="theme[<?php echo $theme_key ?>]" type="radio" id="disabled_<?php echo $theme_key ?>" value="disabled" <?php checked( $disabled ) ?> /> <?php _e( 'No' ) ?></label>
    77                                         </td>
    78                                         <th scope="row" style="text-align:left;"><?php echo $key ?></th>
    79                                         <td><?php echo $theme['Version'] ?></td>
    80                                         <td><?php echo $theme['Description'] ?></td>
    81                                 </tr>
    82                         <?php } ?>
    83                         </tbody>
    84                 </table>
    85                
    86                 <?php submit_button( __( 'Apply Changes' ), '', '' ); ?>
    87         </form>
     90<?php $wp_list_table->views(); ?>
    8891
    89         <h3><?php _e( 'Total' )?></h3>
    90         <p>
    91                 <?php printf( __( 'Themes Installed: %d' ), $total_theme_count); ?>
    92                 <br />
    93                 <?php printf( __( 'Themes Enabled: %d' ), $activated_themes_count); ?>
    94         </p>
     92<form method="post" action="">
     93<input type="hidden" name="theme_status" value="<?php echo esc_attr($status) ?>" />
     94<input type="hidden" name="paged" value="<?php echo esc_attr($page) ?>" />
     95
     96<?php $wp_list_table->display(); ?>
     97</form>
     98
    9599</div>
    96100
    97 <?php include( '../admin-footer.php' ); ?>
     101<?php
     102include(ABSPATH . 'wp-admin/admin-footer.php');
Note: See TracChangeset for help on using the changeset viewer.