[wp-trac] [WordPress Trac] #59365: Deprecated notice when calling get_admin_page_title() on some dashboard pages.

WordPress Trac noreply at wordpress.org
Wed Jul 10 23:06:01 UTC 2024


#59365: Deprecated notice when calling get_admin_page_title() on some dashboard
pages.
----------------------------+--------------------------------
 Reporter:  apedog          |       Owner:  (none)
     Type:  defect (bug)    |      Status:  new
 Priority:  normal          |   Milestone:  Awaiting Review
Component:  Administration  |     Version:
 Severity:  minor           |  Resolution:
 Keywords:  php81           |     Focuses:  php-compatibility
----------------------------+--------------------------------

Comment (by apedog):

 I'm sorry, but I need to revise my previous reply.
 While I did stumble across this issue when registering a settings page,
 **__the issue has nothing to do with registering settings.__**

 The issue can be easily reproduced with this line of code:
 {{{add_action( 'admin_init', 'get_admin_page_title' );}}}

 So this is an issue in core. Especially since `get_admin_page_title()`
 ''does'' return the correct string for the page being visited - even on
 core pages where said globals are null/not set.

 ie.
 {{{add_action( 'admin_init', fn() => wp_die( get_admin_page_title() )
 );}}}
 or (less destructively if using Query Monitor):
 {{{add_action( 'admin_init', fn() => QM::debug( get_admin_page_title() )
 );}}}
 will return the string "Available Tools" when visiting the Tools page.

 So function `get_admin_page_title()` works fine on core pages (there is no
 "doing it wrong" here). However core throws deprecated notices. I don't
 think this is an upstream issue after all.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59365#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list