Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#43229 closed defect (bug) (fixed)

Documentation for add_meta_boxes hook is incorrect

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

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 9 years ago.
Patch to include all three object types.

Download all attachments as: .zip

Change History (10)

#1 @SergeyBiryukov
9 years ago

  • Component General → Options, Meta APIs

#2 follow-up: @danieltj
9 years ago

  • Component Options, Meta APIs → 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
9 years ago

  • Component General → Options, Meta APIs

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

#4 in reply to: ↑ 2 ; follow-up: @SergeyBiryukov
9 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
9 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
9 years ago

Patch to include all three object types.

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


9 years ago

#7 @SergeyBiryukov
9 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone Awaiting Review → 5.0

#8 @SergeyBiryukov
9 years ago

  • Owner set to SergeyBiryukov
  • Resolution → fixed
  • Status new → closed

In 42796:

Docs: Improve documentation for add_meta_boxes and do_meta_boxes actions.

Props danieltj, johnbillion, SergeyBiryukov.
Fixes #43229.

#9 @johnbillion
8 years ago

  • Milestone 5.0 → 5.1
Note: See TracTickets for help on using tickets.