From e2c1ce5be1d6b704b5aa52337f9062a741ae1467 Mon Sep 17 00:00:00 2001 From: Alex Kirk Date: Tue, 3 Sep 2024 12:09:07 +0200 Subject: [PATCH 1/3] Improve discoverability of Plugin Previews --- .../pub/wporg-plugins-2024/inc/template-tags.php | 6 +++--- .../template-parts/plugin-single.php | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/inc/template-tags.php b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/inc/template-tags.php index 51013b327e..10ed985bf6 100644 --- a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/inc/template-tags.php +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/inc/template-tags.php @@ -590,12 +590,12 @@ function the_plugin_self_toggle_preview_button() { return; } - echo '

' . esc_html__( 'Toggle Live Preview', 'wporg-plugins' ) . '

'; + echo '

' . esc_html__( 'Toggle Live Preview', 'wporg-plugins' ) . '

'; $preview_status = get_post_meta( $post->ID, '_public_preview', true ) ? 'enabled' : 'disabled'; if ( 'enabled' === $preview_status ) { - echo '

' . esc_html__( 'The Live Preview link to Playground is currently enabled. Use the toggle button to disable it.', 'wporg-plugins' ) . '

'; + echo '

' . wp_kses( sprintf( __( 'The Live Preview link to Playground is currently enabled. Use the toggle button to disable it.', 'wporg-plugins' ), 'https://developer.wordpress.org/plugins/wordpress-org/previews-and-blueprints/' ), array( 'a' => array( 'href' => array() ) ) ) . '

'; } else { - echo '

' . esc_html__( 'The Live Preview link to Playground is currently disabled. Use the toggle button to enable it.', 'wporg-plugins' ) . '

'; + echo '

' . wp_kses( sprintf( __( 'The Live Preview link to Playground is currently disabled. Use the toggle button to enable it.', 'wporg-plugins' ), 'https://developer.wordpress.org/plugins/wordpress-org/previews-and-blueprints/#committing-a-blueprint-to-subversion' ), array( 'a' => array( 'href' => array() ) ) ) . '

'; } $blueprints = get_post_meta( $post->ID, 'assets_blueprints', true ); diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/template-parts/plugin-single.php b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/template-parts/plugin-single.php index b28bcffb99..dd7b027108 100644 --- a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/template-parts/plugin-single.php +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/template-parts/plugin-single.php @@ -74,7 +74,15 @@
%2$s
', esc_attr( add_query_arg( array( 'preview' => 1 ), get_the_permalink() ) ), - esc_html__( 'Test Preview', 'wporg-plugins' ) + esc_html__( 'Test Preview', 'wporg-plugins' ) . ' ' + ); + } else { + $buttons .= sprintf( + ' +
%2$s
+ ', + esc_attr( get_the_permalink() . 'advanced/#live-preview' ), + esc_html__( 'Preview Not Available', 'wporg-plugins' ) . ' ' ); } echo do_blocks( $buttons ); // phpcs:ignore -- Output escaped while building string. From a89a0d3b08b6fbb16e9a6ada1ca78a0b2dcbd160 Mon Sep 17 00:00:00 2001 From: Alex Kirk Date: Tue, 3 Sep 2024 13:05:52 +0200 Subject: [PATCH 2/3] Only show the preview not available when you can edit the plugin --- .../pub/wporg-plugins-2024/template-parts/plugin-single.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/template-parts/plugin-single.php b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/template-parts/plugin-single.php index dd7b027108..d5b3fea0bd 100644 --- a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/template-parts/plugin-single.php +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/template-parts/plugin-single.php @@ -76,7 +76,7 @@ esc_attr( add_query_arg( array( 'preview' => 1 ), get_the_permalink() ) ), esc_html__( 'Test Preview', 'wporg-plugins' ) . ' ' ); - } else { + } else ( current_user_can( 'plugin_admin_edit', $post ) ) { $buttons .= sprintf( ' From c11eccb28eefe08950f65ee829691462fb5329d5 Mon Sep 17 00:00:00 2001 From: Alex Kirk Date: Tue, 3 Sep 2024 13:07:28 +0200 Subject: [PATCH 3/3] typo --- .../pub/wporg-plugins-2024/template-parts/plugin-single.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/template-parts/plugin-single.php b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/template-parts/plugin-single.php index d5b3fea0bd..7edf617dc5 100644 --- a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/template-parts/plugin-single.php +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/template-parts/plugin-single.php @@ -76,7 +76,7 @@ esc_attr( add_query_arg( array( 'preview' => 1 ), get_the_permalink() ) ), esc_html__( 'Test Preview', 'wporg-plugins' ) . ' ' ); - } else ( current_user_can( 'plugin_admin_edit', $post ) ) { + } elseif ( current_user_can( 'plugin_admin_edit', $post ) ) { $buttons .= sprintf( '