Changeset 13331
- Timestamp:
- 02/23/2010 05:13:24 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/custom-navigation.php
r13298 r13331 177 177 } 178 178 179 // DISPLAY Custom Navigation179 // DISPLAY Custom Navigation 180 180 ?> 181 181 <div id="pages-left"> … … 184 184 <?php 185 185 186 // CHECK if custom menu has been enabled186 // CHECK if custom menu has been enabled 187 187 $enabled_menu = get_option('wp_custom_nav_menu'); 188 188 $checked = strtolower($enabled_menu); 189 189 190 if ($checked == 'true') { 191 } else { 190 if ( $checked != 'true' ) 192 191 echo '<div id="message-enabled" class="error fade below-h2"><p><strong>' . __('The Custom Menu has not been Enabled yet. Please enable it in order to use it -------->') . '</strong></p></div>'; 193 }194 195 192 196 193 ?> … … 216 213 //DISPLAY existing menu 217 214 if ( $menu_selected_id > 0 ) { 218 // SET output type215 // SET output type 219 216 $output_type = "backend"; 220 // MAIN OUTPUT FUNCTION217 // MAIN OUTPUT FUNCTION 221 218 wp_custom_navigation_output( 'type='.$output_type.'&name='.$menu_title.'&id='.$menu_selected_id ); 222 219 } … … 249 246 <?php 250 247 251 // SETUP Custom Menu248 // Setup custom menu 252 249 253 250 $enabled_menu = get_option('wp_custom_nav_menu'); … … 282 279 <?php 283 280 284 // DISPLAY SELECT OPTIONS281 // Display select options 285 282 foreach ( $custom_menus as $menu ) { 286 283 $menu_term = get_term( $menu, 'nav_menu' ); … … 315 312 <?php 316 313 317 // UPDATE and DISPLAY Menu Description Option314 // UPDATE and DISPLAY Menu Description Option 318 315 if ( isset($_POST['menu-descriptions']) ) { 319 320 if ( isset($_POST['switch_menu']) ) { 321 322 } else { 316 if ( !isset($_POST['switch_menu']) ) { 323 317 $menu_options_to_edit = $_POST['menu_id_in_edit']; 324 318 update_option('wp_settings_custom_nav_'.$menu_options_to_edit.'_descriptions',$_POST['menu-descriptions']); 325 319 } 326 327 320 } 328 321 … … 382 375 } 383 376 } else { 384 $page_name = "No pages available";377 $page_name = __('No pages available'); 385 378 } 386 379 … … 449 442 //CHECK for results 450 443 if ( $categories ) { 451 foreach ( $categories as $category ) {444 foreach ( $categories as $category ) { 452 445 $cat_id = $category->term_id; 453 446 … … 508 501 <ul id="existing-categories" class="list"> 509 502 <?php 510 // Get default Categories511 $intCounter = wp_custom_nav_get_categories($intCounter, 'default');503 // Get default Categories 504 $intCounter = wp_custom_nav_get_categories($intCounter, 'default'); 512 505 ?> 513 506 </ul> … … 558 551 559 552 <?php 560 561 553 } 562 554 -
trunk/wp-includes/custom-navigation.php
r13322 r13331 32 32 33 33 function wp_custom_navigation_setup($override = false) { 34 35 34 // Custom Navigation Menu Setup 36 35 … … 45 44 } 46 45 } 46 47 47 function wp_custom_navigation_delete_menu( $menu_term_id ) { 48 48 $term_id = (int) $menu_term_id; … … 58 58 } 59 59 60 function setup_menu_item($menu_item) { 61 global $parent_menu_order; 62 63 $menu_item->type = get_post_meta($menu_item->ID, 'menu_type', true); 64 $menu_item->object_id = get_post_meta($menu_item->ID, 'object_id', true); 65 //$parent_menu_order[ $menu_item->ID ] = $menu_item->menu_order; 66 if ( isset( $parent_menu_order[ $menu_item->post_parent ] ) ) 67 $menu_item->parent_item = $parent_menu_order[ $menu_item->post_parent ]; 68 else 69 $menu_item->parent_item = 0; 70 71 switch ( $menu_item->type ) { 72 // Page Menu Item 73 case 'page': 74 if ( $menu_item->guid == '' ) 75 $menu_item->link = get_permalink( $menu_item->object_id ); 76 else 77 $menu_item->link = $menu_item->guid; 78 79 if ( $menu_item->post_title == '' ) 80 $menu_item->title = htmlentities( get_the_title( $menu_item->object_id ) ); 81 else 82 $menu_item->title = htmlentities( $menu_item->post_title ); 83 84 if ( $menu_item->post_content == '' ) 85 $menu_item->description = htmlentities( get_post_meta( $menu_item->ID, 'page-description', true ) ); 86 else 87 $menu_item->description = htmlentities( $menu_item->post_content ); 88 $menu_item->target = ''; 89 break; 90 // Category Menu Item 91 case 'category': 92 if ( $menu_item->guid == '' ) 93 $menu_item->link = get_category_link( $menu_item->object_id ); 94 else 95 $menu_item->link = $menu_item->guid; 96 97 if ( $menu_item->post_title == '' ) { 98 $title_raw = get_categories( array('include' => $menu_item->object_id) ); 99 $menu_item->title = htmlentities($title_raw[0]->cat_name); 100 } else { 101 $menu_item->title = htmlentities( $menu_item->post_title ); 102 } 103 104 if ( $menu_item->post_content == '' ) 105 $menu_item->description = htmlentities( strip_tags( category_description( $menu_item->object_id ) ) ); 106 else 107 $menu_item->description = htmlentities( $menu_item->post_content ); 108 $menu_item->target = ''; 109 break; 110 default: 111 // Custom Menu Item 112 $menu_item->link = $menu_item->guid; 113 $menu_item->title = htmlentities( $menu_item->post_title ); 114 $menu_item->description = htmlentities( $menu_item->post_content ); 115 $menu_item->target = 'target="_blank"'; 116 break; 117 } 118 119 $menu_item->li_class = ''; 120 global $wp_query; 121 if ( $menu_item->ID == $wp_query->get_queried_object_id() ) 122 $menu_item->li_class = 'class="current_page_item"'; 123 124 /* @todo: update to use tax/post data 125 126 //SET anchor title 127 if (isset($wp_custom_nav_menu_items->custom_anchor_title)) { 128 $anchor_title = htmlentities($wp_custom_nav_menu_items->custom_anchor_title); 129 } 130 else { 131 $anchor_title = $title; 132 } 133 134 if ($queried_id == $wp_custom_nav_menu_items->post_id) { 135 $li_class = 'class="current_page_item"'; 136 } 137 138 if (isset($wp_custom_nav_menu_items->new_window)) { 139 if ($wp_custom_nav_menu_items->new_window > 0) { 140 $target = 'target="_blank"'; 141 } 142 else { 143 $target = ''; 144 } 145 } 146 */ 147 148 return $menu_item; 149 } 150 60 151 /*-----------------------------------------------------------------------------------*/ 61 152 /* Custom Navigation Functions */ 62 153 /* wp_custom_navigation_output() displays the menu in the back/frontend 63 /* wp_custom_navigation_sub_items() is a recursive sub menu item function64 154 /* wp_custom_nav_get_pages() 65 155 /* wp_custom_nav_get_categories() … … 77 167 /* after_title - html after title is outputted in <a> tag 78 168 /*-----------------------------------------------------------------------------------*/ 79 80 169 function wp_custom_navigation_output( $args = array() ) { 81 82 170 // Defaults 83 171 $defaults = array( 'type' => 'frontend', 'name' => 'Menu 1', 'id' => 0, 'desc' => 2, 'before_title' => '', 'after_title' => ''); … … 88 176 $menu_objects = get_objects_in_term( $id, 'nav_menu' ); 89 177 $menu_items = wp_custom_navigation_get_menu_items( $menu_objects, 'menu_order' ); 90 // Override for menu descriptions178 // Override for menu descriptions 91 179 $advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options'); 92 180 if ( $advanced_option_descriptions == 'no' ) 93 181 $desc = 2; 94 182 95 $queried_id = 0;96 global $wp_query;97 if ( is_page() )98 $queried_id = $wp_query->get_queried_object_id();99 elseif ( is_category() )100 $queried_id = $wp_query->get_queried_object_id();101 102 183 $parent_stack = array(); 103 184 $current_parent = 0; 104 185 $parent_menu_order = array(); 186 // Setup parentage 187 foreach ( $menu_items as $key => $menu_item ) { 188 $parent_menu_order[ $menu_item->ID ] = $menu_item->menu_order; 189 } 190 105 191 // Display Loop 106 192 foreach ( $menu_items as $key => $menu_item ) { 107 $menu_type = get_post_meta($menu_item->ID, 'menu_type', true); 108 $object_id = get_post_meta($menu_item->ID, 'object_id', true); 109 $parent_menu_order[ $menu_item->ID ] = $menu_item->menu_order; 110 if ( isset( $parent_menu_order[ $menu_item->post_parent ] ) ) 111 $parent_item = $parent_menu_order[ $menu_item->post_parent ]; 112 else 113 $parent_item = 0; 114 115 switch ( $menu_type ) { 116 // Page Menu Item 117 case 'page': 118 if ( $menu_item->guid == '' ) 119 $link = get_permalink( $object_id ); 120 else 121 $link = $menu_item->guid; 122 123 if ( $menu_item->post_title == '' ) 124 $title = htmlentities( get_the_title( $object_id ) ); 125 else 126 $title = htmlentities( $menu_item->post_title ); 127 128 if ( $menu_item->post_content == '' ) 129 $description = htmlentities( get_post_meta( $menu_item->ID, 'page-description', true ) ); 130 else 131 $description = htmlentities( $menu_item->post_content ); 132 $target = ''; 133 break; 134 // Category Menu Item 135 case 'category': 136 if ( $menu_item->guid == '' ) 137 $link = get_category_link( $object_id ); 138 else 139 $link = $menu_item->guid; 140 141 if ( $menu_item->post_title == '' ) { 142 $title_raw = get_categories( array('include' => $object_id) ); 143 $title = htmlentities($title_raw[0]->cat_name); 144 } else { 145 $title = htmlentities( $menu_item->post_title ); 146 } 147 148 if ( $menu_item->post_content == '' ) 149 $description = htmlentities( strip_tags( category_description( $object_id ) ) ); 150 else 151 $description = htmlentities( $menu_item->post_content ); 152 $target = ''; 153 break; 154 default: 155 // Custom Menu Item 156 $link = $menu_item->guid; 157 $title = htmlentities( $menu_item->post_title ); 158 $description = htmlentities( $menu_item->post_content ); 159 $target = 'target="_blank"'; 160 break; 161 } 162 163 $li_class = ''; 164 /* @todo: update to use tax/post data 165 166 //SET anchor title 167 if (isset($wp_custom_nav_menu_items->custom_anchor_title)) { 168 $anchor_title = htmlentities($wp_custom_nav_menu_items->custom_anchor_title); 169 } 170 else { 171 $anchor_title = $title; 172 } 173 174 if ($queried_id == $wp_custom_nav_menu_items->post_id) { 175 $li_class = 'class="current_page_item"'; 176 } 177 178 if (isset($wp_custom_nav_menu_items->new_window)) { 179 if ($wp_custom_nav_menu_items->new_window > 0) { 180 $target = 'target="_blank"'; 181 } 182 else { 183 $target = ''; 184 } 185 } 186 */ 193 $menu_item = setup_menu_item($menu_item); 187 194 // List Items 188 ?><li id="menu-<?php echo $menu_item->ID; ?>" value="<?php echo $menu_item->ID; ?>" <?php echo $ li_class; ?>><?php195 ?><li id="menu-<?php echo $menu_item->ID; ?>" value="<?php echo $menu_item->ID; ?>" <?php echo $menu_item->li_class; ?>><?php 189 196 //@todo: update front end to use post data 190 197 //FRONTEND Link 191 198 if ( $type == 'frontend' ) { 192 ?><a title="<?php echo $ anchor_title; ?>" href="<?php echo $link; ?>" <?php echo $target; ?>><?php echo $before_title.$title.$after_title; ?><?php199 ?><a title="<?php echo $menu_item->anchor_title; ?>" href="<?php echo $menu_item->link; ?>" <?php echo $menu_item->target; ?>><?php echo $before_title.$menu_item->title.$after_title; ?><?php 193 200 194 201 if ( $advanced_option_descriptions == 'no' ) { … … 197 204 // 0 widget override not set 198 205 if ( ($desc == 1) || ($desc == 0) ) { 199 ?><span class="nav-description"><?php echo $ description; ?></span><?php206 ?><span class="nav-description"><?php echo $menu_item->description; ?></span><?php 200 207 } 201 208 } else { … … 204 211 // 0 widget override not set 205 212 if ( $desc == 1 ) { 206 ?><span class="nav-description"><?php echo $ description; ?></span><?php213 ?><span class="nav-description"><?php echo $menu_item->description; ?></span><?php 207 214 } 208 215 } … … 210 217 ?></a><?php 211 218 } elseif ( $type == 'backend' ) { 212 $link_type = $menu_type;213 219 ?> 214 220 215 221 <dl> 216 222 <dt> 217 <span class="title"><?php echo $ title; ?></span>223 <span class="title"><?php echo $menu_item->title; ?></span> 218 224 <span class="controls"> 219 <span class="type"><?php echo $ link_type; ?></span>220 <a id="edit<?php echo $menu_item->menu_order; ?>" onclick="edititem(<?php echo $menu_item->menu_order; ?>)" value="<?php echo $menu_item->menu_order; ?>"><img class="edit" alt="Edit Menu Item" title="Edit Menu Item" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-edit.png" /></a>221 <a id="remove<?php echo $menu_item->menu_order; ?>" onclick="removeitem(<?php echo $menu_item->menu_order; ?>)" value="<?php echo $menu_item->menu_order; ?>"><img class="remove" alt="Remove from Custom Menu" title="Remove from Custom Menu" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-close.png" /></a>222 <a id="view<?php echo $menu_item->menu_order; ?>" target="_blank" href="<?php echo $ link; ?>"><img alt="View Page" title="View Page" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-viewpage.png" /></a>225 <span class="type"><?php echo $menu_item->type; ?></span> 226 <a id="edit<?php echo $menu_item->menu_order; ?>" onclick="edititem(<?php echo $menu_item->menu_order; ?>)" value="<?php echo $menu_item->menu_order; ?>"><img class="edit" alt="Edit Menu Item" title="Edit Menu Item" src="<?php echo admin_url('images/ico-edit.png'); ?>" /></a> 227 <a id="remove<?php echo $menu_item->menu_order; ?>" onclick="removeitem(<?php echo $menu_item->menu_order; ?>)" value="<?php echo $menu_item->menu_order; ?>"><img class="remove" alt="Remove from Custom Menu" title="Remove from Custom Menu" src="<?php echo admin_url('images/ico-close.png'); ?>" /></a> 228 <a id="view<?php echo $menu_item->menu_order; ?>" target="_blank" href="<?php echo $menu_item->link; ?>"><img alt="View Page" title="View Page" src="<?php echo admin_url('images/ico-viewpage.png'); ?>" /></a> 223 229 </span> 224 230 </dt> … … 228 234 <input type="hidden" name="dbid<?php echo $menu_item->menu_order; ?>" id="dbid<?php echo $menu_item->menu_order; ?>" value="<?php echo $menu_item->ID; ?>" /> 229 235 <input type="hidden" name="postmenu<?php echo $menu_item->menu_order; ?>" id="postmenu<?php echo $menu_item->menu_order; ?>" value="<?php echo $id; ?>" /> 230 <input type="hidden" name="parent<?php echo $menu_item->menu_order; ?>" id="parent<?php echo $menu_item->menu_order; ?>" value="<?php echo $ parent_item; ?>" />231 <input type="hidden" name="title<?php echo $menu_item->menu_order; ?>" id="title<?php echo $menu_item->menu_order; ?>" value="<?php echo $ title; ?>" />232 <input type="hidden" name="linkurl<?php echo $menu_item->menu_order; ?>" id="linkurl<?php echo $menu_item->menu_order; ?>" value="<?php echo $ link; ?>" />233 <input type="hidden" name="description<?php echo $menu_item->menu_order; ?>" id="description<?php echo $menu_item->menu_order; ?>" value="<?php echo $ description; ?>" />236 <input type="hidden" name="parent<?php echo $menu_item->menu_order; ?>" id="parent<?php echo $menu_item->menu_order; ?>" value="<?php echo $menu_item->parent_item; ?>" /> 237 <input type="hidden" name="title<?php echo $menu_item->menu_order; ?>" id="title<?php echo $menu_item->menu_order; ?>" value="<?php echo $menu_item->title; ?>" /> 238 <input type="hidden" name="linkurl<?php echo $menu_item->menu_order; ?>" id="linkurl<?php echo $menu_item->menu_order; ?>" value="<?php echo $menu_item->link; ?>" /> 239 <input type="hidden" name="description<?php echo $menu_item->menu_order; ?>" id="description<?php echo $menu_item->menu_order; ?>" value="<?php echo $menu_item->description; ?>" /> 234 240 <input type="hidden" name="icon<?php echo $menu_item->menu_order; ?>" id="icon<?php echo $menu_item->menu_order; ?>" value="0" /> 235 241 <input type="hidden" name="position<?php echo $menu_item->menu_order; ?>" id="position<?php echo $menu_item->menu_order; ?>" value="<?php echo $menu_item->menu_order; ?>" /> 236 <input type="hidden" name="linktype<?php echo $menu_item->menu_order; ?>" id="linktype<?php echo $menu_item->menu_order; ?>" value="<?php echo $ link_type; ?>" />242 <input type="hidden" name="linktype<?php echo $menu_item->menu_order; ?>" id="linktype<?php echo $menu_item->menu_order; ?>" value="<?php echo $menu_item->type; ?>" /> 237 243 <input type="hidden" name="anchortitle<?php echo $menu_item->menu_order; ?>" id="anchortitle<?php echo $menu_item->menu_order; ?>" value="<?php echo esc_html( $menu_item->post_excerpt ); ?>" /> 238 244 <input type="hidden" name="newwindow<?php echo $menu_item->menu_order; ?>" id="newwindow<?php echo $menu_item->menu_order; ?>" value="<?php echo ( '' == $menu_item->post_content_filtered ? '0' : '1' ); ?>" /> … … 260 266 } 261 267 } 262 //@todo: implement menu heirarchy263 //RECURSIVE Sub Menu Items264 function wp_custom_navigation_sub_items($post_id, $type, $table_name, $output_type, $menu_id = 0) {265 266 $parent_id = 0;267 global $wpdb;268 269 //GET sub menu items270 $wp_custom_nav_menu = $wpdb->get_results("SELECT id,post_id,parent_id,position,custom_title,custom_link,custom_description,menu_icon,link_type,custom_anchor_title,new_window FROM ".$table_name." WHERE parent_id = '".$post_id."' AND menu_id='".$menu_id."' ORDER BY position ASC");271 272 if (empty($wp_custom_nav_menu))273 {274 275 }276 else277 {278 ?><ul id="sub-custom-nav">279 <?php280 $queried_id = 0;281 global $wp_query;282 if (is_page()) {283 $queried_id = $wp_query->post->ID;284 }285 elseif (is_category()) {286 $queried_id = $wp_query->query_vars['cat'];287 }288 else {289 290 }291 //DISPLAY Loop292 foreach ($wp_custom_nav_menu as $sub_item)293 {294 //Figure out where the menu item sits295 $counter=$sub_item->position;296 297 //Prepare Menu Data298 //Category Menu Item299 if ($sub_item->link_type == 'category')300 {301 302 $parent_id = $sub_item->parent_id;303 $post_id = $sub_item->post_id;304 305 if ($sub_item->custom_link == '') {306 $link = get_category_link($sub_item->post_id);307 }308 else {309 $link = $sub_item->custom_link;310 }311 312 if ($sub_item->custom_title == '') {313 $title_raw = get_categories('include='.$sub_item->post_id);314 $title = htmlentities($title_raw[0]->cat_name);315 }316 else {317 $title = htmlentities($sub_item->custom_title);318 }319 320 if ($sub_item->custom_description == '') {321 $description = strip_tags(category_description($sub_item->post_id));322 }323 else {324 $description = $sub_item->custom_description;325 }326 $target = '';327 }328 //Page Menu Item329 elseif ($sub_item->link_type == 'page')330 {331 332 $parent_id = $sub_item->parent_id;333 $post_id = $sub_item->post_id;334 335 if ($sub_item->custom_link == '') {336 $link = get_permalink($sub_item->post_id);337 }338 else {339 $link = $sub_item->custom_link;340 }341 342 if ($sub_item->custom_title == '') {343 $title = htmlentities(get_the_title($sub_item->post_id));344 }345 else {346 $title = htmlentities($sub_item->custom_title);347 }348 349 if ($sub_item->custom_description == '') {350 $description = get_post_meta($sub_item->post_id, 'page-description', true);351 }352 else {353 $description = $sub_item->custom_description;354 }355 $target = '';356 357 }358 //Custom Menu Item359 else360 {361 $link = $sub_item->custom_link;362 $title = htmlentities($sub_item->custom_title);363 $parent_id = $sub_item->parent_id;364 $post_id = $sub_item->post_id;365 $description = $sub_item->custom_description;366 $target = 'target="_blank"';367 }368 if ($queried_id == $sub_item->post_id) {369 $li_class = 'class="current_page_item"';370 }371 else {372 $li_class = '';373 }374 375 //SET anchor title376 if (isset($sub_item->custom_anchor_title)) {377 $anchor_title = htmlentities($sub_item->custom_anchor_title);378 }379 else {380 $anchor_title = $title;381 }382 383 if (isset($sub_item->new_window)) {384 if ($sub_item->new_window > 0) {385 $target = 'target="_blank"';386 }387 }388 389 //List Items390 ?><li id="menu-<?php echo $counter; ?>" value="<?php echo $counter; ?>" <?php echo $li_class; ?>><?php391 //FRONTEND392 if ($output_type == "frontend")393 {394 ?><a title="<?php echo $anchor_title; ?>" href="<?php echo $link; ?>" <?php echo $target; ?>><?php echo $title; ?></a><?php395 }396 //BACKEND397 elseif ($output_type == "backend")398 {399 ?>400 <dl>401 <dt>402 <span class="title"><?php echo $title; ?></span>403 <span class="controls">404 <span class="type"><?php echo $sub_item->link_type; ?></span>405 <a id="edit<?php echo $counter; ?>" onclick="edititem(<?php echo $counter; ?>)" value="<?php echo $counter; ?>"><img class="edit" alt="Edit Menu Item" title="Edit Menu Item" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-edit.png" /></a>406 <a id="remove<?php echo $counter; ?>" onclick="removeitem(<?php echo $counter; ?>)" value="<?php echo $counter; ?>"><img class="remove" alt="Remove from Custom Menu" title="Remove from Custom Menu" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-close.png" /></a>407 <a id="view<?php echo $counter; ?>" target="_blank" href="<?php echo $link; ?>"><img alt="View Page" title="View Page" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-viewpage.png" /></a>408 </span>409 </dt>410 </dl>411 <a class="hide" href="<?php echo $link; ?>"><?php echo $title; ?></a>412 <input type="hidden" name="dbid<?php echo $counter; ?>" id="dbid<?php echo $counter; ?>" value="<?php echo $sub_item->id; ?>" />413 <input type="hidden" name="postmenu<?php echo $counter; ?>" id="postmenu<?php echo $counter; ?>" value="<?php echo $post_id; ?>" />414 <input type="hidden" name="parent<?php echo $counter; ?>" id="parent<?php echo $counter; ?>" value="<?php echo $parent_id; ?>" />415 <input type="hidden" name="title<?php echo $counter; ?>" id="title<?php echo $counter; ?>" value="<?php echo $title; ?>" />416 <input type="hidden" name="linkurl<?php echo $counter; ?>" id="linkurl<?php echo $counter; ?>" value="<?php echo $link; ?>" />417 <input type="hidden" name="description<?php echo $counter; ?>" id="description<?php echo $counter; ?>" value="<?php echo $description; ?>" />418 <input type="hidden" name="icon<?php echo $counter; ?>" id="icon<?php echo $counter; ?>" value="0" />419 <input type="hidden" name="position<?php echo $counter; ?>" id="position<?php echo $counter; ?>" value="<?php echo $counter; ?>" />420 <input type="hidden" name="linktype<?php echo $counter; ?>" id="linktype<?php echo $counter; ?>" value="<?php echo $sub_item->link_type; ?>" />421 <input type="hidden" name="anchortitle<?php echo $counter; ?>" id="anchortitle<?php echo $counter; ?>" value="<?php echo $anchor_title; ?>" />422 <input type="hidden" name="newwindow<?php echo $counter; ?>" id="newwindow<?php echo $counter; ?>" value="<?php echo $sub_item->new_window; ?>" />423 <?php424 }425 426 //Do recursion427 wp_custom_navigation_sub_items($sub_item->id,$sub_item->link_type,$table_name,$output_type,$menu_id);428 ?></li>429 <?php430 431 }432 433 ?></ul>434 <?php435 436 }437 438 return $parent_id;439 440 }441 442 268 443 269 // Outputs All Pages and Sub Items … … 562 388 } 563 389 564 // Outputs All Categories and Sub Items390 // Outputs All Categories and Sub Items 565 391 function wp_custom_nav_get_categories($counter, $type) { 566 392 … … 590 416 // Display Loop 591 417 foreach ( $categories_array as $cat_item ) { 592 593 418 if ( $cat_item->parent == 0 ) { 594 419 // Custom Menu … … 599 424 <dl> 600 425 <dt> 601 <span class="title"><?php echo $cat_item->cat_name; ?></span>426 <span class="title"><?php echo esc_html($cat_item->cat_name); ?></span> 602 427 <span class="controls"> 603 428 <span class="type">category</span> 604 <a id="edit<?php echo $intCounter; ?>" onclick="edititem(<?php echo $intCounter; ?>)" value="<?php echo $intCounter; ?>"><img class="edit" alt=" Edit Menu Item" title="Edit Menu Item" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-edit.png" /></a>429 <a id="edit<?php echo $intCounter; ?>" onclick="edititem(<?php echo $intCounter; ?>)" value="<?php echo $intCounter; ?>"><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> 605 430 <a id="remove<?php echo $intCounter; ?>" onclick="removeitem(<?php echo $intCounter; ?>)" value="<?php echo $intCounter; ?>"> 606 <img class="remove" alt=" Remove from Custom Menu" title="Remove from Custom Menu" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-close.png" />431 <img class="remove" alt="="<?php esc_attr_e('Remove from Custom Menu'); ?>" title="="<?php esc_attr_e('Remove from Custom Menu'); ?>" src="<?php echo admin_url('images/ico-close.png'); ?>" /> 607 432 </a> 608 433 <a target="_blank" href="<?php echo get_category_link($cat_item->cat_ID); ?>"> 609 <img alt=" View Page" title="View Page" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-viewpage.png" />434 <img alt="="<?php esc_attr_e('View Page'); ?>" title="="<?php esc_attr_e('View Page'); ?>" src="<?php echo admin_url('images/ico-viewpage.png'); ?>" /> 610 435 </a> 611 436 </span> … … 623 448 <input type="hidden" name="postmenu<?php echo $intCounter; ?>" id="postmenu<?php echo $intCounter; ?>" value="<?php echo $cat_item->cat_ID; ?>" /> 624 449 <input type="hidden" name="parent<?php echo $intCounter; ?>" id="parent<?php echo $intCounter; ?>" value="0" /> 625 <input type="hidden" name="title<?php echo $intCounter; ?>" id="title<?php echo $intCounter; ?>" value="<?php echo htmlentities($cat_item->cat_name); ?>" />626 <input type="hidden" name="linkurl<?php echo $intCounter; ?>" id="linkurl<?php echo $intCounter; ?>" value="<?php echo get_category_link($cat_item->cat_ID); ?>" />627 <input type="hidden" name="description<?php echo $intCounter; ?>" id="description<?php echo $intCounter; ?>" value="<?php echo htmlentities($cat_item->category_description); ?>" />450 <input type="hidden" name="title<?php echo $intCounter; ?>" id="title<?php echo $intCounter; ?>" value="<?php echo esc_attr($cat_item->cat_name); ?>" /> 451 <input type="hidden" name="linkurl<?php echo $intCounter; ?>" id="linkurl<?php echo $intCounter; ?>" value="<?php echo esc_attr(get_category_link($cat_item->cat_ID)); ?>" /> 452 <input type="hidden" name="description<?php echo $intCounter; ?>" id="description<?php echo $intCounter; ?>" value="<?php echo esc_attr($cat_item->category_description); ?>" /> 628 453 <input type="hidden" name="icon<?php echo $intCounter; ?>" id="icon<?php echo $intCounter; ?>" value="0" /> 629 454 <input type="hidden" name="position<?php echo $intCounter; ?>" id="position<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>" /> 630 455 <input type="hidden" name="linktype<?php echo $intCounter; ?>" id="linktype<?php echo $intCounter; ?>" value="category" /> 631 <input type="hidden" name="anchortitle<?php echo $intCounter; ?>" id="anchortitle<?php echo $intCounter; ?>" value="<?php echo htmlentities($cat_item->cat_name); ?>" />456 <input type="hidden" name="anchortitle<?php echo $intCounter; ?>" id="anchortitle<?php echo $intCounter; ?>" value="<?php echo esc_attr($cat_item->cat_name); ?>" /> 632 457 <input type="hidden" name="newwindow<?php echo $intCounter; ?>" id="newwindow<?php echo $intCounter; ?>" value="0" /> 633 458 … … 636 461 <?php 637 462 638 // Recursive function463 // Recursive function 639 464 $intCounter = wp_custom_navigation_default_sub_items($cat_item->cat_ID, $intCounter, $parentli, 'categories','menu'); 640 465 … … 644 469 645 470 <?php 646 } elseif ( $type == 'default') {471 } elseif ( $type == 'default' ) { 647 472 // Sidebar Menu 648 473 ?> … … 658 483 ?> 659 484 <?php $templatedir = get_bloginfo('url'); ?> 660 <span class="title"><?php echo $cat_item->cat_name; ?></span> <a onclick="appendToList('<?php echo $templatedir; ?>','Category','<?php echo $post_text; ?>','<?php echo $post_url; ?>','<?php echo $post_id; ?>','<?php echo $post_parent_id ?>','<?php echo $description; ?>')" name="<?php echo $post_text; ?>" value="<?php echo $post_url; ?>"><img alt="Add to Custom Menu" title="Add to Custom Menu" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-add.png" /></a> </dt>485 <span class="title"><?php echo esc_html($cat_item->cat_name); ?></span> <a onclick="appendToList('<?php echo $templatedir; ?>','Category','<?php echo $post_text; ?>','<?php echo $post_url; ?>','<?php echo $post_id; ?>','<?php echo $post_parent_id ?>','<?php echo $description; ?>')" name="<?php echo $post_text; ?>" value="<?php echo $post_url; ?>"><img alt="="<?php esc_attr_e('Add to Custom Menu'); ?>" title="="<?php esc_attr_e('Add to Custom Menu'); ?>" src="<?php echo admin_url('images/ico-add.png'); ?>" /></a> </dt> 661 486 </dl> 662 487 <?php $parentli = $cat_item->cat_ID; ?> 663 488 <?php $intCounter++; ?> 664 489 <?php 665 // Recursive function666 $intCounter = wp_custom_navigation_default_sub_items($cat_item->cat_ID, $intCounter, $parentli, 'categories', 'default');490 // Recursive function 491 $intCounter = wp_custom_navigation_default_sub_items($cat_item->cat_ID, $intCounter, $parentli, 'categories', 'default'); 667 492 ?> 668 493 … … 683 508 684 509 // Custom Menu 685 if ( $output_type == 'menu') {510 if ( $output_type == 'menu' ) { 686 511 $sub_args = array( 687 512 'child_of' => $childof, 688 513 'hide_empty' => false, 689 514 'parent' => $childof); 690 } elseif ( $output_type == 'default') {515 } elseif ( $output_type == 'default' ) { 691 516 // Sidebar Menu 692 517 $sub_args = array( … … 709 534 if ( $sub_array ) { 710 535 ?> 711 712 536 <ul id="sub-custom-nav-<?php echo $type ?>"> 713 537 … … 715 539 // Display Loop 716 540 foreach ( $sub_array as $sub_item ) { 717 //Prepare Menu Data 718 //Category Menu Item 541 // Prepare Menu Data 719 542 if ( $type == 'categories' ) { 543 // Category Menu Item 720 544 $link = get_category_link($sub_item->cat_ID); 721 545 $title = htmlentities($sub_item->cat_name); … … 750 574 <span class="controls"> 751 575 <span class="type"><?php echo $linktype; ?></span> 752 <a id="edit<?php echo $counter; ?>" onclick="edititem(<?php echo $counter; ?>)" value="<?php echo $counter; ?>"><img class="edit" alt=" Edit Menu Item" title="Edit Menu Item" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-edit.png" /></a>576 <a id="edit<?php echo $counter; ?>" onclick="edititem(<?php echo $counter; ?>)" value="<?php echo $counter; ?>"><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> 753 577 <a id="remove<?php echo $counter; ?>" onclick="removeitem(<?php echo $counter; ?>)" value="<?php echo $counter; ?>"> 754 <img class="remove" alt=" Remove from Custom Menu" title="Remove from Custom Menu" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-close.png" />578 <img class="remove" alt="<?php esc_attr_e('Remove from Custom Menu'); ?>" title="<?php esc_attr_e('Remove from Custom Menu'); ?>" src="<?php echo admin_url('images/ico-close.png'); ?>" /> 755 579 </a> 756 580 <a target="_blank" href="<?php echo $link; ?>"> 757 <img alt=" View Page" title="View Page" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-viewpage.png" />581 <img alt="<?php esc_attr_e('View Page'); ?>" title="<?php esc_attr_e('View Page'); ?>" src="<?php echo admin_url('images/ico-viewpage.png'); ?>" /> 758 582 </a> 759 583 </span> … … 777 601 <?php 778 602 779 // Do recursion603 // Do recursion 780 604 $counter = wp_custom_navigation_default_sub_items($parent_id, $counter, $parent_id, $type, 'menu'); 781 605 … … 792 616 793 617 <?php $templatedir = get_bloginfo('url'); ?> 794 <span class="title"><?php echo $title; ?></span> <a onclick="appendToList('<?php echo $templatedir; ?>','<?php echo $appendtype; ?>','<?php echo $title; ?>','<?php echo $link; ?>','<?php echo $itemid; ?>','<?php echo $parent_id ?>','<?php echo $description; ?>')" name="<?php echo $title; ?>" value="<?php echo $link; ?>"><img alt=" Add to Custom Menu" title="Add to Custom Menu" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-add.png" /></a> </dt>618 <span class="title"><?php echo $title; ?></span> <a onclick="appendToList('<?php echo $templatedir; ?>','<?php echo $appendtype; ?>','<?php echo $title; ?>','<?php echo $link; ?>','<?php echo $itemid; ?>','<?php echo $parent_id ?>','<?php echo $description; ?>')" name="<?php echo $title; ?>" value="<?php echo $link; ?>"><img alt="<?php esc_attr_e('Add to Custom Menu'); ?>" title="<?php esc_attr_e('Add to Custom Menu'); ?>" src="<?php echo admin_url('images/ico-add.png'); ?>" /></a> </dt> 795 619 </dl> 796 620 <?php 797 621 798 // Do recursion622 // Do recursion 799 623 $counter = wp_custom_navigation_default_sub_items($itemid, $counter, $parent_id, $type, 'default'); 800 624 … … 825 649 $counter = $intCounter; 826 650 827 //Get Sub Category Items828 651 if ( $type == 'categories' ) { 652 // Get Sub Category Items 829 653 $sub_args = array( 830 654 'child_of' => $childof, … … 832 656 'parent' => $childof); 833 657 $sub_array = get_categories($sub_args); 834 } 835 //Get Sub Page Items 836 elseif ($type == 'pages') 837 { 658 } elseif ($type == 'pages') { 659 // Get Sub Page Items 838 660 $sub_args = array( 839 661 'child_of' => $childof, … … 847 669 848 670 if ( $sub_array ) { 849 // DISPLAY Loop671 // DISPLAY Loop 850 672 foreach ( $sub_array as $sub_item ) { 851 if ( isset($sub_item->parent) ) {673 if ( isset($sub_item->parent) ) 852 674 $sub_item_parent = $sub_item->parent; 853 } elseif (isset($sub_item->post_parent)) {675 elseif (isset($sub_item->post_parent)) 854 676 $sub_item_parent = $sub_item->post_parent; 855 }856 677 857 678 // Is child 858 679 if ( $sub_item_parent == $childof ) { 859 // Prepare Menu Data860 // Category Menu Item680 // Prepare Menu Data 681 // Category Menu Item 861 682 if ( $type == 'categories' ) { 862 683 $link = get_category_link($sub_item->cat_ID); … … 867 688 $appendtype= 'Category'; 868 689 } 869 // Page Menu Item690 // Page Menu Item 870 691 elseif ( $type == 'pages' ) { 871 692 $link = get_permalink($sub_item->ID); … … 876 697 $appendtype= 'Page'; 877 698 } 878 // Custom Menu Item699 // Custom Menu Item 879 700 else { 880 701 $title = ''; … … 883 704 } 884 705 885 // CHECK for existing parent records886 // echo $parent_id;706 // CHECK for existing parent records 707 // echo $parent_id; 887 708 $wp_result = $wpdb->get_results("SELECT id FROM ".$table_name." WHERE post_id='".$parent_id."' AND link_type='".$linktype."' AND menu_id='".$menu_id."'"); 888 if ( $wp_result > 0 && isset($wp_result[0]->id)) {709 if ( $wp_result > 0 && isset($wp_result[0]->id) ) 889 710 $parent_id = $wp_result[0]->id; 890 } else {891 //$parent_id = 0;892 }893 711 894 712 //INSERT item
Note: See TracChangeset
for help on using the changeset viewer.