WordPress.org

Make WordPress Core

Ticket #23318: update-service.diff

File update-service.diff, 1.9 KB (added by DavidAnderson, 5 years ago)

This patch 1) implements an "Update Service:" header, which defaults to "wordpressorg" if not present, and 2) excludes plugins whose "Update Service" is not set to wordpressorg from the call to api.wordpress.org. This minimally invasive approach provides a way for 3rd party plugin authors to prevent their plugins being unexpectedly replaced (see #28660), whilst leaving options open for future directions, and for how other plugins (e.g. ones like the WooThemes updates helper) might want to interpret the header.

  • wp-admin/includes/plugin.php

     
    4747 *              'TextDomain' - Plugin's text domain for localization.
    4848 *              'DomainPath' - Plugin's relative directory path to .mo files.
    4949 *              'Network' - Boolean. Whether the plugin can only be activated network wide.
     50 *              'UpdateService' - String. Indicates which update service should be used to obtain plugin information. Defaults to wordpressorg (which is the only one handled natively by WordPress core).
    5051 *
    5152 * Some users have issues with opening large files and manipulating the contents
    5253 * for want is usually the first 1kiB or 2kiB. This function stops pulling in
     
    8182                'TextDomain' => 'Text Domain',
    8283                'DomainPath' => 'Domain Path',
    8384                'Network' => 'Network',
     85                'UpdateService' => 'Update Service',
    8486                // Site Wide Only is deprecated in favor of Network.
    8587                '_sitewide' => 'Site Wide Only',
    8688        );
     
    9395                $plugin_data['Network'] = $plugin_data['_sitewide'];
    9496        }
    9597        $plugin_data['Network'] = ( 'true' == strtolower( $plugin_data['Network'] ) );
     98        if ( empty( $plugin_data['UpdateService'] ) )
     99                $plugin_data['UpdateService'] = 'wordpressorg';
    96100        unset( $plugin_data['_sitewide'] );
    97101
    98102        if ( $markup || $translate ) {
  • wp-includes/update.php

     
    228228        if ( $time_not_changed && ! $extra_stats ) {
    229229                $plugin_changed = false;
    230230                foreach ( $plugins as $file => $p ) {
     231                        if ( 'wordpressorg' != $p['UpdateService'] ) {
     232                                unset( $plugins[ $file ] );
     233                                continue;
     234                        }
     235
    231236                        $new_option->checked[ $file ] = $p['Version'];
    232237
    233238                        if ( !isset( $current->checked[ $file ] ) || strval($current->checked[ $file ]) !== strval($p['Version']) )