From 645d1f8aca28aba8770e074b007ab6b60b7de3ec Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Wed, 30 Mar 2016 13:25:33 -0400 Subject: [PATCH] Added Intro to AJAX for these plugins --- models/admin/ajax/readme.txt | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 models/admin/ajax/readme.txt diff --git a/models/admin/ajax/readme.txt b/models/admin/ajax/readme.txt new file mode 100644 index 00000000..07c37ec9 --- /dev/null +++ b/models/admin/ajax/readme.txt @@ -0,0 +1,40 @@ +Intro to AJAX for these plugins +------------------------------- + +WordPress has an AJAX capability that works through "wp-admin/admin-ajax.php". You can use this +to support AJAX calls, but also can use it to do direct output to the user's browser without +outputting any of the other front-end or admin wordpress content. + +This is driven in these plugins by an add_action() call in the admin controller (controllers/admin.php). +That routes all calls for the following url base to the glmMembersAdminAjax() function in the admin +controller. Note that action and other parameters may be supplied by GET or POST. + + {host}/wp-admin/admin-ajax.php?action=glm_members_admin_ajax + + The glmMembersAdminAjax() function then looks for a "glm_action" parameter that specifies the name + of a model file to load and execute. This model MUST be in a "models/admin/ajax" directory in the + main plugin or one of the add-ons and MUST be listed in the "setup/validActions.php" file of that + plugin or add-on. Here is an example of setting the valid action for an ajax model. Obviously there + would be other valid actions listed. + + $glmMembersEventsAddOnValidActions = array( + 'adminActions' => array( + 'ajax' => array( + 'pdfOutput' => 'glm-member-db' + ) + ) +); + +The model file loaded will be named by the "glm_action" parameter plus ".php". The admin controller +will load the class in the model named as follows where "pdfOutput" is the value provided by the +"glm_action" parameter. It will then call the modelAction() function in that class. + +class GlmMembersAdmin_ajax_pdfOutput + +You may include all your code in the called model file or may extend another model to produce your +output. Output may include custom headers and any desired content. The controller will execute a +wp_die() function call to terminate any further processing if there is a return from the model's +modelAction() function. This prevents any additional output from reaching the browser. + + + \ No newline at end of file -- 2.17.1