Making WordPress.org

Changeset 13040

Timestamp:
12/08/2023 05:58:26 AM (8 months ago)
Author:
tellyworth
Message:

Plugin directory: add committer button to enable previews

This adds a button to the Advanced view that will allow a plugin committer to enable or disable the Live Preview button for public users.

A valid blueprint.json file must be present in the plugin's assets/blueprints/ folder in its svn repo.

See #7251.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/inc/template-tags.php

    r12934 r13040  
    520520        // Output the self close button.
    521521        the_plugin_self_close_button();
     522
     523
     524
    522525    }
    523526
     
    570573
    571574    echo '<h4>' . esc_html__( 'Toggle Live Preview', 'wporg-plugins' ) . '</h4>';
    572     $preview_status = get_post_meta( $post->ID, '_no_preview', true ) ? 'disabled' : 'enabled';
     575    $preview_status = get_post_meta( $post->ID, '_abled';
    573576    if ( 'enabled' === $preview_status ) {
    574577        echo '<p>' . esc_html__( 'The Live Preview link to Playground is currently enabled. Use the toggle button to disable it.', 'wporg-plugins' ) . '</p>';
     
    577580    }
    578581
    579     echo '<div class="plugin-notice notice notice-warning notice-alt"><p>';
    580     _e( '<strong>Note:</strong> This only affects the availability of the Live Preview button on the plugin page. It does not prevent a plugin from running in the Playground.', 'wporg-plugins' );
    581     echo '</p></div>';
     582    $blueprints = get_post_meta( $post->ID, 'assets_blueprints', true );
     583
     584    if ( !isset( $blueprints[ 'blueprint.json' ] ) ) {
     585        echo '<div class="plugin-notice notice notice-error notice-alt"><p>';
     586        _e( '<strong>Note:</strong> Missing or invalid blueprint.json file.', 'wporg-plugins' );
     587        echo '</p></div>';
     588    }
    582589
    583590    if ( $toggle_link ) {
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/plugin-single.php

    r12999 r13040  
    4242                <a class="plugin-download button download-button button-large" href="<?php echo esc_url( Template::download_link() ); ?>"><?php esc_html_e( 'Download', 'wporg-plugins' ); ?></a>
    4343            <?php endif; ?>
    44             <?php if ( current_user_can( 'plugin_admin_edit', $post ) && Template::is_preview_available() ) : ?>
     44            <?php if ( Template::is_preview_available() ) : ?>
     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( 'Live Preview', 'wporg-plugins' ); ?></a>
     46            <?php elseif ( current_user_can( 'plugin_admin_edit', $post ) && Template::preview_link() ) : ?>
    4547                <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>
    4648            <?php endif; ?>
Note: See TracChangeset for help on using the changeset viewer.