AnsPress_Process_Form::ap_ajax()

Description #

Handle all anspress ajax requests.

Changelog #

VersionDescription
2.0.1Introduced.

Source #

File: includes/process-form.php

	public function ap_ajax() {
		$ajax_action = ap_isset_post_value( 'ap_ajax_action' );
		$form_action = ap_isset_post_value( 'ap_form_action' );

		if ( ! $ajax_action ) {
			exit;
		}

		$this->request = $_REQUEST; // phpcs:ignore WordPress.Security.NonceVerification.Recommended

		if ( $form_action ) {
			$this->is_ajax = true;
			$this->process_form();
			ap_ajax_json( $this->result );
		} else {
			$action = ap_sanitize_unslash( 'ap_ajax_action', 'r' );

			/**
				* ACTION: ap_ajax_[$action]
				* Action for processing Ajax requests
			 *
				* @since 2.0.1
				*/
			do_action( 'ap_ajax_' . $action );
		}

		// If reached to this point then there is something wrong.
		ap_ajax_json( 'something_wrong' );
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment