Ticket #15920: 15920.2.diff
File 15920.2.diff, 7.5 KB (added by , 15 years ago) |
---|
-
wp-admin/includes/class-wp-ms-themes-list-table.php
78 78 $current = get_site_transient( 'update_themes' ); 79 79 80 80 foreach ( (array) $themes['all'] as $key => $theme ) { 81 $theme_key = esc_html( $theme['Stylesheet'] );81 $theme_key = $theme['Stylesheet']; 82 82 83 83 if ( isset( $allowed_themes [ $theme_key ] ) ) { 84 84 $themes['all'][$key]['enabled'] = true; … … 276 276 'delete' => '' 277 277 ); 278 278 279 $theme_key = esc_html( $theme['Stylesheet'] );279 $theme_key = $theme['Stylesheet']; 280 280 281 281 if ( empty( $theme['enabled'] ) ) 282 282 $actions['enable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=enable&theme=' . $theme_key . '&paged=' . $page . '&s=' . $s, 'enable-theme_' . $theme_key) ) . '" title="' . esc_attr__('Enable this theme') . '" class="edit">' . ( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) ) . '</a>'; … … 285 285 286 286 if ( current_user_can('edit_themes') ) 287 287 $actions['edit'] = '<a href="' . esc_url('theme-editor.php?theme=' . $theme['Name'] ) . '" title="' . esc_attr__('Open this theme in the Theme Editor') . '" class="edit">' . __('Edit') . '</a>'; 288 289 if ( empty( $theme['enabled'] ) && current_user_can( 'delete_themes' ) && ! $this->is_site_themes )288 289 if ( empty( $theme['enabled'] ) && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $theme_key != get_option( 'stylesheet' ) && $theme_key != get_option( 'template' ) ) 290 290 $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=delete-selected&checked[]=' . $theme_key . '&theme_status=' . $context . '&paged=' . $page . '&s=' . $s, 'bulk-themes' ) ) . '" title="' . esc_attr__( 'Delete this theme' ) . '" class="delete">' . __( 'Delete' ) . '</a>'; 291 291 292 292 $actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme_key, $theme, $context ); -
wp-admin/network/themes.php
28 28 $s = isset($_REQUEST['s']) ? $_REQUEST['s'] : ''; 29 29 30 30 // Clean up request URI from temporary args for screen options/paging uri's to work as expected. 31 $_SERVER['REQUEST_URI'] = remove_query_arg(array('enable', 'disable', 'enable-selected', 'disable-selected'), $_SERVER['REQUEST_URI']); 31 $temp_args = array( 'enabled', 'disabled', 'deleted', 'error', 'enabled', 'disabled', 'deleted', 'error' ); 32 $_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] ); 33 $referer = remove_query_arg( $temp_args, wp_get_referer() ); 32 34 33 35 if ( $action ) { 34 36 $allowed_themes = get_site_option( 'allowedthemes' ); … … 37 39 check_admin_referer('enable-theme_' . $_GET['theme']); 38 40 $allowed_themes[ $_GET['theme'] ] = true; 39 41 update_site_option( 'allowedthemes', $allowed_themes ); 40 wp_redirect( wp_get_referer() ); // @todo add_query_arg for update message41 exit; 42 wp_redirect( add_query_arg( 'enabled', '1', $referer ) ); 43 exit; 42 44 break; 43 45 case 'disable': 44 46 check_admin_referer('disable-theme_' . $_GET['theme']); 45 47 unset( $allowed_themes[ $_GET['theme'] ] ); 46 48 update_site_option( 'allowedthemes', $allowed_themes ); 47 wp_redirect( wp_get_referer() ); // @todo add_query_arg for update message49 wp_redirect( add_query_arg( 'disabled', '1', $referer ) ); 48 50 exit; 49 51 break; 50 52 case 'enable-selected': 51 53 check_admin_referer('bulk-themes'); 52 54 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); 53 55 if ( empty($themes) ) { 54 wp_redirect( wp_get_referer() );56 wp_redirect( add_query_arg( 'error', 'none', $referer ) ); 55 57 exit; 56 } 58 } 57 59 foreach( (array) $themes as $theme ) 58 60 $allowed_themes[ $theme ] = true; 59 61 update_site_option( 'allowedthemes', $allowed_themes ); 62 wp_redirect( add_query_arg( 'enabled', count( $themes ), $referer ) ); 63 exit; 60 64 break; 61 65 case 'disable-selected': 62 66 check_admin_referer('bulk-themes'); 63 67 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); 64 68 if ( empty($themes) ) { 65 wp_redirect( wp_get_referer() );69 wp_redirect( add_query_arg( 'error', 'none', $referer ) ); 66 70 exit; 67 } 71 } 68 72 foreach( (array) $themes as $theme ) 69 73 unset( $allowed_themes[ $theme ] ); 70 74 update_site_option( 'allowedthemes', $allowed_themes ); 75 wp_redirect( add_query_arg( 'disabled', count( $themes ), $referer ) ); 76 exit; 71 77 break; 72 78 case 'delete-selected': 73 79 if ( ! current_user_can( 'delete_themes' ) ) … … 75 81 check_admin_referer( 'bulk-themes' ); 76 82 77 83 $themes = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array(); 84 85 if ( isset( $themes[ get_option( 'template' ) ] ) ) 86 unset( $themes[ get_option( 'template' ) ] ); 87 if ( isset( $themes[ get_option( 'stylesheet' ) ] ) ) 88 unset( $themes[ get_option( 'stylesheet' ) ] ); 89 78 90 if ( empty( $themes ) ) { 79 wp_redirect( wp_get_referer() );91 wp_redirect( add_query_arg( 'error', 'none', $referer ) ); 80 92 exit; 81 93 } 82 94 … … 93 105 } 94 106 95 107 if ( empty( $themes ) ) { 96 wp_redirect( add_query_arg( 'error', 'main', wp_get_referer()) );108 wp_redirect( add_query_arg( 'error', 'main', $referer ) ); 97 109 exit; 98 110 } 99 111 … … 149 161 150 162 foreach ( $themes as $theme ) 151 163 $delete_result = delete_theme( $theme ); 152 wp_redirect( network_admin_url( 'themes.php?deleted=true') );164 wp_redirect( add_query_arg( 'deleted', count( $themes ), $referer ) ); 153 165 exit; 154 166 break; 155 167 } … … 174 186 175 187 require_once(ABSPATH . 'wp-admin/admin-header.php'); 176 188 177 if ( isset( $_GET['deleted'] ) ) : ?>178 <div class="updated"><p><?php _e('Theme deleted.') ?></p></div><?php179 elseif ( isset( $_GET['error'] ) && 'main' == $_GET['error'] ) : ?>180 <div class="error"><p><?php _e( 'You cannot delete a theme while it is active on the main site.' ); ?></p></div><?php181 endif;182 189 ?> 183 190 184 191 <div class="wrap"> … … 188 195 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( $s ) ); ?> 189 196 </h2> 190 197 198 <?php 199 if ( isset( $_GET['enabled'] ) ) { 200 $_GET['enabled'] = absint( $_GET['enabled'] ); 201 echo '<div id="message" class="updated"><p>' . sprintf( _n( 'Theme enabled.', '%s themes enabled.', $_GET['enabled'] ), number_format_i18n( $_GET['enabled'] ) ) . '</p></div>'; 202 } elseif ( isset( $_GET['disabled'] ) ) { 203 $_GET['disabled'] = absint( $_GET['disabled'] ); 204 echo '<div id="message" class="updated"><p>' . sprintf( _n( 'Theme disabled.', '%s themes disabled.', $_GET['disabled'] ), number_format_i18n( $_GET['disabled'] ) ) . '</p></div>'; 205 } elseif ( isset( $_GET['deleted'] ) ) { 206 $_GET['disabled'] = absint( $_GET['deleted'] ); 207 echo '<div id="message" class="updated"><p>' . sprintf( _n( 'Theme deleted.', '%s themes deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) ) . '</p></div>'; 208 } elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) { 209 echo '<div id="message" class="error"><p>' . __( 'No theme selected.' ) . '</p></div>'; 210 } elseif ( isset( $_GET['error'] ) && 'main' == $_GET['error'] ) { 211 echo '<div class="error"><p>' . __( 'You cannot delete a theme while it is active on the main site.' ) . '</p></div>'; 212 } 213 214 ?> 215 191 216 <form method="get" action=""> 192 217 <?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?> 193 218 </form>