Save menu locations meta box via ajax. see #13378.

git-svn-id: http://svn.automattic.com/wordpress/trunk@14715 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-05-17 23:58:56 +00:00
parent f3992a551d
commit f02fddce86
5 changed files with 18 additions and 4 deletions

View File

@ -1103,6 +1103,14 @@ case 'menu-quick-search':
exit; exit;
break; break;
case 'menu-locations-save':
if ( ! current_user_can( 'edit_theme_options' ) )
die('-1');
if ( ! isset( $_POST['menu-locations' ] ) )
die('0');
set_theme_mod( 'nav_menu_locations', $_POST['menu-locations'] );
die('1');
break;
case 'meta-box-order': case 'meta-box-order':
check_ajax_referer( 'meta-box-order' ); check_ajax_referer( 'meta-box-order' );
$order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false; $order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false;

View File

@ -403,7 +403,6 @@ function wp_nav_menu_taxonomy_meta_boxes() {
*/ */
function wp_nav_menu_locations_meta_box() { function wp_nav_menu_locations_meta_box() {
$locations = get_registered_nav_menus(); $locations = get_registered_nav_menus();
$mods = get_nav_menu_locations();
$menus = wp_get_nav_menus(); $menus = wp_get_nav_menus();
$menu_locations = get_nav_menu_locations(); $menu_locations = get_nav_menu_locations();

View File

@ -329,7 +329,7 @@ var wpNavMenu;
}, },
attachAddMenuItemListeners : function() { attachAddMenuItemListeners : function() {
var form = $('#nav-menu-meta'); var form = $('#nav-menu-meta'), loc = form.find('#nav-menu-theme-locations');
form.find('.add-to-menu input').click(function(){ form.find('.add-to-menu input').click(function(){
$(this).trigger('wp-add-menu-item', [api.addMenuItemToBottom]); $(this).trigger('wp-add-menu-item', [api.addMenuItemToBottom]);
@ -341,6 +341,13 @@ var wpNavMenu;
form.find('.posttypediv, .taxonomydiv').bind('wp-add-menu-item', function(e, processMethod) { form.find('.posttypediv, .taxonomydiv').bind('wp-add-menu-item', function(e, processMethod) {
$(this).addSelectedToMenu( processMethod ); $(this).addSelectedToMenu( processMethod );
}); });
loc.find('input[type=submit]').click(function() {
loc.find('.waiting').show();
$.post( ajaxurl, loc.find('select').serialize() + '&action=menu-locations-save', function(r) {
loc.find('.waiting').hide();
});
return false;
});
}, },
attachQuickSearchListeners : function() { attachQuickSearchListeners : function() {

File diff suppressed because one or more lines are too long

View File

@ -393,7 +393,7 @@ function wp_default_scripts( &$scripts ) {
) ); ) );
// Custom Navigation // Custom Navigation
$scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", false, '20100515' ); $scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", false, '20100517' );
$scripts->localize( 'nav-menu', 'navMenuL10n', array( $scripts->localize( 'nav-menu', 'navMenuL10n', array(
'home' => _x('Home', 'nav menu home label'), 'home' => _x('Home', 'nav menu home label'),
'homeurl' => home_url('/'), 'homeurl' => home_url('/'),