Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#43229 closed defect (bug) (fixed)

Documentation for add_meta_boxes hook is incorrect

Reported by: johnbillion's profile johnbillion Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.1 Priority: normal
Severity: normal Version:
Component: Options, Meta APIs Keywords: has-patch
Focuses: docs Cc:

Description

The documentation for the add_meta_boxes hook states that the $post parameter is a WP_Post object. This is incorrect because the object can be any type. On the comment editing screen for example, this parameter is a WP_Comment object.

Attachments (1)

43229.diff (567 bytes) - added by danieltj 7 years ago.
Patch to include all three object types.

Download all attachments as: .zip

Change History (10)

#1 @SergeyBiryukov
7 years ago

  • Component changed from General to Options, Meta APIs

#2 follow-up: @danieltj
7 years ago

  • Component changed from Options, Meta APIs to General

The add_meta_boxes hook doesn't have a parameter for a $post, at least not in function I found. Am I looking at the wrong one? I didn't see anything that referenced posts.

Reference: https://core.trac.wordpress.org/browser/tags/4.9/src/wp-admin/includes/template.php#L886

#3 @danieltj
7 years ago

  • Component changed from General to Options, Meta APIs

Sorry @SergeyBiryukov my comment overwrote the changes. I reverted back.

#4 in reply to: ↑ 2 ; follow-up: @SergeyBiryukov
7 years ago

Replying to danieltj:

The add_meta_boxes hook doesn't have a parameter for a $post, at least not in function I found. Am I looking at the wrong one? I didn't see anything that referenced posts.

It's about the add_meta_boxes filter, not the add_meta_box() function :) There are 3 instances of the hook:

#5 in reply to: ↑ 4 @danieltj
7 years ago

Replying to SergeyBiryukov:

Replying to danieltj:

The add_meta_boxes hook doesn't have a parameter for a $post, at least not in function I found. Am I looking at the wrong one? I didn't see anything that referenced posts.

It's about the add_meta_boxes filter, not the add_meta_box() function :) There are 3 instances of the hook:
[...]

Ah, thank you for pointing that out. Was very confused when I saw the docs.

I'll take a look.

@danieltj
7 years ago

Patch to include all three object types.

This ticket was mentioned in Slack in #core by danieltj. View the logs.


7 years ago

#7 @SergeyBiryukov
7 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone changed from Awaiting Review to 5.0

#8 @SergeyBiryukov
7 years ago

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

In 42796:

Docs: Improve documentation for add_meta_boxes and do_meta_boxes actions.

Props danieltj, johnbillion, SergeyBiryukov.
Fixes #43229.

#9 @johnbillion
7 years ago

  • Milestone changed from 5.0 to 5.1
Note: See TracTickets for help on using tickets.