Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/js/_enqueues/admin/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
var post = {
ps: $( '#find-posts-input' ).val(),
action: 'find_posts',
_ajax_nonce: $('#_ajax_nonce').val()
_ajax_nonce: $( '#_ajax_nonce-find-posts' ).val()
},
spinner = $( '.find-box-search .spinner' );

Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -2043,7 +2043,7 @@ function find_posts_div( $found_action = '' ) {
<input type="hidden" name="found_action" value="<?php echo esc_attr( $found_action ); ?>" />
<?php } ?>
<input type="hidden" name="affected" id="affected" value="" />
<?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
<?php wp_nonce_field( 'find-posts', '_ajax_nonce-find-posts', false ); ?>
<label class="screen-reader-text" for="find-posts-input">
<?php
/* translators: Hidden accessibility text. */
Expand Down
14 changes: 14 additions & 0 deletions tests/phpunit/tests/admin/includesTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) );
}

/**
* @ticket 43611
*
* @covers ::find_posts_div
*/
public function test_find_posts_div_has_unique_nonce_field() {
ob_start();
find_posts_div();
$output = ob_get_clean();

$this->assertStringContainsString( 'id="_ajax_nonce-find-posts"', $output );
$this->assertStringNotContainsString( 'id="_ajax_nonce"', $output );
}

/**
* @ticket 51137
* @dataProvider data_wp_terms_checklist_with_selected_cats
Expand Down
Loading