From 47cbce1b5f2fba4ce93bab70853cac136c39a287 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Thu, 9 Feb 2023 06:54:30 -0800 Subject: [PATCH 1/4] Subscriptions: Adapt message based on Publicize status --- .../extensions/blocks/subscriptions/panel.js | 99 +++++++++++++------ 1 file changed, 71 insertions(+), 28 deletions(-) diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/panel.js b/projects/plugins/jetpack/extensions/blocks/subscriptions/panel.js index 64cc3547a0ea2..3bca9cae7b253 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 subscribers, %2$s will be 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 subscribers, %2$s will be social followers */ + __( + 'This post will reach %1$s and wonʼt be shared on social.', + '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 subscribers, %2$s will be 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 subscribers, %2$s will be social followers */ + __( '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: } + ) } ) } From d440d6e4b2d4b276dad93894d27088ac5252cc99 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Thu, 9 Feb 2023 06:56:06 -0800 Subject: [PATCH 2/4] changelog --- .../jetpack/changelog/improve-newsletter-panel-social-message | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 projects/plugins/jetpack/changelog/improve-newsletter-panel-social-message 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. From ce757f64af057dfc6e37e4eb028d0d6ac99bec4e Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Thu, 9 Feb 2023 07:31:18 -0800 Subject: [PATCH 3/4] Use a more clear phrase Co-authored-by: Jeremy Herve --- .../plugins/jetpack/extensions/blocks/subscriptions/panel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/panel.js b/projects/plugins/jetpack/extensions/blocks/subscriptions/panel.js index 3bca9cae7b253..6fc5410f57d25 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/panel.js +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/panel.js @@ -112,7 +112,7 @@ export default function SubscribePanels() { sprintf( /* translators: 1$s will be subscribers, %2$s will be social followers */ __( - 'This post will reach %1$s and wonʼt be shared on social.', + 'This post will reach %1$s and wonʼt be shared on social media.', 'jetpack' ), sprintf( From 0ef2c83f0f9b4ac176b4e05b25e4f9fcf2754062 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Thu, 9 Feb 2023 07:40:58 -0800 Subject: [PATCH 4/4] Clean up translation comments --- .../jetpack/extensions/blocks/subscriptions/panel.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/panel.js b/projects/plugins/jetpack/extensions/blocks/subscriptions/panel.js index 6fc5410f57d25..648fbbd6f7305 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/panel.js +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/panel.js @@ -92,7 +92,7 @@ export default function SubscribePanels() { { willShareToSocialMedia && createInterpolateElement( sprintf( - /* translators: 1$s will be subscribers, %2$s will be social followers */ + /* 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 */ @@ -110,7 +110,7 @@ export default function SubscribePanels() { { ! willShareToSocialMedia && createInterpolateElement( sprintf( - /* translators: 1$s will be subscribers, %2$s will be social followers */ + /* translators: 1$s will be a number of subscribers */ __( 'This post will reach %1$s and wonʼt be shared on social media.', 'jetpack' @@ -136,7 +136,7 @@ export default function SubscribePanels() { { willShareToSocialMedia && createInterpolateElement( sprintf( - /* translators: 1$s will be subscribers, %2$s will be social followers */ + /* 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' @@ -157,7 +157,7 @@ export default function SubscribePanels() { { ! willShareToSocialMedia && createInterpolateElement( sprintf( - /* translators: 1$s will be subscribers, %2$s will be social followers */ + /* 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 */