Formatting cleanups. see #11817
git-svn-id: http://svn.automattic.com/wordpress/trunk@13317 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
09e8d27130
commit
766de41c58
|
@ -32,35 +32,23 @@ function wp_custom_navigation_get_menu_items( $menu_objects, $key = 'ID' ) {
|
||||||
|
|
||||||
function wp_custom_navigation_setup($override = false) {
|
function wp_custom_navigation_setup($override = false) {
|
||||||
|
|
||||||
$nav_version = '1.1.0';
|
// Custom Navigation Menu Setup
|
||||||
//Custom Navigation Menu Setup
|
|
||||||
|
|
||||||
//Check for Upgrades
|
// Override for menu descriptions
|
||||||
if (get_option('wp_settings_custom_nav_version') <> '') {
|
update_option('wp_settings_custom_nav_advanced_options', 'yes');
|
||||||
$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( 'nav_menu', array( 'hide_empty' => false ) );
|
$custom_menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
|
||||||
if ( !empty( $custom_menus ) ) {
|
if ( !empty( $custom_menus ) ) {
|
||||||
foreach( $custom_menus as $menu ) {
|
foreach ( $custom_menus as $menu ) {
|
||||||
$menu_objects = get_objects_in_term( $menu->term_id, 'nav_menu' );
|
$menu_objects = get_objects_in_term( $menu->term_id, 'nav_menu' );
|
||||||
if ( !empty( $menu_objects ) ) {
|
if ( !empty( $menu_objects ) ) {
|
||||||
foreach( $menu_objects as $item )
|
foreach ( $menu_objects as $item ) {
|
||||||
wp_delete_post( $item );
|
wp_delete_post( $item );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
wp_delete_term( $menu->term_id, 'nav_menu' );
|
wp_delete_term( $menu->term_id, 'nav_menu' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
@ -83,27 +71,17 @@ function wp_custom_navigation_setup($override = false) {
|
||||||
/* after_title - html after title is outputted in <a> tag
|
/* after_title - html after title is outputted in <a> tag
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
function wp_custom_navigation_output($args = array()) {
|
function wp_custom_navigation_output( $args = array() ) {
|
||||||
|
|
||||||
//DEFAULT ARGS
|
// Defaults
|
||||||
$type = 'frontend';
|
$defaults = array( 'type' => 'frontend', 'name' => 'Menu 1', 'id' => 0, 'desc' => 2, 'before_title' => '', 'after_title' => '');
|
||||||
$name = 'Menu 1';
|
|
||||||
$id = 0;
|
|
||||||
$desc = 2;
|
|
||||||
$before_title = '';
|
|
||||||
$after_title = '';
|
|
||||||
|
|
||||||
if (isset($args)) {
|
$args = wp_parse_args($args, $defaults);
|
||||||
|
extract($args, EXTR_SKIP);
|
||||||
if ( !is_array($args) )
|
|
||||||
parse_str( $args, $args );
|
|
||||||
|
|
||||||
extract($args);
|
|
||||||
}
|
|
||||||
|
|
||||||
$menu_objects = get_objects_in_term( $id, 'nav_menu' );
|
$menu_objects = get_objects_in_term( $id, 'nav_menu' );
|
||||||
$menu_items = wp_custom_navigation_get_menu_items( $menu_objects, 'menu_order' );
|
$menu_items = wp_custom_navigation_get_menu_items( $menu_objects, 'menu_order' );
|
||||||
//Override for menu descriptions
|
//O verride for menu descriptions
|
||||||
$advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options');
|
$advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options');
|
||||||
if ( $advanced_option_descriptions == 'no' )
|
if ( $advanced_option_descriptions == 'no' )
|
||||||
$desc = 2;
|
$desc = 2;
|
||||||
|
@ -211,14 +189,9 @@ function wp_custom_navigation_output($args = array()) {
|
||||||
// 2 widget override do NOT display descriptions
|
// 2 widget override do NOT display descriptions
|
||||||
// 1 widget override display descriptions
|
// 1 widget override display descriptions
|
||||||
// 0 widget override not set
|
// 0 widget override not set
|
||||||
if (($desc == 1) || ($desc == 0) )
|
if ( ($desc == 1) || ($desc == 0) ) {
|
||||||
{
|
|
||||||
?><span class="nav-description"><?php echo $description; ?></span><?php
|
?><span class="nav-description"><?php echo $description; ?></span><?php
|
||||||
}
|
}
|
||||||
elseif ($desc == 2)
|
|
||||||
{ }
|
|
||||||
else
|
|
||||||
{ }
|
|
||||||
} else {
|
} else {
|
||||||
// 2 widget override do NOT display descriptions
|
// 2 widget override do NOT display descriptions
|
||||||
// 1 widget override display descriptions
|
// 1 widget override display descriptions
|
||||||
|
@ -226,10 +199,6 @@ function wp_custom_navigation_output($args = array()) {
|
||||||
if ( $desc == 1 ) {
|
if ( $desc == 1 ) {
|
||||||
?><span class="nav-description"><?php echo $description; ?></span><?php
|
?><span class="nav-description"><?php echo $description; ?></span><?php
|
||||||
}
|
}
|
||||||
elseif (($desc == 2) || ($desc == 0))
|
|
||||||
{ }
|
|
||||||
else
|
|
||||||
{ }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?></a><?php
|
?></a><?php
|
||||||
|
@ -287,7 +256,7 @@ function wp_custom_navigation_output($args = array()) {
|
||||||
}
|
}
|
||||||
//@todo: implement menu heirarchy
|
//@todo: implement menu heirarchy
|
||||||
//RECURSIVE Sub Menu Items
|
//RECURSIVE Sub Menu Items
|
||||||
function wp_custom_navigation_sub_items($post_id,$type,$table_name,$output_type,$menu_id = 0) {
|
function wp_custom_navigation_sub_items($post_id, $type, $table_name, $output_type, $menu_id = 0) {
|
||||||
|
|
||||||
$parent_id = 0;
|
$parent_id = 0;
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
@ -466,8 +435,8 @@ function wp_custom_navigation_sub_items($post_id,$type,$table_name,$output_type,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Outputs All Pages and Sub Items
|
// Outputs All Pages and Sub Items
|
||||||
function wp_custom_nav_get_pages($counter,$type) {
|
function wp_custom_nav_get_pages($counter, $type) {
|
||||||
|
|
||||||
$pages_args = array(
|
$pages_args = array(
|
||||||
'child_of' => 0,
|
'child_of' => 0,
|
||||||
|
@ -490,111 +459,99 @@ function wp_custom_nav_get_pages($counter,$type) {
|
||||||
$intCounter = $counter;
|
$intCounter = $counter;
|
||||||
$parentli = $intCounter;
|
$parentli = $intCounter;
|
||||||
|
|
||||||
if ($pages_array)
|
if ( !$pages_array ) {
|
||||||
{
|
echo 'Not Found';
|
||||||
//DISPLAY Loop
|
return $intCounter;
|
||||||
foreach ($pages_array as $post)
|
}
|
||||||
{
|
|
||||||
|
|
||||||
if ($post->post_parent == 0)
|
// Display Loop
|
||||||
{
|
foreach ( $pages_array as $post ) {
|
||||||
//Custom Menu
|
if ($post->post_parent == 0) {
|
||||||
if ($type == 'menu')
|
// Custom Menu
|
||||||
{
|
if ( $type == 'menu' ) {
|
||||||
$description = get_post_meta($post->ID, 'page-description', true);
|
$description = get_post_meta($post->ID, 'page-description', true);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<li id="menu-<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>">
|
<li id="menu-<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>">
|
||||||
|
|
||||||
<dl>
|
<dl>
|
||||||
<dt>
|
<dt>
|
||||||
<span class="title"><?php echo $post->post_title; ?></span>
|
<span class="title"><?php echo $post->post_title; ?></span>
|
||||||
<span class="controls">
|
<span class="controls">
|
||||||
<span class="type">page</span>
|
<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="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; ?>">
|
<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" />
|
<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>
|
||||||
<a target="_blank" href="<?php echo get_permalink($post->ID); ?>">
|
<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" />
|
<img alt="View Page" title="View Page" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-viewpage.png" />
|
||||||
</a>
|
</a>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
</dt>
|
</dt>
|
||||||
</dl>
|
</dl>
|
||||||
<a class="hide" href="<?php echo get_permalink($post->ID); ?>"><span class="title"><?php echo $post->post_title; ?></span>
|
<a class="hide" href="<?php echo get_permalink($post->ID); ?>"><span class="title"><?php echo $post->post_title; ?></span>
|
||||||
</a>
|
</a>
|
||||||
<input type="hidden" name="postmenu<?php echo $intCounter; ?>" id="postmenu<?php echo $intCounter; ?>" value="<?php echo $post->ID; ?>" />
|
<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="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="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="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="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="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="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="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="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" />
|
<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 $parentli = $post->ID; ?>
|
||||||
|
<?php $intCounter++; ?>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
}
|
//Recursive function
|
||||||
//Sidebar Menu
|
$intCounter = wp_custom_navigation_default_sub_items($post->ID, $intCounter, $parentli, 'pages', 'menu');
|
||||||
elseif ($type == 'default')
|
|
||||||
{
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<li>
|
</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
|
||||||
|
|
||||||
?>
|
} elseif ( $type == 'default' ) {
|
||||||
<?php $templatedir = get_bloginfo('url'); ?>
|
// Sidebar Menu
|
||||||
|
?>
|
||||||
|
|
||||||
<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>
|
<li>
|
||||||
</dl>
|
<dl>
|
||||||
<?php $parentli = $post->ID; ?>
|
<dt>
|
||||||
<?php $intCounter++; ?>
|
<?php
|
||||||
<?php
|
$post_text = htmlentities($post->post_title);
|
||||||
|
$post_url = get_permalink($post->ID);
|
||||||
|
$post_id = $post->ID;
|
||||||
|
$post_parent_id = $post->post_parent;
|
||||||
|
|
||||||
//Recursive function
|
$description = htmlentities(get_post_meta($post_id, 'page-description', true));
|
||||||
$intCounter = wp_custom_navigation_default_sub_items($post_id, $intCounter, $parentli, 'pages', 'default');
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
<?php $templatedir = get_bloginfo('url'); ?>
|
||||||
</li>
|
|
||||||
|
|
||||||
|
<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
|
<?php
|
||||||
|
|
||||||
}
|
//Recursive function
|
||||||
else
|
$intCounter = wp_custom_navigation_default_sub_items($post_id, $intCounter, $parentli, 'pages', 'default');
|
||||||
{
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
echo 'Not Found';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $intCounter;
|
return $intCounter;
|
||||||
}
|
}
|
||||||
|
@ -615,110 +572,101 @@ function wp_custom_nav_get_categories($counter, $type) {
|
||||||
'number' => '',
|
'number' => '',
|
||||||
'pad_counts' => false );
|
'pad_counts' => false );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$intCounter = $counter;
|
$intCounter = $counter;
|
||||||
|
|
||||||
//GET all categories
|
// Get all categories
|
||||||
$categories_array = get_categories($category_args);
|
$categories_array = get_categories($category_args);
|
||||||
|
|
||||||
if ($categories_array)
|
if ( !$categories_array ) {
|
||||||
{
|
echo 'Not Found';
|
||||||
//DISPLAY Loop
|
return $intCounter;
|
||||||
foreach ($categories_array as $cat_item)
|
}
|
||||||
{
|
|
||||||
|
// 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');
|
||||||
|
|
||||||
if ($cat_item->parent == 0)
|
|
||||||
{
|
|
||||||
//Custom Menu
|
|
||||||
if ($type == 'menu')
|
|
||||||
{
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<li id="menu-<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>">
|
</li>
|
||||||
<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
|
||||||
|
} elseif ($type == 'default') {
|
||||||
|
// Sidebar Menu
|
||||||
|
?>
|
||||||
|
<li>
|
||||||
|
<dl>
|
||||||
|
<dt>
|
||||||
<?php
|
<?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;
|
return $intCounter;
|
||||||
}
|
}
|
||||||
|
@ -728,53 +676,42 @@ function wp_custom_navigation_default_sub_items($childof, $intCounter, $parentli
|
||||||
|
|
||||||
$counter = $intCounter;
|
$counter = $intCounter;
|
||||||
|
|
||||||
//Custom Menu
|
// Custom Menu
|
||||||
if ($output_type == 'menu')
|
if ($output_type == 'menu') {
|
||||||
{
|
$sub_args = array(
|
||||||
|
'child_of' => $childof,
|
||||||
|
'hide_empty' => false,
|
||||||
|
'parent' => $childof);
|
||||||
|
} elseif ($output_type == 'default') {
|
||||||
|
// Sidebar Menu
|
||||||
$sub_args = array(
|
$sub_args = array(
|
||||||
'child_of' => $childof,
|
'child_of' => $childof,
|
||||||
'hide_empty' => false,
|
'hide_empty' => false,
|
||||||
'parent' => $childof);
|
'parent' => $childof);
|
||||||
}
|
}
|
||||||
//Sidebar Menu
|
|
||||||
elseif ($output_type == 'default')
|
|
||||||
{
|
|
||||||
$sub_args = array(
|
|
||||||
'child_of' => $childof,
|
|
||||||
'hide_empty' => false,
|
|
||||||
'parent' => $childof);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
if ( $type == 'categories' ) {
|
||||||
|
// Get Sub Category Items
|
||||||
//Get Sub Category Items
|
|
||||||
if ($type == 'categories')
|
|
||||||
{
|
|
||||||
$sub_array = get_categories($sub_args);
|
$sub_array = get_categories($sub_args);
|
||||||
}
|
} elseif ($type == 'pages') {
|
||||||
//Get Sub Page Items
|
// Get Sub Page Items
|
||||||
elseif ($type == 'pages')
|
|
||||||
{
|
|
||||||
$sub_array = get_pages($sub_args);
|
$sub_array = get_pages($sub_args);
|
||||||
|
} else {
|
||||||
|
$sub_array = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($sub_array)
|
if ( $sub_array ) {
|
||||||
{
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<ul id="sub-custom-nav-<?php echo $type ?>">
|
<ul id="sub-custom-nav-<?php echo $type ?>">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
//DISPLAY Loop
|
// Display Loop
|
||||||
foreach ($sub_array as $sub_item)
|
foreach ( $sub_array as $sub_item ) {
|
||||||
{
|
|
||||||
//Prepare Menu Data
|
//Prepare Menu Data
|
||||||
//Category Menu Item
|
//Category Menu Item
|
||||||
if ($type == 'categories')
|
if ( $type == 'categories' ) {
|
||||||
{
|
|
||||||
$link = get_category_link($sub_item->cat_ID);
|
$link = get_category_link($sub_item->cat_ID);
|
||||||
$title = htmlentities($sub_item->cat_name);
|
$title = htmlentities($sub_item->cat_name);
|
||||||
$parent_id = $sub_item->cat_ID;
|
$parent_id = $sub_item->cat_ID;
|
||||||
|
@ -782,10 +719,8 @@ function wp_custom_navigation_default_sub_items($childof, $intCounter, $parentli
|
||||||
$linktype = 'category';
|
$linktype = 'category';
|
||||||
$appendtype = 'Category';
|
$appendtype = 'Category';
|
||||||
$description = htmlentities(strip_tags($sub_item->description));
|
$description = htmlentities(strip_tags($sub_item->description));
|
||||||
}
|
} elseif ( $type == 'pages' ) {
|
||||||
//Page Menu Item
|
//Page Menu Item
|
||||||
elseif ($type == 'pages')
|
|
||||||
{
|
|
||||||
$link = get_permalink($sub_item->ID);
|
$link = get_permalink($sub_item->ID);
|
||||||
$title = htmlentities($sub_item->post_title);
|
$title = htmlentities($sub_item->post_title);
|
||||||
$parent_id = $sub_item->ID;
|
$parent_id = $sub_item->ID;
|
||||||
|
@ -793,18 +728,15 @@ function wp_custom_navigation_default_sub_items($childof, $intCounter, $parentli
|
||||||
$itemid = $sub_item->ID;
|
$itemid = $sub_item->ID;
|
||||||
$appendtype = 'Page';
|
$appendtype = 'Page';
|
||||||
$description = htmlentities(get_post_meta($itemid, 'page-description', true));
|
$description = htmlentities(get_post_meta($itemid, 'page-description', true));
|
||||||
}
|
} else {
|
||||||
//Custom Menu Item
|
// Custom Menu Item
|
||||||
else
|
|
||||||
{
|
|
||||||
$title = '';
|
$title = '';
|
||||||
$linktype = 'custom';
|
$linktype = 'custom';
|
||||||
$appendtype= 'Custom';
|
$appendtype= 'Custom';
|
||||||
}
|
}
|
||||||
|
|
||||||
//Custom Menu
|
// Custom Menu
|
||||||
if ($output_type == 'menu')
|
if ( $output_type == 'menu' ) {
|
||||||
{
|
|
||||||
?>
|
?>
|
||||||
<li id="menu-<?php echo $counter; ?>" value="<?php echo $counter; ?>">
|
<li id="menu-<?php echo $counter; ?>" value="<?php echo $counter; ?>">
|
||||||
<dl>
|
<dl>
|
||||||
|
@ -846,11 +778,8 @@ function wp_custom_navigation_default_sub_items($childof, $intCounter, $parentli
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
<?php
|
<?php
|
||||||
}
|
} elseif ($output_type == 'default') {
|
||||||
//Sidebar Menu
|
// Sidebar Menu
|
||||||
elseif ($output_type == 'default')
|
|
||||||
{
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<li>
|
<li>
|
||||||
<dl>
|
<dl>
|
||||||
|
@ -879,7 +808,6 @@ function wp_custom_navigation_default_sub_items($childof, $intCounter, $parentli
|
||||||
}
|
}
|
||||||
|
|
||||||
return $counter;
|
return $counter;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
@ -887,16 +815,12 @@ function wp_custom_navigation_default_sub_items($childof, $intCounter, $parentli
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
function get_children_menu_elements($childof, $intCounter, $parentli, $type, $menu_id, $table_name) {
|
function get_children_menu_elements($childof, $intCounter, $parentli, $type, $menu_id, $table_name) {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
$counter = $intCounter;
|
$counter = $intCounter;
|
||||||
|
|
||||||
global $wpdb;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Get Sub Category Items
|
//Get Sub Category Items
|
||||||
if ($type == 'categories')
|
if ( $type == 'categories' ) {
|
||||||
{
|
|
||||||
$sub_args = array(
|
$sub_args = array(
|
||||||
'child_of' => $childof,
|
'child_of' => $childof,
|
||||||
'hide_empty' => false,
|
'hide_empty' => false,
|
||||||
|
@ -912,31 +836,24 @@ function get_children_menu_elements($childof, $intCounter, $parentli, $type, $me
|
||||||
|
|
||||||
$sub_array = get_pages($sub_args);
|
$sub_array = get_pages($sub_args);
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else {
|
$sub_array = array();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sub_array)
|
if ( $sub_array ) {
|
||||||
{
|
|
||||||
//DISPLAY Loop
|
//DISPLAY Loop
|
||||||
foreach ($sub_array as $sub_item)
|
foreach ( $sub_array as $sub_item ) {
|
||||||
{
|
if ( isset($sub_item->parent) ) {
|
||||||
if (isset($sub_item->parent)) {
|
|
||||||
$sub_item_parent = $sub_item->parent;
|
$sub_item_parent = $sub_item->parent;
|
||||||
}
|
} elseif (isset($sub_item->post_parent)) {
|
||||||
elseif (isset($sub_item->post_parent)) {
|
|
||||||
$sub_item_parent = $sub_item->post_parent;
|
$sub_item_parent = $sub_item->post_parent;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
}
|
// Is child
|
||||||
//Is child
|
if ( $sub_item_parent == $childof ) {
|
||||||
if ($sub_item_parent == $childof)
|
|
||||||
{
|
|
||||||
//Prepare Menu Data
|
//Prepare Menu Data
|
||||||
//Category Menu Item
|
//Category Menu Item
|
||||||
if ($type == 'categories')
|
if ( $type == 'categories' ) {
|
||||||
{
|
|
||||||
$link = get_category_link($sub_item->cat_ID);
|
$link = get_category_link($sub_item->cat_ID);
|
||||||
$title = htmlentities($sub_item->cat_name);
|
$title = htmlentities($sub_item->cat_name);
|
||||||
$parent_id = $sub_item->category_parent;
|
$parent_id = $sub_item->category_parent;
|
||||||
|
@ -945,8 +862,7 @@ function get_children_menu_elements($childof, $intCounter, $parentli, $type, $me
|
||||||
$appendtype= 'Category';
|
$appendtype= 'Category';
|
||||||
}
|
}
|
||||||
//Page Menu Item
|
//Page Menu Item
|
||||||
elseif ($type == 'pages')
|
elseif ( $type == 'pages' ) {
|
||||||
{
|
|
||||||
$link = get_permalink($sub_item->ID);
|
$link = get_permalink($sub_item->ID);
|
||||||
$title = htmlentities($sub_item->post_title);
|
$title = htmlentities($sub_item->post_title);
|
||||||
$parent_id = $sub_item->post_parent;
|
$parent_id = $sub_item->post_parent;
|
||||||
|
@ -955,8 +871,7 @@ function get_children_menu_elements($childof, $intCounter, $parentli, $type, $me
|
||||||
$appendtype= 'Page';
|
$appendtype= 'Page';
|
||||||
}
|
}
|
||||||
//Custom Menu Item
|
//Custom Menu Item
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$title = '';
|
$title = '';
|
||||||
$linktype = 'custom';
|
$linktype = 'custom';
|
||||||
$appendtype= 'Custom';
|
$appendtype= 'Custom';
|
||||||
|
@ -967,8 +882,7 @@ function get_children_menu_elements($childof, $intCounter, $parentli, $type, $me
|
||||||
$wp_result = $wpdb->get_results("SELECT id FROM ".$table_name." WHERE post_id='".$parent_id."' AND link_type='".$linktype."' AND menu_id='".$menu_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)) {
|
if ($wp_result > 0 && isset($wp_result[0]->id)) {
|
||||||
$parent_id = $wp_result[0]->id;
|
$parent_id = $wp_result[0]->id;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
//$parent_id = 0;
|
//$parent_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -979,14 +893,9 @@ function get_children_menu_elements($childof, $intCounter, $parentli, $type, $me
|
||||||
$counter++;
|
$counter++;
|
||||||
$counter = get_children_menu_elements($itemid, $counter, $parent_id, $type, $menu_id, $table_name);
|
$counter = get_children_menu_elements($itemid, $counter, $parent_id, $type, $menu_id, $table_name);
|
||||||
}
|
}
|
||||||
//Do nothing
|
|
||||||
else {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $counter;
|
return $counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue