mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Menu tweaks. Save menu locations when saving the menu. Also, centralize theme support checks and add them to menu.php. Improve some branching. Remove some old JS vars, add a missing semicolon, etc. props koopersmith. see #13378.
git-svn-id: http://svn.automattic.com/wordpress/trunk@14831 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
78ba3b94b1
commit
f15cdc78cf
@ -509,7 +509,7 @@ var wpNavMenu;
|
|||||||
|
|
||||||
attachTabsPanelListeners : function() {
|
attachTabsPanelListeners : function() {
|
||||||
$('#menu-settings-column').bind('click', function(e) {
|
$('#menu-settings-column').bind('click', function(e) {
|
||||||
var selectAreaMatch, activePanel, panelId, wrapper, items,
|
var selectAreaMatch, panelId, wrapper, items,
|
||||||
target = $(e.target);
|
target = $(e.target);
|
||||||
|
|
||||||
if ( target.hasClass('nav-tab-link') ) {
|
if ( target.hasClass('nav-tab-link') ) {
|
||||||
@ -679,6 +679,12 @@ var wpNavMenu;
|
|||||||
},
|
},
|
||||||
|
|
||||||
eventOnClickMenuSave : function(clickedEl) {
|
eventOnClickMenuSave : function(clickedEl) {
|
||||||
|
var locs = '';
|
||||||
|
// Copy menu theme locations
|
||||||
|
$('#nav-menu-theme-locations select').each(function() {
|
||||||
|
locs += '<input type="hidden" name="' + this.name + '" value="' + $(this).val() + '" />';
|
||||||
|
});
|
||||||
|
$('#update-nav-menu').append( locs );
|
||||||
// Update menu item position data
|
// Update menu item position data
|
||||||
api.menuList.find('.menu-item-data-position').val( function(index) { return index + 1; } );
|
api.menuList.find('.menu-item-data-position').val( function(index) { return index + 1; } );
|
||||||
return true;
|
return true;
|
||||||
@ -759,9 +765,8 @@ var wpNavMenu;
|
|||||||
},
|
},
|
||||||
|
|
||||||
removeMenuItem : function(el) {
|
removeMenuItem : function(el) {
|
||||||
el = $(el)
|
el = $(el);
|
||||||
var children = el.childMenuItems(),
|
var children = el.childMenuItems();
|
||||||
that = this;
|
|
||||||
|
|
||||||
el.addClass('deleting').fadeOut( 350 , function() {
|
el.addClass('deleting').fadeOut( 350 , function() {
|
||||||
el.remove();
|
el.remove();
|
||||||
|
File diff suppressed because one or more lines are too long
@ -149,10 +149,12 @@ $menu[59] = array( '', 'read', 'separator2', '', 'wp-menu-separator' );
|
|||||||
if ( current_user_can( 'switch_themes') ) {
|
if ( current_user_can( 'switch_themes') ) {
|
||||||
$menu[60] = array( __('Appearance'), 'switch_themes', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'div' );
|
$menu[60] = array( __('Appearance'), 'switch_themes', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'div' );
|
||||||
$submenu['themes.php'][5] = array(__('Themes'), 'switch_themes', 'themes.php');
|
$submenu['themes.php'][5] = array(__('Themes'), 'switch_themes', 'themes.php');
|
||||||
|
if ( current_theme_supports( 'nav-menus' ) || current_theme_supports( 'widgets' ) )
|
||||||
$submenu['themes.php'][10] = array(__('Menus'), 'edit_theme_options', 'nav-menus.php');
|
$submenu['themes.php'][10] = array(__('Menus'), 'edit_theme_options', 'nav-menus.php');
|
||||||
} else {
|
} else {
|
||||||
$menu[60] = array( __('Appearance'), 'edit_theme_options', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'div' );
|
$menu[60] = array( __('Appearance'), 'edit_theme_options', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'div' );
|
||||||
$submenu['themes.php'][5] = array(__('Themes'), 'edit_theme_options', 'themes.php');
|
$submenu['themes.php'][5] = array(__('Themes'), 'edit_theme_options', 'themes.php');
|
||||||
|
if ( current_theme_supports( 'nav-menus' ) || current_theme_supports( 'widgets' ) )
|
||||||
$submenu['themes.php'][10] = array(__('Menus'), 'edit_theme_options', 'nav-menus.php' );
|
$submenu['themes.php'][10] = array(__('Menus'), 'edit_theme_options', 'nav-menus.php' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,9 @@ require_once( 'admin.php' );
|
|||||||
// Load all the nav menu interface functions
|
// Load all the nav menu interface functions
|
||||||
require_once( ABSPATH . 'wp-admin/includes/nav-menu.php' );
|
require_once( ABSPATH . 'wp-admin/includes/nav-menu.php' );
|
||||||
|
|
||||||
|
if ( ! current_theme_supports( 'nav-menus' ) && ! current_theme_supports( 'widgets' ) )
|
||||||
|
wp_die( __( 'Your theme does not support navigation menus or widgets.' ) );
|
||||||
|
|
||||||
// Permissions Check
|
// Permissions Check
|
||||||
if ( ! current_user_can('edit_theme_options') )
|
if ( ! current_user_can('edit_theme_options') )
|
||||||
wp_die( __( 'Cheatin’ uh?' ) );
|
wp_die( __( 'Cheatin’ uh?' ) );
|
||||||
@ -270,9 +273,11 @@ switch ( $action ) {
|
|||||||
case 'update':
|
case 'update':
|
||||||
check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' );
|
check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' );
|
||||||
|
|
||||||
|
// Update menu theme locations
|
||||||
|
set_theme_mod( 'nav_menu_locations', $_POST['menu-locations'] );
|
||||||
|
|
||||||
// Add Menu
|
// Add Menu
|
||||||
if ( 0 == $nav_menu_selected_id ) {
|
if ( 0 == $nav_menu_selected_id ) {
|
||||||
if ( current_theme_supports('nav-menus') || current_theme_supports('widgets') ) {
|
|
||||||
$new_menu_title = esc_html( $_POST['menu-name'] );
|
$new_menu_title = esc_html( $_POST['menu-name'] );
|
||||||
|
|
||||||
if ( $new_menu_title ) {
|
if ( $new_menu_title ) {
|
||||||
@ -292,7 +297,6 @@ switch ( $action ) {
|
|||||||
} else {
|
} else {
|
||||||
$messages[] = '<div id="message" class="error"><p>' . __('Please enter a valid menu name.') . '</p></div>';
|
$messages[] = '<div id="message" class="error"><p>' . __('Please enter a valid menu name.') . '</p></div>';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// update existing menu
|
// update existing menu
|
||||||
} else {
|
} else {
|
||||||
@ -425,8 +429,6 @@ require_once( 'admin-header.php' );
|
|||||||
echo $message . "\n";
|
echo $message . "\n";
|
||||||
endforeach;
|
endforeach;
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php if ( current_theme_supports('nav-menus') || current_theme_supports('widgets') ) : ?>
|
|
||||||
<div id="nav-menus-frame">
|
<div id="nav-menus-frame">
|
||||||
<div id="menu-settings-column" class="metabox-holder">
|
<div id="menu-settings-column" class="metabox-holder">
|
||||||
|
|
||||||
@ -517,7 +519,7 @@ require_once( 'admin-header.php' );
|
|||||||
</div><!--END #nav-menu-header-->
|
</div><!--END #nav-menu-header-->
|
||||||
<div id="post-body">
|
<div id="post-body">
|
||||||
<div id="post-body-content">
|
<div id="post-body-content">
|
||||||
<?php if ( is_nav_menu( $nav_menu_selected_id ) && ( current_theme_supports('nav-menus') || current_theme_supports('widgets') ) ) : ?>
|
<?php if ( is_nav_menu( $nav_menu_selected_id ) ) : ?>
|
||||||
<ul class="menu" id="menu-to-edit">
|
<ul class="menu" id="menu-to-edit">
|
||||||
<?php
|
<?php
|
||||||
$edit_markup = wp_get_nav_menu_to_edit( $nav_menu_selected_id );
|
$edit_markup = wp_get_nav_menu_to_edit( $nav_menu_selected_id );
|
||||||
@ -542,7 +544,6 @@ require_once( 'admin-header.php' );
|
|||||||
</div><!-- /#menu-management -->
|
</div><!-- /#menu-management -->
|
||||||
</div><!-- /#menu-management-liquid -->
|
</div><!-- /#menu-management-liquid -->
|
||||||
</div><!-- /#nav-menus-frame-->
|
</div><!-- /#nav-menus-frame-->
|
||||||
<?php endif; // if menus supported in current theme ?>
|
|
||||||
</div><!-- /.wrap-->
|
</div><!-- /.wrap-->
|
||||||
|
|
||||||
|
|
||||||
|
@ -385,7 +385,7 @@ function wp_default_scripts( &$scripts ) {
|
|||||||
) );
|
) );
|
||||||
|
|
||||||
// Custom Navigation
|
// Custom Navigation
|
||||||
$scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", false, '20100521' );
|
$scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", false, '20100524' );
|
||||||
$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('/'),
|
||||||
|
Loading…
Reference in New Issue
Block a user