Ticket #14897: 14897.14.diff
File 14897.14.diff, 12.7 KB (added by , 14 years ago) |
---|
-
wp-admin/includes/class-wp-ms-themes-list-table.php
7 7 * @since 3.1.0 8 8 */ 9 9 class WP_MS_Themes_List_Table extends WP_List_Table { 10 11 var $site_id; 12 var $is_site_themes; 10 13 11 14 function WP_MS_Themes_List_Table() { 12 15 global $status, $page; … … 37 40 } 38 41 } 39 42 40 if ( !current_user_can('manage_network_themes') ) 41 wp_die( __( 'You do not have sufficient permissions to manage themes for this site.' ) ); 43 if ( $this->is_site_themes && !current_user_can('manage_sites') ) 44 wp_die( __( 'You do not have sufficient permissions to manage themes for this site.' ) ); 45 else if ( !$this->is_site_themes && !current_user_can('manage_network_themes') ) 46 wp_die( __( 'You do not have sufficient permissions to manage network themes.' ) ); 42 47 } 43 48 44 49 function prepare_items() { … … 54 59 'upgrade' => array() 55 60 ); 56 61 57 $allowed_themes = get_site_allowed_themes(); 62 $site_allowed_themes = get_site_allowed_themes(); 63 if ( !$this->is_site_themes ) 64 $allowed_themes = $site_allowed_themes; 65 else 66 $allowed_themes = wpmu_get_blog_allowedthemes( $this->site_id ); 67 58 68 $current = get_site_transient( 'update_themes' ); 59 69 60 70 foreach ( (array) $themes['all'] as $key => $theme ) { 61 71 $theme_key = esc_html( $theme['Stylesheet'] ); 72 62 73 if ( isset( $allowed_themes [ $theme_key ] ) ) { 63 74 $themes['all'][$key]['enabled'] = true; 64 75 $themes['enabled'][$key] = $themes['all'][$key]; … … 69 80 } 70 81 if ( isset( $current->response[ $theme['Template'] ] ) ) 71 82 $themes['upgrade'][$key] = $themes['all'][$key]; 83 84 if ( $this->is_site_themes && isset( $site_allowed_themes[$theme_key] ) ) { 85 unset( $themes['all'][$key] ); 86 unset( $themes['enabled'][$key] ); 87 unset( $themes['disabled'][$key] ); 88 } 72 89 } 73 90 74 91 if ( !current_user_can( 'update_themes' ) ) … … 188 205 break; 189 206 } 190 207 208 if ( $this->is_site_themes ) 209 $url = 'site-themes.php?id=' . $this->site_id; 210 else 211 $url = 'themes.php'; 212 191 213 $status_links[$type] = sprintf( "<a href='%s' %s>%s</a>", 192 add_query_arg('theme_status', $type, 'themes.php'),214 add_query_arg('theme_status', $type, $url), 193 215 ( $type == $status ) ? ' class="current"' : '', 194 216 sprintf( $text, number_format_i18n( $count ) ) 195 217 ); … … 203 225 204 226 $actions = array(); 205 227 if ( 'enabled' != $status ) 206 $actions[' network-enable-selected'] = __( 'Enable' );228 $actions['enable-selected'] = __( 'Enable' ); 207 229 if ( 'disabled' != $status ) 208 $actions[' network-disable-selected'] = __( 'Disable' );230 $actions['disable-selected'] = __( 'Disable' ); 209 231 if ( current_user_can( 'update_themes' ) ) 210 232 $actions['update-selected'] = __( 'Update' ); 211 233 … … 225 247 global $status, $page, $s; 226 248 227 249 $context = $status; 250 251 if ( $this->is_site_themes ) 252 $url = "site-themes.php?id={$this->site_id}&"; 253 else 254 $url = 'themes.php?'; 228 255 229 256 foreach ( $this->items as $key => $theme ) { 230 257 // preorder 231 258 $actions = array( 232 ' network_enable' => '',233 ' network_disable' => '',259 'enable' => '', 260 'disable' => '', 234 261 'edit' => '' 235 262 ); 236 263 237 264 $theme_key = esc_html( $theme['Stylesheet'] ); 238 265 239 if ( empty( $theme['enabled'] ) ) { 240 if ( current_user_can( 'manage_network_themes' ) ) 241 $actions['network_enable'] = '<a href="' . wp_nonce_url('themes.php?action=network-enable&theme=' . $theme_key . '&paged=' . $page . '&s=' . $s, 'enable-theme_' . $theme_key) . '" title="' . __('Enable this theme for all sites in this network') . '" class="edit">' . __('Enable') . '</a>'; 242 } else { 243 if ( current_user_can( 'manage_network_themes' ) ) 244 $actions['network_disable'] = '<a href="' . wp_nonce_url('themes.php?action=network-disable&theme=' . $theme_key . '&paged=' . $page . '&s=' . $s, 'disable-theme_' . $theme_key) . '" title="' . __('Disable this theme') . '">' . __('Disable') . '</a>'; 245 } 266 if ( empty( $theme['enabled'] ) ) 267 $actions['enable'] = '<a href="' . wp_nonce_url($url . 'action=enable&theme=' . $theme_key . '&paged=' . $page . '&s=' . $s, 'enable-theme_' . $theme_key) . '" title="' . __('Enable this theme') . '" class="edit">' . __('Enable') . '</a>'; 268 else 269 $actions['disable'] = '<a href="' . wp_nonce_url($url . 'action=disable&theme=' . $theme_key . '&paged=' . $page . '&s=' . $s, 'disable-theme_' . $theme_key) . '" title="' . __('Disable this theme') . '">' . __('Disable') . '</a>'; 246 270 247 271 if ( current_user_can('edit_themes') ) 248 272 $actions['edit'] = '<a href="theme-editor.php?theme=' . $theme['Name'] . '" title="' . __('Open this theme in the Theme Editor') . '" class="edit">' . __('Edit') . '</a>'; -
wp-admin/network/themes.php
17 17 $s = isset($_REQUEST['s']) ? $_REQUEST['s'] : ''; 18 18 19 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']);20 $_SERVER['REQUEST_URI'] = remove_query_arg(array('enable', 'disable', 'enable-selected', 'disable-selected'), $_SERVER['REQUEST_URI']); 21 21 22 22 if ( $action ) { 23 23 $allowed_themes = get_site_option( 'allowedthemes' ); 24 24 switch ( $action ) { 25 case ' network-enable':25 case 'enable': 26 26 $allowed_themes[ $_GET['theme'] ] = true; 27 27 update_site_option( 'allowedthemes', $allowed_themes ); 28 28 wp_redirect( wp_get_referer() ); // @todo add_query_arg for update message 29 29 exit; 30 30 break; 31 case ' network-disable':31 case 'disable': 32 32 unset( $allowed_themes[ $_GET['theme'] ] ); 33 33 update_site_option( 'allowedthemes', $allowed_themes ); 34 34 wp_redirect( wp_get_referer() ); // @todo add_query_arg for update message 35 35 exit; 36 36 break; 37 case ' network-enable-selected':37 case 'enable-selected': 38 38 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); 39 39 if ( empty($themes) ) { 40 40 wp_redirect( wp_get_referer() ); … … 44 44 $allowed_themes[ $theme ] = true; 45 45 update_site_option( 'allowedthemes', $allowed_themes ); 46 46 break; 47 case ' network-disable-selected':47 case 'disable-selected': 48 48 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); 49 49 if ( empty($themes) ) { 50 50 wp_redirect( wp_get_referer() ); … … 81 81 <div class="wrap"> 82 82 <?php screen_icon('themes'); ?> 83 83 <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> 84 <p ><?php _e( 'Themes must be enabled for your network before they will be available to individual sites.' ) ?></p>84 <p class="description"><?php _e( 'Themes must be enabled for your network before they will be available to individual sites.' ) ?></p> 85 85 86 86 <form method="get" action=""> 87 87 <p class="search-box"> -
wp-admin/network/site-themes.php
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(); 19 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']); 21 20 22 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; 21 23 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 ); 26 32 if ( $details->site_id != $wpdb->siteid ) … … 28 34 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' ); 33 37 if ( $action ) { 34 38 switch_to_blog( $id ); 39 $allowed_themes = get_option( 'allowedthemes' ); 35 40 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') ); 80 81 wp_redirect( wp_get_referer() ); // @todo add_query_arg for update message 82 exit; 47 83 } 48 84 49 if ( isset($_GET['update']) ) {50 $messages = array();51 if ( 'updated' == $_GET['update'] )52 $messages[] = __('Site users updated.');53 }54 55 85 $title = sprintf( __('Edit Site: %s'), get_blogaddress_by_id($id)); 56 86 $parent_file = 'sites.php'; 57 87 $submenu_file = 'sites.php'; 58 88 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 63 98 <div class="wrap"> … … 73 108 } 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'); 121 No newline at end of file 129 <?php include(ABSPATH . 'wp-admin/admin-footer.php'); ?> 130 No newline at end of file