| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
die( 'You are not allowed to call this page directly.' ); |
| 4 |
} |
| 5 |
|
| 6 |
class FrmStrpLiteHooksController { |
| 7 |
|
| 8 |
/** |
| 9 |
* @return void |
| 10 |
*/ |
| 11 |
public static function load_hooks() { |
| 12 |
if ( class_exists( 'FrmStrpHooksController', false ) ) { |
| 13 |
// Exit early, let the Stripe add on handle everything. |
| 14 |
return; |
| 15 |
} |
| 16 |
|
| 17 |
// Actions. |
| 18 |
add_action( 'frm_entry_form', 'FrmStrpLiteAuth::add_hidden_token_field' ); |
| 19 |
add_action( 'frm_enqueue_form_scripts', 'FrmStrpLiteActionsController::maybe_load_scripts' ); |
| 20 |
add_action( 'init', 'FrmStrpLiteConnectHelper::check_for_stripe_connect_webhooks' ); |
| 21 |
|
| 22 |
// Filters. |
| 23 |
add_filter( 'frm_saved_errors', 'FrmStrpLiteAppController::maybe_add_payment_error', 10, 2 ); |
| 24 |
add_filter( 'frm_filter_final_form', 'FrmStrpLiteAuth::maybe_show_message' ); |
| 25 |
add_filter( 'frm_setup_edit_entry_vars', 'FrmStrpLiteAppController::maybe_delete_pay_entry', 20, 2 ); |
| 26 |
|
| 27 |
add_filter( 'frm_pro_show_card_callback', 'FrmStrpLiteActionsController::maybe_show_card', 10, 2 ); |
| 28 |
|
| 29 |
// This filter hides gateway fields from the entries list. |
| 30 |
add_filter( |
| 31 |
'frm_fields_in_entries_list_table', |
| 32 |
function ( $form_cols ) { |
| 33 |
return array_filter( |
| 34 |
$form_cols, |
| 35 |
/** |
| 36 |
* @param stdClass $form_col |
| 37 |
* |
| 38 |
* @return bool |
| 39 |
*/ |
| 40 |
function ( $form_col ) { |
| 41 |
return 'gateway' !== $form_col->type; |
| 42 |
} |
| 43 |
); |
| 44 |
} |
| 45 |
); |
| 46 |
|
| 47 |
add_filter( 'frm_payment_gateways', 'FrmStrpLiteAppController::add_gateway' ); |
| 48 |
add_filter( 'frm_validate_credit_card_field_entry', 'FrmStrpLiteActionsController::remove_cc_validation', 20, 3 ); |
| 49 |
|
| 50 |
// Stripe link. |
| 51 |
add_filter( 'frm_form_object', 'FrmStrpLiteLinkController::force_ajax_submit_for_stripe_link' ); |
| 52 |
add_action( 'frm_form_classes', 'FrmStrpLiteLinkController::add_form_classes' ); |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* @return void |
| 57 |
*/ |
| 58 |
public static function load_admin_hooks() { |
| 59 |
if ( class_exists( 'FrmStrpHooksController', false ) ) { |
| 60 |
// Exit early, let the Stripe add on handle everything. |
| 61 |
return; |
| 62 |
} |
| 63 |
|
| 64 |
// Actions. |
| 65 |
add_action( 'frm_after_uninstall', 'FrmStrpLiteAppController::uninstall' ); |
| 66 |
add_filter( 'frm_add_settings_section', 'FrmStrpLiteSettingsController::add_settings_section' ); |
| 67 |
add_action( 'frm_update_settings', 'FrmStrpLiteSettingsController::process_form' ); |
| 68 |
|
| 69 |
// Filters. |
| 70 |
add_filter( 'frm_pay_action_defaults', 'FrmStrpLiteActionsController::add_action_defaults' ); |
| 71 |
add_filter( 'frm_before_save_payment_action', 'FrmStrpLiteActionsController::before_save_settings', 10, 2 ); |
| 72 |
add_filter( 'frm_pay_stripe_receipt', 'FrmStrpLitePaymentsController::get_receipt_link' ); |
| 73 |
add_filter( 'frm_sub_stripe_receipt', 'FrmStrpLitePaymentsController::get_receipt_link' ); |
| 74 |
|
| 75 |
if ( defined( 'DOING_AJAX' ) ) { |
| 76 |
self::load_ajax_hooks(); |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* @return void |
| 82 |
*/ |
| 83 |
private static function load_ajax_hooks() { |
| 84 |
$frm_strp_events_controller = new FrmStrpLiteEventsController(); |
| 85 |
add_action( 'wp_ajax_nopriv_frm_strp_process_events', array( &$frm_strp_events_controller, 'process_connect_events' ) ); |
| 86 |
add_action( 'wp_ajax_frm_strp_process_events', array( &$frm_strp_events_controller, 'process_connect_events' ) ); |
| 87 |
add_action( 'wp_ajax_nopriv_frm_strp_amount', 'FrmStrpLiteAuth::update_intent_ajax' ); |
| 88 |
add_action( 'wp_ajax_frm_strp_amount', 'FrmStrpLiteAuth::update_intent_ajax' ); |
| 89 |
|
| 90 |
// Stripe link. |
| 91 |
add_action( 'wp_ajax_nopriv_frmstrplinkreturn', 'FrmStrpLiteLinkController::handle_return_url' ); |
| 92 |
add_action( 'wp_ajax_frmstrplinkreturn', 'FrmStrpLiteLinkController::handle_return_url' ); |
| 93 |
|
| 94 |
// Stripe Lite. |
| 95 |
add_action( 'wp_ajax_nopriv_frm_strp_lite_verify', 'FrmStrpLiteConnectHelper::verify' ); |
| 96 |
} |
| 97 |
} |
| 98 |
|