From 8eda65db3905700e1db6dd9fb2332327b66ac9cf Mon Sep 17 00:00:00 2001 From: laury Date: Wed, 18 May 2016 14:35:56 -0400 Subject: [PATCH] page creation fixed, view styles updated --- classes/glmPluginSupport.php | 192 +++++++++++++++--------------- controllers/admin.php | 10 +- css/front.css | 26 ++-- models/admin/management/index.php | 5 +- setup/adminHooks.php | 11 ++ setup/frontHooks.php | 17 ++- views/admin/management/index.html | 2 +- views/front/members/detail.html | 14 ++- views/front/members/list.html | 18 +-- 9 files changed, 162 insertions(+), 133 deletions(-) diff --git a/classes/glmPluginSupport.php b/classes/glmPluginSupport.php index 4852a50b..0dd64a7e 100644 --- a/classes/glmPluginSupport.php +++ b/classes/glmPluginSupport.php @@ -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; + } /** * diff --git a/controllers/admin.php b/controllers/admin.php index 1d4607e9..bd1964d5 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -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; diff --git a/css/front.css b/css/front.css index 366d4303..9b2a0a35 100644 --- a/css/front.css +++ b/css/front.css @@ -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; @@ -86,10 +89,15 @@ } .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; @@ -382,7 +390,7 @@ } } .glm-member-db-list-view .glm-member-list-active-info { - padding: 0; + padding: 0 15px 0 0; } /* * Member List End @@ -457,9 +465,9 @@ 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; } diff --git a/models/admin/management/index.php b/models/admin/management/index.php index 9331d10a..611b1216 100644 --- a/models/admin/management/index.php +++ b/models/admin/management/index.php @@ -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']; } } diff --git a/setup/adminHooks.php b/setup/adminHooks.php index a3afd3c2..61da0334 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -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 diff --git a/setup/frontHooks.php b/setup/frontHooks.php index 74b2d7d3..a163d3c2 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -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 diff --git a/views/admin/management/index.html b/views/admin/management/index.html index 3b1211cb..349f9fcf 100644 --- a/views/admin/management/index.html +++ b/views/admin/management/index.html @@ -29,7 +29,7 @@ Page Name - + diff --git a/views/front/members/detail.html b/views/front/members/detail.html index 1955baa9..e212bcf0 100644 --- a/views/front/members/detail.html +++ b/views/front/members/detail.html @@ -160,10 +160,9 @@