WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 15 months ago

Last modified 11 months ago

#17515 closed defect (bug) (fixed)

Flaw in add_meta_box/do_meta_boxes

Reported by: jfarthing84 Owned by: 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 3 years ago.
17515.diff (1.3 KB) - added by wonderboymusic 15 months ago.
17515.2.diff (957 bytes) - added by markjaquith 15 months ago.

Download all attachments as: .zip

Change History (12)

comment:1 scribu3 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.

jfarthing843 years ago

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

comment:3 wonderboymusic15 months 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 )

wonderboymusic15 months ago

comment:4 SergeyBiryukov15 months ago

  • Keywords commit added

comment:5 helen15 months ago

  • Component changed from Administration to Inline Docs

comment:6 markjaquith15 months 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.

markjaquith15 months ago

comment:7 markjaquith15 months 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

comment:8 SergeyBiryukov14 months ago

In 23457:

Fix typo in phpdoc. see #17515.

comment:9 DrewAPicture11 months ago

  • Keywords needs-codex added

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

Note: See TracTickets for help on using tickets.