/** * 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; }
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; }