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