Changeset 17101 for trunk/wp-admin/network/themes.php
- Timestamp:
- 12/21/2010 04:50:16 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/network/themes.php
r17050 r17101 66 66 update_site_option( 'allowedthemes', $allowed_themes ); 67 67 break; 68 case 'delete': 69 check_admin_referer('delete-theme_' . $_GET['template']); 70 if ( !current_user_can('delete_themes') ) 71 wp_die( __( 'Cheatin’ uh?' ) ); 72 delete_theme($_GET['template']); 73 wp_redirect( network_admin_url('themes.php?deleted=true') ); 74 exit; 75 break; 76 case 'delete-selected': 77 if ( ! current_user_can( 'delete_themes' ) ) 78 wp_die( __('You do not have sufficient permissions to delete themes for this site.') ); 79 80 $themes = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array(); 81 if ( empty( $themes ) ) { 82 wp_redirect( wp_get_referer() ); 83 exit; 84 } 85 86 $main_theme = get_current_theme(); 87 $files_to_delete = $theme_info = array(); 88 foreach( $themes as $key => $theme ) { 89 $data = get_theme_data( WP_CONTENT_DIR . '/themes/' . $theme . '/style.css' ); 90 if ( $data['Name'] == $main_theme ) { 91 unset( $themes[$key] ); 92 } else { 93 $files_to_delete = array_merge( $files_to_delete, list_files( WP_CONTENT_DIR . "/themes/$theme" ) ); 94 $theme_info[ $theme ] = $data; 95 } 96 } 97 98 if ( empty( $themes ) ) { 99 wp_redirect( add_query_arg( 'error', 'main', wp_get_referer() ) ); 100 exit; 101 } 102 103 include(ABSPATH . 'wp-admin/update.php'); 104 105 $parent_file = 'themes.php'; 106 107 if ( ! isset( $_REQUEST['verify-delete'] ) ) { 108 wp_enqueue_script( 'jquery' ); 109 require_once( ABSPATH . 'wp-admin/admin-header.php' ); 110 ?> 111 <div class="wrap"> 112 <?php 113 $themes_to_delete = count( $themes ); 114 screen_icon(); 115 echo '<h2>' . _n( 'Delete Theme', 'Delete Themes', $themes_to_delete ) . '</h2>'; 116 ?> 117 <div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php echo _n( 'This theme may be active on other sites in the network.', 'These themes may be active on other sites in the network.', $themes_to_delete ); ?></p></div> 118 <p><?php echo _n( 'You are about to remove the following theme:', 'You are about to remove the following themes:', $themes_to_delete ); ?></p> 119 <ul class="ul-disc"> 120 <?php foreach ( $theme_info as $theme ) 121 echo '<li>', sprintf( __('<strong>%1$s</strong> by <em>%2$s</em>' ), esc_html( $theme['Name'] ), esc_html( $theme['AuthorName'] ) ), '</li>'; /* translators: 1: theme name, 2: theme author */ ?> 122 </ul> 123 <p><?php _e('Are you sure you wish to delete these themes?'); ?></p> 124 <form method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" style="display:inline;"> 125 <input type="hidden" name="verify-delete" value="1" /> 126 <input type="hidden" name="action" value="delete-selected" /> 127 <?php 128 foreach ( (array) $themes as $theme ) 129 echo '<input type="hidden" name="checked[]" value="' . esc_attr($theme) . '" />'; 130 ?> 131 <?php wp_nonce_field('bulk-themes') ?> 132 <?php submit_button( _n( 'Yes, Delete this theme', 'Yes, Delete these themes', $themes_to_delete ), 'button', 'submit', false ); ?> 133 </form> 134 <form method="post" action="<?php echo esc_url(wp_get_referer()); ?>" style="display:inline;"> 135 <?php submit_button( __( 'No, Return me to the theme list' ), 'button', 'submit', false ); ?> 136 </form> 137 138 <p><a href="#" onclick="jQuery('#files-list').toggle(); return false;"><?php _e('Click to view entire list of files which will be deleted'); ?></a></p> 139 <div id="files-list" style="display:none;"> 140 <ul class="code"> 141 <?php 142 foreach ( (array) $files_to_delete as $file ) 143 echo '<li>' . esc_html( str_replace( WP_CONTENT_DIR . "/themes", '', $file) ) . '</li>'; 144 ?> 145 </ul> 146 </div> 147 </div> 148 <?php 149 require_once(ABSPATH . 'wp-admin/admin-footer.php'); 150 exit; 151 } //Endif verify-delete 152 foreach( $themes as $theme ) 153 $delete_result = delete_theme( $theme ); 154 wp_redirect( network_admin_url( 'themes.php?deleted=true' ) ); 155 exit; 156 break; 68 157 } 69 158 } … … 88 177 require_once(ABSPATH . 'wp-admin/admin-header.php'); 89 178 179 if ( isset( $_GET['deleted'] ) ) : ?> 180 <div class="updated"><p><?php _e('Theme deleted.') ?></p></div><?php 181 elseif ( isset( $_GET['error'] ) && 'main' == $_GET['error'] ) : ?> 182 <div class="error"><p><?php _e( 'You cannot delete a theme while it is active on the main site.' ); ?></p></div><?php 183 endif; 90 184 ?> 91 185
Note: See TracChangeset
for help on using the changeset viewer.