Opened 11 years ago
Closed 11 years ago
#31805 closed defect (bug) (duplicate)
network menu page url
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 4.1.1 |
| Component: | Networks and Sites | Keywords: | |
| Focuses: | administration, multisite | Cc: |
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.
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; }