Making WordPress.org

Changeset 13061


Ignore:
Timestamp:
12/15/2023 03:08:48 AM (11 months ago)
Author:
tellyworth
Message:

Plugin Directory: fix button text for Test Preview

Props @jeffpaul.
See #7251.

Location:
sites/trunk/wordpress.org/public_html/wp-content
Files:
3 edited

Legend:

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

    r12999 r13061  
    13931393        }
    13941394
    1395         if ( is_single() && isset( $_GET['preview'] ) && Template::is_preview_available( ) ) {
     1395        if ( is_single() && isset( $_GET['preview'] ) && ( Template::is_preview_available() || Template::is_preview_available( null, 'edit' ) ) ) {
    13961396            if ( $preview_url = Template::preview_link() ) {
    13971397                wp_safe_redirect( $preview_url, 302 );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php

    r13035 r13061  
    726726     *
    727727     * @param int|\WP_Post|null $post    Optional. Post ID or post object. Defaults to global $post.
     728     * @param 'view'|'edit'     $context Optional. 'view' to check if preview is available for public viewing. 'edit' to also check if available for current user to test. Default: view.
    728729     * @return bool True if a preview is available and the current user is permitted to see it.
    729730     */
    730     public static function is_preview_available( $post = null ) {
     731    public static function is_preview_available( $post = null, $context = 'view' ) {
    731732
    732733        if ( self::preview_link( $post ) ) {
    733             // Plugin committers can always use the plugin preview button if it exists.
    734             if ( current_user_can( 'plugin_admin_edit', $post ) ) {
     734            // Plugin committers can use the plugin preview button to test if a blueprint exists.
     735            if ( 'edit' === $context && current_user_can( 'plugin_admin_edit', $post ) ) {
    735736                return true;
    736737            }
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/plugin-single.php

    r13040 r13061  
    4444            <?php if ( Template::is_preview_available() ) : ?>
    4545                <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() ) : ?>
     46            <?php elseif ( Template::preview_link() && Template::is_preview_available( $post, 'edit' ) ) : ?>
    4747                <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>
    4848            <?php endif; ?>
Note: See TracChangeset for help on using the changeset viewer.