- How to include jQuery and CSS in WordPress – The WordPress Way (2012, Ryan Sutana)
- Using popup to VIEW DETAIL OF USER SELECTED RECORD – PHP (2020, adnanafzal565)
- popup, modal, PHP, pass data from parent to popup
- Note that the function called by the shortcode should never produce an output of any kind, e.g. using echo. Shortcode functions should ‘return‘ the text that is to be used to replace the shortcode. Producing the output directly will lead to unexpected results. (Code Reference)
- Function plugin_dir-path(__FILE__)
- returns the directory path pointing to the current file.
- The “plugin” part of the function name is misleading – it can be used for any file, and will not return the directory of a plugin unless you call it within a file in the plugin’s base directory.
- Steps for Ajax request in plugins
- Set up the folder structure and action hooks.
- Develop the main php function:
- to generate the basic html markups :
- button for initiate request, with data attributes for passing to the JS function.
- location ID or Class to print the ajax response
- Develop the JS function:
- Retrieve the data passed on from the php function.
- Set up the jQuery.ajax( ) command to pass the data to the php function for handing the request.
- In the success callback function, append the response to the location ID or class. For example: jQuery(‘.class’).append(response);
- Develop the php function for handling the ajax request:
- Retrieve the data passed on from the jQuery.ajax( ) function.
- Performance the required operations to generate the response.
- echo the response to the success function of the ajax call.
- die( ) the connection.
Word Count: 267
