Opened 12 years ago
Closed 12 years ago
#31805 closed defect (bug) (duplicate)
network menu page url
| Reported by: | dll1024 | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Networks and Sites | Version: | 4.1.1 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: | administration, multisite |
Description
i registered menu in network admin by:
add_action( 'network_admin_menu',...
and now i want to get url of that menu by using
menu_page_url(...
but this function will return blog admin url (invalid url) because in this line:
https://core.trac.wordpress.org/browser/tags/4.1.1/src/wp-admin/includes/plugin.php#L1476
only called admin_url function
i searched for another function, but i found nothing :|
Change History (3)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
I agree - there's definitely a case for updating that function. In the meantime, you can roll your own or use the following which works for me:
function network_menu_page_url($menu_slug, $echo = true) { global $_parent_pages; if ( isset( $_parent_pages[$menu_slug] ) ) { $parent_slug = $_parent_pages[$menu_slug]; if ( $parent_slug && ! isset( $_parent_pages[$parent_slug] ) ) { $url = network_admin_url( add_query_arg( 'page', $menu_slug, $parent_slug ) ); } else { $url = network_admin_url( 'admin.php?page=' . $menu_slug ); } } else { $url = ''; } $url = esc_url($url); if ( $echo ) echo $url; // --< return $url; }