Skip to content

Commit

Permalink
Refreshing meta box nonce after re-authenticating following a wp_auth…
Browse files Browse the repository at this point in the history
…_check()
  • Loading branch information
hrkhal committed Apr 15, 2019
1 parent f37f410 commit 8f69262
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 @@ -103,6 +103,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 @@ -414,6 +417,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 8f69262

Please sign in to comment.