Skip to content

Commit

Permalink
Masterbar Site Menu - Tell Calypso the current site via `?origin_site…
Browse files Browse the repository at this point in the history
…_id=` (#38401)

* Add origin_site_id param to the links on masterbar

* changelog

* Use Connection_Manager

* Use Connection_Manager for /read and /me/account

* Extract maybe_add_origin_site_id_to_url

* picky jetpack housekeeping goo

* composer too... dont foget, never forget, always forget...

* add another changelog... IS THIS THE END?

* it wasnt the end, its never the end...

* another composer lock... nesting dolls...

* where is my atreyu

* are we there yet?

---------

Co-authored-by: Addison-Stavlo <stavz01@gmail.com>
  • Loading branch information
okmttdhr and Addison-Stavlo authored Jul 18, 2024
1 parent 546cae1 commit 15f7929
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Add origin_site_id param to the links on masterbar
2 changes: 1 addition & 1 deletion projects/packages/jetpack-mu-wpcom/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
},
"autotagger": true,
"branch-alias": {
"dev-trunk": "5.46.x-dev"
"dev-trunk": "5.47.x-dev"
},
"textdomain": "jetpack-mu-wpcom",
"version-constants": {
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/jetpack-mu-wpcom/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-mu-wpcom",
"version": "5.46.0",
"version": "5.47.0-alpha",
"description": "Enhances your site with features powered by WordPress.com",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/jetpack-mu-wpcom/#readme",
"bugs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Jetpack_Mu_Wpcom main class.
*/
class Jetpack_Mu_Wpcom {
const PACKAGE_VERSION = '5.46.0';
const PACKAGE_VERSION = '5.47.0-alpha';
const PKG_DIR = __DIR__ . '/../';
const BASE_DIR = __DIR__ . '/';
const BASE_FILE = __FILE__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,26 @@
* @package automattic/jetpack-mu-wpcom
*/

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

define( 'WPCOM_ADMIN_BAR_UNIFICATION', true );

/**
* Adds the origin_site_id query parameter to a URL.
*
* @param string $url The URL to add the query param to.
* @return string The URL with the origin_site_id query parameter mey be added.
*/
function maybe_add_origin_site_id_to_url( $url ) {
$site_id = Connection_Manager::get_site_id();
if ( is_wp_error( $site_id ) ) {
return $url;
}

return add_query_arg( 'origin_site_id', $site_id, $url );
}

/**
* Enqueue assets needed by the WordPress.com admin bar.
*/
Expand Down Expand Up @@ -56,7 +72,6 @@ function wpcom_repurpose_wp_logo_as_all_sites_menu( $wp_admin_bar ) {
$wp_admin_bar->remove_node( $node->id );
}
}

$wp_admin_bar->remove_node( 'wp-logo' );
$wp_admin_bar->add_node(
array(
Expand All @@ -65,7 +80,7 @@ function wpcom_repurpose_wp_logo_as_all_sites_menu( $wp_admin_bar ) {
/* translators: Hidden accessibility text. */
__( 'All Sites', 'jetpack-mu-wpcom' ) .
'</span>',
'href' => 'https://wordpress.com/sites',
'href' => maybe_add_origin_site_id_to_url( 'https://wordpress.com/sites' ),
'meta' => array(
'menu_title' => __( 'All Sites', 'jetpack-mu-wpcom' ),
),
Expand All @@ -84,7 +99,7 @@ function wpcom_add_reader_menu( $wp_admin_bar ) {
array(
'id' => 'reader',
'title' => __( 'Reader', 'jetpack-mu-wpcom' ),
'href' => 'https://wordpress.com/read',
'href' => maybe_add_origin_site_id_to_url( 'https://wordpress.com/read' ),
'meta' => array(
'class' => 'wp-admin-bar-reader',
),
Expand All @@ -104,13 +119,12 @@ function wpcom_add_my_account_item_to_profile_menu( $wp_admin_bar ) {
// Adds the 'My Account' menu item before 'Log Out'.
$wp_admin_bar->remove_node( 'logout' );
}

$wp_admin_bar->add_node(
array(
'id' => 'wpcom-profile',
'parent' => 'user-actions',
'title' => __( 'My Account', 'jetpack-mu-wpcom' ),
'href' => 'https://wordpress.com/me/account',
'href' => maybe_add_origin_site_id_to_url( 'https://wordpress.com/me/account' ),
)
);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Adds checks to remove wpcom items and links in wp-admin for users who are not connected to wpcom.
2 changes: 1 addition & 1 deletion projects/plugins/mu-wpcom-plugin/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@
]
},
"config": {
"autoloader-suffix": "d9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ2_4_2_alpha"
"autoloader-suffix": "d9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ2_5_0_alpha"
}
}
4 changes: 2 additions & 2 deletions projects/plugins/mu-wpcom-plugin/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion projects/plugins/mu-wpcom-plugin/mu-wpcom-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Plugin Name: WordPress.com Features
* Description: Test plugin for the jetpack-mu-wpcom package
* Version: 2.4.2-alpha
* Version: 2.5.0-alpha
* Author: Automattic
* License: GPLv2 or later
* Text Domain: jetpack-mu-wpcom-plugin
Expand Down
2 changes: 1 addition & 1 deletion projects/plugins/mu-wpcom-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-mu-wpcom-plugin",
"version": "2.4.2-alpha",
"version": "2.5.0-alpha",
"description": "Test plugin for the jetpack-mu-wpcom package",
"homepage": "https://jetpack.com",
"bugs": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Adds checks to remove wpcom items and links in wp-admin for users who are not connected to wpcom.
2 changes: 1 addition & 1 deletion projects/plugins/wpcomsh/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"composer/installers": true,
"roots/wordpress-core-installer": true
},
"autoloader-suffix": "26841ac2064774301cbe06d174833bfc_wpcomshⓥ4_0_0"
"autoloader-suffix": "26841ac2064774301cbe06d174833bfc_wpcomshⓥ4_1_0_alpha"
},
"extra": {
"mirror-repo": "Automattic/wpcom-site-helper",
Expand Down
50 changes: 25 additions & 25 deletions projects/plugins/wpcomsh/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion projects/plugins/wpcomsh/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "@automattic/jetpack-wpcomsh",
"description": "A helper for connecting WordPress.com sites to external host infrastructure.",
"homepage": "https://jetpack.com",
"version": "4.0.0",
"version": "4.1.0-alpha",
"bugs": {
"url": "https://github.com/Automattic/jetpack/labels/[Plugin] Wpcomsh"
},
Expand Down
4 changes: 2 additions & 2 deletions projects/plugins/wpcomsh/wpcomsh.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
/**
* Plugin Name: WordPress.com Site Helper
* Description: A helper for connecting WordPress.com sites to external host infrastructure.
* Version: 4.0.0
* Version: 4.1.0-alpha
* Author: Automattic
* Author URI: http://automattic.com/
*
* @package wpcomsh
*/

define( 'WPCOMSH_VERSION', '4.0.0' );
define( 'WPCOMSH_VERSION', '4.1.0-alpha' );

// If true, Typekit fonts will be available in addition to Google fonts
add_filter( 'jetpack_fonts_enable_typekit', '__return_true' );
Expand Down

0 comments on commit 15f7929

Please sign in to comment.