From a09e8afc81920c886563a0c3f70b4a3365ef8ad4 Mon Sep 17 00:00:00 2001 From: Zared Rogers <66061110+ZaredRogers@users.noreply.github.com> Date: Mon, 28 Oct 2024 13:45:22 +0000 Subject: [PATCH] Simplified code by removing unecessary registration --- assets/js/blocks/variations.js | 257 ++++++++++++++++----------------- src/init.php | 7 - 2 files changed, 126 insertions(+), 138 deletions(-) diff --git a/assets/js/blocks/variations.js b/assets/js/blocks/variations.js index 36b67180..1ea1ccc4 100644 --- a/assets/js/blocks/variations.js +++ b/assets/js/blocks/variations.js @@ -1,140 +1,135 @@ -wp.domReady(function () { - wp.blocks.registerBlockVariation('core/group', { - name: 'lsx/itinerary', - title: 'Itinerary', - icon: 'list-view', - attributes: { - metadata: { - name: 'Itinerary', - bindings: { - content: { - source: 'lsx/tour-itinerary' - } - } - }, - align: 'wide', - layout: { - type: 'constrained' - } - }, - innerBlocks: [ - ['core/paragraph', { - placeholder: 'Insert your Itinerary pattern here.', - align: 'center' - }] - ], - isDefault: false - }); +wp.domReady(() => { + wp.blocks.registerBlockVariation('core/group', { + name: 'lsx/itinerary', + title: 'Itinerary', + icon: 'list-view', + attributes: { + metadata: { + name: 'Itinerary', + bindings: { + content: { + source: 'lsx/tour-itinerary' + } + } + }, + align: 'wide', + layout: { + type: 'constrained' + } + }, + innerBlocks: [ + ['core/paragraph', { + placeholder: 'Insert your Itinerary pattern here.', + align: 'center' + }] + ], + isDefault: false + }); - wp.blocks.registerBlockVariation('core/group', { - name: 'lsx/accommodation-units', - title: 'Units', - icon: 'admin-multisite', - attributes: { - metadata: { - name: 'Units', - bindings: { - content: { - source: 'lsx/accommodation-units' - } - } - }, - align: 'wide', - layout: { - type: 'constrained' - } - }, - innerBlocks: [ - ['core/paragraph', { - placeholder: 'Insert your Room pattern here.', - align: 'center' - }] - ], - isDefault: false - }); + wp.blocks.registerBlockVariation('core/group', { + name: 'lsx/accommodation-units', + title: 'Units', + icon : 'admin-multisite', + attributes: { + metadata: { + name: 'Units', + bindings: { + content: { + source: 'lsx/accommodation-units' + } + } + }, + align: 'wide', + layout: { + type: 'constrained' + } + }, + innerBlocks: [ + ['core/paragraph', { + placeholder: 'Insert your Room pattern here.', + align: 'center' + }] + ], + isDefault: false + }); - wp.blocks.egisterBlockVariation('core/gallery', { - name: 'lsx/gallery', - title: 'TO Gallery', - icon: 'admin-multisite', - attributes: { - metadata: { - name: 'TO Gallery', - bindings: { - content: { - source: 'lsx/gallery' - } - } - }, - linkTo: 'none', - sizeSlug: 'thumbnail' - }, - innerBlocks: [ - ['core/image', { - href: 'https://tour-operator.lsx.design/wp-content/plugins/tour-operator/assets/img/placeholders/placeholder-general-350x350.jpg' - }], - ['core/image', { - href: 'https://tour-operator.lsx.design/wp-content/plugins/tour-operator/assets/img/placeholders/placeholder-general-350x350.jpg' - }], - ['core/image', { - href: 'https://tour-operator.lsx.design/wp-content/plugins/tour-operator/assets/img/placeholders/placeholder-general-350x350.jpg' - }] - ], - isDefault: false - }); + wp.blocks.registerBlockVariation('core/gallery', { + name: 'lsx/gallery', + title: 'TO Gallery', + icon : 'admin-multisite', + attributes: { + metadata: { + name: 'TO Gallery', + bindings: { + content: { + source: 'lsx/gallery' + } + } + }, + linkTo: 'none', + sizeSlug: 'thumbnail' + }, + innerBlocks: [ + ['core/image', { + href: 'https://tour-operator.lsx.design/wp-content/plugins/tour-operator/assets/img/placeholders/placeholder-general-350x350.jpg' + }], + ['core/image', { + href: 'https://tour-operator.lsx.design/wp-content/plugins/tour-operator/assets/img/placeholders/placeholder-general-350x350.jpg' + }], + ['core/image', { + href: 'https://tour-operator.lsx.design/wp-content/plugins/tour-operator/assets/img/placeholders/placeholder-general-350x350.jpg' + }] + ], + isDefault: false + }); - wp.blocks.registerBlockVariation('core/group', { - name: 'lsx/price', - title: 'Price', - icon: 'bank', - attributes: { - metadata: { - name: 'Price', - }, - align: 'wide', + wp.blocks.registerBlockVariation('core/group', { + name: 'lsx/price', + title: 'Price', + icon : 'bank', + attributes: { + metadata: { + name: 'Price', + }, + align: 'wide', layout: { type: 'flex', flexWrap: 'nowrap' }, - className: 'lsx-price-wrapper' - }, - innerBlocks: [ - ['core/paragraph', { - padding: { - top: '2px', - bottom: '2px' - }, - typography: { - fontSize: 'x-small' - }, - content: 'From:', - className: 'has-x-small-font-size', - }], - ['core/paragraph', { - metadata: { - bindings: { - content: { - source: 'lsx/post-meta', - args: { key: 'price' } - } - } - }, - className: 'has-primary-color has-text-color has-link-color', - color: { - link: 'primary-700', - text: 'primary-700' - } - }] - ], - isDefault: false - }); + className: 'lsx-price-wrapper' + }, + innerBlocks: [ + [ 'core/paragraph', { + padding: { + top: '2px', + bottom: '2px' + }, + typography: { + fontSize: 'x-small' + }, + content : 'From:', + className: 'has-x-small-font-size', + } + ], + [ 'core/paragraph', { + metadata: { + bindings: { + content: { + source: 'lsx/post-meta', + args: { key: 'price' } + } + } + }, + className: 'has-primary-color has-text-color has-link-color', + color: { + link: 'primary-700', + text: 'primary-700' + } + } + ] + ], + isDefault: false + }); + - wp.blocks.registerBlockVariation('core/cover', { - name: 'cover-with-link', - title: 'Cover with Link', - description: 'A Cover block that can be linked.', - attributes: { - }, - isDefault: false, - }); }); diff --git a/src/init.php b/src/init.php index e5757501..b6f8bd64 100644 --- a/src/init.php +++ b/src/init.php @@ -93,13 +93,6 @@ function blocks_loader() { * Enqueues linked cover block. */ function lsx_enqueue_block_assets() { - // Enqueue block editor script for the block variations - wp_enqueue_script( - 'lsx-block-variations', - plugins_url( 'assets/js/blocks/variations.js', dirname( __FILE__ ) ), - array( 'wp-blocks', 'wp-dom-ready', 'wp-hooks', 'wp-compose', 'wp-element', 'wp-block-editor', 'wp-components' ), - filemtime( plugin_dir_path( dirname( __FILE__ ) ) . 'assets/js/blocks/variations.js' ) - ); // Enqueue linked-cover.js wp_enqueue_script(