PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.4.1
JetFormBuilder — Dynamic Blocks Form Builder v3.6.4.1
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 / modules / gateways / migrate-legacy-data.php
jetformbuilder / modules / gateways Last commit date
actions-abstract 2 years ago assets 2 days ago db-models 2 years ago export 2 years ago legacy 2 years ago meta-boxes 2 years ago pages 2 years ago paypal 2 days ago query-views 2 years ago rest-api 8 months ago scenarios-abstract 2 years ago tab-handlers 2 years ago table-views 2 days ago base-gateway-action.php 1 year ago base-gateway.php 3 months ago base-scenario-gateway.php 2 years ago gateways-editor-data.php 2 days ago legacy-base-gateway.php 2 days ago migrate-legacy-data.php 2 years ago module.php 2 days ago scenario-item.php 2 years ago secure-price-notice.php 2 days ago trusted-price-resolver-expression-parser.php 2 days ago trusted-price-resolver.php 2 days ago
migrate-legacy-data.php
89 lines
1 <?php
2
3
4 namespace JFB_Modules\Gateways;
5
6 use Jet_Form_Builder\Actions\Events\Default_Process\Default_Process_Event;
7 use Jet_Form_Builder\Actions\Events\Gateway_Failed\Gateway_Failed_Event;
8 use Jet_Form_Builder\Actions\Events\Gateway_Success\Gateway_Success_Event;
9 use Jet_Form_Builder\Actions\Events_List;
10
11 // If this file is called directly, abort.
12 if ( ! defined( 'WPINC' ) ) {
13 die;
14 }
15
16 class Migrate_Legacy_Data {
17
18 protected $gateways;
19
20 public function __construct( array $gateways ) {
21 $this->gateways = $gateways;
22 }
23
24 public static function migrate( array $gateways ) {
25 if ( ! empty( $gateways['last_migrate'] ) ) {
26 return;
27 }
28 $self = new static( $gateways );
29
30 jet_fb_action_handler()->merge_events(
31 $self->get_actions_ids()
32 );
33 }
34
35 protected function get_actions_ids(): array {
36 $on_success = $this->get_active_actions( $this->gateways['notifications_success'] ?? array() );
37 $on_failed = $this->get_active_actions( $this->gateways['notifications_failed'] ?? array() );
38 $on_before = $this->get_active_actions( $this->gateways['notifications_before'] ?? array() );
39 $use_redirect = $this->gateways['use_success_redirect'] ?? false;
40
41 $has_redirect = false;
42
43 if ( ! $on_success && ! $on_failed && ! $on_before && ! $use_redirect ) {
44 return array();
45 }
46
47 $response = array();
48
49 foreach ( jet_fb_action_handler()->get_all() as $action ) {
50 $events = new Events_List();
51
52 if ( in_array( $action->_id, $on_success, true ) ) {
53 $events->push( Gateway_Success_Event::class );
54 }
55 if ( in_array( $action->_id, $on_failed, true ) ) {
56 $events->push( Gateway_Failed_Event::class );
57 }
58 if ( in_array( $action->_id, $on_before, true ) ) {
59 $events->push( Default_Process_Event::class );
60 }
61 if ( $use_redirect && ! $has_redirect && 'redirect_to_page' === $action->get_id() ) {
62 $events->push( Gateway_Success_Event::class );
63 $has_redirect = true;
64 }
65
66 if ( ! $events ) {
67 continue;
68 }
69
70 $response[ $action->_id ] = $events;
71 }
72
73 return $response;
74 }
75
76 protected function get_active_actions( $actions ): array {
77 $response = array();
78
79 foreach ( $actions as $id => $settings ) {
80 if ( ! empty( $settings['active'] ) ) {
81 $response[] = $id;
82 }
83 }
84
85 return $response;
86 }
87
88 }
89