File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed
projects/packages/admin-ui Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change 11Significance: minor
22Type: changed
33
4- Sidebar upsell: hide when site is not connected to Jetpack.com .
4+ Hide the sidebar upsell when the site is not connected to Jetpack or is in offline mode .
Original file line number Diff line number Diff line change @@ -304,7 +304,8 @@ private static function should_show_upgrade_menu() {
304304 private static function is_site_and_user_connected () {
305305 $ connection_manager = self ::$ connection_manager ;
306306 if ( ! $ connection_manager && class_exists ( '\Automattic\Jetpack\Connection\Manager ' ) ) {
307- $ connection_manager = new \Automattic \Jetpack \Connection \Manager ();
307+ $ connection_manager = new \Automattic \Jetpack \Connection \Manager ();
308+ self ::$ connection_manager = $ connection_manager ;
308309 }
309310
310311 if (
Original file line number Diff line number Diff line change @@ -397,6 +397,26 @@ public function test_upgrade_menu_item_hidden_when_site_not_connected() {
397397 $ this ->assertUpgradeMenuItemAbsent ();
398398 }
399399
400+ /**
401+ * Upgrade item is absent when the user is not connected (site is connected).
402+ *
403+ * @return void
404+ */
405+ public function test_upgrade_menu_item_hidden_when_user_not_connected () {
406+ wp_set_current_user ( self ::$ admin_user_id );
407+ $ connection = $ this ->getMockBuilder ( 'Automattic\Jetpack\Connection\Manager ' )
408+ ->disableOriginalConstructor ()
409+ ->getMock ();
410+ $ connection ->method ( 'is_connected ' )->willReturn ( true );
411+ $ connection ->method ( 'is_user_connected ' )->willReturn ( false );
412+ Admin_Menu::set_connection_manager ( $ connection );
413+
414+ Admin_Menu::init ();
415+ do_action ( 'admin_menu ' );
416+
417+ $ this ->assertUpgradeMenuItemAbsent ();
418+ }
419+
400420 /**
401421 * Upgrade item is absent when the site is in offline (development) mode.
402422 *
You can’t perform that action at this time.
0 commit comments