[wp-trac] [WordPress Trac] #57428: Walker_Nav_Menu::start_el() $data_object is not a WP_Post
WordPress Trac
noreply at wordpress.org
Fri Jan 6 11:26:26 UTC 2023
#57428: Walker_Nav_Menu::start_el() $data_object is not a WP_Post
--------------------------+-----------------------------
Reporter: jdamner | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Menus | Version: 6.1.1
Severity: minor | Keywords:
Focuses: docs |
--------------------------+-----------------------------
The inline docs for `Walker_Nav_menu::start_el()` state that the
`$data_object` parameter is a WP_Post object. This isn't accurate as the
object that comes in has various properties such as `$title` and `$url`
which do not exist on a standard `WP_Post` object.
The docs were changed from `object` to `WP_Post` here
https://core.trac.wordpress.org/changeset/38559, but it's not clear why.
Proposed solutions would be to revert this to an `object` parameter,
leaving it to the developer to find out what type of object is being
passed in, or an improvement would be to define an object type for a
`Walker_Nav_Menu_Data_Object` (likely extending WP_Post) that documents
all possible/acceptable properties that would be expected to be able to be
used in a walker.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57428>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list