Members only area implementation. Testing sidemenu
authorLaury GvR <laury@gaslightmedia.com>
Fri, 29 Jul 2016 15:13:43 +0000 (11:13 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Fri, 29 Jul 2016 15:13:43 +0000 (11:13 -0400)
Members only link and partials added. Members only sidemenu needs
to be tested on dev55.

functions.php
glm-members-only-template.php [new file with mode: 0644]
parts/glm-members-only-login-form.php [new file with mode: 0644]
parts/glm-members-only-lostpass-form.php [new file with mode: 0644]
parts/glm-members-only-top-bar.php [new file with mode: 0644]
parts/members-sidebar.php [new file with mode: 0644]

index ac48333..ed7351a 100644 (file)
@@ -78,6 +78,61 @@ function glm_site_scripts()
 
 }
 
+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 <a>
+            'after' => '',                                  // after each link </a>
+            '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[^>]*>(.*)<\/a>/iU', '<label>$1</label>', $item_html );
+        }
+
+        $output .= $item_html;
+    }
+
+    function start_lvl( &$output, $depth = 0, $args = array() ) {
+        $output .= "\n<ul class=\"children\">\n";
+    }
+
+    function end_lvl(&$output, $depth = 0, $args = array()){
+        $output .= '</ul>';
+    }
+
+}
+endif;
 
 /* Header for posts*/
 function glm_get_header() {
diff --git a/glm-members-only-template.php b/glm-members-only-template.php
new file mode 100644 (file)
index 0000000..b883f8e
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+/*
+Template Name: GLM Members Only Template
+*/
+?>
+<?php get_header(); ?>
+<main class="page-inside">
+    <?php if (is_page("kitchensink")) {
+        get_template_part('parts/glm-kitchen-sink');
+    } else { ?>
+        <div id="content-wrapper">
+            <?php echo glm_get_featured(); ?>
+            <div id="crumb-line">
+                <div class="row">
+                    <?php
+                    get_template_part('parts/bread-crumbs');
+                    ?>
+                </div>
+            </div>
+
+            <div id="members-only-content" class="row">
+                <div id="side-links" class="show-for-large-up left medium-4 columns">
+                    <?php get_template_part('parts/members-sidebar');?>
+                </div>
+                <div id="main-content" class="small-8 columns">
+                    <?php if (current_user_can("glm_members_member")) { ?>
+                        <!-- If user is logged in as a member, display top bar, bread crumbs, & content -->
+                        <?php get_template_part('parts/glm-members-only-top-bar'); ?>
+                        <?php get_template_part('parts/content-section'); ?>
+                    <?php } else if (get_the_ID() == get_option("glm_members_database_option_members_only_id")) {?>
+                        <!-- Otherwise, if it's the main members only page, display content & form -->
+
+                        <?php get_template_part('parts/glm-members-only-login-form'); ?>
+                    <?php } else { ?>
+                        <!-- Otherwise, display main members only page content & form -->
+                        <?php echo get_post_page_content(get_option("glm_members_database_option_members_only_id")); ?>
+                        <?php get_template_part('parts/glm-members-only-login-form'); ?>
+                    <?php } ?>
+                </div>
+            </div>
+
+        </div>
+    <?php } ?>
+<?php get_footer(); ?>
diff --git a/parts/glm-members-only-login-form.php b/parts/glm-members-only-login-form.php
new file mode 100644 (file)
index 0000000..f8cf1fe
--- /dev/null
@@ -0,0 +1,21 @@
+                        <div class="wp_login_error">
+                            <?php $glmAssociateTerms = apply_filters('glm_associate_terms');?>
+                            <p id="glm-member-login-notification">
+                                <?php if( isset( $_GET['login'] ) && $_GET['login'] == 'failed' ) { ?>
+                                    The information you entered is incorrect. Please try again.
+                                <?php } 
+                                else if( isset( $_GET['login'] ) && $_GET['login'] == 'empty' ) { ?>
+                                    Please enter both username and password.
+                                <?php } else { ?>    
+                                Please log in with your <?php echo $glmAssociateTerms['term_member']; ?> username and password.
+                                <br>If you need assistance, email (xxxxx@yyyy.zzz) or call (###-###-####)
+                                <?php } ?>
+                            </p>
+                        </div> 
+                        <div id='glm-member-login-form'>
+                            <?php 
+                                update_option('glm_members_database_frontend_login_request', 'true');
+                                wp_login_form(1, get_permalink()); 
+                                ?>
+                        </div>
+                        <?php get_template_part('parts/glm-members-only-lostpass-form'); ?>
\ No newline at end of file
diff --git a/parts/glm-members-only-lostpass-form.php b/parts/glm-members-only-lostpass-form.php
new file mode 100644 (file)
index 0000000..296b1dd
--- /dev/null
@@ -0,0 +1,25 @@
+
+                        <a id="glm-member-password-lost-link" title="Lost Password">Lost Password?</a>
+                        <div id="glm-member-password-lost-form">
+
+                            <p>
+                                <?php
+                                    _e(
+                                        "Enter your email address and we'll send you a link you can use to pick a new password.",
+                                        'personalize_login'
+                                    );
+                                ?>
+                            </p>
+
+                            <form id="lostpasswordform" action="<?php echo wp_lostpassword_url(); ?>" method="post">
+                                <p class="form-row">
+                                    <label for="user_login"><?php _e( 'Email', 'personalize-login' ); ?>
+                                    <input type="text" name="user_login" id="user_login">
+                                </p>
+
+                                <p class="lostpassword-submit">
+                                    <input type="submit" name="submit" class="lostpassword-button"
+                                           value="<?php _e( 'Reset Password', 'personalize-login' ); ?>"/>
+                                </p>
+                            </form>
+                        </div>
\ No newline at end of file
diff --git a/parts/glm-members-only-top-bar.php b/parts/glm-members-only-top-bar.php
new file mode 100644 (file)
index 0000000..bb67f35
--- /dev/null
@@ -0,0 +1,8 @@
+<div id="glm-member-front-header" class="small-12 columns">
+    <div class='glm-member-greeting'>Hello,     <?php $current_user = wp_get_current_user();echo $current_user->user_login ?>.</div>
+    <a class='button glm-button' href="<?php echo wp_logout_url( home_url() ); ?>">Logout</a>
+    <?php if (current_user_can("glm_members_member")) { ?>
+        <?php apply_filters('glm_associate_terms', $glmAssociateTerms);?>
+        <a class='button glm-button' href='<?php echo get_admin_url() ?>admin.php?page=glm-members-admin-menu-member'>Enter <?php echo $glmAssociateTerms['term_member_cap']; ?> Admin Area</a>                        
+    <?php } ?>
+</div>
\ No newline at end of file
diff --git a/parts/members-sidebar.php b/parts/members-sidebar.php
new file mode 100644 (file)
index 0000000..da2e5a7
--- /dev/null
@@ -0,0 +1,9 @@
+<div id="menu-side" class="row collapse">
+    <?php if (is_in_tree(get_option("glm_members_database_option_members_only_id"))) { ?>
+        <h2> Members Only Area </h2>
+        <?php // glm_side_menu(); ?>
+        <?php if (current_user_can("glm_members_member")) { ?>
+            <?php glm_members_only_menu(); ?>
+        <?php } ?>
+    <?php } ?>
+</div>
\ No newline at end of file