Skip to content

Commit

Permalink
Check user is connected to wpcom
Browse files Browse the repository at this point in the history
  • Loading branch information
DustyReagan committed May 13, 2024
1 parent 8e5ec65 commit 1215b55
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,23 @@
*/

use Automattic\Jetpack\Connection\Client;
use Automattic\Jetpack\Connection\Manager as Connection_Manager;

if ( function_exists( 'wpcom_is_nav_redesign_enabled' ) && wpcom_is_nav_redesign_enabled() ) {
add_filter(
'insert_user_meta',
function ( $meta, $user, $update ) {
$locale = $meta['locale'];
$old_locale = get_user_locale( $user );
$locale = $meta['locale'];
$old_locale = get_user_locale( $user );
$is_user_connected = ( new Connection_Manager( 'jetpack' ) )->is_user_connected();

if ( ! $update || $old_locale === $locale ) {
// Only for locale changes on an existing user
if ( ! $update || $old_locale === $locale || ! $is_user_connected ) {
// Only proceed for locale changes on an existing connected WPCOM user.
return $meta;
}

if ( ! $locale ) {
// No locale means the "Site Default" option which is the Site language (WPLANG).
// No locale means the "Site Default" option, which is the Site language (WPLANG).
$locale = get_option( 'WPLANG', '' );
}

Expand Down

0 comments on commit 1215b55

Please sign in to comment.