class-walker-nav-menu-checklist.php strange way to set title
-
The class class-walker-nav-menu-checklist (spotlight on line 93 in WP 5.2.2) is trying to set the label of a page’s checkbox sending a
label
method to the currently walked WP_Post object.if ( ! empty( $item->label ) ) { $title = $item->label; [...]
$item
is an object of class WP_Post. WP_Post does not have a property or a method calledlabel
. So first question would be: why it is there?
Going further i see that WP_Post has implemented a magic getter__get()
which will try to reply -among a lot of other things- with a post meta namedlabel
attached to the post.The nice part is that we can deliberately “hijack” the WP admin interface naming a meta
label
.Example: https://cl.ly/c2055aea621d/Image%202019-07-09%20at%2011.48.07%20PM.png
Steps to reproduce:
* install wordpress
* activate a theme with menu support
*wp post create --post_title=TestPage --post_type=page --post_status=published
*wp post meta add N 'label' 'baz'
whereN
is the ID obtained from the previous command
*wp server
* go tohttps://localhost:8080/wp-admin/nav-menus.php
and watch to the widget reported in the example.I’m not sure if this is considered a bug. For sure I think it’s a pain and I let you imagine what a hell of debug it could be.
Any thought or advice?
Best,
Alessandro
The page I need help with: [log in to see the link]
- The topic ‘class-walker-nav-menu-checklist.php strange way to set title’ is closed to new replies.