summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/class.jetpack-client-server.php')
-rw-r--r--plugins/jetpack/class.jetpack-client-server.php37
1 files changed, 26 insertions, 11 deletions
diff --git a/plugins/jetpack/class.jetpack-client-server.php b/plugins/jetpack/class.jetpack-client-server.php
index 72af7db9..7793d77d 100644
--- a/plugins/jetpack/class.jetpack-client-server.php
+++ b/plugins/jetpack/class.jetpack-client-server.php
@@ -33,7 +33,6 @@ class Jetpack_Client_Server {
* @param int Jetpack Blog ID.
*/
do_action( 'jetpack_client_authorized', Jetpack_Options::get_option( 'id' ) );
- JetpackTracking::record_user_event( 'jpc_client_authorize_success' );
}
if ( wp_validate_redirect( $redirect ) ) {
@@ -44,6 +43,8 @@ class Jetpack_Client_Server {
wp_safe_redirect( Jetpack::admin_url() );
}
+ JetpackTracking::record_user_event( 'jpc_client_authorize_success' );
+
$this->do_exit();
}
@@ -63,7 +64,7 @@ class Jetpack_Client_Server {
update_option( 'jetpack_unique_connection', $jetpack_unique_connection );
//track unique connection
- $jetpack = $this->get_jetpack();;
+ $jetpack = $this->get_jetpack();
$jetpack->stat( 'connections', 'unique-connection' );
$jetpack->do_stats( 'server_side' );
@@ -129,24 +130,33 @@ class Jetpack_Client_Server {
return 'linked';
}
+ // If redirect_uri is SSO, ensure SSO module is enabled
+ parse_str( parse_url( $data['redirect_uri'], PHP_URL_QUERY ), $redirect_options );
+
+ /** This filter is documented in class.jetpack-cli.php */
+ $jetpack_start_enable_sso = apply_filters( 'jetpack_start_enable_sso', true );
+
+ $activate_sso = (
+ isset( $redirect_options['action'] ) &&
+ 'jetpack-sso' === $redirect_options['action'] &&
+ $jetpack_start_enable_sso
+ );
+ $other_modules = $activate_sso
+ ? array( 'sso' )
+ : array();
+
$redirect_on_activation_error = ( 'client' === $data['auth_type'] ) ? true : false;
if ( $active_modules = Jetpack_Options::get_option( 'active_modules' ) ) {
Jetpack::delete_active_modules();
- Jetpack::activate_default_modules( 999, 1, $active_modules, $redirect_on_activation_error, false );
+ Jetpack::activate_default_modules( 999, 1, array_merge( $active_modules, $other_modules ), $redirect_on_activation_error, false );
} else {
- Jetpack::activate_default_modules( false, false, array(), $redirect_on_activation_error, false );
- }
-
- // If redirect_uri is SSO, ensure SSO module is enabled
- parse_str( parse_url( $data['redirect_uri'], PHP_URL_QUERY ), $redirect_options );
- /** This filter is documented in class.jetpack-cli.php */
- if ( isset( $redirect_options['action'] ) && 'jetpack-sso' === $redirect_options['action'] && apply_filters( 'jetpack_start_enable_sso', true ) ) {
- Jetpack::activate_module( 'sso', false, false );
+ Jetpack::activate_default_modules( false, false, $other_modules, $redirect_on_activation_error, false );
}
// Since this is a fresh connection, be sure to clear out IDC options
Jetpack_IDC::clear_all_idc_options();
+ Jetpack_Options::delete_raw_option( 'jetpack_last_connect_url_check' );
// Start nonce cleaner
wp_clear_scheduled_hook( 'jetpack_clean_nonces' );
@@ -200,12 +210,17 @@ class Jetpack_Client_Server {
'redirect' => $redirect ? urlencode( $redirect ) : false,
), menu_page_url( 'jetpack', false ) );
+ // inject identity for analytics
+ $tracks_identity = jetpack_tracks_get_identity( get_current_user_id() );
+
$body = array(
'client_id' => Jetpack_Options::get_option( 'id' ),
'client_secret' => $client_secret->secret,
'grant_type' => 'authorization_code',
'code' => $data['code'],
'redirect_uri' => $redirect_uri,
+ '_ui' => $tracks_identity['_ui'],
+ '_ut' => $tracks_identity['_ut'],
);
$args = array(