In `wp_ajax_hidden_columns()`, don't `explode()` on an empty string.

In `columns.hidden()`, which lives in `common.js`, don't return items with no `id`.

This was resulting in options like `manageedit-postcolumnshidden` containing a serialized array with random empty items.

Props afercia, wonderboymusic.
Fixes #32466.


git-svn-id: https://develop.svn.wordpress.org/trunk@32751 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2015-06-13 14:59:40 +00:00
parent 5202111c6a
commit 0eb50f80b9
2 changed files with 5 additions and 4 deletions

View File

@ -1325,7 +1325,6 @@ function wp_ajax_closed_postboxes() {
*/
function wp_ajax_hidden_columns() {
check_ajax_referer( 'screen-options-nonce', 'screenoptionnonce' );
$hidden = explode( ',', isset( $_POST['hidden'] ) ? $_POST['hidden'] : '' );
$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
if ( $page != sanitize_key( $page ) )
@ -1334,8 +1333,8 @@ function wp_ajax_hidden_columns() {
if ( ! $user = wp_get_current_user() )
wp_die( -1 );
if ( is_array($hidden) )
update_user_option($user->ID, "manage{$page}columnshidden", $hidden, true);
$hidden = ! empty( $_POST['hidden'] ) ? explode( ',', $_POST['hidden'] ) : array();
update_user_option( $user->ID, "manage{$page}columnshidden", $hidden, true );
wp_die( 1 );
}

View File

@ -47,7 +47,9 @@ columns = {
},
hidden : function() {
return $('.manage-column').filter(':hidden').map(function() { return this.id; }).get().join(',');
return $( '.manage-column[id]' ).filter( ':hidden' ).map(function() {
return this.id;
}).get().join( ',' );
},
useCheckboxesForHidden : function() {