PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.0.0.2
JetFormBuilder — Dynamic Blocks Form Builder v3.0.0.2
3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 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 / actions-tools.php
jetformbuilder / includes / actions Last commit date
conditions 3 years ago events 3 years ago methods 3 years ago types 3 years ago action-handler.php 3 years ago action-localize.php 3 years ago actions-tools.php 3 years ago events-list.php 3 years ago events-manager.php 3 years ago manager.php 3 years ago
actions-tools.php
113 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Actions;
5
6
7 use Jet_Form_Builder\Actions\Types\Base;
8 use Jet_Form_Builder\Classes\Resources\File_Tools;
9
10 class Actions_Tools {
11
12 public static function run_flow( string $flow_path ) {
13 $actions = self::get_flow( $flow_path );
14
15 foreach ( $actions as $action ) {
16 jet_fb_action_handler()->process_single_action( $action );
17 }
18 }
19
20 /**
21 * @param string $flow_path
22 *
23 * @return Base[]
24 */
25 public static function get_flow( string $flow_path ): array {
26 $flow = self::load_flow( $flow_path );
27 $actions = array();
28
29 foreach ( $flow as $action ) {
30 $current = jet_fb_action_handler()->add_hidden( $action['type'], $action );
31
32 if ( ! $current ) {
33 continue;
34 }
35 $current->settings = $action['settings'] ?? array();
36
37 $actions[] = $current;
38 }
39
40 return $actions;
41 }
42
43 /**
44 * @param string $flow_path
45 *
46 * @return array
47 */
48 public static function load_flow( string $flow_path ): array {
49 if ( ! file_exists( $flow_path ) ) {
50 return array();
51 }
52
53 return is_file( $flow_path )
54 ? self::load_flow_file( $flow_path )
55 : self::load_flow_dir( $flow_path );
56 }
57
58 private static function load_flow_dir( string $flow_dir ) {
59 $flow_dir = trailingslashit( $flow_dir );
60
61 $paths = array(
62 $flow_dir . 'flow.php',
63 $flow_dir . 'flow.json'
64 );
65
66 foreach ( $paths as $path ) {
67 $flow = self::load_flow( $path );
68
69 if ( ! $flow ) {
70 continue;
71 }
72
73 return $flow;
74 }
75
76 return false;
77 }
78
79 private static function load_flow_file( string $flow_file ) {
80 $flow = false;
81
82 switch ( File_Tools::get_file_ext( $flow_file ) ) {
83 case 'json':
84 $flow = self::load_flow_json( $flow_file );
85 break;
86 case 'php':
87 $flow = self::load_flow_php( $flow_file );
88 break;
89 }
90
91 if ( ! is_array( $flow ) || empty( $flow ) ) {
92 return array();
93 }
94
95 return $flow;
96 }
97
98 private static function load_flow_json( string $flow_file ) {
99 return wp_json_file_decode(
100 $flow_file,
101 array( 'associative' => true )
102 );
103 }
104
105 private static function load_flow_php( string $file_name ) {
106 if ( ! is_readable( $file_name ) ) {
107 return false;
108 }
109
110 return include_once $file_name;
111 }
112
113 }