PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 1.2.6
JetFormBuilder — Dynamic Blocks Form Builder v1.2.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 / actions / manager.php
jetformbuilder / includes / actions Last commit date
types 4 years ago action-handler.php 4 years ago action-localize.php 4 years ago manager.php 4 years ago
manager.php
145 lines
1 <?php
2
3 namespace Jet_Form_Builder\Actions;
4
5 // If this file is called directly, abort.
6
7 use Jet_Form_Builder\Actions\Types;
8 use Jet_Form_Builder\Admin\Editor;
9
10 if ( ! defined( 'WPINC' ) ) {
11 die;
12 }
13
14 /**
15 * Define Manager class
16 */
17 class Manager {
18
19 private $_types = array();
20 private $localized_actions = array();
21
22 const ENGINE_HANDLE = 'jet-fb-action-localize-helper';
23
24 public function __construct() {
25 add_action( 'init', array( $this, 'register_action_types' ), 99 );
26 add_action( 'jet-form-builder/editor-package/before', array( $this, 'register_assets' ), 10, 2 );
27 }
28
29 /**
30 * Register allowed action types
31 *
32 * @return [type] [description]
33 */
34 public function register_action_types() {
35
36 $actions = array(
37 new Types\Send_Email(),
38 new Types\Insert_Post(),
39 new Types\Register_User(),
40 new Types\Update_User(),
41 new Types\Update_Options(),
42 new Types\Call_Hook(),
43 new Types\Call_Webhook(),
44 new Types\Redirect_To_Page(),
45 new Types\Mailchimp(),
46 new Types\Getresponse(),
47 new Types\Active_Campaign()
48 );
49
50 foreach ( $actions as $action ) {
51 $this->register_action_type( $action );
52 }
53
54 do_action( 'jet-form-builder/actions/register', $this );
55 }
56
57 /**
58 * Register new action type
59 *
60 * @param Types\Base $type
61 *
62 * @return void [description]
63 */
64 public function register_action_type( Types\Base $type ) {
65 if ( $type->dependence() ) {
66 $this->_types[ $type->get_id() ] = $type;
67 }
68 }
69
70 /**
71 * @param string $type
72 *
73 * @return array
74 */
75 public function get_actions( $type = '' ) {
76 if ( $type ) {
77 return $this->_types[ $type ];
78 }
79
80 return $this->_types;
81 }
82
83 public function has_action_type( $type ) {
84 return isset( $this->_types[ $type ] );
85 }
86
87 public function prepare_actions_data( $source ) {
88 $prepared_types = array();
89
90 foreach ( $source as $type ) {
91
92 $type_script_name = $type->self_script_name();
93
94 $prepared_types[] = array(
95 'id' => $type->get_id(),
96 'name' => $type->get_name(),
97 'self' => $type_script_name,
98 'callback' => false, // should be rewritten from JS
99 );
100 $action_localize = $type->action_data();
101
102 $action_localize['__messages'] = $type->get_messages_default();
103 $action_localize['__labels'] = $type->editor_labels();
104 $action_localize['__help_messages'] = $type->editor_labels_help();
105 $action_localize['__gateway_attrs'] = $type->visible_attributes_for_gateway_editor();
106
107 if ( ! empty( $action_localize ) && $type_script_name ) {
108 $this->localized_actions[ $type->self_script_name() ] = $action_localize;
109 }
110 }
111
112 return $prepared_types;
113 }
114
115 public function register_action_types_assets( $handle ) {
116 foreach ( $this->localized_actions as $name => $localized_action ) {
117 wp_localize_script(
118 $handle,
119 $name,
120 $localized_action
121 );
122 }
123 }
124
125 public function register_assets( $editor, $handle ) {
126 wp_enqueue_script(
127 self::ENGINE_HANDLE,
128 JET_FORM_BUILDER_URL . 'assets/js/action-localize-helper.js',
129 array(),
130 JET_FORM_BUILDER_VERSION
131 );
132 $data = self::prepare_actions_data( $this->_types );
133
134 wp_localize_script(
135 self::ENGINE_HANDLE,
136 'jetFormActionTypes',
137 $data
138 );
139
140 $this->register_action_types_assets( self::ENGINE_HANDLE );
141 }
142
143
144 }
145