From 1d6e6240830ec7ea0d11edfa057f1ea77179888f Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Fri, 22 Jul 2016 14:42:57 -0400 Subject: [PATCH] Added support for putting additional content in main dashboard widget. Fixed a minor problem with the shortcode builder where it was causing an undefined parameter error. --- classes/glmPluginSupport.php | 10 ++- defines.php | 2 +- models/admin/dashboardWidget/index.php | 25 ++++++ setup/adminMenus.php | 2 +- setup/hooksHelp.html | 115 ++++++++++++++----------- views/admin/dashboardWidget/index.html | 13 ++- 6 files changed, 107 insertions(+), 60 deletions(-) diff --git a/classes/glmPluginSupport.php b/classes/glmPluginSupport.php index 58be70f6..5a50662c 100644 --- a/classes/glmPluginSupport.php +++ b/classes/glmPluginSupport.php @@ -507,8 +507,14 @@ return; // Off for now ** Need to make this switchable in management // use the addOn slugs to access each of the shortcodes foreach($addOnSlugs as $addOn){ - if ($this->config['addOns'][$addOn]['shortcodes']) { - $shortCodeList[] = $this->config['addOns'][$addOn]['shortcodes']; + + // Check if the add-on has shortcodes + if (isset($this->config['addOns'][$addOn]['shortcodes'])) { + + // It does, so add them to the list + if ($this->config['addOns'][$addOn]['shortcodes']) { + $shortCodeList[] = $this->config['addOns'][$addOn]['shortcodes']; + } } } diff --git a/defines.php b/defines.php index 8b9b4d30..762840c7 100644 --- a/defines.php +++ b/defines.php @@ -33,10 +33,10 @@ define('GLM_MEMBERS_PLUGIN_HTTP_PROTOCOL', $pageProtocol); // Get various pieces of the URL $urlParts = parse_url(get_bloginfo('url')); $pageUri = explode('?', $_SERVER['REQUEST_URI']); // Bust this up to access URL path and script name only - $WPUploadDir = wp_upload_dir(); // URLs +define('GLM_MEMBERS_HOSTNAME', $urlParts['host']); define('GLM_MEMBERS_SITE_BASE_URL', home_url('/') ); define('GLM_MEMBERS_PLUGIN_URL', plugin_dir_url(__FILE__)); define('GLM_MEMBERS_PLUGIN_ADMIN_URL', admin_url('admin.php')); diff --git a/models/admin/dashboardWidget/index.php b/models/admin/dashboardWidget/index.php index 1b99b3e5..e8087564 100644 --- a/models/admin/dashboardWidget/index.php +++ b/models/admin/dashboardWidget/index.php @@ -13,6 +13,31 @@ * @version 0.1 */ +/* + * Adding content to the GLM Associate Dashboard Widget from an Add-on. + * + * There are three filters in the GLM Associate Dashboard Widget view for adding content into the widget. + * These include short warnings, lists of pending user actions, and other notices. + * + * See "Management" -> "Hooks" then scan down to "Main Dashboard Widget Hooks". + * + * Here's the best method for providing content to the dashboard widget. There is an example of this in the search add-on. + * + * 1. Create a Model/View to build additional content for the dashboard widget + * a. Add a model for generating the warning/notice to the add-on in, for example, "models/admin/dashboardWidget/search/" + * b. Add a view for this model to the add-on in, for example, "views/admin/dashboardWidget/search/" + * (see Main Dashboard Widget Hooks descriptions for suggested format) + * c. Add the model to "setup/validActions.php" in the add-on + * + * 2. Place an add_filter() function in the add-on's "setup/adminHooks.php" file, for example... + * + * // Add content to the main dashboard widget + * add_filter( 'glm-member-db-dashboard-widget-warnings', function( $content ) { + * $content .= $this->controller('dashboardWidget', 'search'); + * return $content; + * }); + */ + // Load Members data abstract require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMembers.php'); diff --git a/setup/adminMenus.php b/setup/adminMenus.php index b7770fb6..ab131c6b 100644 --- a/setup/adminMenus.php +++ b/setup/adminMenus.php @@ -41,7 +41,7 @@ if (current_user_can('glm_members_members')) { 'glm_members_main_menu', 'glm-members-admin-menu-members', function() {}, - false, + GLM_MEMBERS_PLUGIN_ASSETS_URL.'/flame.png', '3.100' ); diff --git a/setup/hooksHelp.html b/setup/hooksHelp.html index 31e4e2d8..efb7197d 100644 --- a/setup/hooksHelp.html +++ b/setup/hooksHelp.html @@ -1,8 +1,8 @@ -

Main Member DB Plugin

+

Main Member DB Plugin

- Add-On Registration Hooks +

Add-On Registration Hooks

glm-member-db-register-addon Filter @@ -139,7 +139,7 @@ public function glmMembersAddTabForMembers($addOnTabs) - User Permission Hooks +

User Permission Hooks

glm_members_current_logged_in_user @@ -350,7 +350,7 @@ public function glmMembersAddTabForMembers($addOnTabs) - Front-End Output Hooks - Member List Page +

Front-End Output Hooks - Member List Page

glm-member-db-front-members-list-pageTop @@ -507,7 +507,7 @@ public function glmMembersAddTabForMembers($addOnTabs) - Front-End Output Hooks - Member Detail Page +

Front-End Output Hooks - Member Detail Page

glm-member-db-front-members-detail-pageTop @@ -753,52 +753,63 @@ public function glmMembersAddTabForMembers($addOnTabs) +

Main Dashboard Widget Hooks

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + glm-member-db-dashboard-widget-warnings + Filter + + + Permits adding critical warnings to the main dashboard GLM Associate widget. Be + sure to add content to the end of the string passed along by this filter. +

+ Use the following format. +

+<h4><span class="glm-error">[Warning Title]</span></h4> +[warning content] +
+ + + + glm-member-db-dashboard-widget-pendingaction + Filter + + + Place a list with a title in main dashboard GLM Associate widget. Be + sure to add content to the end of the string passed along by this filter. + This filter is primarily for placing lists of items that are pending + user action. +

+ Use the following format. +

+<h4><span class="glm-error">[Title for this list]</span></h4> +<table class="wp-list-table striped glm-admin-table"> + <tbody> +[template loop code] + <tr> + [list entry content including TH and TD tags as desired] + </tr> +[end of template loop code] + </tbody> +</table> +
+ + + + glm-member-db-dashboard-widget-othernotices + Filter + + + Place a list with a title in main dashboard GLM Associate widget. Be + sure to add content to the end of the string passed along by this filter. + This filter is for adding any other type of information to the dashboard + widget. +

+ Use the following format. +

+<h4><span class="glm-warning">[Notice Title]</span></h4> +[notice content] +
+ + \ No newline at end of file diff --git a/views/admin/dashboardWidget/index.html b/views/admin/dashboardWidget/index.html index 36dace7d..f8fb5b83 100644 --- a/views/admin/dashboardWidget/index.html +++ b/views/admin/dashboardWidget/index.html @@ -56,10 +56,13 @@ {/if} + +{apply_filters('glm-member-db-dashboard-widget-warnings', '')} + {if apply_filters('glm_members_permit_admin_widget_warnings', true)} - {if !$haveMemberTypes || !$haveCategories || !$haveAmenities || !$haveCities || !$haveRegions || $numbMembers == 0} -

Pending {$terms.term_member_cap} Information

+ {if !$haveMemberTypes || !$haveCategories || !$haveAmenities || !$haveCities || !$haveRegions || $numbMembers == 0} + {if !$haveMemberTypes} @@ -96,8 +99,8 @@ {/if} -

Pending {$terms.term_member_cap} Information

No {$terms.term_member_cap} TypesAdd a {$terms.term_member_cap}
{/if} + {if $haveBadLatLon}

Records with Bad Map Locations

@@ -134,6 +137,8 @@ {/if} + + {apply_filters('glm-member-db-dashboard-widget-noticewithlist', '')} {/if} -{apply_filters('glm-member-db-dashboard-widget-notices', '')} +{apply_filters('glm-member-db-dashboard-widget-othernotices', '')} -- 2.17.1