PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.6
JetFormBuilder — Dynamic Blocks Form Builder v3.1.6
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 / get-form-data.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
get-form-data.php
81 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 Get_Form_Data {
12
13 /**
14 * Get post ID from the current request and validate user acess to this post
15 *
16 * @return false|int [type] [description]
17 */
18 public function get_post_id_from_request() {
19
20 /**
21 * Nonce verifies earlier
22 *
23 * @see \Jet_Form_Builder\Form_Actions\Base_Form_Action::do_action
24 */
25 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
26 $post_id = ! empty( $_GET['post'] ) ? absint( $_GET['post'] ) : false;
27
28 if ( ! $post_id ) {
29 wp_die( 'Form ID not found in the request', 'Error!' );
30 }
31
32 if ( ! $this->check_user_access( $post_id ) ) {
33 wp_die( 'You haven`t access to this form', 'Error!' );
34 }
35
36 return $post_id;
37 }
38
39 /**
40 * Returns from data by ID
41 *
42 * @param [type] $form_id [description]
43 *
44 * @return [type] [description]
45 */
46 public function get_from_data( $form_id ) {
47 $post = get_post( $form_id );
48 $meta_value = $this->parse_meta_value(
49 get_post_meta( $form_id ),
50 array( '_edit_lock' )
51 );
52
53 $for_encoding = $this->parse_form_data(
54 array(
55 'post_title' => $post->post_title,
56 'post_content' => $post->post_content,
57 'meta_input' => $meta_value,
58 )
59 );
60
61 return array( $post, $for_encoding );
62 }
63
64 public function parse_form_data( $data ) {
65 return $data;
66 }
67
68 private function parse_meta_value( $meta, $exclude = array() ) {
69 $response = array();
70
71 foreach ( $meta as $key => $value ) {
72 if ( in_array( $key, $exclude, true ) ) {
73 continue;
74 }
75 $response[ $key ] = $value[0];
76 }
77
78 return $response;
79 }
80 }
81