Automattic\WooCommerce\Internal\Jetpack
JetpackConnection::get_authorization_url
Get the authorization URL for the Jetpack connection.
Method of the class: JetpackConnection{}
No Hooks.
Returns
Array. Authorization data.
Usage
$result = JetpackConnection::get_authorization_url( $redirect_url, $from );
- $redirect_url(mixed) (required)
- Redirect URL.
- $from(string)
- From parameter.
Default:''
JetpackConnection::get_authorization_url() JetpackConnection::get authorization url code WC 10.7.0
public static function get_authorization_url( $redirect_url, $from = '' ) {
$manager = self::get_manager();
$errors = new WP_Error();
// Register the site to wp.com.
if ( ! $manager->is_connected() ) {
$result = $manager->try_registration();
if ( is_wp_error( $result ) ) {
$errors->add( $result->get_error_code(), $result->get_error_message() );
}
}
$calypso_env = defined( 'WOOCOMMERCE_CALYPSO_ENVIRONMENT' ) && in_array( WOOCOMMERCE_CALYPSO_ENVIRONMENT, array( 'development', 'wpcalypso', 'horizon', 'stage' ), true ) ? WOOCOMMERCE_CALYPSO_ENVIRONMENT : 'production';
$authorization_url = $manager->get_authorization_url( null, $redirect_url );
$authorization_url = add_query_arg( 'locale', self::get_wpcom_locale(), $authorization_url );
if ( Features::is_enabled( 'use-wp-horizon' ) ) {
$calypso_env = 'horizon';
}
$color_scheme = get_user_option( 'admin_color', get_current_user_id() );
if ( ! $color_scheme ) {
// The default Core color schema is 'fresh'.
$color_scheme = 'fresh';
}
return array(
'success' => ! $errors->has_errors(),
'errors' => $errors->get_error_messages(),
'color_scheme' => $color_scheme,
'url' => add_query_arg(
array(
'from' => $from,
'calypso_env' => $calypso_env,
),
$authorization_url,
),
);
}