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

DataViews: Fix text in action for setting site home page #67787

Merged
merged 2 commits into from
Dec 11, 2024
Merged
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
27 changes: 13 additions & 14 deletions packages/editor/src/components/post-actions/set-as-homepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ const SetAsHomepageModal = ( { items, closeModal } ) => {
};
}
);
const currentHomePageTitle = currentHomePage
? getItemTitle( currentHomePage )
: '';

const { saveEditedEntityRecord, saveEntityRecord } =
useDispatch( coreStore );
Expand Down Expand Up @@ -89,23 +86,25 @@ const SetAsHomepageModal = ( { items, closeModal } ) => {
}
}

const modalWarning =
'posts' === showOnFront
? __(
'This will replace the current homepage which is set to display latest posts.'
)
: sprintf(
// translators: %s: title of the current home page.
__( 'This will replace the current homepage: "%s"' ),
currentHomePageTitle
);
let modalWarning = '';
if ( 'posts' === showOnFront ) {
modalWarning = __(
'This will replace the current homepage which is set to display latest posts.'
);
} else if ( currentHomePage ) {
modalWarning = sprintf(
// translators: %s: title of the current home page.
__( 'This will replace the current homepage: "%s"' ),
getItemTitle( currentHomePage )
);
}

const modalText = sprintf(
// translators: %1$s: title of the page to be set as the homepage, %2$s: homepage replacement warning message.
__( 'Set "%1$s" as the site homepage? %2$s' ),
pageTitle,
modalWarning
);
).trim();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This prevents a space from being left at the end of the modalText variable if modalWarning is an empty string.


// translators: Button label to confirm setting the specified page as the homepage.
const modalButtonLabel = __( 'Set homepage' );
Expand Down
Loading