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/FrmTransLiteAppController.php +9 -94 6.336.16 View file →
@@ -5,12 +5,8 @@
5 5
6 6 class FrmTransLiteAppController {
7 7
8 8 /**
9 - * Install or upgrade database structures.
10 - *
11 - * @param mixed $old_db_version Previous database version, or false on fresh install.
12 - *
13 9 * @return void
14 10 */
15 11 public static function install( $old_db_version = false ) {
16 12 self::maybe_schedule_cron();
@@ -44,25 +40,14 @@
44 40 }
45 41 }
46 42
47 43 /**
48 - * Remove the payment cron when all gateways are disconnected.
44 + * Remove the cron when the plugin is deactivated.
49 45 *
50 - * @since 6.32.1
51 - *
52 - * @param string $gateway 'stripe', 'square', or 'paypal'.
53 - * @param string $mode 'test' or 'live'.
54 - *
55 46 * @return void
56 47 */
57 - public static function maybe_remove_payment_cron( $gateway, $mode ) {
58 - $stripe_connected = FrmStrpLiteConnectHelper::at_least_one_mode_is_setup();
59 - $square_connected = FrmSquareLiteConnectHelper::at_least_one_mode_is_setup();
60 - $paypal_connected = FrmPayPalLiteConnectHelper::at_least_one_mode_is_setup();
61 -
62 - if ( ! $stripe_connected && ! $square_connected && ! $paypal_connected ) {
63 - wp_clear_scheduled_hook( 'frm_payment_cron' );
64 - }
48 + public static function remove_cron() {
49 + wp_clear_scheduled_hook( 'frm_payment_cron' );
65 50 }
66 51
67 52 /**
68 53 * Process overdue subscriptions.
@@ -69,27 +54,18 @@
69 54 *
70 55 * @return void
71 56 */
72 57 public static function run_payment_cron() {
73 - $frm_sub = new FrmTransLiteSubscription();
74 - $frm_payment = new FrmTransLitePayment();
58 + $frm_sub = new FrmTransLiteSubscription();
59 + $frm_payment = new FrmTransLitePayment();
60 +
75 61 $overdue_subscriptions = $frm_sub->get_overdue_subscriptions();
62 + FrmTransLiteLog::log_message( 'Stripe Cron Message', count( $overdue_subscriptions ) . ' subscriptions found to be processed.', false );
76 63
77 - if ( ! $overdue_subscriptions && ! $frm_sub->get_active_subscriptions() ) {
78 - return;
79 - }
80 -
81 - FrmTransLiteLog::log_message( 'Overdue Subscription Cron Message', count( $overdue_subscriptions ) . ' subscriptions found to be processed.', false );
82 -
83 64 foreach ( $overdue_subscriptions as $sub ) {
84 65 $last_payment = $frm_payment->get_one_by( $sub->id, 'sub_id' );
85 66
86 - if ( ! $last_payment ) {
87 - continue;
88 - }
89 -
90 67 $log_message = 'Subscription #' . $sub->id . ': ';
91 -
92 68 if ( $sub->status === 'future_cancel' ) {
93 69 FrmTransLiteSubscriptionsController::change_subscription_status(
94 70 array(
95 71 'status' => 'canceled',
@@ -101,9 +77,9 @@
101 77 $log_message .= 'Failed triggers run on canceled subscription. ';
102 78 } else {
103 79 // Get the most recent payment after the gateway has a chance to create one.
104 80 $check_payment = $frm_payment->get_one_by( $sub->id, 'sub_id' );
105 - $new_payment = (int) $check_payment->id !== (int) $last_payment->id;
81 + $new_payment = $check_payment->id != $last_payment->id;
106 82 $last_payment = $check_payment;
107 83 $status = 'no';
108 84
109 85 if ( ! $last_payment ) {
@@ -121,15 +97,14 @@
121 97 $last_payment = false;
122 98 }
123 99
124 100 $log_message .= $status . ' triggers run ';
125 -
126 101 if ( $last_payment ) {
127 102 $log_message .= 'on payment #' . $last_payment->id;
128 103 }
129 104 }//end if
130 105
131 - FrmTransLiteLog::log_message( 'Overdue Subscription Cron Message', $log_message );
106 + FrmTransLiteLog::log_message( 'Stripe Cron Message', $log_message );
132 107
133 108 self::maybe_trigger_changes(
134 109 array(
135 110 'status' => $status,
@@ -148,9 +123,8 @@
148 123 * @return void
149 124 */
150 125 private static function update_sub_for_new_payment( $sub, $last_payment ) {
151 126 $frm_sub = new FrmTransLiteSubscription();
152 -
153 127 if ( $last_payment->status === 'complete' ) {
154 128 $frm_sub->update(
155 129 $sub->id,
156 130 array(
@@ -167,9 +141,8 @@
167 141 * Add to the fail count.
168 142 * If the subscription has failed > 3 times, set it to canceled.
169 143 *
170 144 * @param object $sub
171 - *
172 145 * @return void
173 146 */
174 147 private static function add_one_fail( $sub ) {
175 148 $frm_sub = new FrmTransLiteSubscription();
@@ -188,9 +161,8 @@
188 161 }
189 162
190 163 /**
191 164 * @param array $atts
192 - *
193 165 * @return void
194 166 */
195 167 private static function maybe_trigger_changes( $atts ) {
196 168 if ( $atts['payment'] ) {
@@ -195,63 +167,6 @@
195 167 private static function maybe_trigger_changes( $atts ) {
196 168 if ( $atts['payment'] ) {
197 169 FrmTransLiteActionsController::trigger_payment_status_change( $atts );
198 170 }
199 - }
200 -
201 - /**
202 - * This is called when the Payments submodule is active.
203 - * It ensures that the hidden repeater cadence input exists even when another add-on is handling the settings.
204 - *
205 - * @since 6.22
206 - *
207 - * @param array $args
208 - *
209 - * @return void
210 - */
211 - public static function add_repeat_cadence_value( $args ) {
212 - $action = $args['form_action'];
213 -
214 - if ( empty( $action->post_content['repeat_cadence'] ) ) {
215 - return;
216 - }
217 -
218 - $params = array(
219 - 'type' => 'hidden',
220 - 'class' => 'frm-repeat-cadence-value',
221 - 'value' => $action->post_content['repeat_cadence'],
222 - );
223 - echo '<input ';
224 - FrmAppHelper::array_to_html_params( $params, true );
225 - echo ' />';
226 - }
227 -
228 - /**
229 - * Gateway fields are included for add-on compatibility but we do not want it to be visible.
230 - * They do however need to be visible when the payments submodule is active.
231 - *
232 - * @since 6.30
233 - *
234 - * @return void
235 - */
236 - public static function hide_gateway_fields_in_builder() {
237 - wp_add_inline_style(
238 - 'formidable-admin',
239 - '
240 - #frm_builder_page li[data-ftype="gateway"] { display: none; }
241 - .frm_field_box:has(li[data-ftype="gateway"]:only-child) { display: none; }
242 - '
243 - );
244 - }
245 -
246 - /**
247 - * Remove the cron when the plugin is deactivated.
248 - *
249 - * @deprecated 6.32.1
250 - *
251 - * @return void
252 - */
253 - public static function remove_cron() {
254 - _deprecated_function( __METHOD__, '6.32.1' );
255 - wp_clear_scheduled_hook( 'frm_payment_cron' );
256 171 }
257 172 }