Skip to content

Instantly share code, notes, and snippets.

@DrewAPicture
Created March 22, 2013 08:14
Show Gist options
  • Save DrewAPicture/5219704 to your computer and use it in GitHub Desktop.
Save DrewAPicture/5219704 to your computer and use it in GitHub Desktop.
<?php
// From wp-admin/nav-menus.php
break;
case 'locations':
check_admin_referer( 'save-menu-locations', 'save-menu-locations-nonce', false );
// Get existing menu locations assignments
$locations = get_registered_nav_menus();
$menu_locations = get_nav_menu_locations();
// Merge new and existing menu locations if any new ones are set
if ( isset( $_POST['menu-locations'] ) ) {
$new_menu_locations = array_map( 'absint', $_POST['menu-locations'] );
$menu_locations = array_merge( $menu_locations, $new_menu_locations );
// Set menu locations
set_theme_mod( 'nav_menu_locations', $menu_locations );
}
// TODO: Add a message
break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment