Ticket #15920: 15920.diff
| File 15920.diff, 7.4 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 $referer = remove_query_arg( array( 'enable', 'disable', 'enable-selected', 'disable-selected', 32 'enabled', 'disabled', 'deleted', 'error'), wp_get_referer() ); 32 33 33 34 if ( $action ) { 34 35 $allowed_themes = get_site_option( 'allowedthemes' ); … … 37 38 check_admin_referer('enable-theme_' . $_GET['theme']); 38 39 $allowed_themes[ $_GET['theme'] ] = true; 39 40 update_site_option( 'allowedthemes', $allowed_themes ); 40 wp_redirect( wp_get_referer() ); // @todo add_query_arg for update message41 exit; 41 wp_redirect( add_query_arg( 'enabled', '1', $referer ) ); 42 exit; 42 43 break; 43 44 case 'disable': 44 45 check_admin_referer('disable-theme_' . $_GET['theme']); 45 46 unset( $allowed_themes[ $_GET['theme'] ] ); 46 47 update_site_option( 'allowedthemes', $allowed_themes ); 47 wp_redirect( wp_get_referer() ); // @todo add_query_arg for update message48 wp_redirect( add_query_arg( 'disabled', '1', $referer ) ); 48 49 exit; 49 50 break; 50 51 case 'enable-selected': 51 52 check_admin_referer('bulk-themes'); 52 53 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); 53 54 if ( empty($themes) ) { 54 wp_redirect( wp_get_referer() );55 wp_redirect( add_query_arg( 'error', 'none', $referer ) ); 55 56 exit; 56 } 57 } 57 58 foreach( (array) $themes as $theme ) 58 59 $allowed_themes[ $theme ] = true; 59 60 update_site_option( 'allowedthemes', $allowed_themes ); 61 wp_redirect( add_query_arg( 'enabled', count( $themes ), $referer ) ); 62 exit; 60 63 break; 61 64 case 'disable-selected': 62 65 check_admin_referer('bulk-themes'); 63 66 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); 64 67 if ( empty($themes) ) { 65 wp_redirect( wp_get_referer() );68 wp_redirect( add_query_arg( 'error', 'none', $referer ) ); 66 69 exit; 67 } 70 } 68 71 foreach( (array) $themes as $theme ) 69 72 unset( $allowed_themes[ $theme ] ); 70 73 update_site_option( 'allowedthemes', $allowed_themes ); 74 wp_redirect( add_query_arg( 'disabled', count( $themes ), $referer ) ); 75 exit; 71 76 break; 72 77 case 'delete-selected': 73 78 if ( ! current_user_can( 'delete_themes' ) ) … … 75 80 check_admin_referer( 'bulk-themes' ); 76 81 77 82 $themes = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array(); 83 84 if ( isset( $themes[ get_option( 'template' ) ] ) ) 85 unset( $themes[ get_option( 'template' ) ] ); 86 if ( isset( $themes[ get_option( 'stylesheet' ) ] ) ) 87 unset( $themes[ get_option( 'stylesheet' ) ] ); 88 78 89 if ( empty( $themes ) ) { 79 wp_redirect( wp_get_referer() );90 wp_redirect( add_query_arg( 'error', 'none', $referer ) ); 80 91 exit; 81 92 } 82 93 … … 93 104 } 94 105 95 106 if ( empty( $themes ) ) { 96 wp_redirect( add_query_arg( 'error', 'main', wp_get_referer()) );107 wp_redirect( add_query_arg( 'error', 'main', $referer ) ); 97 108 exit; 98 109 } 99 110 … … 149 160 150 161 foreach ( $themes as $theme ) 151 162 $delete_result = delete_theme( $theme ); 152 wp_redirect( network_admin_url( 'themes.php?deleted=true') );163 wp_redirect( add_query_arg( 'deleted', count( $themes ), $referer ) ); 153 164 exit; 154 165 break; 155 166 } … … 174 185 175 186 require_once(ABSPATH . 'wp-admin/admin-header.php'); 176 187 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 188 ?> 183 189 184 190 <div class="wrap"> … … 188 194 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( $s ) ); ?> 189 195 </h2> 190 196 197 <?php 198 if ( isset( $_GET['enabled'] ) ) { 199 $_GET['enabled'] = absint( $_GET['enabled'] ); 200 echo '<div id="message" class="updated"><p>' . sprintf( _n( 'Theme enabled.', '%s themes enabled.', $_GET['enabled'] ), number_format_i18n( $_GET['enabled'] ) ) . '</p></div>'; 201 } elseif ( isset( $_GET['disabled'] ) ) { 202 $_GET['disabled'] = absint( $_GET['disabled'] ); 203 echo '<div id="message" class="updated"><p>' . sprintf( _n( 'Theme disabled.', '%s themes disabled.', $_GET['disabled'] ), number_format_i18n( $_GET['disabled'] ) ) . '</p></div>'; 204 } elseif ( isset( $_GET['deleted'] ) ) { 205 $_GET['disabled'] = absint( $_GET['deleted'] ); 206 echo '<div id="message" class="updated"><p>' . sprintf( _n( 'Theme deleted.', '%s themes deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) ) . '</p></div>'; 207 } elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) { 208 echo '<div id="message" class="error"><p>' . __( 'No theme selected.' ) . '</p></div>'; 209 } elseif ( isset( $_GET['error'] ) && 'main' == $_GET['error'] ) { 210 echo '<div class="error"><p>' . __( 'You cannot delete a theme while it is active on the main site.' ) . '</p></div>'; 211 } 212 213 ?> 214 191 215 <form method="get" action=""> 192 216 <?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?> 193 217 </form>