Nav menu cleanups. Props nbachiyski. see #11817

git-svn-id: http://svn.automattic.com/wordpress/trunk@13375 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-02-24 18:52:54 +00:00
parent a762587cca
commit 12f9c6113e
10 changed files with 189 additions and 273 deletions

File diff suppressed because one or more lines are too long

View File

@ -161,6 +161,3 @@ img.remove, img.edit { cursor: pointer; margin: 0 5px 0 0; }
.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.ui-widget-overlay { background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .60;filter:Alpha(Opacity=60); }
.ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .60;filter:Alpha(Opacity=60); -moz-border-radius: 8px; -webkit-border-radius: 8px; }
#reset_wp_menu { background:#c77 none !important;color:white!important;text-shadow:0 1px 0 #555 !important;}

View File

@ -29,27 +29,27 @@ function wp_nav_menu_get_pages($counter, $type) {
//GET all pages
$pages_array = get_pages($pages_args);
$intCounter = $counter;
$parentli = $intCounter;
$items_counter = $counter;
$parentli = $items_counter;
if ( !$pages_array ) {
echo 'Not Found';
return $intCounter;
echo __('Not Found');
return $items_counter;
}
// Display Loop
foreach ( $pages_array as $post ) {
if ( $post->post_parent == 0 ) {
$post = wp_setup_nav_menu_item($post, 'page', $intCounter);
$post = wp_setup_nav_menu_item($post, 'page', $items_counter);
if ( $type == 'menu' ) {
?>
<li id="menu-<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>">
<li id="menu-<?php echo $items_counter; ?>" value="<?php echo $items_counter; ?>">
<?php
wp_print_nav_menu_item($post, 'menu', $intCounter);
wp_print_nav_menu_item($post, 'menu', $items_counter);
$parentli = $post->ID;
$intCounter++;
$intCounter = wp_custom_navigation_default_sub_items($post->ID, $intCounter, $parentli, 'pages', 'menu');
$items_counter++;
$items_counter = wp_custom_navigation_default_sub_items($post->ID, $items_counter, $parentli, 'pages', 'menu');
?>
</li>
@ -61,8 +61,8 @@ function wp_nav_menu_get_pages($counter, $type) {
<?php
wp_print_nav_menu_item($post, 'default');
$parentli = $post->ID;
$intCounter++;
$intCounter = wp_nav_menu_sub_items($post->ID, $intCounter, $parentli, 'pages', 'default');
$items_counter++;
$items_counter = wp_nav_menu_sub_items($post->ID, $items_counter, $parentli, 'pages', 'default');
?>
</li>
@ -71,7 +71,7 @@ function wp_nav_menu_get_pages($counter, $type) {
}
}
return $intCounter;
return $items_counter;
}
// Outputs All Categories and Sub Items
@ -90,30 +90,30 @@ function wp_nav_menu_get_categories($counter, $type) {
'number' => '',
'pad_counts' => false );
$intCounter = $counter;
$items_counter = $counter;
// Get all categories
$categories_array = get_categories($category_args);
if ( !$categories_array ) {
_e('Not Found');
return $intCounter;
return $items_counter;
}
// Display Loop
foreach ( $categories_array as $cat_item ) {
if ( $cat_item->parent == 0 ) {
$cat_item = wp_setup_nav_menu_item($cat_item, 'category', $intCounter);
$cat_item = wp_setup_nav_menu_item($cat_item, 'category', $items_counter);
// Custom Menu
if ( $type == 'menu' ) {
?>
<li id="menu-<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>">
<li id="menu-<?php echo $items_counter; ?>" value="<?php echo $items_counter; ?>">
<?php
wp_print_nav_menu_item($cat_item, 'menu');
$parentli = $cat_item->cat_ID;
$intCounter++;
$intCounter = wp_nav_menu_sub_items($cat_item->cat_ID, $intCounter, $parentli, 'categories', 'menu');
$items_counter++;
$items_counter = wp_nav_menu_sub_items($cat_item->cat_ID, $items_counter, $parentli, 'categories', 'menu');
?>
</li>
@ -126,8 +126,8 @@ function wp_nav_menu_get_categories($counter, $type) {
<?php
wp_print_nav_menu_item($cat_item, 'default');
$parentli = $cat_item->cat_ID;
$intCounter++;
$intCounter = wp_nav_menu_sub_items($cat_item->cat_ID, $intCounter, $parentli, 'categories', 'default');
$items_counter++;
$items_counter = wp_nav_menu_sub_items($cat_item->cat_ID, $items_counter, $parentli, 'categories', 'default');
?>
</li>
@ -137,13 +137,13 @@ function wp_nav_menu_get_categories($counter, $type) {
}
}
return $intCounter;
return $items_counter;
}
//RECURSIVE Sub Menu Items of default categories and pages
function wp_nav_menu_sub_items($childof, $intCounter, $parentli, $type, $output_type) {
function wp_nav_menu_sub_items($childof, $items_counter, $parentli, $type, $output_type) {
$counter = $intCounter;
$counter = $items_counter;
// Custom Menu
if ( $output_type == 'menu' ) {

View File

@ -115,7 +115,7 @@ function updatepostdata()
jQuery(this).find('dl > dt > span > #remove' + j).attr('onClick', 'removeitem(' + i + ')');
jQuery(this).find('dl > dt > span > #remove' + j).attr('id','remove' + i);
jQuery('#licount').attr('value',i);
jQuery('#li-count').attr('value',i);
});
@ -142,16 +142,16 @@ function appendToList(templatedir,additemtype,itemtext,itemurl,itemid,itemparent
var inputdescription = '';
var inputicon = '';
if (additemtype == 'Custom')
if (additemtype == navMenuL10n.custom)
{
inputvaluevarname = document.getElementById('custom_menu_item_name').value;
inputvaluevarurl = document.getElementById('custom_menu_item_url').value;
inputvaluevarname = document.getElementById('custom-menu-item-name').value;
inputvaluevarurl = document.getElementById('custom-menu-item-url').value;
inputitemid = '';
inputparentid = '';
inputlinktype = 'custom';
inputdescription = document.getElementById('custom_menu_item_description').value;
inputdescription = '';
}
else if (additemtype == 'Page')
else if (additemtype == navMenuL10n.page)
{
inputvaluevarname = htmlentities(itemtext.toString());
inputvaluevarurl = itemurl.toString();
@ -161,7 +161,7 @@ function appendToList(templatedir,additemtype,itemtext,itemurl,itemid,itemparent
inputdescription = htmlentities(itemdescription.toString());
}
else if (additemtype == 'Category')
else if (additemtype == navMenuL10n.category)
{
inputvaluevarname = htmlentities(itemtext.toString());
inputvaluevarurl = itemurl.toString();

File diff suppressed because one or more lines are too long

View File

@ -31,25 +31,25 @@ require_once(ABSPATH . 'wp-admin/includes/nav-menu.php');
function wp_reset_nav_menu() {
wp_nav_menu_setup(true);
return true;
}
$messagesdiv = '';
$messages_div = '';
$menu_id_in_edit = 0;
$updated = false;
$advanced_option_descriptions = 'no';
// Check which menu is selected and if menu is in edit already
if ( isset( $_GET['edit_menu'] ) ) {
$menu_selected_id = (int) $_GET['edit_menu'];
if ( isset( $_GET['edit-menu'] ) ) {
$menu_selected_id = (int) $_GET['edit-menu'];
$updated = true;
} elseif ( isset( $_POST[ 'menu_id_in_edit' ] ) ) {
$menu_selected_id = (int) $_POST[ 'menu_id_in_edit' ];
} elseif ( isset( $_POST[ 'menu-id-in-edit' ] ) ) {
$menu_selected_id = (int) $_POST[ 'menu-id-in-edit' ];
} else {
$menu_selected_id = 0;
}
if ( isset( $_POST[ 'delete_menu' ] ) && $menu_selected_id > 0 ) {
if ( isset( $_POST[ 'delete-menu' ] ) && $menu_selected_id > 0 ) {
wp_delete_nav_menu( $menu_selected_id );
$menu_selected_id = 0;
$updated = true;
@ -70,52 +70,51 @@ if ( $menu_selected_id > 0 ) {
}
}
if ( isset( $_POST['licount'] ) )
$postCounter = $_POST['licount'];
if ( isset( $_POST['li-count'] ) )
$post_counter = $_POST['li-count'];
else
$postCounter = 0;
$post_counter = 0;
// Create a new menu. Menus are stored as terms in the 'menu' taxonomy.
if ( isset( $_POST['add_menu'] ) && ! $updated ) {
update_option( 'wp_custom_nav_menu', $_POST['enable_wp_menu'] ); // Do we need this?
$insert_menu_name = $_POST['add_menu_name'];
if ( isset( $_POST['add-menu'] ) && ! $updated ) {
$insert_menu_name = $_POST['add-menu-name'];
if ( $insert_menu_name != '' ) {
$menu = wp_create_nav_menu($insert_menu_name);
if ( is_wp_error($menu) ) {
$messagesdiv = '<div id="message" class="error fade below-h2"><p>' . esc_html( $menu->get_error_message() ) . '</p></div>';
if ( $insert_menu_name ) {
$menu = wp_create_nav_menu( $insert_menu_name );
if ( is_wp_error( $menu ) ) {
$messages_div = '<div id="message" class="error fade below-h2"><p>' . $menu->get_error_message() . '</p></div>';
} else {
$custom_menus[$menu->term_id] = $menu;
$menu_selected_id = $menu->term_id;
$menu_id_in_edit = $menu_selected_id;
$menu_title = $menu->name;
$messagesdiv = '<div id="message" class="updated fade below-h2"><p>' . esc_html( sprintf( __('"%s" menu has been created!'), $menu->name ) ) . '</p></div>';
$postCounter = 0;
$messages_div = '<div id="message" class="updated fade below-h2"><p>' . sprintf( __('&#8220;%s&#8221; menu has been created.'), esc_html( $menu->name ) ) . '</p></div>';
$post_counter = 0;
}
} else {
$messagesdiv = '<div id="message" class="error fade below-h2"><p>' . __('Please enter a valid menu name.') . '</p></div>';
$messages_div = '<div id="message" class="error fade below-h2"><p>' . __('Please enter a valid menu name.') . '</p></div>';
}
$updated = true;
}
if ( $postCounter > 0 && $menu_selected_id > 0 && ! $updated ) {
if ( $post_counter > 0 && $menu_selected_id > 0 && ! $updated ) {
$menu_items = wp_get_nav_menu_items( $menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID') );
$parent_menu_ids = array();
// Loop through all POST variables
for ( $k = 1; $k <= $postCounter; $k++ ) {
if (isset($_POST['dbid'.$k])) { $db_id = $_POST['dbid'.$k]; } else { $db_id = 0; }
if (isset($_POST['postmenu'.$k])) { $object_id = $_POST['postmenu'.$k]; } else { $object_id = 0; }
if (isset($_POST['parent'.$k])) { $parent_id = $_POST['parent'.$k]; } else { $parent_id = 0; }
if (isset($_POST['title'.$k])) { $custom_title = $_POST['title'.$k]; } else { $custom_title = ''; }
if (isset($_POST['linkurl'.$k])) { $custom_linkurl = $_POST['linkurl'.$k]; } else { $custom_linkurl = ''; }
if (isset($_POST['description'.$k])) { $custom_description = $_POST['description'.$k]; } else { $custom_description = ''; }
for ( $k = 1; $k <= $post_counter; $k++ ) {
$db_id = isset( $_POST['dbid'.$k] )? $_POST['dbid'.$k] : 0;
$object_id = isset( $_POST['postmenu'.$k] )? $_POST['postmenu'.$k] : 0;
$parent_id = isset( $_POST['parent'.$k] )? $_POST['parent'.$k] : 0;
$custom_title = isset( $_POST['title'.$k] )? $_POST['title'.$k] : '';
$custom_linkurl = isset( $_POST['linkurl'.$k] )? $_POST['linkurl'.$k] : '';
$custom_description = isset( $_POST['description'.$k] )? $_POST['description'.$k] : '';
// doesn't seem to be used by UI
if (isset($_POST['icon'.$k])) { $icon = $_POST['icon'.$k]; } else { $icon = 0; }
if (isset($_POST['position'.$k])) { $position = $_POST['position'.$k]; } else { $position = 0; }
if (isset($_POST['linktype'.$k])) { $linktype = $_POST['linktype'.$k]; } else { $linktype = 'custom'; }
if (isset($_POST['anchortitle'.$k])) { $custom_anchor_title = $_POST['anchortitle'.$k]; } else { $custom_anchor_title = $custom_title; }
if (isset($_POST['newwindow'.$k])) { $new_window = $_POST['newwindow'.$k]; } else { $new_window = 0; }
$icon = isset( $_POST['icon'.$k] )? $_POST['icon'.$k] : 0;
$position = isset( $_POST['position'.$k] )? $_POST['position'.$k] : 0;
$linktype = isset( $_POST['linktype'.$k] )? $_POST['linktype'.$k] : 'custom';
$custom_anchor_title = isset( $_POST['anchortitle'.$k] )? $_POST['anchortitle'.$k] : $custom_title;
$new_window = isset( $_POST['newwindow'.$k] )? $_POST['newwindow'.$k] : 0;
$post = array( 'post_status' => 'publish', 'post_type' => 'nav_menu_item', 'post_author' => $user_ID,
'ping_status' => 0, 'post_parent' => 0, 'menu_order' => $position,
@ -125,8 +124,8 @@ if ( $postCounter > 0 && $menu_selected_id > 0 && ! $updated ) {
$post['post_content_filtered'] = '_blank';
else
$post['post_content_filtered'] = '';
if ( $parent_id > 0 && isset( $parent_menu_ids[ $parent_id ] ) )
$post[ 'post_parent' ] = $parent_menu_ids[ $parent_id ];
if ( $parent_id > 0 && isset( $parent_menu_ids[$parent_id] ) )
$post['post_parent'] = $parent_menu_ids[$parent_id];
// New menu item
if ( $db_id == 0 ) {
@ -138,16 +137,15 @@ if ( $postCounter > 0 && $menu_selected_id > 0 && ! $updated ) {
}
$parent_menu_ids[ $k ] = $db_id;
update_post_meta($db_id, 'menu_type', $linktype);
update_post_meta($db_id, 'object_id', $object_id);
update_post_meta( $db_id, 'menu_type', $linktype );
update_post_meta( $db_id, 'object_id', $object_id );
}
if ( !empty( $menu_items ) ) {
foreach ( array_keys( $menu_items ) as $menu_id ) {
wp_delete_post( $menu_id );
}
}
// DISPLAY SUCCESS MESSAGE IF POST CORRECT
$messagesdiv = '<div id="message" class="updated fade below-h2"><p>' . __('The menu has been updated.') . '</p></div>';
$messages_div = '<div id="message" class="updated fade below-h2"><p>' . __('The menu has been updated.') . '</p></div>';
}
?>
@ -155,51 +153,48 @@ if ( $postCounter > 0 && $menu_selected_id > 0 && ! $updated ) {
<?php screen_icon(); ?>
<h2><?php esc_html_e('Menus') ?></h2>
<form onsubmit="updatepostdata()" action="<?php echo admin_url( 'nav-menus.php' ); ?>" method="post" enctype="multipart/form-data">
<?php if ( ! empty( $custom_menus ) && count( $custom_menus ) > 1 ) { ?>
<?php if ( ! empty( $custom_menus ) && count( $custom_menus ) > 1 ): ?>
<ul class="subsubsub">
<?php
foreach ( $custom_menus as $menu ) {
$sep = end($custom_menus) == $menu ? '' : ' | ';
// $menu_term = get_term( $menu, 'nav_menu' );
$sep = end( $custom_menus ) == $menu ? '' : ' | ';
if ( ( $menu_id_in_edit == $menu->term_id ) || ( $menu_selected_id == $menu->term_id ) ) { ?>
<li><a href='nav-menus.php?edit_menu=<?php echo esc_attr($menu->term_id); ?>' class="current"><?php echo esc_html( $menu->name ); ?></a><?php echo $sep; ?></li>
<li><a href='nav-menus.php?edit-menu=<?php echo esc_attr($menu->term_id); ?>' class="current"><?php echo esc_html( $menu->name ); ?></a><?php echo $sep; ?></li>
<?php } else { ?>
<li><a href='nav-menus.php?edit_menu=<?php echo esc_attr($menu->term_id); ?>'><?php echo esc_html( $menu->name ); ?></a><?php echo $sep; ?></li>
<li><a href='nav-menus.php?edit-menu=<?php echo esc_attr($menu->term_id); ?>'><?php echo esc_html( $menu->name ); ?></a><?php echo $sep; ?></li>
<?php }
}
?>
</ul>
<div class="clear"></div>
<?php } ?>
<?php endif ?>
<div class="hide-if-js error"><p><?php _e('You do not have JavaScript enabled in your browser. Please enable it to access the Menus functionality.'); ?></p></div>
<div class="hide-if-no-js">
<div id="pages-left">
<div class="inside">
<?php if ( ! empty( $custom_menus ) ) : ?>
<?php echo $messagesdiv; ?>
<?php echo $messages_div; ?>
<input type="hidden" name="licount" id="licount" value="0" />
<input type="hidden" name="menu_id_in_edit" id="menu_id_in_edit" value="<?php echo esc_attr($menu_selected_id); ?>" />
<input type="hidden" name="li-count" id="li-count" value="0" />
<input type="hidden" name="menu-id-in-edit" id="menu-id-in-edit" value="<?php echo esc_attr( $menu_selected_id ); ?>" />
<div class="sidebar-name">
<div class="sidebar-name-arrow">
<br/>
</div>
<h3><?php echo esc_html($menu_title); ?></h3>
<h3><?php echo esc_html( $menu_title ); ?></h3>
</div>
<div id="nav-container">
<ul id="custom-nav">
<?php
//DISPLAY existing menu
<?php
if ( $menu_selected_id > 0 ) {
wp_print_nav_menu( 'type=backend&name='.$menu_title.'&id='.$menu_selected_id );
wp_print_nav_menu( array( 'type' => 'backend', 'name' => $menu_title, 'id' => $menu_selected_id ) );
}
?>
?>
</ul>
</div><!-- /#nav-container -->
@ -209,7 +204,7 @@ if ( $postCounter > 0 && $menu_selected_id > 0 && ! $updated ) {
updatepostdata();
</script>
<input id="save_bottom" name="save_bottom" type="submit" value="<?php esc_attr_e('Save All Changes'); ?>" />
<input id="delete_menu" name="delete_menu" type="submit" value="<?php esc_attr_e('Delete This Menu'); ?>" />
<input id="delete-menu" name="delete-menu" type="submit" value="<?php esc_attr_e('Delete This Menu'); ?>" />
</p>
<?php else : ?>
@ -227,128 +222,71 @@ if ( $postCounter > 0 && $menu_selected_id > 0 && ! $updated ) {
<div class="widget-holder">
<span>
<input id="add_menu_name" name="add_menu_name" type="text" value="" />
<input id="add_menu" type="submit" value="<?php esc_attr_e('Add Menu'); ?>" name="add_menu" class="button" />
<input id="add-menu-name" name="add-menu-name" type="text" value="" />
<input id="add-menu" type="submit" value="<?php esc_attr_e('Add Menu'); ?>" name="add-menu" class="button" />
</span>
</div>
</div><!-- /.widgets-holder-wrap -->
<?php /* ?>
<?php $advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options'); ?>
<div class="widgets-holder-wrap" style="display:none;">
<div class="sidebar-name">
<div class="sidebar-name-arrow"></div>
<h3><?php esc_html_e('Top Level Menu Descriptions'); ?></h3>
</div>
<div class="widget-holder">
<span><?php _e('Display Descriptions in Top Level Menu?'); ?></span>
<?php
// UPDATE and DISPLAY Menu Description Option
if ( isset($_POST['menu-descriptions']) ) {
if ( !isset($_POST['switch_menu']) ) {
$menu_options_to_edit = $_POST['menu_id_in_edit'];
update_option('wp_settings_custom_nav_'.$menu_options_to_edit.'_descriptions',$_POST['menu-descriptions']);
}
}
if ( $menu_id_in_edit > 0 )
$checkedraw = get_option('wp_settings_custom_nav_'.$menu_id_in_edit.'_descriptions');
else
$checkedraw = get_option('wp_settings_custom_nav_'.$menu_selected_id.'_descriptions');
$checked = strtolower($checkedraw);
if ( $advanced_option_descriptions == 'no' )
$checked = 'no';
?>
<span class="checkboxes">
<label><?php _e('Yes'); ?></label><input type="radio" name="menu-descriptions" value="yes" <?php if ($checked=='yes') { echo 'checked="checked"'; } ?> />
<label><?php _e('No'); ?></label><input type="radio" name="menu-descriptions" value="no" <?php if ($checked=='yes') { } else { echo 'checked="checked"'; } ?> />
</span><!-- /.checkboxes -->
</form>
<div class="fix"></div>
</div>
</div><!-- /.widgets-holder-wrap -->
<?php */ ?>
<div class="widgets-holder-wrap">
<div class="sidebar-name">
<div class="sidebar-name-arrow"></div>
<h3><?php esc_html_e('Add an Existing Page'); ?></h3>
</div>
<div class="widget-holder">
<?php
$pages_args = array(
'child_of' => 0,
'sort_order' => 'ASC',
'sort_column' => 'post_title',
'hierarchical' => 1,
'exclude' => '',
'include' => '',
'meta_key' => '',
'meta_value' => '',
'authors' => '',
'parent' => -1,
'exclude_tree' => '',
'number' => '',
'offset' => 0 );
//GET all pages
$pages_array = get_pages($pages_args);
$page_name = '';
//CHECK if pages exist
if ( $pages_array ) {
foreach ( $pages_array as $post ) {
//Add page name to
$page_name .= htmlentities($post->post_title).'|';
}
} else {
$page_name = __('No pages available');
}
?>
<script>
<?php
$pages_args = array(
'child_of' => 0,
'sort_order' => 'ASC',
'sort_column' => 'post_title',
'hierarchical' => 1,
'exclude' => '',
'include' => '',
'meta_key' => '',
'meta_value' => '',
'authors' => '',
'parent' => -1,
'exclude_tree' => '',
'number' => '',
'offset' => 0
);
$page_name = '';
$pages_array = get_pages($pages_args);
if ( $pages_array ) {
foreach ( $pages_array as $post ) {
$page_name .= $post->post_title . '|';
}
} else {
$page_name = __('No pages available');
}
?>
<script type="text/javascript" charset="<?php bloginfo('charset'); ?>">
jQuery(document).ready(function(){
//GET PHP pages
var dataposts = "<?php echo esc_js($page_name); ?>".split("|");
//Set autocomplete
jQuery("#page-search").autocomplete(dataposts);
//Handle autocomplete result
var posts = "<?php echo esc_js( $page_name ); ?>".split("|");
jQuery("#page-search").autocomplete(posts);
jQuery("#page-search").result(function(event, data, formatted) {
jQuery('#existing-pages').css('display','block');
jQuery("#existing-pages dt:contains('" + data + "')").css("display", "block");
jQuery('#show-pages').hide();
jQuery('#hide-pages').show();
});
jQuery('#existing-pages').css('display','none');
});
</script>
<input type="text" onfocus="jQuery('#page-search').attr('value','');" id="page-search" value="<?php esc_attr_e('Search Pages'); ?>" />
<a id="show-pages" style="cursor:pointer;" onclick="jQuery('#existing-pages').css('display','block');jQuery('#page-search').attr('value','');jQuery('#existing-pages dt').css('display','block');jQuery('#show-pages').hide();jQuery('#hide-pages').show();">View All</a>
<a id="hide-pages" style="cursor:pointer;" onclick="jQuery('#existing-pages').css('display','none');jQuery('#page-search').attr('value','Search Pages');jQuery('#existing-pages dt').css('display','none');jQuery('#show-pages').show();jQuery('#hide-pages').hide();">Hide All</a>
<a id="show-pages" style="cursor:pointer;" onclick="jQuery('#existing-pages').css('display','block');jQuery('#page-search').attr('value','');jQuery('#existing-pages dt').css('display','block');jQuery('#show-pages').hide();jQuery('#hide-pages').show();"><?php _e('View All'); ?></a>
<a id="hide-pages" style="cursor:pointer;" onclick="jQuery('#existing-pages').css('display','none');jQuery('#page-search').attr('value','Search Pages');jQuery('#existing-pages dt').css('display','none');jQuery('#show-pages').show();jQuery('#hide-pages').hide();"><?php _e('Hide All'); ?></a>
<script type="text/javascript">
jQuery('#hide-pages').hide();
</script>
<ul id="existing-pages" class="list">
<?php
$intCounter = 0;
//Get default Pages
$intCounter = wp_nav_menu_get_pages($intCounter,'default');
?>
<?php
$items_counter = wp_nav_menu_get_pages( 0,'default' );
?>
</ul>
<div class="fix"></div>
</div>
</div><!-- /.widgets-holder-wrap -->
@ -359,76 +297,59 @@ if ( $postCounter > 0 && $menu_selected_id > 0 && ! $updated ) {
</div>
<div class="widget-holder">
<?php
// Custom GET categories query
// @todo Use API
$categories = $wpdb->get_results("SELECT term_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'category' ORDER BY term_id ASC");
$cat_name = '';
//CHECK for results
if ( $categories ) {
foreach ( $categories as $category ) {
$cat_id = $category->term_id;
$cat_args = array(
'orderby' => 'name',
'include' => $cat_id,
'hierarchical' => 1,
'order' => 'ASC'
);
$category_names=get_categories($cat_args);
if ( isset($category_names[0]->name) ) {
// Add category name to data string
$cat_name .= htmlentities($category_names[0]->name).'|';
}
}
} else {
$cat_name = __('No categories available');
}
?>
<script>
<?php
// Custom GET categories query
// @todo Use API
$categories = $wpdb->get_results("SELECT term_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'category' ORDER BY term_id ASC");
$cat_name = '';
if ( $categories ) {
foreach ( $categories as $category ) {
$cat_id = $category->term_id;
$cat_args = array(
'orderby' => 'name',
'include' => $cat_id,
'hierarchical' => 1,
'order' => 'ASC',
);
$category_names = get_categories( $cat_args );
if ( isset( $category_names[0]->name ) ) {
$cat_name .= htmlentities( $category_names[0]->name ).'|';
}
}
} else {
$cat_name = __('No categories available');
}
?>
<script type="text/javascript" charset="<?php bloginfo('charset'); ?>">
jQuery(document).ready(function(){
//GET PHP categories
var datacats = "<?php echo esc_js($cat_name); ?>".split("|");
//Set autocomplete
jQuery("#cat-search").autocomplete(datacats);
//Handle autocomplete result
var categories = "<?php echo esc_js($cat_name); ?>".split("|");
jQuery("#cat-search").autocomplete(categories);
jQuery("#cat-search").result(function(event, data, formatted) {
jQuery('#existing-categories').css('display','block');
jQuery("#existing-categories dt:contains('" + data + "')").css("display", "block");
jQuery('#show-cats').hide();
jQuery('#hide-cats').show();
});
jQuery('#existing-categories').css('display','none');
});
</script>
<input type="text" onfocus="jQuery('#cat-search').attr('value','');" id="cat-search" value="<?php esc_attr_e('Search Categories'); ?>" />
<a id="show-cats" style="cursor:pointer;" onclick="jQuery('#existing-categories').css('display','block');jQuery('#cat-search').attr('value','');jQuery('#existing-categories dt').css('display','block');jQuery('#show-cats').hide();jQuery('#hide-cats').show();">View All</a>
<a id="hide-cats" style="cursor:pointer;" onclick="jQuery('#existing-categories').css('display','none');jQuery('#cat-search').attr('value','Search Categories');jQuery('#existing-categories dt').css('display','none');jQuery('#show-cats').show();jQuery('#hide-cats').hide();">Hide All</a>
<a id="show-cats" style="cursor:pointer;" onclick="jQuery('#existing-categories').css('display','block');jQuery('#cat-search').attr('value','');jQuery('#existing-categories dt').css('display','block');jQuery('#show-cats').hide();jQuery('#hide-cats').show();"><?php _e('View All'); ?></a>
<a id="hide-cats" style="cursor:pointer;" onclick="jQuery('#existing-categories').css('display','none');jQuery('#cat-search').attr('value','Search Categories');jQuery('#existing-categories dt').css('display','none');jQuery('#show-cats').show();jQuery('#hide-cats').hide();"><?php _e('Hide All'); ?></a>
<script type="text/javascript">
jQuery('#hide-cats').hide();
</script>
<ul id="existing-categories" class="list">
<?php
// Get default Categories
$intCounter = wp_nav_menu_get_categories($intCounter, 'default');
?>
<?php
$items_counter = wp_nav_menu_get_categories( $items_counter, 'default' );
?>
</ul>
<div class="fix"></div>
</div>
</div><!-- /.widgets-holder-wrap -->
@ -438,15 +359,15 @@ if ( $postCounter > 0 && $menu_selected_id > 0 && ! $updated ) {
<h3><?php esc_html_e('Add a Custom Url'); ?></h3>
</div>
<div class="widget-holder">
<input id="custom_menu_item_url" type="text" value="http://" />
<label><?php _e('URL'); ?></label><br />
<?php $templatedir = get_bloginfo('url'); ?>
<input type="hidden" id="templatedir" value="<?php echo esc_attr($templatedir); ?>" />
<input id="custom_menu_item_name" type="text" value="Menu Item" onfocus="jQuery('#custom_menu_item_name').attr('value','');" />
<label><?php _e('Menu Text'); ?></label><br />
<input id="custom-menu-item-url" type="text" value="http://" />
<label for="custom-menu-item-url"><?php _e('URL'); ?></label><br />
<?php $template_dir = get_bloginfo('url'); ?>
<input type="hidden" id="template-dir" value="<?php echo esc_attr($template_dir); ?>" />
<input id="custom-menu-item-name" type="text" value="<?php echo esc_attr( __('Menu Item') ); ?>" onfocus="jQuery('#custom-menu-item-name').attr('value','');" />
<label for="custom-menu-item-name"><?php _e('Menu Text'); ?></label><br />
<input id="custom_menu_item_description" type="text" value="<?php esc_attr_e('A description'); ?>" <?php if ($advanced_option_descriptions == 'no') { ?>style="display:none;"<?php } ?> onfocus="jQuery('#custom_menu_item_description').attr('value','');" />
<label <?php if ($advanced_option_descriptions == 'no') { ?>style="display:none;"<?php } ?> ><?php _e('Description'); ?></label>
<a class="addtomenu" onclick="appendToList('<?php echo $templatedir; ?>','Custom','','','','0','');jQuery('#custom_menu_item_name').attr('value','Menu Item');jQuery('#custom_menu_item_description').attr('value','A description');"><?php _e('Add to menu'); ?></a>
<a class="addtomenu" onclick="appendToList('<?php echo $template_dir; ?>','<?php echo esc_js( _x('Custom', 'menu nav item type') ); ?>','','','','0','');jQuery('#custom-menu-item-name').attr('value','<?php echo esc_js( __('Menu Item') ); ?>');jQuery('#custom_menu_item_description').attr('value','<?php echo esc_js( __('A description') ); ?>');"><?php _e('Add to menu'); ?></a>
<div class="fix"></div>
</div>
</div><!-- /.widgets-holder-wrap -->
@ -455,7 +376,7 @@ if ( $postCounter > 0 && $menu_selected_id > 0 && ! $updated ) {
</div>
<div id="dialog-confirm" style="display:none;" title="<?php esc_attr_e('Edit Menu Item'); ?>">
</label><input id="edittitle" type="text" name="edittitle" value="" /><label class="editlabel" for="edittitle"><?php _e('Menu Title'); ?></label><br />
<input id="edittitle" type="text" name="edittitle" value="" /><label class="editlabel" for="edittitle"><?php _e('Menu Title'); ?></label><br />
<input id="editlink" type="text" name="editlink" value="" /><label class="editlabel" for="editlink"><?php _e('URL'); ?></label><br />
<input id="editanchortitle" type="text" name="editanchortitle" value="" /><label class="editlabel" for="editanchortitle"><?php _e('Link Title'); ?></label><br />
<select id="editnewwindow" name="editnewwindow">
@ -467,4 +388,4 @@ if ( $postCounter > 0 && $menu_selected_id > 0 && ! $updated ) {
<?php
include("admin-footer.php");
include("admin-footer.php");

View File

@ -1120,18 +1120,8 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
<ul class="custom-nav">
<?php
}
?>
<?php
//DISPLAY custom navigation menu
if ( get_option('wp_custom_nav_menu') == 'true' )
wp_nav_menu( array('id' => $navmenu, 'name' => $wp_custom_nav_menu_name, 'desc' => $navwidgetdescription, 'format' => 'widget') );
?>
<?php
//DEVELOPER settings enabled
wp_nav_menu( array('id' => $navmenu, 'name' => $wp_custom_nav_menu_name, 'desc' => $navwidgetdescription, 'format' => 'widget') );
//DEVELOPER settings enabled
if ( $navdeveloper == 'yes' ) {
//DISPLAY Custom UL
if ( $navul == 'yes' ) {

View File

@ -104,7 +104,7 @@ function wp_print_nav_menu_item($menu_item, $context, $args = array() ) {
<?php if ( 'backend' == $context ) { ?>
<a><span class=""></span></a>
<?php } else { ?>
<a class="hide" href="<?php echo $menu_item->link; ?>"><?php echo $menu_item->title; ?></a>
<a class="hide" href="<?php echo $menu_item->link; ?>"><?php echo esc_html( $menu_item->title ); ?></a>
<?php } ?>
<input type="hidden" name="dbid<?php echo $menu_item->menu_order; ?>" id="dbid<?php echo $menu_item->menu_order; ?>" value="<?php echo $menu_item->ID; ?>" />
<input type="hidden" name="postmenu<?php echo $menu_item->menu_order; ?>" id="postmenu<?php echo $menu_item->menu_order; ?>" value="<?php echo esc_attr( get_post_meta( $menu_item->ID, 'object_id', true ) ); ?>" />
@ -148,11 +148,13 @@ function wp_print_nav_menu_item($menu_item, $context, $args = array() ) {
break;
case 'default':
$templatedir = get_bloginfo('url');
$template_dir = get_bloginfo('url');
?>
<dl>
<dt>
<span class="title"><?php echo $menu_item->title; ?></span> <a onclick="appendToList('<?php echo esc_js( esc_url_raw( $templatedir ) ); ?>','<?php echo esc_js( $menu_item->append ); ?>','<?php echo esc_js( $menu_item->title ); ?>','<?php echo esc_js( $menu_item->link ); ?>','<?php echo esc_js( $menu_item->ID ); ?>','<?php echo esc_js( $menu_item->parent_item ); ?>','<?php echo esc_js( $menu_item->description ); ?>')" name="<?php echo esc_attr( $menu_item->title ); ?>" value="<?php echo esc_attr( $menu_item->link ); ?>"><img alt="<?php esc_attr_e('Add to Custom Menu'); ?>" title="<?php esc_attr_e('Add to Custom Menu'); ?>" src="<?php echo admin_url('images/ico-add.png'); ?>" /></a> </dt>
<dt>
<span class="title"><?php echo $menu_item->title; ?></span>
<a onclick="appendToList('<?php echo esc_js( esc_url_raw( $template_dir ) ); ?>','<?php echo esc_js( $menu_item->append ); ?>','<?php echo esc_js( $menu_item->title ); ?>','<?php echo esc_js( $menu_item->link ); ?>','<?php echo esc_js( $menu_item->ID ); ?>','<?php echo esc_js( $menu_item->parent_item ); ?>','<?php echo esc_js( $menu_item->description ); ?>')" name="<?php echo esc_attr( $menu_item->title ); ?>" value="<?php echo esc_attr( $menu_item->link ); ?>"><img alt="<?php esc_attr_e('Add to Custom Menu'); ?>" title="<?php esc_attr_e('Add to Custom Menu'); ?>" src="<?php echo admin_url('images/ico-add.png'); ?>" /></a>
</dt>
</dl>
<?php
break;

View File

@ -25,7 +25,7 @@ function wp_create_nav_menu( $menu_name ) {
$menu_exists = get_term_by( 'name', $menu_name, 'nav_menu' );
if ( $menu_exists )
return WP_Error('menu_exists', sprintf( __('A menu named "%s" already exists; please try another name.'), $menu_exists->name ));
return new WP_Error('menu_exists', sprintf( __('A menu named &#8220;%s&#8221; already exists; please try another name.'), esc_html( $menu_exists->name ) ) );
$menu = wp_insert_term( $menu_name, 'nav_menu' );
if ( is_wp_error($menu) )
@ -97,16 +97,16 @@ function wp_setup_nav_menu_item($menu_item, $type = 'item', $position = 0) {
$menu_item->link = get_page_link( $menu_item->object_id );
if ( $menu_item->post_title == '' )
$menu_item->title = htmlentities( get_the_title( $menu_item->object_id ) );
$menu_item->title = get_the_title( $menu_item->object_id );
else
$menu_item->title = htmlentities( $menu_item->post_title );
$menu_item->title = $menu_item->post_title;
if ( $menu_item->post_content == '' )
$menu_item->description = htmlentities( get_post_meta( $menu_item->ID, 'page-description', true ) );
$menu_item->description = get_post_meta( $menu_item->ID, 'page-description', true );
else
$menu_item->description = htmlentities( $menu_item->post_content );
$menu_item->description = $menu_item->post_content;
$menu_item->target = '';
$menu_item->append = 'Page';
$menu_item->append = _x('Page', 'menu nav item type');
break;
// Category Menu Item
case 'category':
@ -114,25 +114,25 @@ function wp_setup_nav_menu_item($menu_item, $type = 'item', $position = 0) {
if ( empty($menu_item->post_title) ) {
$title_raw = get_category( $menu_item->object_id );
$menu_item->title = htmlentities($title_raw->cat_name);
$menu_item->title = $title_raw->cat_name;
} else {
$menu_item->title = htmlentities( $menu_item->post_title );
$menu_item->title = $menu_item->post_title;
}
if ( empty($menu_item->post_content) )
$menu_item->description = htmlentities( strip_tags( category_description( $menu_item->object_id ) ) );
$menu_item->description = strip_tags( category_description( $menu_item->object_id ) );
else
$menu_item->description = htmlentities( $menu_item->post_content );
$menu_item->description = $menu_item->post_content;
$menu_item->target = '';
$menu_item->append = 'Category';
$menu_item->append = _x('Category', 'menu nav item type');
break;
default:
// Custom Menu Item
$menu_item->link = $menu_item->guid;
$menu_item->title = htmlentities( $menu_item->post_title );
$menu_item->description = htmlentities( $menu_item->post_content );
$menu_item->title = $menu_item->post_title;
$menu_item->description = $menu_item->post_content;
$menu_item->target = 'target="_blank"';
$menu_item->append = 'Custom';
$menu_item->append = _x('Custom', 'menu nav item type');
break;
}
@ -146,7 +146,7 @@ function wp_setup_nav_menu_item($menu_item, $type = 'item', $position = 0) {
//SET anchor title
if (isset($wp_custom_nav_menu_items->custom_anchor_title)) {
$anchor_title = htmlentities($wp_custom_nav_menu_items->custom_anchor_title);
$anchor_title = $wp_custom_nav_menu_items->custom_anchor_title;
}
else {
$anchor_title = $title;

View File

@ -398,7 +398,13 @@ function wp_default_scripts( &$scripts ) {
// Custom Navigation
$scripts->add( 'custom-navigation-default-items', "/wp-admin/js/custom-navigation-default-items$suffix.js", false, '20100223' );
$scripts->add( 'custom-navigation-dynamic-functions', "/wp-admin/js/custom-navigation-dynamic-functions$suffix.js", false, '20100220' );
$scripts->add( 'custom-navigation-dynamic-functions', "/wp-admin/js/custom-navigation-dynamic-functions$suffix.js", false, '20100224' );
$scripts->localize( 'custom-navigation-dynamic-functions', 'navMenuL10n', array(
'custom' => _x('Custom', 'menu nav item type'),
'page' => _x('Page', 'menu nav item type'),
'category' => _x('Category', 'menu nav item type')
) );
$scripts->add( 'custom-navigation-php-functions', "/wp-admin/js/custom-navigation-php-functions$suffix.js", false, '20100220' );
}
}
@ -468,7 +474,7 @@ function wp_default_styles( &$styles ) {
$styles->add( 'farbtastic', '/wp-admin/css/farbtastic.css', array(), '1.2' );
$styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.css', array(), '0.9.8' );
$styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.1' );
$styles->add( 'custom-navigation', "/wp-admin/css/custom-navigation$suffix.css", array(), '20100223' );
$styles->add( 'custom-navigation', "/wp-admin/css/custom-navigation$suffix.css", array(), '20100224' );
foreach ( $rtl_styles as $rtl_style ) {
$styles->add_data( $rtl_style, 'rtl', true );