From 4dd18e8aa62646f8298d09dbe1c93c6ea3d2e8a2 Mon Sep 17 00:00:00 2001 From: Laury GvR Date: Fri, 8 Jul 2016 12:53:30 -0400 Subject: [PATCH] Members only section apply_filters fixed --- functions.php | 98 +++++++++++++++++++++++------- parts/glm-members-only-top-bar.php | 2 +- parts/members-sidebar.php | 6 +- 3 files changed, 82 insertions(+), 24 deletions(-) diff --git a/functions.php b/functions.php index 7467c8a..0edaabb 100644 --- a/functions.php +++ b/functions.php @@ -42,7 +42,6 @@ function glm_get_menu_options() register_nav_menus(array( 'top-bar' => 'Site Navigation', - 'members-side-menu' => 'Members Side Menu', //'mobile-off-canvas' => 'Mobile', 'footer' => 'Footer' )); @@ -190,26 +189,6 @@ class Mountpleasantcvb_Offcanvas_Walker extends Walker_Nav_Menu { } endif; -if ( ! function_exists( 'mountpleasantcvb_members_side_menu' ) ) { - function mountpleasantcvb_members_side_menu() { - wp_nav_menu(array( - 'container' => false, // remove nav container - 'container_class' => '', // class of container - 'menu' => '', // menu name - 'menu_class' => 'members-side-menu', // adding custom nav class - 'theme_location' => 'members-side-menu', // where it's located in the theme - 'before' => '', // before each link - 'after' => '', // after each link - 'link_before' => '', // before each link text - 'link_after' => '', // after each link text - 'depth' => 5, // limit the depth of the nav - 'fallback_cb' => false, // fallback function (see below) - 'items_wrap' => '%3$s', - 'walker' => new Mountpleasantcvb_Offcanvas_Walker() - )); - echo ''; - } -} /** * glm_page_menu * @@ -320,6 +299,83 @@ function glm_site_scripts() } + +/* + * This function returns true when the current page is the page given by ID + * or a descendent thereof. + */ +if (!function_exists('is_in_tree')) { + function is_in_tree( $pid ) { + global $post; + if ( is_page($pid) ) { + return true; + } + $anc = get_post_ancestors( $post->ID ); + foreach ( $anc as $ancestor ) { + if( is_page() && $ancestor == $pid ) { + return true; + } + } + return false; + } +} + +if ( ! function_exists( 'glm_members_only_menu')) { + function glm_members_only_menu() { + wp_nav_menu(array( + 'container' => false, // remove nav container + 'container_class' => 'members-only-menu', // class of container + 'menu' => '', // menu name + 'menu_class' => 'members-only-menu', // adding custom nav class + 'theme_location' => 'members-only-menu', // where it's located in the theme + 'before' => '', // before each link + 'after' => '', // after each link + 'link_before' => '', // before each link text + 'link_after' => '', // after each link text + 'depth' => 2, // limit the depth of the nav + 'fallback_cb' => false, // fallback function (see below) + 'items_wrap' => '%3$s', + 'walker' => new GLM_Members_Only_Walker() + )); + } +} + +if ( ! class_exists( 'GLM_Members_Only_Walker' ) ) : +class GLM_Members_Only_Walker extends Walker_Nav_Menu { + + function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) { + $element->has_children = ! empty( $children_elements[ $element->ID ] ); + $element->classes[] = ( $element->current || $element->current_item_ancestor ) ? 'active' : ''; + $element->classes[] = ( $element->has_children && 1 !== $max_depth ) ? 'page_item_has_children' : ''; + $element->classes[] = 'page_item'; + + parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); + } + + function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) { + $item_html = ''; + parent::start_el( $item_html, $object, $depth, $args ); + + $classes = empty( $object->classes ) ? array() : (array) $object->classes; + + if ( in_array( 'label', $classes ) ) { + $item_html = preg_replace( '/]*>(.*)<\/a>/iU', '', $item_html ); + } + + $output .= $item_html; + } + + function start_lvl( &$output, $depth = 0, $args = array() ) { + $output .= "\n'; + } + +} +endif; + function is_post_type($type){ global $wp_query; if($type == get_post_type($wp_query->post->ID)) return true; diff --git a/parts/glm-members-only-top-bar.php b/parts/glm-members-only-top-bar.php index f9ad26c..bb67f35 100644 --- a/parts/glm-members-only-top-bar.php +++ b/parts/glm-members-only-top-bar.php @@ -2,7 +2,7 @@
Hello, user_login ?>.
Logout - + Enter Admin Area \ No newline at end of file diff --git a/parts/members-sidebar.php b/parts/members-sidebar.php index 4b56112..da2e5a7 100644 --- a/parts/members-sidebar.php +++ b/parts/members-sidebar.php @@ -1,7 +1,9 @@ \ No newline at end of file -- 2.17.1