WordPress.org

Make WordPress Core

Ticket #28226: 28226-plugin.php-2.diff

File 28226-plugin.php-2.diff, 1.2 KB (added by norcross, 6 years ago)

removes network check from existing menu_page_url, adds new network_menu_page_url

  • plugin.php

     
    14581458        return $url;
    14591459}
    14601460
     1461
     1462/**
     1463 * Get the url to access a particular menu page based on the slug it was registered with
     1464 * on the network admin in a multisite install.
     1465 *
     1466 * If the slug hasn't been registered properly no url will be returned
     1467 *
     1468 * @since 3.0.0
     1469 *
     1470 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
     1471 * @param bool $echo Whether or not to echo the url - default is true
     1472 * @return string the url
     1473 */
     1474function network_menu_page_url( $menu_slug, $echo = true ) {
     1475        global $_parent_pages;
     1476
     1477        if ( isset( $_parent_pages[$menu_slug] ) ) {
     1478                $parent_slug = $_parent_pages[$menu_slug];
     1479                if ( $parent_slug && ! isset( $_parent_pages[$parent_slug] ) ) {
     1480                        $url = network_admin_url( add_query_arg( 'page', $menu_slug, $parent_slug ) );
     1481                } else {
     1482                        $url = network_admin_url( 'admin.php?page=' . $menu_slug );
     1483                }
     1484        } else {
     1485                $url = '';
     1486        }
     1487
     1488        $url = esc_url( $url );
     1489
     1490        if ( $echo )
     1491                echo $url;
     1492
     1493        return $url;
     1494}
     1495
    14611496//
    14621497// Pluggable Menu Support -- Private
    14631498//