Initial commit to github
This commit is contained in:
27
views/blocks/grid-cell/block.json
Normal file
27
views/blocks/grid-cell/block.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "acf/grid-cell",
|
||||
"title": "Grid Cell (VDI)",
|
||||
"description": "Custom grid cell block.",
|
||||
"style": [
|
||||
"file:./grid-cell.css"
|
||||
],
|
||||
"category": "vdi-block",
|
||||
"icon": "grid-view",
|
||||
"keywords": [
|
||||
"grid"
|
||||
],
|
||||
"acf": {
|
||||
"mode": "preview",
|
||||
"renderTemplate": "grid-cell.php"
|
||||
},
|
||||
"supports": {
|
||||
"align": false,
|
||||
"anchor": false,
|
||||
"color": true,
|
||||
"html": false,
|
||||
"jsx": true,
|
||||
"mode": true,
|
||||
"multiple": true
|
||||
},
|
||||
"parent": [ "acf/grid" ]
|
||||
}
|
||||
0
views/blocks/grid-cell/grid-cell.css
Normal file
0
views/blocks/grid-cell/grid-cell.css
Normal file
48
views/blocks/grid-cell/grid-cell.php
Normal file
48
views/blocks/grid-cell/grid-cell.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* Block Name: Grid Cell
|
||||
*
|
||||
* This is the template that displays the Grid Cell block.
|
||||
*
|
||||
* @package BasicWP
|
||||
*/
|
||||
|
||||
namespace BasicWP;
|
||||
|
||||
// Initialize variables
|
||||
$className = ! empty( $block['className'] ) ? $block['className'] : '';
|
||||
|
||||
$span = get_field( 'col_span' );
|
||||
$spanBPs = get_field( 'col_span_breakpoints' );
|
||||
|
||||
$className .= $className . ' grid-cell px-4 py-2';
|
||||
|
||||
$gridClasses = '';
|
||||
|
||||
// Add column span classes
|
||||
if ( $span && $span !== 'auto' ) {
|
||||
$gridClasses .= ' col-span-' . $span;
|
||||
}
|
||||
|
||||
// Add breakpoint-specific column span classes
|
||||
if ( $spanBPs ) {
|
||||
foreach ( $spanBPs as $bp ) {
|
||||
$gridClasses .= ' ' . $bp . ':col-span-' . get_field( 'col_span_' . $bp );
|
||||
}
|
||||
}
|
||||
|
||||
// Combine all classes
|
||||
$className .= ' ' . trim( $gridClasses );
|
||||
|
||||
if ( ! $is_preview ) {
|
||||
$wrapper = get_block_wrapper_attributes(
|
||||
array( 'class' => trim( $className ) )
|
||||
);
|
||||
} else {
|
||||
$wrapper = '';
|
||||
}
|
||||
?>
|
||||
|
||||
<div <?php echo wp_kses_post( $wrapper ); ?>>
|
||||
<InnerBlocks className="" />
|
||||
</div>
|
||||
Reference in New Issue
Block a user