| | 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 | |