react-code-dataset / wp-calypso /apps /wpcom-block-editor /src /wpcom /features /site-editor-env-consistency.js
react-code-dataset / wp-calypso /apps /wpcom-block-editor /src /wpcom /features /site-editor-env-consistency.js
Download wp-calypso/apps/wpcom-block-editor/src/wpcom/features/site-editor-env-consistency.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 874 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/apps/wpcom-block-editor/src/wpcom/features/site-editor-env-consistency.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/apps/wpcom-block-editor/src/wpcom/features/site-editor-env-consistency.js
-
curl -L -o site-editor-env-consistency.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/apps/wpcom-block-editor/src/wpcom/features/site-editor-env-consistency.js
874 Bytes
| 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 ); | |