introduce custom menus, props jeffikus, See #11817

git-svn-id: http://svn.automattic.com/wordpress/trunk@13257 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
wpmuguru 2010-02-20 21:57:43 +00:00
parent 00706d68ce
commit 4d203a02c6
22 changed files with 3798 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,168 @@
/**
* WordPress Administration Custom Navigation
* Interface CSS
*
* @author Jeffikus <pearce.jp@gmail.com>
* @version 1.1.0
*
* @package WordPress
* @subpackage Administration
*/
.fix{clear: both;height: 1px;margin: -1px 0 0;overflow: hidden;}
#no-js {display:block;}
.maintitle { margin: 0 0 20px 0!important;}
.logo { vertical-align: middle; margin: 0 10px 0 0; }
#pages-left { min-width:650px;max-width:1100px;width: 100%; float:left; clear: left; margin-right: -315px; }
#pages-left .inside {margin-top: 20px; margin-right: 315px; }
#nav-container { margin-top: -3px; }
.sidebar-name { background-color:#AAAAAA;
background-image:url(../../../../../wp-admin/images/ed-bg.gif);
border-color:#DFDFDF;
text-shadow:0 1px 0 #FFFFFF;-moz-border-radius-topleft:8px;
-moz-border-radius-topright:8px;
background-position:0 0;
background-repeat:repeat-x;
border-style:solid;
border-width:1px;
cursor:pointer;
font-size:13px; }
.sidebar-name h3 {
font-size:13px;
height:19px;
margin:0;
overflow:hidden;
padding:5px 12px;
white-space:nowrap;
}
.sidebar-name-arrow {
background:transparent url(../../../../../wp-admin/images/menu-bits.gif) no-repeat scroll left -109px;
float:right;
height:29px;
width:26px;
}
#menu-right { width: 285px; margin-right: 10px; margin-left: 20px; float:left; clear: right;}
h2.heading { margin: 32px 0 10px 0; }
.widgets-holder-wrap { margin: 0 0 20px 0; }
.widget-holder {
padding:15px 10px;
-moz-border-radius-bottomleft:8px;
-moz-border-radius-bottomright:8px;
border-style:none solid solid;
border-width:0 1px 1px;
background-color:#F1F1F1;
border-color:#DDDDDD;
}
.checkboxes { float: right; margin: 10px 12px 0 0; }
.addtomenu {
display: block;
float: right;
margin: 10px 0 0 0;
text-shadow:0 -1px 0 rgba(0, 0, 0, 0.3);
background:#21759B url(../../../../../wp-admin/images/button-grad.png) repeat-x scroll left top;
border-color:#298CBA !important;
color:#FFFFFF !important;
font-weight:bold;
-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:16px;
padding:2px 8px;
text-decoration:none;
}
.list { zoom: 1; }
.list li { margin: 0; }
.list dt { display:none; float: left; width: 260px; margin: 0; padding: 0 0 0 5px; line-height: 30px; border-bottom: 1px solid #e3e3e3; }
.list dt span { float: left; }
.list dt img { cursor: pointer; float: right; margin: 7px 5px 0 0 }
#nav-container { padding: 0 10px 10px 10px; background-color: #fff; border: 1px solid #DFDFDF; border-top: none; -moz-border-radius-bottomleft:8px; -moz-border-radius-bottomright:8px; }
#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 dl dt a {}
#custom-nav li .title { background:url(../images/ico-arrow.png) no-repeat 4px 5px; 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; }
#existing-pages li .title { background:url(../images/ico-arrow.png) no-repeat 4px 13px; padding-left:15px; }
#existing-pages li ul li .title { margin-left:10px; }
#existing-pages li ul li ul li .title { margin-left:20px; }
#existing-pages li ul li ul li ul li .title { margin-left:30px; }
#existing-pages li ul li ul li ul li ul li .title { margin-left:40px; }
#existing-pages li ul li ul li ul li ul li ul li .title { margin-left:50px; }
#existing-pages li ul li ul li ul li ul li ul li ul li .title { margin-left:60px; }
#existing-pages li ul li ul li ul li ul li ul li ul li ul li .title { margin-left:70px; }
#existing-pages li ul li ul li ul li ul li ul li ul li ul li ul li .title { margin-left:80px; }
#existing-categories li .title { background:url(../images/ico-arrow.png) no-repeat 4px 13px; padding-left:15px; }
#existing-categories li ul li .title { margin-left:10px; }
#existing-categories li ul li ul li .title { margin-left:20px; }
#existing-categories li ul li ul li ul li .title { margin-left:30px; }
#existing-categories li ul li ul li ul li ul li .title { margin-left:40px; }
#existing-categories li ul li ul li ul li ul li ul li .title { margin-left:50px; }
#existing-categories li ul li ul li ul li ul li ul li ul li .title { margin-left:60px; }
#existing-categories li ul li ul li ul li ul li ul li ul li ul li .title { margin-left:70px; }
#existing-categories li ul li ul li ul li ul li ul li ul li ul li ul li .title { margin-left:80px; }
img.remove, img.edit { cursor: pointer; margin: 0 5px 0 0; }
.dropzone {height:7px;margin: 3px 0 3px 0;}
#custom-nav li dl {}
.hide {display:none;}
.type { text-transform: uppercase; font-size: 11px; color: #999999; padding-right:10px; }
#menu_select { width: 170px; }
#dialog-confirm label { padding-left: 10px; }
/* EDIT LINK BOX */
.ui-dialog { background: #fff; border: 1px solid #555555; -moz-box-shadow:0 4px 30px #000000; }
.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; }
#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 #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; }
.ui-dialog-buttonpane button:hover {color:#000;border-color:#666;}
.ui-icon { display: none; }
/* Overlays */
.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.ui-widget-overlay { background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .60;filter:Alpha(Opacity=60); }
.ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .60;filter:Alpha(Opacity=60); -moz-border-radius: 8px; -webkit-border-radius: 8px; }
#reset_wp_menu { background:#c77 none !important;color:white!important;text-shadow:0 1px 0 #555 !important;}

View File

@ -0,0 +1,590 @@
<?php
/**
* WordPress Administration Custom Navigation
* Interface functions
*
* @author Jeffikus <pearce.jp@gmail.com>
* @version 1.1.0
*
* @package WordPress
* @subpackage Administration
*/
require_once('admin.php');
wp_admin_css( 'custom-navigation' );
wp_enqueue_script( 'custom-navigation-jquery' );
wp_enqueue_script( 'custom-navigation-ui-custom' );
wp_enqueue_script( 'custom-navigation-dynamic-functions' );
wp_enqueue_script( 'custom-navigation-default-items' );
wp_enqueue_script( 'custom-navigation-autocomplete' );
wp_enqueue_script( 'custom-navigation-php-functions' );
wp_enqueue_script( 'jquery-ui-dialog' );
require_once('admin-header.php');
require_once (ABSPATH . WPINC . '/custom-navigation-functions.php');
wp_custom_navigation();
function wp_custom_nav_reset() {
global $wpdb;
$table_name = $wpdb->prefix . "custom_nav_records";
//DROP existing menu records
$wpdb->query("DELETE FROM ".$table_name);
$table_name_menus = $wpdb->prefix . "custom_nav_menus";
//DELETE existing menus
$wpdb->query("DELETE FROM ".$table_name_menus);
wp_custom_navigation_setup(true);
return true;
}
/*-----------------------------------------------------------------------------------*/
/* Custom Navigation Admin Interface
/* wp_custom_navigation() is the main function for the Custom Navigation
/* See functions in admin-functions.php
/*-----------------------------------------------------------------------------------*/
function wp_custom_navigation() {
global $wpdb, $user_ID;
?>
<div class="wrap">
<div id="no-js"><h3>You do not have JavaScript enabled in your browser. Please enabled it to access the Custom Menu functionality.</h3></div>
<?php
$messagesdiv = '';
$menu_id_in_edit = 0;
//Get the theme name
$themename = get_current_theme();
//CHECK which menu is selected and if menu is in edit already
if ( isset( $_POST['switch_menu'] ) )
$menu_selected_id = $_POST['menu_select'];
elseif ( isset( $_POST['menu_id_in_edit'] ) )
$menu_selected_id = $_POST['menu_id_in_edit'];
//Default Menu to show
$custom_menus = get_terms( 'menu', array( 'hide_empty' => false ) );
if ( !empty( $custom_menus ) )
$menu_selected_id = $custom_menus[0]->term_id;
$menu_title = '';
if ( $menu_selected_id > 0 ) {
foreach( $custom_menus as $menu ) {
if ( $menu->term_id == $menu_selected_id ) {
$menu_title = $menu->name;
break;
}
}
}
if ( isset( $_POST['set_wp_menu'] ) ) {
update_option( 'wp_custom_nav_menu', $_POST['enable_wp_menu'] );
$messagesdiv = '<div id="message" class="updated fade below-h2"><p>'.$themename.'s Custom Menu has been updated!</p></div>';
}
if ( isset( $_POST['licount'] ) )
$postCounter = $_POST['licount'];
else
$postCounter = 0;
if ( isset( $_POST['add_menu'] ) ) {
$insert_menu_name = $_POST['add_menu_name'];
if ( $insert_menu_name != '' ) {
$existing_term = get_term_by( 'name', $insert_menu_name, 'menu' );
if ( $existing_term ) {
$messagesdiv = '<div id="message" class="error fade below-h2"><p>'.$insert_menu_name.' Menu has already created - please try another name</p></div>';
} else {
$term = wp_insert_term( $insert_menu_name, 'menu' );
if ( $term ) {
$custom_menus[$term['term_id']] = $term;
$menu_selected_id = $term['term_id'];
$menu_id_in_edit = $menu_selected_id;
$messagesdiv = '<div id="message" class="updated fade below-h2"><p>'.$insert_menu_name.' Menu has been created!</p></div>';
$postCounter = 0;
}
}
} else {
$messagesdiv = '<div id="message" class="error fade below-h2"><p>Please enter a valid Menu name</p></div>';
}
}
if (isset($_POST['reset_wp_menu'])) {
$success = wp_custom_nav_reset();
if ($success) {
//DISPLAY SUCCESS MESSAGE IF Menu Reset Correctly
$messagesdiv = '<div id="message" class="updated fade below-h2"><p>'.$themename.'s Custom Menu has been RESET!</p></div>';
//GET reset menu id
$custom_menus = array();
$menu_selected_id = 0;
} else {
//DISPLAY SUCCESS MESSAGE IF Menu Reset Correctly
$messagesdiv = '<div id="message" class="error fade below-h2"><p>'.$themename.'s Custom Menu could not be RESET. Please try again.</p></div>';
}
} elseif ( $postCounter > 0 && $menu_selected_id > 0 ) {
$menu_objects = get_objects_in_term( $menu_selected_id, 'menu' );
$menu_items = wp_custom_navigation_get_menu_items( $menu_objects );
$update_fields = array( 'menu_order', 'guid', 'post_content', 'post_title', 'post_excerpt', 'post_content_filtered' );
//Loop through all POST variables
for ($k = 1;$k<= $postCounter; $k++) {
if (isset($_POST['dbid'.$k])) { $db_id = $_POST['dbid'.$k]; } else { $db_id = 0; }
if (isset($_POST['postmenu'.$k])) { $post_id = $_POST['postmenu'.$k]; } else { $post_id = 0; }
//@todo implement heirarchy
if (isset($_POST['parent'.$k])) { $parent_id = $_POST['parent'.$k]; } else { $parent_id = 0; }
if (isset($_POST['title'.$k])) { $custom_title = stripslashes($_POST['title'.$k]); } else { $custom_title = ''; }
if (isset($_POST['linkurl'.$k])) { $custom_linkurl = $_POST['linkurl'.$k]; } else { $custom_linkurl = ''; }
if (isset($_POST['description'.$k])) { $custom_description = stripslashes($_POST['description'.$k]); } else { $custom_description = ''; }
// doesn't seem to be used by UI
if (isset($_POST['icon'.$k])) { $icon = $_POST['icon'.$k]; } else { $icon = 0; }
if (isset($_POST['position'.$k])) { $position = $_POST['position'.$k]; } else { $position = 0; }
if (isset($_POST['linktype'.$k])) { $linktype = $_POST['linktype'.$k]; } else { $linktype = 'custom'; }
if (isset($_POST['anchortitle'.$k])) { $custom_anchor_title = stripslashes($_POST['anchortitle'.$k]); } else { $custom_anchor_title = $custom_title; }
if (isset($_POST['newwindow'.$k])) { $new_window = $_POST['newwindow'.$k]; } else { $new_window = 0; }
$post = array( 'post_status' => 'menu-' . $linktype, 'post_type' => 'menu_item', 'post_author' => $user_ID,
'ping_status' => 0, 'post_parent' => $post_id, 'menu_order' => $position,
'guid' => $custom_linkurl, 'post_excerpt' => $custom_anchor_title, 'tax_input' => array( 'menu' => $menu_title ),
'post_content' => $custom_description, 'post_title' => $custom_title );
if ( $new_window )
$post['post_content_filtered'] = '_blank';
else
$post['post_content_filtered'] = '';
//New menu item
if ($db_id == 0) {
$post_id = wp_insert_post( $post );
} elseif ( isset( $menu_items[$db_id] ) ) {
foreach( $update_fields as $field ) {
if ( $post[$field] != $menu_items[$db_id]->$field ) {
$post['ID'] = $db_id;
wp_insert_post( $post );
break;
}
}
unset( $menu_items[$db_id] );
}
}
if ( !empty( $menu_items ) ) {
foreach( array_keys( $menu_items ) as $menu_id ) {
wp_delete_post( $menu_id );
}
}
//DISPLAY SUCCESS MESSAGE IF POST CORRECT
$messagesdiv = '<div id="message" class="updated fade below-h2"><p>'.$themename.'s Custom Menu has been updated!</p></div>';
}
//DISPLAY Custom Navigation
?>
<div id="pages-left">
<div class="inside">
<h2 class="maintitle">Custom Navigation</h2>
<?php
//CHECK if custom menu has been enabled
$enabled_menu = get_option('wp_custom_nav_menu');
$checked = strtolower($enabled_menu);
if ($checked == 'true') {
} else {
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>';
}
?>
<?php echo $messagesdiv; ?>
<form onsubmit="updatepostdata()" action="custom-navigation.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="licount" id="licount" value="0" />
<input type="hidden" name="menu_id_in_edit" id="menu_id_in_edit" value="<?php echo $menu_selected_id; ?>" />
<div class="sidebar-name">
<div class="sidebar-name-arrow">
<br/>
</div>
<h3><?php echo $menu_title; ?></h3>
</div>
<div id="nav-container">
<ul id="custom-nav">
<?php
//DISPLAY existing menu
if ( $menu_selected_id > 0 ) {
//SET output type
$output_type = "backend";
//MAIN OUTPUT FUNCTION
wp_custom_navigation_output( 'type='.$output_type.'&name='.$menu_title.'&id='.$menu_selected_id );
}
?>
</ul>
</div><!-- /#nav-container -->
<p class="submit">
<script type="text/javascript">
updatepostdata();
</script>
<input id="save_bottom" name="save_bottom" type="submit" value="Save All Changes" /></p>
</div><!-- /.inside -->
</div>
<div id="menu-right">
<h2 class="heading">Options</h2>
<div class="widgets-holder-wrap">
<div class="sidebar-name">
<div class="sidebar-name-arrow"></div>
<h3>Setup Custom Menu</h3>
</div>
<div class="widget-holder">
<?php
//SETUP Custom Menu
$enabled_menu = get_option('wp_custom_nav_menu');
$checked = strtolower($enabled_menu);
?>
<span >
<label>Enable</label><input type="radio" name="enable_wp_menu" value="true" <?php if ($checked=='true') { echo 'checked="checked"'; } ?> />
<label>Disable</label><input type="radio" name="enable_wp_menu" value="false" <?php if ($checked=='true') { } else { echo 'checked="checked"'; } ?> />
</span><!-- /.checkboxes -->
<input id="set_wp_menu" type="submit" value="Set Menu" name="set_wp_menu" class="button" /><br />
<span>
<label>Reset Menu to Default</label>
<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?');" />
</span>
<div class="fix"></div>
</div>
</div><!-- /.widgets-holder-wrap -->
<div class="widgets-holder-wrap">
<div class="sidebar-name">
<div class="sidebar-name-arrow"></div>
<h3>Menu Selector</h3>
</div>
<div class="widget-holder">
<select id="menu_select" name="menu_select">
<?php
//DISPLAY SELECT OPTIONS
foreach( $custom_menus as $menu ) {
$menu_term = get_term( $menu, 'menu' );
if ( ( $menu_id_in_edit == $menu ) || ( $menu_selected_id == $menu ) )
$selected_option = 'selected="selected"';
else
$selected_option = '';
?>
<option value="<?php echo $menu_term->term_id; ?>" <?php echo $selected_option; ?>><?php echo $menu_term->name; ?></option>
<?php
}
?>
</select>
<input id="switch_menu" type="submit" value="Switch" name="switch_menu" class="button" />
<input id="add_menu_name" name="add_menu_name" type="text" value="" />
<input id="add_menu" type="submit" value="Add Menu" name="add_menu" class="button" />
<div class="fix"></div>
</div>
</div><!-- /.widgets-holder-wrap -->
<?php $advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options'); ?>
<div class="widgets-holder-wrap" style="display:none;">
<div class="sidebar-name">
<div class="sidebar-name-arrow"></div>
<h3>Top Level Menu Descriptions</h3>
</div>
<div class="widget-holder">
<span>Display Descriptions in Top Level Menu?</span>
<?php
//UPDATE and DISPLAY Menu Description Option
if (isset($_POST['menu-descriptions']))
{
if (isset($_POST['switch_menu'])) {
}
else {
$menu_options_to_edit = $_POST['menu_id_in_edit'];
update_option('wp_settings_custom_nav_'.$menu_options_to_edit.'_descriptions',$_POST['menu-descriptions']);
}
}
if ($menu_id_in_edit > 0)
{
$checkedraw = get_option('wp_settings_custom_nav_'.$menu_id_in_edit.'_descriptions');
}
else {
$checkedraw = get_option('wp_settings_custom_nav_'.$menu_selected_id.'_descriptions');
}
$checked = strtolower($checkedraw);
if ($advanced_option_descriptions == 'no')
{
$checked = 'no';
}
?>
<span class="checkboxes">
<label>Yes</label><input type="radio" name="menu-descriptions" value="yes" <?php if ($checked=='yes') { echo 'checked="checked"'; } ?> />
<label>No</label><input type="radio" name="menu-descriptions" value="no" <?php if ($checked=='yes') { } else { echo 'checked="checked"'; } ?> />
</span><!-- /.checkboxes -->
</form>
<div class="fix"></div>
</div>
</div><!-- /.widgets-holder-wrap -->
<div class="widgets-holder-wrap">
<div class="sidebar-name">
<div class="sidebar-name-arrow"></div>
<h3>Add an Existing Page</h3>
</div>
<div class="widget-holder">
<?php
$pages_args = array(
'child_of' => 0,
'sort_order' => 'ASC',
'sort_column' => 'post_title',
'hierarchical' => 1,
'exclude' => '',
'include' => '',
'meta_key' => '',
'meta_value' => '',
'authors' => '',
'parent' => -1,
'exclude_tree' => '',
'number' => '',
'offset' => 0 );
//GET all pages
$pages_array = get_pages($pages_args);
$page_name = '';
//CHECK if pages exist
if ($pages_array)
{
foreach ($pages_array as $post)
{
//Add page name to
$page_name .= htmlentities($post->post_title).'|';
}
}
else
{
$page_name = "No pages available";
}
?>
<script>
$(document).ready(function(){
//GET PHP pages
var dataposts = "<?php echo $page_name; ?>".split("|");
//Set autocomplete
$("#page-search").autocomplete(dataposts);
//Handle autocomplete result
$("#page-search").result(function(event, data, formatted) {
$('#existing-pages').css('display','block');
$("#existing-pages dt:contains('" + data + "')").css("display", "block");
$('#show-pages').hide();
$('#hide-pages').show();
});
$('#existing-pages').css('display','none');
});
</script>
<input type="text" onfocus="jQuery('#page-search').attr('value','');" id="page-search" value="Search Pages" />
<a id="show-pages" style="cursor:pointer;" onclick="jQuery('#existing-pages').css('display','block');jQuery('#page-search').attr('value','');jQuery('#existing-pages dt').css('display','block');jQuery('#show-pages').hide();jQuery('#hide-pages').show();">View All</a>
<a id="hide-pages" style="cursor:pointer;" onclick="jQuery('#existing-pages').css('display','none');jQuery('#page-search').attr('value','Search Pages');jQuery('#existing-pages dt').css('display','none');jQuery('#show-pages').show();jQuery('#hide-pages').hide();">Hide All</a>
<script type="text/javascript">
jQuery('#hide-pages').hide();
</script>
<ul id="existing-pages" class="list">
<?php
$intCounter = 0;
//Get default Pages
$intCounter = wp_custom_nav_get_pages($intCounter,'default');
?>
</ul>
<div class="fix"></div>
</div>
</div><!-- /.widgets-holder-wrap -->
<div class="widgets-holder-wrap">
<div class="sidebar-name">
<div class="sidebar-name-arrow"></div>
<h3>Add an Existing Category</h3>
</div>
<div class="widget-holder">
<?php
//Custom GET categories query
$categories = $wpdb->get_results("SELECT term_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'category' ORDER BY term_id ASC");
$cat_name = '';
//CHECK for results
if ($categories)
{
foreach($categories as $category)
{
$cat_id = $category->term_id;
$cat_args=array(
'orderby' => 'name',
'include' => $cat_id,
'hierarchical' => 1,
'order' => 'ASC'
);
$category_names=get_categories($cat_args);
if (isset($category_names[0]->name))
{
//Add category name to data string
$cat_name .= htmlentities($category_names[0]->name).'|';
}
}
}
else
{
$cat_name = "No categories available";
}
?>
<script>
$(document).ready(function(){
//GET PHP categories
var datacats = "<?php echo $cat_name; ?>".split("|");
//Set autocomplete
$("#cat-search").autocomplete(datacats);
//Handle autocomplete result
$("#cat-search").result(function(event, data, formatted) {
$('#existing-categories').css('display','block');
$("#existing-categories dt:contains('" + data + "')").css("display", "block");
$('#show-cats').hide();
$('#hide-cats').show();
});
$('#existing-categories').css('display','none');
});
</script>
<input type="text" onfocus="jQuery('#cat-search').attr('value','');" id="cat-search" value="Search Categories" />
<a id="show-cats" style="cursor:pointer;" onclick="jQuery('#existing-categories').css('display','block');jQuery('#cat-search').attr('value','');jQuery('#existing-categories dt').css('display','block');jQuery('#show-cats').hide();jQuery('#hide-cats').show();">View All</a>
<a id="hide-cats" style="cursor:pointer;" onclick="jQuery('#existing-categories').css('display','none');jQuery('#cat-search').attr('value','Search Categories');jQuery('#existing-categories dt').css('display','none');jQuery('#show-cats').show();jQuery('#hide-cats').hide();">Hide All</a>
<script type="text/javascript">
jQuery('#hide-cats').hide();
</script>
<ul id="existing-categories" class="list">
<?php
//Get default Categories
$intCounter = wp_custom_nav_get_categories($intCounter,'default');
?>
</ul>
<div class="fix"></div>
</div>
</div><!-- /.widgets-holder-wrap -->
<div class="widgets-holder-wrap">
<div class="sidebar-name">
<div class="sidebar-name-arrow"></div>
<h3>Add a Custom Url</h3>
</div>
<div class="widget-holder">
<input id="custom_menu_item_url" type="text" value="http://" />
<label>URL</label><br />
<?php $templatedir = get_bloginfo('url'); ?>
<input type="hidden" id="templatedir" value="<?php echo $templatedir; ?>" />
<input id="custom_menu_item_name" type="text" value="Menu Item" onfocus="jQuery('#custom_menu_item_name').attr('value','');" />
<label>Menu Text</label><br />
<input id="custom_menu_item_description" type="text" value="A description" <?php if ($advanced_option_descriptions == 'no') { ?>style="display:none;"<?php } ?> onfocus="jQuery('#custom_menu_item_description').attr('value','');" />
<label <?php if ($advanced_option_descriptions == 'no') { ?>style="display:none;"<?php } ?> >Description</label>
<a class="addtomenu" onclick="appendToList('<?php echo $templatedir; ?>','Custom','','','','0','');jQuery('#custom_menu_item_name').attr('value','Menu Item');jQuery('#custom_menu_item_description').attr('value','A description');">Add to menu</a>
<div class="fix"></div>
</div>
</div><!-- /.widgets-holder-wrap -->
</div>
</div>
<script type="text/javascript">
document.getElementById('pages-left').style.display='block';
document.getElementById('menu-right').style.display='block';
document.getElementById('no-js').style.display='none';
</script>
<div id="dialog-confirm" title="Edit Menu Item">
</label><input id="edittitle" type="text" name="edittitle" value="" /><label class="editlabel" for="edittitle">Menu Title</label><br />
<input id="editlink" type="text" name="editlink" value="" /><label class="editlabel" for="editlink">URL</label><br />
<input id="editanchortitle" type="text" name="editanchortitle" value="" /><label class="editlabel" for="editanchortitle" >Link Title</label><br />
<select id="editnewwindow" name="editnewwindow">
<option value="1" >Yes</option>
<option value="0" >No</option>
</select><label class="editlabel" for="editnewwindow" >Open Link in a New Window</label>
<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 } ?> >Description</label><br />
</div>
<?php
}
include("admin-footer.php");

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,808 @@
/*
* jQuery Autocomplete plugin 1.1
*
* Copyright (c) 2009 Jörn Zaefferer
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Revision: $Id: jquery.autocomplete.js 15 2009-08-22 10:30:27Z joern.zaefferer $
*/
;(function($) {
$.fn.extend({
autocomplete: function(urlOrData, options) {
var isUrl = typeof urlOrData == "string";
options = $.extend({}, $.Autocompleter.defaults, {
url: isUrl ? urlOrData : null,
data: isUrl ? null : urlOrData,
delay: isUrl ? $.Autocompleter.defaults.delay : 10,
max: options && !options.scroll ? 10 : 150
}, options);
// if highlight is set to false, replace it with a do-nothing function
options.highlight = options.highlight || function(value) { return value; };
// if the formatMatch option is not specified, then use formatItem for backwards compatibility
options.formatMatch = options.formatMatch || options.formatItem;
return this.each(function() {
new $.Autocompleter(this, options);
});
},
result: function(handler) {
return this.bind("result", handler);
},
search: function(handler) {
return this.trigger("search", [handler]);
},
flushCache: function() {
return this.trigger("flushCache");
},
setOptions: function(options){
return this.trigger("setOptions", [options]);
},
unautocomplete: function() {
return this.trigger("unautocomplete");
}
});
$.Autocompleter = function(input, options) {
var KEY = {
UP: 38,
DOWN: 40,
DEL: 46,
TAB: 9,
RETURN: 13,
ESC: 27,
COMMA: 188,
PAGEUP: 33,
PAGEDOWN: 34,
BACKSPACE: 8
};
// Create $ object for input element
var $input = $(input).attr("autocomplete", "off").addClass(options.inputClass);
var timeout;
var previousValue = "";
var cache = $.Autocompleter.Cache(options);
var hasFocus = 0;
var lastKeyPressCode;
var config = {
mouseDownOnSelect: false
};
var select = $.Autocompleter.Select(options, input, selectCurrent, config);
var blockSubmit;
// prevent form submit in opera when selecting with return key
$.browser.opera && $(input.form).bind("submit.autocomplete", function() {
if (blockSubmit) {
blockSubmit = false;
return false;
}
});
// only opera doesn't trigger keydown multiple times while pressed, others don't work with keypress at all
$input.bind(($.browser.opera ? "keypress" : "keydown") + ".autocomplete", function(event) {
// a keypress means the input has focus
// avoids issue where input had focus before the autocomplete was applied
hasFocus = 1;
// track last key pressed
lastKeyPressCode = event.keyCode;
switch(event.keyCode) {
case KEY.UP:
event.preventDefault();
if ( select.visible() ) {
select.prev();
} else {
onChange(0, true);
}
break;
case KEY.DOWN:
event.preventDefault();
if ( select.visible() ) {
select.next();
} else {
onChange(0, true);
}
break;
case KEY.PAGEUP:
event.preventDefault();
if ( select.visible() ) {
select.pageUp();
} else {
onChange(0, true);
}
break;
case KEY.PAGEDOWN:
event.preventDefault();
if ( select.visible() ) {
select.pageDown();
} else {
onChange(0, true);
}
break;
// matches also semicolon
case options.multiple && $.trim(options.multipleSeparator) == "," && KEY.COMMA:
case KEY.TAB:
case KEY.RETURN:
if( selectCurrent() ) {
// stop default to prevent a form submit, Opera needs special handling
event.preventDefault();
blockSubmit = true;
return false;
}
break;
case KEY.ESC:
select.hide();
break;
default:
clearTimeout(timeout);
timeout = setTimeout(onChange, options.delay);
break;
}
}).focus(function(){
// track whether the field has focus, we shouldn't process any
// results if the field no longer has focus
hasFocus++;
}).blur(function() {
hasFocus = 0;
if (!config.mouseDownOnSelect) {
hideResults();
}
}).click(function() {
// show select when clicking in a focused field
if ( hasFocus++ > 1 && !select.visible() ) {
onChange(0, true);
}
}).bind("search", function() {
// TODO why not just specifying both arguments?
var fn = (arguments.length > 1) ? arguments[1] : null;
function findValueCallback(q, data) {
var result;
if( data && data.length ) {
for (var i=0; i < data.length; i++) {
if( data[i].result.toLowerCase() == q.toLowerCase() ) {
result = data[i];
break;
}
}
}
if( typeof fn == "function" ) fn(result);
else $input.trigger("result", result && [result.data, result.value]);
}
$.each(trimWords($input.val()), function(i, value) {
request(value, findValueCallback, findValueCallback);
});
}).bind("flushCache", function() {
cache.flush();
}).bind("setOptions", function() {
$.extend(options, arguments[1]);
// if we've updated the data, repopulate
if ( "data" in arguments[1] )
cache.populate();
}).bind("unautocomplete", function() {
select.unbind();
$input.unbind();
$(input.form).unbind(".autocomplete");
});
function selectCurrent() {
var selected = select.selected();
if( !selected )
return false;
var v = selected.result;
previousValue = v;
if ( options.multiple ) {
var words = trimWords($input.val());
if ( words.length > 1 ) {
var seperator = options.multipleSeparator.length;
var cursorAt = $(input).selection().start;
var wordAt, progress = 0;
$.each(words, function(i, word) {
progress += word.length;
if (cursorAt <= progress) {
wordAt = i;
return false;
}
progress += seperator;
});
words[wordAt] = v;
// TODO this should set the cursor to the right position, but it gets overriden somewhere
//$.Autocompleter.Selection(input, progress + seperator, progress + seperator);
v = words.join( options.multipleSeparator );
}
v += options.multipleSeparator;
}
$input.val(v);
hideResultsNow();
$input.trigger("result", [selected.data, selected.value]);
return true;
}
function onChange(crap, skipPrevCheck) {
if( lastKeyPressCode == KEY.DEL ) {
select.hide();
return;
}
var currentValue = $input.val();
if ( !skipPrevCheck && currentValue == previousValue )
return;
previousValue = currentValue;
currentValue = lastWord(currentValue);
if ( currentValue.length >= options.minChars) {
$input.addClass(options.loadingClass);
if (!options.matchCase)
currentValue = currentValue.toLowerCase();
request(currentValue, receiveData, hideResultsNow);
} else {
stopLoading();
select.hide();
}
};
function trimWords(value) {
if (!value)
return [""];
if (!options.multiple)
return [$.trim(value)];
return $.map(value.split(options.multipleSeparator), function(word) {
return $.trim(value).length ? $.trim(word) : null;
});
}
function lastWord(value) {
if ( !options.multiple )
return value;
var words = trimWords(value);
if (words.length == 1)
return words[0];
var cursorAt = $(input).selection().start;
if (cursorAt == value.length) {
words = trimWords(value)
} else {
words = trimWords(value.replace(value.substring(cursorAt), ""));
}
return words[words.length - 1];
}
// fills in the input box w/the first match (assumed to be the best match)
// q: the term entered
// sValue: the first matching result
function autoFill(q, sValue){
// autofill in the complete box w/the first match as long as the user hasn't entered in more data
// if the last user key pressed was backspace, don't autofill
if( options.autoFill && (lastWord($input.val()).toLowerCase() == q.toLowerCase()) && lastKeyPressCode != KEY.BACKSPACE ) {
// fill in the value (keep the case the user has typed)
$input.val($input.val() + sValue.substring(lastWord(previousValue).length));
// select the portion of the value not typed by the user (so the next character will erase)
$(input).selection(previousValue.length, previousValue.length + sValue.length);
}
};
function hideResults() {
clearTimeout(timeout);
timeout = setTimeout(hideResultsNow, 200);
};
function hideResultsNow() {
var wasVisible = select.visible();
select.hide();
clearTimeout(timeout);
stopLoading();
if (options.mustMatch) {
// call search and run callback
$input.search(
function (result){
// if no value found, clear the input box
if( !result ) {
if (options.multiple) {
var words = trimWords($input.val()).slice(0, -1);
$input.val( words.join(options.multipleSeparator) + (words.length ? options.multipleSeparator : "") );
}
else {
$input.val( "" );
$input.trigger("result", null);
}
}
}
);
}
};
function receiveData(q, data) {
if ( data && data.length && hasFocus ) {
stopLoading();
select.display(data, q);
autoFill(q, data[0].value);
select.show();
} else {
hideResultsNow();
}
};
function request(term, success, failure) {
if (!options.matchCase)
term = term.toLowerCase();
var data = cache.load(term);
// recieve the cached data
if (data && data.length) {
success(term, data);
// if an AJAX url has been supplied, try loading the data now
} else if( (typeof options.url == "string") && (options.url.length > 0) ){
var extraParams = {
timestamp: +new Date()
};
$.each(options.extraParams, function(key, param) {
extraParams[key] = typeof param == "function" ? param() : param;
});
$.ajax({
// try to leverage ajaxQueue plugin to abort previous requests
mode: "abort",
// limit abortion to this input
port: "autocomplete" + input.name,
dataType: options.dataType,
url: options.url,
data: $.extend({
q: lastWord(term),
limit: options.max
}, extraParams),
success: function(data) {
var parsed = options.parse && options.parse(data) || parse(data);
cache.add(term, parsed);
success(term, parsed);
}
});
} else {
// if we have a failure, we need to empty the list -- this prevents the the [TAB] key from selecting the last successful match
select.emptyList();
failure(term);
}
};
function parse(data) {
var parsed = [];
var rows = data.split("\n");
for (var i=0; i < rows.length; i++) {
var row = $.trim(rows[i]);
if (row) {
row = row.split("|");
parsed[parsed.length] = {
data: row,
value: row[0],
result: options.formatResult && options.formatResult(row, row[0]) || row[0]
};
}
}
return parsed;
};
function stopLoading() {
$input.removeClass(options.loadingClass);
};
};
$.Autocompleter.defaults = {
inputClass: "ac_input",
resultsClass: "ac_results",
loadingClass: "ac_loading",
minChars: 1,
delay: 400,
matchCase: false,
matchSubset: true,
matchContains: false,
cacheLength: 10,
max: 100,
mustMatch: false,
extraParams: {},
selectFirst: true,
formatItem: function(row) { return row[0]; },
formatMatch: null,
autoFill: false,
width: 0,
multiple: false,
multipleSeparator: ", ",
highlight: function(value, term) {
return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
},
scroll: true,
scrollHeight: 180
};
$.Autocompleter.Cache = function(options) {
var data = {};
var length = 0;
function matchSubset(s, sub) {
if (!options.matchCase)
s = s.toLowerCase();
var i = s.indexOf(sub);
if (options.matchContains == "word"){
i = s.toLowerCase().search("\\b" + sub.toLowerCase());
}
if (i == -1) return false;
return i == 0 || options.matchContains;
};
function add(q, value) {
if (length > options.cacheLength){
flush();
}
if (!data[q]){
length++;
}
data[q] = value;
}
function populate(){
if( !options.data ) return false;
// track the matches
var stMatchSets = {},
nullData = 0;
// no url was specified, we need to adjust the cache length to make sure it fits the local data store
if( !options.url ) options.cacheLength = 1;
// track all options for minChars = 0
stMatchSets[""] = [];
// loop through the array and create a lookup structure
for ( var i = 0, ol = options.data.length; i < ol; i++ ) {
var rawValue = options.data[i];
// if rawValue is a string, make an array otherwise just reference the array
rawValue = (typeof rawValue == "string") ? [rawValue] : rawValue;
var value = options.formatMatch(rawValue, i+1, options.data.length);
if ( value === false )
continue;
var firstChar = value.charAt(0).toLowerCase();
// if no lookup array for this character exists, look it up now
if( !stMatchSets[firstChar] )
stMatchSets[firstChar] = [];
// if the match is a string
var row = {
value: value,
data: rawValue,
result: options.formatResult && options.formatResult(rawValue) || value
};
// push the current match into the set list
stMatchSets[firstChar].push(row);
// keep track of minChars zero items
if ( nullData++ < options.max ) {
stMatchSets[""].push(row);
}
};
// add the data items to the cache
$.each(stMatchSets, function(i, value) {
// increase the cache size
options.cacheLength++;
// add to the cache
add(i, value);
});
}
// populate any existing data
setTimeout(populate, 25);
function flush(){
data = {};
length = 0;
}
return {
flush: flush,
add: add,
populate: populate,
load: function(q) {
if (!options.cacheLength || !length)
return null;
/*
* if dealing w/local data and matchContains than we must make sure
* to loop through all the data collections looking for matches
*/
if( !options.url && options.matchContains ){
// track all matches
var csub = [];
// loop through all the data grids for matches
for( var k in data ){
// don't search through the stMatchSets[""] (minChars: 0) cache
// this prevents duplicates
if( k.length > 0 ){
var c = data[k];
$.each(c, function(i, x) {
// if we've got a match, add it to the array
if (matchSubset(x.value, q)) {
csub.push(x);
}
});
}
}
return csub;
} else
// if the exact item exists, use it
if (data[q]){
return data[q];
} else
if (options.matchSubset) {
for (var i = q.length - 1; i >= options.minChars; i--) {
var c = data[q.substr(0, i)];
if (c) {
var csub = [];
$.each(c, function(i, x) {
if (matchSubset(x.value, q)) {
csub[csub.length] = x;
}
});
return csub;
}
}
}
return null;
}
};
};
$.Autocompleter.Select = function (options, input, select, config) {
var CLASSES = {
ACTIVE: "ac_over"
};
var listItems,
active = -1,
data,
term = "",
needsInit = true,
element,
list;
// Create results
function init() {
if (!needsInit)
return;
element = $("<div/>")
.hide()
.addClass(options.resultsClass)
.css("position", "absolute")
.appendTo(document.body);
list = $("<ul/>").appendTo(element).mouseover( function(event) {
if(target(event).nodeName && target(event).nodeName.toUpperCase() == 'LI') {
active = $("li", list).removeClass(CLASSES.ACTIVE).index(target(event));
$(target(event)).addClass(CLASSES.ACTIVE);
}
}).click(function(event) {
$(target(event)).addClass(CLASSES.ACTIVE);
select();
// TODO provide option to avoid setting focus again after selection? useful for cleanup-on-focus
input.focus();
return false;
}).mousedown(function() {
config.mouseDownOnSelect = true;
}).mouseup(function() {
config.mouseDownOnSelect = false;
});
if( options.width > 0 )
element.css("width", options.width);
needsInit = false;
}
function target(event) {
var element = event.target;
while(element && element.tagName != "LI")
element = element.parentNode;
// more fun with IE, sometimes event.target is empty, just ignore it then
if(!element)
return [];
return element;
}
function moveSelect(step) {
listItems.slice(active, active + 1).removeClass(CLASSES.ACTIVE);
movePosition(step);
var activeItem = listItems.slice(active, active + 1).addClass(CLASSES.ACTIVE);
if(options.scroll) {
var offset = 0;
listItems.slice(0, active).each(function() {
offset += this.offsetHeight;
});
if((offset + activeItem[0].offsetHeight - list.scrollTop()) > list[0].clientHeight) {
list.scrollTop(offset + activeItem[0].offsetHeight - list.innerHeight());
} else if(offset < list.scrollTop()) {
list.scrollTop(offset);
}
}
};
function movePosition(step) {
active += step;
if (active < 0) {
active = listItems.size() - 1;
} else if (active >= listItems.size()) {
active = 0;
}
}
function limitNumberOfItems(available) {
return options.max && options.max < available
? options.max
: available;
}
function fillList() {
list.empty();
var max = limitNumberOfItems(data.length);
for (var i=0; i < max; i++) {
if (!data[i])
continue;
var formatted = options.formatItem(data[i].data, i+1, max, data[i].value, term);
if ( formatted === false )
continue;
var li = $("<li/>").html( options.highlight(formatted, term) ).addClass(i%2 == 0 ? "ac_even" : "ac_odd").appendTo(list)[0];
$.data(li, "ac_data", data[i]);
}
listItems = list.find("li");
if ( options.selectFirst ) {
listItems.slice(0, 1).addClass(CLASSES.ACTIVE);
active = 0;
}
// apply bgiframe if available
if ( $.fn.bgiframe )
list.bgiframe();
}
return {
display: function(d, q) {
init();
data = d;
term = q;
fillList();
},
next: function() {
moveSelect(1);
},
prev: function() {
moveSelect(-1);
},
pageUp: function() {
if (active != 0 && active - 8 < 0) {
moveSelect( -active );
} else {
moveSelect(-8);
}
},
pageDown: function() {
if (active != listItems.size() - 1 && active + 8 > listItems.size()) {
moveSelect( listItems.size() - 1 - active );
} else {
moveSelect(8);
}
},
hide: function() {
element && element.hide();
listItems && listItems.removeClass(CLASSES.ACTIVE);
active = -1;
},
visible : function() {
return element && element.is(":visible");
},
current: function() {
return this.visible() && (listItems.filter("." + CLASSES.ACTIVE)[0] || options.selectFirst && listItems[0]);
},
show: function() {
var offset = $(input).offset();
element.css({
width: typeof options.width == "string" || options.width > 0 ? options.width : $(input).width(),
top: offset.top + input.offsetHeight,
left: offset.left
}).show();
if(options.scroll) {
list.scrollTop(0);
list.css({
maxHeight: options.scrollHeight,
overflow: 'auto'
});
if($.browser.msie && typeof document.body.style.maxHeight === "undefined") {
var listHeight = 0;
listItems.each(function() {
listHeight += this.offsetHeight;
});
var scrollbarsVisible = listHeight > options.scrollHeight;
list.css('height', scrollbarsVisible ? options.scrollHeight : listHeight );
if (!scrollbarsVisible) {
// IE doesn't recalculate width when scrollbar disappears
listItems.width( list.width() - parseInt(listItems.css("padding-left")) - parseInt(listItems.css("padding-right")) );
}
}
}
},
selected: function() {
var selected = listItems && listItems.filter("." + CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);
return selected && selected.length && $.data(selected[0], "ac_data");
},
emptyList: function (){
list && list.empty();
},
unbind: function() {
element && element.remove();
}
};
};
$.fn.selection = function(start, end) {
if (start !== undefined) {
return this.each(function() {
if( this.createTextRange ){
var selRange = this.createTextRange();
if (end === undefined || start == end) {
selRange.move("character", start);
selRange.select();
} else {
selRange.collapse(true);
selRange.moveStart("character", start);
selRange.moveEnd("character", end);
selRange.select();
}
} else if( this.setSelectionRange ){
this.setSelectionRange(start, end);
} else if( this.selectionStart ){
this.selectionStart = start;
this.selectionEnd = end;
}
});
}
var field = this[0];
if ( field.createTextRange ) {
var range = document.selection.createRange(),
orig = field.value,
teststring = "<->",
textLength = range.text.length;
range.text = teststring;
var caretAt = field.value.indexOf(teststring);
field.value = orig;
this.selection(caretAt, caretAt + textLength);
return {
start: caretAt,
end: caretAt + textLength
}
} else if( field.selectionStart !== undefined ){
return {
start: field.selectionStart,
end: field.selectionEnd
}
}
};
})(jQuery);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,147 @@
/**
* WordPress Administration Custom Navigation
* Interface JQuery functions
*
* @author Jeffikus <pearce.jp@gmail.com>
* @version 1.1.0
*
* @package WordPress
* @subpackage Administration
*/
/*
* Init Functions
*/
$(function()
{
//Makes dialog box
$("#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');
}
}
});
$('#message').animate({ opacity: 1.0 },2000).fadeOut(300, function(){ $(this).remove();});
//Add dropzone
$('#custom-nav li').prepend('<div class="dropzone"></div>');
//Make li items draggable
$('#custom-nav li').draggable({
handle: ' > dl',
opacity: .8,
addClasses: false,
helper: 'clone',
zIndex: 100
});
//Make items droppable
$('#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');
//Add UL to first child
if (child && li.children('ul').length == 0)
{
li.append('<ul id="sub-menu" />');
}
//Make it draggable
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()
{
//Add child
if ($(this).attr('class') == 'dropzone ui-droppable')
{
$(this).parent().find("div:first").css('background', 'none').css('height', '50px');
}
//Add above
else if ($(this).attr('class') == 'ui-droppable')
{
$(this).parent().find("dt:first").css('background', '#d8d8d8');
}
//do nothing
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()
{
}
});
//Handle Save Button Clicks
$('#save_top').click(function()
{
updatepostdata();
});
$('#save_bottom').click(function()
{
updatepostdata();
});
});

View File

@ -0,0 +1 @@
$(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")}}});$("#message").animate({opacity:1},2000).fadeOut(300,function(){$(this).remove()});$("#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(f,d){var a=$(this).parent();var g=!$(this).hasClass("dropzone");if(g&&a.children("ul").length==0){a.append('<ul id="sub-menu" />')}if(g){a.children("ul").append(d.draggable)}else{a.before(d.draggable)}a.find("dl,.dropzone").css({backgroundColor:"",borderColor:""});var c=d.draggable.attr("value");var b=a.attr("value");a.find("#menu-"+c).find("#parent"+c).val(b);$(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 a=$(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()})});

View File

@ -0,0 +1,289 @@
/**
* WordPress Administration Custom Navigation
* Interface JS functions
*
* @author Jeffikus <pearce.jp@gmail.com>
* @version 1.1.0
*
* @package WordPress
* @subpackage Administration
*/
/*
* Removes menu items from current menu
* @param int o - the id of the menu li to remove.
*/
function removeitem(o)
{
var todelete = document.getElementById('menu-' + o);
if (todelete)
{
var parenttodelete = document.getElementById('menu-' + o).parentNode;
throwaway_node = parenttodelete.removeChild(todelete);
}
updatepostdata();
};
/*
* Loads dialog window to edit menu items from current menu
* @param int o - the id of the menu li to edit.
*/
function edititem(o)
{
itemTitle = $('#title' + o).attr('value');
itemURL = $('#linkurl' + o).attr('value');
itemAnchorTitle = $('#anchortitle' + o).attr('value');
itemNewWindow = $('#newwindow' + o).attr('value');
itemDesc = $('#description' + o).attr('value');
$('#dialog-confirm').dialog( 'option' , 'itemID' , o )
$('#dialog-confirm').dialog('open');
$('#edittitle').attr('value', itemTitle);
$('#editlink').attr('value', itemURL);
$('#editanchortitle').attr('value', itemAnchorTitle);
$("#editnewwindow option[value='" + itemNewWindow + "']").attr('selected', 'selected');
$('#editdescription').attr('value', itemDesc);
};
/*
* Prepares menu items for POST
*/
function updatepostdata()
{
var i = 0;
$("#custom-nav").find("li").each(function(i) {
i = i + 1;
var j = $(this).attr('value');
$(this).find('#position' + j).attr('value', i);
$(this).attr('id','menu-' + i);
$(this).attr('value', i);
$(this).find('#dbid' + j).attr('name','dbid' + i);
$(this).find('#dbid' + j).attr('id','dbid' + i);
$(this).find('#postmenu' + j).attr('name','postmenu' + i);
$(this).find('#postmenu' + j).attr('id','postmenu' + i);
var p = $(this).find('#parent' + j).parent().parent().parent().attr('value');
$(this).find('#parent' + j).attr('name','parent' + i);
$(this).find('#parent' + j).attr('id','parent' + i);
if (p) {
//Do nothing
}
else {
//reset p to be top level
p = 0;
}
$(this).find('#parent' + j).attr('value', p);
$(this).find('#title' + j).attr('name','title' + i);
$(this).find('#title' + j).attr('id','title' + i);
$(this).find('#linkurl' + j).attr('name','linkurl' + i);
$(this).find('#linkurl' + j).attr('id','linkurl' + i);
$(this).find('#description' + j).attr('name','description' + i);
$(this).find('#description' + j).attr('id','description' + i);
$(this).find('#icon' + j).attr('name','icon' + i);
$(this).find('#icon' + j).attr('id','icon' + i);
$(this).find('#position' + j).attr('name','position' + i);
$(this).find('#position' + j).attr('id','position' + i);
$(this).find('#linktype' + j).attr('name','linktype' + i);
$(this).find('#linktype' + j).attr('id','linktype' + i);
$(this).find('#anchortitle' + j).attr('name','anchortitle' + i);
$(this).find('#anchortitle' + j).attr('id','anchortitle' + i);
$(this).find('#newwindow' + j).attr('name','newwindow' + i);
$(this).find('#newwindow' + j).attr('id','newwindow' + i);
$(this).find('dl > dt > span > #remove' + j).attr('value', i);
$(this).find('dl > dt > span > #remove' + j).attr('onClick', 'removeitem(' + i + ')');
$(this).find('dl > dt > span > #remove' + j).attr('id','remove' + i);
$('#licount').attr('value',i);
});
};
/*
* Adds item from Page, Category, or Custom options menu
* @param string templatedir - directory of the add, edit, view images.
* @param string additemtype - Page, Category, or Custom.
* @param string itemtext - menu text.
* @param string itemurl - url of the menu.
* @param int itemid - menu id.
* @param int itemparentid - default 0.
* @param string itemdescription - the description of the menu item.
*/
function appendToList(templatedir,additemtype,itemtext,itemurl,itemid,itemparentid,itemdescription)
{
var inputvaluevarname = '';
var inputvaluevarurl = '';
var inputitemid = '';
var inputparentid= '';
var inputdescription = '';
var inputicon = '';
if (additemtype == 'Custom')
{
inputvaluevarname = document.getElementById('custom_menu_item_name').value;
inputvaluevarurl = document.getElementById('custom_menu_item_url').value;
inputitemid = '';
inputparentid = '';
inputlinktype = 'custom';
inputdescription = document.getElementById('custom_menu_item_description').value;
}
else if (additemtype == 'Page')
{
inputvaluevarname = htmlentities(itemtext.toString());
inputvaluevarurl = itemurl.toString();
inputitemid = itemid.toString();
inputparentid = '0';
inputlinktype = 'page';
inputdescription = htmlentities(itemdescription.toString());
}
else if (additemtype == 'Category')
{
inputvaluevarname = htmlentities(itemtext.toString());
inputvaluevarurl = itemurl.toString();
inputitemid = itemid.toString();
inputparentid = '0';
inputlinktype = 'category';
inputdescription = htmlentities(itemdescription.toString());
}
else
{
inputvaluevarname = '';
inputvaluevarname = '';
inputitemid = '';
inputparentid = '';
inputlinktype = 'custom';
inputdescription = '';
}
var count=document.getElementById('custom-nav').getElementsByTagName('li').length;
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;
}
}
//Notification Message
$('.maintitle').after('<div id="message" class="updated fade below-h2"><p>Menu Item added!</p></div>');
$('#message').animate({ opacity: 1.0 },2000).fadeOut(300, function(){ $(this).remove();});
//Appends HTML to the menu
$('#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>');
//make menu item draggable
$('#menu-' + randomnumber + '').draggable(
{
handle: ' > dl',
opacity: .8,
addClasses: false,
helper: 'clone',
zIndex: 100
});
//make menu item droppable
$('#menu-' + randomnumber + ' dl, #menu-' + randomnumber + ' .dropzone').droppable({
accept: '#' + randomnumber + ', #custom-nav li',
tolerance: 'pointer',
drop: function(e, ui)
{
var li = $(this).parent();
var child = !$(this).hasClass('dropzone');
//Append UL to first child
if (child && li.children('ul').length == 0)
{
li.append('<ul/>');
}
//Make it draggable
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()
{
//Add child
if ($(this).attr('class') == 'dropzone ui-droppable')
{
$(this).parent().find("div:first").css('background', 'none').css('height', '50px');
}
//Add above
else if ($(this).attr('class') == 'ui-droppable')
{
$(this).parent().find("dt:first").css('background', '#d8d8d8');
}
//do nothing
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: '' });
}
});
updatepostdata();
};

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,300 @@
/*
* More info at: http://phpjs.org
*
* This is version: 3.08
* php.js is copyright 2010 Kevin van Zonneveld.
*
* Portions copyright Brett Zamir (http://brett-zamir.me), Kevin van Zonneveld
* (http://kevin.vanzonneveld.net), Onno Marsman, Theriault, Michael White
* (http://getsprink.com), Waldo Malqui Silva, Paulo Ricardo F. Santos, Jack,
* Jonas Raoni Soares Silva (http://www.jsfromhell.com), Philip Peterson, Ates
* Goral (http://magnetiq.com), Legaev Andrey, Alex, Ratheous, Martijn
* Wieringa, Nate, lmeyrick (https://sourceforge.net/projects/bcmath-js/),
* Enrique Gonzalez, Philippe Baumann, Webtoolkit.info
* (http://www.webtoolkit.info/), travc, Carlos R. L. Rodrigues
* (http://www.jsfromhell.com), Jani Hartikainen, Ash Searle
* (http://hexmen.com/blog/), Ole Vrijenhoek, stag019, d3x, Erkekjetter,
* GeekFG (http://geekfg.blogspot.com), T.Wild, Johnny Mast
* (http://www.phpvrouwen.nl), Michael Grier,
* http://stackoverflow.com/questions/57803/how-to-convert-decimal-to-hex-in-javascript,
* pilus, marrtins, Andrea Giammarchi (http://webreflection.blogspot.com),
* WebDevHobo (http://webdevhobo.blogspot.com/), Caio Ariede
* (http://caioariede.com), Thunder.m, Aman Gupta, Martin
* (http://www.erlenwiese.de/), Tyler Akins (http://rumkin.com), Lars Fischer,
* Paul Smith, Alfonso Jimenez (http://www.alfonsojimenez.com), Michael White,
* mdsjack (http://www.mdsjack.bo.it), Pellentesque Malesuada, gettimeofday,
* David, Joris, saulius, Robin, Steven Levithan
* (http://blog.stevenlevithan.com), Public Domain
* (http://www.json.org/json2.js), Kankrelune (http://www.webfaktory.info/),
* Tim de Koning (http://www.kingsquare.nl), Arpad Ray (mailto:arpad@php.net),
* AJ, KELAN, Sakimori, Mailfaker (http://www.weedem.fr/), Oleg Eremeev, Marc
* Palau, Josh Fraser
* (http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/),
* Karol Kowalski, Chris, Breaking Par Consulting Inc
* (http://www.breakingpar.com/bkp/home.nsf/0/87256B280015193F87256CFB006C45F7),
* Mirek Slugen, majak, Felix Geisendoerfer (http://www.debuggable.com/felix),
* gorthaur, Steve Hilder, LH, Stoyan Kyosev (http://www.svest.org/), Der
* Simon (http://innerdom.sourceforge.net/), HKM, echo is bad, nord_ua, Ozh,
* metjay, XoraX (http://www.xorax.info), Eugene Bulkin
* (http://doubleaw.com/), JB, strcasecmp, strcmp, Taras Bogach, Francesco,
* Marco, noname, class_exists, madipta, Alan C, mktime, Douglas Crockford
* (http://javascript.crockford.com), uestla, Frank Forte, David James, Steve
* Clay, J A R, jpfle, Marc Jansen, Paul, Hyam Singer
* (http://www.impact-computing.com/), T. Wild, Ole Vrijenhoek
* (http://www.nervous.nl/), Raphael (Ao RUDLER), kenneth, Brad Touesnard,
* ChaosNo1, Subhasis Deb, Norman "zEh" Fuchs, 0m3r, Sanjoy Roy, Rob, Gilbert,
* Bayron Guevara, paulo kuong, Orlando, duncan, sankai, hitwork, Philippe
* Jausions (http://pear.php.net/user/jausions), Aidan Lister
* (http://aidanlister.com/), ejsanders, Nick Callen, Brian Tafoya
* (http://www.premasolutions.com/), johnrembo, sowberry, Yves Sucaet, Denny
* Wardhana, Ulrich, kilops, dptr1988, john (http://www.jd-tech.net), MeEtc
* (http://yass.meetcweb.com), Peter-Paul Koch
* (http://www.quirksmode.org/js/beat.html), T0bsn, Tim Wiel, Bryan Elliott,
* Alexander Ermolaev (http://snippets.dzone.com/user/AlexanderErmolaev), JT,
* Thomas Beaucourt (http://www.webapp.fr), David Randall, DxGx, Soren Hansen,
* lmeyrick (https://sourceforge.net/projects/bcmath-js/this.), Le Torbi,
* djmix, Lincoln Ramsay, Linuxworld, Thiago Mata
* (http://thiagomata.blog.com), Pedro Tainha (http://www.pedrotainha.com),
* James, Pyerre, Jon Hohle, felix, ger, Russell Walker
* (http://www.nbill.co.uk/), Garagoth, Andrej Pavlovic, Dino, Jamie Beck
* (http://www.terabit.ca/), DtTvB
* (http://dt.in.th/2008-09-16.string-length-in-bytes.html), setcookie, YUI
* Library: http://developer.yahoo.com/yui/docs/YAHOO.util.DateLocale.html,
* Blues at http://hacks.bluesmoon.info/strftime/strftime.js, Andreas, rem,
* meo, Jay Klehr, Kheang Hok Chin (http://www.distantia.ca/), Luke Smith
* (http://lucassmith.name), Rival, Amir Habibi
* (http://www.residence-mixte.com/), Cagri Ekin, Greenseed, mk.keck, Leslie
* Hoare, booeyOH, Ben Bryan, Michael, Christian Doebler, Kirk Strobeck, Brant
* Messenger (http://www.brantmessenger.com/), Rick Waldron, Mick@el, Martin
* Pool, Pierre-Luc Paour, Daniel Esteban, Christoph, Saulo Vallory, Kristof
* Coomans (SCK-CEN Belgian Nucleair Research Centre), rezna, Tomasz
* Wesolowski, Gabriel Paderni, Marco van Oort, Philipp Lenssen,
* penutbutterjelly, Simon Willison (http://simonwillison.net), Anton Ongson,
* Eric Nagel, Bobby Drake, Pul, Blues (http://tech.bluesmoon.info/), Luke
* Godfrey, Diogo Resende, Howard Yeend, vlado houba, Jalal Berrami, Itsacon
* (http://www.itsacon.net/), date, Billy, stensi, Cord, fearphage
* (http://http/my.opera.com/fearphage/), Victor, Matteo, Artur Tchernychev,
* Francois, nobbler, Fox, marc andreu, Nick Kolosov (http://sammy.ru),
* Nathan, Arno, Scott Cariss, Slawomir Kaniecki, ReverseSyntax, Jason Wong
* (http://carrot.org/), Mateusz "loonquawl" Zalega, Manish, Wagner B. Soares,
* 3D-GRAF, jakes, Yannoo, gabriel paderni, daniel airton wermann
* (http://wermann.com.br), Atli ?—r, Allan Jensen
* (http://www.winternet.no), Benjamin Lupton, davook, Maximusya, FGFEmperor,
* baris ozdil, Luis Salazar (http://www.freaky-media.com/), Tim de Koning,
* taith, Matt Bradley, FremyCompany, T.J. Leahy, Greg Frazier, Valentina De
* Rosa, Tod Gentille, Riddler (http://www.frontierwebdev.com/), Alexander M
* Beedie
*
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL KEVIN VAN ZONNEVELD BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
function get_html_translation_table (table, quote_style) {
// http://kevin.vanzonneveld.net
// + original by: Philip Peterson
// + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + bugfixed by: noname
// + bugfixed by: Alex
// + bugfixed by: Marco
// + bugfixed by: madipta
// + improved by: KELAN
// + improved by: Brett Zamir (http://brett-zamir.me)
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
// + input by: Frank Forte
// + bugfixed by: T.Wild
// + input by: Ratheous
// % note: It has been decided that we're not going to add global
// % note: dependencies to php.js, meaning the constants are not
// % note: real constants, but strings instead. Integers are also supported if someone
// % note: chooses to create the constants themselves.
// * example 1: get_html_translation_table('HTML_SPECIALCHARS');
// * returns 1: {'"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;'}
var entities = {}, hash_map = {}, decimal = 0, symbol = '';
var constMappingTable = {}, constMappingQuoteStyle = {};
var useTable = {}, useQuoteStyle = {};
// Translate arguments
constMappingTable[0] = 'HTML_SPECIALCHARS';
constMappingTable[1] = 'HTML_ENTITIES';
constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
constMappingQuoteStyle[2] = 'ENT_COMPAT';
constMappingQuoteStyle[3] = 'ENT_QUOTES';
useTable = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS';
useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT';
if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') {
throw new Error("Table: "+useTable+' not supported');
// return false;
}
entities['38'] = '&amp;';
if (useTable === 'HTML_ENTITIES') {
entities['160'] = '&nbsp;';
entities['161'] = '&iexcl;';
entities['162'] = '&cent;';
entities['163'] = '&pound;';
entities['164'] = '&curren;';
entities['165'] = '&yen;';
entities['166'] = '&brvbar;';
entities['167'] = '&sect;';
entities['168'] = '&uml;';
entities['169'] = '&copy;';
entities['170'] = '&ordf;';
entities['171'] = '&laquo;';
entities['172'] = '&not;';
entities['173'] = '&shy;';
entities['174'] = '&reg;';
entities['175'] = '&macr;';
entities['176'] = '&deg;';
entities['177'] = '&plusmn;';
entities['178'] = '&sup2;';
entities['179'] = '&sup3;';
entities['180'] = '&acute;';
entities['181'] = '&micro;';
entities['182'] = '&para;';
entities['183'] = '&middot;';
entities['184'] = '&cedil;';
entities['185'] = '&sup1;';
entities['186'] = '&ordm;';
entities['187'] = '&raquo;';
entities['188'] = '&frac14;';
entities['189'] = '&frac12;';
entities['190'] = '&frac34;';
entities['191'] = '&iquest;';
entities['192'] = '&Agrave;';
entities['193'] = '&Aacute;';
entities['194'] = '&Acirc;';
entities['195'] = '&Atilde;';
entities['196'] = '&Auml;';
entities['197'] = '&Aring;';
entities['198'] = '&AElig;';
entities['199'] = '&Ccedil;';
entities['200'] = '&Egrave;';
entities['201'] = '&Eacute;';
entities['202'] = '&Ecirc;';
entities['203'] = '&Euml;';
entities['204'] = '&Igrave;';
entities['205'] = '&Iacute;';
entities['206'] = '&Icirc;';
entities['207'] = '&Iuml;';
entities['208'] = '&ETH;';
entities['209'] = '&Ntilde;';
entities['210'] = '&Ograve;';
entities['211'] = '&Oacute;';
entities['212'] = '&Ocirc;';
entities['213'] = '&Otilde;';
entities['214'] = '&Ouml;';
entities['215'] = '&times;';
entities['216'] = '&Oslash;';
entities['217'] = '&Ugrave;';
entities['218'] = '&Uacute;';
entities['219'] = '&Ucirc;';
entities['220'] = '&Uuml;';
entities['221'] = '&Yacute;';
entities['222'] = '&THORN;';
entities['223'] = '&szlig;';
entities['224'] = '&agrave;';
entities['225'] = '&aacute;';
entities['226'] = '&acirc;';
entities['227'] = '&atilde;';
entities['228'] = '&auml;';
entities['229'] = '&aring;';
entities['230'] = '&aelig;';
entities['231'] = '&ccedil;';
entities['232'] = '&egrave;';
entities['233'] = '&eacute;';
entities['234'] = '&ecirc;';
entities['235'] = '&euml;';
entities['236'] = '&igrave;';
entities['237'] = '&iacute;';
entities['238'] = '&icirc;';
entities['239'] = '&iuml;';
entities['240'] = '&eth;';
entities['241'] = '&ntilde;';
entities['242'] = '&ograve;';
entities['243'] = '&oacute;';
entities['244'] = '&ocirc;';
entities['245'] = '&otilde;';
entities['246'] = '&ouml;';
entities['247'] = '&divide;';
entities['248'] = '&oslash;';
entities['249'] = '&ugrave;';
entities['250'] = '&uacute;';
entities['251'] = '&ucirc;';
entities['252'] = '&uuml;';
entities['253'] = '&yacute;';
entities['254'] = '&thorn;';
entities['255'] = '&yuml;';
}
if (useQuoteStyle !== 'ENT_NOQUOTES') {
entities['34'] = '&quot;';
}
if (useQuoteStyle === 'ENT_QUOTES') {
entities['39'] = '&#39;';
}
entities['60'] = '&lt;';
entities['62'] = '&gt;';
// ascii decimals to real symbols
for (decimal in entities) {
symbol = String.fromCharCode(decimal);
hash_map[symbol] = entities[decimal];
}
return hash_map;
}
function htmlentities (string, quote_style) {
// http://kevin.vanzonneveld.net
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + improved by: nobbler
// + tweaked by: Jack
// + bugfixed by: Onno Marsman
// + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
// + input by: Ratheous
// - depends on: get_html_translation_table
// * example 1: htmlentities('Kevin & van Zonneveld');
// * returns 1: 'Kevin &amp; van Zonneveld'
// * example 2: htmlentities("foo'bar","ENT_QUOTES");
// * returns 2: 'foo&#039;bar'
var hash_map = {}, symbol = '', tmp_str = '', entity = '';
tmp_str = string.toString();
if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {
return false;
}
hash_map["'"] = '&#039;';
for (symbol in hash_map) {
entity = hash_map[symbol];
tmp_str = tmp_str.split(symbol).join(entity);
}
return tmp_str;
}

View File

@ -0,0 +1 @@
function get_html_translation_table(i,g){var d={},f={},c=0,a="";var e={},b={};var j={},h={};e[0]="HTML_SPECIALCHARS";e[1]="HTML_ENTITIES";b[0]="ENT_NOQUOTES";b[2]="ENT_COMPAT";b[3]="ENT_QUOTES";j=!isNaN(i)?e[i]:i?i.toUpperCase():"HTML_SPECIALCHARS";h=!isNaN(g)?b[g]:g?g.toUpperCase():"ENT_COMPAT";if(j!=="HTML_SPECIALCHARS"&&j!=="HTML_ENTITIES"){throw new Error("Table: "+j+" not supported")}d["38"]="&amp;";if(j==="HTML_ENTITIES"){d["160"]="&nbsp;";d["161"]="&iexcl;";d["162"]="&cent;";d["163"]="&pound;";d["164"]="&curren;";d["165"]="&yen;";d["166"]="&brvbar;";d["167"]="&sect;";d["168"]="&uml;";d["169"]="&copy;";d["170"]="&ordf;";d["171"]="&laquo;";d["172"]="&not;";d["173"]="&shy;";d["174"]="&reg;";d["175"]="&macr;";d["176"]="&deg;";d["177"]="&plusmn;";d["178"]="&sup2;";d["179"]="&sup3;";d["180"]="&acute;";d["181"]="&micro;";d["182"]="&para;";d["183"]="&middot;";d["184"]="&cedil;";d["185"]="&sup1;";d["186"]="&ordm;";d["187"]="&raquo;";d["188"]="&frac14;";d["189"]="&frac12;";d["190"]="&frac34;";d["191"]="&iquest;";d["192"]="&Agrave;";d["193"]="&Aacute;";d["194"]="&Acirc;";d["195"]="&Atilde;";d["196"]="&Auml;";d["197"]="&Aring;";d["198"]="&AElig;";d["199"]="&Ccedil;";d["200"]="&Egrave;";d["201"]="&Eacute;";d["202"]="&Ecirc;";d["203"]="&Euml;";d["204"]="&Igrave;";d["205"]="&Iacute;";d["206"]="&Icirc;";d["207"]="&Iuml;";d["208"]="&ETH;";d["209"]="&Ntilde;";d["210"]="&Ograve;";d["211"]="&Oacute;";d["212"]="&Ocirc;";d["213"]="&Otilde;";d["214"]="&Ouml;";d["215"]="&times;";d["216"]="&Oslash;";d["217"]="&Ugrave;";d["218"]="&Uacute;";d["219"]="&Ucirc;";d["220"]="&Uuml;";d["221"]="&Yacute;";d["222"]="&THORN;";d["223"]="&szlig;";d["224"]="&agrave;";d["225"]="&aacute;";d["226"]="&acirc;";d["227"]="&atilde;";d["228"]="&auml;";d["229"]="&aring;";d["230"]="&aelig;";d["231"]="&ccedil;";d["232"]="&egrave;";d["233"]="&eacute;";d["234"]="&ecirc;";d["235"]="&euml;";d["236"]="&igrave;";d["237"]="&iacute;";d["238"]="&icirc;";d["239"]="&iuml;";d["240"]="&eth;";d["241"]="&ntilde;";d["242"]="&ograve;";d["243"]="&oacute;";d["244"]="&ocirc;";d["245"]="&otilde;";d["246"]="&ouml;";d["247"]="&divide;";d["248"]="&oslash;";d["249"]="&ugrave;";d["250"]="&uacute;";d["251"]="&ucirc;";d["252"]="&uuml;";d["253"]="&yacute;";d["254"]="&thorn;";d["255"]="&yuml;"}if(h!=="ENT_NOQUOTES"){d["34"]="&quot;"}if(h==="ENT_QUOTES"){d["39"]="&#39;"}d["60"]="&lt;";d["62"]="&gt;";for(c in d){a=String.fromCharCode(c);f[a]=d[c]}return f}function htmlentities(c,f){var e={},d="",a="",b="";a=c.toString();if(false===(e=this.get_html_translation_table("HTML_ENTITIES",f))){return false}e["'"]="&#039;";for(d in e){b=e[d];a=a.split(d).join(b)}return a};

View File

@ -108,6 +108,7 @@ $menu[60] = array( __('Appearance'), 'switch_themes', 'themes.php', '', 'menu-to
$submenu['themes.php'][5] = array(__('Themes'), 'switch_themes', 'themes.php');
$submenu['themes.php'][10] = array(_x('Editor', 'theme editor'), 'edit_themes', 'theme-editor.php');
$submenu['themes.php'][15] = array(__('Add New Themes'), 'install_themes', 'theme-install.php');
$submenu['themes.php'][20] = array(__('Custom Navigation'), 'switch_themes', 'custom-navigation.php');
$update_plugins = get_site_transient( 'update_plugins' );
$update_count = 0;

View File

@ -0,0 +1,993 @@
<?php
/**
* WordPress Administration Custom Navigation
* General Functions
*
* @author Jeffikus <pearce.jp@gmail.com>
* @version 1.1.0
*
* @package WordPress
* @subpackage Administration
*/
function wp_custom_navigation_get_menu_items( $menu_objects, $key = 'ID' ) {
$menu_items = array();
if ( !empty( $menu_objects ) && !empty( $key ) ) {
$args = array( 'orderby' => 'menu_order', 'post_type' => 'menu_item', 'post_status' => 'menu-category,menu-page,menu-custom' );
if ( count( $menu_objects ) > 1 )
$args['include'] = implode( ',', $menu_objects );
else
$args['include'] = $menu_objects[0];
$posts = new WP_Query( $args );
if ( ! empty( $posts->posts ) ) {
foreach( $posts->posts as $post ) {
$menu_items[ $post->$key ] = $post;
}
}
unset( $posts );
ksort( $menu_items );
}
return $menu_items;
}
function wp_custom_navigation_setup($override = false) {
$nav_version = '1.1.0';
//Custom Navigation Menu Setup
//Check for Upgrades
if (get_option('wp_settings_custom_nav_version') <> '') {
$nav_version_in_db = get_option('wp_settings_custom_nav_version');
}
else {
$nav_version_in_db = '0';
}
//Override for menu descriptions
update_option('wp_settings_custom_nav_advanced_options','yes');
if(($nav_version_in_db <> $nav_version) || ($override))
update_option('wp_settings_custom_nav_version',$nav_version);
$custom_menus = get_terms( 'menu', array( 'hide_empty' => false ) );
if ( !empty( $custom_menus ) ) {
foreach( $custom_menus as $menu ) {
$menu_objects = get_objects_in_term( $menu->term_id, 'menu' );
if ( !empty( $menu_objects ) ) {
foreach( $menu_objects as $item )
wp_delete_post( $item );
}
wp_delete_term( $menu->term_id, 'menu' );
}
}
}
/*-----------------------------------------------------------------------------------*/
/* Custom Navigation Functions */
/* wp_custom_navigation_output() displays the menu in the back/frontend
/* wp_custom_navigation_sub_items() is a recursive sub menu item function
/* wp_custom_nav_get_pages()
/* wp_custom_nav_get_categories()
/* wp_custom_navigation_default_sub_items() is a recursive sub menu item function
/*-----------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------*/
/* Main Output Function
/* args list
/* type - frontend or backend
/* name - name of your menu
/* id - id of menu in db
/* desc - 1 = show descriptions, 2 = dont show descriptions
/* before_title - html before title is outputted in <a> tag
/* after_title - html after title is outputted in <a> tag
/*-----------------------------------------------------------------------------------*/
function wp_custom_navigation_output($args = array()) {
//DEFAULT ARGS
$type = 'frontend';
$name = 'Menu 1';
$id = 0;
$desc = 2;
$before_title = '';
$after_title = '';
if (isset($args)) {
if ( !is_array($args) )
parse_str( $args, $args );
extract($args);
}
$menu_objects = get_objects_in_term( $id, 'menu' );
$menu_items = wp_custom_navigation_get_menu_items( $menu_objects, 'menu_order' );
//Override for menu descriptions
$advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options');
if ($advanced_option_descriptions == 'no')
{
$desc = 2;
}
$queried_id = 0;
global $wp_query;
if ( is_page() )
$queried_id = $wp_query->post->ID;
elseif ( is_category() )
$queried_id = $wp_query->query_vars['cat'];
//DISPLAY Loop
foreach ($menu_items as $menu_item) {
//PREPARE Menu Data
//Page Menu Item
switch ( $menu_item->post_status ) {
case 'menu-page':
if ($menu_item->guid == '')
$link = get_permalink( $menu_item->post_parent );
else
$link = $menu_item->guid;
if ( $menu_item->post_title == '' )
$title = htmlentities( get_the_title( $menu_item->post_parent ) );
else
$title = htmlentities( $menu_item->post_title );
if ( $menu_item->post_content == '' )
$description = htmlentities( get_post_meta( $menu_item->ID, 'page-description', true ) );
else
$description = htmlentities( $menu_item->post_content );
$target = '';
break;
//Category Menu Item
case 'menu-category':
if ($menu_item->guid == '')
$link = get_category_link( $menu_item->post_parent );
else
$link = $menu_item->guid;
if ( $menu_item->post_title == '' ) {
$title_raw = get_categories( 'include='.$menu_item->post_parent );
$title = htmlentities($title_raw[0]->cat_name);
} else {
$title = htmlentities( $menu_item->post_title );
}
if ( $menu_item->post_content == '' )
$description = htmlentities( strip_tags( category_description( $menu_item->post_parent ) ) );
else
$description = htmlentities( $menu_item->post_content );
$target = '';
break;
default:
//Custom Menu Item
$link = $menu_item->guid;
$title = htmlentities( $menu_item->post_title );
$description = htmlentities( $menu_item->post_content );
$target = 'target="_blank"';
break;
}
/* @todo: update to use tax/post data
//SET anchor title
if (isset($wp_custom_nav_menu_items->custom_anchor_title)) {
$anchor_title = htmlentities($wp_custom_nav_menu_items->custom_anchor_title);
}
else {
$anchor_title = $title;
}
if ($queried_id == $wp_custom_nav_menu_items->post_id) {
$li_class = 'class="current_page_item"';
}
else {
$li_class = '';
}
if (isset($wp_custom_nav_menu_items->new_window)) {
if ($wp_custom_nav_menu_items->new_window > 0) {
$target = 'target="_blank"';
}
else {
$target = '';
}
}
*/
//List Items
?><li id="menu-<?php echo $menu_item->ID; ?>" value="<?php echo $menu_item->ID; ?>" <?php echo $li_class; ?>><?php
//@todo: update front end to use post data
//FRONTEND Link
if ($type == "frontend")
{
?><a title="<?php echo $anchor_title; ?>" href="<?php echo $link; ?>" <?php echo $target; ?>><?php echo $before_title.$title.$after_title; ?><?php
if ( $advanced_option_descriptions == 'no' )
{
// 2 widget override do NOT display descriptions
// 1 widget override display descriptions
// 0 widget override not set
if (($desc == 1) || ($desc == 0) )
{
?><span class="nav-description"><?php echo $description; ?></span><?php
}
elseif ($desc == 2)
{ }
else
{ }
}
else
{
// 2 widget override do NOT display descriptions
// 1 widget override display descriptions
// 0 widget override not set
if ($desc == 1)
{
?><span class="nav-description"><?php echo $description; ?></span><?php
}
elseif (($desc == 2) || ($desc == 0))
{ }
else
{ }
}
?></a><?php
}
//BACKEND draggable and droppable elements
elseif ($type == "backend")
$link_type = substr( $menu_item->post_status, 5 );
{
?>
<dl>
<dt>
<span class="title"><?php echo $title; ?></span>
<span class="controls">
<span class="type"><?php echo $link_type; ?></span>
<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>
<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>
<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>
</span>
</dt>
</dl>
<a><span class=""></span></a>
<input type="hidden" name="dbid<?php echo $menu_item->menu_order; ?>" id="dbid<?php echo $menu_item->menu_order; ?>" value="<?php echo $menu_item->ID; ?>" />
<input type="hidden" name="postmenu<?php echo $menu_item->menu_order; ?>" id="postmenu<?php echo $menu_item->menu_order; ?>" value="<?php echo $id; ?>" />
<input type="hidden" name="parent<?php echo $menu_item->menu_order; ?>" id="parent<?php echo $menu_item->menu_order; ?>" value="<?php echo $menu_item->post_parent; ?>" />
<input type="hidden" name="title<?php echo $menu_item->menu_order; ?>" id="title<?php echo $menu_item->menu_order; ?>" value="<?php echo $title; ?>" />
<input type="hidden" name="linkurl<?php echo $menu_item->menu_order; ?>" id="linkurl<?php echo $menu_item->menu_order; ?>" value="<?php echo $link; ?>" />
<input type="hidden" name="description<?php echo $menu_item->menu_order; ?>" id="description<?php echo $menu_item->menu_order; ?>" value="<?php echo $description; ?>" />
<input type="hidden" name="icon<?php echo $menu_item->menu_order; ?>" id="icon<?php echo $menu_item->menu_order; ?>" value="0" />
<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; ?>" />
<input type="hidden" name="linktype<?php echo $menu_item->menu_order; ?>" id="linktype<?php echo $menu_item->menu_order; ?>" value="<?php echo $link_type; ?>" />
<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 ); ?>" />
<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' ); ?>" />
<?php
}
//@todo: implement menu heirarchy
/* //DISPLAY menu sub items
if ($wp_custom_nav_menu_items->parent_id == 0)
{
//FRONTEND
if ($type == 'frontend')
{
//Recursive function
$intj = wp_custom_navigation_sub_items($wp_custom_nav_menu_items->id,$wp_custom_nav_menu_items->link_type,$table_name,$type,$wp_custom_nav_menu_id);
}
//BACKEND
else
{
//Recursive function
$intj = wp_custom_navigation_sub_items($wp_custom_nav_menu_items->id,$wp_custom_nav_menu_items->link_type,$table_name,$type,$id);
}
}
*/ ?></li>
<?php
}
}
//@todo: implement menu heirarchy
//RECURSIVE Sub Menu Items
function wp_custom_navigation_sub_items($post_id,$type,$table_name,$output_type,$menu_id = 0) {
$parent_id = 0;
global $wpdb;
//GET sub menu items
$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");
if (empty($wp_custom_nav_menu))
{
}
else
{
?><ul id="sub-custom-nav">
<?php
$queried_id = 0;
global $wp_query;
if (is_page()) {
$queried_id = $wp_query->post->ID;
}
elseif (is_category()) {
$queried_id = $wp_query->query_vars['cat'];
}
else {
}
//DISPLAY Loop
foreach ($wp_custom_nav_menu as $sub_item)
{
//Figure out where the menu item sits
$counter=$sub_item->position;
//Prepare Menu Data
//Category Menu Item
if ($sub_item->link_type == 'category')
{
$parent_id = $sub_item->parent_id;
$post_id = $sub_item->post_id;
if ($sub_item->custom_link == '') {
$link = get_category_link($sub_item->post_id);
}
else {
$link = $sub_item->custom_link;
}
if ($sub_item->custom_title == '') {
$title_raw = get_categories('include='.$sub_item->post_id);
$title = htmlentities($title_raw[0]->cat_name);
}
else {
$title = htmlentities($sub_item->custom_title);
}
if ($sub_item->custom_description == '') {
$description = strip_tags(category_description($sub_item->post_id));
}
else {
$description = $sub_item->custom_description;
}
$target = '';
}
//Page Menu Item
elseif ($sub_item->link_type == 'page')
{
$parent_id = $sub_item->parent_id;
$post_id = $sub_item->post_id;
if ($sub_item->custom_link == '') {
$link = get_permalink($sub_item->post_id);
}
else {
$link = $sub_item->custom_link;
}
if ($sub_item->custom_title == '') {
$title = htmlentities(get_the_title($sub_item->post_id));
}
else {
$title = htmlentities($sub_item->custom_title);
}
if ($sub_item->custom_description == '') {
$description = get_post_meta($sub_item->post_id, 'page-description', true);
}
else {
$description = $sub_item->custom_description;
}
$target = '';
}
//Custom Menu Item
else
{
$link = $sub_item->custom_link;
$title = htmlentities($sub_item->custom_title);
$parent_id = $sub_item->parent_id;
$post_id = $sub_item->post_id;
$description = $sub_item->custom_description;
$target = 'target="_blank"';
}
if ($queried_id == $sub_item->post_id) {
$li_class = 'class="current_page_item"';
}
else {
$li_class = '';
}
//SET anchor title
if (isset($sub_item->custom_anchor_title)) {
$anchor_title = htmlentities($sub_item->custom_anchor_title);
}
else {
$anchor_title = $title;
}
if (isset($sub_item->new_window)) {
if ($sub_item->new_window > 0) {
$target = 'target="_blank"';
}
}
//List Items
?><li id="menu-<?php echo $counter; ?>" value="<?php echo $counter; ?>" <?php echo $li_class; ?>><?php
//FRONTEND
if ($output_type == "frontend")
{
?><a title="<?php echo $anchor_title; ?>" href="<?php echo $link; ?>" <?php echo $target; ?>><?php echo $title; ?></a><?php
}
//BACKEND
elseif ($output_type == "backend")
{
?>
<dl>
<dt>
<span class="title"><?php echo $title; ?></span>
<span class="controls">
<span class="type"><?php echo $sub_item->link_type; ?></span>
<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>
<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>
<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>
</span>
</dt>
</dl>
<a class="hide" href="<?php echo $link; ?>"><?php echo $title; ?></a>
<input type="hidden" name="dbid<?php echo $counter; ?>" id="dbid<?php echo $counter; ?>" value="<?php echo $sub_item->id; ?>" />
<input type="hidden" name="postmenu<?php echo $counter; ?>" id="postmenu<?php echo $counter; ?>" value="<?php echo $post_id; ?>" />
<input type="hidden" name="parent<?php echo $counter; ?>" id="parent<?php echo $counter; ?>" value="<?php echo $parent_id; ?>" />
<input type="hidden" name="title<?php echo $counter; ?>" id="title<?php echo $counter; ?>" value="<?php echo $title; ?>" />
<input type="hidden" name="linkurl<?php echo $counter; ?>" id="linkurl<?php echo $counter; ?>" value="<?php echo $link; ?>" />
<input type="hidden" name="description<?php echo $counter; ?>" id="description<?php echo $counter; ?>" value="<?php echo $description; ?>" />
<input type="hidden" name="icon<?php echo $counter; ?>" id="icon<?php echo $counter; ?>" value="0" />
<input type="hidden" name="position<?php echo $counter; ?>" id="position<?php echo $counter; ?>" value="<?php echo $counter; ?>" />
<input type="hidden" name="linktype<?php echo $counter; ?>" id="linktype<?php echo $counter; ?>" value="<?php echo $sub_item->link_type; ?>" />
<input type="hidden" name="anchortitle<?php echo $counter; ?>" id="anchortitle<?php echo $counter; ?>" value="<?php echo $anchor_title; ?>" />
<input type="hidden" name="newwindow<?php echo $counter; ?>" id="newwindow<?php echo $counter; ?>" value="<?php echo $sub_item->new_window; ?>" />
<?php
}
//Do recursion
wp_custom_navigation_sub_items($sub_item->id,$sub_item->link_type,$table_name,$output_type,$menu_id);
?></li>
<?php
}
?></ul>
<?php
}
return $parent_id;
}
//Outputs All Pages and Sub Items
function wp_custom_nav_get_pages($counter,$type) {
$pages_args = array(
'child_of' => 0,
'sort_order' => 'ASC',
'sort_column' => 'post_title',
'hierarchical' => 1,
'exclude' => '',
'include' => '',
'meta_key' => '',
'meta_value' => '',
'authors' => '',
'parent' => -1,
'exclude_tree' => '',
'number' => '',
'offset' => 0 );
//GET all pages
$pages_array = get_pages($pages_args);
$intCounter = $counter;
$parentli = $intCounter;
if ($pages_array)
{
//DISPLAY Loop
foreach ($pages_array as $post)
{
if ($post->post_parent == 0)
{
//Custom Menu
if ($type == 'menu')
{
$description = get_post_meta($post->ID, 'page-description', true);
?>
<li id="menu-<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>">
<dl>
<dt>
<span class="title"><?php echo $post->post_title; ?></span>
<span class="controls">
<span class="type">page</span>
<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>
<a id="remove<?php echo $intCounter; ?>" onclick="removeitem(<?php echo $intCounter; ?>)" value="<?php echo $intCounter; ?>">
<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>
<a target="_blank" href="<?php echo get_permalink($post->ID); ?>">
<img alt="View Page" title="View Page" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-viewpage.png" />
</a>
</span>
</dt>
</dl>
<a class="hide" href="<?php echo get_permalink($post->ID); ?>"><span class="title"><?php echo $post->post_title; ?></span>
</a>
<input type="hidden" name="postmenu<?php echo $intCounter; ?>" id="postmenu<?php echo $intCounter; ?>" value="<?php echo $post->ID; ?>" />
<input type="hidden" name="parent<?php echo $intCounter; ?>" id="parent<?php echo $intCounter; ?>" value="0" />
<input type="hidden" name="title<?php echo $intCounter; ?>" id="title<?php echo $intCounter; ?>" value="<?php echo htmlentities($post->post_title); ?>" />
<input type="hidden" name="linkurl<?php echo $intCounter; ?>" id="linkurl<?php echo $intCounter; ?>" value="<?php echo get_permalink($post->ID); ?>" />
<input type="hidden" name="description<?php echo $intCounter; ?>" id="description<?php echo $intCounter; ?>" value="<?php echo $description; ?>" />
<input type="hidden" name="icon<?php echo $intCounter; ?>" id="icon<?php echo $intCounter; ?>" value="0" />
<input type="hidden" name="position<?php echo $intCounter; ?>" id="position<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>" />
<input type="hidden" name="linktype<?php echo $intCounter; ?>" id="linktype<?php echo $intCounter; ?>" value="page" />
<input type="hidden" name="anchortitle<?php echo $intCounter; ?>" id="anchortitle<?php echo $intCounter; ?>" value="<?php echo htmlentities($post->post_title); ?>" />
<input type="hidden" name="newwindow<?php echo $intCounter; ?>" id="newwindow<?php echo $intCounter; ?>" value="0" />
<?php $parentli = $post->ID; ?>
<?php $intCounter++; ?>
<?php
//Recursive function
$intCounter = wp_custom_navigation_default_sub_items($post->ID, $intCounter, $parentli, 'pages', 'menu');
?>
</li>
<?php
}
//Sidebar Menu
elseif ($type == 'default')
{
?>
<li>
<dl>
<dt>
<?php
$post_text = htmlentities($post->post_title);
$post_url = get_permalink($post->ID);
$post_id = $post->ID;
$post_parent_id = $post->post_parent;
$description = htmlentities(get_post_meta($post_id, 'page-description', true));
?>
<?php $templatedir = get_bloginfo('url'); ?>
<span class="title"><?php echo $post->post_title; ?></span> <a onclick="appendToList('<?php echo $templatedir; ?>','Page','<?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 get_permalink($post->ID); ?>"><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>
</dl>
<?php $parentli = $post->ID; ?>
<?php $intCounter++; ?>
<?php
//Recursive function
$intCounter = wp_custom_navigation_default_sub_items($post_id, $intCounter, $parentli, 'pages', 'default');
?>
</li>
<?php
}
else
{
}
}
}
}
else
{
echo 'Not Found';
}
return $intCounter;
}
//Outputs All Categories and Sub Items
function wp_custom_nav_get_categories($counter, $type) {
$category_args = array(
'type' => 'post',
'child_of' => 0,
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => false,
'include_last_update_time' => false,
'hierarchical' => 1,
'exclude' => '',
'include' => '',
'number' => '',
'pad_counts' => false );
$intCounter = $counter;
//GET all categories
$categories_array = get_categories($category_args);
if ($categories_array)
{
//DISPLAY Loop
foreach ($categories_array as $cat_item)
{
if ($cat_item->parent == 0)
{
//Custom Menu
if ($type == 'menu')
{
?>
<li id="menu-<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>">
<dl>
<dt>
<span class="title"><?php echo $cat_item->cat_name; ?></span>
<span class="controls">
<span class="type">category</span>
<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>
<a id="remove<?php echo $intCounter; ?>" onclick="removeitem(<?php echo $intCounter; ?>)" value="<?php echo $intCounter; ?>">
<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>
<a target="_blank" href="<?php echo get_category_link($cat_item->cat_ID); ?>">
<img alt="View Page" title="View Page" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-viewpage.png" />
</a>
</span>
</dt>
</dl>
<a class="hide" href="<?php echo get_category_link($cat_item->cat_ID); ?>"><span class="title"><?php echo $cat_item->cat_name; ?></span>
<?php
$use_cats_raw = get_option('wp_settings_custom_nav_descriptions');
$use_cats = strtolower($use_cats_raw);
if ($use_cats == 'yes') { ?>
<br/> <span><?php echo $cat_item->category_description; ?></span>
<?php } ?>
</a>
<input type="hidden" name="postmenu<?php echo $intCounter; ?>" id="postmenu<?php echo $intCounter; ?>" value="<?php echo $cat_item->cat_ID; ?>" />
<input type="hidden" name="parent<?php echo $intCounter; ?>" id="parent<?php echo $intCounter; ?>" value="0" />
<input type="hidden" name="title<?php echo $intCounter; ?>" id="title<?php echo $intCounter; ?>" value="<?php echo htmlentities($cat_item->cat_name); ?>" />
<input type="hidden" name="linkurl<?php echo $intCounter; ?>" id="linkurl<?php echo $intCounter; ?>" value="<?php echo get_category_link($cat_item->cat_ID); ?>" />
<input type="hidden" name="description<?php echo $intCounter; ?>" id="description<?php echo $intCounter; ?>" value="<?php echo htmlentities($cat_item->category_description); ?>" />
<input type="hidden" name="icon<?php echo $intCounter; ?>" id="icon<?php echo $intCounter; ?>" value="0" />
<input type="hidden" name="position<?php echo $intCounter; ?>" id="position<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>" />
<input type="hidden" name="linktype<?php echo $intCounter; ?>" id="linktype<?php echo $intCounter; ?>" value="category" />
<input type="hidden" name="anchortitle<?php echo $intCounter; ?>" id="anchortitle<?php echo $intCounter; ?>" value="<?php echo htmlentities($cat_item->cat_name); ?>" />
<input type="hidden" name="newwindow<?php echo $intCounter; ?>" id="newwindow<?php echo $intCounter; ?>" value="0" />
<?php $parentli = $cat_item->cat_ID; ?>
<?php $intCounter++; ?>
<?php
//Recursive function
$intCounter = wp_custom_navigation_default_sub_items($cat_item->cat_ID, $intCounter, $parentli, 'categories','menu');
?>
</li>
<?php
}
//Sidebar Menu
elseif ($type == 'default')
{
?>
<li>
<dl>
<dt>
<?php
$post_text = htmlentities($cat_item->cat_name);
$post_url = get_category_link($cat_item->cat_ID);
$post_id = $cat_item->cat_ID;
$post_parent_id = $cat_item->parent;
$description = htmlentities(strip_tags($cat_item->description));
?>
<?php $templatedir = get_bloginfo('url'); ?>
<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>
</dl>
<?php $parentli = $cat_item->cat_ID; ?>
<?php $intCounter++; ?>
<?php
//Recursive function
$intCounter = wp_custom_navigation_default_sub_items($cat_item->cat_ID, $intCounter, $parentli, 'categories','default');
?>
</li>
<?php
}
}
}
}
else
{
echo 'Not Found';
}
return $intCounter;
}
//RECURSIVE Sub Menu Items of default categories and pages
function wp_custom_navigation_default_sub_items($childof, $intCounter, $parentli, $type, $output_type) {
$counter = $intCounter;
//Custom Menu
if ($output_type == 'menu')
{
$sub_args = array(
'child_of' => $childof,
'hide_empty' => false,
'parent' => $childof);
}
//Sidebar Menu
elseif ($output_type == 'default')
{
$sub_args = array(
'child_of' => $childof,
'hide_empty' => false,
'parent' => $childof);
}
else
{
}
//Get Sub Category Items
if ($type == 'categories')
{
$sub_array = get_categories($sub_args);
}
//Get Sub Page Items
elseif ($type == 'pages')
{
$sub_array = get_pages($sub_args);
}
if ($sub_array)
{
?>
<ul id="sub-custom-nav-<?php echo $type ?>">
<?php
//DISPLAY Loop
foreach ($sub_array as $sub_item)
{
//Prepare Menu Data
//Category Menu Item
if ($type == 'categories')
{
$link = get_category_link($sub_item->cat_ID);
$title = htmlentities($sub_item->cat_name);
$parent_id = $sub_item->cat_ID;
$itemid = $sub_item->cat_ID;
$linktype = 'category';
$appendtype = 'Category';
$description = htmlentities(strip_tags($sub_item->description));
}
//Page Menu Item
elseif ($type == 'pages')
{
$link = get_permalink($sub_item->ID);
$title = htmlentities($sub_item->post_title);
$parent_id = $sub_item->ID;
$linktype = 'page';
$itemid = $sub_item->ID;
$appendtype = 'Page';
$description = htmlentities(get_post_meta($itemid, 'page-description', true));
}
//Custom Menu Item
else
{
$title = '';
$linktype = 'custom';
$appendtype= 'Custom';
}
//Custom Menu
if ($output_type == 'menu')
{
?>
<li id="menu-<?php echo $counter; ?>" value="<?php echo $counter; ?>">
<dl>
<dt>
<span class="title"><?php echo $title; ?></span>
<span class="controls">
<span class="type"><?php echo $linktype; ?></span>
<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>
<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>
<a 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>
</span>
</dt>
</dl>
<a class="hide" href="<?php echo $link; ?>"><?php echo $title; ?></a>
<input type="hidden" name="dbid<?php echo $counter; ?>" id="dbid<?php echo $counter; ?>" value="<?php echo $sub_item->id; ?>" />
<input type="hidden" name="postmenu<?php echo $counter; ?>" id="postmenu<?php echo $counter; ?>" value="<?php echo $parent_id; ?>" />
<input type="hidden" name="parent<?php echo $counter; ?>" id="parent<?php echo $counter; ?>" value="<?php echo $parentli; ?>" />
<input type="hidden" name="title<?php echo $counter; ?>" id="title<?php echo $counter; ?>" value="<?php echo $title; ?>" />
<input type="hidden" name="linkurl<?php echo $counter; ?>" id="linkurl<?php echo $counter; ?>" value="<?php echo $link; ?>" />
<input type="hidden" name="description<?php echo $counter; ?>" id="description<?php echo $counter; ?>" value="<?php echo $description; ?>" />
<input type="hidden" name="icon<?php echo $counter; ?>" id="icon<?php echo $counter; ?>" value="0" />
<input type="hidden" name="position<?php echo $counter; ?>" id="position<?php echo $counter; ?>" value="<?php echo $counter; ?>" />
<input type="hidden" name="linktype<?php echo $counter; ?>" id="linktype<?php echo $counter; ?>" value="<?php echo $linktype; ?>" />
<input type="hidden" name="anchortitle<?php echo $counter; ?>" id="anchortitle<?php echo $counter; ?>" value="<?php echo $title; ?>" />
<input type="hidden" name="newwindow<?php echo $counter; ?>" id="newwindow<?php echo $counter; ?>" value="0" />
<?php $counter++; ?>
<?php
//Do recursion
$counter = wp_custom_navigation_default_sub_items($parent_id, $counter, $parent_id, $type, 'menu');
?>
</li>
<?php
}
//Sidebar Menu
elseif ($output_type == 'default')
{
?>
<li>
<dl>
<dt>
<?php $templatedir = get_bloginfo('url'); ?>
<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>
</dl>
<?php
//Do recursion
$counter = wp_custom_navigation_default_sub_items($itemid, $counter, $parent_id, $type, 'default');
?>
</li>
<?php
}
}
?>
</ul>
<?php
}
return $counter;
}
/*-----------------------------------------------------------------------------------*/
/* Recursive get children */
/*-----------------------------------------------------------------------------------*/
function get_children_menu_elements($childof, $intCounter, $parentli, $type, $menu_id, $table_name) {
$counter = $intCounter;
global $wpdb;
//Get Sub Category Items
if ($type == 'categories')
{
$sub_args = array(
'child_of' => $childof,
'hide_empty' => false,
'parent' => $childof);
$sub_array = get_categories($sub_args);
}
//Get Sub Page Items
elseif ($type == 'pages')
{
$sub_args = array(
'child_of' => $childof,
'parent' => $childof);
$sub_array = get_pages($sub_args);
}
else {
}
if ($sub_array)
{
//DISPLAY Loop
foreach ($sub_array as $sub_item)
{
if (isset($sub_item->parent)) {
$sub_item_parent = $sub_item->parent;
}
elseif (isset($sub_item->post_parent)) {
$sub_item_parent = $sub_item->post_parent;
}
else {
}
//Is child
if ($sub_item_parent == $childof)
{
//Prepare Menu Data
//Category Menu Item
if ($type == 'categories')
{
$link = get_category_link($sub_item->cat_ID);
$title = htmlentities($sub_item->cat_name);
$parent_id = $sub_item->category_parent;
$itemid = $sub_item->cat_ID;
$linktype = 'category';
$appendtype= 'Category';
}
//Page Menu Item
elseif ($type == 'pages')
{
$link = get_permalink($sub_item->ID);
$title = htmlentities($sub_item->post_title);
$parent_id = $sub_item->post_parent;
$linktype = 'page';
$itemid = $sub_item->ID;
$appendtype= 'Page';
}
//Custom Menu Item
else
{
$title = '';
$linktype = 'custom';
$appendtype= 'Custom';
}
//CHECK for existing parent records
//echo $parent_id;
$wp_result = $wpdb->get_results("SELECT id FROM ".$table_name." WHERE post_id='".$parent_id."' AND link_type='".$linktype."' AND menu_id='".$menu_id."'");
if ($wp_result > 0 && isset($wp_result[0]->id)) {
$parent_id = $wp_result[0]->id;
}
else {
//$parent_id = 0;
}
//INSERT item
$insert = "INSERT INTO ".$table_name." (position,post_id,parent_id,custom_title,custom_link,custom_description,menu_icon,link_type,menu_id,custom_anchor_title) "."VALUES ('".$counter."','".$itemid."','".$parent_id."','".$title."','".$link."','','','".$linktype."','".$menu_id."','".$title."')";
$results = $wpdb->query( $insert );
$counter++;
$counter = get_children_menu_elements($itemid, $counter, $parent_id, $type, $menu_id, $table_name);
}
//Do nothing
else {
}
}
}
return $counter;
}
?>

View File

@ -1000,6 +1000,379 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
}
}
/**
* Custom Navigation widget class
*
* @since 3.0.0
*/
class WP_CustomNavWidget extends WP_Widget {
function WP_CustomNavWidget() {
$widget_ops = array('description' => 'Use this widget to add one of your Custom Navigation Menus as a widget.' );
parent::WP_Widget(false, __('Custom Navigation Menu'),$widget_ops);
}
function widget($args, $instance) {
$navmenu = $instance['navmenu'];
$navtitle = $instance['navtitle'];
$navdeveloper = strtolower($instance['navdeveloper']);
$navdiv = strtolower($instance['navdiv']);
$navul = strtolower($instance['navul']);
$navdivid = $instance['navdivid'];
$navdivclass = $instance['navdivclass'];
$navulid = $instance['navulid'];
$navulclass = $instance['navulclass'];
//Override for menu descriptions
$advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options');
if ($advanced_option_descriptions == 'no')
{
$navwidgetdescription = 2;
}
else
{
$navwidgetdescription = $instance['navwidgetdescription'];
}
$menuexists = false;
global $wpdb;
//GET menu name
if ($navmenu > 0)
{
$table_name_menus = $wpdb->prefix . "custom_nav_menus";
$wp_result = $wpdb->get_results("SELECT menu_name FROM ".$table_name_menus." WHERE id='".$navmenu."'");
$wp_custom_nav_menu_name = $wp_result[0]->menu_name;
$menuexists = true;
}
//Do nothing
else
{
$menuexists = false;
}
?>
<?php
//DEVELOPER settings enabled
if ($navdeveloper == 'yes')
{
//DISPLAY Custom DIV
if ($navdiv == 'yes')
{
?>
<div id="<?php echo $navdivid; ?>" class="<?php echo $navdivclass; ?>">
<?php
}
//Do NOT display DIV
else
{
}
}
//DISPLAY default DIV
else
{
?>
<div class="widget">
<?php
}
?>
<h3><?php echo $navtitle; ?></h3>
<?php
if ($menuexists)
{
?>
<?php
//DEVELOPER settings enabled
if ($navdeveloper == 'yes')
{
//DISPLAY Custom UL
if ($navul == 'yes')
{
?>
<ul id="<?php echo $navulid; ?>" class="<?php echo $navulclass; ?>">
<?php
}
//Do NOT display UL
else
{
}
}
//DISPLAY default UL
else
{
?>
<ul class="custom-nav">
<?php
}
?>
<?php
//DISPLAY custom navigation menu
if (get_option('wp_custom_nav_menu') == 'true') {
custom_nav('name='.$wp_custom_nav_menu_name.'&desc='.$navwidgetdescription);
}
?>
<?php
//DEVELOPER settings enabled
if ($navdeveloper == 'yes')
{
//DISPLAY Custom UL
if ($navul == 'yes')
{
?>
</ul>
<?php
}
//Do NOT display UL
else
{
}
}
//DISPLAY default UL
else
{
?>
</ul>
<?php
}
?>
<?php
}
else
{
echo "You have not setup the custom navigation widget correctly, please check your settings in the backend.";
}
?>
<?php
//DEVELOPER settings enabled
if ($navdeveloper == 'yes')
{
//DISPLAY Custom DIV
if ($navdiv == 'yes')
{
?>
</div>
<?php
}
//Do NOT display DIV
else
{
}
}
//DISPLAY default DIV
else
{
?>
</div>
<?php
}
?><!-- /#nav-container -->
<?php
}
function update($new_instance, $old_instance) {
return $new_instance;
}
function form($instance) {
$navmenu = esc_attr($instance['navmenu']);
$navtitle = esc_attr($instance['navtitle']);
$navdeveloper = esc_attr($instance['navdeveloper']);
$navdiv = esc_attr($instance['navdiv']);
$navul = esc_attr($instance['navul']);
$navdivid = esc_attr($instance['navdivid']);
$navdivclass = esc_attr($instance['navdivclass']);
$navulid = esc_attr($instance['navulid']);
$navulclass = esc_attr($instance['navulclass']);
$navwidgetdescription = esc_attr($instance['navwidgetdescription']);
global $wpdb;
//GET Menu Items for SELECT OPTIONS
$table_name_custom_menus = $wpdb->prefix . "custom_nav_menus";
$custom_menu_records = $wpdb->get_results("SELECT id,menu_name FROM ".$table_name_custom_menus);
//CHECK if menus exist
if ($custom_menu_records > 0)
{
?>
<p>
<label for="<?php echo $this->get_field_id('navmenu'); ?>"><?php _e('Select Menu:'); ?></label>
<select id="<?php echo $this->get_field_id('navmenu'); ?>" name="<?php echo $this->get_field_name('navmenu'); ?>">
<?php
//DISPLAY SELECT OPTIONS
foreach ($custom_menu_records as $custom_menu_record)
{
if ($navmenu == $custom_menu_record->id) {
$selected_option = 'selected="selected"';
}
else {
$selected_option = '';
}
?>
<option value="<?php echo $custom_menu_record->id; ?>" <?php echo $selected_option; ?>><?php echo $custom_menu_record->menu_name; ?></option>
<?php
}
?>
</select>
</p>
<p>
<label for="<?php echo $this->get_field_id('navtitle'); ?>"><?php _e('Title:'); ?></label>
<input type="text" name="<?php echo $this->get_field_name('navtitle'); ?>" value="<?php echo $navtitle; ?>" class="widefat" id="<?php echo $this->get_field_id('navtitle'); ?>" />
</p>
<p>
<?php
$checked = strtolower($navdeveloper);
?>
<label for="<?php echo $this->get_field_id('navdeveloper'); ?>"><?php _e('Advanced Options:'); ?></label><br />
<span class="checkboxes">
<label>Yes</label><input type="radio" id="<?php echo $this->get_field_name('navdeveloper'); ?>" name="<?php echo $this->get_field_name('navdeveloper'); ?>" value="yes" <?php if ($checked=='yes') { echo 'checked="checked"'; } ?> />
<label>No</label><input type="radio" id="<?php echo $this->get_field_name('navdeveloper'); ?>" name="<?php echo $this->get_field_name('navdeveloper'); ?>" value="no" <?php if ($checked=='yes') { } else { echo 'checked="checked"'; } ?> />
</span><!-- /.checkboxes -->
</p>
<?php
//DEVELOPER settings
if ($checked == 'yes')
{
?>
<p>
<?php
$checked = strtolower($navdiv);
?>
<label for="<?php echo $this->get_field_id('navdiv'); ?>"><?php _e('Wrap in container DIV:'); ?></label><br />
<span class="checkboxes">
<label>Yes</label><input type="radio" id="<?php echo $this->get_field_name('navdiv'); ?>" name="<?php echo $this->get_field_name('navdiv'); ?>" value="yes" <?php if ($checked=='yes') { echo 'checked="checked"'; } ?> />
<label>No</label><input type="radio" id="<?php echo $this->get_field_name('navdiv'); ?>" name="<?php echo $this->get_field_name('navdiv'); ?>" value="no" <?php if ($checked=='yes') { } else { echo 'checked="checked"'; } ?> />
</span><!-- /.checkboxes -->
</p>
<?php
if ($checked == 'yes')
{
?>
<p>
<label for="<?php echo $this->get_field_id('navdivid'); ?>"><?php _e('DIV id:'); ?></label>
<input type="text" name="<?php echo $this->get_field_name('navdivid'); ?>" value="<?php echo $navdivid; ?>" class="widefat" id="<?php echo $this->get_field_id('navdivid'); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id('navdivclass'); ?>"><?php _e('DIV class:'); ?></label>
<input type="text" name="<?php echo $this->get_field_name('navdivclass'); ?>" value="<?php echo $navdivclass; ?>" class="widefat" id="<?php echo $this->get_field_id('navdivclass'); ?>" />
</p>
<?php
}
?>
<p>
<?php
$checked = strtolower($navul);
?>
<label for="<?php echo $this->get_field_id('navul'); ?>"><?php _e('Wrap in container UL:'); ?></label><br />
<span class="checkboxes">
<label>Yes</label><input type="radio" id="<?php echo $this->get_field_name('navul'); ?>" name="<?php echo $this->get_field_name('navul'); ?>" value="yes" <?php if ($checked=='yes') { echo 'checked="checked"'; } ?> />
<label>No</label><input type="radio" id="<?php echo $this->get_field_name('navul'); ?>" name="<?php echo $this->get_field_name('navul'); ?>" value="no" <?php if ($checked=='yes') { } else { echo 'checked="checked"'; } ?> />
</span><!-- /.checkboxes -->
</p>
<?php
if ($checked == 'yes')
{
?>
<p>
<label for="<?php echo $this->get_field_id('navulid'); ?>"><?php _e('UL id:'); ?></label>
<input type="text" name="<?php echo $this->get_field_name('navulid'); ?>" value="<?php echo $navulid; ?>" class="widefat" id="<?php echo $this->get_field_id('navulid'); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id('navulclass'); ?>"><?php _e('UL class:'); ?></label>
<input type="text" name="<?php echo $this->get_field_name('navulclass'); ?>" value="<?php echo $navulclass; ?>" class="widefat" id="<?php echo $this->get_field_id('navulclass'); ?>" />
</p>
<?php
}
?>
<?php $advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options'); ?>
<p <?php if ($advanced_option_descriptions == 'no') { ?>style="display:none;"<?php } ?>>
<?php
$checked = strtolower($navwidgetdescription);
?>
<label for="<?php echo $this->get_field_id('navwidgetdescription'); ?>"><?php _e('Show Top Level Descriptions:'); ?></label><br />
<span class="checkboxes">
<label>Yes</label><input type="radio" id="<?php echo $this->get_field_name('navwidgetdescription'); ?>" name="<?php echo $this->get_field_name('navwidgetdescription'); ?>" value="1" <?php if ($checked=='1') { echo 'checked="checked"'; } ?> />
<label>No</label><input type="radio" id="<?php echo $this->get_field_name('navwidgetdescription'); ?>" name="<?php echo $this->get_field_name('navwidgetdescription'); ?>" value="2" <?php if ($checked=='1') { } else { echo 'checked="checked"'; } ?> />
</span><!-- /.checkboxes -->
</p>
<?php
}
//Do nothing
else
{
}
}
//Error message for menus not existing
else
{
?>
<p>
<label><?php _e('The Custom Navigation has not been configured correctly. Please check your Custom Navigation settings before adding this widget.'); ?></label>
</p>
<?php
}
}
}
/**
* Register all of the default WordPress widgets on startup.
*
@ -1035,7 +1408,9 @@ function wp_widgets_init() {
register_widget('WP_Widget_RSS');
register_widget('WP_Widget_Tag_Cloud');
register_widget('WP_CustomNavWidget');
do_action('widgets_init');
}

View File

@ -2215,4 +2215,14 @@ function get_the_generator( $type = '' ) {
return apply_filters( "get_the_generator_{$type}", $gen, $type );
}
/**
* Outputs the Custom Navigation.
*
* @since 3.0.0
*/
function custom_nav($args = array()) {
require_once (ABSPATH . WPINC . '/custom-navigation-functions.php');
wp_custom_navigation_output($args);
}
?>

View File

@ -63,6 +63,14 @@ function create_initial_post_types() {
'query_var' => false,
) );
register_post_type( 'menu_item', array( 'public' => false,
'show_ui' => false,
'_builtin' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => false,
'query_var' => false,
) );
register_post_status( 'publish', array( 'label' => _x('Published', 'post'),
'public' => true,
'_builtin' => true,
@ -105,6 +113,18 @@ function create_initial_post_types() {
'_builtin' => true,
'label_count' => _n_noop('Auto-Draft <span class="count">(%s)</span>', 'Auto-Drafts <span class="count">(%s)</span>')
) );
register_post_status( 'menu-category', array( 'internal' => true,
'_builtin' => true
) );
register_post_status( 'menu-page', array( 'internal' => true,
'_builtin' => true
) );
register_post_status( 'menu-custom', array( 'internal' => true,
'_builtin' => true
) );
}
add_action( 'init', 'create_initial_post_types', 0 ); // highest priority
@ -4494,4 +4514,4 @@ function _show_post_preview() {
add_filter('the_preview', '_set_preview');
}
}
}

View File

@ -394,6 +394,21 @@ function wp_default_scripts( &$scripts ) {
) );
}
//Custom Navigation
$scripts->add( 'custom-navigation-jquery', '/wp-admin/js/custom-navigation-custom-jquery-1.3.2.js', false, '1.3.2' );
$scripts->add( 'custom-navigation-ui-custom', '/wp-admin/js/custom-navigation-custom-jquery-ui-1.7.2.js', array('custom-navigation-jquery'), '1.7.2' );
$scripts->add_data( 'custom-navigation-ui-custom', 'group', 1 );
$scripts->add( 'custom-navigation-autocomplete', '/wp-admin/js/custom-navigation-custom-jquery-autocomplete.js', array('custom-navigation-jquery'), '1.0.0' );
$scripts->add_data( 'custom-navigation-autocomplete', 'group', 1 );
$scripts->add( 'custom-navigation-default-items', '/wp-admin/js/custom-navigation-default-items.js', false, '1.0.0' );
$scripts->add( 'custom-navigation-dynamic-functions', '/wp-admin/js/custom-navigation-dynamic-functions.js', false, '1.0.0' );
$scripts->add( 'custom-navigation-php-functions', '/wp-admin/js/custom-navigation-php-functions.js', false, '1.0.0' );
}
/**
@ -459,7 +474,8 @@ function wp_default_styles( &$styles ) {
$styles->add( 'farbtastic', '/wp-admin/css/farbtastic.css', array(), '1.2' );
$styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.css', array(), '0.9.8' );
$styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.1' );
$styles->add( 'custom-navigation', "/wp-admin/css/custom-navigation$suffix.css", array(), '20100215' );
foreach ( $rtl_styles as $rtl_style )
$styles->add_data( $rtl_style, 'rtl', true );
}

View File

@ -38,6 +38,11 @@ function create_initial_taxonomies() {
'_builtin' => true
) ) ;
register_taxonomy( 'menu', 'post', array( 'hierarchical' => false,
'query_var' => false,
'rewrite' => false
) ) ;
register_taxonomy( 'link_category', 'link', array( 'hierarchical' => false,
'label' => __('Categories'),
'query_var' => false,