More output consolidation. see #11817
git-svn-id: http://svn.automattic.com/wordpress/trunk@13336 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b92bce7e7f
commit
e35199deb6
|
@ -136,6 +136,7 @@ function setup_menu_item($menu_item, $type = 'item', $position = 0) {
|
|||
if ( $menu_item->ID == $wp_query->get_queried_object_id() )
|
||||
$menu_item->li_class = 'class="current_page_item"';
|
||||
|
||||
$menu_item->anchor_title = '';
|
||||
/* @todo: update to use tax/post data
|
||||
|
||||
//SET anchor title
|
||||
|
@ -163,7 +164,7 @@ function setup_menu_item($menu_item, $type = 'item', $position = 0) {
|
|||
return $menu_item;
|
||||
}
|
||||
|
||||
function output_menu_item($menu_item, $context) {
|
||||
function output_menu_item($menu_item, $context, $args = array() ) {
|
||||
switch( $context ) {
|
||||
case 'backend':
|
||||
case 'menu':
|
||||
|
@ -195,6 +196,44 @@ function output_menu_item($menu_item, $context) {
|
|||
<input type="hidden" name="linktype<?php echo $menu_item->menu_order; ?>" id="linktype<?php echo $menu_item->menu_order; ?>" value="<?php echo $menu_item->type; ?>" />
|
||||
<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
|
||||
break;
|
||||
|
||||
case 'frontend':
|
||||
// Override for menu descriptions
|
||||
$advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options');
|
||||
if ( $advanced_option_descriptions == 'no' )
|
||||
$args['desc'] = 2;
|
||||
?>
|
||||
<a title="<?php echo $menu_item->anchor_title; ?>" href="<?php echo $menu_item->link; ?>" <?php echo $menu_item->target; ?>><?php echo $args['before_title'] . $menu_item->title . $args['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 ( ($args['desc'] == 1) || ($args['desc'] == 0) ) {
|
||||
?><span class="nav-description"><?php echo $menu_item->description; ?></span><?php
|
||||
}
|
||||
} else {
|
||||
// 2 widget override do NOT display descriptions
|
||||
// 1 widget override display descriptions
|
||||
// 0 widget override not set
|
||||
if ( $args['desc'] == 1 ) {
|
||||
?><span class="nav-description"><?php echo $menu_item->description; ?></span><?php
|
||||
}
|
||||
}
|
||||
?></a>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'default':
|
||||
?>
|
||||
<dl>
|
||||
<dt>
|
||||
|
||||
<?php $templatedir = get_bloginfo('url'); ?>
|
||||
<span class="title"><?php echo $menu_item->title; ?></span> <a onclick="appendToList('<?php echo $templatedir; ?>','<?php echo $menu_item->append; ?>','<?php echo $menu_item->title; ?>','<?php echo $menu_item->link; ?>','<?php echo $menu_item->ID; ?>','<?php echo $menu_item->parent_item ?>','<?php echo $menu_item->description; ?>')" name="<?php echo $menu_item->title; ?>" value="<?php echo $menu_item->link; ?>"><img alt="<?php esc_attr_e('Add to Custom Menu'); ?>" title="<?php esc_attr_e('Add to Custom Menu'); ?>" src="<?php echo admin_url('images/ico-add.png'); ?>" /></a> </dt>
|
||||
</dl>
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
|
@ -227,10 +266,6 @@ function wp_custom_navigation_output( $args = array() ) {
|
|||
|
||||
$menu_objects = get_objects_in_term( $id, 'nav_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;
|
||||
|
||||
$parent_stack = array();
|
||||
$current_parent = 0;
|
||||
|
@ -245,31 +280,7 @@ function wp_custom_navigation_output( $args = array() ) {
|
|||
$menu_item = setup_menu_item($menu_item);
|
||||
// List Items
|
||||
?><li id="menu-<?php echo $menu_item->ID; ?>" value="<?php echo $menu_item->ID; ?>" <?php echo $menu_item->li_class; ?>><?php
|
||||
//@todo: update front end to use post data
|
||||
//FRONTEND Link
|
||||
if ( $type == 'frontend' ) {
|
||||
?><a title="<?php echo $menu_item->anchor_title; ?>" href="<?php echo $menu_item->link; ?>" <?php echo $menu_item->target; ?>><?php echo $before_title.$menu_item->title.$after_title; ?><?php
|
||||
|
||||
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 $menu_item->description; ?></span><?php
|
||||
}
|
||||
} 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 $menu_item->description; ?></span><?php
|
||||
}
|
||||
}
|
||||
|
||||
?></a><?php
|
||||
} elseif ( $type == 'backend' ) {
|
||||
output_menu_item($menu_item, 'backend');
|
||||
}
|
||||
output_menu_item($menu_item, $type, $args);
|
||||
// Indent children
|
||||
$last_item = ( count( $menu_items ) == $menu_item->menu_order );
|
||||
if ( $last_item || $current_parent != $menu_items[ $key + 1 ]->post_parent ) {
|
||||
|
|
|
@ -1044,8 +1044,8 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
|
|||
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);
|
||||
$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) {
|
||||
|
@ -1059,56 +1059,39 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
|
|||
$navulid = $instance['navulid'];
|
||||
$navulclass = $instance['navulclass'];
|
||||
|
||||
//Override for menu descriptions
|
||||
// Override for menu descriptions
|
||||
$advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options');
|
||||
if ($advanced_option_descriptions == 'no')
|
||||
{
|
||||
if ( $advanced_option_descriptions == 'no' ) {
|
||||
$navwidgetdescription = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
} 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;
|
||||
// GET menu name
|
||||
if ( $navmenu > 0 ) {
|
||||
$custom_menu = get_term( (int) $nav_menu, 'nav_menu' );
|
||||
$wp_custom_nav_menu_name = $custom_menu->name;
|
||||
$menuexists = true;
|
||||
}
|
||||
//Do nothing
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$menuexists = false;
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
//DEVELOPER settings enabled
|
||||
if ($navdeveloper == 'yes')
|
||||
{
|
||||
if ( $navdeveloper == 'yes' ) {
|
||||
//DISPLAY Custom DIV
|
||||
if ($navdiv == 'yes')
|
||||
{
|
||||
if ( $navdiv == 'yes' ) {
|
||||
?>
|
||||
<div id="<?php echo $navdivid; ?>" class="<?php echo $navdivclass; ?>">
|
||||
<?php
|
||||
}
|
||||
//Do NOT display DIV
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//DISPLAY default DIV
|
||||
else
|
||||
{
|
||||
else {
|
||||
?>
|
||||
<div class="widget">
|
||||
<?php
|
||||
|
@ -1118,31 +1101,21 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
|
|||
<h3><?php echo $navtitle; ?></h3>
|
||||
<?php
|
||||
|
||||
if ($menuexists)
|
||||
{
|
||||
if ( $menuexists ) {
|
||||
?>
|
||||
<?php
|
||||
|
||||
//DEVELOPER settings enabled
|
||||
if ($navdeveloper == 'yes')
|
||||
{
|
||||
if ( $navdeveloper == 'yes' ) {
|
||||
//DISPLAY Custom UL
|
||||
if ($navul == 'yes')
|
||||
{
|
||||
if ( $navul == 'yes' ) {
|
||||
?>
|
||||
<ul id="<?php echo $navulid; ?>" class="<?php echo $navulclass; ?>">
|
||||
<?php
|
||||
}
|
||||
//Do NOT display UL
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//DISPLAY default UL
|
||||
else
|
||||
{
|
||||
else {
|
||||
?>
|
||||
<ul class="custom-nav">
|
||||
<?php
|
||||
|
@ -1152,33 +1125,23 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
|
|||
|
||||
<?php
|
||||
//DISPLAY custom navigation menu
|
||||
if (get_option('wp_custom_nav_menu') == 'true') {
|
||||
custom_nav('name='.$wp_custom_nav_menu_name.'&desc='.$navwidgetdescription);
|
||||
}
|
||||
if ( get_option('wp_custom_nav_menu') == 'true' )
|
||||
custom_nav( array('id' => $navmenu, 'name' => $wp_custom_nav_menu_name, 'desc' => $navwidgetdescription) );
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
//DEVELOPER settings enabled
|
||||
if ($navdeveloper == 'yes')
|
||||
{
|
||||
if ( $navdeveloper == 'yes' ) {
|
||||
//DISPLAY Custom UL
|
||||
if ($navul == 'yes')
|
||||
{
|
||||
if ( $navul == 'yes' ) {
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
}
|
||||
//Do NOT display UL
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//DISPLAY default UL
|
||||
else
|
||||
{
|
||||
else {
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
|
@ -1186,16 +1149,13 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
|
|||
|
||||
?>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "You have not setup the custom navigation widget correctly, please check your settings in the backend.";
|
||||
} else {
|
||||
_e('You have not setup the custom navigation widget correctly, please check your settings in the backend.');
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
//DEVELOPER settings enabled
|
||||
if ($navdeveloper == 'yes')
|
||||
{
|
||||
if ($navdeveloper == 'yes') {
|
||||
//DISPLAY Custom DIV
|
||||
if ($navdiv == 'yes')
|
||||
{
|
||||
|
@ -1240,14 +1200,10 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
|
|||
|
||||
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)
|
||||
{
|
||||
// Get menus
|
||||
$custom_menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
|
||||
|
||||
if ( $custom_menus ) {
|
||||
?>
|
||||
|
||||
<p>
|
||||
|
@ -1257,16 +1213,14 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
|
|||
<?php
|
||||
|
||||
//DISPLAY SELECT OPTIONS
|
||||
foreach ($custom_menu_records as $custom_menu_record)
|
||||
{
|
||||
if ($navmenu == $custom_menu_record->id) {
|
||||
foreach ( $custom_menus as $menu ) {
|
||||
if ( $navmenu == $menu->term_id) {
|
||||
$selected_option = 'selected="selected"';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$selected_option = '';
|
||||
}
|
||||
?>
|
||||
<option value="<?php echo $custom_menu_record->id; ?>" <?php echo $selected_option; ?>><?php echo $custom_menu_record->menu_name; ?></option>
|
||||
<option value="<?php echo $menu->term_id; ?>" <?php echo $selected_option; ?>><?php echo $menu->name; ?></option>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
@ -1276,7 +1230,6 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
|
|||
</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>
|
||||
|
@ -1316,8 +1269,7 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
|
|||
|
||||
<?php
|
||||
|
||||
if ($checked == 'yes')
|
||||
{
|
||||
if ( $checked == 'yes' ) {
|
||||
|
||||
?>
|
||||
|
||||
|
|
Loading…
Reference in New Issue