Download wp-calypso/client/dashboard/utils/site-url.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/dashboard/utils/site-url.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/dashboard/utils/site-url.ts
-
curl -L -o site-url.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/dashboard/utils/site-url.ts
1.09 kB
| import { addQueryArgs } from '@wordpress/url'; | |
| import type { Site } from '../data/types'; | |
| /** | |
| * Returns a user-friendly version of the site's URL. | |
| * | |
| * This not only produces a clean version of the site's domain, but | |
| * also deals with the case of Jetpack multi-sites using subdirectory | |
| * installations. | |
| */ | |
| export function getSiteDisplayUrl( site: Site ) { | |
| return site.URL.replace( 'https://', '' ).replace( 'http://', '' ); | |
| } | |
| /** | |
| * Returns the URL for editing the site. | |
| */ | |
| export function getSiteEditUrl( site: Site, isSiteUsingBlockTheme?: boolean ) { | |
| const location = typeof window !== 'undefined' ? window.location : null; | |
| const queryArgs: Record< string, string > = {}; | |
| const siteAdminUrl = site.options?.admin_url; | |
| if ( isSiteUsingBlockTheme ) { | |
| if ( location && location.origin !== 'https://wordpress.com' ) { | |
| queryArgs.calypso_origin = location.origin; | |
| } | |
| return addQueryArgs( `${ siteAdminUrl }site-editor.php`, queryArgs ); | |
| } | |
| if ( location ) { | |
| queryArgs.return = location.href; | |
| } | |
| return addQueryArgs( `${ siteAdminUrl }customize.php`, queryArgs ); | |
| } | |