PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 2.0.0
JetFormBuilder — Dynamic Blocks Form Builder v2.0.0
3.6.5.2 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 / gateways / gateways-editor-data.php
jetformbuilder / includes / gateways Last commit date
db-models 4 years ago meta-boxes 4 years ago pages 4 years ago paypal 4 years ago query-views 4 years ago scenarios-abstract 4 years ago table-views 4 years ago base-gateway-action.php 4 years ago base-gateway.php 4 years ago base-scenario-gateway.php 4 years ago gateway-manager.php 4 years ago gateways-editor-data.php 4 years ago legacy-base-gateway.php 4 years ago
gateways-editor-data.php
120 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Gateways;
5
6 use Jet_Form_Builder\Plugin;
7
8 trait Gateways_Editor_Data {
9
10 private function labels() {
11 return array_merge(
12 array(
13 'notifications_before' => _x( 'Before payment processed:', 'Gateways editor data', 'jet-form-builder' ),
14 'notifications_success' => _x( 'On successful payment:', 'Gateways editor data', 'jet-form-builder' ),
15 'notifications_failed' => _x( 'On failed payment:', 'Gateways editor data', 'jet-form-builder' ),
16 'price_field' => _x( 'Price/amount field', 'Gateways editor data', 'jet-form-builder' ),
17 'message_success' => _x( 'Payment success message', 'Gateways editor data', 'jet-form-builder' ),
18 'message_failed' => _x( 'Payment failed message', 'Gateways editor data', 'jet-form-builder' ),
19 'use_success_redirect' => _x( 'Use redirect URL from Redirect notification', 'Gateways editor data', 'jet-form-builder' ),
20 'action_order' => _x( 'Create payment order notification:', 'Gateways editor data', 'jet-form-builder' ),
21 ),
22 $this->options_labels(),
23 $this->custom_labels()
24 );
25 }
26
27 public function default_messages() {
28 return array(
29 'success' => 'Payment success message',
30 'failed' => 'Payment failed message',
31 );
32 }
33
34 private function options_labels() {
35 $result = array();
36
37 foreach ( $this->rep_get_items() as $gateway ) {
38 /** @var Base_Gateway $gateway */
39 $result[ $gateway->get_id() ] = $gateway->options( 'label' );
40 }
41
42 return $result;
43 }
44
45 private function custom_labels() {
46 $result = array();
47
48 foreach ( $this->rep_get_items() as $gateway ) {
49 /** @var Base_Gateway $gateway */
50 $result = array_merge(
51 $result,
52 $this->join_keys(
53 $gateway->custom_labels(),
54 $gateway->get_id()
55 )
56 );
57 }
58
59 return $result;
60 }
61
62 private function join_keys( $source, $prefix ): array {
63 $custom_labels = array();
64
65 foreach ( $source as $key => $label ) {
66 $computed_key = "{$prefix}.{$key}";
67
68 if ( is_string( $label ) ) {
69 $custom_labels[ $computed_key ] = $label;
70 continue;
71 }
72 if ( is_array( $label ) ) {
73 $custom_labels = array_merge( $custom_labels, $this->join_keys( $label, $computed_key ) );
74 }
75 }
76
77 return $custom_labels;
78 }
79
80 private function gateways_additional() {
81 $result = array();
82
83 foreach ( $this->rep_get_items() as $gateway ) {
84 /** @var Base_Gateway $gateway */
85 $result[ $gateway->get_id() ] = $gateway->additional_editor_data();
86 }
87
88 return $result;
89 }
90
91 private function gateways_for_js() {
92 $result = array();
93
94 foreach ( $this->rep_get_items() as $gateway ) {
95 $result[] = array(
96 'value' => $gateway->get_id(),
97 'label' => $gateway->get_name(),
98 );
99 }
100
101 return $result;
102 }
103
104 public function editor_data() {
105 $result = array(
106 'allowed' => Plugin::instance()->allow_gateways,
107 );
108
109 if ( $result['allowed'] ) {
110 $result['labels'] = $this->labels();
111 $result['list'] = $this->gateways_for_js();
112 $result['messages'] = $this->default_messages();
113 $result['additional'] = $this->gateways_additional();
114 }
115
116 return apply_filters( 'jet-form-builder/gateways/editor-data', $result );
117 }
118
119 }
120