wordpress/wp-content/themes/basic/themify/themify-builder/includes/optin-services/base.php
/**
	 * Handles the Ajax request for subscription form
	 *
	 * Hooked to wp_ajax_tb_optin_subscribe
	 */
Handles the Ajax request for subscription form
Hooked to wp_ajax_tb_optin_subscribe
Handles the Ajax request for subscription form Hooked to wp_ajax_tb_optin_subscribe
public static function ajax_subscribe() {
		if ( ! isset( $_POST['tb_optin_provider'], $_POST['tb_optin_fname'], $_POST['tb_optin_lname'], $_POST['tb_optin_email'] ) ) {
			wp_send_json_error( array( 'error' => __( 'Required fields are empty.', 'themify' ) ) );
		}
		$data = array();
		foreach ( $_POST as $key => $value ) {
			$key = preg_replace( '/^tb_optin_/', '', $key );
			$data[ $key ] = sanitize_text_field( trim( $value ) );
		}
		if ( $provider = self::get_providers( $data['provider'] ) ) {
			$result = $provider->subscribe( $data );
			if ( is_wp_error( $result ) ) {
				wp_send_json_error( array( 'error' => $result->get_error_message() ) );
			} else {
				wp_send_json_success( array(
					'redirect' => add_query_arg( array(
						'fname' => $data['fname'],
						'lname' => $data['lname'],
						'email' => $data['email'],
					), $data['redirect'] )
				) );
			}
		} else {
			wp_send_json_error( array( 'error' => __( 'Unknown provider.', 'themify' ) ) );
		}
	}
public static function ajax_subscribe ( ) { if ( ! isset ( $ _POST [ 'tb_optin_provider' ] , $ _POST [ 'tb_optin_fname' ] , $ _POST [ 'tb_optin_lname' ] , $ _POST [ 'tb_optin_email' ] ) ) { wp_send_json_error ( array ( 'error' => __ ( 'Required fields are empty.' , 'themify' ) ) ) ; } $ data = array ( ) ; foreach ( $ _POST as $ key => $ value ) { $ key = preg_replace ( '/^tb_optin_/' , '' , $ key ) ; $ data [ $ key ] = sanitize_text_field ( trim ( $ value ) ) ; } if ( $ provider = self :: get_providers ( $ data [ 'provider' ] ) ) { $ result = $ provider -> subscribe ( $ data ) ; if ( is_wp_error ( $ result ) ) { wp_send_json_error ( array ( 'error' => $ result -> get_error_message ( ) ) ) ; } else { wp_send_json_success ( array ( 'redirect' => add_query_arg ( array ( 'fname' => $ data [ 'fname' ] , 'lname' => $ data [ 'lname' ] , 'email' => $ data [ 'email' ] , ) , $ data [ 'redirect' ] ) ) ) ; } } else { wp_send_json_error ( array ( 'error' => __ ( 'Unknown provider.' , 'themify' ) ) ) ; } }
Handles the Ajax request for subscription form
 Hooked to wp_ajax_tb_optin_subscribe
Handles the Ajax request for subscription form Hooked to wp_ajax_tb_optin_subscribe
// remove "tb_optin_" prefix from the $_POST data /* send name and email in GET, these may come useful when building the page that the visitor will be redirected to */