WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

Automattic\WooCommerce\Admin\API

Plugins::finish_wccom_connect() public WC 1.0

Finishes connecting to WooCommerce.com.

Ищем WP-разработчика! Фулл-тайм, удаленка, хорошая зарплата, соц. пакет. Подробности.
Компания Boosta.

{} Это метод класса: Plugins{}

Хуки из метода

Возвращает

WP_Error|Массив. Contains success status.

Использование

$Plugins = new Plugins();
$Plugins->finish_wccom_connect( $rest_request );
$rest_request(объект) (обязательный)
Request details.

Код Plugins::finish_wccom_connect() WC 5.8.0

public function finish_wccom_connect( $rest_request ) {
	include_once WC_ABSPATH . 'includes/admin/helper/class-wc-helper.php';
	include_once WC_ABSPATH . 'includes/admin/helper/class-wc-helper-api.php';
	include_once WC_ABSPATH . 'includes/admin/helper/class-wc-helper-updater.php';
	include_once WC_ABSPATH . 'includes/admin/helper/class-wc-helper-options.php';
	if ( ! class_exists( 'WC_Helper_API' ) ) {
		return new \WP_Error( 'woocommerce_rest_helper_not_active', __( 'There was an error loading the WooCommerce.com Helper API.', 'woocommerce' ), 404 );
	}

	// Obtain an access token.
	$request = \WC_Helper_API::post(
		'oauth/access_token',
		array(
			'body' => array(
				'request_token' => wp_unslash( $rest_request['request_token'] ), // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
				'home_url'      => home_url(),
			),
		)
	);

	$code = wp_remote_retrieve_response_code( $request );
	if ( 200 !== $code ) {
		return new \WP_Error( 'woocommerce_rest_helper_connect', __( 'There was an error connecting to WooCommerce.com. Please try again.', 'woocommerce' ), 500 );
	}

	$access_token = json_decode( wp_remote_retrieve_body( $request ), true );
	if ( ! $access_token ) {
		return new \WP_Error( 'woocommerce_rest_helper_connect', __( 'There was an error connecting to WooCommerce.com. Please try again.', 'woocommerce' ), 500 );
	}

	\WC_Helper_Options::update(
		'auth',
		array(
			'access_token'        => $access_token['access_token'],
			'access_token_secret' => $access_token['access_token_secret'],
			'site_id'             => $access_token['site_id'],
			'user_id'             => get_current_user_id(),
			'updated'             => time(),
		)
	);

	if ( ! \WC_Helper::_flush_authentication_cache() ) {
		\WC_Helper_Options::update( 'auth', array() );
		return new \WP_Error( 'woocommerce_rest_helper_connect', __( 'There was an error connecting to WooCommerce.com. Please try again.', 'woocommerce' ), 500 );
	}

	delete_transient( '_woocommerce_helper_subscriptions' );
	\WC_Helper_Updater::flush_updates_cache();

	do_action( 'woocommerce_helper_connected' );

	return array(
		'success' => true,
	);
}