Making WordPress.org


Ignore:
Timestamp:
09/04/2025 04:46:46 AM (3 months ago)
Author:
dd32
Message:

Theme Directory: Upgrade the blueprint used for Theme Review live previews.

This removes the blueprint from being static in the trac ticket, allowing for future maintenance not to break older links.

Fixes #8077.
Merges https://github.com/WordPress/wordpress.org/pull/506.
See https://github.com/WordPress/wordpress-playground/issues/2548.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/class-wporg-themes-upload.php

    r14512 r14523  
    11601160        $theme_zip_link = "https://downloads.wordpress.org/theme/{$this->theme_slug}.{$this->theme->display( 'Version' )}.zip?nostats=1";
    11611161
    1162         // Build the Live Preview Blueprint & URL.
    1163          $blueprint_parent_step = '';
    1164          if (
    1165             $this->theme->parent() &&
    1166             in_array( 'buddypress', $this->theme->get( 'Tags' ) )
    1167         ) {
    1168             $blueprint_parent_step = <<<BLUEPRINT_PARENT_BP
    1169             {
    1170                 "step": "installPlugin",
    1171                 "pluginZipFile": {
    1172                     "resource": "wordpress.org/plugins",
    1173                     "slug": "buddypress"
    1174                 },
    1175                 "options": {
    1176                     "activate": true
    1177                 }
    1178             },
    1179             BLUEPRINT_PARENT_BP;
    1180         } elseif ( $this->theme->parent() ) {
    1181             $blueprint_parent_step = <<<BLUEPRINT_PARENT_THEME
    1182             {
    1183                 "step": "installTheme",
    1184                 "themeZipFile": {
    1185                     "resource": "wordpress.org/themes",
    1186                     "slug": "{$this->theme->get_template()}"
    1187                 }
    1188             },
    1189             BLUEPRINT_PARENT_THEME;
    1190         }
    1191 
    1192         // NOTE: The username + password included below are only used for the local in-browser environment, and are not a secret.
    1193         $blueprint = <<<BLUEPRINT
    1194         {
    1195             "preferredVersions": {
    1196                 "php": "7.4",
    1197                 "wp": "latest"
    1198             },
    1199             "steps": [
    1200                 {
    1201                     "step": "login",
    1202                     "username": "admin",
    1203                     "password": "password"
    1204                 },
    1205                 {
    1206                     "step": "defineWpConfigConsts",
    1207                     "consts": {
    1208                         "WP_DEBUG": true
    1209                     }
    1210                 },
    1211                 {
    1212                     "step": "importFile",
    1213                     "file": {
    1214                         "resource": "url",
    1215                         "url": "https://raw.githubusercontent.com/WordPress/theme-test-data/master/themeunittestdata.wordpress.xml",
    1216                         "caption": "Downloading theme testing content"
    1217                     },
    1218                     "progress": {
    1219                         "caption": "Installing theme testing content"
    1220                     }
    1221                 },
    1222                 {
    1223                     "step": "installPlugin",
    1224                     "pluginZipFile": {
    1225                         "resource": "wordpress.org/plugins",
    1226                         "slug": "theme-check"
    1227                     },
    1228                     "options": {
    1229                         "activate": true
    1230                     }
    1231                 },
    1232                 {$blueprint_parent_step}
    1233                 {
    1234                     "step": "installTheme",
    1235                     "themeZipFile": {
    1236                         "resource": "url",
    1237                         "url": "{$theme_zip_link}",
    1238                         "caption": "Downloading the theme"
    1239                     }
    1240                 }
    1241             ]
    1242         }
    1243         BLUEPRINT;
    1244 
    1245         // NOTE: The json_encode( json_decode() ) is to remove the whitespaces used above for readability.
    1246         $live_preview_link = 'https://playground.wordpress.net/#' . json_encode( json_decode( $blueprint ) );
     1162        $live_preview_link = add_query_arg(
     1163            'blueprint-url',
     1164            urlencode( rest_url( 'themes/v1/review-blueprint/' . $this->theme_post->ID . '-' . $this->theme_slug . '/' . $this->theme->display( 'Version' ) ) ),
     1165            'https://playground.wordpress.net/'
     1166        );
    12471167
    12481168        // Hacky way to prevent a problem with xml-rpc.
Note: See TracChangeset for help on using the changeset viewer.