Making WordPress.org


Ignore:
Timestamp:
12/21/2023 05:40:09 AM (9 months ago)
Author:
tellyworth
Message:

Plugin Dir: Add Preview links for moderators in plugin queue

This adds private Playground Preview links for the plugin review team to more easily test newly submitted plugins that have not yet been published.

Plugins are loaded with plugin-check active.

See #7380.

File:
1 edited

Legend:

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

    r13019 r13076  
    1818            'methods'             => array( \WP_REST_Server::READABLE, \WP_REST_Server::CREATABLE ),
    1919            'callback'            => array( $this, 'blueprint' ),
     20            // Note: the zip part of the endpoint is also public, since playground requests blueprints without cookie credentials
    2021            'permission_callback' => '__return_true',
    2122            'args'                => array(
     
    3536    public function blueprint( $request ) {
    3637        $plugin = Plugin_Directory::get_plugin_post( $request['plugin_slug'] );
     38
     39        // Direct zip preview for plugin reviewers
     40        if ( $request->get_param('zip_hash') ) {
     41            foreach ( get_attached_media( 'application/zip', $plugin ) as $zip_file ) {
     42                if ( hash_equals( Template::preview_link_hash( $zip_file->ID, 0 ), $request->get_param('zip_hash') ) ||
     43                     hash_equals( Template::preview_link_hash( $zip_file->ID, -1 ), $request->get_param('zip_hash') ) ) {
     44                    $zip_url = wp_get_attachment_url( $zip_file->ID );
     45                    $zip_blueprint =<<<EOF
     46{
     47    "landingPage": "/wp-admin/plugins.php",
     48    "preferredVersions": {
     49        "php": "8.0",
     50        "wp": "latest"
     51    },
     52    "phpExtensionBundles": [
     53        "kitchen-sink"
     54    ],
     55    "features": {
     56        "networking": true
     57    },
     58    "steps": [
     59        {
     60            "step": "installPlugin",
     61            "pluginZipFile": {
     62                "resource": "wordpress.org/plugins",
     63                "slug": "plugin-check"
     64            }
     65        },
     66        {
     67            "step": "installPlugin",
     68            "pluginZipFile": {
     69                "resource": "url",
     70                "url": "$zip_url"
     71            }
     72        },
     73        {
     74            "step": "login",
     75            "username": "admin",
     76            "password": "password"
     77        }
     78    ]
     79}
     80EOF;
     81                    header( 'Access-Control-Allow-Origin: https://playground.wordpress.net' );
     82                    die( $zip_blueprint );
     83                }
     84            }
     85        }
    3786
    3887        $blueprints = get_post_meta( $plugin->ID, 'assets_blueprints', true );
Note: See TracChangeset for help on using the changeset viewer.