WordPress.org

Make WordPress Core

Opened 18 months ago

Closed 17 months ago

Last modified 17 months ago

#37211 closed defect (bug) (fixed)

Incorrect docs for second param of `wp_nav_menu_item_(taxonomy|post_type)_meta_box()`

Reported by: ocean90 Owned by: mehulkaklotar
Milestone: 4.6 Priority: low
Severity: normal Version: 3.0
Component: Menus Keywords: good-first-bug has-patch
Focuses: docs Cc:

Description

This is about wp_nav_menu_item_post_type_meta_box() and wp_nav_menu_item_taxonomy_meta_box().

The DocBlock of both both functions declare the second param as string and post type/taxonomy object, but it's an array with four keys:

Attachments (3)

37211.diff (868 bytes) - added by mehulkaklotar 18 months ago.
PHPDoc for both functions changed
37211.2.diff (1.3 KB) - added by mehulkaklotar 18 months ago.
changed phpdoc as per handbook instructions
37211.3.diff (1.4 KB) - added by mehulkaklotar 17 months ago.

Download all attachments as: .zip

Change History (19)

#1 @ocean90
18 months ago

$posttype is also passed to "nav_menu_items_{$post_type_name}_recent" which should be $posttype[args] or the result of get_post_type_object() like it's done for "nav_menu_items_{$post_type_name}".

@mehulkaklotar
18 months ago

PHPDoc for both functions changed

#2 @swissspidy
18 months ago

Thanks for the patch @mehulkaklotar, but as stated in the ticket description those aren't objects but arrays instead. So not only the type is wrong, but also the description.

The arrays would need to be documented according to our inline documentation standards: https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/php/#1-1-parameters-that-are-arrays

@mehulkaklotar
18 months ago

changed phpdoc as per handbook instructions

#3 @rabmalin
17 months ago

  • Keywords has-patch added; needs-patch removed

#4 @DrewAPicture
17 months ago

  • Owner set to mehulkaklotar
  • Status changed from new to assigned

Assigning to mark the good-first-bug as "claimed".

See 37211.2.diff

#5 @ocean90
17 months ago

  • Keywords needs-refresh added

@mehulkaklotar Thanks for your patch. Some feedback:

  • Each line should end with a period.
  • "A id" should be "An ID".
  • $args is not an array, it's an object for wp_nav_menu_item_taxonomy_meta_box() and WP_Post_Type for wp_nav_menu_item_post_type_meta_box().
  • "An array of post type arguments" should be replaced with something else. I think we can use something similar to the one we're using for $callback_args from https://developer.wordpress.org/reference/functions/add_meta_box/.

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


17 months ago

#7 @ocean90
17 months ago

  • Priority changed from normal to low

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


17 months ago

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


17 months ago

#10 @SergeyBiryukov
17 months ago

In 38127:

Docs: Correct and expand the docs for the $post_type argument of wp_nav_menu_item_post_type_meta_box().

Props mehulkaklotar for initial patch.
See #37211.

#11 @SergeyBiryukov
17 months ago

In 38128:

Docs: Correct and expand the docs for the $taxonomy argument of wp_nav_menu_item_taxonomy_meta_box().

Props mehulkaklotar for initial patch.
See #37211.

#12 @SergeyBiryukov
17 months ago

In 38129:

Menus: In wp_nav_menu_item_post_type_meta_box():

  • Rename the $post_type parameter to $box for clarity and consistency with other meta box functions.
  • Make the docs more consistent with post_format_meta_box() and other meta box functions.
  • Correct type and description for the third argument of nav_menu_items_{$post_type_name}_recent filter.

See #37211.

#13 @SergeyBiryukov
17 months ago

In 38130:

Menus: In wp_nav_menu_item_taxonomy_meta_box():

  • Rename the $taxonomy parameter to $box for clarity and consistency with other meta box functions.
  • Make the docs more consistent with post_categories_meta_box() and other meta box functions.

See #37211.

#14 @SergeyBiryukov
17 months ago

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

In 38131:

Docs: In meta box functions, clarify that "Meta box ID" refers to the id attribute of the meta box and not a numeric ID.

Fixes #37211.

#15 @ocean90
17 months ago

  • Keywords needs-refresh removed

Thanks for the cleanup.

Last edited 17 months ago by ocean90 (previous) (diff)

#16 @SergeyBiryukov
17 months ago

In 38142:

Docs: Update the description of the $box argument of wp_nav_menu_item_taxonomy_meta_box() for consistency with [38129].

Missed in [38130].

See #37211.

Note: See TracTickets for help on using tickets.