Changeset 13268 for trunk/wp-admin/custom-navigation.php
- Timestamp:
- 02/21/2010 12:03:42 AM (16 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/custom-navigation.php (modified) (33 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/custom-navigation.php
r13266 r13268 10 10 * @subpackage Administration 11 11 */ 12 12 13 13 require_once('admin.php'); 14 14 … … 29 29 function wp_custom_nav_reset() { 30 30 wp_custom_navigation_setup(true); 31 31 32 32 return true; 33 33 34 34 } 35 35 … … 47 47 <div class="wrap"> 48 48 <div id="no-js"><h3>You do not have JavaScript enabled in your browser. Please enable it to access the Custom Menu functionality.</h3></div> 49 49 50 50 <?php 51 51 $messagesdiv = ''; 52 52 $menu_id_in_edit = 0; 53 53 54 54 // Get the theme name 55 55 $themename = get_current_theme(); 56 56 57 57 // Check which menu is selected and if menu is in edit already 58 58 if ( isset( $_POST['switch_menu'] ) ) … … 60 60 elseif ( isset( $_POST['menu_id_in_edit'] ) ) 61 61 $menu_selected_id = $_POST['menu_id_in_edit']; 62 62 63 63 // Default Menu to show 64 64 $custom_menus = get_terms( 'menu', array( 'hide_empty' => false ) ); … … 75 75 } 76 76 } 77 77 78 78 if ( isset( $_POST['set_wp_menu'] ) ) { 79 79 update_option( 'wp_custom_nav_menu', $_POST['enable_wp_menu'] ); 80 80 $messagesdiv = '<div id="message" class="updated fade below-h2"><p>'.$themename.'s Custom Menu has been updated!</p></div>'; 81 } 82 81 } 82 83 83 if ( isset( $_POST['licount'] ) ) 84 84 $postCounter = $_POST['licount']; … … 94 94 if ( $existing_term ) { 95 95 $messagesdiv = '<div id="message" class="error fade below-h2"><p>'.$insert_menu_name.' Menu has already created - please try another name</p></div>'; 96 } else { 96 } else { 97 97 $term = wp_insert_term( $insert_menu_name, 'menu' ); 98 98 if ( $term ) { … … 100 100 $menu_selected_id = $term['term_id']; 101 101 $menu_id_in_edit = $menu_selected_id; 102 $messagesdiv = '<div id="message" class="updated fade below-h2"><p>'.$insert_menu_name.' Menu has been created!</p></div>'; 102 $messagesdiv = '<div id="message" class="updated fade below-h2"><p>'.$insert_menu_name.' Menu has been created!</p></div>'; 103 103 104 104 $postCounter = 0; … … 109 109 } 110 110 } 111 112 if ( isset($_POST['reset_wp_menu']) ) { 111 112 if ( isset($_POST['reset_wp_menu']) ) { 113 113 $success = wp_custom_nav_reset(); 114 114 if ($success) { … … 129 129 //Loop through all POST variables 130 130 for ($k = 1;$k<= $postCounter; $k++) { 131 131 132 132 if (isset($_POST['dbid'.$k])) { $db_id = $_POST['dbid'.$k]; } else { $db_id = 0; } 133 133 if (isset($_POST['postmenu'.$k])) { $post_id = $_POST['postmenu'.$k]; } else { $post_id = 0; } … … 143 143 if (isset($_POST['anchortitle'.$k])) { $custom_anchor_title = stripslashes($_POST['anchortitle'.$k]); } else { $custom_anchor_title = $custom_title; } 144 144 if (isset($_POST['newwindow'.$k])) { $new_window = $_POST['newwindow'.$k]; } else { $new_window = 0; } 145 145 146 146 $post = array( 'post_status' => 'publish', 'post_type' => 'menu_item', 'post_author' => $user_ID, 147 147 'ping_status' => 0, 'post_parent' => $post_id, '`menu_order' => $position, … … 176 176 $messagesdiv = '<div id="message" class="updated fade below-h2"><p>'.$themename.'s Custom Menu has been updated!</p></div>'; 177 177 } 178 178 179 179 //DISPLAY Custom Navigation 180 180 ?> … … 183 183 <h2 class="maintitle">Custom Navigation</h2> 184 184 <?php 185 185 186 186 //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 190 if ($checked == 'true') { 191 191 } else { 192 192 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 193 } 194 195 194 195 196 196 ?> 197 197 <?php echo $messagesdiv; ?> 198 198 <form onsubmit="updatepostdata()" action="custom-navigation.php" method="post" enctype="multipart/form-data"> 199 199 200 200 <input type="hidden" name="licount" id="licount" value="0" /> 201 201 <input type="hidden" name="menu_id_in_edit" id="menu_id_in_edit" value="<?php echo $menu_selected_id; ?>" /> 202 202 203 203 <div class="sidebar-name"> 204 204 205 205 <div class="sidebar-name-arrow"> 206 206 <br/> 207 207 </div> 208 208 <h3><?php echo $menu_title; ?></h3> 209 209 210 210 </div> 211 211 212 212 <div id="nav-container"> 213 213 <ul id="custom-nav"> 214 214 215 215 <?php 216 216 //DISPLAY existing menu … … 220 220 //MAIN OUTPUT FUNCTION 221 221 wp_custom_navigation_output( 'type='.$output_type.'&name='.$menu_title.'&id='.$menu_selected_id ); 222 } 222 } 223 223 ?> 224 224 225 225 </ul> 226 226 </div><!-- /#nav-container --> 227 227 228 228 <p class="submit"> 229 229 230 230 <script type="text/javascript"> 231 updatepostdata(); 231 updatepostdata(); 232 232 </script> 233 233 234 234 <input id="save_bottom" name="save_bottom" type="submit" value="Save All Changes" /></p> 235 235 </div><!-- /.inside --> 236 236 </div> 237 237 238 238 <div id="menu-right"> 239 239 240 240 <h2 class="heading">Options</h2> 241 241 242 242 <div class="widgets-holder-wrap"> 243 243 <div class="sidebar-name"> … … 246 246 </div> 247 247 <div class="widget-holder"> 248 248 249 249 <?php 250 250 251 251 //SETUP Custom Menu 252 252 253 253 $enabled_menu = get_option('wp_custom_nav_menu'); 254 254 255 255 $checked = strtolower($enabled_menu); 256 256 257 257 ?> 258 258 259 259 <span > 260 260 <label>Enable</label><input type="radio" name="enable_wp_menu" value="true" <?php if ($checked=='true') { echo 'checked="checked"'; } ?> /> 261 261 <label>Disable</label><input type="radio" name="enable_wp_menu" value="false" <?php if ($checked=='true') { } else { echo 'checked="checked"'; } ?> /> 262 </span><!-- /.checkboxes --> 263 262 </span><!-- /.checkboxes --> 263 264 264 <input id="set_wp_menu" type="submit" value="Set Menu" name="set_wp_menu" class="button" /><br /> 265 265 266 266 <span> 267 267 <label>Reset Menu to Default</label> 268 268 <input id="reset_wp_menu" type="submit" value="Reset" name="reset_wp_menu" class="button" onclick="return confirm('Are you sure you want to RESET the Custom Navigation Menu to its Default Settings?');" /> 269 269 </span> 270 270 271 271 <div class="fix"></div> 272 272 </div> 273 273 </div><!-- /.widgets-holder-wrap --> 274 274 275 275 <div class="widgets-holder-wrap"> 276 276 <div class="sidebar-name"> … … 280 280 <div class="widget-holder"> 281 281 <select id="menu_select" name="menu_select"> 282 <?php 283 282 <?php 283 284 284 //DISPLAY SELECT OPTIONS 285 285 foreach( $custom_menus as $menu ) { … … 292 292 <option value="<?php echo $menu_term->term_id; ?>" <?php echo $selected_option; ?>><?php echo $menu_term->name; ?></option> 293 293 <?php 294 294 295 295 } 296 296 ?> 297 297 </select> 298 298 299 299 <input id="switch_menu" type="submit" value="Switch" name="switch_menu" class="button" /> 300 300 <input id="add_menu_name" name="add_menu_name" type="text" value="" /> 301 301 <input id="add_menu" type="submit" value="Add Menu" name="add_menu" class="button" /> 302 302 303 303 <div class="fix"></div> 304 304 </div> … … 310 310 <h3>Top Level Menu Descriptions</h3> 311 311 </div> 312 <div class="widget-holder"> 312 <div class="widget-holder"> 313 313 <span>Display Descriptions in Top Level Menu?</span> 314 314 315 315 <?php 316 316 317 317 //UPDATE and DISPLAY Menu Description Option 318 318 if (isset($_POST['menu-descriptions'])) 319 319 { 320 320 321 321 if (isset($_POST['switch_menu'])) { 322 322 323 323 } 324 324 else { 325 325 $menu_options_to_edit = $_POST['menu_id_in_edit']; 326 update_option('wp_settings_custom_nav_'.$menu_options_to_edit.'_descriptions',$_POST['menu-descriptions']); 326 update_option('wp_settings_custom_nav_'.$menu_options_to_edit.'_descriptions',$_POST['menu-descriptions']); 327 327 } 328 328 329 329 } 330 330 331 331 if ($menu_id_in_edit > 0) 332 332 { … … 336 336 $checkedraw = get_option('wp_settings_custom_nav_'.$menu_selected_id.'_descriptions'); 337 337 } 338 338 339 339 $checked = strtolower($checkedraw); 340 340 341 341 if ($advanced_option_descriptions == 'no') 342 342 { 343 343 $checked = 'no'; 344 344 } 345 345 346 346 ?> 347 347 348 348 <span class="checkboxes"> 349 349 <label>Yes</label><input type="radio" name="menu-descriptions" value="yes" <?php if ($checked=='yes') { echo 'checked="checked"'; } ?> /> … … 354 354 </div> 355 355 </div><!-- /.widgets-holder-wrap --> 356 356 357 357 <div class="widgets-holder-wrap"> 358 358 <div class="sidebar-name"> … … 361 361 </div> 362 362 <div class="widget-holder"> 363 363 364 364 <?php 365 365 366 366 $pages_args = array( 367 367 'child_of' => 0, … … 378 378 'number' => '', 379 379 'offset' => 0 ); 380 381 //GET all pages 380 381 //GET all pages 382 382 $pages_array = get_pages($pages_args); 383 383 $page_name = ''; … … 387 387 foreach ($pages_array as $post) 388 388 { 389 //Add page name to 389 //Add page name to 390 390 $page_name .= htmlentities($post->post_title).'|'; 391 391 } … … 395 395 $page_name = "No pages available"; 396 396 } 397 397 398 398 ?> 399 399 400 400 <script> 401 401 jQuery(document).ready(function(){ … … 403 403 //GET PHP pages 404 404 var dataposts = "<?php echo $page_name; ?>".split("|"); 405 405 406 406 //Set autocomplete 407 407 jQuery("#page-search").autocomplete(dataposts); 408 408 409 409 //Handle autocomplete result 410 410 jQuery("#page-search").result(function(event, data, formatted) { 411 411 jQuery('#existing-pages').css('display','block'); 412 412 jQuery("#existing-pages dt:contains('" + data + "')").css("display", "block"); 413 413 414 414 jQuery('#show-pages').hide(); 415 415 jQuery('#hide-pages').show(); 416 416 417 417 }); 418 418 jQuery('#existing-pages').css('display','none'); … … 421 421 422 422 423 <input type="text" onfocus="jQuery('#page-search').attr('value','');" id="page-search" value="Search Pages" /> 424 425 <a id="show-pages" style="cursor:pointer;" onclick="jQuery('#existing-pages').css('display','block');jQuery('#page-search').attr('value','');jQuery('#existing-pages dt').css('display','block');jQuery('#show-pages').hide();jQuery('#hide-pages').show();">View All</a> 423 <input type="text" onfocus="jQuery('#page-search').attr('value','');" id="page-search" value="Search Pages" /> 424 425 <a id="show-pages" style="cursor:pointer;" onclick="jQuery('#existing-pages').css('display','block');jQuery('#page-search').attr('value','');jQuery('#existing-pages dt').css('display','block');jQuery('#show-pages').hide();jQuery('#hide-pages').show();">View All</a> 426 426 <a id="hide-pages" style="cursor:pointer;" onclick="jQuery('#existing-pages').css('display','none');jQuery('#page-search').attr('value','Search Pages');jQuery('#existing-pages dt').css('display','none');jQuery('#show-pages').show();jQuery('#hide-pages').hide();">Hide All</a> 427 427 428 428 <script type="text/javascript"> 429 429 430 430 jQuery('#hide-pages').hide(); 431 431 432 432 </script> 433 433 434 434 <ul id="existing-pages" class="list"> 435 435 <?php … … 439 439 ?> 440 440 </ul> 441 441 442 442 <div class="fix"></div> 443 443 444 444 </div> 445 445 </div><!-- /.widgets-holder-wrap --> 446 446 447 447 <div class="widgets-holder-wrap"> 448 448 <div class="sidebar-name"> … … 451 451 </div> 452 452 <div class="widget-holder"> 453 453 454 454 <?php 455 455 456 456 //Custom GET categories query 457 457 $categories = $wpdb->get_results("SELECT term_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'category' ORDER BY term_id ASC"); … … 460 460 if ($categories) 461 461 { 462 foreach($categories as $category) 463 { 462 foreach($categories as $category) 463 { 464 464 $cat_id = $category->term_id; 465 465 466 466 $cat_args=array( 467 467 'orderby' => 'name', … … 470 470 'order' => 'ASC' 471 471 ); 472 472 473 473 $category_names=get_categories($cat_args); 474 474 475 475 if (isset($category_names[0]->name)) 476 476 { … … 484 484 $cat_name = "No categories available"; 485 485 } 486 486 487 487 ?> 488 488 … … 492 492 //GET PHP categories 493 493 var datacats = "<?php echo $cat_name; ?>".split("|"); 494 494 495 495 //Set autocomplete 496 496 jQuery("#cat-search").autocomplete(datacats); 497 497 498 498 //Handle autocomplete result 499 499 jQuery("#cat-search").result(function(event, data, formatted) { 500 500 jQuery('#existing-categories').css('display','block'); 501 501 jQuery("#existing-categories dt:contains('" + data + "')").css("display", "block"); 502 502 503 503 jQuery('#show-cats').hide(); 504 504 jQuery('#hide-cats').show(); 505 505 506 506 }); 507 507 jQuery('#existing-categories').css('display','none'); 508 508 509 509 }); 510 510 </script> 511 511 512 512 513 <input type="text" onfocus="jQuery('#cat-search').attr('value','');" id="cat-search" value="Search Categories" /> 514 515 <a id="show-cats" style="cursor:pointer;" onclick="jQuery('#existing-categories').css('display','block');jQuery('#cat-search').attr('value','');jQuery('#existing-categories dt').css('display','block');jQuery('#show-cats').hide();jQuery('#hide-cats').show();">View All</a> 513 <input type="text" onfocus="jQuery('#cat-search').attr('value','');" id="cat-search" value="Search Categories" /> 514 515 <a id="show-cats" style="cursor:pointer;" onclick="jQuery('#existing-categories').css('display','block');jQuery('#cat-search').attr('value','');jQuery('#existing-categories dt').css('display','block');jQuery('#show-cats').hide();jQuery('#hide-cats').show();">View All</a> 516 516 <a id="hide-cats" style="cursor:pointer;" onclick="jQuery('#existing-categories').css('display','none');jQuery('#cat-search').attr('value','Search Categories');jQuery('#existing-categories dt').css('display','none');jQuery('#show-cats').show();jQuery('#hide-cats').hide();">Hide All</a> 517 517 518 518 <script type="text/javascript"> 519 519 520 520 jQuery('#hide-cats').hide(); 521 521 522 522 </script> 523 523 524 524 <ul id="existing-categories" class="list"> 525 525 <?php 526 526 //Get default Categories 527 $intCounter = wp_custom_nav_get_categories($intCounter,'default'); 527 $intCounter = wp_custom_nav_get_categories($intCounter,'default'); 528 528 ?> 529 529 </ul> 530 530 531 531 <div class="fix"></div> 532 532 533 533 </div> 534 534 </div><!-- /.widgets-holder-wrap --> 535 535 536 536 <div class="widgets-holder-wrap"> 537 537 <div class="sidebar-name"> … … 552 552 </div> 553 553 </div><!-- /.widgets-holder-wrap --> 554 554 555 555 </div> 556 556 </div> 557 557 558 558 <script type="text/javascript"> 559 559 document.getElementById('pages-left').style.display='block'; … … 561 561 document.getElementById('no-js').style.display='none'; 562 562 </script> 563 563 564 564 <div id="dialog-confirm" title="Edit Menu Item"> 565 565 </label><input id="edittitle" type="text" name="edittitle" value="" /><label class="editlabel" for="edittitle">Menu Title</label><br />
Note: See TracChangeset
for help on using the changeset viewer.