Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block Theme Previews: Add a nonce for activation #4795

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
prefix function
scruffian committed Jul 5, 2023
commit 0cdfdc964f58a5152f4ddbdb7668e7cd23362d47
4 changes: 2 additions & 2 deletions src/wp-includes/theme-previews.php
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ function wp_attach_theme_preview_middleware() {
*
* @since 6.3.0
tellthemachines marked this conversation as resolved.
Show resolved Hide resolved
*/
function block_theme_activate_nonce() {
function wp_block_theme_activate_nonce() {
$nonce_handle = 'switch-theme_' . wp_get_theme_preview_path();
Copy link

@anton-vlasenko anton-vlasenko Jul 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: I don't see many PHP frameworks using inline tags to output text these days. Instead, I would use echo or print to output the nonce code to the buffer. But I admit, this is just a personal preference.

?>
<script type="text/javascript">
@@ -76,5 +76,5 @@ function block_theme_activate_nonce() {
add_filter( 'stylesheet', 'wp_get_theme_preview_path' );
add_filter( 'template', 'wp_get_theme_preview_path' );
add_action( 'init', 'wp_attach_theme_preview_middleware' );
add_action( 'admin_head', 'block_theme_activate_nonce' );
add_action( 'admin_head', 'wp_block_theme_activate_nonce' );
}