PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.2
JetFormBuilder — Dynamic Blocks Form Builder v3.1.2
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / includes / form-actions / import-form-trait.php
jetformbuilder / includes / form-actions Last commit date
types 2 years ago base-form-action.php 2 years ago form-actions-manager.php 2 years ago get-form-data.php 2 years ago import-form-trait.php 2 years ago
import-form-trait.php
63 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Form_Actions;
5
6 // If this file is called directly, abort.
7 if ( ! defined( 'WPINC' ) ) {
8 die;
9 }
10
11 trait Import_Form_Trait {
12
13 /**
14 * Import form by data
15 *
16 * @param array $form_data [description]
17 *
18 * @return [type] [description]
19 */
20 public function import_form( $form_data = array() ) {
21
22 $form_data = wp_parse_args(
23 $form_data,
24 array(
25 'post_title' => 'New form',
26 'post_status' => 'publish',
27 'post_content' => '',
28 )
29 );
30
31 $form_data['post_content'] = wp_slash( $form_data['post_content'] );
32
33 if ( isset( $form_data['meta_input'] ) && is_array( $form_data['meta_input'] ) ) {
34 foreach ( $form_data['meta_input'] as &$meta_value ) {
35 $unserialized = maybe_unserialize( $meta_value );
36
37 if ( $unserialized !== $meta_value ) {
38 $meta_value = $unserialized;
39 continue;
40 }
41 $meta_value = wp_slash( $meta_value );
42 }
43 }
44
45 $post_id = wp_insert_post(
46 array_merge(
47 $form_data,
48 array(
49 'post_type' => $this->post_type(),
50 )
51 )
52 );
53
54 if ( is_wp_error( $post_id ) ) {
55 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
56 wp_die( $post_id->get_error_message(), 'Error' );
57 }
58
59 return $post_id;
60 }
61
62 }
63