WordPress.org

Make WordPress Core

Opened 16 months ago

Closed 16 months ago

Last modified 16 months ago

#22923 closed defect (bug) (invalid)

add_meta_box() ignores $context='side' if $post_type = 'page' & $id is exactly 'myplugin_sectionid'

Reported by: SavesEnergy Owned by:
Milestone: Priority: normal
Severity: minor Version: 3.5
Component: Administration Keywords:
Focuses: Cc:

Description

This one's so strange I can hardly believe it -- but it reproduces every time. Running latest public version of WP (3.5), fresh install (no added plugins) downloaded yesterday from http://wordpress.org/latest.zip, on a WAMP Server running Windows XP [though I don't see how that could be relevant here].

Steps to reproduce:

  1. Start with WP install of http://wordpress.org/latest.zip (version from yesterday, not today, if any changes made)
  1. Create a new plugin. Fill in the code from http://codex.wordpress.org/Function_Reference/add_meta_box, first code sample under "Example".
  1. Change
    add_meta_box(
        'myplugin_sectionid',
        __( 'My Post Section Title', 'myplugin_textdomain' ), 
        'myplugin_inner_custom_box',
        'page'
    );

to

    add_meta_box(
        'myplugin_sectionid',
        __( 'My Post Section Title', 'myplugin_textdomain' ), 
        'myplugin_inner_custom_box',
        'page'
        'side'
    );
  1. Load a new page. Dashboard > Pages > Add New.

Expected results: "My Post Section" appears to the side.
Actual results: "My Post Section" appears below the editing area (as if 'side' was not supplied).

The very strange particular is if I change 'myplugin_sectionid' to ANYTHING else -- say 'myplugin2_sectionid', it works correctly.

Also, if I make the same change to the 'post' example instead of the 'page' one, it works correctly. How bizarro is that?

Change History (3)

comment:1 helenyhou16 months ago

  • Keywords reporter-feedback added

Starting with the second snippet (which is missing a comma after 'page') puts the metabox in the side as expected. I suspect that this is happening because you previously moved the metabox on the screen, which is saved as a setting and overrides where the code tells it to go. Can you reproduce either on a clean install or with a different user (since the metabox position settings are a user preference)? You can also delete the preference (meta-box-order_page for that user in the usermeta table) if you like.

comment:2 SavesEnergy16 months ago

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

Concerning the code, yes, you're right -- my mistake. And deleting the preference and re-running the code it consistently places it correctly, so this is definitely closed. I didn't think I moved it, but I had copied the code first as given and executed it that way, before changing it -- and maybe I had and just didn't remember. Apologies for the unnecessary ticket: great response time though! :D

comment:3 helenyhou16 months ago

  • Component changed from General to Administration
  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution changed from fixed to invalid
Note: See TracTickets for help on using tickets.