Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: v2.0.1
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 209 lines (209 sloc) 6.779 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
<?php
/**
* Site Navigation Template Part
*
* Template part file that contains the site header navigation
* menu.
*
* By default, this neader navigation will output
* the list of top-level static Pages, and depending
* on the 'header_nav_menu_depth' setting, up to two
* additional levels of Page hierarchy. The default menu
* is incredibly flexible and powerful, because it updates
* dynamically whenever the user changes Page hierarchy,
* by adding or removing Pages, or by changing the
* child-parent relationship for Pages.
*
* However, users can override this menu output by
* creating a custom navigation menu, and assigning it
* to the 'nav-sidebar' Theme location.
*
* This file is called by all primary template pages
*
* @link http://codex.wordpress.org/Function_Reference/get_option get_option()
* @link http://codex.wordpress.org/Function_Reference/get_permalink get_permalink()
* @link http://codex.wordpress.org/Function_Reference/has_nav_menu has_nav_menu()
* @link http://codex.wordpress.org/Function_Reference/home_url home_url()
* @link http://codex.wordpress.org/Function_Reference/is_front_page is_front_page()
* @link http://codex.wordpress.org/Function_Reference/is_home is_home()
* @link http://codex.wordpress.org/Function_Reference/wp_list_pages wp_list_pages()
* @link http://codex.wordpress.org/Function_Reference/wp_nav_menu wp_nav_menu()
*
* @package Oenology
* @copyright Copyright (c) 2010, Chip Bennett
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License, v2 (or newer)
*
* @since Oenology 1.0
*/
?>
<?php
/**
* Global variable that contains the
* Theme's options array.
*
* @global array $oenology_options
*/
global $oenology_options;
/**
* Output the header navigation menu
*
* If the user has defined a custom navigation menu
* and has applied that menu to the 'nav-header'
* theme location, then output that menu. Otherwise,
* output a list of Pages.
*
* The menu displays only top-level menu items or
* top-level Pages by default; however, dropdown
* menus up to an additional two levels of
* hierarchy can be displayed, using the appropriate
* Theme setting.
*
* NOTE: list items are set to overflow:hidden.
* Long page titles will be cut off, but the full
* Page Title will display in the tooltip
*/
if (
/**
* WordPress conditional tag that returns true if
* the user has applied a custom navigation menu
* to the specified theme location
*/
has_nav_menu( 'nav-header' )
) {
/**
* Output a custom navigation menu
*
* Output a custom navigation menu
* according to the parameters
* specified by the options array
*
* @param array options defining menu output
*/
wp_nav_menu( array(
// apply 'id="nav"' to the <ul> tag that
// contains the menu
'menu_id' => 'nav',
// apply 'class="nav-header"' to the <ul>
// tag that contains the menu
'menu_class' => 'nav-header',
// Use the default fallback if the user has
// not applied a menu to the specified theme
// location
'fallback_cb' => '',
// Apply hierarchical depth per the Theme
// setting 'header_nav_menu_depth'
'depth' => $oenology_options['header_nav_menu_depth'],
// Output the menu the user has applied to
// the 'nav-header' Theme Location
'theme_location' => 'nav-header'
) );
} else {
/**
* Otherwise, if the user has not applied a
* menu to the 'nav-header' Theme location,
* output a list of static Pages.
*/
?>
<ul id="nav" class="nav-header">
<?php
/**
* If posts, and not a static page, are being used
* as the site home page, display a link to HOME.
*/
if (
/**
* Returns true if the Front Page is set to
* display the Blog Posts Index
*/
'posts' == get_option( 'show_on_front' )
) {
$list_pages_exclude = '';
?>
<li><a id="navhome" href="<?php echo home_url(); ?>">Home</a></li>
<?php
} else {
// By default, do not exclude any
// static Pages
$list_pages_exclude = '';
// Determine if a static Page is
// currently set to display the
// site Front Page
$page_on_front = ( get_option( 'page_on_front' ) ? get_option( 'page_on_front' ) : false );
// Determine if a static Page is
// currently set to display the
// Blog Posts index
$page_for_posts = ( get_option( 'page_for_posts' ) ? get_option( 'page_for_posts' ) : false );
// If static Pages are set to
// display both the Front Page
// and the Blog Posts Index
if ( $page_on_front && $page_for_posts ) {
// Exclude both static Pages from
// the 'wp_list_pages()'
$list_pages_exclude = $page_on_front . ',' . $page_for_posts;
}
// Otherwise, if a static Page
// is set to display the site
// Front page
else if ( $page_on_front ) {
// Exclude this static Page from
// the 'wp_list_pages()'
$list_pages_exclude = $page_on_front;
}
// Otherwise, if a static Page
// is set to display the Blog
// Posts Index
else if ( $page_for_posts ) {
// Exclude this static Page from
// the 'wp_list_pages()'
$list_pages_exclude = $page_for_posts;
}
/**
* If a static Page is set to display the site
* Front Page, output a link to the Front Page
*/
if ( $page_on_front ) {
?>
<li class="page_item<?php if ( is_front_page() ) echo ' current_page_item'; ?>"><a href="<?php echo home_url(); ?>"><?php echo get_the_title( $page_on_front ); ?></a></li>
<?php
}
/**
* If a static Page is set to display the Blog
* Posts Index, output a link to the Blog Posts
* Index
*/
if ( $page_for_posts ) {
?>
<li class="page_item<?php if ( is_home() ) echo ' current_page_item'; ?>"><a href="<?php echo get_permalink( $page_for_posts ); ?>"><?php echo get_the_title( $page_for_posts ); ?></a></li>
<?php
}
}
/**
* Output a list of static Pages
*
* Output a custom navigation menu
* according to the parameters
* specified by the options array
*
* @param array options defining menu output
*/
wp_list_pages( array(
// Display levels of Page hierarchy (i.e. levels
// of child pages) as specified by Theme setting
// 'header_nav_menu_depth'
'depth' => $oenology_options['header_nav_menu_depth'],
// Sort pages as defined by the user
// in the Pages administration panel
'sort_column' => 'menu_order',
// Do not wrap list in <ul> tags, and
// do not give the menu a title <li>
'title_li' => '',
// Exclude static Pages used for the Front Page
// and for the Blog Posts Index, as these are
// added explicitly already, if they exist
'exclude' => $list_pages_exclude
) );
?>
</ul>
<?php
}
?>
Something went wrong with that request. Please try again.