Changeset 3100331
- Timestamp:
- 06/10/2024 07:08:59 AM (21 months ago)
- Location:
- auto-submenu
- Files:
-
- 16 added
- 5 edited
-
tags/1.0.1 (added)
-
tags/1.0.1/auto-submenu.php (added)
-
tags/1.0.1/readme.txt (added)
-
tags/1.0.1/screenshot-1.png (added)
-
tags/1.0.1/screenshot-2.png (added)
-
tags/1.0.1/screenshot-3.png (added)
-
tags/1.0.1/src (added)
-
tags/1.0.1/src/asm-functions.php (added)
-
tags/1.0.1/src/asm.css (added)
-
tags/1.0.1/src/blocks (added)
-
tags/1.0.1/src/blocks/asm_core_navigation_link (added)
-
tags/1.0.1/src/blocks/asm_core_navigation_link/build (added)
-
tags/1.0.1/src/blocks/asm_core_navigation_link/build/block.json (added)
-
tags/1.0.1/src/blocks/asm_core_navigation_link/build/index.asset.php (added)
-
tags/1.0.1/src/blocks/asm_core_navigation_link/build/index.js (added)
-
tags/1.0.1/src/blocks/asm_core_navigation_link/build/index.js.map (added)
-
trunk/auto-submenu.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/src/blocks/asm_core_navigation_link/build/index.asset.php (modified) (1 diff)
-
trunk/src/blocks/asm_core_navigation_link/build/index.js (modified) (1 diff)
-
trunk/src/blocks/asm_core_navigation_link/build/index.js.map (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
auto-submenu/trunk/auto-submenu.php
r3058332 r3100331 4 4 * Plugin URI: https://wordpress.telodelic.nl/auto-submenu 5 5 * Description: Dynamic menus: Add a page to your menu and then let WordPress automatically add the child pages. 6 * Version: 1.0. 06 * Version: 1.0.1 7 7 * Author: Diana van de Laarschot 8 8 * Author URI: https://wordpress.telodelic.nl … … 248 248 // Loop through the menus to find page parent 249 249 foreach ($auto_add as $menu_id) { 250 $menu_items = wp_get_nav_menu_items($menu_id, array('post_status' => 'publish,draft')); 251 if (!is_array($menu_items)) { 252 continue; 253 } 254 250 255 // Assumption of current implementation: Top level pages are added to the menu only once. 251 256 $menu_child = NULL; 252 257 $menu_parent = NULL; 253 $menu_items = wp_get_nav_menu_items($menu_id, array('post_status' => 'publish,draft'));254 if (!is_array($menu_items)) {255 continue;256 }257 258 258 259 // Find the child menu item and the parent menu item for this child page 259 260 foreach ($menu_items as $menu_item) { 260 // Item already in menu?261 261 if ($menu_item->object_id == $post->ID) { 262 262 $menu_child = $menu_item; 263 // In menu under the correct parent?264 if ($menu_item->parent_id == $post->post_parent) {265 // Already in the menu under correct parent, skip.266 continue 2;267 }268 263 } 269 264 if ($menu_item->object_id == $post->post_parent) { … … 272 267 } 273 268 274 if ($menu_parent) { 275 if ($menu_child) { 276 // Update the existing child menu item (even if it wasn't moved. Menu order might have changed) 277 wp_update_nav_menu_item( 278 $menu_id, 279 $menu_child->db_id, 280 array( 281 'menu-item-position' => $post->menu_order, 282 'menu-item-object-id' => $post->ID, 283 'menu-item-object' => $post->post_type, 284 'menu-item-parent-id' => $menu_parent->ID, 285 'menu-item-type' => 'post_type', 286 'menu-item-status' => 'publish' 287 ) 288 ); 289 } else { 290 // No menu item yet. Add new menu item for child page 291 wp_update_nav_menu_item( 292 $menu_id, 293 0, // New 294 array( 295 'menu-item-object-id' => $post->ID, 296 'menu-item-object' => $post->post_type, 297 'menu-item-parent-id' => $menu_parent->ID, 298 'menu-item-type' => 'post_type', 299 'menu-item-status' => 'publish' 300 ) 301 ); 302 } 269 // Parent not in menu, abort. 270 if ( !$menu_parent ){ 271 break; 272 } 273 274 if ( $menu_child ) { 275 // Is child menu item already under correct parent? (If so, do nothing) 276 if ( $menu_child->menu_item_parent != $menu_parent->ID ) { 277 // Update the existing child menu item, move to correct parent 278 wp_update_nav_menu_item( $menu_id, $menu_child->db_id, array( 279 'menu-item-position' => $post->menu_order, 280 'menu-item-object-id' => $post->ID, 281 'menu-item-object' => $post->post_type, 282 'menu-item-parent-id' => $menu_parent->ID, 283 'menu-item-type' => 'post_type', 284 'menu-item-status' => 'publish' 285 ) ); 286 } 287 } else { 288 // No menu item yet. Add new menu item for child page 289 wp_update_nav_menu_item( $menu_id, 0, array( 290 'menu-item-position' => $post->menu_order, 291 'menu-item-object-id' => $post->ID, 292 'menu-item-object' => $post->post_type, 293 'menu-item-parent-id' => $menu_parent->ID, 294 'menu-item-type' => 'post_type', 295 'menu-item-status' => 'publish' 296 ) ); 303 297 } 304 298 } -
auto-submenu/trunk/readme.txt
r3058361 r3100331 6 6 Tested up to: 6.5 7 7 Requires PHP: 7.4 8 Stable tag: 1.0.08 Stable Tag: 1.0.1 9 9 10 10 Dynamic menus: Add a page to your menu and then let WordPress automatically add the child pages. … … 65 65 == Changelog == 66 66 67 = 1.0.1 = 68 69 Bugfix: Plugin moved page to the bottom of the submenu. 70 67 71 = 1.0.0 = 68 72 … … 71 75 72 76 = 0.3.1 = 77 73 78 * Confirmed compatibility with WordPress 6.4 74 79 -
auto-submenu/trunk/src/blocks/asm_core_navigation_link/build/index.asset.php
r3058332 r3100331 1 <?php return array('dependencies' => array('react', 'wp-components', 'wp-hooks'), 'version' => ' 79b72464927ece3b1842');1 <?php return array('dependencies' => array('react', 'wp-components', 'wp-hooks'), 'version' => '6f2510038351594475c6'); -
auto-submenu/trunk/src/blocks/asm_core_navigation_link/build/index.js
r3058332 r3100331 158 158 title: "Auto Submenu", 159 159 initialOpen: false 160 }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.BaseControl, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.Notice, { 161 isDismissible: false, 162 status: "warning" 163 }, wp.i18n.__('Experimental, please report any issues you may encounter.', 'auto-submenu'))), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.BaseControl, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.ToggleControl, { 160 }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.BaseControl, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.ToggleControl, { 164 161 id: "asm_unfold", 165 162 key: "asm_unfold", -
auto-submenu/trunk/src/blocks/asm_core_navigation_link/build/index.js.map
r3058332 r3100331 1 {"version":3,"file":"index.js","mappings":";;;;;;;;;;AAAA;;;;;;;;;;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;;;;;;;;;;;;;;;;;;ACN6C;AAC0E;AAEvH,MAAM;EAAEO;AAA2B,CAAC,GAAGC,EAAE,CAACC,OAAO;AACjD,MAAM;EAAEC;AAAkB,CAAC,GAAGF,EAAE,CAACG,WAAW;AAC5C,MAAM;EAAEC,SAAS;EAAEC;AAAS,CAAC,GAAGL,EAAE,CAACM,UAAU;AAE7C,SAASC,qBAAqBA,CAACC,QAAQ,EAAE;EACxC,IAAI,OAAOA,QAAQ,CAACC,UAAU,KAAK,WAAW,EAAE;IAC/C,IAAID,QAAQ,CAACE,IAAI,IAAI,sBAAsB,EAAE;MAC5CF,QAAQ,CAACC,UAAU,GAAGE,MAAM,CAACC,MAAM,CAACJ,QAAQ,CAACC,UAAU,EAAE;QACxD,YAAY,EAAE;UACbI,IAAI,EAAE;QACP,CAAC;QACD,gBAAgB,EAAE;UACjBA,IAAI,EAAE;QACP,CAAC;QACD,aAAa,EAAE;UACdA,IAAI,EAAE;QACP,CA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JQ,KAAK,GAAAlB,sBAAA,GAAEF,KAAK,CAACP,UAAU,CAACiC,eAAe,cAAAxB,sBAAA,cAAAA,sBAAA,GAAI,aAAc;MACzDe,QAAQ,EAAGC,QAAQ,IAAKlB,KAAK,CAACmB,aAAa,CAAC;QAAEO,eAAe,EAAER;MAAS,CAAC;IAAE,CAC3E,CACW,CAAC,EACdf,oDAAA,CAAC1B,8DAAW,QACVO,EAAE,CAAC2B,IAAI,CAACC,EAAE,CAAC,gGAAgG,EAAE,cAAc,CAChH,CACZ,CAAC,GACD,IACO,CACO,CAAC,GAClB,IACF,CAAC;EAEL,CAAC;AACF,CAAC,EAAE,sBAAsB,CAAC;AAE1B5B,EAAE,CAAC2C,KAAK,CAACnD,SAAS,CACjB,kBAAkB,EAClB,YAAY,EACZsB,iBACD,CAAC,C","sources":["webpack://asm_core_navigation_link/external window \"React\"","webpack://asm_core_navigation_link/external window [\"wp\",\"components\"]","webpack://asm_core_navigation_link/external window [\"wp\",\"hooks\"]","webpack://asm_core_navigation_link/webpack/bootstrap","webpack://asm_core_navigation_link/webpack/runtime/compat get default export","webpack://asm_core_navigation_link/webpack/runtime/define property getters","webpack://asm_core_navigation_link/webpack/runtime/hasOwnProperty shorthand","webpack://asm_core_navigation_link/webpack/runtime/make namespace object","webpack://asm_core_navigation_link/./src/index.jsx"],"sourcesContent":["module.exports = window[\"React\"];","module.exports = window[\"wp\"][\"components\"];","module.exports = window[\"wp\"][\"hooks\"];","// 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};","import { addFilter } from '@wordpress/hooks';\nimport { BaseControl, Notice, SelectControl, ToggleControl, TextControl, TextareaControl } from '@wordpress/components'\n\nconst { createHigherOrderComponent } = wp.compose;\nconst { InspectorControls } = wp.blockEditor;\nconst { PanelBody, PanelRow } = wp.components;\n\nfunction addASMUnfoldAttribute(settings) {\n\tif (typeof settings.attributes !== 'undefined') {\n\t\tif (settings.name == 'core/navigation-link') {\n\t\t\tsettings.attributes = Object.assign(settings.attributes, {\n\t\t\t\t'asm_unfold': {\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t},\n\t\t\t\t'asm_item_depth': {\n\t\t\t\t\ttype: 'integer',\n\t\t\t\t},\n\t\t\t\t'asm_orderby': {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t},\n\t\t\t\t'asm_item_titles': {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\treturn settings;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'asm/unfold',\n\taddASMUnfoldAttribute\n);\n\nconst asmUnfoldControls = createHigherOrderComponent((BlockEdit) => {\n\treturn (props) => {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit key=\"edit\" {...props} />\n\t\t\t\t{props.attributes.kind === 'post-type' && props.attributes.type === 'page'\n\t\t\t\t\t? <InspectorControls>\n\t\t\t\t\t\t<PanelBody title=\"Auto Submenu\" initialOpen={false}>\n\t\t\t\t\t\t\t<BaseControl>\n\t\t\t\t\t\t\t\t<Notice isDismissible={false} status=\"warning\">{wp.i18n.__('Experimental, please report any issues you may encounter.', 'auto-submenu')}</Notice>\n\t\t\t\t\t\t\t</BaseControl>\n\t\t\t\t\t\t\t<BaseControl>\n\t\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t\tid='asm_unfold'\n\t\t\t\t\t\t\t\t\tkey='asm_unfold'\n\t\t\t\t\t\t\t\t\tlabel={wp.i18n.__('Create submenu containing child pages', 'auto-submenu')}\n\t\t\t\t\t\t\t\t\tchecked={!!props.attributes.asm_unfold}\n\t\t\t\t\t\t\t\t\tonChange={(newValue) => props.setAttributes({ asm_unfold: newValue })}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</BaseControl>\n\t\t\t\t\t\t\t{props.attributes.asm_unfold\n\t\t\t\t\t\t\t\t? <>\n\t\t\t\t\t\t\t\t\t<BaseControl>\n\t\t\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\t\t\tlabel={<>\n\t\t\t\t\t\t\t\t\t\t\t\t{wp.i18n.__('Nesting depth', 'auto-submenu')} (max 3)\n\t\t\t\t\t\t\t\t\t\t\t</>}\n\t\t\t\t\t\t\t\t\t\t\tvalue={props.attributes.asm_item_depth > 0 ? props.attributes.asm_item_depth : 3}\n\t\t\t\t\t\t\t\t\t\t\tonChange={(newValue) => props.setAttributes({ asm_item_depth: isNaN(+newValue) || (+newValue) > 3 ? 3 : +newValue })}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</BaseControl>\n\t\t\t\t\t\t\t\t\t<BaseControl>\n\t\t\t\t\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\t\t\t\t\tdisabled\n\t\t\t\t\t\t\t\t\t\t\tlabel={wp.i18n.__('Order by', 'auto-submenu')}\n\t\t\t\t\t\t\t\t\t\t\tvalue={props.attributes.asm_orderby ?? 'none'}\n\t\t\t\t\t\t\t\t\t\t\toptions={[\n\t\t\t\t\t\t\t\t\t\t\t\t{ label: wp.i18n.__('Menu Order', 'auto-submenu'), value: 'menu_order' }\n\t\t\t\t\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t\t\t\t\t\tonChange={(newValue) => props.setAttributes({ asm_orderby: newValue })}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</BaseControl>\n\t\t\t\t\t\t\t\t\t<BaseControl>\n\t\t\t\t\t\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\t\t\t\t\t\tlabel={<>\n\t\t\t\t\t\t\t\t\t\t\t\t{wp.i18n.__('Navigation Label', 'auto-submenu')}\n\t\t\t\t\t\t\t\t\t\t\t</>}\n\t\t\t\t\t\t\t\t\t\t\tvalue={props.attributes.asm_item_titles ?? '%post_title'}\n\t\t\t\t\t\t\t\t\t\t\tonChange={(newValue) => props.setAttributes({ asm_item_titles: newValue })}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</BaseControl>\n\t\t\t\t\t\t\t\t\t<BaseControl>\n\t\t\t\t\t\t\t\t\t\t{wp.i18n.__('The navigation label may be customized using wildcards such as %post_title. See documentation.', 'auto-submenu')}\n\t\t\t\t\t\t\t\t\t</BaseControl>\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t: null}\n\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t: null}\n\t\t\t</>\n\t\t);\n\t};\n}, 'withMyPluginControls');\n\nwp.hooks.addFilter(\n\t'editor.BlockEdit',\n\t'asm/unfold',\n\tasmUnfoldControls\n);\n"],"names":["addFilter","BaseControl","Notice","SelectControl","ToggleControl","TextControl","TextareaControl","createHigherOrderComponent","wp","compose","InspectorControls","blockEditor","PanelBody","PanelRow","components","addASMUnfoldAttribute","settings","attributes","name","Object","assign","type","asmUnfoldControls","BlockEdit","props","_props$attributes$asm","_props$attributes$asm2","createElement","Fragment","key","kind","title","initialOpen","isDismissible","status","i18n","__","id","label","checked","asm_unfold","onChange","newValue","setAttributes","value","asm_item_depth","isNaN","disabled","asm_orderby","options","asm_item_titles","hooks"],"sourceRoot":""}1 {"version":3,"file":"index.js","mappings":";;;;;;;;;;AAAA;;;;;;;;;;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;;;;;;;;;;;;;;;;;;ACN6C;AAC0E;AAEvH,MAAM;EAAEO;AAA2B,CAAC,GAAGC,EAAE,CAACC,OAAO;AACjD,MAAM;EAAEC;AAAkB,CAAC,GAAGF,EAAE,CAACG,WAAW;AAC5C,MAAM;EAAEC,SAAS;EAAEC;AAAS,CAAC,GAAGL,EAAE,CAACM,UAAU;AAE7C,SAASC,qBAAqBA,CAACC,QAAQ,EAAE;EACxC,IAAI,OAAOA,QAAQ,CAACC,UAAU,KAAK,WAAW,EAAE;IAC/C,IAAID,QAAQ,CAACE,IAAI,IAAI,sBAAsB,EAAE;MAC5CF,QAAQ,CAACC,UAAU,GAAGE,MAAM,CAACC,MAAM,CAACJ,QAAQ,CAACC,UAAU,EAAE;QACxD,YAAY,EAAE;UACbI,IAA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sBAAA,GAAI,aAAc;MACzDa,QAAQ,EAAGC,QAAQ,IAAKhB,KAAK,CAACiB,aAAa,CAAC;QAAEO,eAAe,EAAER;MAAS,CAAC;IAAE,CAC3E,CACW,CAAC,EACdb,oDAAA,CAAC1B,8DAAW,QACVO,EAAE,CAAC2B,IAAI,CAACC,EAAE,CAAC,gGAAgG,EAAE,cAAc,CAChH,CACZ,CAAC,GACD,IACO,CACO,CAAC,GAClB,IACF,CAAC;EAEL,CAAC;AACF,CAAC,EAAE,sBAAsB,CAAC;AAE1B5B,EAAE,CAACyC,KAAK,CAACjD,SAAS,CACjB,kBAAkB,EAClB,YAAY,EACZsB,iBACD,CAAC,C","sources":["webpack://asm_core_navigation_link/external window \"React\"","webpack://asm_core_navigation_link/external window [\"wp\",\"components\"]","webpack://asm_core_navigation_link/external window [\"wp\",\"hooks\"]","webpack://asm_core_navigation_link/webpack/bootstrap","webpack://asm_core_navigation_link/webpack/runtime/compat get default export","webpack://asm_core_navigation_link/webpack/runtime/define property getters","webpack://asm_core_navigation_link/webpack/runtime/hasOwnProperty shorthand","webpack://asm_core_navigation_link/webpack/runtime/make namespace object","webpack://asm_core_navigation_link/./src/index.jsx"],"sourcesContent":["module.exports = window[\"React\"];","module.exports = window[\"wp\"][\"components\"];","module.exports = window[\"wp\"][\"hooks\"];","// 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};","import { addFilter } from '@wordpress/hooks';\nimport { BaseControl, Notice, SelectControl, ToggleControl, TextControl, TextareaControl } from '@wordpress/components'\n\nconst { createHigherOrderComponent } = wp.compose;\nconst { InspectorControls } = wp.blockEditor;\nconst { PanelBody, PanelRow } = wp.components;\n\nfunction addASMUnfoldAttribute(settings) {\n\tif (typeof settings.attributes !== 'undefined') {\n\t\tif (settings.name == 'core/navigation-link') {\n\t\t\tsettings.attributes = Object.assign(settings.attributes, {\n\t\t\t\t'asm_unfold': {\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t},\n\t\t\t\t'asm_item_depth': {\n\t\t\t\t\ttype: 'integer',\n\t\t\t\t},\n\t\t\t\t'asm_orderby': {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t},\n\t\t\t\t'asm_item_titles': {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\treturn settings;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'asm/unfold',\n\taddASMUnfoldAttribute\n);\n\nconst asmUnfoldControls = createHigherOrderComponent((BlockEdit) => {\n\treturn (props) => {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit key=\"edit\" {...props} />\n\t\t\t\t{props.attributes.kind === 'post-type' && props.attributes.type === 'page'\n\t\t\t\t\t? <InspectorControls>\n\t\t\t\t\t\t<PanelBody title=\"Auto Submenu\" initialOpen={false}>\n\t\t\t\t\t\t\t<BaseControl>\n\t\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t\tid='asm_unfold'\n\t\t\t\t\t\t\t\t\tkey='asm_unfold'\n\t\t\t\t\t\t\t\t\tlabel={wp.i18n.__('Create submenu containing child pages', 'auto-submenu')}\n\t\t\t\t\t\t\t\t\tchecked={!!props.attributes.asm_unfold}\n\t\t\t\t\t\t\t\t\tonChange={(newValue) => props.setAttributes({ asm_unfold: newValue })}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</BaseControl>\n\t\t\t\t\t\t\t{props.attributes.asm_unfold\n\t\t\t\t\t\t\t\t? <>\n\t\t\t\t\t\t\t\t\t<BaseControl>\n\t\t\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\t\t\tlabel={<>\n\t\t\t\t\t\t\t\t\t\t\t\t{wp.i18n.__('Nesting depth', 'auto-submenu')} (max 3)\n\t\t\t\t\t\t\t\t\t\t\t</>}\n\t\t\t\t\t\t\t\t\t\t\tvalue={props.attributes.asm_item_depth > 0 ? props.attributes.asm_item_depth : 3}\n\t\t\t\t\t\t\t\t\t\t\tonChange={(newValue) => props.setAttributes({ asm_item_depth: isNaN(+newValue) || (+newValue) > 3 ? 3 : +newValue })}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</BaseControl>\n\t\t\t\t\t\t\t\t\t<BaseControl>\n\t\t\t\t\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\t\t\t\t\tdisabled\n\t\t\t\t\t\t\t\t\t\t\tlabel={wp.i18n.__('Order by', 'auto-submenu')}\n\t\t\t\t\t\t\t\t\t\t\tvalue={props.attributes.asm_orderby ?? 'none'}\n\t\t\t\t\t\t\t\t\t\t\toptions={[\n\t\t\t\t\t\t\t\t\t\t\t\t{ label: wp.i18n.__('Menu Order', 'auto-submenu'), value: 'menu_order' }\n\t\t\t\t\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t\t\t\t\t\tonChange={(newValue) => props.setAttributes({ asm_orderby: newValue })}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</BaseControl>\n\t\t\t\t\t\t\t\t\t<BaseControl>\n\t\t\t\t\t\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\t\t\t\t\t\tlabel={<>\n\t\t\t\t\t\t\t\t\t\t\t\t{wp.i18n.__('Navigation Label', 'auto-submenu')}\n\t\t\t\t\t\t\t\t\t\t\t</>}\n\t\t\t\t\t\t\t\t\t\t\tvalue={props.attributes.asm_item_titles ?? '%post_title'}\n\t\t\t\t\t\t\t\t\t\t\tonChange={(newValue) => props.setAttributes({ asm_item_titles: newValue })}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</BaseControl>\n\t\t\t\t\t\t\t\t\t<BaseControl>\n\t\t\t\t\t\t\t\t\t\t{wp.i18n.__('The navigation label may be customized using wildcards such as %post_title. See documentation.', 'auto-submenu')}\n\t\t\t\t\t\t\t\t\t</BaseControl>\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t: null}\n\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t: null}\n\t\t\t</>\n\t\t);\n\t};\n}, 'withMyPluginControls');\n\nwp.hooks.addFilter(\n\t'editor.BlockEdit',\n\t'asm/unfold',\n\tasmUnfoldControls\n);\n"],"names":["addFilter","BaseControl","Notice","SelectControl","ToggleControl","TextControl","TextareaControl","createHigherOrderComponent","wp","compose","InspectorControls","blockEditor","PanelBody","PanelRow","components","addASMUnfoldAttribute","settings","attributes","name","Object","assign","type","asmUnfoldControls","BlockEdit","props","_props$attributes$asm","_props$attributes$asm2","createElement","Fragment","key","kind","title","initialOpen","id","label","i18n","__","checked","asm_unfold","onChange","newValue","setAttributes","value","asm_item_depth","isNaN","disabled","asm_orderby","options","asm_item_titles","hooks"],"sourceRoot":""}
Note: See TracChangeset
for help on using the changeset viewer.