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: Laying foundations for showing Advertising in menu for Jetpack sites #28088

Merged
merged 12 commits into from
Jan 13, 2023
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: enhancement

Blaze: Show Advertising in menu for Jetpack sites
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,10 @@ public function add_users_menu() {
*/
public function add_tools_menu() {
add_menu_page( esc_attr__( 'Tools', 'jetpack' ), __( 'Tools', 'jetpack' ), 'publish_posts', 'tools.php', null, 'dashicons-admin-tools', 75 );

// TODO: currently only open to sites that have en locale.
if ( false !== strpos( get_locale(), 'en_' ) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we're currently looking at the user locale, not the site locale. The site locale may make more sense on the long run in my opinion, but maybe we want to keep using the user locale here as well, for consistency?

I believe you can get that info from (new Automattic\Jetpack\Connection\Manager() )->get_connected_user_data()['user_locale']

This again highlights the need for a more accessible way to check if a site is eligible for Blaze, as I was mentioning here:
1386-gh-Automattic/dotcom-forge#issuecomment-1351085107

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but maybe we want to keep using the user locale here as well, for consistency?

Sounds good to me @jeherve! We'll start soon working on translating Blaze so we'll be able to remove this check altogether: p1673035073317699-slack-C04DZ725FEK

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you can get that info from (new Automattic\Jetpack\Connection\Manager() )->get_connected_user_data()['user_locale']

Thanks for mentioning this. It's super helpful 🙏

add_submenu_page( 'tools.php', esc_attr__( 'Advertising', 'jetpack' ), __( 'Advertising', 'jetpack' ), 'manage_options', 'https://wordpress.com/advertising/' . $this->domain, null, 1 );
}
add_submenu_page( 'tools.php', esc_attr__( 'Marketing', 'jetpack' ), __( 'Marketing', 'jetpack' ), 'publish_posts', 'https://wordpress.com/marketing/tools/' . $this->domain );
add_submenu_page( 'tools.php', esc_attr__( 'Earn', 'jetpack' ), __( 'Earn', 'jetpack' ), 'manage_options', 'https://wordpress.com/earn/' . $this->domain );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ public function test_add_tools_menu() {
// Check Import/Export menu always links to WP Admin.
$this->assertSame( 'export.php', array_pop( $submenu['tools.php'] )[2] );
$this->assertSame( 'import.php', array_pop( $submenu['tools.php'] )[2] );

$this->assertSame( 'https://wordpress.com/earn/' . static::$domain, array_pop( $submenu['tools.php'] )[2] );
$this->assertSame( 'https://wordpress.com/marketing/tools/' . static::$domain, array_pop( $submenu['tools.php'] )[2] );
$this->assertSame( 'https://wordpress.com/advertising/' . static::$domain, array_pop( $submenu['tools.php'] )[2] );
}

/**
Expand Down