Noptin_Ajax::import_forms()

Imports forms


Return Return

(void)


Top ↑

Source Source

File: includes/class-noptin-ajax.php

	public function import_forms() {

		// Ensure the nonce is valid...
		check_ajax_referer( 'noptin_admin_nonce' );

		// ... and that the user can import subscribers.
		if ( ! current_user_can( get_noptin_capability() ) ) {
			wp_die( -1, 403 );
		}

		// Maybe abort early.
		if ( ! isset( $_POST['forms'] ) ) {
			wp_die( -1, 400 );
		}

		// Prepare forms.
		$forms = json_decode( stripslashes_deep( $_POST['forms'] ), true );

		if ( ! is_array( $forms ) ) {
			_e( 'Invalid export file', 'newsletter-optin-box' );
			exit;
		}

		foreach ( $forms as $form ) {
			$form['id'] = null;
			$form       = new Noptin_Form( $form );
			$form->create();
		}

		wp_send_json_success( true );
		exit;

	}


Top ↑

Changelog Changelog

Changelog
VersionDescription
1.2.6Introduced.

Top ↑

User Contributed Notes User Contributed Notes

30 day money back guarantee
Safe & Secure online payment
Custom CSS Slide Example
Custom Animation Example
Default Animation