diff --git a/projects/plugins/jetpack/changelog/improve-newsletter-panel-social-message b/projects/plugins/jetpack/changelog/improve-newsletter-panel-social-message new file mode 100644 index 0000000000000..6374485cbd293 --- /dev/null +++ b/projects/plugins/jetpack/changelog/improve-newsletter-panel-social-message @@ -0,0 +1,4 @@ +Significance: patch +Type: enhancement + +Newsletter Panel message now adapts based on Publicize status. diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/panel.js b/projects/plugins/jetpack/extensions/blocks/subscriptions/panel.js index 64cc3547a0ea2..648fbbd6f7305 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/panel.js +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/panel.js @@ -1,4 +1,8 @@ import { JetpackLogo, numberFormat } from '@automattic/jetpack-components'; +import { + usePublicizeConfig, + useSocialMediaConnections, +} from '@automattic/jetpack-publicize-components'; import { isComingSoon, isPrivateSite } from '@automattic/jetpack-shared-extension-utils'; import { useEntityProp } from '@wordpress/core-data'; import { useSelect } from '@wordpress/data'; @@ -24,6 +28,9 @@ export default function SubscribePanels() { const accessLevel = postMeta[ META_NAME_FOR_POST_LEVEL_ACCESS_SETTINGS ] ?? Object.keys( accessOptions )[ 0 ]; + const { hasConnections, hasEnabledConnections } = useSocialMediaConnections(); + const { isPublicizeEnabled } = usePublicizeConfig(); + const [ followerCount, setFollowerCount ] = useState( null ); useEffect( () => { getSubscriberCounts( counts => { @@ -63,6 +70,8 @@ export default function SubscribePanels() { return null; } + const willShareToSocialMedia = isPublicizeEnabled && hasConnections && hasEnabledConnections; + const showNotices = Number.isFinite( subscriberCount ) && subscriberCount > 0; return ( <> @@ -80,23 +89,40 @@ export default function SubscribePanels() { > { showNotices && ( - { createInterpolateElement( - sprintf( - /* translators: 1$s will be subscribers, %2$s will be social followers */ - __( 'This post will reach %1$s and %2$s.', 'jetpack' ), + { willShareToSocialMedia && + createInterpolateElement( sprintf( - /* translators: %s will be a number of subscribers */ - _n( '%s subscriber', '%s subscribers', subscriberCount, 'jetpack' ), - numberFormat( subscriberCount ) + /* translators: 1$s will be a number of subscribers, %2$s will be a number of social followers */ + __( 'This post will reach %1$s and %2$s.', 'jetpack' ), + sprintf( + /* translators: %s will be a number of subscribers */ + _n( '%s subscriber', '%s subscribers', subscriberCount, 'jetpack' ), + numberFormat( subscriberCount ) + ), + sprintf( + /* translators: %s will be a number of social followers */ + _n( '%s social follower', '%s social followers', followerCount, 'jetpack' ), + numberFormat( followerCount ) + ) ), + { span: } + ) } + { ! willShareToSocialMedia && + createInterpolateElement( sprintf( - /* translators: %s will be a number of social followers */ - _n( '%s social follower', '%s social followers', followerCount, 'jetpack' ), - numberFormat( followerCount ) - ) - ), - { span: } - ) } + /* translators: 1$s will be a number of subscribers */ + __( + 'This post will reach %1$s and wonʼt be shared on social media.', + 'jetpack' + ), + sprintf( + /* translators: %s will be a number of subscribers */ + _n( '%s subscriber', '%s subscribers', subscriberCount, 'jetpack' ), + numberFormat( subscriberCount ) + ) + ), + { span: } + ) } ) } @@ -107,23 +133,40 @@ export default function SubscribePanels() { { showNotices && ( - { createInterpolateElement( - sprintf( - /* translators: 1$s will be subscribers, %2$s will be social followers */ - __( 'This post was shared to %1$s and %2$s.', 'jetpack' ), + { willShareToSocialMedia && + createInterpolateElement( sprintf( - /* translators: %s will be a number of subscribers */ - _n( '%s subscriber', '%s subscribers', subscriberCount, 'jetpack' ), - numberFormat( subscriberCount ) + /* translators: 1$s will be a number of subscribers, %2$s will be a number of social followers */ + __( + 'This post was shared to %1$s and %2$s.', + 'jetpack' + ), + sprintf( + /* translators: %s will be a number of subscribers */ + _n( '%s subscriber', '%s subscribers', subscriberCount, 'jetpack' ), + numberFormat( subscriberCount ) + ), + sprintf( + /* translators: %s will be a number of social followers */ + _n( '%s social follower', '%s social followers', followerCount, 'jetpack' ), + numberFormat( followerCount ) + ) ), + { span: } + ) } + { ! willShareToSocialMedia && + createInterpolateElement( sprintf( - /* translators: %s will be a number of social followers */ - _n( '%s social follower', '%s social followers', followerCount, 'jetpack' ), - numberFormat( followerCount ) - ) - ), - { span: } - ) } + /* translators: 1$s will be a number of subscribers */ + __( 'This post was shared to %1$s.', 'jetpack' ), + sprintf( + /* translators: %s will be a number of subscribers */ + _n( '%s subscriber', '%s subscribers', subscriberCount, 'jetpack' ), + numberFormat( subscriberCount ) + ) + ), + { span: } + ) } ) }