Changeset 13088
- Timestamp:
- 01/02/2024 02:44:07 AM (9 months ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-plugin-posts.php
r13076 r13088 712 712 713 713 printf( 714 '<a href="%1$s">%2$s</a><br>%3$s<br>(<a href="%4$s" target="_blank">preview</a> )</li>',714 '<a href="%1$s">%2$s</a><br>%3$s<br>(<a href="%4$s" target="_blank">preview</a> | <a href="%5$s" target="_blank">pcp</a>)</li>', 715 715 esc_url( $url ), 716 716 esc_html( $name ), 717 717 esc_html( $zip_size ), 718 esc_url( Template::preview_link_zip( $post->post_name, $zip_file->ID ) ) 718 esc_url( Template::preview_link_zip( $post->post_name, $zip_file->ID ) ), 719 esc_url( Template::preview_link_zip( $post->post_name, $zip_file->ID, 'pcp' ) ) 719 720 ); 720 721 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-review-tools.php
r13076 r13088 129 129 $zip_size = size_format( filesize( get_attached_file( $zip_file->ID ) ), 1 ); 130 130 $zip_preview = Template::preview_link_zip( $slug, $zip_file->ID ); 131 $zip_pcp = Template::preview_link_zip( $slug, $zip_file->ID, 'pcp' ); 131 132 132 133 printf( 133 '<li>%1$s <a href="%2$s">%3$s</a> (%4$s) (<a href="%5$s" target="_blank">preview</a> )</li>',134 '<li>%1$s <a href="%2$s">%3$s</a> (%4$s) (<a href="%5$s" target="_blank">preview</a> | <a href="%6$s" target="_blank">pcp</a>)</li>', 134 135 esc_html( $zip_date ), 135 136 esc_url( $zip_url ), 136 137 esc_html( basename( $zip_url ) ), 137 138 esc_html( $zip_size ), 138 esc_url( $zip_preview ) 139 esc_url( $zip_preview ), 140 esc_url( $zip_pcp ) 139 141 ); 140 142 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-blueprint.php
r13076 r13088 37 37 $plugin = Plugin_Directory::get_plugin_post( $request['plugin_slug'] ); 38 38 39 // Direct zip preview for plugin reviewers40 39 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 } 40 $this->reviewer_blueprint( $request, $plugin ); 85 41 } 86 42 … … 102 58 } 103 59 60 function reviewer_blueprint( $request, $plugin ) { 61 // Direct zip preview for plugin reviewers 62 if ( $request->get_param('zip_hash') ) { 63 foreach ( get_attached_media( 'application/zip', $plugin ) as $zip_file ) { 64 if ( hash_equals( Template::preview_link_hash( $zip_file->ID, 0 ), $request->get_param('zip_hash') ) || 65 hash_equals( Template::preview_link_hash( $zip_file->ID, -1 ), $request->get_param('zip_hash') ) ) { 66 $zip_url = wp_get_attachment_url( $zip_file->ID ); 67 if ( $zip_url ) { 68 69 $landing_page = '/wp-admin/plugins.php'; 70 $activate_plugin = true; 71 72 // Plugin deactivated, and land on the Plugin Check page 73 if ( 'pcp' === $request->get_param('type') ) { 74 $landing_page = '/wp-admin/admin.php?page=plugin-check'; 75 $activate_plugin = false; 76 } 77 78 $zip_blueprint = (object)[ 79 'landingPage' => $landing_page, 80 'preferredVersions' => (object)[ 81 'php' => '8.0', 82 'wp' => 'latest', 83 ], 84 'phpExtensionBundles' => [ 85 'kitchen-sink' 86 ], 87 'features' => (object)[ 88 'networking' => true 89 ], 90 'steps' => [ 91 (object)[ 92 'step' => 'installPlugin', 93 'pluginZipFile' => [ 94 'resource' => 'wordpress.org/plugins', 95 'slug' => 'plugin-check', 96 ] 97 ], 98 (object)[ 99 'step' => 'installPlugin', 100 'pluginZipFile' => (object)[ 101 'resource' => 'url', 102 'url' => $zip_url, 103 ], 104 'options' => (object)[ 105 'activate' => (bool)$activate_plugin 106 ] 107 ], 108 (object)[ 109 'step' => 'login', 110 'username' => 'admin', 111 'password' => 'password', 112 ] 113 ] 114 ]; 115 116 $output = json_encode( $zip_blueprint ); 117 118 if ( $output ) { 119 header( 'Access-Control-Allow-Origin: https://playground.wordpress.net' ); 120 die( $output ); 121 } 122 } 123 } 124 } 125 } 126 127 return new \WP_Error( 'invalid_blueprint', 'Invalid file', array( 'status' => 500 ) ); 128 129 } 130 104 131 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
r13076 r13088 772 772 * @return false|string The preview URL. 773 773 */ 774 public static function preview_link_zip( $slug, $attachment_id ) {774 public static function preview_link_zip( $slug, $attachment_id, $type = null ) { 775 775 776 776 $zip_hash = self::preview_link_hash( $attachment_id ); … … 779 779 } 780 780 $zip_blueprint = sprintf( 'https://wordpress.org/plugins/wp-json/plugins/v1/plugin/%s/blueprint.json?zip_hash=%s', esc_attr( $slug ), esc_attr( $zip_hash ) ); 781 if ( is_string( $type ) ) { 782 $zip_blueprint = add_query_arg( 'type', strval( $type ), $zip_blueprint ); 783 } 781 784 $zip_preview = add_query_arg( 'blueprint-url', urlencode($zip_blueprint), 'https://playground.wordpress.net/' ); 782 785
Note: See TracChangeset
for help on using the changeset viewer.