PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.5.6.3
JetFormBuilder — Dynamic Blocks Form Builder v3.5.6.3
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 / modules / actions-v2 / insert-post / properties / base-post-action.php
jetformbuilder / modules / actions-v2 / insert-post / properties Last commit date
abstract-post-modifier.php 7 months ago base-post-action.php 1 year ago insert-action.php 1 year ago post-author-property.php 1 year ago post-comments-property.php 1 year ago post-content-property.php 1 year ago post-date-gmt-property.php 1 year ago post-date-property.php 1 year ago post-excerpt-property.php 1 year ago post-id-property.php 1 year ago post-meta-property.php 7 months ago post-modifier.php 7 months ago post-parent-property.php 1 year ago post-status-property.php 1 year ago post-terms-property.php 1 year ago post-thumbnail-property.php 8 months ago post-title-property.php 1 year ago post-type-property.php 1 year ago trash-action.php 1 year ago update-action.php 1 year ago
base-post-action.php
110 lines
1 <?php
2
3
4 namespace JFB_Modules\Actions_V2\Insert_Post\Properties;
5
6 use Jet_Form_Builder\Actions\Methods\Base_Modifier_Action;
7 use JFB_Modules\Actions_V2\Insert_Post\Insert_Post_Action;
8
9 // If this file is called directly, abort.
10 if ( ! defined( 'WPINC' ) ) {
11 die;
12 }
13
14 abstract class Base_Post_Action extends Base_Modifier_Action {
15
16 protected $inserted_id = 0;
17
18 /**
19 * Inserted ID getter.
20 *
21 * @return integer
22 */
23 public function get_inserted_id(): int {
24 return $this->inserted_id;
25 }
26
27 public function do_after() {
28 if ( ! $this->inserted_id ) {
29 return;
30 }
31 $this->add_inserted_post_id();
32 $this->add_context_once();
33
34 /**
35 * Perform any actions after post inserted/updated
36 */
37 do_action(
38 'jet-form-builder/action/after-post-' . $this->get_id(),
39 jet_fb_action_handler()->get_current_action(),
40 jet_fb_action_handler(),
41 $this
42 );
43 }
44
45 public function pre_check(): bool {
46 return apply_filters(
47 'jet-form-builder/action/insert-post/pre-check',
48 true,
49 $this->modifier->source_arr,
50 jet_fb_action_handler()->get_current_action()
51 );
52 }
53
54 public function add_inserted_post_id() {
55 $handler = jet_fb_action_handler();
56
57 if ( ! $handler->in_loop() ) {
58 return;
59 }
60
61 if ( empty( $handler->response_data['inserted_post_id'] ) ) {
62 $handler->response_data['inserted_post_id'] = $this->inserted_id;
63 jet_fb_context()->update_request( $this->inserted_id, 'inserted_post_id' );
64 } else {
65 $handler->response_data['inserted_posts'][] = array(
66 'post_id' => $this->inserted_id,
67 'action_id' => $handler->get_current_action()->_id,
68 );
69 }
70
71 $post_type = $this->modifier->source_arr['post_type'] ?? '';
72
73 if ( ! $post_type ) {
74 $post_type = get_post_type( $this->inserted_id );
75 }
76
77 $inserted_key = jet_fb_context()->get_unique_name(
78 'inserted_' . $post_type
79 );
80
81 jet_fb_context()->update_request( $this->inserted_id, $inserted_key );
82 }
83
84 public function add_context_once() {
85 if ( ! jet_fb_action_handler()->in_loop() ) {
86 return;
87 }
88 /**
89 * For Redirect to Page action
90 */
91 jet_fb_action_handler()->add_context_once(
92 'insert_post',
93 array(
94 Insert_Post_Action::get_context_post_key( $this->inserted_id ) => array_merge(
95 array(
96 '__action' => $this->get_id(),
97 'ID' => $this->inserted_id,
98 ),
99 $this->modifier->source_arr
100 ),
101 )
102 );
103 }
104
105 public function get_inserted(): int {
106 return $this->inserted_id;
107 }
108
109 }
110