File size: 874 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import { getCalypsoUrl } from '@automattic/calypso-url';
import { select, dispatch } from '@wordpress/data';
import domReady from '@wordpress/dom-ready';
/**
* Make the Site Editor's navigation consistent with the
* Calypso environment it's running in.
*/
function makeSiteEditorNavConsistent() {
const siteEditor = select( 'core/edit-site' );
// Not in the Site Editor? Bail.
if ( ! siteEditor ) {
return;
}
// Don't have to change the origin? Bail.
if ( getCalypsoUrl() === 'https://wordpress.com' ) {
return;
}
const backButtonUrl = siteEditor.getSettings().__experimentalDashboardLink;
const envRespectingBackButtonUrl = backButtonUrl.replace(
/^https:\/\/wordpress.com/,
getCalypsoUrl()
);
dispatch( 'core/edit-site' ).updateSettings( {
__experimentalDashboardLink: envRespectingBackButtonUrl,
} );
}
domReady( makeSiteEditorNavConsistent );
|