From 714848440408f5282371bf313077f30c0d314b99 Mon Sep 17 00:00:00 2001 From: Laury GvR Date: Thu, 28 Apr 2016 15:08:18 -0400 Subject: [PATCH] Members Only-friendly theme updates --- css/app.css | 3 ++ functions.php | 38 +++++++++---------- ...plate.php => glm-members-only-template.php | 6 +-- lib/navigation.php | 11 ++++-- scss/_sidebar.scss | 5 +++ 5 files changed, 36 insertions(+), 27 deletions(-) rename sample-template.php => glm-members-only-template.php (94%) diff --git a/css/app.css b/css/app.css index 686ff93..677d63f 100644 --- a/css/app.css +++ b/css/app.css @@ -7465,6 +7465,9 @@ article { border-radius: 2px; padding: 0 10px; } +.members-only-template #side-links #menu-side h2 { + font-size: 26px; } + #side-links #menu-side { background: #2c296d; padding-top: 20px; diff --git a/functions.php b/functions.php index 291f455..52156df 100644 --- a/functions.php +++ b/functions.php @@ -146,20 +146,7 @@ function mytheme_search_loop() { ID ); - foreach ( $anc as $ancestor ) { - if( is_page() && $ancestor == $pid ) { - return true; - } - } - return false; -} add_action('thematic_searchloop', 'mytheme_search_loop'); // End of the Contextual/Highlight Search functions @@ -200,16 +187,25 @@ function remove_admin_bar() { show_admin_bar(false); } } -add_filter( 'template_include', 'portfolio_page_template', 99 ); -function portfolio_page_template( $template ) { - if ( is_tree(27) ) { // the members page for this site - $new_template = locate_template( array( 'sample-template.php' ) ); - if ( '' != $new_template ) { - return $new_template ; +/* + * 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; } - - return $template; } ?> diff --git a/sample-template.php b/glm-members-only-template.php similarity index 94% rename from sample-template.php rename to glm-members-only-template.php index a9fd506..20c907c 100644 --- a/sample-template.php +++ b/glm-members-only-template.php @@ -1,10 +1,10 @@ -
+
@@ -20,7 +20,7 @@ Template Name: Sample Template
Hello, user_login ?>.
- Logout + Logout Enter Member Admin Area diff --git a/lib/navigation.php b/lib/navigation.php index 076a0ef..69e299f 100644 --- a/lib/navigation.php +++ b/lib/navigation.php @@ -188,10 +188,15 @@ function glm_side_menu($mobile = false) { global $post; $sideMenu = $allMenu = $pageMenuId = array(); // do not use appearance menu for the following page ID's or their ancestors - if( !is_page(array(3200, 3201,3202,3203)) && !is_tree(3200) && !is_tree(3201) && !is_tree(3202) && !is_tree(3203)) { + //if( !is_page(array(3200, 3201,3202,3203)) && !is_in_tree(3200) && !is_in_tree(3201) && !is_in_tree(3202) && !is_in_tree(3203)) { + if (is_in_tree(get_option('glm_members_database_members_only_id'))) { + if (($locations = get_nav_menu_locations()) && isset($locations['members-only'])) { + $menu = wp_get_nav_menu_object($locations['members-only']); + } + } else if( !is_in_tree(3200) && !is_in_tree(3201) && !is_in_tree(3202) && !is_in_tree(3203)) { if (($locations = get_nav_menu_locations()) && isset($locations['top-bar'])) { - $menu = wp_get_nav_menu_object($locations['top-bar']); - } + $menu = wp_get_nav_menu_object($locations['top-bar']); + } } else { if (($locations = get_nav_menu_locations()) && isset($locations['top-links'])) { $menu = wp_get_nav_menu_object($locations['top-links']); diff --git a/scss/_sidebar.scss b/scss/_sidebar.scss index 20c9c5a..5e212e3 100644 --- a/scss/_sidebar.scss +++ b/scss/_sidebar.scss @@ -44,6 +44,11 @@ padding: 0 10px; } } +.members-only-template #side-links #menu-side { + h2 { + font-size: 26px; + } +} #side-links { #menu-side { background: $purple; -- 2.17.1