From 5ca87d09c2edfea59e04cc6ce2e49500106f9971 Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Wed, 25 Jan 2017 13:26:02 -0500 Subject: [PATCH] Added text to member info pages to warn user when update could not be completed. Fixed use of views in the theme to override views in the plugin/addons. Added defines for theme name and path. --- controllers/front.php | 21 ++++++++++++--------- defines.php | 4 ++++ views/admin/member/memberEdit.html | 2 -- views/admin/member/memberInfo.html | 5 +++++ views/front/members/header.html | 2 +- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/controllers/front.php b/controllers/front.php index 43ff11d5..c3b3b740 100644 --- a/controllers/front.php +++ b/controllers/front.php @@ -267,9 +267,6 @@ class glmMembersFront extends GlmPluginSupport // Enqueue all css here so that only happens when we're doing something $this->glmMembersFrontCSS(); - // Get the current theme directory to check for modified views - $theme = get_template_directory(); - /* * Because WordPress insists on forcing the timezone to UTC * we need to save the current timezone setting, set the one @@ -463,10 +460,12 @@ class glmMembersFront extends GlmPluginSupport if ($view) { // Get the specified view file - check theme first - $viewPath = "$theme/$plugIn/views"; + $viewPath = GLM_MEMBERS_PLUGIN_CURRENT_THEME_DIR."/$plugIn/views"; + $viewPath2 = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . "$plugIn/views"; // Save default $viewFile = $view; - if (!is_file($viewPath.'/'.$viewFile)) { + // If the view is not found in the theme, fall back to views in the plugin + if (!is_file($viewPath.'/'.$viewFile)) { // Next try the plugin/add-on $viewPath = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . "$plugIn/views"; $viewFile = $view; @@ -476,7 +475,6 @@ class glmMembersFront extends GlmPluginSupport $errorMsg .= "Bad or missing view file: $viewPath/$viewFile"; } - } } @@ -535,8 +533,8 @@ Request Data: ".print_r($_REQUEST,1)." 'Front-End GLM Associate Error', $mailMsg ); - $viewPath = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.GLM_MEMBERS_PLUGIN_SLUG.'/views'; - $viewFile = 'front/error/index.html'; +// $viewPath = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.GLM_MEMBERS_PLUGIN_SLUG.'/views'; +// $viewFile = 'front/error/index.html'; require_once GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.GLM_MEMBERS_PLUGIN_SLUG.'/models/front/error/index.php'; $model = new GlmMembersFront_error_index($this->wpdb, $this->config); $results = $model->modelAction($actionData); @@ -571,7 +569,12 @@ Request Data: ".print_r($_REQUEST,1)." } // Update the Smarty view path - $smarty->template->addTemplateDir($viewPath); + $smarty->template->setTemplateDir($viewPath); + + // If the view path doesn't match the default, add the default (using theme view) + if ($viewPath2 != $viewPath) { + $smarty->template->addTemplateDir($viewPath2); + } // Generate output from model data and view $out = $smarty->template->fetch($viewFile); diff --git a/defines.php b/defines.php index 03e774b3..e6315291 100644 --- a/defines.php +++ b/defines.php @@ -83,3 +83,7 @@ global $wpdb; define('GLM_MEMBERS_PLUGIN_DB_PREFIX', $wpdb->prefix.'glm_members_'); define('GLM_MEMBERS_PLUGIN_ACTIVE_DB_OPTION', 'glmMembersDatabaseDbVersion'); +// Current Theme Information +$glmCurrentTheme = wp_get_theme(); +define('GLM_MEMBERS_PLUGIN_CURRENT_THEME', $glmCurrentTheme->get_template()); +define('GLM_MEMBERS_PLUGIN_CURRENT_THEME_DIR', $glmCurrentTheme->get_template_directory()); diff --git a/views/admin/member/memberEdit.html b/views/admin/member/memberEdit.html index d4defc49..3e239769 100644 --- a/views/admin/member/memberEdit.html +++ b/views/admin/member/memberEdit.html @@ -12,8 +12,6 @@ {/if} {if $memberUpdated}{$terms.term_member_cap} Updated{/if} {if $memberUpdateError}{$terms.term_member_cap} Update Error{/if} - - {if apply_filters('glm_members_permit_admin_member_index_edit_member', true)} diff --git a/views/admin/member/memberInfo.html b/views/admin/member/memberInfo.html index bc25253f..7a9884d6 100644 --- a/views/admin/member/memberInfo.html +++ b/views/admin/member/memberInfo.html @@ -66,6 +66,11 @@

Add New {$terms.term_member_cap} Profile

{/if} + {if $memberUpdateError} +

NOTICE: Your {$terms.term_member} information has not yet been submitted.
Please select the tabs indicating a problem, correct the indicated fields and resubmit.

+ {/if} + +
diff --git a/views/front/members/header.html b/views/front/members/header.html index 4eaaceac..76baa1c4 100644 --- a/views/front/members/header.html +++ b/views/front/members/header.html @@ -1,3 +1,3 @@
- \ No newline at end of file + blablabla \ No newline at end of file -- 2.17.1