Skip to content

Commit

Permalink
Simplified code by removing unecessary registration
Browse files Browse the repository at this point in the history
  • Loading branch information
ZaredRogers committed Oct 28, 2024
1 parent e353576 commit a09e8af
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 138 deletions.
257 changes: 126 additions & 131 deletions assets/js/blocks/variations.js
Original file line number Diff line number Diff line change
@@ -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: '<strong>From:</strong>',
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 : '<strong>From:</strong>',
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,
});
});
7 changes: 0 additions & 7 deletions src/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,6 @@ function blocks_loader() {
* Enqueues linked cover block.
*/
function lsx_enqueue_block_assets() {

Check warning on line 95 in src/init.php

View check run for this annotation

codefactor.io / CodeFactor

src/init.php#L95

Expected 2 blank lines before function; 1 found. (Squiz.WhiteSpace.FunctionSpacing-[fixable])

Check warning on line 95 in src/init.php

View check run for this annotation

codefactor.io / CodeFactor

src/init.php#L95

Expected 0 blank lines after opening function brace; 1 found. (Squiz.WhiteSpace.FunctionOpeningBraceSpace-[fixable])
// 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

Check warning on line 97 in src/init.php

View check run for this annotation

codefactor.io / CodeFactor

src/init.php#L97

Inline comments must end in full-stops, exclamation marks, or question marks. (Squiz.Commenting.InlineComment)
wp_enqueue_script(

Check notice on line 98 in src/init.php

View check run for this annotation

codefactor.io / CodeFactor

src/init.php#L98

In footer ($in_footer) is not set explicitly wp_enqueue_script; It is recommended to load scripts in the footer. Please set this value to `true` to load it in the footer, or explicitly `false` if it should be loaded in the header. (WordPress.WP.EnqueuedResourceParameters)
Expand Down

0 comments on commit a09e8af

Please sign in to comment.