Making WordPress.org


Ignore:
Timestamp:
12/04/2023 04:42:52 AM (2 years ago)
Author:
tellyworth
Message:

Plugins: improved Test Preview button

This uses the new Playground blueprint-url param to pass the blueprint rather than a URL fragment.

Also, opens the preview in a new tab, as per suggestions.

See #7251.

File:
1 edited

Legend:

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

    r12816 r12999  
    5050        add_action( 'wp_head', array( Template::class, 'json_ld_schema' ), 1 );
    5151        add_action( 'wp_head', array( Template::class, 'hreflang_link_attributes' ), 2 );
     52        add_filter( 'allowed_redirect_hosts', array( $this, 'filter_redirect_hosts' ) );
    5253
    5354        // Add no-index headers where appropriate.
     
    13921393        }
    13931394
     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
    13941402        if ( is_comment_feed() ) {
    13951403            wp_redirect( 'https://wordpress.org/plugins/', 301 );
     
    13971405        }
    13981406
     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;
    13991417    }
    14001418
Note: See TracChangeset for help on using the changeset viewer.