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.

Built from https://develop.svn.wordpress.org/trunk@32751


git-svn-id: http://core.svn.wordpress.org/trunk@32722 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-06-13 15:00:25 +00:00
parent 5ec278f585
commit 18827ed337
4 changed files with 7 additions and 6 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() {

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.3-alpha-32750';
$wp_version = '4.3-alpha-32751';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.