Changeset 13076 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-blueprint.php
- Timestamp:
- 12/21/2023 05:40:09 AM (9 months ago)
- 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 18 18 'methods' => array( \WP_REST_Server::READABLE, \WP_REST_Server::CREATABLE ), 19 19 'callback' => array( $this, 'blueprint' ), 20 // Note: the zip part of the endpoint is also public, since playground requests blueprints without cookie credentials 20 21 'permission_callback' => '__return_true', 21 22 'args' => array( … … 35 36 public function blueprint( $request ) { 36 37 $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 } 80 EOF; 81 header( 'Access-Control-Allow-Origin: https://playground.wordpress.net' ); 82 die( $zip_blueprint ); 83 } 84 } 85 } 37 86 38 87 $blueprints = get_post_meta( $plugin->ID, 'assets_blueprints', true );
Note: See TracChangeset
for help on using the changeset viewer.