Changeset 12999
- Timestamp:
- 12/04/2023 04:42:52 AM (15 months ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/class-base.php
r12933 r12999 39 39 new Routes\Plugin_Categorization(); 40 40 new Routes\Plugin_Upload(); 41 new Routes\Plugin_Blueprint(); 41 42 } 42 43 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-blueprint.php
r12998 r12999 37 37 $blueprints = get_post_meta( $plugin->ID, 'assets_blueprints', true ); 38 38 // Note: for now, only use a file called `blueprint.json`. 39 40 return false;39 if ( !isset( $blueprints['blueprint.json'] ) ) { 40 return new \WP_Error( 'no_blueprint', 'File not found', array( 'status' => 404 ) ); 41 41 } 42 42 $blueprint = $blueprints['blueprint.json']; 43 43 if ( !$blueprint || !isset( $blueprint['contents'] ) || !is_string( $blueprint['contents'] ) ) { 44 return false;44 return new \WP_Error( 'invalid_blueprint', 'Invalid file', array( 'status' => 500 ) ); 45 45 } 46 46 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r12816 r12999 50 50 add_action( 'wp_head', array( Template::class, 'json_ld_schema' ), 1 ); 51 51 add_action( 'wp_head', array( Template::class, 'hreflang_link_attributes' ), 2 ); 52 add_filter( 'allowed_redirect_hosts', array( $this, 'filter_redirect_hosts' ) ); 52 53 53 54 // Add no-index headers where appropriate. … … 1392 1393 } 1393 1394 1395 if ( is_single() && isset( $_GET['preview'] ) && Template::is_preview_available( ) ) { 1396 if ( $preview_url = Template::preview_link() ) { 1397 wp_safe_redirect( $preview_url, 302 ); 1398 die; 1399 } 1400 } 1401 1394 1402 if ( is_comment_feed() ) { 1395 1403 wp_redirect( 'https://wordpress.org/plugins/', 301 ); … … 1397 1405 } 1398 1406 1407 } 1408 1409 /** 1410 * Filter allowed_redirect_hosts to allow safe redirect to trusted hosts. 1411 * @param array $hosts 1412 */ 1413 function filter_redirect_hosts( $hosts ) { 1414 $hosts[] = 'playground.wordpress.net'; 1415 1416 return $hosts; 1399 1417 } 1400 1418 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
r12978 r12999 758 758 } 759 759 760 $blueprint_ encoded = esc_html( str_replace( '%', '%25', $blueprint['contents'] ));761 762 return sprintf( 'https://playground.wordpress.net/?plugin=%s #%s', $post->post_name, $blueprint_encoded);760 $blueprint_url = sprintf( 'https://wordpress.org/plugins/wp-json/plugins/v1/plugin/%s/blueprint.json?rev=%d', $post->post_name, $blueprint['revision'] ); 761 762 return sprintf( 'https://playground.wordpress.net/?plugin=%s&blueprint-url=%s', esc_attr($post->post_name), esc_attr($blueprint_url ) ); 763 763 } 764 764 -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/plugin-single.php
r12976 r12999 43 43 <?php endif; ?> 44 44 <?php if ( current_user_can( 'plugin_admin_edit', $post ) && Template::is_preview_available() ) : ?> 45 <a class="plugin-preview button download-button button-large" href="<?php echo esc_html( Template::preview_link() ); ?>"><?php esc_html_e( 'Test Preview', 'wporg-plugins' ); ?></a>45 <a class="plugin-preview button download-button button-large" target="_blank" href="<?php echo esc_attr( add_query_arg( array( 'preview' => 1 ), get_the_permalink() ) ); ?>"><?php esc_html_e( 'Test Preview', 'wporg-plugins' ); ?></a> 46 46 <?php endif; ?> 47 47 </div>
Note: See TracChangeset
for help on using the changeset viewer.