PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 1.2.3
JetFormBuilder — Dynamic Blocks Form Builder v1.2.3
3.6.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
143 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 private $localized_actions = array();
20
21 const ENGINE_HANDLE = 'jet-fb-action-localize-helper';
22
23 public function __construct() {
24 add_action( 'init', array( $this, 'register_action_types' ), 99 );
25 add_action( 'jet-form-builder/editor-package/before', array( $this, 'register_assets' ), 10, 2 );
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 public function prepare_actions_data( $source ) {
87 $prepared_types = array();
88
89 foreach ( $source as $type ) {
90
91 $type_script_name = $type->self_script_name();
92
93 $prepared_types[] = array(
94 'id' => $type->get_id(),
95 'name' => $type->get_name(),
96 'self' => $type_script_name,
97 'callback' => false, // should be rewritten from JS
98 );
99 $action_localize = $type->action_data();
100
101 $action_localize['__messages'] = $type->get_messages_default();
102 $action_localize['__labels'] = $type->editor_labels();
103 $action_localize['__help_messages'] = $type->editor_labels_help();
104 $action_localize['__gateway_attrs'] = $type->visible_attributes_for_gateway_editor();
105
106 if ( ! empty( $action_localize ) && $type_script_name ) {
107 $this->localized_actions[ $type->self_script_name() ] = $action_localize;
108 }
109 }
110
111 return $prepared_types;
112 }
113
114 public function register_action_types_assets( $handle ) {
115 foreach ( $this->localized_actions as $name => $localized_action ) {
116 wp_localize_script(
117 $handle,
118 $name,
119 $localized_action
120 );
121 }
122 }
123
124 public function register_assets( $editor, $handle ) {
125 wp_enqueue_script(
126 self::ENGINE_HANDLE,
127 JET_FORM_BUILDER_URL . 'assets/js/action-localize-helper.js',
128 array(),
129 JET_FORM_BUILDER_VERSION
130 );
131 $data = self::prepare_actions_data( $this->_types );
132
133 wp_localize_script(
134 self::ENGINE_HANDLE,
135 'jetFormActionTypes',
136 $data
137 );
138
139 $this->register_action_types_assets( self::ENGINE_HANDLE );
140 }
141
142 }
143