Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Social | Enable social admin page for all WPCOM sites #41713

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open
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: fixed

Social | Hide upgrade nudge for Atomic sites
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
getRedirectUrl,
useBreakpointMatch,
} from '@automattic/jetpack-components';
import { getScriptData } from '@automattic/jetpack-script-data';
import { getScriptData, isWpcomPlatformSite } from '@automattic/jetpack-script-data';
import { ExternalLink } from '@wordpress/components';
import { useSelect, useDispatch } from '@wordpress/data';
import { __, _x } from '@wordpress/i18n';
Expand Down Expand Up @@ -111,7 +111,7 @@ const SocialModuleToggle: React.FC = () => {
{ __( 'Learn more', 'jetpack-publicize-components' ) }
</ExternalLink>
</Text>
{ ! is_wpcom && ! hasSocialPaidFeatures() ? (
{ ! isWpcomPlatformSite() && ! hasSocialPaidFeatures() ? (
<ContextualUpgradeTrigger
className={ clsx( styles.cut, { [ styles.small ]: isSmall } ) }
description={ __( 'Unlock advanced sharing options', 'jetpack-publicize-components' ) }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: added

Update the site host utility functions
42 changes: 34 additions & 8 deletions projects/js-packages/script-data/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { AdminSiteData } from './types';

/**
* Values come from https://opengrok.a8c.com/source/xref/jetpack/projects/packages/status/src/class-host.php?r=9f212812&fi=get_known_host_guess#240
*
* @type {Array<import('@automattic/jetpack-script-data').AdminSiteData['host']>}
* Values come from https://github.com/Automattic/jetpack/blob/128db0505a27dcdcdef5946d60f443173b2ef6cd/projects/packages/status/src/class-host.php#L240
*/
const NON_SELF_HOSTED_TYPES = [ 'woa', 'atomic', 'newspack', 'vip', 'wpcom' ];
const NON_SELF_HOSTED_TYPES: Array< AdminSiteData[ 'host' ] > = [
'woa',
'atomic',
'newspack',
'vip',
'wpcom',
];

/**
* Get the script data from the window object.
Expand Down Expand Up @@ -82,16 +88,36 @@ export function siteHasFeature( feature: string ) {
* @return {boolean} Whether the site host is wpcom.
*/
export function isSimpleSite() {
return getScriptData()?.site?.host === 'wpcom';
return getScriptData().site?.host === 'wpcom';
}

/**
* Check if the site host is woa.
* Check if the is an Atomic site.
*
* @return {boolean} Whether the site host is woa.
* @return {boolean} Whether the site is an Atomic site.
*/
export function isAtomicSite() {
return getScriptData()?.site?.host === 'atomic';
return getScriptData().site?.host === 'atomic';
}

/**
* Check if the site is a WoA site
*
* @return Whether the site is woa.
*/
export function isWoASite() {
return getScriptData().site?.host === 'woa';
}

/**
* Determine if this is a WordPress.com site.
*
* Includes both Simple and WoA platforms.
*
* @return Whether the site is a WordPress.com site.
*/
export function isWpcomPlatformSite() {
return isSimpleSite() || isWoASite();
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Social | Enable Social admin page for all WPCOM sites
Original file line number Diff line number Diff line change
Expand Up @@ -1070,12 +1070,7 @@ class WPCOM_Features {
self::JETPACK_GROWTH_PLANS,
),
self::SOCIAL_ADMIN_PAGE => array(
array(
// This feature isn't launched yet, so we're ensuring that it's not available on any plans.
'before' => '1900-01-01',
self::WPCOM_ALL_SITES,
self::JETPACK_ALL_SITES,
),
self::WPCOM_ALL_SITES,
),
self::SOCIAL_MASTODON_CONNECTION => array(
array(
Expand Down
Loading