Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!function_exists('pods_handle_menu')) {
- function pods_handle_menu ($menu_object) {
- $url = current(explode('#', current(explode('?', $_SERVER['REQUEST_URI']))));
- $depth = count(array_filter(explode('/', $url)));
- $url = get_bloginfo('wpurl') . $url;
- foreach ($menu_object as $key => $object) {
- $current_url = $object->url;
- $parsed_url = @parse_url($current_url);
- $current_depth = count(array_filter(explode('/', $parsed_url['path'])));
- if (get_bloginfo('wpurl') . '/' != $object->url && !in_array('current-menu-item', $object->classes) && $url == $object->url)
- $menu_object[$key]->classes[] = 'current-menu-item';
- if (get_bloginfo('wpurl') . '/' != $object->url && !in_array('current-menu-parent', $object->classes) && false !== strpos($url, $object->url) && 0 == strpos($url, $object->url) && $depth == ($current_depth+1))
- $menu_object[$key]->classes[] = 'current-menu-parent';
- if (get_bloginfo('wpurl') . '/' != $object->url && !in_array('current-menu-ancestor', $object->classes) && false !== strpos($url, $object->url) && 0 == strpos($url, $object->url))
- $menu_object[$key]->classes[] = 'current-menu-ancestor';
- }
- return $menu_object;
- }
- add_filter('wp_nav_menu_objects', 'pods_handle_menu', 10, 1);
- }
- if (!function_exists('pods_handle_list_pages')) {
- function pods_handle_list_pages ($output, $r) {
- global $post;
- $current_url = current(explode('#', current(explode('?', $_SERVER['REQUEST_URI']))));
- $real_post = $post;
- $depth = 0;
- $uri = array_filter(explode('/', $current_url));
- $url = get_bloginfo('wpurl') . '/' . implode('/', $uri) . '/';
- if (empty($real_post->ID) || $url != get_permalink($real_post->ID)) {
- $real_post->ID = 0;
- while(0 < strlen(array_pop($uri)) && empty($real_post->ID)) {
- $depth++;
- $url = get_bloginfo('wpurl') . '/' . implode('/', $uri) . '/';
- $real_post_ID = url_to_postid($url);
- if (0 < $real_post_ID && $url == get_permalink($real_post_ID)) {
- $real_post = get_post($real_post_ID);
- }
- }
- if (!function_exists('pixopoint_menu')) {
- if (0 < $real_post->ID) {
- if (0 == $depth) {
- $output = str_replace(' page-item-'. $real_post->ID . ' ', ' page-item-'. $real_post->ID . ' current_page_item ', $output);
- $output = str_replace(' page-item-'. $real_post->ID . '"', ' page-item-'. $real_post->ID . ' current_page_item"', $output);
- }
- elseif (1 == $depth) {
- $output = str_replace(' page-item-'. $real_post->ID . ' ', ' page-item-'. $real_post->ID . ' current_page_parent ', $output);
- $output = str_replace(' page-item-'. $real_post->ID . '"', ' page-item-'. $real_post->ID . ' current_page_parent"', $output);
- }
- elseif (2 <= $depth) {
- $output = str_replace(' page-item-'. $real_post->ID . ' ', ' page-item-'. $real_post->ID . ' current_page_ancestor ', $output);
- $output = str_replace(' page-item-'. $real_post->ID . '"', ' page-item-'. $real_post->ID . ' current_page_ancestor"', $output);
- }
- if (0 < $real_post->post_parent) {
- if (0 == $depth) {
- $output = str_replace(' page-item-'. $real_post->post_parent . ' ', ' page-item-'. $real_post->post_parent . ' current_page_parent ', $output);
- $output = str_replace(' page-item-'. $real_post->post_parent . '"', ' page-item-'. $real_post->post_parent . ' current_page_parent"', $output);
- }
- elseif (1 <= $depth) {
- $output = str_replace(' page-item-'. $real_post->post_parent . ' ', ' page-item-'. $real_post->post_parent . ' current_page_ancestor ', $output);
- $output = str_replace(' page-item-'. $real_post->post_parent . '"', ' page-item-'. $real_post->post_parent . ' current_page_ancestor"', $output);
- }
- if (!empty($real_post->ancestors)) {
- foreach ($real_post->ancestors as $ancestor) {
- $output = str_replace(' page-item-'. $ancestor . ' ', ' page-item-'. $ancestor . ' current_page_ancestor ', $output);
- $output = str_replace(' page-item-'. $ancestor . '"', ' page-item-'. $ancestor . ' current_page_ancestor"', $output);
- }
- }
- }
- }
- }
- }
- if (function_exists('pixopoint_menu')) {
- if (0 < $real_post->ID) {
- if (0 == $depth) {
- $output = str_replace(' page-item-'. $real_post->ID . ' ', ' page-item-'. $real_post->ID . ' current_page_item ', $output);
- $output = str_replace(' page-item-'. $real_post->ID . '"', ' page-item-'. $real_post->ID . ' current_page_item"', $output);
- }
- elseif (1 == $depth) {
- $output = str_replace(' page-item-'. $real_post->ID . ' ', ' page-item-'. $real_post->ID . ' current_page_parent ', $output);
- $output = str_replace(' page-item-'. $real_post->ID . '"', ' page-item-'. $real_post->ID . ' current_page_parent"', $output);
- }
- elseif (2 <= $depth) {
- $output = str_replace(' page-item-'. $real_post->ID . ' ', ' page-item-'. $real_post->ID . ' current_page_ancestor ', $output);
- $output = str_replace(' page-item-'. $real_post->ID . '"', ' page-item-'. $real_post->ID . ' current_page_ancestor"', $output);
- }
- if (0 < $real_post->post_parent) {
- if (0 == $depth) {
- $output = str_replace(' page-item-'. $real_post->post_parent . ' ', ' page-item-'. $real_post->post_parent . ' current_page_parent ', $output);
- $output = str_replace(' page-item-'. $real_post->post_parent . '"', ' page-item-'. $real_post->post_parent . ' current_page_parent"', $output);
- }
- elseif (1 <= $depth) {
- $output = str_replace(' page-item-'. $real_post->post_parent . ' ', ' page-item-'. $real_post->post_parent . ' current_page_ancestor ', $output);
- $output = str_replace(' page-item-'. $real_post->post_parent . '"', ' page-item-'. $real_post->post_parent . ' current_page_ancestor"', $output);
- }
- if (!empty($real_post->ancestors)) {
- foreach ($real_post->ancestors as $ancestor) {
- $output = str_replace(' page-item-'. $ancestor . ' ', ' page-item-'. $ancestor . ' current_page_ancestor ', $output);
- $output = str_replace(' page-item-'. $ancestor . '"', ' page-item-'. $ancestor . ' current_page_ancestor"', $output);
- }
- }
- }
- }
- }
- return $output;
- }
- add_filter('wp_list_pages', 'pods_handle_list_pages', 10, 2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement