Skip to content

Commit

Permalink
Prevent quick edit nonces from being submitted when searching or filt…
Browse files Browse the repository at this point in the history
…ering the post list table.
  • Loading branch information
bradyvercher committed Jan 30, 2014
1 parent a32d423 commit 8cc4f5d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ public static function display_columns( $column, $page_id ) {
}

// Add the nonce here and copy it to the inline editor with javascript.
wp_nonce_field( 'update-page-sidebar_' . $page_id, 'simplepagesidebars_page_sidebar_update_nonce', false );
$nonce = wp_create_nonce( 'update-page-sidebar_' . $page_id );
printf( '<input type="hidden" value="%s" class="simplepagesidebars_page_sidebar_update_nonce">', esc_attr( $nonce ) );
}
}

Expand Down Expand Up @@ -251,6 +252,7 @@ public static function quick_edit_custom_box( $column, $post_type ) {
?>
</select>
</label>
<?php wp_nonce_field( 'update-page-sidebar', 'simplepagesidebars_page_sidebar_update_nonce', false ); ?>
</div>
</div>
</fieldset>
Expand Down Expand Up @@ -283,7 +285,8 @@ public static function quick_edit_js() {

var postId = inlineEditPost.getId( id ),
currentSidebar = $( '#post-' + postId + ' .simple-page-sidebar' ).text(),
sidebarNameField = $( '#simple-page-sidebars-page-sidebar-name' );
sidebarNameField = $( '#simple-page-sidebars-page-sidebar-name' ),
$nonceField = $( '#simple-page-sidebars-page-sidebar-edit-group' ).find( 'input[name="simplepagesidebars_page_sidebar_update_nonce"]' );

// Select the current sidebar option.
sidebarNameField.find( 'option' ).attr( 'selected', false );
Expand All @@ -292,9 +295,7 @@ public static function quick_edit_js() {
}

// Copy the sidebar name nonce.
$( '#simple-page-sidebars-page-sidebar-edit-group' )
.find( 'input[name="simplepagesidebars_page_sidebar_update_nonce"]' ).remove().end()
.append( $( '#post-' + postId + ' input[name="simplepagesidebars_page_sidebar_update_nonce"]' ).clone() );
$nonceField.val( $( '#post-' + postId + ' .simplepagesidebars_page_sidebar_update_nonce' ).val() );
};
} )( window, jQuery );
</script>
Expand Down

0 comments on commit 8cc4f5d

Please sign in to comment.