Skip to content

Commit edaf6dc

Browse files
arthur791004matticbot
authored andcommitted
MU WPCOM: Port the site visibility settings from Calypso to WP Admin (#42230)
* MU WPCOM: Port the site visibility setting * Render the site visibility on frontend * Handle the logic of the settings * Generate site preview link * changelog * Refine layout * Update pnpm-lock.yaml * Handle the update of the site options * Clean up variables * Display launch site button for the unlaunched sites * Display site preview link for unlaunched sites * Update the copy of the site management panel link * Fix lint * Change to use the /sites//hosting/wpcom-public-coming-soon endpoint * Fix the value of wpcom_data_sharing_opt_out * Change to use the /sites//site-visibility endpoint * Use wpcom_json_api_request_as_blog on simple sites * Show the details of the public only when the current site visibility is configured to public * Simplify the condition * Add missing class name Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/13988484555 Upstream-Ref: Automattic/jetpack@5b3eef2
1 parent 04df8e5 commit edaf6dc

14 files changed

+703
-17
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ This is an alpha version! The changes listed here are not final.
9696
- Remove duplicate views: Enhance notices
9797
- Render the Global Styles frontend bar separately from the .com launch bar.
9898
- Restored the code that assigned global styles on personal variations and added the new experiment code
99+
- Site Visibility: Port the site visibility settings from Calypso to WP Admin
99100
- Theme: Clean up files that were used during the theme switch and theme preview
100101
- Update background pattern image
101102
- Updated /settings/general url to /sites/settings/site for classic style users

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"@wordpress/base-styles": "5.19.0",
6464
"@wordpress/blocks": "14.8.0",
6565
"@wordpress/components": "29.5.0",
66+
"@wordpress/compose": "7.19.0",
6667
"@wordpress/data": "10.19.0",
6768
"@wordpress/dom-ready": "^4.8.1",
6869
"@wordpress/element": "6.19.0",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php return array('dependencies' => array('react', 'react-dom', 'wp-components', 'wp-compose', 'wp-i18n', 'wp-polyfill', 'wp-url'), 'version' => 'b2c7b09603290d3c31dd');

src/build/wpcom-replace-site-visibility/wpcom-replace-site-visibility.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/build/wpcom-replace-site-visibility/wpcom-replace-site-visibility.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/build/wpcom-replace-site-visibility/wpcom-replace-site-visibility.rtl.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/features/coming-soon/coming-soon.php

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
use Automattic\Jetpack\Jetpack_Mu_Wpcom;
1111

12+
require_once __DIR__ . '/../../utils.php';
13+
1214
/**
1315
* Determines whether the coming soon page should be shown.
1416
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import { __ } from '@wordpress/i18n';
2+
import { addQueryArgs } from '@wordpress/url';
3+
import SitePreviewLink from '../site-preview-link';
4+
import type { SitePreviewLinkObject } from '../site-preview-link';
5+
6+
interface Props {
7+
homeUrl: string;
8+
siteTitle: string;
9+
isUnlaunchedSite: boolean;
10+
hasSitePreviewLink: boolean;
11+
sitePreviewLink?: SitePreviewLinkObject;
12+
sitePreviewLinkNonce: string;
13+
blogPublic: number;
14+
wpcomComingSoon: number;
15+
wpcomPublicComingSoon: number;
16+
}
17+
18+
const LaunchSite = ( {
19+
homeUrl,
20+
siteTitle,
21+
isUnlaunchedSite,
22+
hasSitePreviewLink,
23+
sitePreviewLink,
24+
sitePreviewLinkNonce,
25+
blogPublic,
26+
wpcomComingSoon,
27+
wpcomPublicComingSoon,
28+
}: Props ) => {
29+
// isPrivateAndUnlaunched means it is an unlaunched coming soon v1 site
30+
const isPrivateAndUnlaunched = -1 === blogPublic && isUnlaunchedSite;
31+
const isAnyComingSoonEnabled =
32+
( 0 === blogPublic && wpcomPublicComingSoon ) || isPrivateAndUnlaunched || wpcomComingSoon;
33+
34+
const launchUrl = addQueryArgs( 'https://wordpress.com/start/launch-site', {
35+
siteSlug: new URL( homeUrl ).host,
36+
source: 'options-reading.php',
37+
new: siteTitle,
38+
search: 'yes',
39+
} );
40+
41+
const showPreviewLink = isAnyComingSoonEnabled && hasSitePreviewLink;
42+
43+
return (
44+
<>
45+
<p>
46+
{ isAnyComingSoonEnabled
47+
? __(
48+
'Your site hasn\'t been launched yet. It is hidden from visitors behind a "Coming Soon" notice until it is launched.',
49+
'jetpack-mu-wpcom'
50+
)
51+
: __(
52+
"Your site hasn't been launched yet. It's private; only you can see it until it is launched.",
53+
'jetpack-mu-wpcom',
54+
0
55+
) }
56+
</p>
57+
<a
58+
role="button"
59+
className="button-secondary"
60+
style={ { marginTop: '0.5em' } }
61+
href={ launchUrl }
62+
>
63+
{ __( 'Launch site', 'jetpack-mu-wpcom' ) }
64+
</a>
65+
{ showPreviewLink && (
66+
<SitePreviewLink
67+
homeUrl={ homeUrl }
68+
sitePreviewLink={ sitePreviewLink }
69+
sitePreviewLinkNonce={ sitePreviewLinkNonce }
70+
description={
71+
<>
72+
{ __(
73+
'"Coming soon" sites are only visible to you and invited users.',
74+
'jetpack-mu-wpcom'
75+
) }
76+
&nbsp;
77+
</>
78+
}
79+
/>
80+
) }
81+
</>
82+
);
83+
};
84+
85+
export default LaunchSite;

0 commit comments

Comments
 (0)