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