PluginProbe
Advanced Forms for ACF / trunk
Advanced Forms for ACF vtrunk
1.9.0 1.9.1 1.9.2.1 1.9.3 1.9.3.1 1.9.3.2 1.9.3.3 1.9.3.4 1.9.3.5 1.9.3.6 1.9.3.7 1.9.3.8 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.3.1 1.0.3.2 1.0.3.3 1.0.4 1.1.0 1.1.1 1.2.0 1.3.0 All 51 releases
advanced-forms / api / api-import-export.php

api-import-export.php in Advanced Forms for ACF trunk, at api/api-import-export.php

41 lines 712 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Prepares a form object for export.
5 *
6 * @since 1.7.0
7 *
8 */
9 function af_export_form( $form ) {
10 unset( $form['post_id'] );
11 return $form;
12 }
13
14
15 /**
16 * Imports a form object to a form post.
17 * A new post will be generated if none exists with the specific key.
18 *
19 * @since 1.7.0
20 *
21 */
22 function af_import_form( $form ) {
23 $post = af_form_post_from_key( $form['key'] );
24
25 $post_id = NULL;
26 if ( ! $post ) {
27 $post_id = wp_insert_post(array(
28 'post_title' => '',
29 'post_type' => 'af_form',
30 'post_status' => 'publish',
31 ));
32
33 if ( is_wp_error( $post_id ) ) {
34 return false;
35 }
36 } else {
37 $post_id = $post->ID;
38 }
39
40 return af_form_to_post( $form, $post_id );
41 }