function f6_topbar_menu_fallback($args) { /* * Instantiate new Page Walker class instead of applying a filter to the * "wp_page_menu" function in the event there are multiple active menus in theme. */ $walker_page = new Walker_Page(); $fallback = $walker_page->walk(get_pages(), 0); $fallback = str_replace("<ul class='children'>", '<ul class="children submenu menu vertical" data-submenu>', $fallback); echo '<ul class="dropdown menu" data-dropdown-menu">' . $fallback . '</ul>'; }
function f6_drill_menu_fallback($args) { /* * Instantiate new Page Walker class instead of applying a filter to the * "wp_page_menu" function in the event there are multiple active menus in theme. */ $walker_page = new Walker_Page(); $fallback = $walker_page->walk(get_pages(), 0); $fallback = str_replace("children", "children vertical menu", $fallback); echo '<ul class="vertical menu" data-drilldown="">' . $fallback . '</ul>'; }
/** * This is effectively a wrapper for the default method, dynamically adding * and removing the class filter when the current item has children. */ function start_el(&$output, $page, $depth, $args, $current_page) { if (!empty($args['has_children'])) { add_filter('page_css_class', array(&$this, '_filterClass')); } parent::start_el($output, $page, $depth, $args, $current_page); if (!empty($args['has_children'])) { remove_filter('page_css_class', array(&$this, '_filterClass')); } }
/** * @see Walker_Page::start_el() * @since 1.3.0 * * @param string $output Passed by reference. Used to append additional content. * @param object $page Page data object. * @param int $depth Depth of page. Used for padding. * @param int $current_page Page ID. * @param array $args */ public function start_el(&$output, $page, $depth = 0, $args = array(), $current_page = 0) { $current_character = strtolower(substr($page->post_title, 0, 1)); if ($depth === 0 && $current_character !== $this->last_character) { $output .= "<li class=\"jc-list-anchor\" id=\"jc-list-anchor-{$current_character}\">"; $output .= strtoupper($current_character); $output .= '</li>'; $this->last_character = $current_character; } parent::start_el($output, $page, $depth, $args, $current_page); }
function start_el(&$output, $page, $depth = 0, $args = array(), $current_page = 0) { $item_html = ''; parent::start_el($item_html, $page, $depth, $args, $current_page); $css_class = array('page_item', 'page-item-' . $page->ID); if ($args['has_children']) { $css_class[] = 'has-dropdown'; } $css_class = implode(' ', apply_filters('page_css_class', $css_class, $page, $depth, $args, $current_page)); $item_html = '<li class="' . $css_class . '"><a href="' . get_permalink($page->ID) . '">' . apply_filters('the_title', $page->post_title, $page->ID) . '</a>'; $output .= $item_html; }
/** * [start_el description] * * @param [type] $output [description] * @param [type] $item [description] * @param integer $depth [description] * @param array $args [description] * @return [type] [description] */ function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { $item_html = ''; parent::start_el($item_html, $item, $depth, $args); $output .= $depth == 0 ? '<li class="divider"></li>' : ''; $classes = empty($item->classes) ? array() : (array) $item->classes; if (in_array('label', $classes)) { $output .= '<li class="divider"></li>'; $item_html = preg_replace('/<a[^>]*>(.*)<\\/a>/iU', '<label>$1</label>', $item_html); } if (in_array('divider', $classes)) { $item_html = preg_replace('/<a[^>]*>( .* )<\\/a>/iU', '', $item_html); } $output .= $item_html; }
/** * Traverse elements to create list from elements. * * Calls parent function in wp-includes/class-wp-walker.php */ function display_element($element, &$children_elements, $max_depth, $depth = 0, $args, &$output) { if (!$element) { return; } //Add indicators for top level menu items with submenus $id_field = $this->db_fields['id']; if (!empty($children_elements[$element->{$id_field}])) { $this->dt_menu_parents[] = $element->{$id_field}; } parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output); }
public function start_el(&$output, $page, $depth = 0, $args = array(), $current_page = 0) { $letter = substr($page->post_title, 0, 1); if ($letter != $this->current_letter) { $cb_args = array_merge(array(&$output, $depth), $args); call_user_func_array(array($this, 'end_lvl'), $cb_args); call_user_func_array(array($this, 'start_lvl'), $cb_args); $this->current_letter = $letter; } parent::start_el($output, $page, $depth, $args, $current_page); }
function start_el(&$output, $page, $depth = 0, $args = array(), $current_page = 0) { $item_html = ''; //since the &$output is passed by reference, it will modify the value on the fly based on the parent method treatment //we just have to make some additional treatments afterwards parent::start_el($item_html, $page, $depth, $args, $current_page); if ($args['has_children']) { //makes top menu not clickable (default bootstrap behaviour) $search = '<a'; $replace = !wp_is_mobile() && 'hover' == esc_attr(TC_utils::$inst->tc_opt('tc_menu_type')) ? $search : '<a class="dropdown-toggle" data-toggle="dropdown" data-target="#"'; $replace .= strpos($item_html, 'href=') ? '' : ' href="#"'; $replace = apply_filters('tc_menu_open_on_click', $replace, $search); $item_html = str_replace($search, $replace, $item_html); //adds arrows down if ($depth === 0) { $item_html = str_replace('</a>', ' <strong class="caret"></strong></a>', $item_html); } } elseif (stristr($item_html, 'li class="divider')) { $item_html = preg_replace('/<a[^>]*>.*?<\\/a>/iU', '', $item_html); } elseif (stristr($item_html, 'li class="nav-header')) { $item_html = preg_replace('/<a[^>]*>(.*)<\\/a>/iU', '$1', $item_html); } $output .= $item_html; }
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 __construct($options = array()) { if (method_exists('Walker_Page', '__construct')) { parent::__construct(); } }