Make WordPress Core

Opened 13 years ago

Closed 11 years ago

Last modified 11 years ago

#17515 closed defect (bug) (fixed)

Flaw in add_meta_box/do_meta_boxes

Reported by: jfarthing84's profile jfarthing84 Owned by: markjaquith's profile markjaquith
Milestone: 3.6 Priority: normal
Severity: normal Version: 3.1.2
Component: Inline Docs Keywords: has-patch 3.3-early commit needs-codex
Focuses: Cc:

Description

There is a mysterious, undocumented 7th parameter in the add_meta_box() function, named $callback_args. This is to be an array of arguments that are passed into the callback function. The problem is that it the arguments are not passed into the callback function, but rather the whole $box object is instead. While I realize that one can access the arguments passed in via the $box object, I don't feel this is the proper method. I am attaching a patch to correctly pass the arguments.

Attachments (3)

template.php.diff (647 bytes) - added by jfarthing84 13 years ago.
17515.diff (1.3 KB) - added by wonderboymusic 11 years ago.
17515.2.diff (957 bytes) - added by markjaquith 11 years ago.

Download all attachments as: .zip

Change History (12)

#1 @scribu
13 years ago

  • Milestone changed from Awaiting Review to 3.2

+1. I've been confused by this myself.

We should also document the argument, while we're at it.

PS: Please make patches relative to the root WP dir, as opposed to wp-admin/includes.

#2 @ryan
13 years ago

  • Keywords 3.3-early added
  • Milestone changed from 3.2 to Future Release

Meta boxes will get new API in 3.3. Let's tidy this up then.

#3 @wonderboymusic
11 years ago

  • Milestone changed from Future Release to 3.6

template.php.diff completely breaks the admin. Converting the object to array doesn't make sense, and not having a second parameter to pass to the callback is the culprit. My patch just adds docs for the SEVENTH (7th) undocumented param for add_meta_box( $id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null )

#4 @SergeyBiryukov
11 years ago

  • Keywords commit added

#5 @helen
11 years ago

  • Component changed from Administration to Inline Docs

#6 @markjaquith
11 years ago

Can't do template.php.diff — it's a breaking change. wonderboymusic's docs explanation still leaves me slightly confused. Attempting to re-work.

@markjaquith
11 years ago

#7 @markjaquith
11 years ago

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

In 23397:

Document the mysterious seventh parameter of add_meta_box().

props wonderboymusic, markjaquith. fixes #17515

#8 @SergeyBiryukov
11 years ago

In 23457:

Fix typo in phpdoc. see #17515.

#9 @DrewAPicture
11 years ago

  • Keywords needs-codex added

[23397] documents the 7th parameter, $callback_args in add_meta_box().

Note: See TracTickets for help on using tickets.