diff --git a/wp-content/plugins/acf-blocks-toolkit/build/icons.json b/wp-content/plugins/acf-blocks-toolkit/assets/icons.json similarity index 100% rename from wp-content/plugins/acf-blocks-toolkit/build/icons.json rename to wp-content/plugins/acf-blocks-toolkit/assets/icons.json diff --git a/wp-content/plugins/acf-blocks-toolkit/build/editor.asset.php b/wp-content/plugins/acf-blocks-toolkit/build/editor.asset.php index 7e7ff5da..b3969845 100644 --- a/wp-content/plugins/acf-blocks-toolkit/build/editor.asset.php +++ b/wp-content/plugins/acf-blocks-toolkit/build/editor.asset.php @@ -1 +1 @@ - array(), 'version' => 'aa3233cc24842e7fbaef'); + array(), 'version' => '51a36d532ad341289a38'); diff --git a/wp-content/plugins/acf-blocks-toolkit/build/editor.css b/wp-content/plugins/acf-blocks-toolkit/build/editor.css index 722acd83..8de0b0ee 100644 --- a/wp-content/plugins/acf-blocks-toolkit/build/editor.css +++ b/wp-content/plugins/acf-blocks-toolkit/build/editor.css @@ -1,53 +1 @@ -/*!****************************************************************************************************************************************************************************************************************************************!*\ - !*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].use[2]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[4].use[3]!./src/editor.scss ***! - \****************************************************************************************************************************************************************************************************************************************/ -.wp-block-button[class*=has-icon__] .wp-block-button__link::after { - content: ""; -} -.wp-block-button[class*=has-icon__] .wp-block-button__link::after, .wp-block-button[class*=has-icon__] .wp-block-button__link::before { - display: inline-block; - background-color: currentColor; - -webkit-mask-size: contain; - mask-size: contain; - -webkit-mask-position: center; - mask-position: center; - -webkit-mask-repeat: no-repeat; - mask-repeat: no-repeat; - height: 0.8em; - width: 0.45em; -} -.wp-block-button[class*=has-icon__].has-icon-position__left .wp-block-button__link::after { - content: none; -} -.wp-block-button[class*=has-icon__].has-icon-position__left .wp-block-button__link::before { - content: ""; -} - -.button-icon-picker .components-panel__row:not(:nth-child(2)) { - margin-top: 16px; -} -.button-icon-picker .button-icon-picker__grid { - border-radius: 2px; - border: 1px solid rgb(148, 148, 148); - max-height: 150px; - overflow: auto; - padding: 2px; - width: 100%; -} -.button-icon-picker__button span { - align-items: center; - display: flex; - height: 100%; - justify-content: center; - width: 100%; -} -.button-icon-picker__button span svg { - -o-object-fit: contain; - object-fit: contain; - display: block; - width: 100%; - height: 100%; - aspect-ratio: 1/1; -} - -/*# sourceMappingURL=editor.css.map*/ \ No newline at end of file +.wp-block-button[class*=has-icon__] .wp-block-button__link:after{content:""}.wp-block-button[class*=has-icon__] .wp-block-button__link:after,.wp-block-button[class*=has-icon__] .wp-block-button__link:before{background-color:currentColor;display:inline-block;height:.8em;-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-size:contain;mask-size:contain;width:.45em}.wp-block-button[class*=has-icon__].has-icon-position__left .wp-block-button__link:before{content:""}.button-icon-picker .components-panel__row:not(:nth-child(2)){margin-top:16px}.button-icon-picker .button-icon-picker__grid{border:1px solid #949494;border-radius:2px;max-height:150px;overflow:auto;padding:2px;width:100%}.button-icon-picker__button span{align-items:center;display:flex;height:100%;justify-content:center;width:100%}.button-icon-picker__button span svg{aspect-ratio:1/1;display:block;height:100%;-o-object-fit:contain;object-fit:contain;width:100%} diff --git a/wp-content/plugins/acf-blocks-toolkit/build/editor.css.map b/wp-content/plugins/acf-blocks-toolkit/build/editor.css.map deleted file mode 100644 index 311ee5dd..00000000 --- a/wp-content/plugins/acf-blocks-toolkit/build/editor.css.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"editor.css","mappings":";;;AAGE;EACC;AAFH;AAME;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AAJH;AAUG;EACC;AARJ;AAWG;EACC;AATJ;;AAkBE;EACC;AAfH;AAmBC;EACC;EACA;EACA;EACA;EACA;EACA;AAjBF;AAoBC;EACC;EACA;EACA;EACA;EACA;AAlBF;AAoBE;EACC;KAAA;EACA;EACA;EACA;EACA;AAlBH,C","sources":["webpack://acf-blocks-toolkit/./src/editor.scss"],"sourcesContent":["// Add icons to Button blocks and style appropriately.\n.wp-block-button[class*=has-icon__] {\n\t.wp-block-button__link {\n\t\t&::after {\n\t\t\tcontent: \"\";\n\t\t}\n\n\t\t// Styles the icon.\n\t\t&::after, &::before {\n\t\t\tdisplay: inline-block;\n\t\t\tbackground-color: currentColor;\n\t\t\t-webkit-mask-size: contain;\n\t\t\tmask-size: contain;\n\t\t\t-webkit-mask-position:center;\n\t\t\tmask-position:center;\n\t\t\t-webkit-mask-repeat: no-repeat;\n\t\t\tmask-repeat: no-repeat;\n\t\t\theight: 0.8em;\n\t\t\twidth: 0.45em;\n\t\t}\n\t}\n\n\t&.has-icon-position__left {\n\t\t.wp-block-button__link {\n\t\t\t&::after {\n\t\t\t\tcontent: none;\n\t\t\t}\n\n\t\t\t&::before {\n\t\t\t\tcontent: \"\";\n\t\t\t}\n\t\t}\n\t}\n}\n\n// Style \"Icon Settings\" panel.\n.button-icon-picker {\n\t.components-panel__row {\n\t\t&:not(:nth-child(2)) {\n\t\t\tmargin-top: 16px;\n\t\t}\n\t}\n\n\t.button-icon-picker__grid {\n\t\tborder-radius: 2px;\n\t\tborder: 1px solid rgb(148, 148, 148);\n\t\tmax-height: 150px;\n\t\toverflow: auto;\n\t\tpadding: 2px;\n\t\twidth: 100%;\n\t}\n\n\t&__button span {\n\t\talign-items: center;\n\t\tdisplay: flex;\n\t\theight: 100%;\n\t\tjustify-content: center;\n\t\twidth: 100%;\n\n\t\tsvg {\n\t\t\tobject-fit: contain;\n\t\t\tdisplay: block;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t\taspect-ratio: 1/1;\n\t\t}\n\t}\n}\n"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/wp-content/plugins/acf-blocks-toolkit/build/index.asset.php b/wp-content/plugins/acf-blocks-toolkit/build/index.asset.php index 4bc43a19..1890eb06 100644 --- a/wp-content/plugins/acf-blocks-toolkit/build/index.asset.php +++ b/wp-content/plugins/acf-blocks-toolkit/build/index.asset.php @@ -1 +1 @@ - array('react', 'wp-block-editor', 'wp-components', 'wp-hooks', 'wp-i18n'), 'version' => '47c7012022a02d01182b'); + array('react', 'wp-block-editor', 'wp-components', 'wp-hooks', 'wp-i18n'), 'version' => '5d2f309ba1c2b62ab162'); diff --git a/wp-content/plugins/acf-blocks-toolkit/build/index.js b/wp-content/plugins/acf-blocks-toolkit/build/index.js index a624e481..8fa0c582 100644 --- a/wp-content/plugins/acf-blocks-toolkit/build/index.js +++ b/wp-content/plugins/acf-blocks-toolkit/build/index.js @@ -1,392 +1 @@ -/******/ (() => { // webpackBootstrap -/******/ var __webpack_modules__ = ({ - -/***/ "react": -/*!************************!*\ - !*** external "React" ***! - \************************/ -/***/ ((module) => { - -"use strict"; -module.exports = window["React"]; - -/***/ }), - -/***/ "@wordpress/block-editor": -/*!*************************************!*\ - !*** external ["wp","blockEditor"] ***! - \*************************************/ -/***/ ((module) => { - -"use strict"; -module.exports = window["wp"]["blockEditor"]; - -/***/ }), - -/***/ "@wordpress/components": -/*!************************************!*\ - !*** external ["wp","components"] ***! - \************************************/ -/***/ ((module) => { - -"use strict"; -module.exports = window["wp"]["components"]; - -/***/ }), - -/***/ "@wordpress/hooks": -/*!*******************************!*\ - !*** external ["wp","hooks"] ***! - \*******************************/ -/***/ ((module) => { - -"use strict"; -module.exports = window["wp"]["hooks"]; - -/***/ }), - -/***/ "@wordpress/i18n": -/*!******************************!*\ - !*** external ["wp","i18n"] ***! - \******************************/ -/***/ ((module) => { - -"use strict"; -module.exports = window["wp"]["i18n"]; - -/***/ }), - -/***/ "./node_modules/classnames/index.js": -/*!******************************************!*\ - !*** ./node_modules/classnames/index.js ***! - \******************************************/ -/***/ ((module, exports) => { - -var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! - Copyright (c) 2018 Jed Watson. - Licensed under the MIT License (MIT), see - http://jedwatson.github.io/classnames -*/ -/* global define */ - -(function () { - 'use strict'; - - var hasOwn = {}.hasOwnProperty; - - function classNames () { - var classes = ''; - - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i]; - if (arg) { - classes = appendClass(classes, parseValue(arg)); - } - } - - return classes; - } - - function parseValue (arg) { - if (typeof arg === 'string' || typeof arg === 'number') { - return arg; - } - - if (typeof arg !== 'object') { - return ''; - } - - if (Array.isArray(arg)) { - return classNames.apply(null, arg); - } - - if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) { - return arg.toString(); - } - - var classes = ''; - - for (var key in arg) { - if (hasOwn.call(arg, key) && arg[key]) { - classes = appendClass(classes, key); - } - } - - return classes; - } - - function appendClass (value, newClass) { - if (!newClass) { - return value; - } - - if (value) { - return value + ' ' + newClass; - } - - return value + newClass; - } - - if ( true && module.exports) { - classNames.default = classNames; - module.exports = classNames; - } else if (true) { - // register as 'classnames', consistent with npm package name - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () { - return classNames; - }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else {} -}()); - - -/***/ }), - -/***/ "./build/icons.json": -/*!**************************!*\ - !*** ./build/icons.json ***! - \**************************/ -/***/ ((module) => { - -"use strict"; -module.exports = /*#__PURE__*/JSON.parse('[{"label":"Arrow Left","value":"arrow-left","icon":""},{"label":"Arrow Right","value":"arrow-right","icon":""},{"label":"Chevron Left","value":"chevron-left","icon":""},{"label":"Chevron Left Small","value":"chevron-left-small","icon":""},{"label":"Chevron Right","value":"chevron-right","icon":""},{"label":"Chevron Right Small","value":"chevron-right-small","icon":""},{"label":"Cloud","value":"cloud","icon":""},{"label":"Cloud Upload","value":"cloud-upload","icon":""},{"label":"Comment Author Avatar","value":"comment-author-avatar","icon":""},{"label":"Download","value":"download","icon":""},{"label":"External","value":"external","icon":""},{"label":"External Arrow","value":"external-arrow","icon":""},{"label":"Help","value":"help","icon":""},{"label":"Info","value":"info","icon":""},{"label":"Lock Outline","value":"lock-outline","icon":""},{"label":"Login","value":"login","icon":""},{"label":"Next","value":"next","icon":""},{"label":"Previous","value":"previous","icon":""},{"label":"Shuffle","value":"shuffle","icon":""},{"label":"WordPress","value":"wordpress","icon":""}]'); - -/***/ }) - -/******/ }); -/************************************************************************/ -/******/ // 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 in strict mode. -(() => { -"use strict"; -/*!**********************!*\ - !*** ./src/index.js ***! - \**********************/ -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ ICONS: () => (/* binding */ ICONS) -/* harmony export */ }); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! classnames */ "./node_modules/classnames/index.js"); -/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/hooks */ "@wordpress/hooks"); -/* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_3__); -/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/block-editor */ "@wordpress/block-editor"); -/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4__); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__); -/* harmony import */ var _build_icons_json__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../build/icons.json */ "./build/icons.json"); - -/** - * External dependencies - */ - - -/** - * WordPress dependencies - */ - - - - - - -/** - * All available icons. - * (Order determines presentation order) - */ -const ICONS = _build_icons_json__WEBPACK_IMPORTED_MODULE_6__; - -/** - * Add the attributes needed for button icons. - * - * @since 0.1.0 - * @param {Object} settings - */ -function addAttributes(settings) { - if ('core/button' !== settings.name) { - return settings; - } - - // Add the block visibility attributes. - const iconAttributes = { - icon: { - type: 'string' - }, - iconPositionLeft: { - type: 'boolean', - default: false - } - }; - return { - ...settings, - attributes: { - ...settings.attributes, - ...iconAttributes - } - }; -} -(0,_wordpress_hooks__WEBPACK_IMPORTED_MODULE_3__.addFilter)('blocks.registerBlockType', 'acf-blocks-toolkit/add-attributes', addAttributes); - -/** - * Filter the BlockEdit object and add icon inspector controls to button blocks. - * - * @since 0.1.0 - * @param {Object} BlockEdit - */ -function addInspectorControls(BlockEdit) { - return props => { - if (props.name !== 'core/button') { - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(BlockEdit, { - ...props - }); - } - const { - attributes, - setAttributes - } = props; - const { - icon: currentIcon, - iconPositionLeft - } = attributes; - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(BlockEdit, { - ...props - }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4__.InspectorControls, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.PanelBody, { - title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Icon', 'acf-blocks-toolkit'), - className: "button-icon-picker", - initialOpen: true - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.PanelRow, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.__experimentalGrid, { - className: "button-icon-picker__grid", - columns: "5", - gap: "0" - }, ICONS.map((icon, index) => { - var _icon$icon; - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.Button, { - key: index, - label: icon?.label, - isPressed: currentIcon === icon.value, - className: "button-icon-picker__button", - onClick: () => setAttributes({ - // Allow user to disable icons. - icon: currentIcon === icon.value ? null : icon.value - }) - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", { - dangerouslySetInnerHTML: { - __html: (_icon$icon = icon.icon) !== null && _icon$icon !== void 0 ? _icon$icon : icon.value - } - })); - }))), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.PanelRow, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.ToggleControl, { - label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Show icon on left', 'acf-blocks-toolkit'), - checked: iconPositionLeft, - onChange: () => { - setAttributes({ - iconPositionLeft: !iconPositionLeft - }); - } - }))))); - }; -} -(0,_wordpress_hooks__WEBPACK_IMPORTED_MODULE_3__.addFilter)('editor.BlockEdit', 'acf-blocks-toolkit/add-inspector-controls', addInspectorControls); - -/** - * Add icon and position classes in the Editor. - * - * @since 0.1.0 - * @param {Object} BlockListBlock - */ -function addClasses(BlockListBlock) { - return props => { - const { - name, - attributes - } = props; - if ('core/button' !== name || !attributes?.icon) { - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(BlockListBlock, { - ...props - }); - } - const classes = classnames__WEBPACK_IMPORTED_MODULE_1___default()(props?.className, { - [`has-icon__${attributes?.icon}`]: attributes?.icon, - 'has-icon-position__left': attributes?.iconPositionLeft - }); - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(BlockListBlock, { - ...props, - className: classes - }); - }; -} -(0,_wordpress_hooks__WEBPACK_IMPORTED_MODULE_3__.addFilter)('editor.BlockListBlock', 'acf-blocks-toolkit/add-classes', addClasses); -})(); - -/******/ })() -; -//# sourceMappingURL=index.js.map \ No newline at end of file +(()=>{var t={942:(t,e)=>{var n;!function(){"use strict";var o={}.hasOwnProperty;function r(){for(var t="",e=0;e{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{"use strict";const t=window.React;var e=n(942),o=n.n(e);const r=window.wp.i18n,i=window.wp.hooks,c=window.wp.blockEditor,a=window.wp.components,l=acfbtIcons.iconsJson;(0,i.addFilter)("blocks.registerBlockType","acf-blocks-toolkit/add-attributes",(function(t){return"core/button"!==t.name?t:{...t,attributes:{...t.attributes,icon:{type:"string"},iconPositionLeft:{type:"boolean",default:!1}}}})),(0,i.addFilter)("editor.BlockEdit","acf-blocks-toolkit/add-inspector-controls",(function(e){return n=>{if("core/button"!==n.name)return(0,t.createElement)(e,{...n});const{attributes:o,setAttributes:i}=n,{icon:s,iconPositionLeft:u}=o;return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(e,{...n}),(0,t.createElement)(c.InspectorControls,null,(0,t.createElement)(a.PanelBody,{title:(0,r.__)("Icon","acf-blocks-toolkit"),className:"button-icon-picker",initialOpen:!0},(0,t.createElement)(a.PanelRow,null,(0,t.createElement)(a.__experimentalGrid,{className:"button-icon-picker__grid",columns:"5",gap:"0"},l.map(((e,n)=>{var o;return(0,t.createElement)(a.Button,{key:n,label:e?.label,isPressed:s===e.value,className:"button-icon-picker__button button-icon-picker__icon-"+e.value,onClick:()=>i({icon:s===e.value?null:e.value})},(0,t.createElement)("span",{dangerouslySetInnerHTML:{__html:null!==(o=e.icon)&&void 0!==o?o:e.value}}))})))),(0,t.createElement)(a.PanelRow,null,(0,t.createElement)(a.ToggleControl,{label:(0,r.__)("Show icon on left","acf-blocks-toolkit"),checked:u,onChange:()=>{i({iconPositionLeft:!u})}})))))}})),(0,i.addFilter)("editor.BlockListBlock","acf-blocks-toolkit/add-classes",(function(e){return n=>{const{name:r,attributes:i}=n;if("core/button"!==r||!i?.icon)return(0,t.createElement)(e,{...n});const c=o()(n?.className,{[`has-icon__${i?.icon}`]:i?.icon,"has-icon-position__left":i?.iconPositionLeft});return(0,t.createElement)(e,{...n,className:c})}}))})()})(); \ No newline at end of file diff --git a/wp-content/plugins/acf-blocks-toolkit/build/index.js.map b/wp-content/plugins/acf-blocks-toolkit/build/index.js.map deleted file mode 100644 index 946f84a4..00000000 --- a/wp-content/plugins/acf-blocks-toolkit/build/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","mappings":";;;;;;;;;;AAAA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,gBAAgB;;AAEhB;AACA;;AAEA,kBAAkB,sBAAsB;AACxC;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,KAAK,KAA6B;AAClC;AACA;AACA,GAAG,SAAS,IAA4E;AACxF;AACA,EAAE,iCAAqB,EAAE,mCAAE;AAC3B;AACA,GAAG;AAAA,kGAAC;AACJ,GAAG,KAAK,EAEN;AACF,CAAC;;;;;;;;;;;;;;;;;;UC5ED;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;AACoC;;AAEpC;AACA;AACA;AACqC;AACQ;AACe;AAO7B;AAES;;AAExC;AACA;AACA;AACA;AACO,MAAMW,KAAK,GAAGD,8CAAK;;AAE1B;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,aAAaA,CAAEC,QAAQ,EAAG;EAClC,IAAK,aAAa,KAAKA,QAAQ,CAACC,IAAI,EAAG;IACtC,OAAOD,QAAQ;EAChB;;EAEA;EACA,MAAME,cAAc,GAAG;IACtBC,IAAI,EAAE;MACLC,IAAI,EAAE;IACP,CAAC;IACDC,gBAAgB,EAAE;MACjBD,IAAI,EAAE,SAAS;MACfE,OAAO,EAAE;IACV;EACD,CAAC;EAED,OAAO;IACN,GAAGN,QAAQ;IACXO,UAAU,EAAE;MACX,GAAGP,QAAQ,CAACO,UAAU;MACtB,GAAGL;IACJ;EACD,CAAC;AACF;AAEAb,2DAAS,CACR,0BAA0B,EAC1B,mCAAmC,EACnCU,aACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,SAASS,oBAAoBA,CAAEC,SAAS,EAAG;EAC1C,OAASC,KAAK,IAAM;IACnB,IAAKA,KAAK,CAACT,IAAI,KAAK,aAAa,EAAG;MACnC,OAAOU,oDAAA,CAACF,SAAS;QAAA,GAAMC;MAAK,CAAI,CAAC;IAClC;IAEA,MAAM;MAAEH,UAAU;MAAEK;IAAc,CAAC,GAAGF,KAAK;IAC3C,MAAM;MAAEP,IAAI,EAAEU,WAAW;MAAER;IAAiB,CAAC,GAAGE,UAAU;IAE1D,OACCI,oDAAA,CAAAG,2CAAA,QACCH,oDAAA,CAACF,SAAS;MAAA,GAAMC;IAAK,CAAI,CAAC,EAC1BC,oDAAA,CAACrB,sEAAiB,QACjBqB,oDAAA,CAACnB,4DAAS;MACTuB,KAAK,EAAG3B,mDAAE,CAAE,MAAM,EAAE,oBAAqB,CAAG;MAC5C4B,SAAS,EAAC,oBAAoB;MAC9BC,WAAW,EAAG;IAAM,GAEpBN,oDAAA,CAAClB,2DAAQ,QACRkB,oDAAA,CAACf,qEAAI;MACJoB,SAAS,EAAC,0BAA0B;MACpCE,OAAO,EAAC,GAAG;MACXC,GAAG,EAAC;IAAG,GAELrB,KAAK,CAACsB,GAAG,CAAE,CAAEjB,IAAI,EAAEkB,KAAK;MAAA,IAAAC,UAAA;MAAA,OACzBX,oDAAA,CAACpB,yDAAM;QACNgC,GAAG,EAAEF,KAAM;QACXG,KAAK,EAAErB,IAAI,EAAEqB,KAAM;QACnBC,SAAS,EAAEZ,WAAW,KAAKV,IAAI,CAACuB,KAAM;QACtCV,SAAS,EAAC,4BAA4B;QACtCW,OAAO,EAAEA,CAAA,KACRf,aAAa,CAAC;UACb;UACAT,IAAI,EACHU,WAAW,KAAKV,IAAI,CAACuB,KAAK,GACvB,IAAI,GACJvB,IAAI,CAACuB;QACV,CAAC;MACD,GAEDf,oDAAA;QAAMiB,uBAAuB,EAAE;UAACC,MAAM,GAAAP,UAAA,GAAEnB,IAAI,CAACA,IAAI,cAAAmB,UAAA,cAAAA,UAAA,GAAInB,IAAI,CAACuB;QAAK;MAAE,CAAC,CAC3D,CAAC;IAAA,CACT,CACI,CACG,CAAC,EACXf,oDAAA,CAAClB,2DAAQ,QACTkB,oDAAA,CAACjB,gEAAa;MACZ8B,KAAK,EAAGpC,mDAAE,CACT,mBAAmB,EACnB,oBACD,CAAG;MACH0C,OAAO,EAAGzB,gBAAkB;MAC5B0B,QAAQ,EAAGA,CAAA,KAAM;QAChBnB,aAAa,CAAE;UACdP,gBAAgB,EAAE,CAAEA;QACrB,CAAE,CAAC;MACJ;IAAG,CACH,CACQ,CACA,CACO,CAClB,CAAC;EAEL,CAAC;AACF;AAEAhB,2DAAS,CACR,kBAAkB,EAClB,2CAA2C,EAC3CmB,oBACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,SAASwB,UAAUA,CAAEC,cAAc,EAAG;EACrC,OAASvB,KAAK,IAAM;IACnB,MAAM;MAAET,IAAI;MAAEM;IAAW,CAAC,GAAGG,KAAK;IAElC,IAAK,aAAa,KAAKT,IAAI,IAAI,CAAEM,UAAU,EAAEJ,IAAI,EAAG;MACnD,OAAOQ,oDAAA,CAACsB,cAAc;QAAA,GAAMvB;MAAK,CAAI,CAAC;IACvC;IAEA,MAAMwB,OAAO,GAAG/C,iDAAU,CAAEuB,KAAK,EAAEM,SAAS,EAAE;MAC7C,CAAG,aAAaT,UAAU,EAAEJ,IAAM,EAAC,GAAII,UAAU,EAAEJ,IAAI;MACvD,yBAAyB,EAAEI,UAAU,EAAEF;IACxC,CAAE,CAAC;IAEH,OAAOM,oDAAA,CAACsB,cAAc;MAAA,GAAMvB,KAAK;MAAGM,SAAS,EAAGkB;IAAS,CAAE,CAAC;EAC7D,CAAC;AACF;AAEA7C,2DAAS,CACR,uBAAuB,EACvB,gCAAgC,EAChC2C,UACD,CAAC,C","sources":["webpack://acf-blocks-toolkit/external window \"React\"","webpack://acf-blocks-toolkit/external window [\"wp\",\"blockEditor\"]","webpack://acf-blocks-toolkit/external window [\"wp\",\"components\"]","webpack://acf-blocks-toolkit/external window [\"wp\",\"hooks\"]","webpack://acf-blocks-toolkit/external window [\"wp\",\"i18n\"]","webpack://acf-blocks-toolkit/./node_modules/classnames/index.js","webpack://acf-blocks-toolkit/webpack/bootstrap","webpack://acf-blocks-toolkit/webpack/runtime/compat get default export","webpack://acf-blocks-toolkit/webpack/runtime/define property getters","webpack://acf-blocks-toolkit/webpack/runtime/hasOwnProperty shorthand","webpack://acf-blocks-toolkit/webpack/runtime/make namespace object","webpack://acf-blocks-toolkit/./src/index.js"],"sourcesContent":["module.exports = window[\"React\"];","module.exports = window[\"wp\"][\"blockEditor\"];","module.exports = window[\"wp\"][\"components\"];","module.exports = window[\"wp\"][\"hooks\"];","module.exports = window[\"wp\"][\"i18n\"];","/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = '';\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (arg) {\n\t\t\t\tclasses = appendClass(classes, parseValue(arg));\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction parseValue (arg) {\n\t\tif (typeof arg === 'string' || typeof arg === 'number') {\n\t\t\treturn arg;\n\t\t}\n\n\t\tif (typeof arg !== 'object') {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (Array.isArray(arg)) {\n\t\t\treturn classNames.apply(null, arg);\n\t\t}\n\n\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\treturn arg.toString();\n\t\t}\n\n\t\tvar classes = '';\n\n\t\tfor (var key in arg) {\n\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\tclasses = appendClass(classes, key);\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction appendClass (value, newClass) {\n\t\tif (!newClass) {\n\t\t\treturn value;\n\t\t}\n\t\n\t\tif (value) {\n\t\t\treturn value + ' ' + newClass;\n\t\t}\n\t\n\t\treturn value + newClass;\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","// 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 * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { addFilter } from '@wordpress/hooks';\nimport { InspectorControls } from '@wordpress/block-editor';\nimport {\n\tButton,\n\tPanelBody,\n\tPanelRow,\n\tToggleControl,\n\t__experimentalGrid as Grid, // eslint-disable-line\n} from '@wordpress/components';\n\nimport icons from '../build/icons.json';\n\n/**\n * All available icons.\n * (Order determines presentation order)\n */\nexport const ICONS = icons;\n\n/**\n * Add the attributes needed for button icons.\n *\n * @since 0.1.0\n * @param {Object} settings\n */\nfunction addAttributes( settings ) {\n\tif ( 'core/button' !== settings.name ) {\n\t\treturn settings;\n\t}\n\n\t// Add the block visibility attributes.\n\tconst iconAttributes = {\n\t\ticon: {\n\t\t\ttype: 'string',\n\t\t},\n\t\ticonPositionLeft: {\n\t\t\ttype: 'boolean',\n\t\t\tdefault: false,\n\t\t},\n\t};\n\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\t...iconAttributes,\n\t\t},\n\t};\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'acf-blocks-toolkit/add-attributes',\n\taddAttributes\n);\n\n/**\n * Filter the BlockEdit object and add icon inspector controls to button blocks.\n *\n * @since 0.1.0\n * @param {Object} BlockEdit\n */\nfunction addInspectorControls( BlockEdit ) {\n\treturn ( props ) => {\n\t\tif ( props.name !== 'core/button' ) {\n\t\t\treturn ;\n\t\t}\n\n\t\tconst { attributes, setAttributes } = props;\n\t\tconst { icon: currentIcon, iconPositionLeft } = attributes;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t{ ICONS.map( ( icon, index ) => (\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\tsetAttributes({\n\t\t\t\t\t\t\t\t\t\t\t\t// Allow user to disable icons.\n\t\t\t\t\t\t\t\t\t\t\t\ticon:\n\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentIcon === icon.value\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: icon.value,\n\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t {\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\ticonPositionLeft: ! iconPositionLeft,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t);\n\t};\n}\n\naddFilter(\n\t'editor.BlockEdit',\n\t'acf-blocks-toolkit/add-inspector-controls',\n\taddInspectorControls\n);\n\n/**\n * Add icon and position classes in the Editor.\n *\n * @since 0.1.0\n * @param {Object} BlockListBlock\n */\nfunction addClasses( BlockListBlock ) {\n\treturn ( props ) => {\n\t\tconst { name, attributes } = props;\n\n\t\tif ( 'core/button' !== name || ! attributes?.icon ) {\n\t\t\treturn ;\n\t\t}\n\n\t\tconst classes = classnames( props?.className, {\n\t\t\t[ `has-icon__${ attributes?.icon }` ]: attributes?.icon,\n\t\t\t'has-icon-position__left': attributes?.iconPositionLeft,\n\t\t} );\n\n\t\treturn ;\n\t};\n}\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'acf-blocks-toolkit/add-classes',\n\taddClasses\n);\n"],"names":["classnames","__","addFilter","InspectorControls","Button","PanelBody","PanelRow","ToggleControl","__experimentalGrid","Grid","icons","ICONS","addAttributes","settings","name","iconAttributes","icon","type","iconPositionLeft","default","attributes","addInspectorControls","BlockEdit","props","createElement","setAttributes","currentIcon","Fragment","title","className","initialOpen","columns","gap","map","index","_icon$icon","key","label","isPressed","value","onClick","dangerouslySetInnerHTML","__html","checked","onChange","addClasses","BlockListBlock","classes"],"sourceRoot":""} \ No newline at end of file diff --git a/wp-content/plugins/acf-blocks-toolkit/build/style.asset.php b/wp-content/plugins/acf-blocks-toolkit/build/style.asset.php index c6212768..38823eee 100644 --- a/wp-content/plugins/acf-blocks-toolkit/build/style.asset.php +++ b/wp-content/plugins/acf-blocks-toolkit/build/style.asset.php @@ -1 +1 @@ - array(), 'version' => '93c9fe6185f9e6d0fdaa'); + array(), 'version' => '593029f68ba74678b270'); diff --git a/wp-content/plugins/acf-blocks-toolkit/build/style.css b/wp-content/plugins/acf-blocks-toolkit/build/style.css index 9bb30912..a90bacf1 100644 --- a/wp-content/plugins/acf-blocks-toolkit/build/style.css +++ b/wp-content/plugins/acf-blocks-toolkit/build/style.css @@ -1,19 +1 @@ -/*!***************************************************************************************************************************************************************************************************************************************!*\ - !*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].use[2]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[4].use[3]!./src/index.scss ***! - \***************************************************************************************************************************************************************************************************************************************/ -.wp-block-button[class*=has-icon__] .wp-block-button__link { - display: flex; - gap: 0.5em; - align-items: center; -} -.wp-block-button[class*=has-icon__] .wp-block-button__link span { - line-height: 0; -} -.wp-block-button[class*=has-icon__] .wp-block-button__link svg { - color: currentColor; - fill: currentColor; - height: 0.7em; - width: 1em; -} - -/*# sourceMappingURL=style.css.map*/ \ No newline at end of file +.wp-block-button[class*=has-icon__] .wp-block-button__link{align-items:center;display:flex;gap:.5em}.wp-block-button[class*=has-icon__] .wp-block-button__link span{line-height:0}.wp-block-button[class*=has-icon__] .wp-block-button__link svg{color:currentColor;fill:currentColor;height:.7em;width:1em} diff --git a/wp-content/plugins/acf-blocks-toolkit/build/style.css.map b/wp-content/plugins/acf-blocks-toolkit/build/style.css.map deleted file mode 100644 index 894ffdc0..00000000 --- a/wp-content/plugins/acf-blocks-toolkit/build/style.css.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"style.css","mappings":";;;AACC;EACC;EACA;EACA;AAAF;AAEE;EACC;AAAH;AAGE;EACC;EACA;EACA;EACA;AADH,C","sources":["webpack://acf-blocks-toolkit/./src/index.scss"],"sourcesContent":[".wp-block-button[class*=has-icon__] {\n\t.wp-block-button__link {\n\t\tdisplay: flex;\n\t\tgap: 0.5em;\n\t\talign-items: center;\n\n\t\tspan {\n\t\t\tline-height: 0;\n\t\t}\n\n\t\tsvg {\n\t\t\tcolor: currentColor;\n\t\t\tfill: currentColor;\n\t\t\theight: 0.7em;\n\t\t\twidth: 1em;\n\t\t}\n\t}\n}\n"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/wp-content/plugins/acf-blocks-toolkit/includes/button-icons.php b/wp-content/plugins/acf-blocks-toolkit/includes/button-icons.php index 40f6816f..3e887865 100644 --- a/wp-content/plugins/acf-blocks-toolkit/includes/button-icons.php +++ b/wp-content/plugins/acf-blocks-toolkit/includes/button-icons.php @@ -16,29 +16,39 @@ add_action( 'enqueue_block_editor_assets', function () { - $asset_file = include ACFBT_PLUGIN_PATH . '/build/index.asset.php'; + $asset_file = include ACFBT_PLUGIN_PATH . 'build/index.asset.php'; - wp_enqueue_script( + wp_register_script( 'acfbt-editor-scripts', - ACFBT_PLUGIN_URL . '/build/index.js', + ACFBT_PLUGIN_URL . 'build/index.js', $asset_file['dependencies'], $asset_file['version'] ); + wp_localize_script( + 'acfbt-editor-scripts', + 'acfbtIcons', + [ + 'iconsJson' => acfbt_get_icons(), + ] + ); + + wp_enqueue_script( 'acfbt-editor-scripts' ); + wp_set_script_translations( 'acfbt-editor-scripts', 'acf-blocks-toolkit', - ACFBT_PLUGIN_URL . '/languages' + ACFBT_PLUGIN_URL . 'languages' ); wp_enqueue_style( 'acfbt-editor-styles', - ACFBT_PLUGIN_URL . '/build/editor.css' + ACFBT_PLUGIN_URL . 'build/editor.css' ); wp_add_inline_style( 'acfbt-editor-styles', - acfbt_button_icons_css() + acfbt_button_icons_editor_css() ); } ); @@ -68,22 +78,29 @@ function () { * * @return string */ -function acfbt_button_icons_css(): string { +function acfbt_button_icons_editor_css(): string { $icons = acfbt_get_icons(); $css = ''; - foreach ( $icons as $slug => $icon ) { + foreach ( $icons as $icon ) { + $slug = $icon['value']; $content = 'data:image/svg+xml;utf8,' . rawurlencode( $icon['icon'] ); + $css .= ".wp-block-button.has-icon__{$slug} .wp-block-button__link::after,"; $css .= ".wp-block-button.has-icon__{$slug} .wp-block-button__link::before {"; $css .= 'height: 0.7em;'; $css .= 'width: 1em;'; $css .= "mask-image: url( $content );"; $css .= "-webkit-mask-image: url( $content );"; - $css .= '}'; + $css .= '}' . PHP_EOL; } - return $css; + // Manually adjust a few of the icons + $css .= '.button-icon-picker__button.button-icon-picker__icon-chevron-left-small span svg,.button-icon-picker__button.button-icon-picker__icon-chevron-right-small span svg, + .button-icon-picker__button.button-icon-picker__icon-external-arrow span svg {max-height: 60%}'; + $css .= '.button-icon-picker__button.button-icon-picker__icon-previous span svg,.button-icon-picker__button.button-icon-picker__icon-next span svg {max-height: 80%}'; + + return apply_filters( 'acfbt_button_icons_editor_css', $css ); } /** @@ -96,29 +113,28 @@ function ( string $block_content, array $block ): string { return $block_content; } - $icon = $block['attrs']['icon']; - $position_left = $block['attrs']['iconPositionLeft'] ?? false; - - // All available icon SVGs. - $icons = acfbt_get_icons(); + $icon = acfbt_get_icon( $block['attrs']['icon'] ); - // Make sure the selected icon is in the array, otherwise bail. - if ( ! array_key_exists( $icon, $icons ) ) { + // Make sure the selected icon exists, otherwise bail. + if ( empty( $icon ) ) { return $block_content; } + $position_left = $block['attrs']['iconPositionLeft'] ?? false; + // Append the icon class to the block. $p = new WP_HTML_Tag_Processor( $block_content ); if ( $p->next_tag() ) { - $p->add_class( 'has-icon__' . $icon ); + $p->add_class( 'has-icon__' . $icon['value'] ); } $block_content = $p->get_updated_html(); + $block_content = str_replace( '$', '\$', $block_content ); $pattern = '/(]*>)(.*?)(<\/a>)/i'; $markup = sprintf( '', - esc_attr( $icon ), - $icons[ $icon ]['icon'] + esc_attr( $icon['value'] ), + $icon['icon'] ); // Add the SVG icon either to the left of right of the button text. @@ -133,9 +149,16 @@ function ( string $block_content, array $block ): string { /** * Get all available icons. * + * @param bool $from_file + * * @return array */ -function acfbt_get_icons(): array { +function acfbt_get_icons( bool $from_file = true ): array { + if ( $from_file ) { + $path = acfbt_get_icons_file_path(); + return file_exists( $path ) ? json_decode( file_get_contents( $path ), true ) : []; + } + /** * Filter the available button icons. * @@ -228,20 +251,39 @@ function acfbt_get_icons(): array { ); } +/** + * Get an icon + * + * @param string $slug + * + * @return array + */ +function acfbt_get_icon( string $slug ): array { + $icons = acfbt_get_icons(); + + foreach ( $icons as $icon ) { + if ( $slug === $icon['value'] ) { + return $icon; + } + } + + return []; +} + /** * Generate the Icons JSON file. * * @return void */ function acfbt_generate_json(): void { - $icons = acfbt_get_icons(); + $icons = acfbt_get_icons( false ); $checksum = md5( json_encode( $icons ) ); if ( $checksum === get_transient( ACFBT_ICONS_CHECKSUM ) ) { return; } - $path = ACFBT_PLUGIN_PATH . '/build/icons.json'; + $path = acfbt_get_icons_file_path( true ); $json = []; foreach ( $icons as $slug => $icon ) { @@ -252,11 +294,41 @@ function acfbt_generate_json(): void { ]; } - file_put_contents( $path, json_encode( $json, JSON_PRETTY_PRINT ) ); + if ( ! is_dir( dirname( $path ) ) ) { + wp_mkdir_p( dirname( $path ) ); + } - set_transient( ACFBT_ICONS_CHECKSUM, $checksum ); + if ( file_put_contents( $path, json_encode( $json, JSON_PRETTY_PRINT ) ) ) { + set_transient( ACFBT_ICONS_CHECKSUM, $checksum ); + } } add_action( 'init', 'acfbt_generate_json' ); +/** + * Get path to the icons JSON file. + * + * @param bool $write_file + * + * @return string + */ +function acfbt_get_icons_file_path( bool $write_file = false ): string { + $uploads_dir = wp_get_upload_dir(); + $custom_icons = $uploads_dir['basedir'] . '/acf-blocks-toolkit/icons.json'; + + if ( $write_file ) { + return $custom_icons; + } + + $theme_icons = get_stylesheet_directory() . '/acf-blocks-toolkit/icons.json'; + if ( file_exists( $theme_icons ) ) { + return $theme_icons; + } + + if ( file_exists( $custom_icons ) ) { + return $custom_icons; + } + + return ACFBT_PLUGIN_PATH . 'assets/icons.json'; +} diff --git a/wp-content/plugins/acf-blocks-toolkit/src/index.js b/wp-content/plugins/acf-blocks-toolkit/src/index.js index 91e505d4..35a46eb7 100644 --- a/wp-content/plugins/acf-blocks-toolkit/src/index.js +++ b/wp-content/plugins/acf-blocks-toolkit/src/index.js @@ -1,3 +1,5 @@ +/** global acfbtIcons */ + /** * External dependencies */ @@ -17,7 +19,7 @@ import { __experimentalGrid as Grid, // eslint-disable-line } from '@wordpress/components'; -import icons from '../build/icons.json'; +const icons = acfbtIcons.iconsJson; /** * All available icons. @@ -93,7 +95,7 @@ function addInspectorControls(BlockEdit) { key={index} label={icon?.label} isPressed={currentIcon === icon.value} - className="button-icon-picker__button" + className={"button-icon-picker__button button-icon-picker__icon-" + icon.value } onClick={() => setAttributes({ // Allow user to disable icons.