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/controllers/FrmTransLiteHooksController.php +64 -29 6.25 → trunk View file →
@@ -35,20 +35,43 @@
35 35 /**
36 36 * @return void
37 37 */
38 38 public static function load_admin_hooks() {
39 - add_action(
40 - 'admin_init',
41 - function () {
42 - self::fix_addon_hooks();
43 - }
44 - );
39 + add_action( 'frm_disconnected_gateway', 'FrmTransLiteAppController::maybe_remove_payment_cron', 10, 2 );
45 40
46 41 if ( class_exists( 'FrmTransHooksController', false ) ) {
47 42 add_action( 'frm_pay_show_square_options', 'FrmTransLiteAppController::add_repeat_cadence_value' );
48 43
49 - // Exit early, let the Payments submodule handle everything.
44 + add_action( 'frm_pay_show_stripe_options', 'FrmStrpLiteActionsController::add_action_options' );
45 +
46 + remove_action( 'admin_head', 'FrmTransListsController::add_list_hooks' );
47 + add_action( 'admin_head', 'FrmTransLiteListsController::add_list_hooks' );
48 +
49 + self::maybe_set_admin_menu();
50 +
51 + add_action(
52 + 'init',
53 + function () {
54 + if ( ! self::on_form_settings_page() ) {
55 + return;
56 + }
57 +
58 + $gateways = array_keys( FrmTransLiteAppHelper::get_gateways() );
59 +
60 + // If no additional gateways (Like Authorize.Net) are set, hide the Collect Payment action.
61 + // Since we have icons for Stripe, Square, and PayPal, we don't need the Collect Payment action.
62 + if ( ! array_diff( $gateways, array( 'stripe', 'square', 'paypal' ) ) ) {
63 + add_action( 'admin_print_styles', array( self::class, 'hide_collect_payment_action' ) );
64 + }
65 + }
66 + );
67 +
68 + // Exit early, let the Payments submodule handle everything else.
50 69 return;
70 + }//end if
71 +
72 + if ( self::on_form_settings_page() ) {
73 + add_action( 'admin_print_styles', array( self::class, 'hide_collect_payment_action' ) );
51 74 }
52 75
53 76 // Actions.
54 77 add_action( 'admin_menu', 'FrmTransLitePaymentsController::menu', 25 );
@@ -66,39 +89,51 @@
66 89 self::load_ajax_hooks();
67 90 }
68 91 }
69 92
70 - private static function load_ajax_hooks() {
71 - add_action( 'wp_ajax_frm_trans_refund', 'FrmTransLitePaymentsController::refund_payment' );
72 - add_action( 'wp_ajax_frm_trans_cancel', 'FrmTransLiteSubscriptionsController::cancel_subscription' );
93 + /**
94 + * @since 6.31
95 + *
96 + * @return bool
97 + */
98 + private static function on_form_settings_page() {
99 + return 'formidable' === FrmAppHelper::simple_get( 'page' ) && 'settings' === FrmAppHelper::simple_get( 'frm_action' );
73 100 }
74 101
75 102 /**
76 - * Make sure that Payments appear when there are inbox items for all Payments plugins.
103 + * Hide the Collect Payment action if there are no additional gateways enabled (like Authorize.Net).
77 104 *
78 - * @since 6.17.1
105 + * @since 6.31
79 106 *
80 107 * @return void
81 108 */
82 - private static function fix_addon_hooks() {
83 - $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count();
84 - if ( ! $unread_count ) {
85 - // Nothing to fix.
109 + public static function hide_collect_payment_action() {
110 + echo '
111 + <style>
112 + li.frm-action:has(.frm_payment_action) { display: none; }
113 + </style>
114 + ';
115 + }
116 +
117 + /**
118 + * @since 6.27
119 + *
120 + * @return void
121 + */
122 + private static function maybe_set_admin_menu() {
123 + if ( in_array( FrmAppHelper::simple_get( 'action' ), array( 'edit', 'new', 'bulk_delete' ), true ) ) {
124 + // We're still falling back to the Stripe, Authorize.Net, or PayPal add-on to handle these routes.
86 125 return;
87 126 }
88 127
89 - $menu_name = FrmAppHelper::get_menu_name();
90 - $hook_name = 'manage_' . sanitize_title( $menu_name ) . '-' . $unread_count . '_page_formidable-payments_columns';
128 + remove_action( 'admin_menu', 'FrmTransPaymentsController::menu', 25 );
129 + add_action( 'admin_menu', 'FrmTransLitePaymentsController::menu', 25 );
130 + }
91 131
92 - if ( FrmTransLiteAppHelper::should_fallback_to_paypal() && is_callable( 'FrmPaymentsController::payment_columns' ) ) {
93 - // Fallback to PayPal add-on.
94 - add_filter( $hook_name, 'FrmPaymentsController::payment_columns' );
95 - } elseif ( is_callable( 'FrmTransListsController::payment_columns' ) ) {
96 - // Fallback to the Payments submodule.
97 - add_filter( $hook_name, 'FrmTransListsController::payment_columns' );
98 - } else {
99 - return;
100 - }
101 -
102 - add_filter( 'screen_options_show_screen', 'FrmTransLiteListsController::remove_screen_options', 10, 2 );
132 + /**
133 + * @return void
134 + */
135 + private static function load_ajax_hooks() {
136 + add_action( 'wp_ajax_frm_trans_refund', 'FrmTransLitePaymentsController::refund_payment' );
137 + add_action( 'wp_ajax_frm_trans_cancel', 'FrmTransLiteSubscriptionsController::cancel_subscription' );
103 138 }
104 139 }