UNPKG

@wordpress/editor

Version:
32 lines (30 loc) 919 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getItemTitle = getItemTitle; var _htmlEntities = require("@wordpress/html-entities"); /** * WordPress dependencies */ /** * Helper function to get the title of a post item. * This is duplicated from the `@wordpress/fields` package. * `packages/fields/src/actions/utils.ts` * * @param {Object} item The post item. * @return {string} The title of the item, or an empty string if the title is not found. */ function getItemTitle(item) { if (typeof item.title === 'string') { return (0, _htmlEntities.decodeEntities)(item.title); } if (item.title && 'rendered' in item.title) { return (0, _htmlEntities.decodeEntities)(item.title.rendered); } if (item.title && 'raw' in item.title) { return (0, _htmlEntities.decodeEntities)(item.title.raw); } return ''; } //# sourceMappingURL=get-item-title.js.map