Commit 45f7b5d9 authored by Eric Windham's avatar Eric Windham

added doc block or comment to all ajax endpoints

parent 6f7cceb4
Pipeline #3642 passed with stages
in 1 minute and 9 seconds
......@@ -4,6 +4,7 @@ class NF_AJAX_Controllers_DeleteAllData extends NF_Abstracts_Controller
{
public function __construct()
{
// Ajax call handled in 'delete_all_data' in this file.
add_action( 'wp_ajax_nf_delete_all_data', array( $this, 'delete_all_data' ) );
}
......
......@@ -7,7 +7,7 @@ class NF_AJAX_Controllers_DispatchPoints
*/
public function __construct()
{
// Add out ajax end points.
// Add our ajax end points. Calls are handled in this file.
add_action( 'wp_ajax_nf_undo_click', array( $this, 'undo_click' ) );
add_action( 'wp_ajax_nf_form_telemetry', array( $this, 'form_telemetry' ) );
}
......
......@@ -6,6 +6,7 @@ class NF_AJAX_Controllers_Fields extends NF_Abstracts_Controller
public function __construct()
{
// Ajax call handed in 'maybe_delete_field' in this file
add_action( 'wp_ajax_nf_maybe_delete_field', array( $this,
'maybe_delete_field' ) );
......
......@@ -8,8 +8,9 @@ class NF_AJAX_Controllers_Form extends NF_Abstracts_Controller
{
add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
// All Ajax call here are handled in this file
add_action( 'wp_ajax_nf_ajax_get_new_nonce', array( $this, 'get_new_nonce' ) );
add_action( 'wp_ajax_nopriv_nf_ajax_get_new_nonce', array( $this, 'get_new_nonce' ) );
add_action( 'wp_ajax_nopriv_nf_ajax_get_new_nonce', array( $this, 'get_new_nonce' ) );
add_action( 'wp_ajax_nf_save_form', array( $this, 'save' ) );
add_action( 'wp_ajax_nf_delete_form', array( $this, 'delete' ) );
add_action( 'wp_ajax_nf_remove_maintenance_mode', array( $this, 'remove_maintenance_mode' ) );
......@@ -167,7 +168,7 @@ class NF_AJAX_Controllers_Form extends NF_Abstracts_Controller
$this->_data['errors'] = __('Access denied. You must have admin privileges to view this data.', 'ninja-forms');
$this->_respond();
}
check_ajax_referer( 'ninja_forms_settings_nonce', 'security' );
WPN_Helper::set_forms_maintenance_mode();
......
......@@ -4,6 +4,7 @@ class NF_AJAX_Controllers_JSError
{
public function __construct()
{
// Ajax calls are handled by 'log_error' in this file
add_action( 'wp_ajax_nf_log_js_error', array( $this, 'log_error' ) );
add_action( 'wp_ajax_nopriv_nf_log_js_error', array( $this, 'log_error' ) );
}
......
......@@ -6,6 +6,7 @@ class NF_AJAX_Controllers_Preview extends NF_Abstracts_Controller
public function __construct()
{
// Ajax call handled in 'update' in this file
add_action( 'wp_ajax_nf_preview_update', array( $this, 'update' ) );
add_filter( 'ninja_forms_run_action_settings', array( $this, 'filter_action_settings' ), 10, 4 );
......
......@@ -4,6 +4,10 @@ class NF_AJAX_Controllers_SavedFields extends NF_Abstracts_Controller
{
public function __construct()
{
/**
* These Ajax calls are all handled in this file by 'create', 'update',
* and 'delete', respectively
*/
add_action( 'wp_ajax_nf_create_saved_field', array( $this, 'create' ) );
add_action( 'wp_ajax_nf_update_saved_field', array( $this, 'update' ) );
add_action( 'wp_ajax_nf_delete_saved_field', array( $this, 'delete' ) );
......@@ -61,7 +65,7 @@ class NF_AJAX_Controllers_SavedFields extends NF_Abstracts_Controller
$this->_errors[] = __('Access denied. You must have admin privileges to view this data.', 'ninja-forms');
$this->_respond();
}
check_ajax_referer( 'ninja_forms_settings_nonce', 'security' );
if( ! isset( $_POST[ 'field' ] ) || empty( $_POST[ 'field' ] ) ){
......
......@@ -25,9 +25,15 @@ class NF_AJAX_Controllers_Submission extends NF_Abstracts_Controller
}
// Ajax calls here are both handled by 'submit' in this file
add_action( 'wp_ajax_nf_ajax_submit', array( $this, 'submit' ) );
add_action( 'wp_ajax_nopriv_nf_ajax_submit', array( $this, 'submit' ) );
/**
* Ajax calls here are handled by 'resume' in this file. These calls
* are normally made by the application when returning from 'PayPal' or
* 'Stripe'.
*/
add_action( 'wp_ajax_nf_ajax_resume', array( $this, 'resume' ) );
add_action( 'wp_ajax_nopriv_nf_ajax_resume', array( $this, 'resume' ) );
}
......
......@@ -17,6 +17,17 @@ abstract class NF_AJAX_REST_Controller extends NF_Abstracts_Controller
public function __construct()
{
if( $this->action ) {
/**
* The function that handles these actions are located in the
* classes that extend this class. The action is usually of the type 'get', 'post', or 'delete'
* These files inlcude:
* NF_AJAX_REST_BatchProcess
* NF_AJAX_REST_Forms
* NF_AJAX_REST_NewFormTemplates
* NF_AJAX_REST_RequiredUpdate
*
* And any other class that extends this class(NF_AJAX_REST_Controller)
*/
add_action('wp_ajax_' . $this->action, array($this, 'route'));
}
}
......@@ -44,7 +55,10 @@ abstract class NF_AJAX_REST_Controller extends NF_Abstracts_Controller
$this->_errors[] = __( 'Endpoint does not exist.', 'ninja-forms' );
$this->_respond();
}
/**
* This call get the $_REQUEST info for the call(post, get, etc.)
* being called.
*/
$request_data = $this->get_request_data();
try {
......
......@@ -43,6 +43,10 @@ abstract class NF_Abstracts_ActionNewsletter extends NF_Abstracts_Action
$this->_transient = $this->get_name() . '_newsletter_lists';
}
/**
* Ajax call handled in '_get_lists', but bulk of work could be done in
* the NewsLetter class that extends this class
*/
add_action( 'wp_ajax_nf_' . $this->_name . '_get_lists', array( $this, '_get_lists' ) );
$this->get_list_settings();
......
......@@ -39,7 +39,7 @@ class NF_Admin_CPT_Submission
// Filter our hidden columns by form ID.
add_action( 'wp', array( $this, 'filter_hidden_columns' ) );
// Save our hidden columns by form id.
// Save our hidden columns by form id. Ajax call handed in 'hide_columns' in this file
add_action( 'wp_ajax_nf_hide_columns', array( $this, 'hide_columns' ) );
add_action( 'trashed_post', array( $this, 'nf_trash_sub' ) );
......
<?php
// Ajax called handled just below
add_action( 'wp_ajax_ninja_forms_sendwp_remote_install', 'wp_ajax_ninja_forms_sendwp_remote_install_handler' );
function wp_ajax_ninja_forms_sendwp_remote_install_handler () {
......
......@@ -58,6 +58,10 @@ if ( ! class_exists( 'WP_Async_Request' ) ) {
public function __construct() {
$this->identifier = $this->prefix . '_' . $this->action;
/**
* Ajax calls handled by 'maybe_handle', which will most likely
* call the 'handle' function of the class that extended this class
*/
add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) );
add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) );
}
......
......@@ -29,7 +29,8 @@ final class NF_Tracking
// Temporary: Report previously opted-in users that were not already reported. @todo Remove after a couple of versions.
// add_action( 'admin_init', array( $this, 'report_optin' ) );
// Ajax call handled in 'maybe_opt_in' in this file
add_action( 'wp_ajax_nf_optin', array( $this, 'maybe_opt_in' ) );
add_filter( 'ninja_forms_check_setting_allow_tracking', array( $this, 'check_setting' ) );
add_filter( 'ninja_forms_update_setting_allow_tracking', array( $this, 'update_setting' ) );
......
<?php if ( ! defined( 'ABSPATH' ) ) exit;
// Ajax call handled just below this add_action call
add_action( 'wp_ajax_ninja_forms_ajax_migrate_database', 'ninja_forms_ajax_migrate_database' );
function ninja_forms_ajax_migrate_database(){
if( ! current_user_can( apply_filters( 'ninja_forms_admin_upgrade_migrate_database_capabilities', 'manage_options' ) ) ) return;
......@@ -20,6 +21,7 @@ function ninja_forms_ajax_migrate_database(){
wp_die();
}
// Ajax call handled just below this 'add_action' call
add_action( 'wp_ajax_ninja_forms_ajax_import_form', 'ninja_forms_ajax_import_form' );
function ninja_forms_ajax_import_form(){
if( ! current_user_can( apply_filters( 'ninja_forms_admin_upgrade_import_form_capabilities', 'manage_options' ) ) ) return;
......@@ -42,6 +44,7 @@ function ninja_forms_ajax_import_form(){
wp_die();
}
// Ajax call handled just below this 'add_action' call
add_action( 'wp_ajax_ninja_forms_ajax_import_fields', 'ninja_forms_ajax_import_fields' );
function ninja_forms_ajax_import_fields(){
if( ! current_user_can( apply_filters( 'ninja_forms_admin_upgrade_import_fields_capabilities', 'manage_options' ) ) ) return;
......
......@@ -63,6 +63,7 @@ class NF_Step_Processing
// //set_time_limit( 0 );
// }
// Ajax call handled in 'processing' in this file
add_action( 'wp_ajax_nf_' . $this->action, array( $this, 'processing' ) );
}
......
......@@ -43,6 +43,7 @@ class OAuth
] ) );
});
// These Ajax calls handled in 'connect' and 'disconnect', respectively
add_action( 'wp_ajax_nf_oauth_connect', [ $this, 'connect' ] );
add_action( 'wp_ajax_nf_oauth_disconnect', [ $this, 'disconnect' ] );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment