Changeset 29856 for trunk/src/wp-admin/includes/plugin.php
- Timestamp:
- 10/08/2014 07:04:05 PM (10 years ago)
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.