WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#12439 closed defect (bug) (fixed)

Metaboxes options ignored

Reported by: scribu Owned by:
Milestone: 3.0 Priority: normal
Severity: major Version: 3.0
Component: Administration Keywords: has-patch tested commit
Focuses: Cc:

Description

Steps to reproduce

On any admin page with meta boxes:

  1. Open Screen Options.
  1. Uncheck one of the metabox titles, to hide it.
  1. Refresh page.

Expected result

Box stays hidden.

Actual result

Hidden metaboxes are reset to default values.

Attachments (4)

12439.diff (1.1 KB) - added by scribu 6 years ago.
Add $wpdb->prefix.
12439.2.diff (1.8 KB) - added by scribu 6 years ago.
use update_user_option() instead of update_user_meta()
12439.3.diff (1.9 KB) - added by scribu 6 years ago.
Remove $option = preg_replace('|[a-z0-9_]|i', , $option);
12439.4.diff (5.7 KB) - added by scribu 6 years ago.
take care of custom post types

Download all attachments as: .zip

Change History (15)

#1 @scribu
6 years ago

I've traced the error to get_hidden_meta_boxes() -> get_user_option().

@scribu
6 years ago

Add $wpdb->prefix.

#2 @scribu
6 years ago

  • Keywords has-patch added; needs-patch removed

The problem was that get_user_option() first looks for blog-specific options, but the AJAX calls updated the user-specific options.

12439.diff fixes this.

@scribu
6 years ago

use update_user_option() instead of update_user_meta()

@scribu
6 years ago

Remove $option = preg_replace('|[a-z0-9_]|i', , $option);

#3 @scribu
6 years ago

12439.2.diff uses update_user_option(), making it compatible with get_user_option().

12439.3.diff takes a more "radical" approach and removes the $option = preg_replace('|[^a-z0-9_]|i', '', $option); filter. It has the short-term drawback that users will loose their customizations when upgrading.

#4 @prettyboymp
6 years ago

  • Keywords tested added

#5 @prettyboymp
6 years ago

  • Keywords tested removed

scratch that, its working on the dashboard and built in edit pages, but not on custom post_type pages.

#6 @scribu
6 years ago

  • Summary changed from Hidden metaboxes options ignored to Metaboxes options ignored

@scribu
6 years ago

take care of custom post types

#7 @scribu
6 years ago

With 12439.4.diff metaboxes on editing screens other than posts should work too.

#8 @prettyboymp
6 years ago

  • Keywords tested added

That patch seems to have fixed the custom post_types now.

#9 @voyagerfan5761
6 years ago

  • Cc WordPress@… added

#10 @scribu
6 years ago

  • Keywords commit added

#11 @ryan
6 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [13551]) Fix metabox hiding. Props scribu. fixes #12439

Note: See TracTickets for help on using tickets.