Changeset 29856
- Timestamp:
- 10/08/2014 07:04:05 PM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/plugin.php
r29818 r29856 798 798 return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors); 799 799 800 // Get the base plugin folder800 // Get the base plugin folder. 801 801 $plugins_dir = $wp_filesystem->wp_plugins_dir(); 802 if ( empty($plugins_dir) ) 803 return new WP_Error('fs_no_plugins_dir', __('Unable to locate WordPress Plugin directory.')); 802 if ( empty( $plugins_dir ) ) { 803 return new WP_Error( 'fs_no_plugins_dir', __( 'Unable to locate WordPress Plugin directory.' ) ); 804 } 804 805 805 806 $plugins_dir = trailingslashit( $plugins_dir ); 806 807 808 $translations_dir = $wp_filesystem->wp_lang_dir(); 809 $translations_dir = trailingslashit( $translations_dir ); 810 811 $plugin_translations = wp_get_installed_translations( 'plugins' ); 812 807 813 $errors = array(); 808 814 809 815 foreach( $plugins as $plugin_file ) { 810 // Run Uninstall hook 811 if ( is_uninstallable_plugin( $plugin_file ) ) 816 // Run Uninstall hook. 817 if ( is_uninstallable_plugin( $plugin_file ) ) { 812 818 uninstall_plugin($plugin_file); 813 814 $this_plugin_dir = trailingslashit( dirname($plugins_dir . $plugin_file) ); 819 } 820 821 $this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin_file ) ); 815 822 // If plugin is in its own directory, recursively delete the directory. 816 if ( strpos($plugin_file, '/') && $this_plugin_dir != $plugins_dir ) //base check on if plugin includes directory separator AND that it's not the root plugin folder 817 $deleted = $wp_filesystem->delete($this_plugin_dir, true); 818 else 819 $deleted = $wp_filesystem->delete($plugins_dir . $plugin_file); 820 821 if ( ! $deleted ) 823 if ( strpos( $plugin_file, '/' ) && $this_plugin_dir != $plugins_dir ) { //base check on if plugin includes directory separator AND that it's not the root plugin folder 824 $deleted = $wp_filesystem->delete( $this_plugin_dir, true ); 825 } else { 826 $deleted = $wp_filesystem->delete( $plugins_dir . $plugin_file ); 827 } 828 829 if ( ! $deleted ) { 822 830 $errors[] = $plugin_file; 831 continue; 832 } 833 834 // Remove language files, silently. 835 $plugin_slug = dirname( $plugin_file ); 836 if ( '.' !== $plugin_slug && ! empty( $plugin_translations[ $plugin_slug ] ) ) { 837 $translations = $plugin_translations[ $plugin_slug ]; 838 839 foreach ( $translations as $translation => $data ) { 840 $wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.po' ); 841 $wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.mo' ); 842 } 843 } 823 844 } 824 845 -
trunk/src/wp-admin/includes/theme.php
r29479 r29856 56 56 return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors); 57 57 58 // Get the base plugin folder58 // Get the base plugin folder. 59 59 $themes_dir = $wp_filesystem->wp_themes_dir(); 60 if ( empty($themes_dir) ) 61 return new WP_Error('fs_no_themes_dir', __('Unable to locate WordPress theme directory.')); 60 if ( empty( $themes_dir ) ) { 61 return new WP_Error( 'fs_no_themes_dir', __( 'Unable to locate WordPress theme directory.' ) ); 62 } 62 63 63 64 $themes_dir = trailingslashit( $themes_dir ); 64 $theme_dir = trailingslashit($themes_dir . $stylesheet); 65 $deleted = $wp_filesystem->delete($theme_dir, true); 66 67 if ( ! $deleted ) 68 return new WP_Error('could_not_remove_theme', sprintf(__('Could not fully remove the theme %s.'), $stylesheet) ); 69 70 // Force refresh of theme update information 71 delete_site_transient('update_themes'); 65 $theme_dir = trailingslashit( $themes_dir . $stylesheet ); 66 $deleted = $wp_filesystem->delete( $theme_dir, true ); 67 68 if ( ! $deleted ) { 69 return new WP_Error( 'could_not_remove_theme', sprintf( __( 'Could not fully remove the theme %s.' ), $stylesheet ) ); 70 } 71 72 $translations_dir = $wp_filesystem->wp_lang_dir(); 73 $translations_dir = trailingslashit( $translations_dir ); 74 75 $theme_translations = wp_get_installed_translations( 'themes' ); 76 77 // Remove language files, silently. 78 if ( ! empty( $theme_translations[ $stylesheet ] ) ) { 79 $translations = $theme_translations[ $stylesheet ]; 80 81 foreach ( $translations as $translation => $data ) { 82 $wp_filesystem->delete( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.po' ); 83 $wp_filesystem->delete( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.mo' ); 84 } 85 } 86 87 // Force refresh of theme update information. 88 delete_site_transient( 'update_themes' ); 72 89 73 90 return true; -
trunk/src/wp-admin/network/themes.php
r29839 r29856 97 97 exit; 98 98 case 'delete-selected': 99 if ( ! current_user_can( 'delete_themes' ) ) 99 if ( ! current_user_can( 'delete_themes' ) ) { 100 100 wp_die( __('You do not have sufficient permissions to delete themes for this site.') ); 101 } 102 101 103 check_admin_referer( 'bulk-themes' ); 102 104 … … 116 118 117 119 $files_to_delete = $theme_info = array(); 120 $theme_translations = wp_get_installed_translations( 'themes' ); 118 121 foreach ( $themes as $key => $theme ) { 119 122 $theme_info[ $theme ] = wp_get_theme( $theme ); 120 $files_to_delete = array_merge( $files_to_delete, list_files( $theme_info[ $theme ]->get_stylesheet_directory() ) ); 123 124 // Locate all the files in that folder. 125 $files = list_files( $theme_info[ $theme ]->get_stylesheet_directory() ); 126 if ( $files ) { 127 $files_to_delete = array_merge( $files_to_delete, $files ); 128 } 129 130 // Add translation files. 131 $theme_slug = $theme_info[ $theme ]->get_stylesheet(); 132 if ( ! empty( $theme_translations[ $theme_slug ] ) ) { 133 $translations = $theme_translations[ $theme_slug ]; 134 135 foreach ( $translations as $translation => $data ) { 136 $files_to_delete[] = $theme_slug . '-' . $translation . '.po'; 137 $files_to_delete[] = $theme_slug . '-' . $translation . '.mo'; 138 } 139 } 121 140 } 122 141 … … 137 156 <p><?php echo _n( 'You are about to remove the following theme:', 'You are about to remove the following themes:', $themes_to_delete ); ?></p> 138 157 <ul class="ul-disc"> 139 <?php foreach ( $theme_info as $theme ) 140 echo '<li>', sprintf( __('<strong>%1$s</strong> by <em>%2$s</em>' ), $theme->display('Name'), $theme->display('Author') ), '</li>'; /* translators: 1: theme name, 2: theme author */ ?> 158 <?php 159 foreach ( $theme_info as $theme ) { 160 /* translators: 1: theme name, 2: theme author */ 161 echo '<li>', sprintf( __('<strong>%1$s</strong> by <em>%2$s</em>' ), $theme->display('Name'), $theme->display('Author') ), '</li>'; 162 } 163 ?> 141 164 </ul> 142 165 <p><?php _e('Are you sure you wish to delete these themes?'); ?></p> … … 145 168 <input type="hidden" name="action" value="delete-selected" /> 146 169 <?php 147 foreach ( (array) $themes as $theme ) 170 foreach ( (array) $themes as $theme ) { 148 171 echo '<input type="hidden" name="checked[]" value="' . esc_attr($theme) . '" />'; 172 } 149 173 ?> 150 174 <?php wp_nonce_field('bulk-themes') ?> … … 159 183 <ul class="code"> 160 184 <?php 161 foreach ( (array) $files_to_delete as $file ) 162 echo '<li>' . esc_html( str_replace( WP_CONTENT_DIR . "/themes", '', $file) ) . '</li>'; 185 foreach ( (array) $files_to_delete as $file ) { 186 echo '<li>' . esc_html( str_replace( WP_CONTENT_DIR . '/themes', '', $file ) ) . '</li>'; 187 } 163 188 ?> 164 189 </ul> -
trunk/src/wp-admin/plugins.php
r28646 r29856 208 208 209 209 case 'delete-selected': 210 if ( ! current_user_can('delete_plugins') ) 210 if ( ! current_user_can('delete_plugins') ) { 211 211 wp_die(__('You do not have sufficient permissions to delete plugins for this site.')); 212 } 212 213 213 214 check_admin_referer('bulk-plugins'); … … 238 239 $files_to_delete = $plugin_info = array(); 239 240 $have_non_network_plugins = false; 241 $plugin_translations = wp_get_installed_translations( 'plugins' ); 240 242 foreach ( (array) $plugins as $plugin ) { 241 if ( '.' == dirname($plugin) ) { 243 $plugin_slug = dirname( $plugin ); 244 245 if ( '.' == $plugin_slug ) { 242 246 $files_to_delete[] = WP_PLUGIN_DIR . '/' . $plugin; 243 if ( $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin) ) {247 if ( $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ) ) { 244 248 $plugin_info[ $plugin ] = $data; 245 249 $plugin_info[ $plugin ]['is_uninstallable'] = is_uninstallable_plugin( $plugin ); 246 if ( ! $plugin_info[ $plugin ]['Network'] ) 250 if ( ! $plugin_info[ $plugin ]['Network'] ) { 247 251 $have_non_network_plugins = true; 252 } 248 253 } 249 254 } else { 250 // Locate all the files in that folder 251 $files = list_files( WP_PLUGIN_DIR . '/' . dirname($plugin));255 // Locate all the files in that folder. 256 $files = list_files( WP_PLUGIN_DIR . '/' . $plugin_slug ); 252 257 if ( $files ) { 253 $files_to_delete = array_merge( $files_to_delete, $files);258 $files_to_delete = array_merge( $files_to_delete, $files ); 254 259 } 255 // Get plugins list from that folder 256 if ( $folder_plugins = get_plugins( '/' . dirname($plugin)) ) { 260 261 // Get plugins list from that folder. 262 if ( $folder_plugins = get_plugins( '/' . $plugin_slug ) ) { 257 263 foreach( $folder_plugins as $plugin_file => $data ) { 258 264 $plugin_info[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file, $data ); 259 265 $plugin_info[ $plugin_file ]['is_uninstallable'] = is_uninstallable_plugin( $plugin ); 260 if ( ! $plugin_info[ $plugin_file ]['Network'] ) 266 if ( ! $plugin_info[ $plugin_file ]['Network'] ) { 261 267 $have_non_network_plugins = true; 268 } 269 } 270 } 271 272 // Add translation files. 273 if ( ! empty( $plugin_translations[ $plugin_slug ] ) ) { 274 $translations = $plugin_translations[ $plugin_slug ]; 275 276 foreach ( $translations as $translation => $data ) { 277 $files_to_delete[] = $plugin_slug . '-' . $translation . '.po'; 278 $files_to_delete[] = $plugin_slug . '-' . $translation . '.mo'; 262 279 } 263 280 } … … 296 313 <input type="hidden" name="action" value="delete-selected" /> 297 314 <?php 298 foreach ( (array) $plugins as $plugin ) 299 echo '<input type="hidden" name="checked[]" value="' . esc_attr($plugin) . '" />'; 315 foreach ( (array) $plugins as $plugin ) { 316 echo '<input type="hidden" name="checked[]" value="' . esc_attr( $plugin ) . '" />'; 317 } 300 318 ?> 301 319 <?php wp_nonce_field('bulk-plugins') ?> … … 310 328 <ul class="code"> 311 329 <?php 312 foreach ( (array)$files_to_delete as $file ) 313 echo '<li>' . esc_html(str_replace(WP_PLUGIN_DIR, '', $file)) . '</li>'; 330 foreach ( (array) $files_to_delete as $file ) { 331 echo '<li>' . esc_html( str_replace( WP_PLUGIN_DIR, '', $file ) ) . '</li>'; 332 } 314 333 ?> 315 334 </ul> -
trunk/src/wp-includes/l10n.php
r29630 r29856 798 798 799 799 foreach ( $files as $file ) { 800 if ( '.' === $file[0] || is_dir( $file ) ) 800 if ( '.' === $file[0] || is_dir( $file ) ) { 801 801 continue; 802 if ( substr( $file, -3 ) !== '.po' ) 802 } 803 if ( substr( $file, -3 ) !== '.po' ) { 803 804 continue; 804 if ( ! preg_match( '/(?:(.+)-)?([A-Za-z_]{2,6}).po/', $file, $match ) ) 805 } 806 if ( ! preg_match( '/(?:(.+)-)?([A-Za-z_]{2,6}).po/', $file, $match ) ) { 805 807 continue; 808 } 809 if ( ! in_array( substr( $file, 0, -3 ) . '.mo', $files ) ) { 810 continue; 811 } 806 812 807 813 list( , $textdomain, $language ) = $match; 808 if ( '' === $textdomain ) 814 if ( '' === $textdomain ) { 809 815 $textdomain = 'default'; 816 } 810 817 $language_data[ $textdomain ][ $language ] = wp_get_pomo_file_data( WP_LANG_DIR . "$dir/$file" ); 811 818 }
Note: See TracChangeset
for help on using the changeset viewer.