Make WordPress Core

Ticket #14179: 23318-upgrade-header.diff

File 23318-upgrade-header.diff, 3.4 KB (added by meloniq, 10 years ago)

Adds optional "Upgrade" header for plugins and themes. New header defaults to 'true', when "Upgrade: false" is set, it excludes plugin/theme from checking for updates in WP API.

  • wp-admin/includes/plugin.php

     
    3232 * Network: Optional. Specify "Network: true" to require that a plugin is activated
    3333 *              across all sites in an installation. This will prevent a plugin from being
    3434 *              activated on a single site when Multisite is enabled.
     35 * Upgrade: Optional. Specify "Upgrade: false" to exclude plugin from checking for updates.
    3536 *  * / # Remove the space to close comment
    3637 * </code>
    3738 *
     
    4748 *              'TextDomain' - Plugin's text domain for localization.
    4849 *              'DomainPath' - Plugin's relative directory path to .mo files.
    4950 *              'Network' - Boolean. Whether the plugin can only be activated network wide.
     51 *              'Upgrade' - Boolean. Whether the plugin should be checked for updates on api.wordpress.org/plugins/update-check/
    5052 *
    5153 * Some users have issues with opening large files and manipulating the contents
    5254 * for want is usually the first 1kiB or 2kiB. This function stops pulling in
     
    8183                'TextDomain' => 'Text Domain',
    8284                'DomainPath' => 'Domain Path',
    8385                'Network' => 'Network',
     86                'Upgrade' => 'Upgrade',
    8487                // Site Wide Only is deprecated in favor of Network.
    8588                '_sitewide' => 'Site Wide Only',
    8689        );
     
    9598        $plugin_data['Network'] = ( 'true' == strtolower( $plugin_data['Network'] ) );
    9699        unset( $plugin_data['_sitewide'] );
    97100
     101        // verify and set boolean value Upgrade header
     102        $plugin_data['Upgrade'] = ( empty( $plugin_data['Upgrade'] ) || 'true' == strtolower( $plugin_data['Upgrade'] ) );
     103
    98104        if ( $markup || $translate ) {
    99105                $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate );
    100106        } else {
  • wp-includes/class-wp-theme.php

     
    2727                'Tags'        => 'Tags',
    2828                'TextDomain'  => 'Text Domain',
    2929                'DomainPath'  => 'Domain Path',
     30                'Upgrade'     => 'Upgrade',
    3031        );
    3132
    3233        /**
     
    239240                                if ( basename( $this->stylesheet ) != $default_theme_slug )
    240241                                        $this->headers['Name'] .= '/' . $this->stylesheet;
    241242                        }
     243                        // verify and set boolean value Upgrade header
     244                        $this->headers['Upgrade'] = ( empty( $this->headers['Upgrade'] ) || 'true' == strtolower( $this->headers['Upgrade'] ) );
    242245                }
    243246
    244247                // (If template is set from cache [and there are no errors], we know it's good.)
  • wp-includes/update.php

     
    223223                        }
    224224        }
    225225
     226        // filter out plugins that not allow updating
     227        foreach ( $plugins as $file => $p ) {
     228                if ( ! $p['Upgrade'] ) {
     229                        unset( $plugins[ $file ] );
     230                }
     231        }
     232
    226233        $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked );
    227234
    228235        if ( $time_not_changed && ! $extra_stats ) {
     
    355362        $request['active'] = get_option( 'stylesheet' );
    356363
    357364        foreach ( $installed_themes as $theme ) {
     365                // omit themes that not allow updating
     366                if ( ! $theme->get('Upgrade') ) {
     367                        continue;
     368                }
     369
    358370                $checked[ $theme->get_stylesheet() ] = $theme->get('Version');
    359371
    360372                $themes[ $theme->get_stylesheet() ] = array(