Making WordPress.org


Ignore:
Timestamp:
09/24/2024 07:12:05 AM (14 months ago)
Author:
tellyworth
Message:

Plugin Dir: use locale for Live Preview button.

This carries the user's current locale through to Playground when using the Live Preview button in the plugin directory. A setSiteLanguage step is automatically added to the plugin's blueprint.json file if not already present.

See #7769.

File:
1 edited

Legend:

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

    r13673 r14075  
    752752     * @return false|string The preview url. False if no preview is configured.
    753753     */
    754     public static function preview_link( $post = null ) {
     754    public static function preview_link( $post = null, $locale = null ) {
    755755        $post = get_post( $post );
    756756
     
    762762        $blueprint = $blueprints['blueprint.json'];
    763763
    764         return sprintf( 'https://playground.wordpress.net/?plugin=%s&blueprint-url=%s', esc_attr($post->post_name), esc_attr($blueprint['url'] ) );
     764        $blueprint_url = $blueprint['url'];
     765        $locale = $locale ?? get_locale();
     766        $blueprint_url = add_query_arg( 'lang', $locale, $blueprint_url );
     767
     768        return sprintf( 'https://playground.wordpress.net/?plugin=%s&blueprint-url=%s', esc_attr($post->post_name), rawurlencode($blueprint_url) );
    765769    }
    766770
Note: See TracChangeset for help on using the changeset viewer.