Changeset 13473
- Timestamp:
- 02/27/2010 11:06:56 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-ajax.php
r13409 r13473 477 477 _wp_ajax_delete_comment_response( $comment->comment_ID ); 478 478 die( '0' ); 479 break; 480 case 'add-menu-link': 481 if ( !current_user_can( 'manage_links' ) ) 482 die('-1'); 483 484 $link_url = isset($_POST['link_url']) ? $_POST['link_url'] : false; 485 $link_name = isset($_POST['link_name']) ? $_POST['link_name'] : false; 486 487 if ( !$link_url || !$link_name ) 488 die('-1'); 489 490 $post = array( 'post_type' => 'nav_menu_item', 'post_title' => $link_name, 'ping_status' => false, 'post_excerpt' => '', 'post_content' => '' ); 491 $db_id = wp_insert_post( $post ); 492 493 update_post_meta( $db_id, 'menu_type', 'custom' ); 494 update_post_meta( $db_id, 'object_id', '' ); 495 update_post_meta( $db_id, 'menu_new_window', 0 ); 496 update_post_meta( $db_id, 'menu_link', esc_url_raw( $link_url ) ); 497 498 echo $db_id; 479 499 break; 480 500 case 'add-link-category' : // On the Fly -
trunk/wp-admin/css/nav-menu.css
r13449 r13473 1 .maintitle{margin:0 0 20px 0!important;}.logo{vertical-align:middle;margin:0 10px 0 0;}h2.heading{margin:32px 0 10px 0;}.checkboxes{float:right;margin:10px 12px 0 0;}#menus-container{clear:both;}#nav-container .inside{padding:0 10px 10px;}#menus-container .submit{padding:0;}#menu-settings-column .inside{padding:10px;}#custom-nav ul{width:100%;}#custom-nav li{margin:0;}.ui-draggable-dragging{width:500px;}#custom-nav li dl dt{-webkit-border-bottom-left-radius:6px;-webkit-border-bottom-right-radius:6px;-webkit-border-top-left-radius:6px;-webkit-border-top-right-radius:6px;border-bottom-left-radius:6px;border-bottom-right-radius:6px;border-top-left-radius:6px;border-top-right-radius:6px;-moz-border-radius-bottomleft:6px;-moz-border-radius-bottomright:6px;-moz-border-radius-topleft:6px;-moz-border-radius-topright:6px;border:1px solid #E6E6E6;position:relative;padding-left:10px;background-color:#f1f1f1;height:35px;line-height:35px;}#custom-nav li dl dt:hover{cursor:move;}#custom-nav li dl dt .controls{position:absolute;right:15px;top:-1px;}#custom-nav li dl dt img{vertical-align:middle;}#custom-nav li .title{background:url(../images/ico-arrow.png) no-repeat 4px 5px;background-position:center left;padding-left:15px;}#custom-nav li ul li{margin-left:20px;opacity:.7;}#custom-nav li ul li ul li{opacity:.9;}#custom-nav li ul li ul li ul li{opacity:.9;}#custom-nav li ul li ul li ul li ul li{opacity:.95;}#add-custom-link .howto{font-size:11px;}#add-custom-link .widefat{width:85%;margin-right:5px;}.list-container{max-height:203px;overflow-y:auto;padding-left:2px;padding-right:5px;}.list{zoom:1;}.list li{margin:0;}.list dt{display:none;margin:0;border-bottom:1px solid #e3e3e3;overflow:hidden;}.list dt{background:url(../images/ico-add.png) no-repeat right;}.list li .title{cursor:pointer;display:block;width:95%;padding:5px 0;}.list li .title{background:url(../images/ico-arrow.png) no-repeat 4px 13px;background-position:center left;padding-left:5%;}.list li ul li .title{margin-left:14px;}.list li ul li ul li .title{margin-left:28px;}.list li ul li ul li ul li .title{margin-left:42px;}.list li ul li ul li ul li ul li .title{margin-left:56px;}.list li ul li ul li ul li ul li ul li .title{margin-left:70px;}.list li ul li ul li ul li ul li ul li ul li .title{margin-left:84px;}.list li ul li ul li ul li ul li ul li ul li ul li .title{margin-left:98px;}.list li ul li ul li ul li ul li ul li ul li ul li ul li .title{margin-left:112px;}img.remove,img.edit{cursor:pointer;margin:0 5px 0 0;}.dropzone{height:7px;margin:3px 0 3px 0;}.hide{display:none;}.type{text-transform:uppercase;font-size:11px;color:#999;padding-right:10px;}#menu_select{width:170px;}#dialog-confirm label{padding-left:10px;}.ui-dialog{background:#fff;border:1px solid #555;-moz-box-shadow:0 4px 30px #000;}.ui-dialog-titlebar{color:#CFCFCF;font-family:"Lucida Grande",Verdana,Arial,sans-serif;padding:6px 10px 6px;background-color:#222!important;border:none!important;-moz-border-radius:none!important;}#dialog-confirm{height:168px!important;padding:20px 10px 10px;}#dialog-confirm input{margin:0 0 15px 0;width:280px;}#dialog-confirm select{margin:0 0 15px 0;}.ui-dialog-buttonpane{padding:10px;}.ui-dialog-buttonpane button{margin:0 10px 0 0;background:#F2F2F2;text-shadow:0 1px 0 #FFF;border-color:#BBB;color:#464646;-moz-border-radius-bottomleft:11px;-moz-border-radius-bottomright:11px;-moz-border-radius-topleft:11px;-moz-border-radius-topright:11px;border-style:solid;border-width:1px;cursor:pointer;font-size:11px!important;line-height:14px;padding:2px 8px;text-decoration:none;}.ui-dialog-buttonpane button:hover{color:#000;border-color:#666;}.ui-icon{display:none;}.ui-widget-overlay{position:absolute;top:0;left:0;width:100%;height:100%;}.ui-widget-overlay{background:#aaa 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:#aaa 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;}1 #menu-management{clear:both;}#menu-management .inside{padding:0 10px;}#menu-container .submit{margin:0 0 10px;padding:0;}.submitdelete{color:#f00;text-decoration:underline;font-size:11px;float:left;margin-top:5px;}.submitdelete:hover{background-color:#F00;color:#fff;}.save{float:right;}.button-controls{float:left;}.add-to-menu{float:right;}#create-menu-name{width:159px;}#available-links{margin:15px 0 0;}#available-links dt{display:block;}#add-custom-link .howto{font-size:11px;}#add-custom-link label span{display:block;float:left;margin-top:5px;padding-right:5px;}#menu-item-url,#menu-item-name{float:right;width:220px;}.show-all,.hide-all{cursor:pointer;}.hide-all{display:none;}.quick-search{width:190px;}.list-wrap{display:none;clear:both;}.list-container{max-height:200px;overflow-y:auto;padding:10px 10px 5px;border:1px solid #DFDFDF;-moz-border-radius:4px;}.postbox p.submit{margin-bottom:0;}.list li{margin:0;}.list dt{display:none;margin:0;overflow:hidden;margin-bottom:5px;}.list li .item-title{cursor:pointer;display:block;}.list li .item-title input{margin-right:3px;margin-top:-3px;}.list li ul li .item-title{margin-left:14px;}.list li ul li ul li .item-title{margin-left:28px;}.list li ul li ul li ul li .item-title{margin-left:42px;}.list li ul li ul li ul li ul li .item-title{margin-left:56px;}.list li ul li ul li ul li ul li ul li .item-title{margin-left:70px;}.list li ul li ul li ul li ul li ul li ul li .item-title{margin-left:84px;}.list li ul li ul li ul li ul li ul li ul li ul li .item-title{margin-left:98px;}.list li ul li ul li ul li ul li ul li ul li ul li ul li .item-title{margin-left:112px;}#menu-container .inside{padding-bottom:10px;}#menu ul{width:100%;}#menu li{margin:0;}#menu li dl dt{-webkit-border-bottom-left-radius:6px;-webkit-border-bottom-right-radius:6px;-webkit-border-top-left-radius:6px;-webkit-border-top-right-radius:6px;border-bottom-left-radius:6px;border-bottom-right-radius:6px;border-top-left-radius:6px;border-top-right-radius:6px;-moz-border-radius-bottomleft:6px;-moz-border-radius-bottomright:6px;-moz-border-radius-topleft:6px;-moz-border-radius-topright:6px;border:1px solid #E6E6E6;position:relative;padding-left:10px;background-color:#f1f1f1;height:35px;line-height:35px;}#menu li dl dt:hover{cursor:move;}#menu li .item-title{background:url(../images/ico-arrow.png) no-repeat 4px 5px;background-position:center left;padding-left:15px;}#menu li ul li{margin-left:20px;opacity:.7;}#menu li ul li ul li{opacity:.9;}#menu li ul li ul li ul li{opacity:.9;}#menu li ul li ul li ul li ul li{opacity:.95;}.dropzone{height:7px;margin:3px 0 3px 0;}.ui-draggable-dragging{width:600px;}.item-type{text-transform:uppercase;font-size:11px;color:#999;padding-right:10px;}.item-controls{font-size:11px;position:absolute;right:15px;top:-1px;}.item-controls a{text-decoration:none;}.item-controls a:hover{cursor:pointer;}.item-controls .item-delete:hover{color:#f00;}#menu-item-settings{display:none;}#cancel-save{cursor:pointer;}#cancel-save:hover{color:#fff!important;}#update-menu-item{color:#fff!important;}#update-menu-item:hover,#update-menu-item:active,#update-menu-item:focus{color:#eaf2fa!important;border-color:#13455b!important;}.hide{display:none;} -
trunk/wp-admin/css/nav-menu.dev.css
r13449 r13473 3 3 * Interface CSS 4 4 * 5 * @version 1.1.05 * @version 2.0.0 6 6 * 7 7 * @package WordPress … … 9 9 */ 10 10 11 .maintitle { margin: 0 0 20px 0!important;} 12 .logo { vertical-align: middle; margin: 0 10px 0 0; } 13 h2.heading { margin: 32px 0 10px 0; } 14 .checkboxes { float: right; margin: 10px 12px 0 0; } 11 /* Menu Container */ 12 #menu-management { clear: both; } 13 #menu-management .inside { padding: 0 10px; } 15 14 16 #menus-container { clear: both; } 17 #nav-container .inside { padding: 0px 10px 10px; } 18 #menus-container .submit { padding: 0px; } 19 #menu-settings-column .inside { padding: 10px; } 15 /* Button Primary Actions */ 16 #menu-container .submit { margin: 0px 0px 10px; padding: 0px; } 17 .submitdelete { color: #ff0000; text-decoration: underline; font-size: 11px; float: left; margin-top: 5px; } 18 .submitdelete:hover { background-color: #FF0000; color: #fff; } 19 .save { float: right; } 20 20 21 #custom-nav ul { width: 100%; } 22 #custom-nav li { margin: 0; } 23 .ui-draggable-dragging { width: 500px; } 24 #custom-nav li dl dt { -webkit-border-bottom-left-radius: 6px; -webkit-border-bottom-right-radius: 6px; -webkit-border-top-left-radius: 6px; -webkit-border-top-right-radius: 6px; border-bottom-left-radius: 6px; border-bottom-right-radius: 6px; border-top-left-radius: 6px; border-top-right-radius: 6px; -moz-border-radius-bottomleft: 6px; -moz-border-radius-bottomright: 6px; -moz-border-radius-topleft: 6px; -moz-border-radius-topright: 6px; border: 1px solid #E6E6E6;position: relative; padding-left:10px; background-color: #f1f1f1; height: 35px; line-height: 35px; } 25 #custom-nav li dl dt:hover { cursor: move; } 26 #custom-nav li dl dt .controls { position: absolute; right: 15px; top: -1px; } 27 #custom-nav li dl dt img { vertical-align: middle; } 28 #custom-nav li dl dt a {} 29 #custom-nav li .title { background:url(../images/ico-arrow.png) no-repeat 4px 5px; background-position: center left; padding-left: 15px; } 30 #custom-nav li ul li { margin-left: 20px; opacity: .7;} 31 #custom-nav li ul li ul li { opacity: .9;} 32 #custom-nav li ul li ul li ul li { opacity: .9;} 33 #custom-nav li ul li ul li ul li ul li { opacity: .95; } 21 /* Button Secondary Actions */ 22 .button-controls { float: left; } 23 .add-to-menu { float: right; } 34 24 25 /* CSS for switching the columns *//* 26 #menu-settings-column { clear: none; float: left; } 27 #menu-management #post-body { float: right; margin-left: -340px; margin-right: 0px; } 28 #menu-management #post-body-content { margin-left: 300px; margin-right: 0px; } 29 */ 30 31 /* Create Menu */ 32 #create-menu-name { width: 159px; } 33 34 /* Custom Links */ 35 #available-links { margin: 15px 0px 0px; } 36 #available-links dt { display: block; } 35 37 #add-custom-link .howto { font-size: 11px; } 36 #add-custom-link .widefat { width: 85%; margin-right: 5px; } 38 #add-custom-link label span { display: block; float: left; margin-top: 5px; padding-right: 5px; } 39 #menu-item-url, #menu-item-name { float: right; width: 220px; } 37 40 38 .list-container { max-height: 203px; overflow-y: auto; padding-left: 2px; padding-right: 5px; } 41 /* Pages/Categories */ 42 .show-all, .hide-all { cursor: pointer; } 43 .hide-all { display: none; } 39 44 40 .list { zoom: 1; } 45 .quick-search { width: 190px; } 46 .list-wrap { display: none; clear: both; } 47 .list-container { max-height: 200px; overflow-y: auto; padding: 10px 10px 5px; border: 1px solid #DFDFDF; -moz-border-radius: 4px; } 48 .postbox p.submit { margin-bottom: 0; } 49 50 /* Listings */ 41 51 .list li { margin: 0; } 42 .list dt { display: none; margin: 0; border-bottom: 1px solid #e3e3e3; overflow: hidden; } 43 .list dt { background: url(../images/ico-add.png) no-repeat right; } 52 .list dt { display: none; margin: 0; overflow: hidden; margin-bottom: 5px; } 44 53 45 .list li . title { cursor: pointer; display: block; width: 95%; padding: 5px 0px; }46 .list li . title { background: url(../images/ico-arrow.png) no-repeat 4px 13px; background-position: center left; padding-left: 5%; }54 .list li .item-title { cursor: pointer; display: block; } 55 .list li .item-title input { margin-right: 3px; margin-top: -3px; } 47 56 48 /* Visually shows the menu item hierarchy. */ 49 .list li ul li .title { margin-left: 14px; } 50 .list li ul li ul li .title { margin-left: 28px; } 51 .list li ul li ul li ul li .title { margin-left: 42px; } 52 .list li ul li ul li ul li ul li .title { margin-left: 56px; } 53 .list li ul li ul li ul li ul li ul li .title { margin-left: 70px; } 54 .list li ul li ul li ul li ul li ul li ul li .title { margin-left: 84px; } 55 .list li ul li ul li ul li ul li ul li ul li ul li .title { margin-left: 98px; } 56 .list li ul li ul li ul li ul li ul li ul li ul li ul li .title { margin-left: 112px; } 57 .list li ul li .item-title { margin-left: 14px; } 58 .list li ul li ul li .item-title { margin-left: 28px; } 59 .list li ul li ul li ul li .item-title { margin-left: 42px; } 60 .list li ul li ul li ul li ul li .item-title { margin-left: 56px; } 61 .list li ul li ul li ul li ul li ul li .item-title { margin-left: 70px; } 62 .list li ul li ul li ul li ul li ul li ul li .item-title { margin-left: 84px; } 63 .list li ul li ul li ul li ul li ul li ul li ul li .item-title { margin-left: 98px; } 64 .list li ul li ul li ul li ul li ul li ul li ul li ul li .item-title { margin-left: 112px; } 57 65 58 img.remove, img.edit { cursor: pointer; margin: 0 5px 0 0; } 66 /* Menu */ 67 #menu-container .inside { padding-bottom: 10px; } 68 69 #menu ul { width: 100%; } 70 #menu li { margin: 0; } 71 #menu li dl dt { -webkit-border-bottom-left-radius: 6px; -webkit-border-bottom-right-radius: 6px; -webkit-border-top-left-radius: 6px; -webkit-border-top-right-radius: 6px; border-bottom-left-radius: 6px; border-bottom-right-radius: 6px; border-top-left-radius: 6px; border-top-right-radius: 6px; -moz-border-radius-bottomleft: 6px; -moz-border-radius-bottomright: 6px; -moz-border-radius-topleft: 6px; -moz-border-radius-topright: 6px; border: 1px solid #E6E6E6;position: relative; padding-left:10px; background-color: #f1f1f1; height: 35px; line-height: 35px; } 72 #menu li dl dt:hover { cursor: move; } 73 74 #menu li .item-title { background: url(../images/ico-arrow.png) no-repeat 4px 5px; background-position: center left; padding-left: 15px; } 75 #menu li ul li { margin-left: 20px; opacity: .7;} 76 #menu li ul li ul li { opacity: .9;} 77 #menu li ul li ul li ul li { opacity: .9;} 78 #menu li ul li ul li ul li ul li { opacity: .95; } 79 80 /* Drag and Drop */ 59 81 .dropzone { height: 7px; margin: 3px 0 3px 0; } 60 #custom-nav li dl { } 82 .ui-draggable-dragging { width: 600px; } 83 84 /* Menu Controls */ 85 .item-type { text-transform: uppercase; font-size: 11px; color: #999999; padding-right: 10px; } 86 .item-controls { font-size: 11px; position: absolute; right: 15px; top: -1px; } 87 .item-controls a { text-decoration: none; } 88 .item-controls a:hover { cursor: pointer; } 89 .item-controls .item-delete:hover { color: #ff0000; } 90 91 /* Thickbox */ 92 #menu-item-settings { display: none; } 93 #cancel-save { cursor: pointer; } 94 #cancel-save:hover { color: #fff !important; } 95 #update-menu-item { color: #fff !important; } 96 #update-menu-item:hover, 97 #update-menu-item:active, 98 #update-menu-item:focus { color: #eaf2fa !important; border-color: #13455b !important; } 99 100 /* Misc */ 61 101 .hide { display: none; } 62 .type { text-transform: uppercase; font-size: 11px; color: #999999; padding-right: 10px; }63 64 #menu_select { width: 170px; }65 #dialog-confirm label { padding-left: 10px; }66 67 /* EDIT LINK BOX */68 .ui-dialog { background: #fff; border: 1px solid #555555; -moz-box-shadow:0 4px 30px #000000; }69 .ui-dialog-titlebar { color: #CFCFCF; font-family: "Lucida Grande", Verdana, Arial, sans-serif; padding: 6px 10px 6px; background-color: #222222 !important; border: none !important; -moz-border-radius: none !important; }70 #dialog-confirm { height: 168px !important; padding: 20px 10px 10px; }71 #dialog-confirm input { margin: 0 0 15px 0; width: 280px; }72 #dialog-confirm select { margin: 0 0 15px 0; }73 .ui-dialog-buttonpane { padding: 10px; }74 .ui-dialog-buttonpane button { margin: 0 10px 0 0; background: #F2F2F2; text-shadow: 0 1px 0 #FFFFFF; border-color: #BBBBBB; color: #464646; -moz-border-radius-bottomleft: 11px; -moz-border-radius-bottomright: 11px; -moz-border-radius-topleft: 11px; -moz-border-radius-topright: 11px; border-style: solid; border-width: 1px; cursor: pointer; font-size: 11px !important; line-height: 14px; padding: 2px 8px; text-decoration: none; }75 .ui-dialog-buttonpane button:hover { color: #000; border-color: #666; }76 .ui-icon { display: none; }77 78 /* Overlays */79 .ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }80 .ui-widget-overlay { background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .60; filter:Alpha(Opacity=60); }81 .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; } -
trunk/wp-admin/includes/nav-menu.php
r13375 r13473 176 176 if ( $sub_array ) { 177 177 ?> 178 <ul id="sub- custom-nav-<?php echo $type ?>">178 <ul id="sub-menu-<?php echo $type ?>"> 179 179 180 180 <?php … … 222 222 223 223 // Override for menu descriptions 224 update_option('wp_settings_ custom_nav_advanced_options', 'yes');224 update_option('wp_settings_nav_menu_advanced_options', 'yes'); 225 225 226 226 $menus = wp_get_nav_menus(); -
trunk/wp-admin/js/nav-menu-default-items.dev.js
r13449 r13473 1 1 /** 2 2 * WordPress Administration Custom Navigation 3 * Interface JQueryfunctions3 * Interface $ functions 4 4 * 5 * @version 1.1.05 * @version 2.0.0 6 6 * 7 7 * @package WordPress … … 9 9 */ 10 10 11 /* 11 /** 12 12 * Init Functions 13 */ 14 jQuery(function($) 15 { 16 //Makes dialog box 17 $("#dialog-confirm").dialog({ 18 autoOpen: false, 19 resizable: false, 20 height: 210, 21 width: 400, 22 modal: true, 23 buttons: { 24 'Save': function() { 13 */ 14 jQuery(document).ready(function($){ 15 16 // Handle Save Button Clicks 17 $('#save_menu').click(function(){ 18 wp_update_post_data(); 19 }); 20 21 // Clear the quick search textbox 22 $('.quick-search').click(function(){ 23 $(this).attr( 'value', '' ); 24 }); 25 26 // Quick Search submit 27 $('.quick-search-submit').click(function(){ 28 $(this).siblings('.quick-search').search(); 29 }); 30 31 // Edit menu item 32 $('#menu-container .item-edit').click(function(){ 33 wp_edit_menu_item( $(this).attr('value') ); 34 }); 35 36 // Delete menu item 37 $('#menu-container .item-delete').live( 'click', function(){ 38 wp_remove_menu_item( $(this).attr('value') ); 39 }); 40 41 // Update menu item settings (thickbox) 42 $('#update-menu-item').click(function(){ 43 wp_update_menu_item(); 44 tb_remove(); 45 46 // Give feedback to the user 47 var id = $('#edit-item-id').val(); 48 $('#menu-' + id + ' dt:first').animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { jQuery(this).css( 'backgroundColor', '' ); }}); 49 }); 50 51 // Close thickbox 52 $('#cancel-save').click(function(){ 53 tb_remove(); 54 }); 55 56 // Show All Button 57 $('.show-all').click(function(){ 58 $(this).offsetParent().find('#add-buttons-actions').attr( 'style','margin-bottom: 10px;' ); 59 $(this).offsetParent().find('.list-wrap').css( 'display','block' ); 60 $(this).siblings('.quick-search').attr( 'value', '' ); 61 $(this).offsetParent().find('.list-wrap dt').css( 'display', 'block' ); 62 $(this).hide(); 63 $(this).siblings('.hide-all').show(); 64 }); 65 66 // Hide All Button 67 $('.hide-all').click(function(){ 68 $(this).offsetParent().find('#add-buttons-actions').attr( 'style','margin-bottom: 0px;' ); 69 $(this).offsetParent().find('.list-wrap').css( 'display','none' ); 70 $(this).siblings('.quick-search').attr( 'value', 'Search' ); 71 $(this).offsetParent().find('.list-wrap dt').css( 'display', 'none' ); 72 $(this).hide(); 73 $(this).siblings('.show-all').show(); 74 }); 75 76 // Add queued menu items into the menu 77 $('.enqueue a').click(function(){ 78 wp_add_queued_items_to_menu(this); 79 }); 80 81 // Create the link, add it to the menu + available links section 82 $('#add-custom-link .add-to-menu a').click(function(){ 83 var link_url = $(this).offsetParent().find('#menu-item-url').val(); 84 var link_name = $(this).offsetParent().find('#menu-item-name').val(); 85 var links = $(this).offsetParent().find('#available-links input:checked'); 86 87 // If links are checked in the available links section, add them to the menu 88 if ( links ) { 89 for (var i = 0; i < links.length; i++) { 90 wp_add_item_to_menu( 'Custom', links[i].name, links[i].value, links[i].id.substring( 5, links[i].id.length ), 0, '' ); 91 }; 92 93 // Reset the checkboxes; 94 $(links).attr('checked', false); 95 }; 96 97 // Don't save the link if it was left with it's default settings 98 if ( 'http://' == link_url || 'Menu Item' == link_name ) 99 return; 100 101 // Parameters to send off 102 params = { 103 action: 'add-menu-link', 104 link_url: link_url, 105 link_name: link_name, 106 }; 107 108 // save the link 109 $.post( ajaxurl, params, function(response) { 110 if ( null == response || '-1' == response ) 111 return false; 112 113 params.link_id = response; 114 115 // add it to the available links section 116 // wp_update_links_list( params ); 117 118 // and update the Menu with the new link 119 wp_add_item_to_menu( 'Custom', params.link_name, params.link_url, params.link_id, 0, '' ); 120 }, 'json'); 121 }); 122 123 // Add dropzones 124 $('#menu li').prepend('<div class="dropzone"></div>'); 25 125 26 titletosave = $('#edittitle').attr('value'); 27 linktosave = $('#editlink').attr('value'); 28 anchortitletosave = $('#editanchortitle').attr('value'); 29 newwindowtosave = $('#editnewwindow').attr('value'); 30 desctosave = $('#editdescription').attr('value'); 31 32 $('#title' + $(this).dialog('option', 'itemID')).attr('value',titletosave); 33 $('#linkurl' + $(this).dialog('option', 'itemID')).attr('value',linktosave); 34 $('#anchortitle' + $(this).dialog('option', 'itemID')).attr('value',anchortitletosave); 35 $('#newwindow' + $(this).dialog('option', 'itemID')).attr('value',newwindowtosave); 36 $('#description' + $(this).dialog('option', 'itemID')).attr('value',desctosave); 37 38 $('#menu-' + $(this).dialog('option', 'itemID') + ' > dl > dt > span.title').text(titletosave); 39 40 $('#view' + + $(this).dialog('option', 'itemID')).attr('href', linktosave); 41 42 $(this).dialog('close'); 43 44 }, 45 Cancel: function() { 46 $(this).dialog('close'); 47 } 48 } 49 }); 50 51 // $('#message').animate({ opacity: 1.0 },2000).fadeOut(300, function(){ $(this).remove();}); 52 53 //Add dropzone 54 $('#custom-nav li').prepend('<div class="dropzone"></div>'); 55 56 //Make li items draggable 57 $('#custom-nav li').draggable({ 58 handle: ' > dl', 59 opacity: .8, 60 addClasses: false, 61 helper: 'clone', 62 zIndex: 100 63 }); 64 65 //Make items droppable 66 $('#custom-nav dl, #custom-nav .dropzone').droppable( 67 { 68 accept: '#custom-nav li', 69 tolerance: 'pointer', 70 drop: function(e, ui) 71 { 72 var li = $(this).parent(); 73 var child = !$(this).hasClass('dropzone'); 74 //Add UL to first child 75 if (child && li.children('ul').length == 0) 76 { 77 li.append('<ul id="sub-menu" />'); 78 } 79 //Make it draggable 80 if (child) 81 { 82 li.children('ul').append(ui.draggable); 83 } 84 else 85 { 86 li.before(ui.draggable); 87 } 88 89 li.find('dl,.dropzone').css({ backgroundColor: '', borderColor: '' }); 90 91 var draggablevalue = ui.draggable.attr('value'); 92 var droppablevalue = li.attr('value'); 93 li.find('#menu-' + draggablevalue).find('#parent' + draggablevalue).val(droppablevalue); 94 $(this).parent().find("dt").removeAttr('style'); 95 $(this).parent().find("div:first").removeAttr('style'); 96 97 98 }, 99 over: function() 100 { 101 //Add child 102 if ($(this).attr('class') == 'dropzone ui-droppable') 103 { 104 $(this).parent().find("div:first").css('background', 'none').css('height', '50px'); 105 } 106 //Add above 107 else if ($(this).attr('class') == 'ui-droppable') 108 { 109 $(this).parent().find("dt:first").css('background', '#d8d8d8'); 110 } 111 //do nothing 112 else { 113 114 } 115 var parentid = $(this).parent().attr('id'); 116 117 }, 118 out: function() 119 { 120 $(this).parent().find("dt").removeAttr('style'); 121 $(this).parent().find("div:first").removeAttr('style'); 122 $(this).filter('.dropzone').css({ borderColor: '' }); 123 }, 124 deactivate: function() 125 { 126 127 128 } 129 130 131 }); 132 133 //Handle Save Button Clicks 134 $('#save_top').click(function() 135 { 136 updatepostdata(); 137 }); 138 $('#save_bottom').click(function() 139 { 140 updatepostdata(); 141 }); 142 143 126 // Make menu items draggable 127 $('#menu li').draggable({ 128 handle: ' > dl', 129 opacity: .8, 130 addClasses: false, 131 helper: 'clone', 132 zIndex: 100 144 133 }); 145 134 135 // Make items droppable 136 $('#menu dl, #menu .dropzone').droppable({ 137 accept: '#menu li', 138 tolerance: 'pointer', 139 140 drop: function(e, ui) { 141 var li = $(this).parent(); 142 var child = !$(this).hasClass('dropzone'); 143 144 // Add UL to first child 145 if ( child && li.children('ul').length == 0 ) { 146 li.append('<ul id="sub-menu" />'); 147 } 148 // Make it draggable 149 if ( child ) { 150 li.children('ul').append( ui.draggable ); 151 } else { 152 li.before( ui.draggable ); 153 } 146 154 155 li.find('dl,.dropzone').css({ backgroundColor: '', borderColor: '' }); 156 157 var draggablevalue = ui.draggable.attr('value'); 158 var droppablevalue = li.attr('value'); 159 160 li.find('#menu-' + draggablevalue).find('#parent' + draggablevalue).val(droppablevalue); 161 $(this).parent().find('dt').removeAttr('style'); 162 163 $(this).parent().find('div:first').removeAttr('style'); 164 }, 165 166 over: function() { 167 168 if ( 'dropzone ui-droppable' == $(this).attr('class') ) { 169 // Add child 170 $(this).parent().find('dt:first').css('background', 'none').css('height', '50px'); 171 172 } else if ($(this).attr('class') == 'ui-droppable') { 173 // Add above 174 $(this).parent().find('dt:first').css('background', '#d8d8d8'); 175 176 } else { 177 // do nothing 178 } 179 var parentid = $(this).parent().attr('id'); 180 }, 181 out: function() { 182 $(this).parent().find('dt').removeAttr('style'); 183 $(this).parent().find('div:first').removeAttr('style'); 184 $(this).filter('.dropzone').css({ borderColor: '' }); 185 }, 186 deactivate: function() { 187 // 188 } 189 }); 190 }); -
trunk/wp-admin/js/nav-menu-default-items.js
r13449 r13473 1 jQuery( function($){$("#dialog-confirm").dialog({autoOpen:false,resizable:false,height:210,width:400,modal:true,buttons:{Save:function(){titletosave=$("#edittitle").attr("value");linktosave=$("#editlink").attr("value");anchortitletosave=$("#editanchortitle").attr("value");newwindowtosave=$("#editnewwindow").attr("value");desctosave=$("#editdescription").attr("value");$("#title"+$(this).dialog("option","itemID")).attr("value",titletosave);$("#linkurl"+$(this).dialog("option","itemID")).attr("value",linktosave);$("#anchortitle"+$(this).dialog("option","itemID")).attr("value",anchortitletosave);$("#newwindow"+$(this).dialog("option","itemID")).attr("value",newwindowtosave);$("#description"+$(this).dialog("option","itemID")).attr("value",desctosave);$("#menu-"+$(this).dialog("option","itemID")+" > dl > dt > span.title").text(titletosave);$("#view"+ +$(this).dialog("option","itemID")).attr("href",linktosave);$(this).dialog("close")},Cancel:function(){$(this).dialog("close")}}});$("#custom-nav li").prepend('<div class="dropzone"></div>');$("#custom-nav li").draggable({handle:" > dl",opacity:0.8,addClasses:false,helper:"clone",zIndex:100});$("#custom-nav dl, #custom-nav .dropzone").droppable({accept:"#custom-nav li",tolerance:"pointer",drop:function(e,ui){var li=$(this).parent();var child=!$(this).hasClass("dropzone");if(child&&li.children("ul").length==0){li.append('<ul id="sub-menu" />')}if(child){li.children("ul").append(ui.draggable)}else{li.before(ui.draggable)}li.find("dl,.dropzone").css({backgroundColor:"",borderColor:""});var draggablevalue=ui.draggable.attr("value");var droppablevalue=li.attr("value");li.find("#menu-"+draggablevalue).find("#parent"+draggablevalue).val(droppablevalue);$(this).parent().find("dt").removeAttr("style");$(this).parent().find("div:first").removeAttr("style")},over:function(){if($(this).attr("class")=="dropzone ui-droppable"){$(this).parent().find("div:first").css("background","none").css("height","50px")}else{if($(this).attr("class")=="ui-droppable"){$(this).parent().find("dt:first").css("background","#d8d8d8")}else{}}var parentid=$(this).parent().attr("id")},out:function(){$(this).parent().find("dt").removeAttr("style");$(this).parent().find("div:first").removeAttr("style");$(this).filter(".dropzone").css({borderColor:""})},deactivate:function(){}});$("#save_top").click(function(){updatepostdata()});$("#save_bottom").click(function(){updatepostdata()})});1 jQuery(document).ready(function($){$("#save_menu").click(function(){wp_update_post_data()});$(".quick-search").click(function(){$(this).attr("value","")});$(".quick-search-submit").click(function(){$(this).siblings(".quick-search").search()});$("#menu-container .item-edit").click(function(){wp_edit_menu_item($(this).attr("value"))});$("#menu-container .item-delete").live("click",function(){wp_remove_menu_item($(this).attr("value"))});$("#update-menu-item").click(function(){wp_update_menu_item();tb_remove();var id=$("#edit-item-id").val();$("#menu-"+id+" dt:first").animate({backgroundColor:"#FFFF33"},{duration:"normal",complete:function(){jQuery(this).css("backgroundColor","")}})});$("#cancel-save").click(function(){tb_remove()});$(".show-all").click(function(){$(this).offsetParent().find("#add-buttons-actions").attr("style","margin-bottom: 10px;");$(this).offsetParent().find(".list-wrap").css("display","block");$(this).siblings(".quick-search").attr("value","");$(this).offsetParent().find(".list-wrap dt").css("display","block");$(this).hide();$(this).siblings(".hide-all").show()});$(".hide-all").click(function(){$(this).offsetParent().find("#add-buttons-actions").attr("style","margin-bottom: 0px;");$(this).offsetParent().find(".list-wrap").css("display","none");$(this).siblings(".quick-search").attr("value","Search");$(this).offsetParent().find(".list-wrap dt").css("display","none");$(this).hide();$(this).siblings(".show-all").show()});$(".enqueue a").click(function(){wp_add_queued_items_to_menu(this)});$("#add-custom-link .add-to-menu a").click(function(){var link_url=$(this).offsetParent().find("#menu-item-url").val();var link_name=$(this).offsetParent().find("#menu-item-name").val();var links=$(this).offsetParent().find("#available-links input:checked");if(links){for(var i=0;i<links.length;i++){wp_add_item_to_menu("Custom",links[i].name,links[i].value,links[i].id.substring(5,links[i].id.length),0,"")}$(links).attr("checked",false)}if("http://"==link_url||"Menu Item"==link_name){return}params={action:"add-menu-link",link_url:link_url,link_name:link_name,};$.post(ajaxurl,params,function(response){if(null==response||"-1"==response){return false}params.link_id=response;wp_add_item_to_menu("Custom",params.link_name,params.link_url,params.link_id,0,"")},"json")});$("#menu li").prepend('<div class="dropzone"></div>');$("#menu li").draggable({handle:" > dl",opacity:0.8,addClasses:false,helper:"clone",zIndex:100});$("#menu dl, #menu .dropzone").droppable({accept:"#menu li",tolerance:"pointer",drop:function(e,ui){var li=$(this).parent();var child=!$(this).hasClass("dropzone");if(child&&li.children("ul").length==0){li.append('<ul id="sub-menu" />')}if(child){li.children("ul").append(ui.draggable)}else{li.before(ui.draggable)}li.find("dl,.dropzone").css({backgroundColor:"",borderColor:""});var draggablevalue=ui.draggable.attr("value");var droppablevalue=li.attr("value");li.find("#menu-"+draggablevalue).find("#parent"+draggablevalue).val(droppablevalue);$(this).parent().find("dt").removeAttr("style");$(this).parent().find("div:first").removeAttr("style")},over:function(){if("dropzone ui-droppable"==$(this).attr("class")){$(this).parent().find("dt:first").css("background","none").css("height","50px")}else{if($(this).attr("class")=="ui-droppable"){$(this).parent().find("dt:first").css("background","#d8d8d8")}else{}}var parentid=$(this).parent().attr("id")},out:function(){$(this).parent().find("dt").removeAttr("style");$(this).parent().find("div:first").removeAttr("style");$(this).filter(".dropzone").css({borderColor:""})},deactivate:function(){}})}); -
trunk/wp-admin/js/nav-menu-dynamic-functions.dev.js
r13449 r13473 9 9 */ 10 10 11 /* 12 * Removes menu items from current menu 11 /** 12 * Adds a link to the available links section 13 * 14 * @param object e - An object recieved via ajax 15 */ 16 function wp_update_links_list(e) { 17 var link = '<li><dl><dt><label class="item-title"><input type="checkbox" id="link-'+ e.link_id +'" name="'+ e.link_name +'" value="'+ e.link_url +'" />'+ e.link_name +'</label></dt></dl></li>'; 18 19 // Prepend the link to the available links section 20 jQuery('#available-links .list').prepend( link ); 21 22 // Give feedback to the user 23 jQuery('#available-links .list #link-' + e.link_id).parent().animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { jQuery(this).css( 'backgroundColor', '' ); }}); 24 } 25 26 /** 27 * Removes a menu item from current menu 28 * 13 29 * @param int o - the id of the menu li to remove. 14 */ 15 function removeitem(o) 16 { 17 30 */ 31 function wp_remove_menu_item( o ) { 18 32 var todelete = document.getElementById('menu-' + o); 19 20 if (todelete) 21 { 22 var parenttodelete = document.getElementById('menu-' + o).parentNode; 23 throwaway_node = parenttodelete.removeChild(todelete); 24 } 25 26 updatepostdata(); 27 }; 28 29 /* 30 * Loads dialog window to edit menu items from current menu 33 34 if ( todelete ) { 35 // Give some feedback to the user 36 jQuery( todelete ).find('dt').each(function(){ 37 jQuery(this).animate( { backgroundColor: '#FF3333' }, { duration: 'normal', complete: function() { jQuery(this).parent().parent().remove() } } ); 38 }); 39 40 wp_update_post_data(); 41 } 42 }; 43 44 /** 45 * Populate the thickbox window with the selected menu items 46 * 31 47 * @param int o - the id of the menu li to edit. 32 */ 33 function edititem(o) 34 { 35 36 itemTitle = jQuery('#title' + o).val(); 37 itemURL = jQuery('#linkurl' + o).val(); 38 itemAnchorTitle = jQuery('#anchortitle' + o).val(); 39 itemNewWindow = jQuery('#newwindow' + o).val(); 40 itemDesc = jQuery('#description' + o).val(); 41 42 jQuery('#dialog-confirm').dialog( 'option' , 'itemID' , o ) 43 44 jQuery('#dialog-confirm').dialog('open'); 45 46 jQuery('#edittitle').val( itemTitle ); 47 if ( 'custom' == jQuery( '#linktype' + o ).val() ) { 48 jQuery( '#editlink-wrap' ).css( 'display', 'inline' ); 49 } else { 50 jQuery( '#editlink-wrap' ).css( 'display', 'none' ); 51 } 52 jQuery('#editlink').val( itemURL ); 53 jQuery('#editanchortitle').val( itemAnchorTitle ); 54 jQuery("#editnewwindow option[value='" + itemNewWindow + "']").attr('selected', 'selected'); 55 jQuery('#editdescription').val( itemDesc ); 56 57 }; 58 59 /* 48 */ 49 function wp_edit_menu_item( id ) { 50 console.log('wp_edit_menu_item'); 51 52 var itemTitle = jQuery('#item-title' + id).val(); 53 var itemURL = jQuery('#item-url' + id).val(); 54 var itemAttrTitle = jQuery('#item-attr-title' + id).val(); 55 var itemTarget = jQuery('#item-target' + id).val(); 56 var itemDesc = jQuery('#item-description' + id).val(); 57 58 console.log(id); 59 console.log(itemTitle); 60 console.log(itemURL); 61 console.log(itemAttrTitle); 62 console.log(itemTarget); 63 console.log(itemDesc); 64 65 // Populate the fields for thickbox 66 jQuery( '#edit-item-id' ).val(id); 67 jQuery( '#edit-item-title' ).val(itemTitle); 68 jQuery( '#edit-item-url' ).val(itemURL); 69 jQuery( '#edit-item-attr-title' ).val(itemAttrTitle); 70 jQuery( '#edit-item-target' ).val(itemTarget); 71 jQuery( "#edit-item-target option[value='" + itemTarget + "']" ).attr('selected', 'selected'); 72 jQuery( '#edit-item-description' ).val(itemDesc); 73 }; 74 75 /** 76 * Update the values for the menu item being editing 77 */ 78 function wp_update_menu_item() { 79 var id = jQuery('#edit-item-id').val(); 80 var itemTitle = jQuery('#edit-item-title').val(); 81 var itemURL = jQuery('#edit-item-url').val(); 82 var itemAttrTitle = jQuery('#edit-item-attr-title').val(); 83 var itemTarget = jQuery('#edit-item-target').val(); 84 var itemDesc = jQuery('#edit-item-description').val(); 85 86 console.log(id); 87 console.log(itemTitle); 88 console.log(itemURL); 89 console.log(itemAttrTitle); 90 console.log(itemTarget); 91 console.log(itemDesc); 92 93 // update menu item settings 94 jQuery('#menu-' + id).find('.item-title:first').html(itemTitle); 95 jQuery('#item-title' + id).val(itemTitle); 96 jQuery('#item-url' + id).val(itemURL); 97 jQuery('#item-attr-title' + id).val(itemAttrTitle); 98 jQuery('#item-target' + id).val(itemTarget); 99 jQuery('#item-description' + id).val(itemDesc); 100 } 101 102 /** 60 103 * Prepares menu items for POST 61 */ 62 function updatepostdata() 63 { 64 104 */ 105 function wp_update_post_data() { 65 106 var i = 0; 66 jQuery("#custom-nav").find("li").each(function(i) { 107 108 jQuery('#menu li').each(function(i) { 67 109 i = i + 1; 68 110 var j = jQuery(this).attr('value'); … … 80 122 var p = jQuery(this).find('#parent' + j).parent().parent().parent().attr('value'); 81 123 82 jQuery(this).find('#parent' + j).attr('name','parent' + i); 83 jQuery(this).find('#parent' + j).attr('id','parent' + i); 84 if (p) { 85 //Do nothing 86 } 87 else { 88 //reset p to be top level 89 p = 0; 90 } 91 92 jQuery(this).find('#parent' + j).attr('value', p); 93 94 jQuery(this).find('#title' + j).attr('name','title' + i); 95 jQuery(this).find('#title' + j).attr('id','title' + i); 96 97 jQuery(this).find('#linkurl' + j).attr('name','linkurl' + i); 98 jQuery(this).find('#linkurl' + j).attr('id','linkurl' + i); 99 100 jQuery(this).find('#description' + j).attr('name','description' + i); 101 jQuery(this).find('#description' + j).attr('id','description' + i); 102 103 jQuery(this).find('#icon' + j).attr('name','icon' + i); 104 jQuery(this).find('#icon' + j).attr('id','icon' + i); 105 106 jQuery(this).find('#position' + j).attr('name','position' + i); 107 jQuery(this).find('#position' + j).attr('id','position' + i); 108 109 jQuery(this).find('#linktype' + j).attr('name','linktype' + i); 110 jQuery(this).find('#linktype' + j).attr('id','linktype' + i); 111 112 jQuery(this).find('#anchortitle' + j).attr('name','anchortitle' + i); 113 jQuery(this).find('#anchortitle' + j).attr('id','anchortitle' + i); 114 115 jQuery(this).find('#newwindow' + j).attr('name','newwindow' + i); 116 jQuery(this).find('#newwindow' + j).attr('id','newwindow' + i); 117 118 jQuery(this).find('dl > dt > span > #remove' + j).attr('value', i); 119 jQuery(this).find('dl > dt > span > #remove' + j).attr('onClick', 'removeitem(' + i + ')'); 120 jQuery(this).find('dl > dt > span > #remove' + j).attr('id','remove' + i); 121 122 jQuery('#li-count').attr('value',i); 123 124 jQuery(this).find('#parent' + j).attr('name','parent' + i); 125 jQuery(this).find('#parent' + j).attr('id','parent' + i); 126 127 if (p) { 128 // Do nothing 129 } else { 130 // reset p to be top level 131 p = 0; 132 } 133 134 jQuery(this).find('#parent' + j).attr('value', p); 135 136 jQuery(this).find('#item-title' + j).attr('name','item-title' + i); 137 jQuery(this).find('#item-title' + j).attr('id','item-title' + i); 138 139 jQuery(this).find('#item-url' + j).attr('name','item-url' + i); 140 jQuery(this).find('#item-url' + j).attr('id','item-url' + i); 141 142 jQuery(this).find('#item-description' + j).attr('name','item-description' + i); 143 jQuery(this).find('#item-description' + j).attr('id','item-description' + i); 144 145 jQuery(this).find('#item-attr-title' + j).attr('name','item-attr-title' + i); 146 jQuery(this).find('#item-attr-title' + j).attr('id','item-attr-title' + i); 147 148 jQuery(this).find('#item-target' + j).attr('name','item-target' + i); 149 jQuery(this).find('#item-target' + j).attr('id','item-target' + i); 150 151 jQuery(this).find('#position' + j).attr('name', 'position' + i); 152 jQuery(this).find('#position' + j).attr('id', 'position' + i); 153 154 jQuery(this).find('#linktype' + j).attr('name', 'linktype' + i); 155 jQuery(this).find('#linktype' + j).attr('id', 'linktype' + i); 156 157 jQuery('#li-count').attr( 'value', i ); 124 158 }); 125 126 127 159 }; 160 161 /** 162 * Adds the item to the menu 163 * 164 * @param string id - The menu item's id 165 * @param string additemtype - Page, Category, or Custom. 166 * @param string itemtext - menu text. 167 * @param string itemurl - url of the menu. 168 * @param int itemid - menu id. 169 * @param int itemparentid - default 0. 170 * @param string itemdescription - the description of the menu item. 171 */ 172 function wp_add_item_to_menu( additemtype, itemtext, itemurl, itemid, itemparentid, itemdescription ) { 173 var inputvaluevarname = ''; 174 var inputvaluevarurl = ''; 175 var inputitemid = ''; 176 var inputparentid= ''; 177 var inputdescription = ''; 178 var randomnumber = wp_get_unique_menu_id(); 179 180 inputvaluevarname = htmlentities(itemtext.toString()); 181 inputvaluevarurl = itemurl.toString(); 182 inputitemid = itemid; 183 inputparentid = itemparentid; 184 inputlinktype = 'custom'; 185 inputdescription = htmlentities(itemdescription.toString()); 186 187 // Adds the item in the queue 188 jQuery('#menu').append('<li id="menu-' + randomnumber + '" value="' + randomnumber + '"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">' + inputvaluevarname + '</span><span class="item-controls"><span class="item-type">' + additemtype + '</span><a class="item-edit thickbox" id="edit' + randomnumber + '" value="' + randomnumber +'" onClick="wp_edit_menu_item('+ randomnumber +')" title="' + navMenuL10n.thickbox + '" href="#TB_inline?height=380&width=300&inlineId=menu-item-settings">' + navMenuL10n.edit + '</a> | <a class="item-delete" id="delete' + randomnumber + '" value="' + randomnumber +'">Delete</a></span></dt></dl><a class="hide" href="' + inputvaluevarurl + '">' + inputvaluevarname + '</a><input type="hidden" name="postmenu' + randomnumber + '" id="postmenu' + randomnumber + '" value="' + inputitemid + '" /><input type="hidden" name="parent' + randomnumber + '" id="parent' + randomnumber + '" value="' + inputparentid + '" /><input type="hidden" name="item-title' + randomnumber + '" id="item-title' + randomnumber + '" value="' + inputvaluevarname + '" /><input type="hidden" name="item-url' + randomnumber + '" id="item-url' + randomnumber + '" value="' + inputvaluevarurl + '" /><input type="hidden" name="item-description' + randomnumber + '" id="item-description' + randomnumber + '" value="' + inputdescription + '" /><input type="hidden" name="position' + randomnumber + '" id="position' + randomnumber + '" value="' + randomnumber + '" /><input type="hidden" name="linktype' + randomnumber + '" id="linktype' + randomnumber + '" value="' + inputlinktype + '" /><input type="hidden" name="item-attr-title' + randomnumber + '" id="item-attr-title' + randomnumber + '" value="' + inputvaluevarname + '" /><input type="hidden" name="item-target' + randomnumber + '" id="item-target' + randomnumber + '" value="0" /></li>'); 189 190 // Give some feedback to the user 191 jQuery( '#menu #menu-' + randomnumber + ' dt:first' ).animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { jQuery(this).css( 'backgroundColor', '' ); }}); 192 193 // Enable drag-n-drop 194 wp_drag_and_drop(); 195 196 // Reload thickbox 197 tb_init('a.thickbox, area.thickbox, input.thickbox'); 128 198 }; 129 199 130 200 /* 131 * Adds item from Page, Category, or Custom options menu 132 * @param string templatedir - directory of the add, edit, view images. 201 * Queues items in perperation for appendToList 202 * 203 * @param string id - The menu item's id 133 204 * @param string additemtype - Page, Category, or Custom. 134 205 * @param string itemtext - menu text. … … 138 209 * @param string itemdescription - the description of the menu item. 139 210 */ 140 function appendToList(templatedir,additemtype,itemtext,itemurl,itemid,itemparentid,itemdescription) 141 { 211 function wp_update_queue( additemtype, itemtext, itemurl, itemid, itemparentid, itemdescription ) { 142 212 var inputvaluevarname = ''; 143 213 var inputvaluevarurl = ''; … … 145 215 var inputparentid= ''; 146 216 var inputdescription = ''; 147 var inputicon = ''; 148 149 if (additemtype == navMenuL10n.custom) 150 { 151 inputvaluevarname = document.getElementById('custom-menu-item-name').value; 152 inputvaluevarurl = document.getElementById('custom-menu-item-url').value; 153 inputitemid = ''; 154 inputparentid = ''; 155 inputlinktype = 'custom'; 156 inputdescription = ''; 157 } 158 else if (additemtype == navMenuL10n.page) 159 { 217 var randomnumber = wp_get_unique_menu_id(); 218 219 if ( additemtype == navMenuL10n.page ) { 160 220 inputvaluevarname = htmlentities(itemtext.toString()); 161 221 inputvaluevarurl = itemurl.toString(); … … 165 225 inputdescription = htmlentities(itemdescription.toString()); 166 226 167 } 168 else if (additemtype == navMenuL10n.category) 169 { 227 } else if ( additemtype == navMenuL10n.category ) { 170 228 inputvaluevarname = htmlentities(itemtext.toString()); 171 229 inputvaluevarurl = itemurl.toString(); … … 175 233 inputdescription = htmlentities(itemdescription.toString()); 176 234 } 177 else 178 { 179 inputvaluevarname = ''; 180 inputvaluevarname = ''; 181 inputitemid = ''; 182 inputparentid = ''; 183 inputlinktype = 'custom'; 184 inputdescription = ''; 185 } 186 187 var count=document.getElementById('custom-nav').getElementsByTagName('li').length + 1; 188 189 var randomnumber = count; 190 191 var validatetest = 0; 192 193 try 194 { 195 var test=document.getElementById("menu-" + randomnumber.toString()).value; 196 } 197 catch (err) 198 { 199 validatetest = 1; 200 } 201 202 while (validatetest == 0) 203 { 204 randomnumber = randomnumber + 1; 205 206 try 207 { 208 var test2=document.getElementById("menu-" + randomnumber.toString()).value; 209 } 210 catch (err) 211 { 212 validatetest = 1; 213 } 214 } 215 216 //Notification Message 217 jQuery('.maintitle').after('<div id="message" class="updated fade below-h2"><p>Menu Item added!</p></div>'); 218 jQuery('#message').animate({ opacity: 1.0 },2000).fadeOut(300, function(){ jQuery(this).remove();}); 219 220 //Appends HTML to the menu 221 jQuery('#custom-nav').append('<li id="menu-' + randomnumber + '" value="' + randomnumber + '"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="title">' + inputvaluevarname + '</span><span class="controls"><span class="type">' + additemtype + '</span><a id="edit' + randomnumber + '" onclick="edititem(' + randomnumber + ')" value="' + randomnumber +'"><img class="edit" alt="Edit Menu Item" title="Edit Menu Item" src="' + templatedir + '/wp-admin/images/ico-edit.png" /></a> <a id="remove' + randomnumber + '" onclick="removeitem(' + randomnumber + ')" value="' + randomnumber +'"><img class="remove" alt="Remove from Custom Menu" title="Remove from Custom Menu" src="' + templatedir + '/wp-admin/images/ico-close.png" /></a> <a href="' + inputvaluevarurl + '" target="_blank"><img alt="View Custom Link" title="View Custom Link" src="' + templatedir + '/wp-admin/images/ico-viewpage.png" /></a></span></dt></dl><a class="hide" href="' + inputvaluevarurl + '">' + inputvaluevarname + '</a><input type="hidden" name="postmenu' + randomnumber + '" id="postmenu' + randomnumber + '" value="' + inputitemid + '" /><input type="hidden" name="parent' + randomnumber + '" id="parent' + randomnumber + '" value="' + inputparentid + '" /><input type="hidden" name="title' + randomnumber + '" id="title' + randomnumber + '" value="' + inputvaluevarname + '" /><input type="hidden" name="linkurl' + randomnumber + '" id="linkurl' + randomnumber + '" value="' + inputvaluevarurl + '" /><input type="hidden" name="description' + randomnumber + '" id="description' + randomnumber + '" value="' + inputdescription + '" /><input type="hidden" name="icon' + randomnumber + '" id="icon' + randomnumber + '" value="' + inputicon + '" /><input type="hidden" name="position' + randomnumber + '" id="position' + randomnumber + '" value="' + randomnumber + '" /><input type="hidden" name="linktype' + randomnumber + '" id="linktype' + randomnumber + '" value="' + inputlinktype + '" /><input type="hidden" name="anchortitle' + randomnumber + '" id="anchortitle' + randomnumber + '" value="' + inputvaluevarname + '" /><input type="hidden" name="newwindow' + randomnumber + '" id="newwindow' + randomnumber + '" value="0" /></li>'); 222 223 //make menu item draggable 224 jQuery('#menu-' + randomnumber + '').draggable( 225 { 235 236 // Adds or removes the item from the queue 237 if ( jQuery(menu_item_id = '#menu-item-' + inputitemid).attr('checked') ) { 238 239 // Add menu item to the queue 240 jQuery('#queue').append('<li id="menu-' + randomnumber + '" value="' + randomnumber + '"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">' + inputvaluevarname + '</span><span class="item-controls"><span class="item-type">' + additemtype + '</span><a class="item-edit thickbox" id="edit' + randomnumber + '" value="' + randomnumber +'" onClick="wp_edit_menu_item('+ randomnumber +')" title="' + navMenuL10n.thickbox + '" href="#TB_inline?height=380&width=300&inlineId=menu-item-settings">' + navMenuL10n.edit + '</a> | <a class="item-delete" id="delete' + randomnumber + '" value="' + randomnumber +'">Delete</a></span></dt></dl><a class="hide" href="' + inputvaluevarurl + '">' + inputvaluevarname + '</a><input type="hidden" name="postmenu' + randomnumber + '" id="postmenu' + randomnumber + '" value="' + inputitemid + '" /><input type="hidden" name="parent' + randomnumber + '" id="parent' + randomnumber + '" value="' + inputparentid + '" /><input type="hidden" name="item-title' + randomnumber + '" id="item-title' + randomnumber + '" value="' + inputvaluevarname + '" /><input type="hidden" name="item-url' + randomnumber + '" id="item-url' + randomnumber + '" value="' + inputvaluevarurl + '" /><input type="hidden" name="item-description' + randomnumber + '" id="item-description' + randomnumber + '" value="' + inputdescription + '" /><input type="hidden" name="position' + randomnumber + '" id="position' + randomnumber + '" value="' + randomnumber + '" /><input type="hidden" name="linktype' + randomnumber + '" id="linktype' + randomnumber + '" value="' + inputlinktype + '" /><input type="hidden" name="item-attr-title' + randomnumber + '" id="item-attr-title' + randomnumber + '" value="' + inputvaluevarname + '" /><input type="hidden" name="item-target' + randomnumber + '" id="item-target' + randomnumber + '" value="0" /></li>'); 241 } else { 242 243 // Get the item in the queue 244 for ( var i = 0; i < jQuery('#queue li input[name^="postmenu"]').length; i++ ) { 245 if ( itemid == jQuery('#queue li input[name^="postmenu"]')[i].value ) { 246 var menu_queue_id = jQuery('#queue li input[name^="postmenu"]')[i].name.substring( 8, jQuery('#queue li input[name^="postmenu"]')[i].name.length ); 247 }; 248 }; 249 250 // Removes the item from the queue 251 jQuery('#queue li#menu-' + menu_queue_id).remove(); 252 }; 253 }; 254 255 /** 256 * Grabs items from the queue and adds them to the menu. 257 * 258 * @param string button - a reference of the button that was clicked 259 */ 260 function wp_add_queued_items_to_menu( button ) { 261 // Grab items in queue 262 var items = jQuery('#queue').children(); 263 264 // Empty Queue 265 jQuery('#queue').empty(); 266 267 // Appends HTML to the menu 268 jQuery('#menu').append( items ); 269 270 // Give some feedback to the user 271 jQuery(items).each(function(){ 272 jQuery(this).find('dt').animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { jQuery(this).css( 'backgroundColor', '' ); }}); 273 }); 274 275 // Uncheck the checkboxes in the list 276 jQuery(button).offsetParent().find('.list-container input').attr('checked', false); 277 278 wp_update_post_data(); 279 280 // Enable drag-n-drop 281 wp_drag_and_drop(); 282 283 // Reload thickbox 284 tb_init('a.thickbox, area.thickbox, input.thickbox'); 285 }; 286 287 /** 288 * Allow the items in the Menu to be dragged and dropped. 289 */ 290 function wp_drag_and_drop() { 291 // make menu item draggable 292 jQuery('#menu li').draggable({ 226 293 handle: ' > dl', 227 294 opacity: .8, … … 231 298 }); 232 299 233 // make menu item droppable234 jQuery('#menu -' + randomnumber + ' dl, #menu-' + randomnumber + '.dropzone').droppable({235 accept: '# ' + randomnumber + ', #custom-navli',300 // make menu item droppable 301 jQuery('#menu li dl, #menu li .dropzone').droppable({ 302 accept: '#menu li', 236 303 tolerance: 'pointer', 237 drop: function(e, ui) 238 { 304 drop: function(e, ui) { 239 305 var li = jQuery(this).parent(); 240 306 var child = !jQuery(this).hasClass('dropzone'); 241 //Append UL to first child242 if (child && li.children('ul').length == 0)243 {244 li.append( '<ul/>');307 308 // Append UL to first child 309 if ( child && li.children('ul').length == 0 ) { 310 li.append( '<ul/>' ); 245 311 } 246 //Make it draggable 247 if (child) 248 { 249 li.children('ul').append(ui.draggable); 312 // Make it draggable 313 if ( child ) { 314 li.children('ul').append( ui.draggable ); 315 } else { 316 li.before( ui.draggable ); 250 317 } 251 else252 {253 li.before(ui.draggable);254 }255 318 256 319 li.find('dl,.dropzone').css({ backgroundColor: '', borderColor: '' }); 257 320 258 321 var draggablevalue = ui.draggable.attr('value'); 259 var droppablevalue = li.attr('value'); 260 li.find('#menu-' + draggablevalue).find('#parent' + draggablevalue).val(droppablevalue); 261 jQuery(this).parent().find("dt").removeAttr('style'); 262 jQuery(this).parent().find("div:first").removeAttr('style'); 322 var droppablevalue = li.attr('value'); 323 324 li.find('#menu-' + draggablevalue).find('#parent' + draggablevalue).val(droppablevalue); 325 jQuery(this).parent().find("dt").removeAttr('style'); 326 jQuery(this).parent().find("div:first").removeAttr('style'); 263 327 264 328 }, 265 over: function() 266 { 267 //Add child 268 if (jQuery(this).attr('class') == 'dropzone ui-droppable') 269 { 329 over: function() { 330 // Add child 331 if ( jQuery(this).attr('class') == 'dropzone ui-droppable' ) { 270 332 jQuery(this).parent().find("div:first").css('background', 'none').css('height', '50px'); 271 333 } 272 //Add above 273 else if (jQuery(this).attr('class') == 'ui-droppable') 274 { 334 // Add above 335 else if ( jQuery(this).attr('class') == 'ui-droppable' ) { 275 336 jQuery(this).parent().find("dt:first").css('background', '#d8d8d8'); 276 } 277 //do nothing 278 else { 279 337 } else { 338 // do nothing 280 339 } 281 340 var parentid = jQuery(this).parent().attr('id'); 282 341 283 342 }, 284 out: function() 285 { 343 out: function() { 286 344 jQuery(this).parent().find("dt").removeAttr('style'); 287 345 jQuery(this).parent().find("div:first").removeAttr('style'); 288 346 jQuery(this).filter('.dropzone').css({ borderColor: '' }); 289 347 } 290 }); 291 292 updatepostdata(); 293 }; 348 } 349 ); 350 } 351 352 /** 353 * Gets a unique number based on how many items are in the menu 354 */ 355 function wp_get_unique_menu_id() { 356 var count = document.getElementById('menu').getElementsByTagName('li').length + 1; 357 var randomnumber = count; 358 var validatetest = 0; 359 360 try { 361 var test = document.getElementById( 'menu-' + randomnumber.toString() ).value; 362 } 363 catch ( err ) { 364 validatetest = 1; 365 } 366 367 while ( validatetest == 0 ) { 368 randomnumber = randomnumber + 1; 369 try { 370 var test2 = document.getElementById( 'menu-' + randomnumber.toString() ).value; 371 } 372 catch ( err ) { 373 validatetest = 1; 374 } 375 } 376 return randomnumber; 377 } -
trunk/wp-admin/js/nav-menu-dynamic-functions.js
r13449 r13473 1 function removeitem(c){var b=document.getElementById("menu-"+c);if(b){var a=document.getElementById("menu-"+c).parentNode;throwaway_node=a.removeChild(b)}updatepostdata()}function edititem(a){itemTitle=jQuery("#title"+a).attr("value");itemURL=jQuery("#linkurl"+a).attr("value");itemAnchorTitle=jQuery("#anchortitle"+a).attr("value");itemNewWindow=jQuery("#newwindow"+a).attr("value");itemDesc=jQuery("#description"+a).attr("value");jQuery("#dialog-confirm").dialog("option","itemID",a);jQuery("#dialog-confirm").dialog("open");jQuery("#edittitle").attr("value",itemTitle);jQuery("#editlink").attr("value",itemURL);jQuery("#editanchortitle").attr("value",itemAnchorTitle);jQuery("#editnewwindow option[value='"+itemNewWindow+"']").attr("selected","selected");jQuery("#editdescription").attr("value",itemDesc)}function updatepostdata(){var a=0;jQuery("#custom-nav").find("li").each(function(c){c=c+1;var b=jQuery(this).attr("value");jQuery(this).find("#position"+b).attr("value",c);jQuery(this).attr("id","menu-"+c);jQuery(this).attr("value",c);jQuery(this).find("#dbid"+b).attr("name","dbid"+c);jQuery(this).find("#dbid"+b).attr("id","dbid"+c);jQuery(this).find("#postmenu"+b).attr("name","postmenu"+c);jQuery(this).find("#postmenu"+b).attr("id","postmenu"+c);var d=jQuery(this).find("#parent"+b).parent().parent().parent().attr("value");jQuery(this).find("#parent"+b).attr("name","parent"+c);jQuery(this).find("#parent"+b).attr("id","parent"+c);if(d){}else{d=0}jQuery(this).find("#parent"+b).attr("value",d);jQuery(this).find("#title"+b).attr("name","title"+c);jQuery(this).find("#title"+b).attr("id","title"+c);jQuery(this).find("#linkurl"+b).attr("name","linkurl"+c);jQuery(this).find("#linkurl"+b).attr("id","linkurl"+c);jQuery(this).find("#description"+b).attr("name","description"+c);jQuery(this).find("#description"+b).attr("id","description"+c);jQuery(this).find("#icon"+b).attr("name","icon"+c);jQuery(this).find("#icon"+b).attr("id","icon"+c);jQuery(this).find("#position"+b).attr("name","position"+c);jQuery(this).find("#position"+b).attr("id","position"+c);jQuery(this).find("#linktype"+b).attr("name","linktype"+c);jQuery(this).find("#linktype"+b).attr("id","linktype"+c);jQuery(this).find("#anchortitle"+b).attr("name","anchortitle"+c);jQuery(this).find("#anchortitle"+b).attr("id","anchortitle"+c);jQuery(this).find("#newwindow"+b).attr("name","newwindow"+c);jQuery(this).find("#newwindow"+b).attr("id","newwindow"+c);jQuery(this).find("dl > dt > span > #remove"+b).attr("value",c);jQuery(this).find("dl > dt > span > #remove"+b).attr("onClick","removeitem("+c+")");jQuery(this).find("dl > dt > span > #remove"+b).attr("id","remove"+c);jQuery("#li-count").attr("value",c)})}function appendToList(b,s,d,n,h,l,e){var k="";var c="";var r="";var o="";var i="";var a="";if(s==navMenuL10n.custom){k=document.getElementById("custom-menu-item-name").value;c=document.getElementById("custom-menu-item-url").value;r="";o="";inputlinktype="custom";i=""}else{if(s==navMenuL10n.page){k=htmlentities(d.toString());c=n.toString();r=h.toString();o="0";inputlinktype="page";i=htmlentities(e.toString())}else{if(s==navMenuL10n.category){k=htmlentities(d.toString());c=n.toString();r=h.toString();o="0";inputlinktype="category";i=htmlentities(e.toString())}else{k="";k="";r="";o="";inputlinktype="custom";i=""}}}var g=document.getElementById("custom-nav").getElementsByTagName("li").length+1;var p=g;var m=0;try{var q=document.getElementById("menu-"+p.toString()).value}catch(f){m=1}while(m==0){p=p+1;try{var j=document.getElementById("menu-"+p.toString()).value}catch(f){m=1}}jQuery(".maintitle").after('<div id="message" class="updated fade below-h2"><p>Menu Item added!</p></div>');jQuery("#message").animate({opacity:1},2000).fadeOut(300,function(){jQuery(this).remove()});jQuery("#custom-nav").append('<li id="menu-'+p+'" value="'+p+'"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="title">'+k+'</span><span class="controls"><span class="type">'+s+'</span><a id="edit'+p+'" onclick="edititem('+p+')" value="'+p+'"><img class="edit" alt="Edit Menu Item" title="Edit Menu Item" src="'+b+'/wp-admin/images/ico-edit.png" /></a> <a id="remove'+p+'" onclick="removeitem('+p+')" value="'+p+'"><img class="remove" alt="Remove from Custom Menu" title="Remove from Custom Menu" src="'+b+'/wp-admin/images/ico-close.png" /></a> <a href="'+c+'" target="_blank"><img alt="View Custom Link" title="View Custom Link" src="'+b+'/wp-admin/images/ico-viewpage.png" /></a></span></dt></dl><a class="hide" href="'+c+'">'+k+'</a><input type="hidden" name="postmenu'+p+'" id="postmenu'+p+'" value="'+r+'" /><input type="hidden" name="parent'+p+'" id="parent'+p+'" value="'+o+'" /><input type="hidden" name="title'+p+'" id="title'+p+'" value="'+k+'" /><input type="hidden" name="linkurl'+p+'" id="linkurl'+p+'" value="'+c+'" /><input type="hidden" name="description'+p+'" id="description'+p+'" value="'+i+'" /><input type="hidden" name="icon'+p+'" id="icon'+p+'" value="'+a+'" /><input type="hidden" name="position'+p+'" id="position'+p+'" value="'+p+'" /><input type="hidden" name="linktype'+p+'" id="linktype'+p+'" value="'+inputlinktype+'" /><input type="hidden" name="anchortitle'+p+'" id="anchortitle'+p+'" value="'+k+'" /><input type="hidden" name="newwindow'+p+'" id="newwindow'+p+'" value="0" /></li>');jQuery("#menu-"+p+"").draggable({handle:" > dl",opacity:0.8,addClasses:false,helper:"clone",zIndex:100});jQuery("#menu-"+p+" dl, #menu-"+p+" .dropzone").droppable({accept:"#"+p+", #custom-nav li",tolerance:"pointer",drop:function(x,w){var t=jQuery(this).parent();var y=!jQuery(this).hasClass("dropzone");if(y&&t.children("ul").length==0){t.append("<ul/>")}if(y){t.children("ul").append(w.draggable)}else{t.before(w.draggable)}t.find("dl,.dropzone").css({backgroundColor:"",borderColor:""});var v=w.draggable.attr("value");var u=t.attr("value");t.find("#menu-"+v).find("#parent"+v).val(u);jQuery(this).parent().find("dt").removeAttr("style");jQuery(this).parent().find("div:first").removeAttr("style")},over:function(){if(jQuery(this).attr("class")=="dropzone ui-droppable"){jQuery(this).parent().find("div:first").css("background","none").css("height","50px")}else{if(jQuery(this).attr("class")=="ui-droppable"){jQuery(this).parent().find("dt:first").css("background","#d8d8d8")}else{}}var t=jQuery(this).parent().attr("id")},out:function(){jQuery(this).parent().find("dt").removeAttr("style");jQuery(this).parent().find("div:first").removeAttr("style");jQuery(this).filter(".dropzone").css({borderColor:""})}});updatepostdata()};1 function wp_update_links_list(e){var link='<li><dl><dt><label class="item-title"><input type="checkbox" id="link-'+e.link_id+'" name="'+e.link_name+'" value="'+e.link_url+'" />'+e.link_name+"</label></dt></dl></li>";jQuery("#available-links .list").prepend(link);jQuery("#available-links .list #link-"+e.link_id).parent().animate({backgroundColor:"#FFFF33"},{duration:"normal",complete:function(){jQuery(this).css("backgroundColor","")}})}function wp_remove_menu_item(o){var todelete=document.getElementById("menu-"+o);if(todelete){jQuery(todelete).find("dt").each(function(){jQuery(this).animate({backgroundColor:"#FF3333"},{duration:"normal",complete:function(){jQuery(this).parent().parent().remove()}})});wp_update_post_data()}}function wp_edit_menu_item(id){console.log("wp_edit_menu_item");var itemTitle=jQuery("#item-title"+id).val();var itemURL=jQuery("#item-url"+id).val();var itemAttrTitle=jQuery("#item-attr-title"+id).val();var itemTarget=jQuery("#item-target"+id).val();var itemDesc=jQuery("#item-description"+id).val();console.log(id);console.log(itemTitle);console.log(itemURL);console.log(itemAttrTitle);console.log(itemTarget);console.log(itemDesc);jQuery("#edit-item-id").val(id);jQuery("#edit-item-title").val(itemTitle);jQuery("#edit-item-url").val(itemURL);jQuery("#edit-item-attr-title").val(itemAttrTitle);jQuery("#edit-item-target").val(itemTarget);jQuery("#edit-item-target option[value='"+itemTarget+"']").attr("selected","selected");jQuery("#edit-item-description").val(itemDesc)}function wp_update_menu_item(){var id=jQuery("#edit-item-id").val();var itemTitle=jQuery("#edit-item-title").val();var itemURL=jQuery("#edit-item-url").val();var itemAttrTitle=jQuery("#edit-item-attr-title").val();var itemTarget=jQuery("#edit-item-target").val();var itemDesc=jQuery("#edit-item-description").val();console.log(id);console.log(itemTitle);console.log(itemURL);console.log(itemAttrTitle);console.log(itemTarget);console.log(itemDesc);jQuery("#menu-"+id).find(".item-title:first").html(itemTitle);jQuery("#item-title"+id).val(itemTitle);jQuery("#item-url"+id).val(itemURL);jQuery("#item-attr-title"+id).val(itemAttrTitle);jQuery("#item-target"+id).val(itemTarget);jQuery("#item-description"+id).val(itemDesc)}function wp_update_post_data(){var i=0;jQuery("#menu li").each(function(i){i=i+1;var j=jQuery(this).attr("value");jQuery(this).find("#position"+j).attr("value",i);jQuery(this).attr("id","menu-"+i);jQuery(this).attr("value",i);jQuery(this).find("#dbid"+j).attr("name","dbid"+i);jQuery(this).find("#dbid"+j).attr("id","dbid"+i);jQuery(this).find("#postmenu"+j).attr("name","postmenu"+i);jQuery(this).find("#postmenu"+j).attr("id","postmenu"+i);var p=jQuery(this).find("#parent"+j).parent().parent().parent().attr("value");jQuery(this).find("#parent"+j).attr("name","parent"+i);jQuery(this).find("#parent"+j).attr("id","parent"+i);if(p){}else{p=0}jQuery(this).find("#parent"+j).attr("value",p);jQuery(this).find("#item-title"+j).attr("name","item-title"+i);jQuery(this).find("#item-title"+j).attr("id","item-title"+i);jQuery(this).find("#item-url"+j).attr("name","item-url"+i);jQuery(this).find("#item-url"+j).attr("id","item-url"+i);jQuery(this).find("#item-description"+j).attr("name","item-description"+i);jQuery(this).find("#item-description"+j).attr("id","item-description"+i);jQuery(this).find("#item-attr-title"+j).attr("name","item-attr-title"+i);jQuery(this).find("#item-attr-title"+j).attr("id","item-attr-title"+i);jQuery(this).find("#item-target"+j).attr("name","item-target"+i);jQuery(this).find("#item-target"+j).attr("id","item-target"+i);jQuery(this).find("#position"+j).attr("name","position"+i);jQuery(this).find("#position"+j).attr("id","position"+i);jQuery(this).find("#linktype"+j).attr("name","linktype"+i);jQuery(this).find("#linktype"+j).attr("id","linktype"+i);jQuery("#li-count").attr("value",i)})}function wp_add_item_to_menu(additemtype,itemtext,itemurl,itemid,itemparentid,itemdescription){var inputvaluevarname="";var inputvaluevarurl="";var inputitemid="";var inputparentid="";var inputdescription="";var randomnumber=wp_get_unique_menu_id();inputvaluevarname=htmlentities(itemtext.toString());inputvaluevarurl=itemurl.toString();inputitemid=itemid;inputparentid=itemparentid;inputlinktype="custom";inputdescription=htmlentities(itemdescription.toString());jQuery("#menu").append('<li id="menu-'+randomnumber+'" value="'+randomnumber+'"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">'+inputvaluevarname+'</span><span class="item-controls"><span class="item-type">'+additemtype+'</span><a class="item-edit thickbox" id="edit'+randomnumber+'" value="'+randomnumber+'" onClick="wp_edit_menu_item('+randomnumber+')" title="'+navMenuL10n.thickbox+'" href="#TB_inline?height=380&width=300&inlineId=menu-item-settings">'+navMenuL10n.edit+'</a> | <a class="item-delete" id="delete'+randomnumber+'" value="'+randomnumber+'">Delete</a></span></dt></dl><a class="hide" href="'+inputvaluevarurl+'">'+inputvaluevarname+'</a><input type="hidden" name="postmenu'+randomnumber+'" id="postmenu'+randomnumber+'" value="'+inputitemid+'" /><input type="hidden" name="parent'+randomnumber+'" id="parent'+randomnumber+'" value="'+inputparentid+'" /><input type="hidden" name="item-title'+randomnumber+'" id="item-title'+randomnumber+'" value="'+inputvaluevarname+'" /><input type="hidden" name="item-url'+randomnumber+'" id="item-url'+randomnumber+'" value="'+inputvaluevarurl+'" /><input type="hidden" name="item-description'+randomnumber+'" id="item-description'+randomnumber+'" value="'+inputdescription+'" /><input type="hidden" name="position'+randomnumber+'" id="position'+randomnumber+'" value="'+randomnumber+'" /><input type="hidden" name="linktype'+randomnumber+'" id="linktype'+randomnumber+'" value="'+inputlinktype+'" /><input type="hidden" name="item-attr-title'+randomnumber+'" id="item-attr-title'+randomnumber+'" value="'+inputvaluevarname+'" /><input type="hidden" name="item-target'+randomnumber+'" id="item-target'+randomnumber+'" value="0" /></li>');jQuery("#menu #menu-"+randomnumber+" dt:first").animate({backgroundColor:"#FFFF33"},{duration:"normal",complete:function(){jQuery(this).css("backgroundColor","")}});wp_drag_and_drop();tb_init("a.thickbox, area.thickbox, input.thickbox")}function wp_update_queue(additemtype,itemtext,itemurl,itemid,itemparentid,itemdescription){var inputvaluevarname="";var inputvaluevarurl="";var inputitemid="";var inputparentid="";var inputdescription="";var randomnumber=wp_get_unique_menu_id();if(additemtype==navMenuL10n.page){inputvaluevarname=htmlentities(itemtext.toString());inputvaluevarurl=itemurl.toString();inputitemid=itemid.toString();inputparentid="0";inputlinktype="page";inputdescription=htmlentities(itemdescription.toString())}else{if(additemtype==navMenuL10n.category){inputvaluevarname=htmlentities(itemtext.toString());inputvaluevarurl=itemurl.toString();inputitemid=itemid.toString();inputparentid="0";inputlinktype="category";inputdescription=htmlentities(itemdescription.toString())}}if(jQuery(menu_item_id="#menu-item-"+inputitemid).attr("checked")){jQuery("#queue").append('<li id="menu-'+randomnumber+'" value="'+randomnumber+'"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">'+inputvaluevarname+'</span><span class="item-controls"><span class="item-type">'+additemtype+'</span><a class="item-edit thickbox" id="edit'+randomnumber+'" value="'+randomnumber+'" onClick="wp_edit_menu_item('+randomnumber+')" title="'+navMenuL10n.thickbox+'" href="#TB_inline?height=380&width=300&inlineId=menu-item-settings">'+navMenuL10n.edit+'</a> | <a class="item-delete" id="delete'+randomnumber+'" value="'+randomnumber+'">Delete</a></span></dt></dl><a class="hide" href="'+inputvaluevarurl+'">'+inputvaluevarname+'</a><input type="hidden" name="postmenu'+randomnumber+'" id="postmenu'+randomnumber+'" value="'+inputitemid+'" /><input type="hidden" name="parent'+randomnumber+'" id="parent'+randomnumber+'" value="'+inputparentid+'" /><input type="hidden" name="item-title'+randomnumber+'" id="item-title'+randomnumber+'" value="'+inputvaluevarname+'" /><input type="hidden" name="item-url'+randomnumber+'" id="item-url'+randomnumber+'" value="'+inputvaluevarurl+'" /><input type="hidden" name="item-description'+randomnumber+'" id="item-description'+randomnumber+'" value="'+inputdescription+'" /><input type="hidden" name="position'+randomnumber+'" id="position'+randomnumber+'" value="'+randomnumber+'" /><input type="hidden" name="linktype'+randomnumber+'" id="linktype'+randomnumber+'" value="'+inputlinktype+'" /><input type="hidden" name="item-attr-title'+randomnumber+'" id="item-attr-title'+randomnumber+'" value="'+inputvaluevarname+'" /><input type="hidden" name="item-target'+randomnumber+'" id="item-target'+randomnumber+'" value="0" /></li>')}else{for(var i=0;i<jQuery('#queue li input[name^="postmenu"]').length;i++){if(itemid==jQuery('#queue li input[name^="postmenu"]')[i].value){var menu_queue_id=jQuery('#queue li input[name^="postmenu"]')[i].name.substring(8,jQuery('#queue li input[name^="postmenu"]')[i].name.length)}}jQuery("#queue li#menu-"+menu_queue_id).remove()}}function wp_add_queued_items_to_menu(button){var items=jQuery("#queue").children();jQuery("#queue").empty();jQuery("#menu").append(items);jQuery(items).each(function(){jQuery(this).find("dt").animate({backgroundColor:"#FFFF33"},{duration:"normal",complete:function(){jQuery(this).css("backgroundColor","")}})});jQuery(button).offsetParent().find(".list-container input").attr("checked",false);wp_update_post_data();wp_drag_and_drop();tb_init("a.thickbox, area.thickbox, input.thickbox")}function wp_drag_and_drop(){jQuery("#menu li").draggable({handle:" > dl",opacity:0.8,addClasses:false,helper:"clone",zIndex:100});jQuery("#menu li dl, #menu li .dropzone").droppable({accept:"#menu li",tolerance:"pointer",drop:function(e,ui){var li=jQuery(this).parent();var child=!jQuery(this).hasClass("dropzone");if(child&&li.children("ul").length==0){li.append("<ul/>")}if(child){li.children("ul").append(ui.draggable)}else{li.before(ui.draggable)}li.find("dl,.dropzone").css({backgroundColor:"",borderColor:""});var draggablevalue=ui.draggable.attr("value");var droppablevalue=li.attr("value");li.find("#menu-"+draggablevalue).find("#parent"+draggablevalue).val(droppablevalue);jQuery(this).parent().find("dt").removeAttr("style");jQuery(this).parent().find("div:first").removeAttr("style")},over:function(){if(jQuery(this).attr("class")=="dropzone ui-droppable"){jQuery(this).parent().find("div:first").css("background","none").css("height","50px")}else{if(jQuery(this).attr("class")=="ui-droppable"){jQuery(this).parent().find("dt:first").css("background","#d8d8d8")}else{}}var parentid=jQuery(this).parent().attr("id")},out:function(){jQuery(this).parent().find("dt").removeAttr("style");jQuery(this).parent().find("div:first").removeAttr("style");jQuery(this).filter(".dropzone").css({borderColor:""})}})}function wp_get_unique_menu_id(){var count=document.getElementById("menu").getElementsByTagName("li").length+1;var randomnumber=count;var validatetest=0;try{var test=document.getElementById("menu-"+randomnumber.toString()).value}catch(err){validatetest=1}while(validatetest==0){randomnumber=randomnumber+1;try{var test2=document.getElementById("menu-"+randomnumber.toString()).value}catch(err){validatetest=1}}return randomnumber}; -
trunk/wp-admin/nav-menus.php
r13406 r13473 4 4 * Interface functions 5 5 * 6 * @version 1.1.06 * @version 2.0.0 7 7 * 8 8 * @package WordPress … … 12 12 require_once('admin.php'); 13 13 14 /* 15 TODO 16 Add caps: edit_menus, delete_menus 17 */ 14 18 if ( ! current_user_can('switch_themes') ) 15 19 wp_die( __( 'Cheatin’ uh?' )); … … 25 29 wp_enqueue_script( 'jquery-autocomplete' ); 26 30 wp_enqueue_script( 'nav-menu-php-functions' ); 31 add_thickbox(); 27 32 28 33 require_once( 'admin-header.php' ); … … 38 43 $updated = false; 39 44 $advanced_option_descriptions = 'no'; 45 46 // Get all menu link items 47 $available_links = new WP_Query( array( 'post_status' => 'any', 'post_type' => 'nav_menu_item', 'meta_key' => 'menu_type', 'meta_value' => 'custom' ) ); 40 48 41 49 // Check which menu is selected and if menu is in edit already … … 49 57 } 50 58 51 if ( isset( $_POST[ 'delete-menu' ] ) && $menu_selected_id > 0 ) { 52 wp_delete_nav_menu( $menu_selected_id ); 59 // Delete a menu 60 if ( isset($_GET['delete-menu']) && $_GET['delete-menu'] > 0 ) { 61 // if ( ! current_user_can('delete_menus') ) 62 // wp_die( __( 'Cheatin’ uh?' )); 63 64 $menu_id = (int) $_GET['delete-menu']; 65 check_admin_referer( 'delete_menu-' . $menu_id ); 66 67 wp_delete_nav_menu( $menu_id ); 68 $messages_div = '<div id="message" class="updated fade below-h2"><p>' . __('Menu successfully deleted.') . '</p></div>'; 53 69 $menu_selected_id = 0; 54 70 $updated = true; … … 56 72 57 73 // Default Menu to show 58 $ custom_menus = wp_get_nav_menus();59 60 if ( empty($ custom_menus)&& empty($_POST) ) {74 $menus = wp_get_nav_menus(); 75 76 if ( empty($menus) && empty($_POST) ) { 61 77 wp_create_default_nav_menu(); 62 $custom_menus = wp_get_nav_menus(); 63 } 64 65 if ( ! $menu_selected_id && ! empty( $custom_menus ) ) 66 $menu_selected_id = $custom_menus[0]->term_id; 67 78 $menus = wp_get_nav_menus(); 79 } 80 81 if ( ! $menu_selected_id && ! empty($menus) ) 82 $menu_selected_id = $menus[0]->term_id; 83 84 // Get the name of the current Menu 68 85 $menu_title = ''; 86 $valid_menu = false; 69 87 if ( $menu_selected_id > 0 ) { 70 foreach ( $ custom_menus as $menu ) {88 foreach ( $menus as $menu ) { 71 89 if ( $menu->term_id == $menu_selected_id ) { 72 90 $menu_title = $menu->name; 91 $valid_menu = true; 73 92 break; 74 93 } … … 82 101 83 102 // Create a new menu. Menus are stored as terms in the 'menu' taxonomy. 84 if ( isset( $_POST[' add-menu'] ) && ! $updated ) {85 $insert_menu_name = $_POST[' add-menu-name'];103 if ( isset( $_POST['create-menu'] ) && ! $updated ) { 104 $insert_menu_name = $_POST['create-menu-name']; 86 105 87 106 if ( $insert_menu_name ) { … … 90 109 $messages_div = '<div id="message" class="error fade below-h2"><p>' . $menu->get_error_message() . '</p></div>'; 91 110 } else { 92 $ custom_menus[$menu->term_id] = $menu;111 $menus[$menu->term_id] = $menu; 93 112 $menu_selected_id = $menu->term_id; 94 113 $menu_id_in_edit = $menu_selected_id; … … 106 125 $menu_items = wp_get_nav_menu_items( $menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID') ); 107 126 $parent_menu_ids = array(); 108 127 109 128 // Loop through all POST variables 110 129 for ( $k = 1; $k <= $post_counter; $k++ ) { … … 112 131 $object_id = isset( $_POST['postmenu'.$k] )? $_POST['postmenu'.$k] : 0; 113 132 $parent_id = isset( $_POST['parent'.$k] )? $_POST['parent'.$k] : 0; 114 $custom_title = isset( $_POST[' title'.$k] )? $_POST['title'.$k] : '';115 $custom_linkurl = ( isset( $_POST[' linkurl'.$k] ) && 'custom' == $_POST['linktype'.$k] ) ? $_POST['linkurl'.$k] : '';116 $custom_description = isset( $_POST[' description'.$k] )? $_POST['description'.$k] : '';133 $custom_title = isset( $_POST['item-title'.$k] )? $_POST['item-title'.$k] : ''; 134 $custom_linkurl = ( isset( $_POST['item-url'.$k] ) && 'custom' == $_POST['linktype'.$k] ) ? $_POST['item-url'.$k] : ''; 135 $custom_description = isset( $_POST['item-description'.$k] )? $_POST['item-description'.$k] : ''; 117 136 // doesn't seem to be used by UI 118 137 $icon = isset( $_POST['icon'.$k] )? $_POST['icon'.$k] : 0; 119 138 $position = isset( $_POST['position'.$k] )? $_POST['position'.$k] : 0; 120 139 $linktype = isset( $_POST['linktype'.$k] )? $_POST['linktype'.$k] : 'custom'; 121 $custom_anchor_title = isset( $_POST[' anchortitle'.$k] )? $_POST['anchortitle'.$k] : $custom_title;122 $new_window = isset( $_POST[' newwindow'.$k] )? $_POST['newwindow'.$k] : 0;140 $custom_anchor_title = isset( $_POST['item-attr-title'.$k] )? $_POST['item-attr-title'.$k] : $custom_title; 141 $new_window = isset( $_POST['item-target'.$k] )? $_POST['item-target'.$k] : 0; 123 142 124 143 $post = array( 'post_status' => 'publish', 'post_type' => 'nav_menu_item', 'post_author' => $user_ID, … … 129 148 if ( $parent_id > 0 && isset( $parent_menu_ids[$parent_id] ) ) 130 149 $post['post_parent'] = $parent_menu_ids[$parent_id]; 131 150 132 151 // New menu item 133 152 if ( $db_id == 0 ) { … … 161 180 <div class="wrap"> 162 181 <?php screen_icon(); ?> 163 <h2><?php esc_html_e('Menus') ?></h2>182 <h2><?php esc_html_e('Menus'); ?></h2> 164 183 <?php echo $messages_div; ?> 165 184 <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> 166 185 167 168 <form onsubmit="updatepostdata()" action="<?php echo admin_url( 'nav-menus.php' ); ?>" method="post" enctype="multipart/form-data"> 169 <?php if ( ! empty( $custom_menus ) && count( $custom_menus ) > 1 ) : ?> 186 <form onsubmit="wp_update_post_data();" action="<?php echo admin_url( 'nav-menus.php' ); ?>" method="post" enctype="multipart/form-data"> 187 <?php if ( !empty($menus) && count($menus) > 1 ) : ?> 170 188 <ul class="subsubsub"> 171 189 <?php 172 foreach ( $ custom_menus as $menu ) {173 $sep = end( $ custom_menus ) == $menu ? '' : ' | ';190 foreach ( $menus as $menu ) { 191 $sep = end( $menus ) == $menu ? '' : ' | '; 174 192 if ( ( $menu_id_in_edit == $menu->term_id ) || ( $menu_selected_id == $menu->term_id ) ) { ?> 175 193 <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> … … 182 200 <?php endif; ?> 183 201 184 <div id="menus-container" class="metabox-holder has-right-sidebar"> 202 <div id="menu-management" class="metabox-holder has-right-sidebar"> 203 <div id="post-body"> 204 <div id="post-body-content"> 205 <div id="normal-sortables" class="meta-box-sortables ui-sortable"> 206 <?php if ( $valid_menu and ! empty( $menus ) ) : ?> 207 <div id="menu-container" class="postbox"> 208 <h3 class="hndle"><?php echo esc_html( $menu_title ); ?></h3> 209 <div class="inside"> 210 <input type="hidden" name="li-count" id="li-count" value="0" /> 211 <input type="hidden" name="menu-id-in-edit" id="menu-id-in-edit" value="<?php echo esc_attr( $menu_selected_id ); ?>" /> 212 213 <ul id="menu"> 214 <?php 215 if ( $menu_selected_id > 0 ) { 216 wp_print_nav_menu( array( 'type' => 'backend', 'name' => $menu_title, 'id' => $menu_selected_id ) ); 217 } 218 ?> 219 </ul><!-- /#menu--> 220 221 <div id="queue" class="hide"> 222 </div><!--/#queue--> 223 </div><!-- /.inside --> 224 <!-- /#nav-menu-canvas .postbox--> 225 </div> 226 <p> 227 <script type="text/javascript"> 228 wp_update_post_data(); 229 </script> 230 <a class="submitdelete deletion" href="<?php echo wp_nonce_url( admin_url('nav-menus.php?delete-menu=' . $menu_selected_id), 'delete_menu-' . $menu_selected_id ); ?>"><?php _e('Delete Menu'); ?></a> 231 <input class="button-primary save" name="save_menu" type="submit" value="<?php esc_attr_e('Save All Changes'); ?>" /> 232 <br class="clear" /> 233 </p> 234 <?php endif; ?> 235 </div><!-- /#normal-sortables--> 236 </div><!-- /#post-body-content--> 237 </div><!--- /#post-body --> 185 238 <div id="menu-settings-column" class="inner-sidebar"> 186 239 <div id="side-sortables" class="meta-box-sortables ui-sortable"> 187 240 188 <div id="add-menu" class="postbox"> 189 <div class="handlediv" title="Click to toggle"><br /></div> 190 <h3 class="hndle"><?php esc_html_e('Add Menu'); ?></h3> 241 <div id="create-menu" class="postbox"> 242 <h3 class="hndle"><?php esc_html_e('Create Menu'); ?></h3> 191 243 <div class="inside"> 192 < span>193 <input id="add-menu-name" name="add-menu-name" type="text" class="regular-text" value="" />194 <input id="add-menu" type="submit" value="<?php esc_attr_e('Add Menu'); ?>" name="add-menu" class="button" />195 </ span>244 <p> 245 <input type="text" name="create-menu-name" id="create-menu-name" class="regular-text" value="" /> 246 <input type="submit" name="create-menu" id="create-menu" class="button" value="<?php esc_attr_e('Create Menu'); ?>" /> 247 </p> 196 248 </div><!-- /.inside--> 197 </div><!--END # add-menu-->249 </div><!--END #create-menu--> 198 250 199 251 <div id="add-custom-link" class="postbox"> 200 <div class="handlediv" title="Click to toggle"><br /></div>201 252 <h3 class="hndle"><?php esc_html_e('Add a Custom Link'); ?></h3> 202 <div class="inside"> 253 <div class="inside"> 254 <p id="menu-item-url-wrap"> 255 <label class="howto" for="menu-item-url"> 256 <span><?php _e('URL'); ?></span> 257 <input id="menu-item-url" name="menu-item-url" type="text" class="code" value="http://" /> 258 </label> 259 </p> 260 <br class="clear" /> 261 <p id="menu-item-name-wrap"> 262 <label class="howto" for="custom-menu-item-name"> 263 <span><?php _e('Text'); ?></span> 264 <input id="menu-item-name" type="text" class="regular-text" value="<?php echo esc_attr( __('Menu Item') ); ?>" /> 265 </label> 266 </p> 203 267 204 <p class="howto"><label for="custom-menu-item-url"><input id="custom-menu-item-url" type="text" class="widefat code" value="http://" /><?php _e('URL'); ?></label></p> 205 206 <?php $template_dir = get_bloginfo('url'); ?> 207 <input type="hidden" id="template-dir" value="<?php echo esc_attr($template_dir); ?>" /> 208 209 <p class="howto"><label for="custom-menu-item-name"><input id="custom-menu-item-name" type="text" class="widefat regular-text" value="<?php echo esc_attr( __('Menu Item') ); ?>" /><?php _e('Text'); ?></label></p> 210 211 <label class="howto" for="custom_menu_item_description" <?php if ($advanced_option_descriptions == 'no') { ?>style="display:none;"<?php } ?>> 212 <input id="custom_menu_item_description" type="text" class="widefat regular-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','');" /> 213 <?php _e('Description'); ?> 214 </label> 215 216 <?php if ( 'no' != $advanced_option_descriptions ) { echo '<br />'; } ?> 217 218 <a class="addtomenu button" 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 Link'); ?></a> 268 <?php if ( $available_links->posts ) : ?> 269 <p class="button-controls"> 270 <a class="show-all button"><?php _e('View All'); ?></a> 271 <a class="hide-all button"><?php _e('Hide All'); ?></a> 272 </p> 273 <div id="available-links" class="list-wrap"> 274 <div class="list-container"> 275 <ul class="list"> 276 <?php 277 foreach ( $available_links->posts as $link ) : 278 $url = get_post_meta( $link->ID, 'menu_link' ); 279 ?> 280 <li> 281 <dl> 282 <dt> 283 <label class="item-title"><input type="checkbox" id="link-<?php echo esc_attr($link->ID); ?>" name="<?php echo esc_attr($link->post_title); ?>" value="<?php echo esc_attr($url[0]); ?>" /><?php echo esc_html($link->post_title); ?></label> 284 </dt> 285 </dl> 286 </li> 287 <?php 288 endforeach; 289 ?> 290 </ul> 291 </div><!-- /.list-container--> 292 </div><!-- /#available-links--> 293 <?php endif; ?> 294 <p class="add-to-menu"> 295 <a class="button"><?php _e('Add to Menu'); ?></a> 296 </p> 219 297 <br class="clear" /> 220 298 </div><!-- /.inside--> … … 222 300 223 301 <div id="add-pages" class="postbox"> 224 <div class="handlediv" title="Click to toggle"><br /></div>225 302 <h3 class="hndle"><?php esc_html_e('Add an Existing Page'); ?></h3> 226 303 <div class="inside"> 227 304 <?php 228 305 $pages_args = array( 229 'child_of' => 0, 230 'sort_order' => 'ASC', 231 'sort_column' => 'post_title', 232 'hierarchical' => 1, 233 'exclude' => '', 234 'include' => '', 235 'meta_key' => '', 236 'meta_value' => '', 237 'authors' => '', 238 'parent' => -1, 239 'exclude_tree' => '', 240 'number' => '', 241 'offset' => 0 306 'child_of' => 0, 'sort_order' => 'ASC', 'sort_column' => 'post_title', 'hierarchical' => 1, 307 'exclude' => '', 'include' => '', 'meta_key' => '', 'meta_value' => '', 'authors' => '', 308 'parent' => -1, 'exclude_tree' => '', 'number' => '', 'offset' => 0 242 309 ); 243 310 $page_name = ''; 244 $pages_array = get_pages( $pages_args);311 $pages_array = get_pages( $pages_args ); 245 312 if ( $pages_array ) { 246 313 foreach ( $pages_array as $post ) { … … 253 320 <script type="text/javascript" charset="<?php bloginfo('charset'); ?>"> 254 321 jQuery(document).ready(function(){ 255 var posts = "<?php echo esc_js( $page_name ); ?>".split("|"); 256 jQuery("#page-search").autocomplete(posts); 257 jQuery("#page-search").result(function(event, data, formatted) { 258 jQuery('#existing-pages').css('display','block'); 259 jQuery("#existing-pages dt:contains('" + data + "')").css("display", "block"); 260 jQuery('#show-pages').hide(); 261 jQuery('#hide-pages').show(); 322 var posts = "<?php echo esc_js( $page_name ); ?>".split('|'); 323 jQuery('#add-pages .quick-search').autocomplete(posts); 324 325 326 jQuery('#add-pages .quick-search').result(function(event, data, formatted) { 327 jQuery('#add-pages .list-wrap').css('display','block'); 328 jQuery("#add-pages .list-wrap dt:contains('" + data + "')").css('display','block'); 329 jQuery('#add-pages .show-all').hide(); 330 jQuery('#add-pages .hide-all').show(); 262 331 }); 263 jQuery('#existing-pages').css('display','none');264 332 }); 265 333 </script> 266 <input type="text" onfocus="jQuery('#page-search').attr('value','');" id="page-search" class="regular-text" value="<?php esc_attr_e('Search Pages'); ?>" /> 267 268 <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> 269 <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> 270 271 <script type="text/javascript"> 272 jQuery('#hide-pages').hide(); 273 </script> 334 <p> 335 <input type="text" class="quick-search regular-text" value="" /> 336 <a class="quick-search-submit button"><?php _e('Search'); ?></a> 337 </p> 274 338 339 <p class="button-controls"> 340 <a class="show-all button"><?php _e('View All'); ?></a> 341 <a class="hide-all button"><?php _e('Hide All'); ?></a> 342 </p> 275 343 276 <div id="existing-pages" class="list-container"> 277 <ul class="list"> 278 <?php $items_counter = wp_nav_menu_get_pages( 0,'default' ); ?> 279 </ul> 280 </div><!-- /.list-container--> 344 <div id="existing-pages" class="list-wrap"> 345 <div class="list-container"> 346 <ul class="list"> 347 <?php $items_counter = wp_nav_menu_get_pages( 0, 'default' ); ?> 348 </ul> 349 </div><!-- /.list-container--> 350 </div><!-- /#existing-pages--> 351 <p class="add-to-menu enqueue"> 352 <a class="button"><?php _e('Add to Menu'); ?></a> 353 </p> 281 354 <br class="clear" /> 282 355 </div><!-- /.inside--> … … 284 357 285 358 <div id="add-categories" class="postbox"> 286 <div class="handlediv" title="Click to toggle"><br /></div>287 359 <h3 class="hndle"><?php esc_html_e('Add an Existing Category'); ?></h3> 288 360 <div class="inside"> … … 312 384 <script type="text/javascript" charset="<?php bloginfo('charset'); ?>"> 313 385 jQuery(document).ready(function(){ 314 var categories = "<?php echo esc_js($cat_name); ?>".split( "|");315 jQuery( "#cat-search").autocomplete(categories);316 jQuery( "#cat-search").result(function(event, data, formatted) {317 jQuery('# existing-categories').css('display','block');318 jQuery("# existing-categories dt:contains('" + data + "')").css("display", "block");319 jQuery('# show-cats').hide();320 jQuery('# hide-cats').show();386 var categories = "<?php echo esc_js($cat_name); ?>".split('|'); 387 jQuery('#add-categories .quick-search').autocomplete(categories); 388 jQuery('#add-categories .quick-search').result(function(event, data, formatted) { 389 jQuery('#add-categories .list-wrap').css('display','block'); 390 jQuery("#add-categories .list-wrap dt:contains('" + data + "')").css('display','block'); 391 jQuery('#add-categories .show-all').hide(); 392 jQuery('#add-categories .hide-all').show(); 321 393 }); 322 jQuery('#existing-categories').css('display','none');323 394 }); 324 395 </script> 325 326 <input type="text" onfocus="jQuery('#cat-search').attr('value','');" id="cat-search" class="regular-text" value="<?php esc_attr_e('Search Categories'); ?>" /> 327 328 <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> 329 <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> 330 331 <script type="text/javascript"> 332 jQuery('#hide-cats').hide(); 333 </script> 334 335 <div id="existing-categories" class="list-container"> 336 <ul class="list"> 337 <?php $items_counter = wp_nav_menu_get_categories( $items_counter, 'default' ); ?> 338 </ul> 339 </div><!-- /.list-container--> 396 <p> 397 <input type="text" class="quick-search regular-text" value="" /> 398 <a class="quick-search-submit button"><?php _e('Search'); ?></a> 399 </p> 400 401 <p class="button-controls"> 402 <a class="show-all button"><?php _e('View All'); ?></a> 403 <a class="hide-all button"><?php _e('Hide All'); ?></a> 404 </p> 405 406 <div id="existing-categories" class="list-wrap"> 407 <div class="list-container"> 408 <ul class="list"> 409 <?php $items_counter = wp_nav_menu_get_categories( $items_counter, 'default' ); ?> 410 </ul> 411 </div><!-- /.list-container--> 412 </div><!-- /#existing-categories--> 413 <p class="add-to-menu enqueue"> 414 <a class="button"><?php _e('Add to Menu'); ?></a> 415 </p> 340 416 <br class="clear" /> 341 417 </div><!-- /.inside--> … … 343 419 </div><!-- /#side-sortables--> 344 420 </div><!-- /#menu-settings-column --> 345 346 <div id="post-body">347 <div id="post-body-content">348 <div id="normal-sortables" class="meta-box-sortables ui-sortable">349 350 <?php if ( ! empty( $custom_menus ) ) : ?>351 <div id="nav-container" class="postbox">352 <h3 class="hndle"><?php echo esc_html( $menu_title ); ?></h3>353 <div class="inside">354 <input type="hidden" name="li-count" id="li-count" value="0" />355 <input type="hidden" name="menu-id-in-edit" id="menu-id-in-edit" value="<?php echo esc_attr( $menu_selected_id ); ?>" />356 357 <ul id="custom-nav">358 <?php359 if ( $menu_selected_id > 0 ) {360 wp_print_nav_menu( array( 'type' => 'backend', 'name' => $menu_title, 'id' => $menu_selected_id ) );361 }362 ?>363 </ul><!-- /#custom-nav-->364 </div><!-- /.inside -->365 <!-- /#nav-menu-canvas .postbox-->366 </div>367 <p class="submit">368 <script type="text/javascript">369 updatepostdata();370 </script>371 <input id="save_bottom" name="save_bottom" type="submit" value="<?php esc_attr_e('Save All Changes'); ?>" />372 <input id="delete-menu" name="delete-menu" type="submit" value="<?php esc_attr_e('Delete This Menu'); ?>" />373 </p>374 375 <?php else : ?>376 <div class="updated"><p><?php _e( 'Add a menu to start editing!' ); ?></p></div>377 <?php endif; ?>378 </div><!-- /#normal-sortables-->379 </div><!-- /#post-body-content-->380 </div><!--- /#post-body -->381 421 <br class="clear" /> 382 422 </div><!-- /.metabox-holder has-right-sidebar--> … … 384 424 </div><!-- /.wrap--> 385 425 386 <div id="dialog-confirm" style="display:none;" title="<?php esc_attr_e('Edit Menu Item'); ?>"> 387 <span id="edittitle-wrap"><input id="edittitle" type="text" name="edittitle" value="" /><label class="editlabel" for="edittitle"><?php _e('Menu Title'); ?></label><br /></span> 388 <span id="editlink-wrap"><input id="editlink" type="text" name="editlink" value="" /><label class="editlabel" for="editlink"><?php _e('URL'); ?></label><br /></span> 389 <span id="editanchortitle-wrap"><input id="editanchortitle" type="text" name="editanchortitle" value="" /><label class="editlabel" for="editanchortitle"><?php _e('Link Title'); ?></label><br /></span> 390 <span id="editnewwindow-wrap"> 391 <select id="editnewwindow" name="editnewwindow"> 392 <option value="1"><?php _e('Yes'); ?></option> 393 <option value="0"><?php _e('No'); ?></option> 394 </select><label class="editlabel" for="editnewwindow"><?php _e('Open Link in a new window'); ?></label> 395 </span> 396 <span id="editdescription-wrap"> 397 <input id="editdescription" type="text" name="editdescription" value="" <?php if ($advanced_option_descriptions == 'no') { ?>style="display:none;"<?php } ?> /><label class="editlabel" for="editdescription" <?php if ($advanced_option_descriptions == 'no') { ?>style="display:none;"<?php } ?> ><?php _e('Description'); ?></label><br /></span> 398 </div> 399 400 <?php 401 402 include( 'admin-footer.php' ); 426 <div id="menu-item-settings"> 427 <p class="description"> 428 <label for="edit-item-title"> 429 <?php _e( 'Menu Title' ); ?><br /> 430 <input type="text" id="edit-item-title" class="widefat" name="edit-item-title" value="" tabindex="1" /> 431 </label> 432 </p> 433 <p class="description"> 434 <label for="edit-item-url"> 435 <?php _e( 'URL' ); ?><br /> 436 <input type="text" id="edit-item-url" class="widefat code" name="edit-item-url" value="" tabindex="2" /> 437 </label> 438 </p> 439 <p class="description"> 440 <label for="edit-item-attr-title"> 441 <?php _e( 'Attribute Title' ); ?><br /> 442 <input type="text" id="edit-item-attr-title" class="widefat" name="edit-item-attr-title" value="" tabindex="3" /> 443 </label> 444 </p> 445 <p class="description"> 446 <label for="edit-item-target"> 447 <?php _e( 'Open Link in a new window' ); ?><br /> 448 <select id="edit-item-target" class="widefat" name="edit-item-target"> 449 <option value="1">Yes</option> 450 <option value="0">No</option> 451 </select> 452 </label> 453 </p> 454 <p class="description"> 455 <label for="edit-item-description"> 456 <?php _e( 'Description' ); ?><br /> 457 <textarea id="edit-item-description" class="widefat" rows="3" name="edit-item-description" tabindex="4" /></textarea> 458 </label> 459 </p> 460 <p> 461 <a id="cancel-save" class="submitdelete deletion"><?php _e('Cancel'); ?></a> 462 <a id="update-menu-item" class="save button-primary" tabindex="5"><?php _e('Save Changes'); ?></a> 463 </p> 464 <input type="hidden" id="edit-item-id" name="edit-item-id" value="" /> 465 </div><!-- /#menu-item-settings--> 466 467 <?php include( 'admin-footer.php' ); ?> -
trunk/wp-includes/default-widgets.php
r13388 r13473 1046 1046 function WP_Nav_Menu_Widget() { 1047 1047 $widget_ops = array('description' => __('Use this widget to add one of your navigation menus as a widget.') ); 1048 parent::WP_Widget( false, __('Navigation Menu'), $widget_ops);1048 parent::WP_Widget( false, __('Navigation Menu'), $widget_ops ); 1049 1049 } 1050 1050 … … 1061 1061 1062 1062 // Override for menu descriptions 1063 $advanced_option_descriptions = get_option('wp_settings_ custom_nav_advanced_options');1063 $advanced_option_descriptions = get_option('wp_settings_nav_menu_advanced_options'); 1064 1064 if ( $advanced_option_descriptions == 'no' ) { 1065 1065 $navwidgetdescription = 2; … … 1105 1105 // DISPLAY default UL 1106 1106 ?> 1107 <ul class=" custom-nav">1107 <ul class="menu"> 1108 1108 <?php 1109 1109 } 1110 1110 wp_nav_menu( array('id' => $navmenu, 'name' => $wp_custom_nav_menu_name, 'desc' => $navwidgetdescription, 'format' => 'widget') ); 1111 1111 if ( $navdeveloper == 'yes' ) { 1112 // DISPLAY Custom UL1112 // DISPLAY Custom UL 1113 1113 if ( $navul == 'yes' ) { 1114 1114 ?> … … 1117 1117 } 1118 1118 } else { 1119 // DISPLAY default UL1119 // DISPLAY default UL 1120 1120 ?> 1121 1121 </ul> … … 1258 1258 <?php 1259 1259 } 1260 $advanced_option_descriptions = get_option('wp_settings_ custom_nav_advanced_options');1260 $advanced_option_descriptions = get_option('wp_settings_nav_menu_advanced_options'); 1261 1261 ?> 1262 1262 <p <?php if ($advanced_option_descriptions == 'no') { ?>style="display:none;"<?php } ?>> -
trunk/wp-includes/nav-menu-template.php
r13415 r13473 3 3 /** 4 4 * Outputs a navigation menu. 5 * 6 * Optional $args contents: 7 * 8 * id - The menu id. Defaults to blank. 9 * slug - The menu slug. Defaults to blank. 10 * menu_class - CSS class to use for the div container of the menu list. Defaults to 'menu'. 11 * format - Whether to format the ul. Defaults to 'div'. 12 * fallback_cb - If the menu doesn't exists, a callback function will fire. Defaults to 'wp_page_menu'. 13 * 14 * TODO: 15 * show_home - If you set this argument, then it will display the link to the home page. The show_home argument really just needs to be set to the value of the text of the link. 16 * link_before - Text before show_home argument text. 17 * link_after - Text after show_home argument text. 18 * echo - Whether to echo the menu or return it. Defaults to echo. 5 19 * 6 20 * @since 3.0.0 … … 9 23 */ 10 24 function wp_nav_menu( $args = array() ) { 11 $defaults = array( 'id' => '', 'slug' => '', 'menu_class' => 'menu', 'format' => 'div', 'fallback_cb' => 'wp_page_menu');12 $args = wp_parse_args( $args, $defaults);25 $defaults = array( 'id' => '', 'slug' => '', 'menu_class' => 'menu', 'format' => 'div', 'fallback_cb' => 'wp_page_menu', 'echo' => true, 'link_before' => '', 'link_after' => '' ); 26 $args = wp_parse_args( $args, $defaults ); 13 27 $args = (object) $args; 14 28 29 // Get the menu 15 30 $menu = null; 16 31 if ( !empty($args->id) ) { 17 32 $menu = wp_get_nav_menu( $args->id ); 18 33 } elseif ( !empty($args->slug) ) { 19 $menu = get_term_by( 'slug', $args->slug, 'nav_menu');34 $menu = get_term_by( 'slug', $args->slug, 'nav_menu' ); 20 35 } else { 21 36 $menus = wp_get_nav_menus(); … … 27 42 } 28 43 } 29 44 45 // If the menu doesn't exists, call the fallback_cb 30 46 if ( !$menu || is_wp_error($menu) ) 31 47 return call_user_func($args->fallback_cb, $args ); … … 86 102 } 87 103 88 function wp_print_nav_menu_item( $menu_item, $context, $args = array() ) {104 function wp_print_nav_menu_item( $menu_item, $context, $args = array() ) { 89 105 switch ( $context ) { 90 106 case 'backend': … … 93 109 <dl> 94 110 <dt> 95 <span class="title"><?php echo esc_html($menu_item->title); ?></span> 96 <span class="controls"> 97 <span class="type"><?php echo esc_html($menu_item->type); ?></span> 98 <a id="edit<?php echo esc_attr( $menu_item->menu_order ); ?>" onclick="edititem(<?php echo esc_attr( $menu_item->menu_order ); ?>)" value="<?php echo esc_attr( $menu_item->menu_order ); ?>"><img class="edit" alt="<?php esc_attr_e('Edit Menu Item'); ?>" title="<?php esc_attr_e('Edit Menu Item'); ?>" src="<?php echo admin_url('images/ico-edit.png'); ?>" /></a> 99 <a id="remove<?php echo esc_attr( $menu_item->menu_order ); ?>" onclick="removeitem(<?php echo esc_attr( $menu_item->menu_order ); ?>)" value="<?php echo esc_attr( $menu_item->menu_order ); ?>"><img class="remove" alt="<?php esc_attr_e('Remove from Menu'); ?>" title="<?php esc_attr_e('Remove from Menu'); ?>" src="<?php echo admin_url('images/ico-close.png'); ?>" /></a> 100 <a id="view<?php echo esc_attr( $menu_item->menu_order ); ?>" target="_blank" href="<?php echo $menu_item->link; ?>"><img alt="<?php esc_attr_e('View Page'); ?>" title="<?php esc_attr_e('View Page'); ?>" src="<?php echo admin_url('images/ico-viewpage.png'); ?>" /></a> 111 <span class="item-title"><?php echo esc_html($menu_item->title); ?></span> 112 <span class="item-controls"> 113 <span class="item-type"><?php echo esc_html($menu_item->type); ?></span> 114 <a class="item-edit thickbox" id="edit<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->menu_order ); ?>" title="<?php _e('Edit Menu Item'); ?>" href="#TB_inline?height=380&width=300&inlineId=menu-item-settings"><?php _e('Edit'); ?></a> | 115 <a class="item-delete" id="delete<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->menu_order ); ?>"><?php _e('Delete'); ?></a> 101 116 </span> 102 117 </dt> … … 110 125 <input type="hidden" name="postmenu<?php echo esc_attr( $menu_item->menu_order ); ?>" id="postmenu<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( get_post_meta( $menu_item->ID, 'object_id', true ) ); ?>" /> 111 126 <input type="hidden" name="parent<?php echo esc_attr( $menu_item->menu_order ); ?>" id="parent<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->parent_item ); ?>" /> 112 <input type="hidden" name="title<?php echo esc_attr( $menu_item->menu_order ); ?>" id="title<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->title ); ?>" />113 <input type="hidden" name="linkurl<?php echo esc_attr( $menu_item->menu_order ); ?>" id="linkurl<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->link ); ?>" />114 <input type="hidden" name="description<?php echo esc_attr( $menu_item->menu_order ); ?>" id="description<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->description ); ?>" />115 127 <input type="hidden" name="icon<?php echo esc_attr( $menu_item->menu_order ); ?>" id="icon<?php echo esc_attr( $menu_item->menu_order ); ?>" value="0" /> 116 128 <input type="hidden" name="position<?php echo esc_attr( $menu_item->menu_order ); ?>" id="position<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->menu_order ); ?>" /> 117 129 <input type="hidden" name="linktype<?php echo esc_attr( $menu_item->menu_order ); ?>" id="linktype<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( get_post_meta( $menu_item->ID, 'menu_type', true ) ); ?>" /> 118 <input type="hidden" name="anchortitle<?php echo esc_attr( $menu_item->menu_order ); ?>" id="anchortitle<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->post_excerpt ); ?>" /> 119 <input type="hidden" name="newwindow<?php echo esc_attr( $menu_item->menu_order ); ?>" id="newwindow<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo ( get_post_meta( $menu_item->ID, 'menu_new_window', true ) ? '1' : '0' ); ?>" /> 130 <input type="hidden" name="item-title<?php echo esc_attr( $menu_item->menu_order ); ?>" id="item-title<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->title ); ?>" /> 131 <input type="hidden" name="item-url<?php echo esc_attr( $menu_item->menu_order ); ?>" id="item-url<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->link ); ?>" /> 132 <input type="hidden" name="item-description<?php echo esc_attr( $menu_item->menu_order ); ?>" id="item-description<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->description ); ?>" /> 133 <input type="hidden" name="item-attr-title<?php echo esc_attr( $menu_item->menu_order ); ?>" id="item-attr-title<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->post_excerpt ); ?>" /> 134 <input type="hidden" name="item-target<?php echo esc_attr( $menu_item->menu_order ); ?>" id="item-target<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo ( get_post_meta( $menu_item->ID, 'menu_new_window', true ) ? '1' : '0' ); ?>" /> 120 135 <?php 121 136 break; … … 123 138 case 'frontend': 124 139 // Override for menu descriptions 125 $advanced_option_descriptions = get_option('wp_settings_ custom_nav_advanced_options');140 $advanced_option_descriptions = get_option('wp_settings_nav_menu_advanced_options'); 126 141 if ( $advanced_option_descriptions == 'no' ) 127 142 $args['desc'] = 2; … … 149 164 150 165 case 'default': 151 $ template_dir = get_bloginfo('url');166 $menu_id = 'menu-item-' . $menu_item->ID; 152 167 ?> 153 168 <dl> 154 169 <dt> 155 < a class="title" title="<?php esc_attr_e('Add to Menu'); ?>" 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 ); ?>"><?php echo $menu_item->title; ?></a>170 <label class="item-title"><input type="checkbox" id="<?php echo esc_attr($menu_id); ?>" onclick="wp_update_queue('<?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 ); ?>" /><?php echo $menu_item->title; ?></label> 156 171 </dt> 157 172 </dl> -
trunk/wp-includes/nav-menu.php
r13407 r13473 8 8 */ 9 9 10 // Deletes a nav menu 10 11 function wp_delete_nav_menu( $menu_id ) { 11 12 $menu_id = (int) $menu_id; … … 22 23 } 23 24 25 // Creates a new nav menu 24 26 function wp_create_nav_menu( $menu_name, $args = array() ) { 25 27 $menu_exists = get_term_by( 'name', $menu_name, 'nav_menu' ); 26 28 27 29 if ( $menu_exists ) 28 return new WP_Error( 'menu_exists', sprintf( __('A menu named “%s” already exists; please try another name.'), esc_html( $menu_exists->name ) ) );30 return new WP_Error( 'menu_exists', sprintf( __('A menu named “%s” already exists; please try another name.'), esc_html( $menu_exists->name ) ) ); 29 31 30 32 if ( isset($args['slug']) ) … … 41 43 } 42 44 45 // Creates a default menu if none exists 43 46 function wp_create_default_nav_menu() { 44 $menu = wp_create_nav_menu( __('Main'), array('slug' => 'main'));47 $menu = wp_create_nav_menu( __('Menu 1'), array('slug' => 'menu-1') ); 45 48 46 49 if ( is_wp_error($menu) ) … … 50 53 $counter = 1; 51 54 foreach ( $pages as $page ) { 52 $item = array( 'post_status' => 'publish', 'post_type' => 'nav_menu_item', 'menu_order' => $counter, 'tax_input' => array( 'nav_menu' => $menu->name), 'post_title' => addslashes($page->post_title) );55 $item = array( 'post_status' => 'publish', 'post_type' => 'nav_menu_item', 'menu_order' => $counter, 'tax_input' => array( 'nav_menu' => $menu->name), 'post_title' => addslashes($page->post_title) ); 53 56 $item_id = wp_insert_post($item, true); 54 57 update_post_meta( $item_id, 'menu_type', 'page' ); … … 59 62 } 60 63 64 // Get nav menu by id 61 65 function wp_get_nav_menu( $menu ) { 62 return get_term( (int) $menu, 'nav_menu' );66 return get_term( (int) $menu, 'nav_menu' ); 63 67 } 64 68 69 // Get all nav menus 65 70 function wp_get_nav_menus() { 66 71 return get_terms( 'nav_menu', array( 'hide_empty' => false, 'orderby' => 'id' ) ); 67 72 } 68 73 74 // Get the nav menu items 69 75 function wp_get_nav_menu_items( $menu, $args = array() ) { 70 76 $items = get_objects_in_term( (int) $menu, 'nav_menu' ); … … 93 99 } 94 100 101 // wp_setup_nav_menu_item() 95 102 function wp_setup_nav_menu_item($menu_item, $type = 'item', $position = 0) { 96 103 global $parent_menu_order; -
trunk/wp-includes/script-loader.php
r13437 r13473 399 399 // Custom Navigation 400 400 $scripts->add( 'nav-menu-default-items', "/wp-admin/js/nav-menu-default-items$suffix.js", false, '20100223' ); 401 $scripts->add( 'nav-menu-dynamic-functions', "/wp-admin/js/nav-menu-dynamic-functions$suffix.js", false, '2010022 4b' );401 $scripts->add( 'nav-menu-dynamic-functions', "/wp-admin/js/nav-menu-dynamic-functions$suffix.js", false, '20100225b' ); 402 402 $scripts->localize( 'nav-menu-dynamic-functions', 'navMenuL10n', array( 403 403 'custom' => _x('Custom', 'menu nav item type'), 404 404 'page' => _x('Page', 'menu nav item type'), 405 'category' => _x('Category', 'menu nav item type') 405 'category' => _x('Category', 'menu nav item type'), 406 'thickbox' => _x('Edit Menu Item', 'Thickbox Title'), 407 'edit' => _x('Edit', 'menu item edit text'), 406 408 ) ); 407 409 … … 475 477 $styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.css', array(), '0.9.8' ); 476 478 $styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.1' ); 477 $styles->add( 'nav-menu', "/wp-admin/css/nav-menu$suffix.css", array(), '20100225 ' );479 $styles->add( 'nav-menu', "/wp-admin/css/nav-menu$suffix.css", array(), '20100225b' ); 478 480 479 481 foreach ( $rtl_styles as $rtl_style ) {
Note: See TracChangeset
for help on using the changeset viewer.