Skip to content

Commit

Permalink
Page creation and duplication: Decode HTML entities in success notices (
Browse files Browse the repository at this point in the history
#62313)

* Decode the page title when creating a new page from the Site Editor > Pages
* Decode the page title when a page is duplicated from the Data Views
* Decode the page title when you duplicate an item in the Edit Site > Editor component
* Decode the page title when a page or post is duplicated from the block editor
* Add ´@wordpress/html-entities´ to the edit post package.

Co-authored-by: carolinan <poena@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
  • Loading branch information
4 people committed Jun 18, 2024
1 parent b7ce5b9 commit 2b5ac52
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/edit-post/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Bug Fixes

- Add ´@wordpress/html-entities´ package to the list of dependencies in package.json. ([#62313](https://github.com/WordPress/gutenberg/pull/62313))

## 8.0.0 (2024-05-31)

### Breaking Changes
Expand Down
1 change: 1 addition & 0 deletions packages/edit-post/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@wordpress/editor": "file:../editor",
"@wordpress/element": "file:../element",
"@wordpress/hooks": "file:../hooks",
"@wordpress/html-entities": "file:../html-entities",
"@wordpress/i18n": "file:../i18n",
"@wordpress/icons": "file:../icons",
"@wordpress/keyboard-shortcuts": "file:../keyboard-shortcuts",
Expand Down
3 changes: 2 additions & 1 deletion packages/edit-post/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { privateApis as commandsPrivateApis } from '@wordpress/commands';
import { privateApis as coreCommandsPrivateApis } from '@wordpress/core-commands';
import { privateApis as blockLibraryPrivateApis } from '@wordpress/block-library';
import { addQueryArgs } from '@wordpress/url';
import { decodeEntities } from '@wordpress/html-entities';

/**
* Internal dependencies
Expand Down Expand Up @@ -240,7 +241,7 @@ function Layout( { initialPost } ) {
sprintf(
// translators: %s: Title of the created post e.g: "Post 1".
__( '"%s" successfully created.' ),
title
decodeEntities( title )
),
{
type: 'snackbar',
Expand Down
3 changes: 2 additions & 1 deletion packages/edit-site/src/components/add-new-page/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useDispatch } from '@wordpress/data';
import { useState } from '@wordpress/element';
import { store as coreStore } from '@wordpress/core-data';
import { store as noticesStore } from '@wordpress/notices';
import { decodeEntities } from '@wordpress/html-entities';

export default function AddNewPageModal( { onSave, onClose } ) {
const [ isCreatingPage, setIsCreatingPage ] = useState( false );
Expand Down Expand Up @@ -47,7 +48,7 @@ export default function AddNewPageModal( { onSave, onClose } ) {
sprintf(
// translators: %s: Title of the created template e.g: "Category".
__( '"%s" successfully created.' ),
newPage.title?.rendered || title
decodeEntities( newPage.title?.rendered || title )
),
{
type: 'snackbar',
Expand Down
3 changes: 2 additions & 1 deletion packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { useCallback, useMemo } from '@wordpress/element';
import { store as noticesStore } from '@wordpress/notices';
import { privateApis as routerPrivateApis } from '@wordpress/router';
import { store as preferencesStore } from '@wordpress/preferences';
import { decodeEntities } from '@wordpress/html-entities';

/**
* Internal dependencies
Expand Down Expand Up @@ -152,7 +153,7 @@ export default function EditSiteEditor( { isLoading } ) {
sprintf(
// translators: %s: Title of the created post e.g: "Post 1".
__( '"%s" successfully created.' ),
_title
decodeEntities( _title )
),
{
type: 'snackbar',
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/components/post-actions/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ const duplicatePostAction = {
sprintf(
// translators: %s: Title of the created template e.g: "Category".
__( '"%s" successfully created.' ),
newItem.title?.rendered || title
decodeEntities( newItem.title?.rendered || title )
),
{
id: 'duplicate-post-action',
Expand Down

1 comment on commit 2b5ac52

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in 2b5ac52.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9560536877
📝 Reported issues:

Please sign in to comment.