Make WordPress Core

Ticket #30465: 30465.diff

File 30465.diff, 3.5 KB (added by valendesigns, 10 years ago)
  • src/wp-admin/includes/update.php

    diff --git src/wp-admin/includes/update.php src/wp-admin/includes/update.php
    index 502666a..ffba47c 100644
    function update_nag() { 
    214214add_action( 'admin_notices', 'update_nag', 3 );
    215215add_action( 'network_admin_notices', 'update_nag', 3 );
    216216
     217function removed_plugin_nag() {
     218        global $pagenow;
     219
     220        if ( ! current_user_can( 'update_plugins' ) || 'update-core.php' == $pagenow )
     221                return;
     222
     223        $active  = get_option( 'active_plugins', array() );
     224        $directory_plugins = get_option( 'directory_plugins' );
     225
     226        if ( ! isset( $directory_plugins['removed'] ) || empty( $directory_plugins['removed'] ) )
     227                return false;
     228
     229        foreach( $active as $plugin_file ) {
     230                if ( isset( $directory_plugins['removed'][$plugin_file]['name'] ) )
     231                        echo '<div class="update-nag">' . sprintf( __( 'The %s plugin has been removed from the WordPress Directory.' ), '<strong>' . $directory_plugins['removed'][$plugin_file]['name'] . '</strong>' ) . '</div>';
     232        }
     233}
     234add_action( 'admin_notices', 'removed_plugin_nag', 3 );
     235add_action( 'network_admin_notices', 'removed_plugin_nag', 3 );
     236
    217237// Called directly from dashboard
    218238function update_right_now_message() {
    219239        $theme_name = wp_get_theme();
  • src/wp-includes/update.php

    diff --git src/wp-includes/update.php src/wp-includes/update.php
    index 597a020..ad89787 100644
    function wp_update_plugins( $extra_stats = array() ) { 
    248248                        return false;
    249249        }
    250250
     251        // Keeps this code from executing when called from `wp_admin_bar_updates_menu()`.
     252        $trace = debug_backtrace();
     253        if ( ! isset( $trace[2]['function'] ) || $trace[2]['function'] != 'wp_admin_bar_updates_menu' ) {
     254
     255                $directory_plugins = get_option( 'directory_plugins', array() );
     256
     257                // Check for deleted plugins in the WordPress Respository.
     258                foreach( $active as $plugin_file ) {
     259
     260                        $url = 'http://api.wordpress.org/plugins/info/1.0/' . $plugin_file;
     261                        if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
     262                                $url = set_url_scheme( $url, 'https' );
     263
     264                        // Check the Plugin repo for plugin information
     265                        $raw_response = wp_remote_post( $url, array(
     266                                'timeout' => 3,
     267                                'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
     268                        ) );
     269
     270                        // Check for valid response
     271                        if ( ! is_wp_error( $raw_response ) && 200 == wp_remote_retrieve_response_code( $raw_response ) ) {
     272
     273                                // Setup response data
     274                                $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) );
     275
     276                                $found = isset( $directory_plugins['found'] ) && array_key_exists( $plugin_file, $directory_plugins['found'] );
     277                                $removed = isset( $directory_plugins['removed'] ) && array_key_exists( $plugin_file, $directory_plugins['removed'] );
     278
     279                                // Add plugins to the `found` array that exist in the Directory.
     280                                if ( ! $found && isset( $response->slug ) ) {
     281                                        $directory_plugins['found'][$plugin_file]['name'] = $response->name;
     282                                        $found = true;
     283                                }
     284
     285                                // Add plugins to the `removed` array that no longer exist in the Directory.
     286                                if ( $found && ! $removed && $raw_response['body'] == 'N;' ) {
     287                                        $directory_plugins['removed'][$plugin_file]['name'] = $directory_plugins['found'][$plugin_file]['name'];
     288                                }
     289
     290                        }
     291               
     292                }
     293
     294                update_option( 'directory_plugins', $directory_plugins );
     295
     296        }
     297 
    251298        // Update last_checked for current to prevent multiple blocking requests if request hangs
    252299        $current->last_checked = time();
    253300        set_site_transient( 'update_plugins', $current );