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)

comment:1 @scribu6 years ago

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

@scribu6 years ago

Add $wpdb->prefix.

comment:2 @scribu6 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.

@scribu6 years ago

use update_user_option() instead of update_user_meta()

@scribu6 years ago

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

comment:3 @scribu6 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.

comment:4 @prettyboymp6 years ago

  • Keywords tested added

comment:5 @prettyboymp6 years ago

  • Keywords tested removed

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

comment:6 @scribu6 years ago

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

@scribu6 years ago

take care of custom post types

comment:7 @scribu6 years ago

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

comment:8 @prettyboymp6 years ago

  • Keywords tested added

That patch seems to have fixed the custom post_types now.

comment:9 @voyagerfan57616 years ago

  • Cc WordPress@… added

comment:10 @scribu6 years ago

  • Keywords commit added

comment:11 @ryan6 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.