classes/PodsComponents.php
public function admin_ajax() {

		if ( false === headers_sent() ) {
			pods_session_start();

			header( 'Content-Type: text/html; charset=' . get_bloginfo( 'charset' ) );
		}

		// Sanitize input @codingStandardsIgnoreLine
		$params = pods_unslash( (array) $_POST );

		foreach ( $params as $key => $value ) {
			if ( 'action' === $key ) {
				continue;
			}

			unset( $params[ $key ] );

			$params[ str_replace( '_podsfix_', '', $key ) ] = $value;
		}

		$params = (object) $params;

		$component = $params->component;
		$method    = $params->method;

		if ( ! isset( $component ) || ! isset( $this->components[ $component ] ) || ! isset( $this->settings['components'][ $component ] ) ) {
			pods_error( 'Invalid AJAX request', $this );
		}

		if ( ! isset( $params->_wpnonce ) || false === wp_verify_nonce( $params->_wpnonce, 'pods-component-' . $component . '-' . $method ) ) {
			pods_error( 'Unauthorized request', $this );
		}

		// Cleaning up $params
		unset( $params->action, $params->component, $params->method, $params->_wpnonce );

		$params = (object) apply_filters( "pods_component_ajax_{$component}_{$method}", $params, $component, $method );

		$output = false;

		// Component init
		if ( isset( $this->components[ $component ]['object'] ) && method_exists( $this->components[ $component ]['object'], 'init' ) ) {
			$this->components[ $component ]['object']->init( $this->settings['components'][ $component ], $component );
		}

		if ( isset( $this->components[ $component ]['object'] ) && ! method_exists( $this->components[ $component ]['object'], 'ajax_' . $method ) && method_exists( $this, 'admin_ajax_' . $method ) ) {
			// Handle internal methods
			$output = call_user_func( array( $this, 'admin_ajax_' . $method ), $component, $params );
		} elseif ( ! isset( $this->components[ $component ]['object'] ) || ! method_exists( $this->components[ $component ]['object'], 'ajax_' . $method ) ) {
			// Make sure method exists
			pods_error( 'API method does not exist', $this );
		} else {
			// Dynamically call the component method
			$output = call_user_func( array( $this->components[ $component ]['object'], 'ajax_' . $method ), $params );
		}

		if ( ! is_bool( $output ) ) {
			// @codingStandardsIgnoreLine
			echo $output;
		}

		die();
		// KBAI!
	}
public function admin_ajax() {

		if ( false === headers_sent() ) {
			pods_session_start();

			header( 'Content-Type: text/html; charset=' . get_bloginfo( 'charset' ) );
		}

		// Sanitize input @codingStandardsIgnoreLine
		$params = pods_unslash( (array) $_POST );

		foreach ( $params as $key => $value ) {
			if ( 'action' === $key ) {
				continue;
			}

			unset( $params[ $key ] );

			$params[ str_replace( '_podsfix_', '', $key ) ] = $value;
		}

		$params = (object) $params;

		$component = $params->component;
		$method    = $params->method;

		if ( ! isset( $component ) || ! isset( $this->components[ $component ] ) || ! isset( $this->settings['components'][ $component ] ) ) {
			pods_error( 'Invalid AJAX request', $this );
		}

		if ( ! isset( $params->_wpnonce ) || false === wp_verify_nonce( $params->_wpnonce, 'pods-component-' . $component . '-' . $method ) ) {
			pods_error( 'Unauthorized request', $this );
		}

		// Cleaning up $params
		unset( $params->action, $params->component, $params->method, $params->_wpnonce );

		$params = (object) apply_filters( "pods_component_ajax_{$component}_{$method}", $params, $component, $method );

		$output = false;

		// Component init
		if ( isset( $this->components[ $component ]['object'] ) && method_exists( $this->components[ $component ]['object'], 'init' ) ) {
			$this->components[ $component ]['object']->init( $this->settings['components'][ $component ], $component );
		}

		if ( isset( $this->components[ $component ]['object'] ) && ! method_exists( $this->components[ $component ]['object'], 'ajax_' . $method ) && method_exists( $this, 'admin_ajax_' . $method ) ) {
			// Handle internal methods
			$output = call_user_func( array( $this, 'admin_ajax_' . $method ), $component, $params );
		} elseif ( ! isset( $this->components[ $component ]['object'] ) || ! method_exists( $this->components[ $component ]['object'], 'ajax_' . $method ) ) {
			// Make sure method exists
			pods_error( 'API method does not exist', $this );
		} else {
			// Dynamically call the component method
			$output = call_user_func( array( $this->components[ $component ]['object'], 'ajax_' . $method ), $params );
		}

		if ( ! is_bool( $output ) ) {
			// @codingStandardsIgnoreLine
			echo $output;
		}

		die();
		// KBAI!
	}
public function admin_ajax ( ) { if ( false === headers_sent ( ) ) { pods_session_start ( ) ; header ( 'Content-Type: text/html; charset=' . get_bloginfo ( 'charset' ) ) ; } // Sanitize input @codingStandardsIgnoreLine $ params = pods_unslash ( ( array ) $ _POST ) ; foreach ( $ params as $ key => $ value ) { if ( 'action' === $ key ) { continue ; } unset ( $ params [ $ key ] ) ; $ params [ str_replace ( '_podsfix_' , '' , $ key ) ] = $ value ; } $ params = ( object ) $ params ; $ component = $ params -> component ; $ method = $ params -> method ; if ( ! isset ( $ component ) || ! isset ( $ this -> components [ $ component ] ) || ! isset ( $ this -> settings [ 'components' ] [ $ component ] ) ) { pods_error ( 'Invalid AJAX request' , $ this ) ; } if ( ! isset ( $ params -> _wpnonce ) || false === wp_verify_nonce ( $ params -> _wpnonce , 'pods-component-' . $ component . '-' . $ method ) ) { pods_error ( 'Unauthorized request' , $ this ) ; } // Cleaning up $params unset ( $ params -> action , $ params -> component , $ params -> method , $ params -> _wpnonce ) ; $ params = ( object ) apply_filters ( "pods_component_ajax_{$component}_{$method}" , $ params , $ component , $ method ) ; $ output = false ; // Component init if ( isset ( $ this -> components [ $ component ] [ 'object' ] ) && method_exists ( $ this -> components [ $ component ] [ 'object' ] , 'init' ) ) { $ this -> components [ $ component ] [ 'object' ] -> init ( $ this -> settings [ 'components' ] [ $ component ] , $ component ) ; } if ( isset ( $ this -> components [ $ component ] [ 'object' ] ) && ! method_exists ( $ this -> components [ $ component ] [ 'object' ] , 'ajax_' . $ method ) && method_exists ( $ this , 'admin_ajax_' . $ method ) ) { // Handle internal methods $ output = call_user_func ( array ( $ this , 'admin_ajax_' . $ method ) , $ component , $ params ) ; } elseif ( ! isset ( $ this -> components [ $ component ] [ 'object' ] ) || ! method_exists ( $ this -> components [ $ component ] [ 'object' ] , 'ajax_' . $ method ) ) { // Make sure method exists pods_error ( 'API method does not exist' , $ this ) ; } else { // Dynamically call the component method $ output = call_user_func ( array ( $ this -> components [ $ component ] [ 'object' ] , 'ajax_' . $ method ) , $ params ) ; } if ( ! is_bool ( $ output ) ) { // @codingStandardsIgnoreLine echo $ output ; } die ( ) ; // KBAI! }
Handle admin ajax

@since 2.0.0
Handle admin ajax