Changeset 13061
- Timestamp:
- 12/15/2023 03:08:48 AM (11 months ago)
- 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 1393 1393 } 1394 1394 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' ) ) ) { 1396 1396 if ( $preview_url = Template::preview_link() ) { 1397 1397 wp_safe_redirect( $preview_url, 302 ); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
r13035 r13061 726 726 * 727 727 * @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. 728 729 * @return bool True if a preview is available and the current user is permitted to see it. 729 730 */ 730 public static function is_preview_available( $post = null ) {731 public static function is_preview_available( $post = null, $context = 'view' ) { 731 732 732 733 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 ) ) { 735 736 return true; 736 737 } -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/plugin-single.php
r13040 r13061 44 44 <?php if ( Template::is_preview_available() ) : ?> 45 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() ) : ?>46 <?php elseif ( Template::preview_link() && Template::is_preview_available( $post, 'edit' ) ) : ?> 47 47 <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> 48 48 <?php endif; ?>
Note: See TracChangeset
for help on using the changeset viewer.