[wp-trac] [WordPress Trac] #27888: Feature request: `get_current_admin_url()` and `get_current_admin_hook()`
WordPress Trac
noreply at wordpress.org
Sun Jan 18 12:21:24 UTC 2026
#27888: Feature request: `get_current_admin_url()` and `get_current_admin_hook()`
-------------------------------------------------+-------------------------
Reporter: Denis-de-Bernardy | Owner: lucatume
Type: feature request | Status: assigned
Priority: normal | Milestone: Awaiting
| Review
Component: Administration | Version: 3.9
Severity: normal | Resolution:
Keywords: good-first-bug has-patch has-unit- | Focuses:
tests | administration
-------------------------------------------------+-------------------------
Changes (by ozgursar):
* keywords: good-first-bug has-patch needs-testing has-unit-tests => good-
first-bug has-patch has-unit-tests
Comment:
== Test Report
=== Description
This report validates whether the indicated patch works as expected.
Patch tested: https://github.com/WordPress/wordpress-develop/pull/8266
=== Environment
- WordPress: 7.0-alpha-61215-src
- PHP: 8.2.29
- Server: nginx/1.29.4
- Database: mysqli (Server: 8.4.7 / Client: mysqlnd 8.2.29)
- Browser: Chrome 143.0.0.0
- OS: macOS
- Theme: Twenty Twenty-One 2.7
- MU Plugins: None activated
- Plugins:
* Code Snippets 3.9.4
* Test Reports 1.2.1
=== Steps to Reproduce
1. Using Code Snippets plugin or to the functions.php of the theme add the
following snippet to view the current admin page url and admin hook
{{{
// Add to admin bar
add_action( 'admin_bar_menu', function( $wp_admin_bar ) {
if ( ! is_admin() ) {
return;
}
$current_url = get_current_admin_page_url();
$current_hook = get_current_admin_hook();
// Parent menu item
$wp_admin_bar->add_node( array(
'id' => 'debug-info',
'title' => '🔍 Debug Info',
'href' => '#',
) );
// Current page URL
$wp_admin_bar->add_node( array(
'parent' => 'debug-info',
'id' => 'current-page-url',
'title' => '<strong>Page URL:</strong> ' . esc_html( $current_url
),
'href' => '#',
) );
// Current hook
$wp_admin_bar->add_node( array(
'parent' => 'debug-info',
'id' => 'current-hook',
'title' => '<strong>Hook:</strong> ' . esc_html( $current_hook ),
'href' => '#',
) );
}, 100 );
// Add some styling to make it more visible
add_action( 'admin_head', function() {
?>
<style>
#wp-admin-bar-debug-info > .ab-item {
background: #2271b1 !important;
color: white !important;
}
#wp-admin-bar-current-page-url .ab-item,
#wp-admin-bar-current-hook .ab-item {
font-family: monospace;
font-size: 12px;
}
</style>
<?php
} );
}}}
=== Actual Results
1. ✅ get_current_admin_page_url() and get_current_admin_hook() return
the expected output.
=== Additional Notes
- I had to write the PHP code above to be able to test the functionality
as no specific use case was provided for the test.
=== Supplemental Artifacts
[[Image(https://i.imgur.com/5Y5Vu0h.png)]]
Video:
https://files.catbox.moe/q87hhq.mp4
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27888#comment:20>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list