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