ninja_forms_ajax_import_fields

The Ninja Forms ninja forms ajax import fields function.

Description

ninja_forms_ajax_import_fields(); 

Usage

  1. if ( !function_exists( 'ninja_forms_ajax_import_fields' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/lib/NF_Upgrade.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = ninja_forms_ajax_import_fields(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/lib/NF_Upgrade.php  
  1. function ninja_forms_ajax_import_fields() { 
  2. if( ! current_user_can( apply_filters( 'ninja_forms_admin_upgrade_import_fields_capabilities', 'manage_options' ) ) ) return; 
  3. $fields = stripslashes( $_POST[ 'fields' ] ); // TODO: How to sanitize serialized string? 
  4. $fields = maybe_unserialize( $fields ); 
  5.  
  6. foreach( $fields as $field ) { 
  7. Ninja_Forms()->form()->import_field( $field, $field[ 'id' ], TRUE ); 
  8.  
  9. echo json_encode( array( 'export' => $_POST[ 'fields' ], 'import' => $fields ) ); 
  10. wp_die();