| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
die( 'You are not allowed to call this page directly.' ); |
| 4 |
} |
| 5 |
|
| 6 |
class FrmSquareLiteHooksController { |
| 7 |
|
| 8 |
/** |
| 9 |
* @return void |
| 10 |
*/ |
| 11 |
public static function load_hooks() { |
| 12 |
add_action( 'frm_enqueue_form_scripts', 'FrmSquareLiteActionsController::maybe_load_scripts' ); |
| 13 |
add_filter( 'frm_validate_credit_card_field_entry', 'FrmSquareLiteActionsController::remove_cc_validation', 20, 3 ); |
| 14 |
|
| 15 |
add_filter( 'frm_payment_gateways', 'FrmSquareLiteAppController::add_gateway' ); |
| 16 |
|
| 17 |
add_action( 'init', 'FrmSquareLiteConnectHelper::check_for_redirects' ); |
| 18 |
|
| 19 |
// Use 20 so this happens after the Stripe add-on. |
| 20 |
add_filter( 'frm_pro_show_card_callback', 'FrmSquareLiteActionsController::maybe_show_card', 20, 2 ); |
| 21 |
} |
| 22 |
|
| 23 |
/** |
| 24 |
* @return void |
| 25 |
*/ |
| 26 |
public static function load_admin_hooks() { |
| 27 |
add_filter( 'frm_add_settings_section', 'FrmSquareLiteSettingsController::add_settings_section' ); |
| 28 |
add_action( 'frm_update_settings', 'FrmSquareLiteSettingsController::process_form' ); |
| 29 |
|
| 30 |
if ( defined( 'DOING_AJAX' ) ) { |
| 31 |
self::load_ajax_hooks(); |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* @return void |
| 37 |
*/ |
| 38 |
private static function load_ajax_hooks() { |
| 39 |
add_action( 'wp_ajax_frm_square_oauth', 'FrmSquareLiteAppController::handle_oauth' ); |
| 40 |
add_action( 'wp_ajax_frm_square_disconnect', 'FrmSquareLiteAppController::handle_disconnect' ); |
| 41 |
|
| 42 |
add_action( 'wp_ajax_frm_verify_buyer', 'FrmSquareLiteAppController::verify_buyer' ); |
| 43 |
add_action( 'wp_ajax_nopriv_frm_verify_buyer', 'FrmSquareLiteAppController::verify_buyer' ); |
| 44 |
|
| 45 |
$frm_square_events_controller = new FrmSquareLiteEventsController(); |
| 46 |
add_action( 'wp_ajax_nopriv_frm_square_process_events', array( &$frm_square_events_controller, 'process_events' ) ); |
| 47 |
add_action( 'wp_ajax_frm_square_process_events', array( &$frm_square_events_controller, 'process_events' ) ); |
| 48 |
|
| 49 |
// Verify Square Lite sites. |
| 50 |
add_action( 'wp_ajax_nopriv_frm_square_lite_verify', 'FrmSquareLiteConnectHelper::verify' ); |
| 51 |
} |
| 52 |
} |
| 53 |
|