Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Atomic sites: Display site visibility in wp-admin settings based on the privacy model instead of the 'blog_public' option value.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

use Automattic\Jetpack\Connection\Client;
use Automattic\Jetpack\Status\Host;

/**
* Load dependencies.
Expand Down Expand Up @@ -107,25 +108,32 @@ function wpcom_get_site_preview_link() {
function replace_site_visibility_load_assets() {
$handle = jetpack_mu_wpcom_enqueue_assets( 'wpcom-replace-site-visibility', array( 'js', 'css' ) );

$data = wp_json_encode(
array(
'homeUrl' => home_url( '/' ),
'siteTitle' => bloginfo( 'name' ),
'isWpcomStagingSite' => (bool) get_option( 'wpcom_is_staging_site' ),
'isUnlaunchedSite' => get_option( 'launch-status' ) === 'unlaunched',
'hasSitePreviewLink' => function_exists( 'wpcom_site_has_feature' ) && wpcom_site_has_feature( \WPCOM_Features::SITE_PREVIEW_LINKS ),
'sitePreviewLink' => wpcom_get_site_preview_link(),
'sitePreviewLinkNonce' => wp_create_nonce( 'wpcom_site_visibility_site_preview_link' ),
'blogPublic' => get_option( 'blog_public' ),
'wpcomComingSoon' => get_option( 'wpcom_coming_soon' ),
'wpcomPublicComingSoon' => get_option( 'wpcom_public_coming_soon' ),
'wpcomDataSharingOptOut' => (bool) get_option( 'wpcom_data_sharing_opt_out' ),
)
$data = array(
'homeUrl' => home_url( '/' ),
'siteTitle' => get_bloginfo( 'name' ),
'isWpcomStagingSite' => (bool) get_option( 'wpcom_is_staging_site' ),
'isUnlaunchedSite' => get_option( 'launch-status' ) === 'unlaunched',
'hasSitePreviewLink' => function_exists( 'wpcom_site_has_feature' ) && wpcom_site_has_feature( \WPCOM_Features::SITE_PREVIEW_LINKS ),
'sitePreviewLink' => wpcom_get_site_preview_link(),
'sitePreviewLinkNonce' => wp_create_nonce( 'wpcom_site_visibility_site_preview_link' ),
'blogPublic' => get_option( 'blog_public' ),
'wpcomComingSoon' => get_option( 'wpcom_coming_soon' ),
'wpcomPublicComingSoon' => get_option( 'wpcom_public_coming_soon' ),
'wpcomDataSharingOptOut' => (bool) get_option( 'wpcom_data_sharing_opt_out' ),
);

// If the site is launched, replace the option value with the actual site visibility.
if ( ( new Host() )->is_woa_site() && function_exists( '\Private_Site\site_is_private' )
&& ! $data['isUnlaunchedSite'] && ! $data['wpcomPublicComingSoon'] && ! $data['wpcomComingSoon'] && (string) $data['blogPublic'] !== '0'
) {
// @phan-suppress-next-line PhanUndeclaredFunction
$data['blogPublic'] = \Private_Site\site_is_private() ? '-1' : '1';
}

$encoded_data = wp_json_encode( $data );
wp_add_inline_script(
$handle,
"var JETPACK_MU_WPCOM_SITE_VISIBILITY = $data;",
"var JETPACK_MU_WPCOM_SITE_VISIBILITY = $encoded_data;",
'before'
);
}
Expand Down