From: Anthony Talarico Date: Wed, 17 Oct 2018 16:40:44 +0000 (-0400) Subject: fixing the sub menu page registration X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=e69b88d34ddb44f2c8bfdb85888c84c791344551;p=WP-Plugins%2Fglm-member-db-leads.git fixing the sub menu page registration --- diff --git a/setup/adminHooks.php b/setup/adminHooks.php index 20c029e..061cf3c 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -55,3 +55,108 @@ add_filter( 11, 1 ); +add_filter( + GLM_MEMBERS_LEADS_PLUGIN_SLUG .'-dashboard-widget', + function ( $member = null ) { + require_once GLM_MEMBERS_LEADS_PLUGIN_CLASS_PATH.'/data/dataLeads.php'; + $Leads = new GlmDataLeads($this->wpdb, $this->config); + + // Set default values for using getList() later, where the custom set of fields below will be used. + $where = ''; + $order = ''; + $fieldVals = true; + $idField = 'id'; + $start = false; + $limit = false; + + // Save the current fields array and make a copy. Will be restored before the return. + $fSave = $Events->fields; + + // Remove what we don't want from the copy and get the list + $Events->fields = array( + 'id' => $fSave['id'], + 'name' => $fSave['name'], + 'name_slug' => $fSave['name_slug'], + 'ref_type' => $fSave['ref_type'], + 'ref_dest' => $fSave['ref_dest'], + 'ref_dest_id' => $fSave['ref_dest_id'], + 'status' => $fSave['status'], + ); + + $leadsIndexPage = GLM_MEMBERS_LEADS_PLUGIN_ADMIN_URL . '?page=glm-members-admin-menu-leads-index&glm_action=edit'; + $leadsTable = GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "leads"; + $leadsEditPage = GLM_MEMBERS_PLUGIN_ADMIN_MENU_URL_BASE.'leads-index&glm_action=list&option=edit'; + $leadsListPage = GLM_MEMBERS_LEADS_PLUGIN_ADMIN_URL . '?page=glm-members-admin-menu-leads-list'; + $leadsRefLink = GLM_MEMBERS_LEADS_PLUGIN_ADMIN_URL . '?page=glm-members-admin-menu-member&glm_action=index'; + $content = [ + 'title' => 'Leads', + 'components' => [ + [ + 'id' => 'quickLinks', + 'order' => -1, + 'template' => 'quickLinks', + 'quickLinks' => [ + 'dashboard' => [ + 'content' => 'Dashboard', + 'url' => $leadsIndexPage . "&option=dashboard", + ], + 'search' => [ + 'content' => 'Advanced Search', + 'url' => $leadsIndexPage . "&option=search", + ], + 'settings' => [ + 'content' => 'Settings', + 'url' => '#set', + ] + ], + ], + [ + 'id' => 'topButtons', + 'order' => 0, + 'template' => 'buttons', + 'buttons' => [ + 'add-event' => [ + 'content' => 'Add', + 'url' => $leadsIndexPage . "&option=create", + 'classes' => '', + 'styles' => '', + 'data' => '' + ], + 'export-button' => [ + 'content' => 'Export', + 'url' => '#', + 'classes' => 'btn-small widget-export-btn waves-effect waves-light btn modal-trigger', + 'styles' => '', + 'data' => 'leads' + ], + ], + ], + [ + 'id' => 'entityAmount', + 'title' => 'Number of Leads', + 'order' => 1, + 'template' => 'entityAmount', + 'url' => $leadsIndexPage . "&option=search", + 'result' => $Leads->getStats() + ], + [ + 'id' => 'textSearch', + 'order' => 2, + 'template' => 'textSearch', + 'entityID' => 'event', + 'table' => $leadsTable, + 'fields' => 'concat(fname," ",lname) as name,id,image,ref_dest', + 'resultUrl' => $leadsEditPage.'&lead=', + 'where' => 'concat(fname," ",lname)' + ], + ] + ]; + + // Restore the fields list + $Events->fields = $fSave; + + return $content; + }, + 13, + 1 +); diff --git a/setup/adminMenus.php b/setup/adminMenus.php index c5b6066..a47faf4 100644 --- a/setup/adminMenus.php +++ b/setup/adminMenus.php @@ -52,7 +52,7 @@ // Add Leads sub-menu for GLM Associate menu add_submenu_page( - 'glm-members-admin-menu-members', + 'glm-members-admin-menu-dashboard', 'Leads', 'Leads', 'glm_members_members',