PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
formidable / paypal / helpers / FrmPayPalLiteAppHelper.php

FrmPayPalLiteAppHelper.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More trunk, at paypal/helpers/FrmPayPalLiteAppHelper.php

116 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 die( 'You are not allowed to call this page directly.' );
4 }
5
6 class FrmPayPalLiteAppHelper {
7
8 /**
9 * @var FrmPayPalLiteSettings|null
10 */
11 private static $settings;
12
13 /**
14 * @return string
15 */
16 public static function plugin_path() {
17 return FrmAppHelper::plugin_path() . '/paypal/';
18 }
19
20 /**
21 * @return string
22 */
23 public static function plugin_folder() {
24 return basename( self::plugin_path() );
25 }
26
27 /**
28 * @return string
29 */
30 public static function plugin_url() {
31 return FrmAppHelper::plugin_url() . '/paypal/';
32 }
33
34 /**
35 * @return FrmPayPalLiteSettings
36 */
37 public static function get_settings() {
38 if ( ! isset( self::$settings ) ) {
39 self::$settings = new FrmPayPalLiteSettings();
40 }
41 return self::$settings;
42 }
43
44 /**
45 * @return string
46 *
47 * @psalm-return 'live'|'test'
48 */
49 public static function active_mode() {
50 return self::get_settings()->settings->test_mode ? 'test' : 'live';
51 }
52
53 /**
54 * Get PayPal button style configuration from form action settings
55 *
56 * @param object $form_action The form action object containing post_content.
57 *
58 * @return array PayPal button style configuration
59 */
60 public static function get_paypal_button_style( $form_action ) {
61 $button_layout = $form_action->post_content['button_layout'] ?? 'vertical';
62 $button_color = $form_action->post_content['button_color'] ?? 'default';
63 $button_label = $form_action->post_content['button_label'] ?? 'paypal';
64 $button_border_radius = $form_action->post_content['button_border_radius'] ?? 10;
65
66 return array(
67 'style' => array(
68 'layout' => $button_layout,
69 'color' => $button_color,
70 'shape' => 'rect',
71 // Default shape, could be made configurable
72 'label' => $button_label,
73 'messaging' => true,
74 // Show messaging under button
75 'borderRadius' => (int) $button_border_radius,
76 ),
77 );
78 }
79
80 /**
81 * Add education about PayPal fees.
82 *
83 * PayPal Commerce is not included in a grandfathered license, so its fees
84 * always apply there even though Stripe fees do not.
85 *
86 * @param string $content UTM Content for the admin upgrade link.
87 * @param array|false|string $gateway Gateway or list of gateways this applies to.
88 *
89 * @return void
90 */
91 public static function fee_education( $content = 'tip', $gateway = false ) {
92 if ( ! FrmAddonsController::payment_fees_apply( 'paypal' ) ) {
93 return;
94 }
95
96 $classes = 'frm-light-tip show_paypal';
97
98 if ( $gateway && ! array_intersect( (array) $gateway, array( 'paypal' ) ) ) {
99 $classes .= ' frm_hidden';
100 }
101
102 FrmTipsHelper::show_tip(
103 array(
104 'link' => array(
105 'campaign' => 'paypal-fee',
106 'content' => $content,
107 ),
108 'tip' => 'Pay as you go pricing: 3% fee per-transaction + PayPal fees.',
109 'call' => __( 'Upgrade to save on fees.', 'formidable' ),
110 'class' => $classes,
111 ),
112 'p'
113 );
114 }
115 }
116