WC_Helper::_helper_auth_return()
Return from WooCommerce.com OAuth flow.
Method of the class: WC_Helper{}
Hooks from the method
Return
null
. Ничего (null).
Usage
$result = WC_Helper::_helper_auth_return();
WC_Helper::_helper_auth_return() WC Helper:: helper auth return code WC 8.0.2
private static function _helper_auth_return() { if ( empty( $_GET['wc-helper-nonce'] ) || ! wp_verify_nonce( wp_unslash( $_GET['wc-helper-nonce'] ), 'connect' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized self::log( 'Could not verify nonce in _helper_auth_return' ); wp_die( 'Something went wrong' ); } // Bail if the user clicked deny. if ( ! empty( $_GET['deny'] ) ) { /** * Fires when the Helper connection process is denied/cancelled. */ do_action( 'woocommerce_helper_denied' ); wp_safe_redirect( admin_url( 'admin.php?page=wc-addons§ion=helper' ) ); die(); } // We do need a request token... if ( empty( $_GET['request_token'] ) ) { self::log( 'Request token not found in _helper_auth_return' ); wp_die( 'Something went wrong' ); } // Obtain an access token. $request = WC_Helper_API::post( 'oauth/access_token', array( 'body' => array( 'request_token' => wp_unslash( $_GET['request_token'] ), // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized 'home_url' => home_url(), ), ) ); $code = wp_remote_retrieve_response_code( $request ); if ( 200 !== $code ) { self::log( sprintf( 'Call to oauth/access_token returned a non-200 response code (%d)', $code ) ); wp_die( 'Something went wrong' ); } $access_token = json_decode( wp_remote_retrieve_body( $request ), true ); if ( ! $access_token ) { self::log( sprintf( 'Call to oauth/access_token returned an invalid body: %s', wp_remote_retrieve_body( $request ) ) ); wp_die( 'Something went wrong' ); } self::update_auth_option( $access_token['access_token'], $access_token['access_token_secret'], $access_token['site_id'] ); /** * Fires when the Helper connection process has completed successfully. */ do_action( 'woocommerce_helper_connected' ); // Enable tracking when connected. if ( class_exists( 'WC_Tracker' ) ) { update_option( 'woocommerce_allow_tracking', 'yes' ); WC_Tracker::send_tracking_data( true ); } // If connecting through in-app purchase, redirects back to WooCommerce.com // for product installation. if ( ! empty( $_GET['wccom-install-url'] ) ) { wp_redirect( wp_unslash( $_GET['wccom-install-url'] ) ); exit; } wp_safe_redirect( add_query_arg( array( 'page' => 'wc-addons', 'section' => 'helper', 'wc-helper-status' => 'helper-connected', ), admin_url( 'admin.php' ) ) ); die(); }