page creation fixed, view styles updated
authorlaury <laury@gaslightmedia.com>
Wed, 18 May 2016 18:35:56 +0000 (14:35 -0400)
committerlaury <laury@gaslightmedia.com>
Wed, 18 May 2016 18:35:56 +0000 (14:35 -0400)
classes/glmPluginSupport.php
controllers/admin.php
css/front.css
models/admin/management/index.php
setup/adminHooks.php
setup/frontHooks.php
views/admin/management/index.html
views/front/members/detail.html
views/front/members/list.html

index 4852a50..0dd64a7 100644 (file)
@@ -511,102 +511,102 @@ return; // Off for now ** Need to make this switchable in management
      *
      * @return void
      */
-//    public function createPages($requiredPages)
-//    {
-//        foreach($requiredPages as $requiredPage => $requiredPageInfo) {
-//            $trimmedName = GLM_MEMBERS_PLUGIN_OPTION_PREFIX.$requiredPageInfo['underscored_title'];
-//            if ($requiredPageInfo['parent'] == 'associate') {
-//                $postParent = get_option(GLM_MEMBERS_PLUGIN_OPTION_ASSOCIATE_ID);
-//            } else if ($requiredPageInfo['parent'] == 'membersonly') {
-//                $postParent = get_option(GLM_MEMBERS_PLUGIN_OPTION_MEMBERS_ONLY_ID);
-//            } else if (is_numeric($requiredPageInfo['parent'])) {
-//                $postParent = $requiredPageInfo['parent'];
-//            } else {
-//                $postParent = '0';
-//            }
-//            $existingPost = get_post(get_option($trimmedName));
-//            $newSlug = sanitize_title($requiredPageInfo['title']);
-//            $existingSlug = $this->verify_post_slug($newSlug);
-//
-//
-//            // If a post with the ID set in the option does not exist
-//            if ( !$existingPost) {
-//
-//                // If the new slug corresponds to an already existent page, yet the ID option does not exist,
-//                //  then it's either the first time this plugin is run on an outdated site or somehow the ID was
-//                //  deleted. Either way, replace the option value with whatever is the ID of the page matching
-//                //  that slug. The slug is checked by translating the page title.
-//                if ($newSlug == $existingSlug) {
-//                    $existingID = $this->get_post_id_by_slug($newSlug);
-//                    update_option($trimmedName, $existingID);
-//                // Otherwise create a new page
-//                } else {
-//                    // Put together the new page, then update the option with the new ID
-//                    $templateUsed = isset($requiredPageInfo['template']) ? $requiredPageInfo['template'] : 'index.php';
-//                    $new_id = $this->insertReqPage(
-//                            $requiredPageInfo['title'],
-//                            $requiredPageInfo['content'],
-//                            'publish',
-//                            'page',
-//                            '1',
-//                            $templateUsed,
-//                            $postParent
-//                        );
-//                    update_option($trimmedName, $new_id);
-//
-//                    // Make extra page if members only is created
-//                    if ($new_id == get_option(GLM_MEMBERS_PLUGIN_OPTION_MEMBERS_ONLY_ID)) {
-//                        $this->insertReqPage(
-//                            'Members Only Sample Subpage',
-//                            'This page will automatically be locked to Members Only with the members-only-template',
-//                            'publish',
-//                            'page',
-//                            '1',
-//                            $templateUsed,
-//                            $new_id
-//                        );
-//
-//                    }
-//                }
-//            } else {
-//                // No page created
-//            }
-//        }
-//
-//    }
-
-//    public function insertReqPage($pTitle = '--bad page--', $pContent = '', $pPublish = 'publish', $pType = 'page', $pAuthor = '1', $pTemplate = 'index.php', $pParent = '0')
-//    {
-//        $new_page = array(
-//            'post_title' => $pTitle,
-//            'post_content' => $pContent,
-//            'post_status' => $pPublish,
-//            'post_type' => $pType,
-//            'post_author' => $pAuthor,
-//            'page_template' => $pTemplate ,
-//            'post_parent' => $pParent
-//        );
-//        return wp_insert_post($new_page);
-//    }
-
-
-//    public function get_post_data($needle = 1, $valueField = 'post_name', $needleField = 'ID')
-//    {
-//        $value = $this->wpdb->get_var("SELECT $valueField FROM ".$this->wpdb->posts." WHERE $needleField = '".$needle."'");
-//        return $value;
-//    }
-
-//    public function verify_post_slug($postName)
-//    {
-//        $value = $this->wpdb->get_var("SELECT post_name FROM ".$this->wpdb->posts." WHERE post_name = '".$postName."'");
-//        return $value;
-//    }
-
-//    public function get_post_id_by_slug($postName)
-//    {
-//        $value = $this->wpdb->get_var("SELECT ID FROM ".$this->wpdb->posts." WHERE post_name = '".$postName."'");
-//        return $value;
-//    }
+    public function createPages($requiredPages)
+    {
+        foreach($requiredPages as $requiredPage => $requiredPageInfo) {
+            $option = GLM_MEMBERS_PLUGIN_OPTION_PREFIX.$requiredPageInfo['underscored_title'];
+            if ($requiredPageInfo['parent'] == 'associate') {
+                $postParent = get_option(GLM_MEMBERS_PLUGIN_OPTION_ASSOCIATE_ID);
+            } else if ($requiredPageInfo['parent'] == 'membersonly') {
+                $postParent = get_option(GLM_MEMBERS_PLUGIN_OPTION_MEMBERS_ONLY_ID);
+            } else if (is_numeric($requiredPageInfo['parent'])) {
+                $postParent = $requiredPageInfo['parent'];
+            } else {
+                $postParent = '0';
+            }
+            
+            
+            // If the new slug corresponds to a page already existent, then it's
+            //  either the first time this plugin is run on an outdated site or
+            //  somehow the ID was deleted. Either way, replace the option value
+            //  with whatever is the ID of the page matching that slug. The slug
+            //  is checked by translating the page title.
+            $newSlug = sanitize_title($requiredPageInfo['title']);
+            $existingSlug = $this->verify_post_slug($newSlug);
+            if ($newSlug == $existingSlug) {
+                $existingID = $this->get_post_id_by_slug($newSlug);
+                update_option($option, $existingID);   
+            }
+            $existingPost = get_post(get_option($option));
+            // If a post with the ID set in the option does not exist
+            if ( !$existingPost) {
+
+
+                    // Put together the new page, then update the option with the new ID
+                    $templateUsed = isset($requiredPageInfo['template']) ? $requiredPageInfo['template'] : 'index.php';
+                    $new_id = $this->insertReqPage(
+                            $requiredPageInfo['title'],
+                            $requiredPageInfo['content'],
+                            'publish',
+                            'page',
+                            '1',
+                            $templateUsed,
+                            $postParent
+                        );
+                    update_option($option, $new_id);
+
+                    // Make extra page if members only is created
+                    if ($new_id == get_option(GLM_MEMBERS_PLUGIN_OPTION_MEMBERS_ONLY_ID)) {
+                        $this->insertReqPage(
+                            'Members Only Sample Subpage',
+                            'This page will automatically be locked to Members Only with the members-only-template',
+                            'publish',
+                            'page',
+                            '1',
+                            $templateUsed,
+                            $new_id
+                        );
+
+                    }
+            } else {
+                // No page created
+            }
+        }
+
+    }
+
+    public function insertReqPage($pTitle = '--bad page--', $pContent = '', $pPublish = 'publish', $pType = 'page', $pAuthor = '1', $pTemplate = 'index.php', $pParent = '0')
+    {
+        $new_page = array(
+            'post_title' => $pTitle,
+            'post_content' => $pContent,
+            'post_status' => $pPublish,
+            'post_type' => $pType,
+            'post_author' => $pAuthor,
+            'page_template' => $pTemplate ,
+            'post_parent' => $pParent
+        );
+        return wp_insert_post($new_page);
+    }
+
+
+    public function get_post_data($needle = 1, $valueField = 'post_name', $needleField = 'ID')
+    {
+        $value = $this->wpdb->get_var("SELECT $valueField FROM ".$this->wpdb->posts." WHERE $needleField = '".$needle."'");
+        return $value;
+    }
+
+    public function verify_post_slug($postName)
+    {
+        $value = $this->wpdb->get_var("SELECT post_name FROM ".$this->wpdb->posts." WHERE post_name = '".$postName."'");
+        return $value;
+    }
+
+    public function get_post_id_by_slug($postName)
+    {
+        $value = $this->wpdb->get_var("SELECT ID FROM ".$this->wpdb->posts." WHERE post_name = '".$postName."'");
+        return $value;
+    }
 
     /**
      *
index 1d4607e..bd1964d 100644 (file)
@@ -632,11 +632,11 @@ class glmMembersAdmin extends GlmPluginSupport
          * Check Required Pages
          *
          */
-//        foreach ($this->config['addOns'] as $a) {
-//            if (isset($a['requiredPages'])) {
-//                $this->createPages($a['requiredPages']);
-//            }
-//        }
+        foreach ($this->config['addOns'] as $a) {
+            if (isset($a['requiredPages'])) {
+                $this->createPages($a['requiredPages']);
+            }
+        }
 
         // Loop till we have a final action
         $loopCheck = 0;
index 366d430..9b2a0a3 100644 (file)
@@ -65,6 +65,9 @@
     background: white;
     margin: .8em 0px .8em 0px;
 }
+.glm-member-list-data {
+    padding: 15px 20px;
+}
 .glm-member-db-list-grid-view {
     overflow: hidden;
     position: relative;
 }
 .glm-member-db-list-view .glm-member-title {
     text-transform: none;
+    line-height: 1.2;
+    margin: 0;
 }
 .glm-member-db-list-grid-view .glm-member-db-border-wrap {
     border-radius: 4px;
 }
+.glm-member-list-social {
+    margin-top: 5px;
+}
 #glm-member-list-map-toggle {
     background-color: lightgrey;
     position: absolute;
     }    
 }
 .glm-member-db-list-view .glm-member-list-active-info {
-    padding: 0;
+    padding: 0 15px 0 0;
 }
 /*
  * Member List End
     background-size: contain;
     content: " ";
     display: inline-block;
-    height: 15px;
-    margin-right: 10px;
-    width: 15px;
+    height: 10px;
+    margin-right: 6px;
+    width: 10px;
     
 }
 #glm-member-detail-website-link a {
@@ -541,7 +549,7 @@ input[type="submit"].glm-member-button {
 }
 .glm-member-db-list-view .glm-member-list-container {
     padding: 0;
-    height: 200px;
+    
 }
 .glm-member-db-list-view .glm-member-db-phone-tollfree {
     
@@ -752,9 +760,9 @@ input[type="submit"].glm-member-button {
     background-size: contain;
     content: " ";
     display: inline-block;
-    height: 12px;
+    height: 10px;
     margin-right: 6px;
-    width: 12px;
+    width: 10px;
 }
 .glm-member-list-links a,
 #glm-member-detail-list-links a {
@@ -839,6 +847,10 @@ input[type="submit"].glm-member-button {
     }
     
 }
+.fancybox-title.fancybox-title-inside-wrap{
+    text-align: center;
+    font-weight: bold;
+}
 /*#glm-locationMap-container {
     margin-bottom: 0px;
 }
index 9331d10..611b121 100644 (file)
@@ -128,14 +128,11 @@ class GlmMembersAdmin_management_index extends GlmDataSettingsGeneral
 
             if (isset($a['requiredPages'])) {
                 foreach($a['requiredPages'] as $pageName => &$pageData) {
-                    //echo $pageName;
                     $pageID = get_option(GLM_MEMBERS_PLUGIN_OPTION_PREFIX.$pageData['underscored_title']);
                     $pageData['id'] = $pageID;
                     $pageData['slug'] = sanitize_title($pageData['title']);;
                 }
-                $requiredPages[$a['underscored_title']] = $a['requiredPages'];
-
-                //$a['requiredPages'][]
+                $requiredPages[$a['underscored_name']] = $a['requiredPages'];
             }
         }
 
index a3afd3c..61da033 100644 (file)
@@ -106,4 +106,15 @@ if ( ! function_exists( 'glm_theme_members_only_menu' ) && function_exists('Glm_
     }
 }
 
+add_filter( 'login_redirect', 'dashboard_redirect' );
+function dashboard_redirect( $url ) {
+    if ( current_user_can( 'glm_members_member' ) ) {
+         $url = esc_url( admin_url( 'admin.php?page=glm-members-admin-menu-member' ) );
+    } else {
+        $url = 'http://www.google.com';
+    }
+
+    return $url;
+}    
+
 ?>
\ No newline at end of file
index 74b2d7d..a163d3c 100644 (file)
@@ -68,7 +68,6 @@ if (is_plugin_active($plugin_name)) {
 if (!function_exists('is_in_tree')) {
     function is_in_tree( $pid ) {
         global $post;
-
         if ( is_page($pid) )
             return true;
 
@@ -124,14 +123,20 @@ function glm_members_only_template( $template ) {
     $templateName = "glm-members-only-template.php";
     $membersOnlyPage = get_option(GLM_MEMBERS_PLUGIN_OPTION_MEMBERS_ONLY_ID);
     $newTemplate = locate_template( $templateName );
-    if ( is_in_tree($membersOnlyPage) && $newTemplate != '' ) { // if in same tree as the members page for this site
+    if ( (is_in_tree($membersOnlyPage)) && ($newTemplate != "") ) { // if in same tree as the members page for this site
         apply_filters('glmMembersFrontCSSFilter');
         return $newTemplate;
-        /* Uncomment this if you want every child page of the members only page to be given the members only template
-         *  (i.e. changed in the database) and not just using them on the front-end
+        /* //Uncomment this if you want every child page of the members only page to be given the members only template
+         * // (i.e. changed in the database) and not just using them on the front-end
+         
+         * global $post;
+         * update_post_meta($post->ID, '_wp_page_template', $templateName);
+         * 
          */
-         // global $post;
-         // update_post_meta($post->ID, '_wp_page_template', $templateName);
+    //} else if (is_in_tree($membersOnlyPage)) {
+        // Bad template;
+    //} else {
+        // Not in tree of $membersOnlyPage;
     }
     return $template;
 }
\ No newline at end of file
index 3b1211c..349f9fc 100644 (file)
@@ -29,7 +29,7 @@
                             <tr>
                                 <th>Page Name</th>
                                 <td>
-                                    <input type="text" name="glm_members_database_option_{$requiredPageData.name}" value="{$requiredPageData.name}">
+                                    <input type="text" name="glm_members_database_option_{$requiredPageData.title}" value="{$requiredPageData.title}">
                                 </td>
                             </tr>
                             <tr>
index 1955baa..e212bcf 100644 (file)
 
                             <ul class="small-block-grid-1 medium-block-grid-2 large-block-grid-3">
                         {foreach $imageGallery as $i}
-                               {$i.caption}
                                 <li>
                                     <a class="glm-member-detail-images-thumb" rel="gallery1" href="{$glmPluginMediaUrl}/images/large/{$i.file_name}" style="background-image: url('{$glmPluginMediaUrl}/images/small/{$i.file_name}')">
-                                        <img class="glm-member-filler-image" src="{$assetsUrl}/filler_s.gif">
+                                        <img class="glm-member-filler-image" src="{$assetsUrl}/filler_s.gif" alt="{$i.caption}">
                                     </a>
                                 </li>
                         {/foreach}
         jQuery(document).ready(function($) {
             
             $("a.glm-member-detail-images-thumb").fancybox({
+           
                  helpers: {
-                    overlay: {
-                        locked: false
-                    }
-                }  
+                    overlay: { locked: false },
+                     title: { type: 'inside'},
+                },
+                afterLoad: function(){
+                    this.title = $(this.element).find('img').attr('alt');
+                }
             });
              $("a.glm-member-detail-images-thumb").click(function(e) {
                  e.preventDefault();
index 5b17cd1..8d2e6c0 100644 (file)
                 {apply_filters('glm-member-db-front-members-list-memberTop', '', $m.id)}
                  <!-- Member Logo - Medium and up-->
                  
+                    <div class="glm-member-list-data small-12 columns">
                 {if $m.logo && $settings.list_show_logo}
                     <div class="glm-member-list-image-wrapper right small-12 medium-4 columns">
-                        <div class="glm-member-list-image-border" style="background: url('{$glmPluginMediaUrl}/images/{$settings.list_logo_size}/{$m.logo}') no-repeat; background-size: cover; background-position: center center; height: 250px;">
+                        <div class="glm-member-list-image-border" style="background: url('{$glmPluginMediaUrl}/images/{$settings.list_logo_size}/{$m.logo}') no-repeat; background-size: contain; background-position: center center; height: 250px;">
                         </div>
                    </div>
                 {/if}
-                    <div class="glm-member-list-data small-12 medium-8 columns">
-                     <div class="glm-member-list-active-info small-12 columns">
+                        
+                     <div class="glm-member-list-active-info small-12 medium-8 columns">
  <!-- Member name, address, and basic information -->
                     {apply_filters('glm-member-db-front-members-list-memberInfoTop', '', $m.id)}
                     <h4 class="glm-member-title">
                     {if $m.region && $settings.list_show_region}<div><b>Region:</b> {$m.region}</div>{/if}
 
                     <div class="glm-member-list-links">
-                        {if $m.url && $settings.list_show_url}<a id='glm-member-list-website-link' href="{$m.url}"{if $settings.list_show_url_newtarget} target="_blank"{/if}>Website</a>{/if}
+                        {if $m.url && $settings.list_show_url}<a id='glm-member-list-website-link' href="{$m.url}"{if $settings.list_show_url_newtarget} target="_blank"{/if}>Visit Website</a>{/if}
                         {if $m.email && $settings.list_show_email}<a href="mailto:{$m.email}">Email</a>{/if}
                      </div>
-                    <div class="socialtest">
-                        {apply_filters('glm-member-db-front-members-list-memberDetailBottom', '', $m.id)}
-                       Social:{apply_filters('glm-member-db-front-members-social-list', '', $m.id)}
+                    <div class="glm-member-list-socials">
+                       {apply_filters('glm-member-db-front-members-social-list', '', $m.id)}
                     </div>
-                 </div>
                     
                 <div class="glm-member-list-description small-12 columns">
                     <div>
                     {/if}
                     </div>
                 </div>
+                    {apply_filters('glm-member-db-front-members-list-memberDetailBottom', '', $m.id)}
+                 </div>
+                    
                         
                     <!-- Laury - This is the one that should go underneath all the address and description area -->
                 {apply_filters('glm-member-db-front-members-list-memberDataBelow', '', $m.id)}