Make WordPress Core

Ticket #30945: class-wp-upgrader.diff

File class-wp-upgrader.diff, 1015 bytes (added by miyarakira, 10 years ago)

This enables plugin update into correct folder, for the first zip format

  • class-wp-upgrader.php

     
    405405                        $protected_directories = array_merge( $protected_directories, $wp_theme_directories );
    406406                }
    407407                if ( in_array( $destination, $protected_directories ) ) {
    408                         $remote_destination = trailingslashit( $remote_destination ) . trailingslashit( basename( $source ) );
    409                         $destination = trailingslashit( $destination ) . trailingslashit( basename( $source ) );
     408
     409                        if ( isset( $args['hook_extra']['plugin'] ) ) {
     410                                // Get the plugin top directory
     411                                $new_dest = current(explode(DIRECTORY_SEPARATOR, $args['hook_extra']['plugin']));
     412                        } else {
     413                                $new_dest = basename( $source );
     414                        }
     415
     416                        $remote_destination = trailingslashit( $remote_destination ) .trailingslashit( $new_dest );
     417                        $destination = trailingslashit( $destination ) . trailingslashit( $new_dest );
     418
    410419                }
    411420
    412421                if ( $clear_destination ) {