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