Changeset 16242 for trunk/wp-admin/network/site-themes.php
- Timestamp:
- 11/08/2010 09:52:54 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/network/site-themes.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/network/site-themes.php
r15962 r16242 1 1 <?php 2 3 2 /** 4 * Edit Site Themes Administration Screen3 * Multisite themes administration panel. 5 4 * 6 5 * @package WordPress 7 * @subpackage Administration6 * @subpackage Multisite 8 7 * @since 3.1.0 9 8 */ 10 9 11 /** Load WordPress Administration Bootstrap */ 12 require_once('./admin.php'); 10 require_once( './admin.php' ); 13 11 14 if ( ! is_multisite() ) 15 wp_die( __( 'Multisite support is not enabled.' ));12 $wp_list_table = get_list_table('WP_MS_Themes_List_Table'); 13 $wp_list_table->check_permissions(); 16 14 17 if ( ! current_user_can('manage_sites') ) 18 wp_die(__('You do not have sufficient permissions to edit this site.')); 15 $action = $wp_list_table->current_action(); 16 17 $s = isset($_REQUEST['s']) ? $_REQUEST['s'] : ''; 18 19 // Clean up request URI from temporary args for screen options/paging uri's to work as expected. 20 $_SERVER['REQUEST_URI'] = remove_query_arg(array('network-enable', 'network-disable', 'network-enable-selected', 'network-disable-selected'), $_SERVER['REQUEST_URI']); 19 21 20 22 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; … … 22 24 if ( ! $id ) 23 25 wp_die( __('Invalid site ID.') ); 26 27 $wp_list_table->site_id = $id; 28 $wp_list_table->is_site_themes = true; 29 $wp_list_table->prepare_items(); 24 30 25 31 $details = get_blog_details( $id ); … … 29 35 $is_main_site = is_main_site( $id ); 30 36 31 if ( isset($_REQUEST['action']) && 'update-site' == $_REQUEST['action'] ) { 32 check_admin_referer( 'edit-site' ); 37 if ( $action ) { 38 switch_to_blog( $id ); 39 $allowed_themes = get_option( 'allowedthemes' ); 33 40 34 switch_to_blog( $id ); 35 36 $allowedthemes = array(); 37 if ( isset($_POST['theme']) && is_array( $_POST['theme'] ) ) { 38 foreach ( $_POST['theme'] as $theme => $val ) { 39 if ( 'on' == $val ) 40 $allowedthemes[$theme] = true; 41 } 41 switch ( $action ) { 42 case 'enable': 43 $theme = $_GET['theme']; 44 if ( !$allowed_themes ) 45 $allowed_themes = array( $theme => true ); 46 else 47 $allowed_themes[$theme] = true; 48 break; 49 case 'disable': 50 $theme = $_GET['theme']; 51 if ( !$allowed_themes ) 52 $allowed_themes = array(); 53 else 54 unset( $allowed_themes[$theme] ); 55 break; 56 case 'enable-selected': 57 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); 58 if ( empty($themes) ) { 59 restore_current_blog(); 60 wp_redirect( wp_get_referer() ); 61 exit; 62 } 63 foreach( (array) $themes as $theme ) 64 $allowed_themes[ $theme ] = true; 65 break; 66 case 'disable-selected': 67 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); 68 if ( empty($themes) ) { 69 restore_current_blog(); 70 wp_redirect( wp_get_referer() ); 71 exit; 72 } 73 foreach( (array) $themes as $theme ) 74 unset( $allowed_themes[ $theme ] ); 75 break; 42 76 } 43 update_option( 'allowedthemes', $allowedthemes );44 77 78 update_option( 'allowedthemes', $allowed_themes ); 45 79 restore_current_blog(); 46 wp_redirect( add_query_arg( array( 'update' => 'updated', 'id' => $id ), 'site-themes.php') ); 47 } 48 49 if ( isset($_GET['update']) ) { 50 $messages = array(); 51 if ( 'updated' == $_GET['update'] ) 52 $messages[] = __('Site users updated.'); 80 81 wp_redirect( wp_get_referer() ); // @todo add_query_arg for update message 82 exit; 53 83 } 54 84 … … 59 89 require('../admin-header.php'); 60 90 91 add_thickbox(); 92 93 add_screen_option( 'per_page', array('label' => _x( 'Themes', 'themes per page (screen options)' ), 'default' => 999) ); 94 95 require_once(ABSPATH . 'wp-admin/admin-header.php'); 61 96 ?> 62 97 … … 74 109 ?> 75 110 </h3> 111 <p class="description"><?php _e( 'Network enabled themes are not shown on this screen.' ) ?></p> 76 112 <?php 77 113 if ( ! empty( $messages ) ) { 78 114 foreach ( $messages as $msg ) 79 115 echo '<div id="message" class="updated"><p>' . $msg . '</p></div>'; 80 } ?> 116 } 117 118 $wp_list_table->views(); ?> 119 81 120 <form method="post" action="site-themes.php?action=update-site"> 82 121 <?php wp_nonce_field( 'edit-site' ); ?> 83 122 <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" /> 84 <?php85 $themes = get_themes();86 $blog_allowed_themes = wpmu_get_blog_allowedthemes( $id );87 $allowed_themes = get_site_option( 'allowedthemes' );88 123 89 if ( ! $allowed_themes ) 90 $allowed_themes = array_keys( $themes ); 124 <?php $wp_list_table->display(); ?> 91 125 92 $out = '';93 foreach ( $themes as $key => $theme ) {94 $theme_key = esc_html( $theme['Stylesheet'] );95 if ( ! isset( $allowed_themes[$theme_key] ) ) {96 $checked = isset( $blog_allowed_themes[ $theme_key ] ) ? 'checked="checked"' : '';97 $out .= '<tr class="form-field form-required">98 <th title="' . esc_attr( $theme["Description"] ).'" scope="row">' . esc_html( $key ) . '</th>99 <td><label><input name="theme[' . esc_attr( $theme_key ) . ']" type="checkbox" style="width:20px;" value="on" '.$checked.'/> ' . __( 'Active' ) . '</label></td>100 </tr>';101 }102 }103 104 if ( $out != '' ) {105 ?>106 <p class="description"><?php _e( 'Activate the themename of an existing theme and hit "Update Options" to allow the theme for this site.' ) ?></p>107 <table class="form-table">108 <?php echo $out; ?>109 </table>110 <?php111 submit_button();112 } else {113 _e('All themes are allowed.');114 }115 ?>116 126 </form> 117 127 118 128 </div> 119 <?php 120 require('../admin-footer.php'); 129 <?php include(ABSPATH . 'wp-admin/admin-footer.php'); ?>
Note: See TracChangeset
for help on using the changeset viewer.