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

Update unlink warning message copy #1006

Merged
merged 8 commits into from
Feb 22, 2023
2 changes: 1 addition & 1 deletion assets/js/gutenberg-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const RenderShowAdminBar = () => {
{ sprintf(
/* translators: 1: Post type or generic term content. */
__( 'Distribute %1$s', 'distributor' ),
dtGutenberg.postTypeSingular ||
dtGutenberg.postTypeSingular.toLowerCase() ||
_x(
'content',
'generic term for post content',
Expand Down
36 changes: 26 additions & 10 deletions assets/js/gutenberg-syndicated-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,49 +14,65 @@ if (
message = sprintf(
/* translators: 1) Distributor post type singular name, 2) Source of content. */
__(
'This %1$s was distributed from %2$s. However, the original has been deleted.'
'This %1$s was distributed from %2$s. However, the origin %1$s has been deleted.'
),
dtGutenberg.postTypeSingular,
dtGutenberg.postTypeSingular.toLowerCase(),
dtGutenberg.originalLocationName
);
} else if ( ! parseInt( dtGutenberg.unlinked ) ) {
message = sprintf(
/* translators: 1) Source of content, 2) Distributor post type singular name. */
__(
'Distributed from %1$s. This %2$s is linked to the original. Edits to the original will update this version.',
'Distributed from %1$s. This %2$s is linked to the origin %2$s. Edits to the origin %2$s will update this remote version.',
'distributor'
),
dtGutenberg.originalLocationName,
dtGutenberg.postTypeSingular
dtGutenberg.postTypeSingular.toLowerCase()
);

actions.push( {
label: __( 'Unlink from original.', 'distributor' ),
label: sprintf(
/* translators: 1) Distributor post type singular name. */
__( 'Unlink from the origin %1$s.', 'distributor' ),
dtGutenberg.postTypeSingular.toLowerCase()
),
url: dtGutenberg.unlinkNonceUrl,
} );

actions.push( {
label: __( 'View Original', 'distributor' ),
label: sprintf(
/* translators: 1) Distributor post type singular name. */
__( 'View the origin %1$s.', 'distributor' ),
dtGutenberg.postTypeSingular.toLowerCase()
),
url: dtGutenberg.postUrl,
} );
} else {
message = sprintf(
/* translators: 1) Source of content, 2) Distributor post type singular name. */
__(
'Originally distributed from %1$s. This %2$s has been unlinked from the original. Edits to the original will not update this version.',
'Originally distributed from %1$s. This %2$s has been unlinked from the origin %2$s. Edits to the origin %2$s will not update this remote version.',
'distributor'
),
dtGutenberg.originalLocationName,
dtGutenberg.postTypeSingular
dtGutenberg.postTypeSingular.toLowerCase()
);

actions.push( {
label: __( 'Relink to original.', 'distributor' ),
label: sprintf(
/* translators: 1) Distributor post type singular name. */
__( 'Relink to the origin %1$s.', 'distributor' ),
dtGutenberg.postTypeSingular.toLowerCase()
),
url: dtGutenberg.linkNonceUrl,
} );

actions.push( {
label: __( 'View Original', 'distributor' ),
label: sprintf(
/* translators: 1) Distributor post type singular name. */
__( 'View the origin %1$s.', 'distributor' ),
dtGutenberg.postTypeSingular.toLowerCase()
),
url: dtGutenberg.postUrl,
} );
}
Expand Down
22 changes: 14 additions & 8 deletions includes/push-ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,19 +586,25 @@ function menu_content() {
<?php /* translators: %s: post type name */ ?>

<?php
echo wp_kses_post(
sprintf(
/* translators: 1) Distributor post type singular name, 2) Source of content. */
__( 'This %1$s was distributed from %2$s.', 'distributor' ),
esc_html( strtolower( $post_type_object->labels->singular_name ) ),
'<a href="' . esc_url( $site_url ) . '">' . esc_html( $blog_name ) . '</a>'
)
printf(
/* translators: 1) Distributor post type singular name, 2) Source of content. */
esc_html__( 'This %1$s was distributed from %2$s.', 'distributor' ),
esc_html( strtolower( $post_type_object->labels->singular_name ) ),
'<a href="' . esc_url( $site_url ) . '">' . esc_html( $blog_name ) . '</a>'
);

if ( ! empty( $post_url ) ) {
?>
<a href="<?php echo esc_url( $post_url ); ?>" target="_blank">
<?php esc_html_e( 'View original', 'distributor' ); ?>
<?php
echo wp_kses_post(
sprintf(
/* translators: 1) Distributor post type singular name. */
__( 'View the origin %1$s.', 'distributor' ),
esc_html( strtolower( $post_type_object->labels->singular_name ) ),
)
);
?>
</a>
<?php
}
Expand Down
46 changes: 39 additions & 7 deletions includes/syndicated-post-ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ function syndicated_message( $post ) {
<?php
printf(
/* translators: 1) Distributor post type singular name, 2) Source of content. */
esc_html__( 'This %1$s was distributed from %2$s. However, the original has been deleted.', 'distributor' ),
esc_html__( 'This %1$s was distributed from %2$s. However, the origin %1$s has been deleted.', 'distributor' ),
esc_html( strtolower( $post_type_singular ) ),
esc_html( $original_location_name )
);
Expand All @@ -466,7 +466,7 @@ function syndicated_message( $post ) {
<?php
printf(
/* translators: 1) Source of content, 2) Distributor post type singular name. */
esc_html__( 'Distributed from %1$s. This %2$s is linked to the original. Edits to the original will update this version.', 'distributor' ),
esc_html__( 'Distributed from %1$s. This %2$s is linked to the origin %2$s. Edits to the origin %2$s will update this remote version.', 'distributor' ),
esc_html( $original_location_name ),
esc_html( strtolower( $post_type_singular ) )
);
Expand All @@ -478,8 +478,24 @@ function syndicated_message( $post ) {
?>
</p>
<p>
<span><a href="<?php echo esc_url( $unlink_url ); ?>"><?php echo esc_html__( 'Unlink from original.', 'distributor' ); ?></a></span>
<span><a href="<?php echo esc_url( $original_post_url ); ?>"><?php echo esc_html__( 'View Original.', 'distributor' ); ?></a></span>
<span><a href="<?php echo esc_url( $unlink_url ); ?>">
<?php
printf(
/* translators: 1) Distributor post type singular name. */
esc_html__( 'Unlink from the origin %1$s.', 'distributor' ),
esc_html( strtolower( $post_type_singular ) )
);
// phpcs:ignore Squiz.PHP.EmbeddedPhp.ContentAfterEnd, avoids layout issues.
?></a></span>
<span><a href="<?php echo esc_url( $original_post_url ); ?>">
<?php
printf(
/* translators: 1) Distributor post type singular name. */
esc_html__( 'View the origin %1$s.', 'distributor' ),
esc_html( strtolower( $post_type_singular ) )
);
?>
</a></span>
<?php endif; ?>
</p>
<?php else : ?>
Expand All @@ -488,7 +504,7 @@ function syndicated_message( $post ) {
printf(
/* translators: 1) Source of content, 2) Distributor post type singular name. */
esc_html__(
'Originally distributed from %1$s. This %2$s has been unlinked from the original. Edits to the original will not update this version.',
'Originally distributed from %1$s. This %2$s has been unlinked from the origin %2$s. Edits to the origin %2$s will not update this remote version.',
'distributor'
),
esc_html( $original_location_name ),
Expand All @@ -498,8 +514,24 @@ function syndicated_message( $post ) {
?>
</p>
<p>
<span><a href="<?php echo esc_url( $relink_url ); ?>"><?php echo esc_html__( 'Relink to original.', 'distributor' ); ?></a></span>
<span><a href="<?php echo esc_url( $original_post_url ); ?>"><?php echo esc_html__( 'View Original.', 'distributor' ); ?></a></span>
<span><a href="<?php echo esc_url( $relink_url ); ?>">
<?php
printf(
/* translators: 1) Distributor post type singular name. */
esc_html__( 'Relink to the origin %1$s.', 'distributor' ),
esc_html( strtolower( $post_type_singular ) )
);
// phpcs:ignore Squiz.PHP.EmbeddedPhp.ContentAfterEnd, avoids layout issues.
?></a></span>
<span><a href="<?php echo esc_url( $original_post_url ); ?>">
<?php
printf(
/* translators: 1) Distributor post type singular name. */
esc_html__( 'View the origin %1$s.', 'distributor' ),
esc_html( strtolower( $post_type_singular ) )
);
?>
</a></span>
</p>
<?php endif; ?>
</div>
Expand Down
6 changes: 3 additions & 3 deletions tests/wpacceptance/DistributedPostTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ public function testDistributedFrom() {

// Make sure we see distributed status admin notice and that it shows as linked
if ( $editor_has_blocks ) {
$I->seeText( 'Distributed from Site One. The original will update this version unless you unlink from original.View Original', '.components-notice__content' );
$I->seeText( 'Distributed from Site One. The origin post will update this version unless you unlink from the origin post. View the origin post', '.components-notice__content' );
$element = $I->getElement( '.components-notice__action' );
$I->seeText( 'unlink from original.', '.components-notice__action' );
$I->seeText( 'unlink from the origin post.', '.components-notice__action' );
} else {
$I->seeText( 'Distributed from', '.syndicate-status');
$I->seeText( 'unlink from the original', '.syndicate-status' );
$I->seeText( 'unlink from the origin post', '.syndicate-status' );
}

// Now let's check in the front end
Expand Down
8 changes: 4 additions & 4 deletions tests/wpacceptance/LinkUnlinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testUnlinkPublishPost() {

// I see linked link
if ( $editor_has_blocks ) {
$I->seeLink( 'View Original' );
$I->seeLink( 'View the origin post' );
// Unlink post
$I->click( '.components-notice__action' );

Expand All @@ -39,13 +39,13 @@ public function testUnlinkPublishPost() {
sleep( 1 );

// I see unlinked text
$I->seeText( 'Originally distributed from Site One. This Post has been unlinked from the original. However, you can alwaysrestore it.View Original', '.components-notice__content' );
$I->seeText( 'Originally distributed from Site One. This Post has been unlinked from the origin post. However, you can always restore it. View the origin post', '.components-notice__content' );

// I can interact with title field
$I->canInteractWithField( '#post-title-0' );

} else {
$I->seeLink( 'unlink from the original' );
$I->seeLink( 'unlink from the origin post' );
// I cant interact with title field
$I->cannotInteractWithField( '#title' );
// Unlink post
Expand All @@ -54,7 +54,7 @@ public function testUnlinkPublishPost() {
$I->waitUntilElementVisible( 'body.post-php' );;

// I see unlinked text
$I->seeText( 'This post has been unlinked from the original', '.syndicate-status' );
$I->seeText( 'This post has been unlinked from the origin post', '.syndicate-status' );

// I can interact with title field
$I->canInteractWithField( '#title' );
Expand Down