Skip to content

Commit

Permalink
Merge pull request #670 from hrkhal/bug/refresh-meta-box-nonce
Browse files Browse the repository at this point in the history
  • Loading branch information
GaryJones authored Jul 30, 2023
2 parents 6229d6d + 8f69262 commit 428a475
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions co-authors-plus.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ function __construct() {
add_action( 'add_meta_boxes', array( $this, 'add_coauthors_box' ) );
add_action( 'add_meta_boxes', array( $this, 'remove_authors_box' ) );

// Refresh the nonce after the user re-authenticates due to a wp_auth_check() to avoid failing check_admin_referrer()
add_action( 'wp_refresh_nonces', array( $this, 'refresh_coauthors_nonce' ), 20, 1 );

// Removes the co-author dropdown from the post quick edit
add_action( 'admin_head', array( $this, 'remove_quick_edit_authors_box' ) );

Expand Down Expand Up @@ -480,6 +483,15 @@ public function coauthors_meta_box( $post ) {
<?php
}

/**
* Filters the Heartbeat response to refresh the coauthors-nonce
*/
public function refresh_coauthors_nonce( $response ) {
$response['wp-refresh-post-nonces']['replace']['coauthors-nonce'] = wp_create_nonce( 'coauthors-edit' );

return $response;
}

/**
* Removes the default 'author' dropdown from quick edit
*/
Expand Down

0 comments on commit 428a475

Please sign in to comment.