<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[50921] trunk/src: Plugins: Add support for `Update URI` header.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/50921">50921</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/50921","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2021-05-17 17:02:49 +0000 (Mon, 17 May 2021)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Plugins: Add support for `Update URI` header.
This allows third-party plugins to avoid accidentally being overwritten with an update of a plugin of a similar name from the WordPress.org Plugin Directory.
Additionally, introduce the `update_plugins_{$hostname}` filter, which third-party plugins can use to offer updates for a given hostname.
If set, the `Update URI` header field should be a URI and have a unique hostname.
Some examples include:
* `https://wordpress.org/plugins/example-plugin/`
* `https://example.com/my-plugin/`
* `my-custom-plugin-name`
`Update URI: false` also works, and unless there is code handling the `false` hostname, the plugin will never get an update notification.
If the header is present, the WordPress.org API will currently only return updates for the plugin if it matches the following format:
* `https://wordpress.org/plugins/{$slug}/`
* `w.org/plugin/{$slug}`
If the header has any other value, the API will not return a result and will ignore the plugin for update purposes.
Props dd32, DavidAnderson, meloniq, markjaquith, DrewAPicture, mweichert, design_dolphin, filosofo, sean212, nhuja, JeroenReumkens, infolu, dingdang, joyously, earnjam, williampatton, grapplerulrich, markparnell, apedog, afragen, miqrogroove, rmccue, crazycoders, jdgrimes, damonganto, joostdevalk, jorbin, georgestephanis, khromov, GeekStreetWP, jb510, Rarst, juliobox, Ipstenu, mikejolley, Otto42, gMagicScott, TJNowell, GaryJ, knutsp, mordauk, nvartolomei, aspexi, chriscct7, benoitchantre, ryno267, lev0, gregorlove, dougwollison, SergeyBiryukov.
See <a href="https://core.trac.wordpress.org/ticket/14179">#14179</a>, <a href="https://core.trac.wordpress.org/ticket/23318">#23318</a>, <a href="https://core.trac.wordpress.org/ticket/32101">#32101</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesclasswpplugininstalllisttablephp">trunk/src/wp-admin/includes/class-wp-plugin-install-list-table.php</a></li>
<li><a href="#trunksrcwpadminincludespluginphp">trunk/src/wp-admin/includes/plugin.php</a></li>
<li><a href="#trunksrcwpadminincludesupdatephp">trunk/src/wp-admin/includes/update.php</a></li>
<li><a href="#trunksrcwpincludesupdatephp">trunk/src/wp-includes/update.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludesclasswpplugininstalllisttablephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/class-wp-plugin-install-list-table.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/class-wp-plugin-install-list-table.php 2021-05-17 15:06:27 UTC (rev 50920)
+++ trunk/src/wp-admin/includes/class-wp-plugin-install-list-table.php 2021-05-17 17:02:49 UTC (rev 50921)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -47,15 +47,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $plugin_info = get_site_transient( 'update_plugins' );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $plugin_info->no_update ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $plugin_info->no_update as $plugin ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $plugin->upgrade = false;
- $plugins[ $plugin->slug ] = $plugin;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isset( $plugin->slug ) ) {
+ $plugin->upgrade = false;
+ $plugins[ $plugin->slug ] = $plugin;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $plugin_info->response ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $plugin_info->response as $plugin ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $plugin->upgrade = true;
- $plugins[ $plugin->slug ] = $plugin;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isset( $plugin->slug ) ) {
+ $plugin->upgrade = true;
+ $plugins[ $plugin->slug ] = $plugin;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpadminincludespluginphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/plugin.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/plugin.php 2021-05-17 15:06:27 UTC (rev 50920)
+++ trunk/src/wp-admin/includes/plugin.php 2021-05-17 17:02:49 UTC (rev 50921)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -44,6 +44,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 1.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.3.0 Added support for `Requires at least` and `Requires PHP` headers.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.8.0 Added support for `Update URI` header.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $plugin_file Absolute path to the main plugin file.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param bool $markup Optional. If the returned data should have HTML markup applied.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -63,6 +64,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @type bool $Network Whether the plugin can only be activated network-wide.
</span><span class="cx" style="display: block; padding: 0 10px"> * @type string $RequiresWP Minimum required version of WordPress.
</span><span class="cx" style="display: block; padding: 0 10px"> * @type string $RequiresPHP Minimum required version of PHP.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @type string $UpdateURI ID of the plugin for update purposes, should be a URI.
</ins><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function get_plugin_data( $plugin_file, $markup = true, $translate = true ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -79,6 +81,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'Network' => 'Network',
</span><span class="cx" style="display: block; padding: 0 10px"> 'RequiresWP' => 'Requires at least',
</span><span class="cx" style="display: block; padding: 0 10px"> 'RequiresPHP' => 'Requires PHP',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'UpdateURI' => 'Update URI',
</ins><span class="cx" style="display: block; padding: 0 10px"> // Site Wide Only is deprecated in favor of Network.
</span><span class="cx" style="display: block; padding: 0 10px"> '_sitewide' => 'Site Wide Only',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span></span></pre></div>
<a id="trunksrcwpadminincludesupdatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/update.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/update.php 2021-05-17 15:06:27 UTC (rev 50920)
+++ trunk/src/wp-admin/includes/update.php 2021-05-17 17:02:49 UTC (rev 50921)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -435,8 +435,25 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $response->slug . '§ion=changelog&TB_iframe=true&width=600&height=800' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $plugin_slug = isset( $response->slug ) ? $response->slug : $response->id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isset( $response->slug ) ) {
+ $details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_slug . '§ion=changelog' );
+ } elseif ( isset( $response->url ) ) {
+ $details_url = $response->url;
+ } else {
+ $details_url = $plugin_data['PluginURI'];
+ }
+
+ $details_url = add_query_arg(
+ array(
+ 'TB_iframe' => 'true',
+ 'width' => 600,
+ 'height' => 800,
+ ),
+ $details_url
+ );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /** @var WP_Plugins_List_Table $wp_list_table */
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_list_table = _get_list_table(
</span><span class="cx" style="display: block; padding: 0 10px"> 'WP_Plugins_List_Table',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -461,8 +478,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> '<td colspan="%s" class="plugin-update colspanchange">' .
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class="update-message notice inline %s notice-alt"><p>',
</span><span class="cx" style="display: block; padding: 0 10px"> $active_class,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- esc_attr( $response->slug . '-update' ),
- esc_attr( $response->slug ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ esc_attr( $plugin_slug . '-update' ),
+ esc_attr( $plugin_slug ),
</ins><span class="cx" style="display: block; padding: 0 10px"> esc_attr( $file ),
</span><span class="cx" style="display: block; padding: 0 10px"> esc_attr( $wp_list_table->get_column_count() ),
</span><span class="cx" style="display: block; padding: 0 10px"> $notice_type
</span></span></pre></div>
<a id="trunksrcwpincludesupdatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/update.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/update.php 2021-05-17 15:06:27 UTC (rev 50920)
+++ trunk/src/wp-includes/update.php 2021-05-17 17:02:49 UTC (rev 50921)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -296,8 +296,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $current = new stdClass;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $new_option = new stdClass;
- $new_option->last_checked = time();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $updates = new stdClass;
+ $updates->last_checked = time();
+ $updates->response = array();
+ $updates->translations = array();
+ $updates->no_update = array();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $doing_cron = wp_doing_cron();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -327,7 +330,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $plugin_changed = false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $plugins as $file => $p ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $new_option->checked[ $file ] = $p['Version'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $updates->checked[ $file ] = $p['Version'];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! isset( $current->checked[ $file ] ) || (string) $current->checked[ $file ] !== (string) $p['Version'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $plugin_changed = true;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -418,38 +421,114 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = json_decode( wp_remote_retrieve_body( $raw_response ), true );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $response['plugins'] as &$plugin ) {
- $plugin = (object) $plugin;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $response && is_array( $response ) ) {
+ $updates->response = $response['plugins'];
+ $updates->translations = $response['translations'];
+ $updates->no_update = $response['no_update'];
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( isset( $plugin->compatibility ) ) {
- $plugin->compatibility = (object) $plugin->compatibility;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Support updates for any plugins using the `Update URI` header field.
+ foreach ( $plugins as $plugin_file => $plugin_data ) {
+ if ( ! $plugin_data['UpdateURI'] || isset( $updates->response[ $plugin_file ] ) ) {
+ continue;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $plugin->compatibility as &$data ) {
- $data = (object) $data;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hostname = wp_parse_url( esc_url_raw( $plugin_data['UpdateURI'] ), PHP_URL_HOST );
+
+ /**
+ * Filters the update response for a given plugin hostname.
+ *
+ * The dynamic portion of the hook name, `$hostname`, refers to the hostname
+ * of the URI specified in the `Update URI` header field.
+ *
+ * @since 5.8.0
+ *
+ * @param array|false $update {
+ * The plugin update data with the latest details. Default false.
+ *
+ * @type string $id Optional. ID of the plugin for update purposes, should be a URI
+ * specified in the `Update URI` header field.
+ * @type string $slug Slug of the plugin.
+ * @type string $version The version of the plugin.
+ * @type string $url The URL for details of the plugin.
+ * @type string $package Optional. The update ZIP for the plugin.
+ * @type string $tested Optional. The version of WordPress the plugin is tested against.
+ * @type string $requires_php Optional. The version of PHP which the plugin requires.
+ * @type bool $autoupdate Optional. Whether the plugin should automatically update.
+ * @type array $icons Optional. Array of plugin icons.
+ * @type array $banners Optional. Array of plugin banners.
+ * @type array $banners_rtl Optional. Array of plugin RTL banners.
+ * @type array $translations {
+ * Optional. List of translation updates for the plugin.
+ *
+ * @type string $language The language the translation update is for.
+ * @type string $version The version of the plugin this translation is for.
+ * This is not the version of the language file.
+ * @type string $updated The update timestamp of the translation file.
+ * Should be a date in the `YYYY-MM-DD HH:MM:SS` format.
+ * @type string $package The ZIP location containing the translation update.
+ * @type string $autoupdate Whether the translation should be automatically installed.
+ * }
+ * }
+ * @param array $plugin_data Plugin headers.
+ * @param string $plugin_file Plugin filename.
+ * @param array $locales Installed locales to look translations for.
+ */
+ $update = apply_filters( "update_plugins_{$hostname}", false, $plugin_data, $plugin_file, $locales );
+
+ if ( ! $update ) {
+ continue;
+ }
+
+ $update = (object) $update;
+
+ // Is it valid? We require at least a version.
+ if ( ! isset( $update->version ) ) {
+ continue;
+ }
+
+ // These should remain constant.
+ $update->id = $plugin_data['UpdateURI'];
+ $update->plugin = $plugin_file;
+
+ // WordPress needs the version field specified as 'new_version'.
+ if ( ! isset( $update->new_version ) ) {
+ $update->new_version = $update->version;
+ }
+
+ // Handle any translation updates.
+ if ( ! empty( $update->translations ) ) {
+ foreach ( $update->translations as $translation ) {
+ if ( isset( $translation['language'], $translation['package'] ) ) {
+ $translation['type'] = 'plugin';
+ $translation['slug'] = isset( $update->slug ) ? $update->slug : $update->id;
+
+ $updates->translations[] = $translation;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- }
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- unset( $plugin, $data );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unset( $updates->no_update[ $plugin_file ], $updates->response[ $plugin_file ] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $response['no_update'] as &$plugin ) {
- $plugin = (object) $plugin;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( version_compare( $update->new_version, $plugin_data['Version'], '>' ) ) {
+ $updates->response[ $plugin_file ] = $update;
+ } else {
+ $updates->no_update[ $plugin_file ] = $update;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- unset( $plugin );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $sanitize_plugin_update_payload = function( &$item ) {
+ $item = (object) $item;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( is_array( $response ) ) {
- $new_option->response = $response['plugins'];
- $new_option->translations = $response['translations'];
- // TODO: Perhaps better to store no_update in a separate transient with an expiry?
- $new_option->no_update = $response['no_update'];
- } else {
- $new_option->response = array();
- $new_option->translations = array();
- $new_option->no_update = array();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unset( $item->translations, $item->compatibility );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- set_site_transient( 'update_plugins', $new_option );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $item;
+ };
+
+ array_walk( $updates->response, $sanitize_plugin_update_payload );
+ array_walk( $updates->no_update, $sanitize_plugin_update_payload );
+
+ set_site_transient( 'update_plugins', $updates );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre>
</div>
</div>
</body>
</html>