Making WordPress.org

Changeset 14503


Ignore:
Timestamp:
07/31/2025 03:56:58 AM (6 months ago)
Author:
dd32
Message:

Plugin Directory: Introduce an initial phased rollout mode.

This implements a single alternate rollout strategy for plugin updates: Delay automatic updates by 24 hours (for WordPess 6.6+)

This is:

  • Allows WordPress users to install the update manually in the first 24hrs.
  • WordPress 6.6+ is instructed not to perform an automatic update (ie. via cron).
  • Available only for plugins using Release Confirmation
  • No rollback to a previous release is available, change the readme.txt's Stable Tag field or release a new plugin version instead.
  • No feedback mechanisms are added beyond what currently exists (Support Forums)

See #8009.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-release-confirmation.php

    r14495 r14503  
    207207            'location' => wp_get_referer() ?: home_url( '/developers/releases/' ),
    208208        ];
     209
     210        $result['location'] = preg_replace(
     211            '/(#.+)?$/',
     212            '#releases-' . urlencode( $plugin->post_name ),
     213            $result['location']
     214        );
     215
    209216        header( 'Location: ' . $result['location'] );
    210217
     
    223230            $release['confirmed']      = true;
    224231            $result['fully_confirmed'] = true;
     232        }
     233
     234        // Store the release strategy if provided, overwriting any previous choice.
     235        if ( isset( $request['rollout_strategy'] ) ) {
     236            $release['rollout_strategy'] = wp_unslash( $request['rollout_strategy'] );
    225237        }
    226238
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php

    r14262 r14503  
    13701370        return $sorted;
    13711371    }
     1372
     1373    /**
     1374     * Get the available rollout strategies for plugin updates.
     1375     *
     1376     * @return array
     1377     */
     1378    static function get_rollout_strategies() {
     1379        return [
     1380            '' => [
     1381                'name' => __( 'Immediate (default)', 'wporg-plugins' ),
     1382                'description' => __( 'Plugin updates will be released to all sites as soon as they check for updates.', 'wporg-plugins' ),
     1383            ],
     1384            'manual-updates-24hr' => [
     1385                'name' => __( 'Manual updates only (24 hours)', 'wporg-plugins' ),
     1386                'description' => __( 'Plugin updates will be released to all sites, but automatic updates will be disabled for 24 hours. After that, sites will receive the update as normal.', 'wporg-plugins' ),
     1387            ],
     1388        ];
     1389    }
    13721390}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-release-confirmation.php

    r14499 r14503  
    176176                ),
    177177                self::get_actions( $plugin, $data ),
    178                 self::get_approval_text( $plugin, $data )
     178                self::get_approval_text( $plugin, $data ) .
     179                    self::get_rollout_strategy( $plugin, $data )
    179180            );
    180181        }
     
    342343    }
    343344
     345    /**
     346     * Display the Rollout Strategy options for a given plugin release.
     347     *
     348     * @param WP_Post $plugin The plugin post object.
     349     * @param array   $data   The release data.
     350     * @return string HTML for the rollout strategy options.
     351     */
     352    static function get_rollout_strategy( $plugin, $data ) {
     353        if ( ! current_user_can( 'plugin_manage_releases', $plugin ) ) {
     354            return '';
     355        }
     356
     357        if ( ! $data['confirmations_required'] || ! empty( $data['discarded'] ) ) {
     358            return '';
     359        }
     360
     361        $rollout = $data['rollout_strategy'] ?? '';
     362        if ( $data['confirmed'] && ! $rollout ) {
     363            // If the release is confirmed, but no rollout strategy was set for the release, don't display the UI.
     364            return '';
     365        }
     366
     367        ob_start();
     368        echo '<div class="release-strategy">';
     369        echo '<h3>' . __( 'Rollout Strategy', 'wporg-plugins' ) . '</h3>';
     370
     371        echo '<select
     372            id="rollout_strategy"
     373            name="rollout_strategy"
     374            onchange="this.nextElementSibling.innerText = this.options[this.selectedIndex].dataset.description;"'
     375            . disabled( $data['confirmed'], true, false ) .
     376            '>';
     377        foreach ( Template::get_rollout_strategies() as $slug => $set ) {
     378            printf(
     379                '<option value="%s" data-description="%s" %s>%s</option>',
     380                esc_attr( $slug ),
     381                esc_attr( $set['description'] ),
     382                selected( $rollout, $slug, false ),
     383                esc_html( $set['name'] )
     384            );
     385        }
     386        echo '</select>';
     387        echo '<div class="help">' . esc_html( Template::get_rollout_strategies()[ $rollout ]['description'] ?? '' ) . '</div>';
     388
     389        echo '</div>';
     390
     391        return ob_get_clean();
     392    }
     393
    344394    static function generate_access_url( $user = null ) {
    345395        return home_url( '/developers/releases/' );
Note: See TracChangeset for help on using the changeset viewer.