'',
'width' => 0,
'height' => 0,
'flex-width' => true,
'flex-height' => true,
'random-default' => false,
'header-text' => false,
'default-text-color' => '#000',
'uploads' => true,
);
add_theme_support( 'custom-header', $header_args );
}
// Hook into the 'after_setup_theme' action
add_action( 'after_setup_theme', '_sf_custom_header' );
endif; //! _sf_custom_header
/**
* Menu fallback. Shows a list of pages.
*/
if (! function_exists('_sf_menu_fallback') ) :
function _sf_menu_fallback( ) {
echo '';
wp_list_pages('title_li=&&depth=1');
echo '
';
}
endif; // ! _sf_menu_fallback exists
// Add Foundation 'active' class for the current menu item
if (! function_exists('_sf_active_nav_class') ) :
function _sf_active_nav_class( $classes, $item ) {
if ( $item->current == 1 || $item->current_item_ancestor == true ) {
$classes[] = 'active';
}
return $classes;
}
add_filter( 'nav_menu_css_class', '_sf_active_nav_class', 10, 2 );
endif; // ! _sf_active_nav_class exists
/**
* Use the active class of ZURB Foundation on wp_list_pages output.
* From required+ Foundation http://themes.required.ch
*/
if (function_exists('_sf_active_list_pages_class') ) :
function _sf_active_list_pages_class( $input ) {
$pattern = '/current_page_item/';
$replace = 'current_page_item active';
$output = preg_replace( $pattern, $replace, $input );
return $output;
}
add_filter( 'wp_list_pages', '_sf_active_list_pages_class', 10, 2 );
endif; // ! _sf_active_list_pages_class exists
/**
* class required_walker
* Custom output to enable the the ZURB Navigation style.
* Courtesy of Kriesi.at. http://www.kriesi.at/archives/improve-your-wordpress-navigation-menu-output
* From required+ Foundation http://themes.required.ch
*/
class _sf_walker extends Walker_Nav_Menu {
/**
* Specify the item type to allow different walkers
* @var array
*/
var $nav_bar = '';
function __construct( $nav_args = '' ) {
$defaults = array(
'item_type' => 'li',
'in_top_bar' => false,
);
$this->nav_bar = apply_filters( 'req_nav_args', wp_parse_args( $nav_args, $defaults ) );
}
function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) {
$id_field = $this->db_fields['id'];
if ( is_object( $args[0] ) ) {
$args[0]->has_children = ! empty( $children_elements[$element->$id_field] );
}
return parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
}
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
global $wp_query;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$classes[] = 'menu-item-' . $item->ID;
// Check for flyout
$flyout_toggle = '';
if ( $args->has_children && $this->nav_bar['item_type'] == 'li' ) {
if ( $depth == 0 && $this->nav_bar['in_top_bar'] == false ) {
$classes[] = 'has-flyout';
$flyout_toggle = '';
} else if ( $this->nav_bar['in_top_bar'] == true ) {
$classes[] = 'has-dropdown';
$flyout_toggle = '';
}
}
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
if ( $depth > 0 ) {
$output .= $indent . '' : '' ) . '<' . $this->nav_bar['item_type'] . ' id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
}
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
$item_output = $args->before;
$item_output .= '';
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
$item_output .= '';
$item_output .= $flyout_toggle; // Add possible flyout toggle
$item_output .= $args->after;
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
}
function end_el( &$output, $item, $depth = 0, $args = array() ) {
if ( $depth > 0 ) {
$output .= "\n";
} else {
$output .= "" . $this->nav_bar['item_type'] . ">\n";
}
}
function start_lvl( &$output, $depth = 0, $args = array() ) {
if ( $depth == 0 && $this->nav_bar['item_type'] == 'li' ) {
$indent = str_repeat("\t", 1);
$output .= $this->nav_bar['in_top_bar'] == true ? "\n$indent\n" : "\n$indent\n";
} else {
$indent = str_repeat("\t", $depth);
$output .= $this->nav_bar['in_top_bar'] == true ? "\n$indent