Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blaze: only display UI to English customers. #28266

Merged
merged 7 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions projects/packages/blaze/changelog/update-blaze-conditions
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Only display the Blaze UI if the connected user's language is English.
2 changes: 1 addition & 1 deletion projects/packages/blaze/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-blaze",
"version": "0.3.3",
"version": "0.3.4-alpha",
"description": "Attract high-quality traffic to your site using Blaze. Using this service, you can advertise a post or page on some of the millions of pages across WordPress.com and Tumblr from just $5 per day.",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/blaze/#readme",
"bugs": {
Expand Down
21 changes: 18 additions & 3 deletions projects/packages/blaze/src/class-blaze.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
class Blaze {

const PACKAGE_VERSION = '0.3.3';
const PACKAGE_VERSION = '0.3.4-alpha';

/**
* The configuration method that is called from the jetpack-config package.
Expand Down Expand Up @@ -64,9 +64,24 @@ public function register() {
*/
public static function should_initialize() {
$should_initialize = true;
$user_data = ( defined( 'IS_WPCOM' ) && IS_WPCOM )
? array( 'user_locale' => get_user_locale() )
: ( new Jetpack_Connection() )->get_connected_user_data();

// These features currently only work on WordPress.com, so they should be connected for best experience.
if ( ! ( new Jetpack_Connection() )->is_user_connected() ) {
/*
* These features currently only work on WordPress.com,
* so the user should either be connected to WordPress.com for things to work,
* or be on a WordPress.com site where we have direct access to user data such as user locale.
*/
if ( ! $user_data ) {
$should_initialize = false;
}

// We currently do not show the UI for non-English WordPress.com users.
if (
! empty( $user_data['user_locale'] )
&& ! in_array( $user_data['user_locale'], array( 'en', 'en-gb' ), true )
) {
$should_initialize = false;
}

Expand Down