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 11, 2024
1 parent b7368c0 commit d2d7bf6
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 @@ -34,6 +34,7 @@ import {
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';
import { store as coreStore } from '@wordpress/core-data';
import { SlotFillProvider } from '@wordpress/components';

Expand Down Expand Up @@ -288,7 +289,7 @@ function Layout( {
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 @@ -146,7 +147,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

0 comments on commit d2d7bf6

Please sign in to comment.