← Back
Editing: wc-blocks.js
(()=>{var e={50364:()=>{},38878:()=>{},97575:()=>{}},o={};function t(r){var c=o[r];if(void 0!==c)return c.exports;var i=o[r]={exports:{}};return e[r](i,i.exports,t),i.exports}t.n=e=>{var o=e&&e.__esModule?()=>e.default:()=>e;return t.d(o,{a:o}),o},t.d=(e,o)=>{for(var r in o)t.o(o,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:o[r]})},t.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),(()=>{"use strict";t(50364),t(38878);const e=window.wp.element,o=window.wp.compose,r=window.wp.blocks,c=window.wp.hooks,i=window.ReactJSXRuntime,s=(0,o.createHigherOrderComponent)(o=>{class t extends e.Component{mounted=!1;componentDidMount(){const{block:e,setAttributes:o}=this.props;e.name.startsWith("woocommerce/")&&o(this.getAttributesWithDefaults())}componentDidUpdate(){this.props.block.name.startsWith("woocommerce/")&&!this.mounted&&(this.mounted=!0)}getAttributesWithDefaults(){const e=(0,r.getBlockType)(this.props.block.name);let o=this.props.attributes;return!this.mounted&&this.props.block.name.startsWith("woocommerce/")&&void 0!==e.attributes&&void 0!==e.defaults&&(o=Object.assign({},this.props.attributes||{}),Object.keys(e.attributes).map(t=>(void 0===o[t]&&void 0!==e.defaults[t]&&(o[t]=e.defaults[t]),t))),o}render(){return(0,i.jsx)(o,{...this.props,attributes:this.getAttributesWithDefaults()})}}return t},"withDefaultAttributes");(0,c.addFilter)("editor.BlockListBlock","woocommerce-blocks/block-list-block",s),(0,c.addFilter)("blocks.getBlockAttributes","woocommerce-blocks/get-block-attributes",(e,o)=>(o.name.startsWith("woocommerce/")&&Object.keys(o.attributes).map(t=>(void 0===e[t]&&void 0!==o.defaults&&void 0!==o.defaults[t]&&(e[t]=o.defaults[t]),t)),e));const m=["mini-cart","add-to-cart-with-options"];(0,c.addFilter)("blocks.registerBlockType","woocommerce/hide-incompatible-template-parts",(e,o)=>"core/template-part"===o&&e.variations?{...e,variations:e.variations.map(e=>m.includes(e.attributes?.area??"")?{...e,scope:(e.scope??[]).filter(e=>"inserter"!==e)}:e)}:e);const n=window.wp.domReady;var a=t.n(n);const d=window.wc.wcSettings,p=window.wp.data,w="core/editor",u=["woocommerce/breadcrumbs","woocommerce/catalog-sorting","woocommerce/product-results-count","woocommerce/legacy-template"],l=["woocommerce/breadcrumbs","woocommerce/catalog-sorting","woocommerce/legacy-template","woocommerce/product-results-count","woocommerce/product-reviews","woocommerce/order-confirmation-status","woocommerce/order-confirmation-summary","woocommerce/order-confirmation-totals","woocommerce/order-confirmation-totals-wrapper","woocommerce/order-confirmation-downloads","woocommerce/order-confirmation-downloads-wrapper","woocommerce/order-confirmation-billing-address","woocommerce/order-confirmation-shipping-address","woocommerce/order-confirmation-billing-wrapper","woocommerce/order-confirmation-shipping-wrapper","woocommerce/order-confirmation-additional-information","woocommerce/order-confirmation-additional-fields-wrapper","woocommerce/order-confirmation-additional-fields"],f=["woocommerce/all-reviews","woocommerce/breadcrumbs","woocommerce/cart-link","woocommerce/catalog-sorting","woocommerce/classic-shortcode","woocommerce/customer-account","woocommerce/dropdown","woocommerce/featured-category","woocommerce/featured-product","woocommerce/mini-cart","woocommerce/product-categories","woocommerce/product-results-count","woocommerce/product-search","woocommerce/reviews-by-category","woocommerce/reviews-by-product","woocommerce/product-filters","woocommerce/product-filter-status","woocommerce/product-filter-price","woocommerce/product-filter-price-slider","woocommerce/product-filter-attribute","woocommerce/product-filter-rating","woocommerce/product-filter-active","woocommerce/product-filter-removable-chips","woocommerce/product-filter-clear-button","woocommerce/product-filter-checkbox-list","woocommerce/product-filter-chips","woocommerce/product-filter-taxonomy","woocommerce/active-filters","woocommerce/attribute-filter","woocommerce/filter-wrapper","woocommerce/price-filter","woocommerce/rating-filter","woocommerce/stock-filter","woocommerce/handpicked-products","woocommerce/product-best-sellers","woocommerce/product-new","woocommerce/product-on-sale","woocommerce/product-top-rated","woocommerce/products-by-attribute","woocommerce/product-category","woocommerce/product-tag"],g=()=>{const e=window,o=e.adminpage;return["post-php","post-new-php"].includes(o??"")?"post":["widgets-php","customize-php"].includes(o??"")||"customize"===e.pagenow?"widgets":"other"},b=e=>{(e=>{const o=(0,r.getBlockTypes)().map(({name:e})=>e),t=g();if("post"===t){const t="shop"in d.STORE_PAGES?d.STORE_PAGES.shop?.id:void 0,r=(0,d.getSetting)("currentThemeIsFSETheme",!1)&&!!t&&Number(e)===t;return l.filter(e=>o.includes(e)&&!(r&&u.includes(e)))}return"widgets"===t?o.filter(e=>e.startsWith("woocommerce/")&&!f.includes(e)):[]})(e).forEach(e=>{(0,r.unregisterBlockType)(e)})};a()(()=>{if("post"!==g())return void b();const e=(0,p.subscribe)(()=>{if(!(0,p.select)(w).getCurrentPostId())return;const o=(0,p.select)(w)?.getCurrentPostId()??null;e(),b(o)},w)});const h=window.wp.coreData,k=window.wp.plugins,v=window.wp.preferences,y=()=>{const o=(0,e.useRef)(null),t=(0,p.useSelect)(e=>{const o=e(w).getEditorSettings().defaultRenderingMode,t=e(h.store).getCurrentTheme()?.stylesheet;return e(v.store).get("core","renderingModes")?.[t]?.page??o},[]),{setRenderingMode:r}=(0,p.useDispatch)(w),c=(0,p.useSelect)(e=>{const o=e(w),t="shop"in d.STORE_PAGES?d.STORE_PAGES.shop?.id:void 0,r=e(h.store)?.getCurrentTheme()?.is_block_theme;return r&&!!t&&!!o&&"page"===o.getCurrentPostType()&&Number(o?.getCurrentPostId())===t&&!!o.getEditorSettings().supportsTemplateMode},[]);return(0,e.useEffect)(()=>{c&&(r("template-locked"),o.current=!0),c!==o.current&&(r(t),o.current=!1)},[c,r,t]),null};a()(()=>{(0,p.select)(w)&&(0,k.registerPlugin)("woocommerce-shop-page-rendering-mode",{render:y})}),t(97575)})(),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["wc-blocks"]={}})();
Save File
Cancel