Changeset 50921
- Timestamp:
- 05/17/2021 05:02:49 PM (3 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-plugin-install-list-table.php
r50808 r50921 48 48 if ( isset( $plugin_info->no_update ) ) { 49 49 foreach ( $plugin_info->no_update as $plugin ) { 50 $plugin->upgrade = false; 51 $plugins[ $plugin->slug ] = $plugin; 50 if ( isset( $plugin->slug ) ) { 51 $plugin->upgrade = false; 52 $plugins[ $plugin->slug ] = $plugin; 53 } 52 54 } 53 55 } … … 55 57 if ( isset( $plugin_info->response ) ) { 56 58 foreach ( $plugin_info->response as $plugin ) { 57 $plugin->upgrade = true; 58 $plugins[ $plugin->slug ] = $plugin; 59 if ( isset( $plugin->slug ) ) { 60 $plugin->upgrade = true; 61 $plugins[ $plugin->slug ] = $plugin; 62 } 59 63 } 60 64 } -
trunk/src/wp-admin/includes/plugin.php
r50788 r50921 45 45 * @since 1.5.0 46 46 * @since 5.3.0 Added support for `Requires at least` and `Requires PHP` headers. 47 * @since 5.8.0 Added support for `Update URI` header. 47 48 * 48 49 * @param string $plugin_file Absolute path to the main plugin file. … … 64 65 * @type string $RequiresWP Minimum required version of WordPress. 65 66 * @type string $RequiresPHP Minimum required version of PHP. 67 * @type string $UpdateURI ID of the plugin for update purposes, should be a URI. 66 68 * } 67 69 */ … … 80 82 'RequiresWP' => 'Requires at least', 81 83 'RequiresPHP' => 'Requires PHP', 84 'UpdateURI' => 'Update URI', 82 85 // Site Wide Only is deprecated in favor of Network. 83 86 '_sitewide' => 'Site Wide Only', -
trunk/src/wp-admin/includes/update.php
r50121 r50921 436 436 437 437 $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags ); 438 $details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $response->slug . '§ion=changelog&TB_iframe=true&width=600&height=800' ); 438 $plugin_slug = isset( $response->slug ) ? $response->slug : $response->id; 439 440 if ( isset( $response->slug ) ) { 441 $details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_slug . '§ion=changelog' ); 442 } elseif ( isset( $response->url ) ) { 443 $details_url = $response->url; 444 } else { 445 $details_url = $plugin_data['PluginURI']; 446 } 447 448 $details_url = add_query_arg( 449 array( 450 'TB_iframe' => 'true', 451 'width' => 600, 452 'height' => 800, 453 ), 454 $details_url 455 ); 439 456 440 457 /** @var WP_Plugins_List_Table $wp_list_table */ … … 462 479 '<div class="update-message notice inline %s notice-alt"><p>', 463 480 $active_class, 464 esc_attr( $ response->slug . '-update' ),465 esc_attr( $ response->slug ),481 esc_attr( $plugin_slug . '-update' ), 482 esc_attr( $plugin_slug ), 466 483 esc_attr( $file ), 467 484 esc_attr( $wp_list_table->get_column_count() ), -
trunk/src/wp-includes/update.php
r50082 r50921 297 297 } 298 298 299 $new_option = new stdClass; 300 $new_option->last_checked = time(); 299 $updates = new stdClass; 300 $updates->last_checked = time(); 301 $updates->response = array(); 302 $updates->translations = array(); 303 $updates->no_update = array(); 301 304 302 305 $doing_cron = wp_doing_cron(); … … 328 331 329 332 foreach ( $plugins as $file => $p ) { 330 $ new_option->checked[ $file ] = $p['Version'];333 $updates->checked[ $file ] = $p['Version']; 331 334 332 335 if ( ! isset( $current->checked[ $file ] ) || (string) $current->checked[ $file ] !== (string) $p['Version'] ) { … … 419 422 $response = json_decode( wp_remote_retrieve_body( $raw_response ), true ); 420 423 421 foreach ( $response['plugins'] as &$plugin ) { 422 $plugin = (object) $plugin; 423 424 if ( isset( $plugin->compatibility ) ) { 425 $plugin->compatibility = (object) $plugin->compatibility; 426 427 foreach ( $plugin->compatibility as &$data ) { 428 $data = (object) $data; 424 if ( $response && is_array( $response ) ) { 425 $updates->response = $response['plugins']; 426 $updates->translations = $response['translations']; 427 $updates->no_update = $response['no_update']; 428 } 429 430 // Support updates for any plugins using the `Update URI` header field. 431 foreach ( $plugins as $plugin_file => $plugin_data ) { 432 if ( ! $plugin_data['UpdateURI'] || isset( $updates->response[ $plugin_file ] ) ) { 433 continue; 434 } 435 436 $hostname = wp_parse_url( esc_url_raw( $plugin_data['UpdateURI'] ), PHP_URL_HOST ); 437 438 /** 439 * Filters the update response for a given plugin hostname. 440 * 441 * The dynamic portion of the hook name, `$hostname`, refers to the hostname 442 * of the URI specified in the `Update URI` header field. 443 * 444 * @since 5.8.0 445 * 446 * @param array|false $update { 447 * The plugin update data with the latest details. Default false. 448 * 449 * @type string $id Optional. ID of the plugin for update purposes, should be a URI 450 * specified in the `Update URI` header field. 451 * @type string $slug Slug of the plugin. 452 * @type string $version The version of the plugin. 453 * @type string $url The URL for details of the plugin. 454 * @type string $package Optional. The update ZIP for the plugin. 455 * @type string $tested Optional. The version of WordPress the plugin is tested against. 456 * @type string $requires_php Optional. The version of PHP which the plugin requires. 457 * @type bool $autoupdate Optional. Whether the plugin should automatically update. 458 * @type array $icons Optional. Array of plugin icons. 459 * @type array $banners Optional. Array of plugin banners. 460 * @type array $banners_rtl Optional. Array of plugin RTL banners. 461 * @type array $translations { 462 * Optional. List of translation updates for the plugin. 463 * 464 * @type string $language The language the translation update is for. 465 * @type string $version The version of the plugin this translation is for. 466 * This is not the version of the language file. 467 * @type string $updated The update timestamp of the translation file. 468 * Should be a date in the `YYYY-MM-DD HH:MM:SS` format. 469 * @type string $package The ZIP location containing the translation update. 470 * @type string $autoupdate Whether the translation should be automatically installed. 471 * } 472 * } 473 * @param array $plugin_data Plugin headers. 474 * @param string $plugin_file Plugin filename. 475 * @param array $locales Installed locales to look translations for. 476 */ 477 $update = apply_filters( "update_plugins_{$hostname}", false, $plugin_data, $plugin_file, $locales ); 478 479 if ( ! $update ) { 480 continue; 481 } 482 483 $update = (object) $update; 484 485 // Is it valid? We require at least a version. 486 if ( ! isset( $update->version ) ) { 487 continue; 488 } 489 490 // These should remain constant. 491 $update->id = $plugin_data['UpdateURI']; 492 $update->plugin = $plugin_file; 493 494 // WordPress needs the version field specified as 'new_version'. 495 if ( ! isset( $update->new_version ) ) { 496 $update->new_version = $update->version; 497 } 498 499 // Handle any translation updates. 500 if ( ! empty( $update->translations ) ) { 501 foreach ( $update->translations as $translation ) { 502 if ( isset( $translation['language'], $translation['package'] ) ) { 503 $translation['type'] = 'plugin'; 504 $translation['slug'] = isset( $update->slug ) ? $update->slug : $update->id; 505 506 $updates->translations[] = $translation; 507 } 429 508 } 430 509 } 431 } 432 433 unset( $plugin, $data ); 434 435 foreach ( $response['no_update'] as &$plugin ) {436 $plugin = (object) $plugin;437 }438 439 unset( $plugin );440 441 if ( is_array( $response )) {442 $ new_option->response = $response['plugins'];443 $new_option->translations = $response['translations']; 444 // TODO: Perhaps better to store no_update in a separate transient with an expiry?445 $new_option->no_update = $response['no_update']; 446 } else {447 $new_option->response = array();448 $new_option->translations = array(); 449 $new_option->no_update = array();450 }451 452 set_site_transient( 'update_plugins', $ new_option);510 511 unset( $updates->no_update[ $plugin_file ], $updates->response[ $plugin_file ] ); 512 513 if ( version_compare( $update->new_version, $plugin_data['Version'], '>' ) ) { 514 $updates->response[ $plugin_file ] = $update; 515 } else { 516 $updates->no_update[ $plugin_file ] = $update; 517 } 518 } 519 520 $sanitize_plugin_update_payload = function( &$item ) { 521 $item = (object) $item; 522 523 unset( $item->translations, $item->compatibility ); 524 525 return $item; 526 }; 527 528 array_walk( $updates->response, $sanitize_plugin_update_payload ); 529 array_walk( $updates->no_update, $sanitize_plugin_update_payload ); 530 531 set_site_transient( 'update_plugins', $updates ); 453 532 } 454 533
Note: See TracChangeset
for help on using the changeset viewer.