Created
January 20, 2015 10:27
-
-
Save iamshanto/7eac27d86dff0dcd67e0 to your computer and use it in GitHub Desktop.
Wrodress multisite menu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$slot = 1; | |
function ra_wp_nav_menu_filter( $content, $args ) { | |
global $slot; | |
$locale = get_locale(); | |
$registered = get_registered_nav_menus(); | |
$current = array_slice( $registered, absint( $slot - 1 ), 1 ); | |
if( empty( $current ) || empty( $current[$args->theme_location] ) ) { | |
return $content; | |
} | |
if( is_main_site() ) { | |
set_site_transient('multisite_site_menu_'.$locale, $content); | |
} else { | |
$content = get_site_transient('multisite_site_menu_'.$locale); | |
} | |
return $content; | |
} | |
add_filter( 'wp_nav_menu_objects', 'ra_wp_nav_menu_filter', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment