From e8b2863cc4f5e8a94729d3cf760e38fc0417a001 Mon Sep 17 00:00:00 2001 From: Maxwell Morgan Date: Tue, 23 Jan 2024 12:02:38 -0500 Subject: [PATCH] fix(#95): check if current post type supports PTS sooner --- blocks/build/index.asset.php | 2 +- blocks/build/index.js | 585 +---------------------------------- blocks/build/index.js.map | 1 - blocks/package-lock.json | 4 +- blocks/src/admin/index.js | 10 +- 5 files changed, 9 insertions(+), 593 deletions(-) delete mode 100644 blocks/build/index.js.map diff --git a/blocks/build/index.asset.php b/blocks/build/index.asset.php index a7cac56..c9aa678 100644 --- a/blocks/build/index.asset.php +++ b/blocks/build/index.asset.php @@ -1 +1 @@ - array('lodash', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives'), 'version' => 'fbd8aae897381d1e782b'); + array('lodash', 'react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives'), 'version' => 'c5f778d16b993979e2fd'); diff --git a/blocks/build/index.js b/blocks/build/index.js index 7c7bdc8..dce70d1 100644 --- a/blocks/build/index.js +++ b/blocks/build/index.js @@ -1,584 +1 @@ -/******/ (() => { // webpackBootstrap -/******/ "use strict"; -/******/ var __webpack_modules__ = ({ - -/***/ "./src/admin/index.js": -/*!****************************!*\ - !*** ./src/admin/index.js ***! - \****************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _wordpress_plugins__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/plugins */ "@wordpress/plugins"); -/* harmony import */ var _wordpress_plugins__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_plugins__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _wordpress_edit_post__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/edit-post */ "@wordpress/edit-post"); -/* harmony import */ var _wordpress_edit_post__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_edit_post__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__); -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_4__); -/* harmony import */ var _wordpress_core_data__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @wordpress/core-data */ "@wordpress/core-data"); -/* harmony import */ var _wordpress_core_data__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_wordpress_core_data__WEBPACK_IMPORTED_MODULE_5__); -/* harmony import */ var _components_toggle__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../components/toggle */ "./src/components/toggle.js"); -/* harmony import */ var _components_logo_mark__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../components/logo-mark */ "./src/components/logo-mark.js"); - - - - - - - -// Internal Components - - -const Admin = () => { - const postId = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_4__.useSelect)(select => select('core/editor').getCurrentPostId()); - const postType = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_4__.useSelect)(select => select('core/editor').getCurrentPostType()); - let featuredTerm = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_4__.useSelect)(select => select('core').getEntityRecords('taxonomy', 'pts_feature_tax', { - slug: 'featured' - })); - let postTerms = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_4__.useSelect)(select => select('core/editor').getEditedPostAttribute('pts_feature_tax')); - if (postTerms && !Array.isArray(postTerms)) { - postTerms = [postTerms]; - } - featuredTerm = featuredTerm ? featuredTerm[0]?.id : null; - const isFeatured = featuredTerm && (postTerms.includes(featuredTerm) || postTerms === featuredTerm); - const { - editEntityRecord - } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_4__.useDispatch)('core'); - const [postTypeSpotlightSettings] = (0,_wordpress_core_data__WEBPACK_IMPORTED_MODULE_5__.useEntityProp)('root', 'site', 'pts_featured_post_types_settings'); - - // If the post type is not enabled in our writing settings - // then we can die early. - if (!postTypeSpotlightSettings || postTypeSpotlightSettings && postTypeSpotlightSettings.indexOf(postType) === -1) { - return null; - } - const onUpdateFeatured = newValue => { - const updatedTerms = newValue ? [...postTerms, featuredTerm] : postTerms.filter(termId => termId !== featuredTerm); - editEntityRecord('postType', postType, postId, { - pts_feature_tax: updatedTerms - }); - }; - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_edit_post__WEBPACK_IMPORTED_MODULE_2__.PluginPostStatusInfo, { - name: "pts-post-settings-panel", - title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('Post Type Spotlight Settings', 'linchpin'), - className: "pts-post-settings-panel", - style: { - width: '100%' - } - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_components_toggle__WEBPACK_IMPORTED_MODULE_6__["default"], { - onUpdateFeatured: onUpdateFeatured, - isFeatured: isFeatured, - postType: postType - })); -}; -(0,_wordpress_plugins__WEBPACK_IMPORTED_MODULE_1__.registerPlugin)('post-type-post-settings', { - render: Admin, - icon: _components_logo_mark__WEBPACK_IMPORTED_MODULE_7__["default"] -}); - -/***/ }), - -/***/ "./src/components/filter.js": -/*!**********************************!*\ - !*** ./src/components/filter.js ***! - \**********************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) -/* harmony export */ }); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! lodash */ "lodash"); -/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_3__); -/* harmony import */ var _components_logo_mark__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../components/logo-mark */ "./src/components/logo-mark.js"); - - - - - -const PTSFilter = ({ - attributes, - setAttributes -}) => { - const { - query: { - queryType - } - } = attributes; - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.SelectControl, { - value: queryType, - label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Display Type', 'post-type-spotlight'), - onChange: queryType => { - // filter the tokens to remove wrong items. - setAttributes({ - query: { - ...attributes.query, - queryType: queryType || 'featured-only' - } - }); - }, - options: [{ - value: 'featured-only', - label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Only Show Featured', 'post-type-spotlight') - }, { - value: 'featured-first', - label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Show Featured First', 'post-type-spotlight') - }, { - value: 'featured-exclude', - label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Exclude Featured', 'post-type-spotlight') - }] - }); -}; -/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (PTSFilter); - -/***/ }), - -/***/ "./src/components/logo-mark.js": -/*!*************************************!*\ - !*** ./src/components/logo-mark.js ***! - \*************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "default": () => (/* binding */ LogoMark) -/* harmony export */ }); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/primitives */ "@wordpress/primitives"); -/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__); - -/** - * WordPress dependencies - */ - -function LogoMark(props) { - const { - width, - height - } = props; - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__.SVG, { - id: "Layer_1", - xmlns: "http://www.w3.org/2000/svg", - viewBox: "0 0 47.507 48", - width: width, - height: height - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__.Defs, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__.LinearGradient, { - id: "linear-gradient", - x1: "15.044", - y1: "46.627", - x2: "31.956", - y2: ".16", - gradientUnits: "userSpaceOnUse" - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__.Stop, { - offset: 0, - stopColor: "#7d58c6" - }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__.Stop, { - offset: .261, - stopColor: "#677bc9" - }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__.Stop, { - offset: .581, - stopColor: "#51a1cc" - }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__.Stop, { - offset: .838, - stopColor: "#44b8cf" - }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__.Stop, { - offset: 1, - stopColor: "#3fc1d0" - }))), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__.Circle, { - cx: "43.966", - cy: "3.54", - r: "3.54", - style: { - fill: "#7a7a7a" - } - }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__.Path, { - d: "m43.966,9.895c-3.509,0-6.354-2.845-6.354-6.354,0-.437.044-.863.128-1.275h-14.873C10.238,2.266,0,12.504,0,25.133h0c0,12.629,10.238,22.867,22.867,22.867h0c12.629,0,22.867-10.238,22.867-22.867v-15.489c-.562.162-1.154.251-1.768.251Zm-12.953,26.821l-8.146-4.073-8.146,4.073,1.534-9.001-5.607-6.272,8.146-1.018,4.073-8.146,4.073,8.146,8.146,1.018-5.594,6.272,1.521,9.001Z", - style: { - fill: "url(#linear-gradient)" - } - })); -} - -/***/ }), - -/***/ "./src/components/toggle.js": -/*!**********************************!*\ - !*** ./src/components/toggle.js ***! - \**********************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) -/* harmony export */ }); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! lodash */ "lodash"); -/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_3__); -/* harmony import */ var _components_logo_mark__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../components/logo-mark */ "./src/components/logo-mark.js"); - - - - - -const PTSToggle = props => { - const { - postType, - isFeatured, - onUpdateFeatured - } = props; - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.__experimentalHStack, { - alignment: "top", - justify: "flex-start", - spacing: "3", - style: { - marginTop: "calc(12px)", - minHeight: '3rem' - } - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.Tooltip, { - text: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.sprintf)((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('You can query all featured %1$s using the pts_feature_tax'), postType) - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.Icon, { - icon: (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_components_logo_mark__WEBPACK_IMPORTED_MODULE_4__["default"], { - width: '24px', - height: '24px' - }) - })), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.ToggleControl, { - checked: isFeatured, - label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.sprintf)((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Feature %1$s', 'post-type-spotlight'), (0,lodash__WEBPACK_IMPORTED_MODULE_3__.capitalize)(postType)), - onChange: onUpdateFeatured, - style: { - marginBottom: "0!important" - } - })); -}; -/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (PTSToggle); - -/***/ }), - -/***/ "./src/query-loop/controls.js": -/*!************************************!*\ - !*** ./src/query-loop/controls.js ***! - \************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "withPSTQueryControls": () => (/* binding */ withPSTQueryControls) -/* harmony export */ }); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/block-editor */ "@wordpress/block-editor"); -/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/hooks */ "@wordpress/hooks"); -/* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__); -/* harmony import */ var _components_filter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../components/filter */ "./src/components/filter.js"); - - - - - -const withPSTQueryControls = BlockEdit => props => { - const isPTSQueryLoopVariation = props => { - const { - attributes: { - namespace - } - } = props; - return namespace === 'post-type-spotlight/featured-list'; - }; - return isPTSQueryLoopVariation(props) ? (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(BlockEdit, { - ...props - }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.InspectorControls, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.PanelBody, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_components_filter__WEBPACK_IMPORTED_MODULE_4__["default"], { - ...props - })))) : (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(BlockEdit, { - ...props - }); -}; -(0,_wordpress_hooks__WEBPACK_IMPORTED_MODULE_2__.addFilter)('editor.BlockEdit', 'core/query', withPSTQueryControls); - -/***/ }), - -/***/ "./src/query-loop/index.js": -/*!*********************************!*\ - !*** ./src/query-loop/index.js ***! - \*********************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _components_logo_mark__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../components/logo-mark */ "./src/components/logo-mark.js"); -/* harmony import */ var _wordpress_blocks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/blocks */ "@wordpress/blocks"); -/* harmony import */ var _wordpress_blocks__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_blocks__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./controls */ "./src/query-loop/controls.js"); - - - - // Load out controls - -const VARIATION_NAME = 'post-type-spotlight/featured-list'; -(0,_wordpress_blocks__WEBPACK_IMPORTED_MODULE_2__.registerBlockVariation)('core/query', { - name: VARIATION_NAME, - title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_0__.__)('Featured List', 'post-type-spotlight'), - description: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_0__.__)('Displays a list of posts that are marked as featured.', 'post-type-spotlight'), - isActive: ({ - namespace, - query - }) => { - return namespace === VARIATION_NAME; - }, - isPTSQueryLoopVariation: ({ - namespace, - query - }) => { - return namespace === VARIATION_NAME; - }, - icon: _components_logo_mark__WEBPACK_IMPORTED_MODULE_1__["default"], - attributes: { - namespace: VARIATION_NAME, - query: { - perPage: 10, - pages: 0, - paged: 1, - offset: 0, - postType: 'page', - order: 'desc', - orderBy: 'date', - author: '', - search: '', - exclude: [], - sticky: '', - inherit: false - }, - queryType: 'featured-only' - }, - scope: ['inserter'], - innerBlocks: [['core/post-template', {}, [['core/post-title'], ['core/post-excerpt']]], ['core/query-pagination'], ['core/query-no-results']], - allowedControls: ['postType', 'search', 'taxQuery'] -}); - -/***/ }), - -/***/ "lodash": -/*!*************************!*\ - !*** external "lodash" ***! - \*************************/ -/***/ ((module) => { - -module.exports = window["lodash"]; - -/***/ }), - -/***/ "@wordpress/block-editor": -/*!*************************************!*\ - !*** external ["wp","blockEditor"] ***! - \*************************************/ -/***/ ((module) => { - -module.exports = window["wp"]["blockEditor"]; - -/***/ }), - -/***/ "@wordpress/blocks": -/*!********************************!*\ - !*** external ["wp","blocks"] ***! - \********************************/ -/***/ ((module) => { - -module.exports = window["wp"]["blocks"]; - -/***/ }), - -/***/ "@wordpress/components": -/*!************************************!*\ - !*** external ["wp","components"] ***! - \************************************/ -/***/ ((module) => { - -module.exports = window["wp"]["components"]; - -/***/ }), - -/***/ "@wordpress/core-data": -/*!**********************************!*\ - !*** external ["wp","coreData"] ***! - \**********************************/ -/***/ ((module) => { - -module.exports = window["wp"]["coreData"]; - -/***/ }), - -/***/ "@wordpress/data": -/*!******************************!*\ - !*** external ["wp","data"] ***! - \******************************/ -/***/ ((module) => { - -module.exports = window["wp"]["data"]; - -/***/ }), - -/***/ "@wordpress/edit-post": -/*!**********************************!*\ - !*** external ["wp","editPost"] ***! - \**********************************/ -/***/ ((module) => { - -module.exports = window["wp"]["editPost"]; - -/***/ }), - -/***/ "@wordpress/element": -/*!*********************************!*\ - !*** external ["wp","element"] ***! - \*********************************/ -/***/ ((module) => { - -module.exports = window["wp"]["element"]; - -/***/ }), - -/***/ "@wordpress/hooks": -/*!*******************************!*\ - !*** external ["wp","hooks"] ***! - \*******************************/ -/***/ ((module) => { - -module.exports = window["wp"]["hooks"]; - -/***/ }), - -/***/ "@wordpress/i18n": -/*!******************************!*\ - !*** external ["wp","i18n"] ***! - \******************************/ -/***/ ((module) => { - -module.exports = window["wp"]["i18n"]; - -/***/ }), - -/***/ "@wordpress/plugins": -/*!*********************************!*\ - !*** external ["wp","plugins"] ***! - \*********************************/ -/***/ ((module) => { - -module.exports = window["wp"]["plugins"]; - -/***/ }), - -/***/ "@wordpress/primitives": -/*!************************************!*\ - !*** external ["wp","primitives"] ***! - \************************************/ -/***/ ((module) => { - -module.exports = window["wp"]["primitives"]; - -/***/ }) - -/******/ }); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/************************************************************************/ -/******/ /* webpack/runtime/compat get default export */ -/******/ (() => { -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = (module) => { -/******/ var getter = module && module.__esModule ? -/******/ () => (module['default']) : -/******/ () => (module); -/******/ __webpack_require__.d(getter, { a: getter }); -/******/ return getter; -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/define property getters */ -/******/ (() => { -/******/ // define getter functions for harmony exports -/******/ __webpack_require__.d = (exports, definition) => { -/******/ for(var key in definition) { -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); -/******/ } -/******/ } -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/hasOwnProperty shorthand */ -/******/ (() => { -/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) -/******/ })(); -/******/ -/******/ /* webpack/runtime/make namespace object */ -/******/ (() => { -/******/ // define __esModule on exports -/******/ __webpack_require__.r = (exports) => { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ })(); -/******/ -/************************************************************************/ -var __webpack_exports__ = {}; -// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. -(() => { -/*!**********************!*\ - !*** ./src/index.js ***! - \**********************/ -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _admin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./admin */ "./src/admin/index.js"); -/* harmony import */ var _query_loop__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./query-loop */ "./src/query-loop/index.js"); -/** - * Register all admin slotfills - */ - // Toggle Sidebar - // Query Loop -})(); - -/******/ })() -; -//# sourceMappingURL=index.js.map \ No newline at end of file +(()=>{"use strict";const e=window.React,t=window.wp.plugins,o=window.wp.editPost,r=window.wp.i18n,s=window.wp.data,a=window.wp.coreData,n=window.wp.components,l=window.lodash,i=window.wp.primitives;function p(t){const{width:o,height:r}=t;return(0,e.createElement)(i.SVG,{id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 47.507 48",width:o,height:r},(0,e.createElement)(i.Defs,null,(0,e.createElement)(i.LinearGradient,{id:"linear-gradient",x1:"15.044",y1:"46.627",x2:"31.956",y2:".16",gradientUnits:"userSpaceOnUse"},(0,e.createElement)(i.Stop,{offset:0,stopColor:"#7d58c6"}),(0,e.createElement)(i.Stop,{offset:.261,stopColor:"#677bc9"}),(0,e.createElement)(i.Stop,{offset:.581,stopColor:"#51a1cc"}),(0,e.createElement)(i.Stop,{offset:.838,stopColor:"#44b8cf"}),(0,e.createElement)(i.Stop,{offset:1,stopColor:"#3fc1d0"}))),(0,e.createElement)(i.Circle,{cx:"43.966",cy:"3.54",r:"3.54",style:{fill:"#7a7a7a"}}),(0,e.createElement)(i.Path,{d:"m43.966,9.895c-3.509,0-6.354-2.845-6.354-6.354,0-.437.044-.863.128-1.275h-14.873C10.238,2.266,0,12.504,0,25.133h0c0,12.629,10.238,22.867,22.867,22.867h0c12.629,0,22.867-10.238,22.867-22.867v-15.489c-.562.162-1.154.251-1.768.251Zm-12.953,26.821l-8.146-4.073-8.146,4.073,1.534-9.001-5.607-6.272,8.146-1.018,4.073-8.146,4.073,8.146,8.146,1.018-5.594,6.272,1.521,9.001Z",style:{fill:"url(#linear-gradient)"}}))}const c=t=>{const{postType:o,isFeatured:s,onUpdateFeatured:a}=t;return(0,e.createElement)(n.__experimentalHStack,{alignment:"top",justify:"flex-start",spacing:"3",style:{marginTop:"calc(12px)",minHeight:"3rem"}},(0,e.createElement)(n.Tooltip,{text:(0,r.sprintf)((0,r.__)("You can query all featured %1$s using the pts_feature_tax"),o)},(0,e.createElement)(n.Icon,{icon:(0,e.createElement)(p,{width:"24px",height:"24px"})})),(0,e.createElement)(n.ToggleControl,{checked:s,label:(0,r.sprintf)((0,r.__)("Feature %1$s","post-type-spotlight"),(0,l.capitalize)(o)),onChange:a,style:{marginBottom:"0!important"}}))};(0,t.registerPlugin)("post-type-post-settings",{render:()=>{const t=(0,s.useSelect)((e=>e("core/editor").getCurrentPostId())),n=(0,s.useSelect)((e=>e("core/editor").getCurrentPostType()));let l=(0,s.useSelect)((e=>e("core").getEntityRecords("taxonomy","pts_feature_tax",{slug:"featured"}))),i=(0,s.useSelect)((e=>e("core/editor").getEditedPostAttribute("pts_feature_tax")));i&&!Array.isArray(i)&&(i=[i]);const[p]=(0,a.useEntityProp)("root","site","pts_featured_post_types_settings");if(!p||p&&-1===p.indexOf(n))return null;l=l?l[0]?.id:null;const u=l&&(i.includes(l)||i===l),{editEntityRecord:d}=(0,s.useDispatch)("core");return(0,e.createElement)(o.PluginPostStatusInfo,{name:"pts-post-settings-panel",title:(0,r.__)("Post Type Spotlight Settings","linchpin"),className:"pts-post-settings-panel",style:{width:"100%"}},(0,e.createElement)(c,{onUpdateFeatured:e=>{const o=e?[...i,l]:i.filter((e=>e!==l));d("postType",n,t,{pts_feature_tax:o})},isFeatured:u,postType:n}))},icon:p});const u=window.wp.blocks,d=window.wp.blockEditor,y=window.wp.hooks,g=({attributes:t,setAttributes:o})=>{const{query:{queryType:s}}=t;return(0,e.createElement)(n.SelectControl,{value:s,label:(0,r.__)("Display Type","post-type-spotlight"),onChange:e=>{o({query:{...t.query,queryType:e||"featured-only"}})},options:[{value:"featured-only",label:(0,r.__)("Only Show Featured","post-type-spotlight")},{value:"featured-first",label:(0,r.__)("Show Featured First","post-type-spotlight")},{value:"featured-exclude",label:(0,r.__)("Exclude Featured","post-type-spotlight")}]})};(0,y.addFilter)("editor.BlockEdit","core/query",(t=>o=>(e=>{const{attributes:{namespace:t}}=e;return"post-type-spotlight/featured-list"===t})(o)?(0,e.createElement)(e.Fragment,null,(0,e.createElement)(t,{...o}),(0,e.createElement)(d.InspectorControls,null,(0,e.createElement)(n.PanelBody,null,(0,e.createElement)(g,{...o})))):(0,e.createElement)(t,{...o})));const m="post-type-spotlight/featured-list";(0,u.registerBlockVariation)("core/query",{name:m,title:(0,r.__)("Featured List","post-type-spotlight"),description:(0,r.__)("Displays a list of posts that are marked as featured.","post-type-spotlight"),isActive:({namespace:e,query:t})=>e===m,isPTSQueryLoopVariation:({namespace:e,query:t})=>e===m,icon:p,attributes:{namespace:m,query:{perPage:10,pages:0,paged:1,offset:0,postType:"page",order:"desc",orderBy:"date",author:"",search:"",exclude:[],sticky:"",inherit:!1},queryType:"featured-only"},scope:["inserter"],innerBlocks:[["core/post-template",{},[["core/post-title"],["core/post-excerpt"]]],["core/query-pagination"],["core/query-no-results"]],allowedControls:["postType","search","taxQuery"]})})(); \ No newline at end of file diff --git a/blocks/build/index.js.map b/blocks/build/index.js.map deleted file mode 100644 index 1fd4add..0000000 --- a/blocks/build/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAoD;AACQ;AACvB;AACoB;AACJ;;AAErD;AAC6C;AACE;AAE/C,MAAMQ,KAAK,GAAGA,CAAA,KAAM;EAElB,MAAMC,MAAM,GAAGN,0DAAS,CAAIO,MAAM,IAAMA,MAAM,CAAE,aAAa,CAAE,CAACC,gBAAgB,EAAE,CAAE;EACpF,MAAMC,QAAQ,GAAGT,0DAAS,CAAIO,MAAM,IAAMA,MAAM,CAAE,aAAa,CAAE,CAACG,kBAAkB,EAAE,CAAE;EACxF,IAAIC,YAAY,GAAGX,0DAAS,CAAIO,MAAM,IAAM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AAO,EAAE,EAAE;MACXC,MAAM,EAAE,EAAE;MACVC,OAAO,EAAE;IACX,CAAC;IACDxD,SAAS,EAAE;EACb,CAAC;EACDyD,KAAK,EAAE,CAAE,UAAU,CAAE;EACrBC,WAAW,EAAG,CACZ,CACE,oBAAoB,EACpB,CAAC,CAAC,EACF,CAAE,CAAE,iBAAiB,CAAE,EAAE,CAAE,mBAAmB,CAAE,CAAE,CACnD,EACD,CAAE,uBAAuB,CAAE,EAC3B,CAAE,uBAAuB,CAAE,CAC5B;EACDC,eAAe,EAAE,CAAE,UAAU,EAAE,QAAQ,EAAE,UAAU;AACrD,CAAC,CACF;;;;;;;;;;ACtDD;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;;;;;;;;;ACNA;AACA;AACA;AACgB,CAAC;AACI,CAAC,a","sources":["webpack://post-type-spotlight-blocks/./src/admin/index.js","webpack://post-type-spotlight-blocks/./src/components/filter.js","webpack://post-type-spotlight-blocks/./src/components/logo-mark.js","webpack://post-type-spotlight-blocks/./src/components/toggle.js","webpack://post-type-spotlight-blocks/./src/query-loop/controls.js","webpack://post-type-spotlight-blocks/./src/query-loop/index.js","webpack://post-type-spotlight-blocks/external window \"lodash\"","webpack://post-type-spotlight-blocks/external window [\"wp\",\"blockEditor\"]","webpack://post-type-spotlight-blocks/external window [\"wp\",\"blocks\"]","webpack://post-type-spotlight-blocks/external window [\"wp\",\"components\"]","webpack://post-type-spotlight-blocks/external window [\"wp\",\"coreData\"]","webpack://post-type-spotlight-blocks/external window [\"wp\",\"data\"]","webpack://post-type-spotlight-blocks/external window [\"wp\",\"editPost\"]","webpack://post-type-spotlight-blocks/external window [\"wp\",\"element\"]","webpack://post-type-spotlight-blocks/external window [\"wp\",\"hooks\"]","webpack://post-type-spotlight-blocks/external window [\"wp\",\"i18n\"]","webpack://post-type-spotlight-blocks/external window [\"wp\",\"plugins\"]","webpack://post-type-spotlight-blocks/external window [\"wp\",\"primitives\"]","webpack://post-type-spotlight-blocks/webpack/bootstrap","webpack://post-type-spotlight-blocks/webpack/runtime/compat get default export","webpack://post-type-spotlight-blocks/webpack/runtime/define property getters","webpack://post-type-spotlight-blocks/webpack/runtime/hasOwnProperty shorthand","webpack://post-type-spotlight-blocks/webpack/runtime/make namespace object","webpack://post-type-spotlight-blocks/./src/index.js"],"sourcesContent":["import { registerPlugin } from '@wordpress/plugins';\nimport { PluginPostStatusInfo } from '@wordpress/edit-post';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEntityProp } from \"@wordpress/core-data\";\n\n// Internal Components\nimport PTSToggle from '../components/toggle';\nimport LogoMark from '../components/logo-mark';\n\nconst Admin = () => {\n\n const postId = useSelect( ( select ) => select( 'core/editor' ).getCurrentPostId() );\n const postType = useSelect( ( select ) => select( 'core/editor' ).getCurrentPostType() );\n let featuredTerm = useSelect( ( select ) => select( 'core' ).getEntityRecords( 'taxonomy', 'pts_feature_tax', { slug: 'featured' } ) );\n let postTerms = useSelect( ( select ) => select( 'core/editor' ).getEditedPostAttribute( 'pts_feature_tax' ) );\n\n if ( postTerms && ! Array.isArray( postTerms ) ) {\n postTerms = [ postTerms ];\n }\n\n featuredTerm = featuredTerm ? featuredTerm[0]?.id : null;\n const isFeatured = featuredTerm && (postTerms.includes( featuredTerm ) || postTerms === featuredTerm );\n\n const { editEntityRecord } = useDispatch( 'core' );\n\n const [ postTypeSpotlightSettings ] = useEntityProp( 'root', 'site', 'pts_featured_post_types_settings' );\n\n // If the post type is not enabled in our writing settings\n // then we can die early.\n if ( ! postTypeSpotlightSettings || ( postTypeSpotlightSettings && postTypeSpotlightSettings.indexOf( postType ) === -1 ) ) {\n return null;\n }\n\n const onUpdateFeatured = ( newValue ) => {\n const updatedTerms = newValue\n ? [...postTerms, featuredTerm]\n : postTerms.filter( ( termId ) => termId !== featuredTerm );\n\n editEntityRecord( 'postType', postType, postId, { pts_feature_tax: updatedTerms } );\n };\n\n\treturn (\n\t\t\n \n\t\t\n\t);\n}\n\nregisterPlugin( 'post-type-post-settings', {\n\trender: Admin,\n\ticon: LogoMark,\n} );\n","import { __, sprintf } from '@wordpress/i18n';\nimport {\n ToggleControl,\n __experimentalHStack as HStack,\n Tooltip,\n Icon, SelectControl\n} from \"@wordpress/components\";\nimport {capitalize} from \"lodash\";\n\nimport LogoMark from '../components/logo-mark';\n\nconst PTSFilter = ( { attributes, setAttributes } ) => {\n\n const {\n query: {\n queryType\n }\n } = attributes;\n\n\treturn (\n {\n // filter the tokens to remove wrong items.\n setAttributes( {\n query: {\n ...attributes.query,\n queryType: queryType || 'featured-only',\n },\n } );\n } }\n options={ [\n {value : 'featured-only', label : __('Only Show Featured', 'post-type-spotlight')},\n {value : 'featured-first', label : __('Show Featured First', 'post-type-spotlight')},\n {value : 'featured-exclude', label : __('Exclude Featured', 'post-type-spotlight')},\n ] } />\n\t);\n}\n\nexport default PTSFilter;\n","/**\n * WordPress dependencies\n */\nimport { SVG, Path, Defs, Stop, Circle, LinearGradient } from '@wordpress/primitives';\n\nexport default function LogoMark(props) {\n\n const {\n width,\n height\n } = props;\n\n return (\n \n \n \n \n \n \n \n \n \n \n \n \n \n );\n}\n","import { __, sprintf } from '@wordpress/i18n';\nimport {\n ToggleControl,\n __experimentalHStack as HStack,\n Tooltip,\n Icon\n} from \"@wordpress/components\";\nimport {capitalize} from \"lodash\";\n\nimport LogoMark from '../components/logo-mark';\n\nconst PTSToggle = ( props ) => {\n\n const {\n postType,\n isFeatured,\n onUpdateFeatured,\n } = props;\n\n\treturn (\n \n \n } />\n \n \n \n\t);\n}\n\nexport default PTSToggle;\n","import { InspectorControls } from '@wordpress/block-editor';\nimport { addFilter } from '@wordpress/hooks';\nimport { PanelBody } from \"@wordpress/components\";\nimport PTSFilter from '../components/filter';\n\nexport const withPSTQueryControls = ( BlockEdit ) => ( props ) => {\n\n const isPTSQueryLoopVariation = ( props ) => {\n const {\n attributes: { namespace },\n } = props;\n\n return (\n namespace === 'post-type-spotlight/featured-list'\n );\n }\n\n return isPTSQueryLoopVariation( props ) ? (\n <>\n \n \n \n \n \n \n \n ) : (\n \n );\n};\n\naddFilter( 'editor.BlockEdit', 'core/query', withPSTQueryControls );\n","import { __, sprintf } from '@wordpress/i18n';\n\nimport LogoMark from '../components/logo-mark';\nimport {registerBlockVariation} from \"@wordpress/blocks\";\n\nimport './controls'; // Load out controls\n\nconst VARIATION_NAME = 'post-type-spotlight/featured-list';\n\nregisterBlockVariation( 'core/query', {\n name: VARIATION_NAME,\n title: __( 'Featured List', 'post-type-spotlight' ),\n description: __( 'Displays a list of posts that are marked as featured.', 'post-type-spotlight' ),\n isActive: ( { namespace, query } ) => {\n return (\n namespace === VARIATION_NAME\n );\n },\n isPTSQueryLoopVariation: ( { namespace, query } ) => {\n return (\n namespace === VARIATION_NAME\n );\n },\n icon: LogoMark,\n attributes: {\n namespace: VARIATION_NAME,\n query: {\n perPage: 10,\n pages: 0,\n paged: 1,\n offset: 0,\n postType: 'page',\n order: 'desc',\n orderBy: 'date',\n author: '',\n search: '',\n exclude: [],\n sticky: '',\n inherit: false,\n },\n queryType: 'featured-only',\n },\n scope: [ 'inserter' ],\n innerBlocks : [\n [\n 'core/post-template',\n {},\n [ [ 'core/post-title' ], [ 'core/post-excerpt' ] ],\n ],\n [ 'core/query-pagination' ],\n [ 'core/query-no-results' ],\n ],\n allowedControls: [ 'postType', 'search', 'taxQuery' ]\n }\n);\n","module.exports = window[\"lodash\"];","module.exports = window[\"wp\"][\"blockEditor\"];","module.exports = window[\"wp\"][\"blocks\"];","module.exports = window[\"wp\"][\"components\"];","module.exports = window[\"wp\"][\"coreData\"];","module.exports = window[\"wp\"][\"data\"];","module.exports = window[\"wp\"][\"editPost\"];","module.exports = window[\"wp\"][\"element\"];","module.exports = window[\"wp\"][\"hooks\"];","module.exports = window[\"wp\"][\"i18n\"];","module.exports = window[\"wp\"][\"plugins\"];","module.exports = window[\"wp\"][\"primitives\"];","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\n * Register all admin slotfills\n */\nimport './admin' // Toggle Sidebar\nimport './query-loop' // Query Loop\n"],"names":["registerPlugin","PluginPostStatusInfo","__","useSelect","useDispatch","useEntityProp","PTSToggle","LogoMark","Admin","postId","select","getCurrentPostId","postType","getCurrentPostType","featuredTerm","getEntityRecords","slug","postTerms","getEditedPostAttribute","Array","isArray","id","isFeatured","includes","editEntityRecord","postTypeSpotlightSettings","indexOf","onUpdateFeatured","newValue","updatedTerms","filter","termId","pts_feature_tax","createElement","name","title","className","style","width","render","icon","sprintf","ToggleControl","__experimentalHStack","HStack","Tooltip","Icon","SelectControl","capitalize","PTSFilter","attributes","setAttributes","query","queryType","value","label","onChange","options","SVG","Path","Defs","Stop","Circle","LinearGradient","props","height","xmlns","viewBox","x1","y1","x2","y2","gradientUnits","offset","stopColor","cx","cy","r","fill","d","alignment","justify","spacing","marginTop","minHeight","text","checked","marginBottom","InspectorControls","addFilter","PanelBody","withPSTQueryControls","BlockEdit","isPTSQueryLoopVariation","namespace","Fragment","registerBlockVariation","VARIATION_NAME","description","isActive","perPage","pages","paged","order","orderBy","author","search","exclude","sticky","inherit","scope","innerBlocks","allowedControls"],"sourceRoot":""} \ No newline at end of file diff --git a/blocks/package-lock.json b/blocks/package-lock.json index 9cfd2bd..dc5dedd 100644 --- a/blocks/package-lock.json +++ b/blocks/package-lock.json @@ -1,12 +1,12 @@ { "name": "post-type-spotlight-blocks", - "version": "3.0.0", + "version": "3.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "post-type-spotlight-blocks", - "version": "3.0.0", + "version": "3.0.1", "license": "GPL-2.0-or-later", "dependencies": { "@wordpress/block-editor": "^12.13.0", diff --git a/blocks/src/admin/index.js b/blocks/src/admin/index.js index 0630dc5..9a2723c 100644 --- a/blocks/src/admin/index.js +++ b/blocks/src/admin/index.js @@ -19,11 +19,6 @@ const Admin = () => { postTerms = [ postTerms ]; } - featuredTerm = featuredTerm ? featuredTerm[0]?.id : null; - const isFeatured = featuredTerm && (postTerms.includes( featuredTerm ) || postTerms === featuredTerm ); - - const { editEntityRecord } = useDispatch( 'core' ); - const [ postTypeSpotlightSettings ] = useEntityProp( 'root', 'site', 'pts_featured_post_types_settings' ); // If the post type is not enabled in our writing settings @@ -32,6 +27,11 @@ const Admin = () => { return null; } + featuredTerm = featuredTerm ? featuredTerm[0]?.id : null; + const isFeatured = featuredTerm && (postTerms.includes( featuredTerm ) || postTerms === featuredTerm ); + + const { editEntityRecord } = useDispatch( 'core' ); + const onUpdateFeatured = ( newValue ) => { const updatedTerms = newValue ? [...postTerms, featuredTerm]