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
← All changes | stripe/helpers/FrmTransLiteAppHelper.php +69 -1 6.30 → trunk View file →
@@ -361,9 +361,22 @@
361 361 *
362 362 * @return int
363 363 */
364 364 public static function get_user_id_for_current_payment() {
365 - return is_user_logged_in() ? get_current_user_id() : 0;
365 + $user_id = is_user_logged_in() ? get_current_user_id() : 0;
366 +
367 + /**
368 + * Set the user who owns the payment being made.
369 + * This makes it possible for an add on to claim the payment for a user who isn't logged in yet,
370 + * for example when the same submission registers them.
371 + *
372 + * @since 6.35
373 + *
374 + * @param int $user_id The logged in user, or 0 for a guest.
375 + */
376 + $user_id = (int) apply_filters( 'frm_payment_user_id', $user_id );
377 +
378 + return max( 0, $user_id );
366 379 }
367 380
368 381 /**
369 382 * @param int $user_id
@@ -602,6 +615,61 @@
602 615 */
603 616 public static function should_fallback_to_paypal() {
604 617 _deprecated_function( __METHOD__, '6.27' );
605 618 return false;
619 + }
620 +
621 + /**
622 + * Render the gateway icon buttons for the payment action settings.
623 + *
624 + * @param array $gateways
625 + * @param WP_Post $form_action
626 + * @param FrmFormAction $action_control
627 + *
628 + * @return void
629 + */
630 + public static function show_gateway_buttons( $gateways, $form_action, $action_control ) {
631 + $gateway_order = array( 'stripe', 'square', 'paypal' );
632 + $gateways = self::sort_gateways( $gateways, $gateway_order );
633 +
634 + include self::plugin_path() . '/views/action-settings/gateway-buttons.php';
635 + }
636 +
637 + /**
638 + * Sort gateways by a predefined order.
639 + * Unlisted gateways are appended at the end.
640 + *
641 + * @param array $gateways
642 + * @param array $order Gateway keys in desired order.
643 + *
644 + * @return array
645 + */
646 + private static function sort_gateways( $gateways, $order ) {
647 + $sorted = array();
648 +
649 + foreach ( $order as $key ) {
650 + if ( isset( $gateways[ $key ] ) ) {
651 + $sorted[ $key ] = $gateways[ $key ];
652 + }
653 + }
654 +
655 + return $sorted + $gateways;
656 + }
657 +
658 + /**
659 + * @since 6.32.1
660 + *
661 + * @param string $gateway 'stripe', 'square', or 'paypal'.
662 + * @param string $mode 'test' or 'live'.
663 + *
664 + * @return void
665 + */
666 + public static function trigger_gateway_disconnected_hook( $gateway, $mode ) {
667 + /**
668 + * @since 6.32.1
669 + *
670 + * @param string $gateway 'stripe', 'square', or 'paypal'.
671 + * @param string $mode 'test' or 'live'.
672 + */
673 + do_action( 'frm_disconnected_gateway', $gateway, $mode );
606 674 }
607 675 }