PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.16
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.16
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
← All changes | stripe/controllers/FrmTransLiteSubscriptionsController.php +26 -82 6.336.16 View file →
@@ -6,9 +6,8 @@
6 6 class FrmTransLiteSubscriptionsController extends FrmTransLiteCRUDController {
7 7
8 8 /**
9 9 * @param object $subscription
10 - *
11 10 * @return void
12 11 */
13 12 public static function load_sidebar_actions( $subscription ) {
14 13 $date_format = __( 'M j, Y @ G:i', 'formidable' );
@@ -24,14 +23,12 @@
24 23 /**
25 24 * @since 6.5
26 25 *
27 26 * @param object $subscription
28 - *
29 27 * @return void
30 28 */
31 29 public static function show_receipt_link( $subscription ) {
32 30 $link = esc_html( $subscription->sub_id );
33 -
34 31 if ( $subscription->sub_id !== 'None' ) {
35 32 /**
36 33 * Filter a receipt link for a specific gateway.
37 34 * For example, Stripe uses frm_sub_stripe_receipt.
@@ -42,15 +39,14 @@
42 39 */
43 40 $link = apply_filters( 'frm_sub_' . $subscription->paysys . '_receipt', $link );
44 41 }
45 42
46 - FrmAppHelper::kses_echo( $link, array( 'a' ) );
43 + echo FrmAppHelper::kses( $link, array( 'a' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
47 44 }
48 45
49 46 /**
50 47 * @param object $sub
51 48 * @param array $atts
52 - *
53 49 * @return void
54 50 */
55 51 public static function show_cancel_link( $sub, $atts = array() ) {
56 52 if ( ! isset( $sub->user_id ) ) {
@@ -64,9 +60,8 @@
64 60
65 61 /**
66 62 * @param object $sub
67 63 * @param array $atts
68 - *
69 64 * @return string
70 65 */
71 66 public static function cancel_link( $sub, $atts = array() ) {
72 67 $defaults = array(
@@ -92,61 +87,17 @@
92 87 * Handle routing to cancel a subscription.
93 88 *
94 89 * @return void
95 90 */
96 - public static function cancel_subscription() { // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh
91 + public static function cancel_subscription() {
97 92 check_ajax_referer( 'frm_trans_ajax', 'nonce' );
98 - FrmAppHelper::permission_check( 'frm_edit_entries' );
99 93
100 - $canceled = false;
101 - $sub_id = FrmAppHelper::get_param( 'sub', '', 'get', 'sanitize_text_field' );
102 -
94 + $sub_id = FrmAppHelper::get_param( 'sub', '', 'get', 'sanitize_text_field' );
103 95 if ( $sub_id ) {
104 96 $frm_sub = new FrmTransLiteSubscription();
105 97 $sub = $frm_sub->get_one( $sub_id );
106 -
107 98 if ( $sub ) {
108 - $reason = '';
109 - $debug_id = '';
110 -
111 - switch ( $sub->paysys ) {
112 - case 'stripe':
113 - $canceled = FrmStrpLiteAppHelper::call_stripe_helper_class( 'cancel_subscription', $sub->sub_id );
114 - break;
115 - case 'square':
116 - $canceled = FrmSquareLiteConnectHelper::cancel_subscription( $sub->sub_id );
117 - break;
118 - case 'paypal':
119 - $response = FrmPayPalLiteConnectHelper::cancel_subscription( $sub->sub_id );
120 -
121 - // Check for structured error response with message and debug_id (array or object)
122 - $reason = '';
123 - $debug_id = '';
124 - $canceled = false !== $response;
125 -
126 - if ( is_array( $response ) || is_object( $response ) ) {
127 - // Extract error details without type checks to avoid Mago type narrowing
128 - $response_array = is_array( $response ) ? $response : (array) $response;
129 - $reason = $response_array['message'] ?? '';
130 - // PayPal API returns debug_id (snake_case) in some cases and debugId (camelCase) in others
131 - $debug_id = $response_array['debug_id'] ?? $response_array['debugId'] ?? '';
132 -
133 - // If there's an error message or debug_id, the cancellation failed
134 - if ( $reason || $debug_id ) {
135 - $canceled = false;
136 - }
137 - } elseif ( false === $response ) {
138 - // Response is false, get error from static properties
139 - $reason = FrmPayPalLiteConnectHelper::get_latest_error_from_paypal_api();
140 - $debug_id = FrmPayPalLiteConnectHelper::get_latest_debug_id_from_paypal_api();
141 - $canceled = false;
142 - }
143 - break;
144 - default:
145 - $canceled = false;
146 - break;
147 - }//end switch
148 -
99 + $canceled = FrmStrpLiteAppHelper::call_stripe_helper_class( 'cancel_subscription', $sub->sub_id );
149 100 if ( $canceled ) {
150 101 self::change_subscription_status(
151 102 array(
152 103 'status' => 'future_cancel',
@@ -154,40 +105,20 @@
154 105 )
155 106 );
156 107
157 108 $message = __( 'Canceled', 'formidable' );
158 - // phpcs:ignore Universal.ControlStructures.DisallowLonelyIf.Found
159 109 } else {
160 - // If the reason is already a complete error message, use it directly
161 - // instead of wrapping it redundantly in "Failed (...)"
162 - if ( $reason && ! preg_match( '/^[A-Z_]+$/', $reason ) ) {
163 - $message = $reason;
164 - } else {
165 - $message = __( 'Failed', 'formidable' );
166 -
167 - if ( ! empty( $reason ) ) {
168 - $message .= ' (' . $reason . ')';
169 - }
170 - }
171 - }//end if
172 -
173 - if ( $debug_id ) {
174 - $message .= '<br><br>Debug ID: ' . esc_html( $debug_id );
110 + $message = __( 'Failed', 'formidable' );
175 111 }
176 112 } else {
177 113 $message = __( 'That subscription was not found', 'formidable' );
178 - }//end if
114 + }
179 115 } else {
180 116 $message = __( 'Oops! No subscription was selected for cancelation.', 'formidable' );
181 117 }//end if
182 118
183 - wp_die(
184 - sprintf(
185 - '<div class="%1$s">%2$s</div>',
186 - $canceled ? 'frm_updated_message' : 'frm_error_style',
187 - wp_kses_post( $message )
188 - )
189 - );
119 + echo esc_html( $message );
120 + wp_die();
190 121 }
191 122
192 123 /**
193 124 * @since 6.5, introduced in v1.12 of the Payments submodule.
@@ -192,9 +123,8 @@
192 123 /**
193 124 * @since 6.5, introduced in v1.12 of the Payments submodule.
194 125 *
195 126 * @param array $atts
196 - *
197 127 * @return void
198 128 */
199 129 public static function change_subscription_status( $atts ) {
200 130 $frm_sub = new FrmTransLiteSubscription();
@@ -204,13 +134,27 @@
204 134 FrmTransLiteActionsController::trigger_subscription_status_change( $atts['sub'] );
205 135 }
206 136
207 137 /**
208 - * @deprecated 6.27
209 - *
210 138 * @return string|null
211 139 */
212 140 public static function list_subscriptions_shortcode() {
213 - _deprecated_function( __METHOD__, '6.27' );
214 - return null;
141 + if ( ! is_user_logged_in() ) {
142 + return;
143 + }
144 +
145 + $frm_sub = new FrmTransLiteSubscription();
146 + $subscriptions = $frm_sub->get_all_for_user( get_current_user_id() );
147 + if ( empty( $subscriptions ) ) {
148 + return;
149 + }
150 +
151 + FrmTransLiteActionsController::actions_js();
152 +
153 + ob_start();
154 + include FrmTransLiteAppHelper::plugin_path() . '/views/subscriptions/list_shortcode.php';
155 + $content = ob_get_contents();
156 + ob_end_clean();
157 +
158 + return $content;
215 159 }
216 160 }