| @@ -35,18 +35,43 @@ | ||
| 35 | 35 | /** |
| 36 | 36 | * @return void |
| 37 | 37 | */ |
| 38 | 38 | public static function load_admin_hooks() { |
| 39 | + add_action( 'frm_disconnected_gateway', 'FrmTransLiteAppController::maybe_remove_payment_cron', 10, 2 ); | |
| 40 | + | |
| 39 | 41 | if ( class_exists( 'FrmTransHooksController', false ) ) { |
| 40 | 42 | add_action( 'frm_pay_show_square_options', 'FrmTransLiteAppController::add_repeat_cadence_value' ); |
| 41 | 43 | |
| 44 | + add_action( 'frm_pay_show_stripe_options', 'FrmStrpLiteActionsController::add_action_options' ); | |
| 45 | + | |
| 42 | 46 | remove_action( 'admin_head', 'FrmTransListsController::add_list_hooks' ); |
| 43 | 47 | add_action( 'admin_head', 'FrmTransLiteListsController::add_list_hooks' ); |
| 44 | 48 | |
| 45 | 49 | self::maybe_set_admin_menu(); |
| 46 | 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 | + | |
| 47 | 68 | // Exit early, let the Payments submodule handle everything else. |
| 48 | 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' ) ); | |
| 49 | 74 | } |
| 50 | 75 | |
| 51 | 76 | // Actions. |
| 52 | 77 | add_action( 'admin_menu', 'FrmTransLitePaymentsController::menu', 25 ); |
| @@ -62,8 +87,32 @@ | ||
| 62 | 87 | |
| 63 | 88 | if ( defined( 'DOING_AJAX' ) ) { |
| 64 | 89 | self::load_ajax_hooks(); |
| 65 | 90 | } |
| 91 | + } | |
| 92 | + | |
| 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' ); | |
| 100 | + } | |
| 101 | + | |
| 102 | + /** | |
| 103 | + * Hide the Collect Payment action if there are no additional gateways enabled (like Authorize.Net). | |
| 104 | + * | |
| 105 | + * @since 6.31 | |
| 106 | + * | |
| 107 | + * @return void | |
| 108 | + */ | |
| 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 | + '; | |
| 66 | 115 | } |
| 67 | 116 | |
| 68 | 117 | /** |
| 69 | 118 | * @since 6.27 |