diff --git a/blocks/library/categories/index.js b/blocks/library/categories/index.js index db7d113862482..ab5553acc2f9e 100644 --- a/blocks/library/categories/index.js +++ b/blocks/library/categories/index.js @@ -4,6 +4,7 @@ import { Component } from '@wordpress/element'; import { Placeholder, Spinner } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; +import { unescape } from 'lodash'; /** * Internal dependencies @@ -95,6 +96,14 @@ registerBlockType( 'core/categories', { return `${ className }__list ${ className }__list-level-${ level }`; } + renderCategoryName( category ) { + if ( ! category.name ) { + return __( '(Untitled)' ); + } + + return unescape( category.name ).trim(); + } + renderCategoryList() { const { showHierarchy } = this.props.attributes; const parentId = showHierarchy ? 0 : null; @@ -113,7 +122,7 @@ registerBlockType( 'core/categories', { return (
  • - { category.name.trim() || __( '(Untitled)' ) } + { this.renderCategoryName( category ) } { showPostCounts && { ' ' }({ category.count }) @@ -151,7 +160,7 @@ registerBlockType( 'core/categories', { return [