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 / modules / gateways / gateways-editor-data.php
jetformbuilder / modules / gateways Last commit date
actions-abstract 2 years ago assets 2 years 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 years ago query-views 2 years ago rest-api 2 years ago scenarios-abstract 2 years ago tab-handlers 2 years ago table-views 2 years ago base-gateway-action.php 2 years ago base-gateway.php 2 years ago base-scenario-gateway.php 2 years ago gateways-editor-data.php 2 years ago legacy-base-gateway.php 2 years ago migrate-legacy-data.php 2 years ago module.php 2 years ago scenario-item.php 2 years ago
gateways-editor-data.php
125 lines
1 <?php
2
3
4 namespace JFB_Modules\Gateways;
5
6 // If this file is called directly, abort.
7 if ( ! defined( 'WPINC' ) ) {
8 die;
9 }
10
11 trait Gateways_Editor_Data {
12
13 private function labels() {
14 return array_merge(
15 array(
16 'notifications_before' => _x( 'Before payment processed:', 'Gateways editor data', 'jet-form-builder' ),
17 'notifications_success' => _x( 'On successful payment:', 'Gateways editor data', 'jet-form-builder' ),
18 'notifications_failed' => _x( 'On failed payment:', 'Gateways editor data', 'jet-form-builder' ),
19 'price_field' => _x( 'Price/amount field', 'Gateways editor data', 'jet-form-builder' ),
20 'message_success' => _x( 'Payment success message', 'Gateways editor data', 'jet-form-builder' ),
21 'message_failed' => _x( 'Payment failed message', 'Gateways editor data', 'jet-form-builder' ),
22 'use_success_redirect' => _x( 'Redirect to a page', 'Gateways editor data', 'jet-form-builder' ),
23 'action_order' => _x( 'Create payment order notification:', 'Gateways editor data', 'jet-form-builder' ),
24 'use_success_redirect_help' => _x(
25 'Enable this toggle to redirect a user after successful payment.',
26 'Gateways editor data',
27 'jet-form-builder'
28 ),
29 ),
30 $this->options_labels(),
31 $this->custom_labels()
32 );
33 }
34
35 public function default_messages() {
36 return array(
37 'success' => 'Payment success message',
38 'failed' => 'Payment failed message',
39 );
40 }
41
42 private function options_labels() {
43 $result = array();
44
45 foreach ( $this->rep_get_items() as $gateway ) {
46 /** @var Base_Gateway $gateway */
47 $result[ $gateway->get_id() ] = $gateway->options( 'label' );
48 }
49
50 return $result;
51 }
52
53 private function custom_labels() {
54 $result = array();
55
56 foreach ( $this->rep_get_items() as $gateway ) {
57 /** @var Base_Gateway $gateway */
58 $result = array_merge(
59 $result,
60 $this->join_keys(
61 $gateway->custom_labels(),
62 $gateway->get_id()
63 )
64 );
65 }
66
67 return $result;
68 }
69
70 private function join_keys( $source, $prefix ): array {
71 $custom_labels = array();
72
73 foreach ( $source as $key => $label ) {
74 $computed_key = "{$prefix}.{$key}";
75
76 if ( is_string( $label ) ) {
77 $custom_labels[ $computed_key ] = $label;
78 continue;
79 }
80 if ( is_array( $label ) ) {
81 $custom_labels = array_merge( $custom_labels, $this->join_keys( $label, $computed_key ) );
82 }
83 }
84
85 return $custom_labels;
86 }
87
88 private function gateways_additional() {
89 $result = array();
90
91 foreach ( $this->rep_get_items() as $gateway ) {
92 /** @var Base_Gateway $gateway */
93 $result[ $gateway->get_id() ] = $gateway->additional_editor_data();
94 }
95
96 return $result;
97 }
98
99 private function gateways_for_js() {
100 $result = array();
101
102 foreach ( $this->rep_get_items() as $gateway ) {
103 $result[] = array(
104 'value' => $gateway->get_id(),
105 'label' => $gateway->get_name(),
106 );
107 }
108
109 return $result;
110 }
111
112 public function editor_data() {
113 $result = array(
114 'allowed' => true,
115 'labels' => $this->labels(),
116 'list' => $this->gateways_for_js(),
117 'messages' => $this->default_messages(),
118 'additional' => $this->gateways_additional(),
119 );
120
121 return apply_filters( 'jet-form-builder/gateways/editor-data', $result );
122 }
123
124 }
125