From a08f24551cd700639e98605efdf3476f9fdecf7b Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Mon, 13 Nov 2017 13:38:25 -0500 Subject: [PATCH] Started adding some documentation to the admin hooks and started building the hooksHelp.html file. --- setup/adminHooks.php | 55 ++++++++++++++++++++++++--- setup/hooksHelp.html | 88 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 137 insertions(+), 6 deletions(-) diff --git a/setup/adminHooks.php b/setup/adminHooks.php index f82fb26..24edd4a 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -25,29 +25,50 @@ * * Also note that parameters will be in the context of the main admin controller constructor. */ + +// Add hooksHelp.html file to admin Management hooks output +add_filter('glm-member-db-admin-management-hooksHelp', function($content) { + + // Read in this plugin/addon hook help file + $fname = GLM_MEMBERS_FIELDS_PLUGIN_PATH.'/setup/hooksHelp.html'; + if (is_file($fname)) { + $hooksHelp = file_get_contents($fname); + if ($hooksHelp != false) { + $content .= $hooksHelp; + } + } + return $content; +}, +10, +2 +); + /** * Filter will return true if the plugin is active. */ add_filter( 'glm-members-customfields-active', function( $active ){ return true; }, 10, 1 ); + /** - * Filter returns html from the management -> fields model. + * Filter returns html from the management -> fields model. */ add_filter( 'glm-members-customfields-edit', function( $content, $uid ){ unset( $_REQUEST['glm_action'] ); - $content = $this->controller( 'management', 'fields', array( 'uid' => $uid ), true ); + $content .= $this->controller( 'management', 'fields', array( 'uid' => $uid ), true ); return $content; }, 10, 2 ); + /** * Filter returns the html for the form segment */ add_filter( 'glm-members-custom-fields-form', function( $content, $uid, $id,$cfData = false ){ unset( $_REQUEST['glm_action'] ); // echo "CONTENT: " . $content . " UID: " . $uid . " ID: " . $id . '
'; - $content = $this->controller( 'entity', 'fields', array( 'uid' => $uid, 'entityID' => $id,'cfData'=>$cfData ), true); + $content .= $this->controller( 'entity', 'fields', array( 'uid' => $uid, 'entityID' => $id,'cfData'=>$cfData ), true); return $content; }, 10, 4 ); + /** * Filter Captured Data Success Status * @@ -56,22 +77,34 @@ add_filter( 'glm-members-custom-fields-form', function( $content, $uid, $id,$cfD add_filter( 'glm-members-customfields-capture', function( $content, $uid, $id ){ }, 10, 3 ); + /** * Filter to Return Stored Data */ add_filter( 'glm-members-customfields-data', function( $content, $uid, $id ){ }, 10, 3 ); + +/** + * Filter to Return a tab link for multi-page sub-tabs. + */ add_filter( 'glm-member-db-custom-fields-nav', function( $content, $tableName ){ - $out = 'Custom Fields'; + $out .= 'Custom Fields'; return $out; },10,2); +/** + * ????????? + */ add_filter( 'glm-member-db-custom-fields-tab', function( $content, $entityID = '' ){ unset( $_REQUEST['glm_action'] ); $content = $this->controller( 'fields', 'fields', $entityID ); return $content; },1,2); + +/** + * ????????? + */ add_filter( 'glm-member-db-custom-filter-search', function ( $content ) { $parts = array(); $customFields = $this->wpdb->get_results( @@ -109,6 +142,10 @@ $parts = array(); } return implode( ' ', $parts ); }); + +/** + * ????????? + */ add_filter('glm-member-db-admin-search-query', function() { $queryParts = array(); // Get all custom fields @@ -157,16 +194,24 @@ add_filter('glm-member-db-admin-search-query', function() { } return $queryParts; }); + +/** + * ???????? + */ add_filter('glm-member-db-save-custom-fields', function( $entityID) { require_once GLM_MEMBERS_FIELDS_PLUGIN_CLASS_PATH . '/customFieldPluginSupport.php'; // this will save the member data //echo "uid = $uid"; return customFieldsSaveFields( $entityID); - + }, 10, 1 ); + +/** + * ???????? + */ add_action( 'glm-member-db-clone-custom-fields', function( $entityID, $newId ){ diff --git a/setup/hooksHelp.html b/setup/hooksHelp.html index bbe0e75..8ba7a8c 100644 --- a/setup/hooksHelp.html +++ b/setup/hooksHelp.html @@ -13,4 +13,90 @@ ---> \ No newline at end of file +--> + +

Custom Fields Add-On

+Menu/Tab Hooks + + glm-members-customfields-active + FILTER + + + Returns TRUE if Custom Fields Add-On is installed and active. + + + + glm-member-db-custom-fields-nav + FILTER + $content, $tableName + + Displays a tab to use for customer fields and will select the $tableName for display + when clicked. The $content parameter should be an empty string unless there is a + desire to put additional HTML code before the tab. The return will be HTML to + display a functional tab. +

+ Note that such tabs will require the correct scripting to make them work as + is used for sub-tabs in our add-ons. +

+ + +Fields Add/Delete/Edit + + glm-members-customfields-edit + FILTER + $content, $uid + + Return HTML for field add/delete/edit for the specified form ($uid). +

+ The $content parameter should be an empty string when this filter is applied. + Any HTML returned from this filter will be appended to the supplied text. + If desired, HTML code may be provided to be included at the beginning of the + resulting string that's returned. +

+

+ The $uid parameter is a text string that is a unique identifier for the the form that is to + be edited. This should include the slug of the plugin that is calling + for this form and a name or other identifier for the specific form. This might + typically be specified in the form of a slug with hyphens between the words. +

+ + +Fields Use + + glm-members-custom-fields-form + FILTER + $content, $uid, $id, $cfData + + Displays a specific custom fields from to request user input. +

+ The $content parameter should be an empty string when this filter is applied. + Any HTML returned from this filter will be appended to the supplied text. + If desired, HTML code may be provided to be included at the beginning of the + resulting string that's returned. +

+

+ The $uid parameter is a text string that is a unique identifier for the the form that is to + be edited. This should include the slug of the plugin that is calling + for this form and a name or other identifier for the specific form. This might + typically be specified in the form of a slug with hyphens between the words. +

+

+ The $id parameter is an INTEGER that is unique to this specific use of the form + specified by $uid. For example, if $uid points to a form with added fields to + be used along with the usual fields in a contact information form, the $id + parameter might be the 'id' field from the record containing the contact that's + being edited. Any results submitted will be stored along with this $id. If + this $uid and $id pair are used anywhere else, data submitted there will replace + the other uses of the same form and id. +

+

+ The $cfData field is an array that contains field data to use as the default + when the form is displayed. This will usually come from a previous submission + of the form that failed due to a missing required field or other failure. This + permit re-displaying the form again with the data in it that the user attempted + to subit. The $cfData may also have information that will be used by the custom + fields add-on to format failed fields differently to show which need attention. + If This is an initial display of the form, simply provide FALSE. ?????? +

+ + -- 2.17.1