Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class WPF_API {
- public function __construct() {
- add_action( 'init', array( $this, 'get_actions' ) );
- add_action( 'after_setup_theme', array( $this, 'thrivecart' ) ); // after_setup_theme to get around issues with ThriveCart and headers already being sent by init
- add_action( 'wpf_update', array( $this, 'update_user' ) );
- add_action( 'wpf_update_tags', array( $this, 'update_tags' ) );
- add_action( 'wpf_add', array( $this, 'add_user' ) );
- // Import / update user actions
- add_action( 'wp_ajax_nopriv_wpf_update_user', array( $this, 'update_user' ) );
- add_action( 'wp_ajax_nopriv_wpf_add_user', array( $this, 'add_user' ) );
- }
- /**
- * Gets actions passed as query params
- *
- * @access public
- * @return void
- */
- public function get_actions() {
- if ( isset( $_REQUEST['wpf_action'] ) ) {
- if ( ! isset( $_REQUEST['access_key'] ) || $_REQUEST['access_key'] != wp_fusion()->settings->get( 'access_key' ) ) {
- wpf_log( 'error', 0, 'Webhook received but access key ' . $_REQUEST['access_key'] . ' was invalid.', array( 'source' => 'api' ) );
- wp_die( 'Invalid Access Key' );
- }
- if ( $_REQUEST['wpf_action'] == 'test' ) {
- echo json_encode( array( 'status' => 'success' ) );
- die();
- }
- if ( has_action( 'wp_ajax_nopriv_wpf_' . $_REQUEST['wpf_action'] ) ) {
- do_action( 'wp_ajax_nopriv_wpf_' . $_REQUEST['wpf_action'] );
- } else {
- do_action( 'wpf_' . $_REQUEST['wpf_action'] );
- }
- }
- }
Add Comment
Please, Sign In to add comment