Last active
March 15, 2021 11:05
-
-
Save damiencarbery/00aa77cecebfc3dd7b750eba7ee58ea7 to your computer and use it in GitHub Desktop.
Demo of Genesis Custom Blocks - A simple custom block delivered in a plugin. https://www.damiencarbery.com/2020/09/demo-of-genesis-custom-blocks/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<details class="genesis-custom-block <?php block_field('className'); ?>"> | |
<summary class="item-title"><?php block_field( 'title' ); ?></summary> | |
<div class="item-content"><?php block_field( 'content' ); ?></div> | |
</details> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="genesis-custom-block <?php block_field('className'); ?>"> | |
<h3 class="item-title"><?php block_field( 'title' ); ?></h3> | |
<div class="item-subtitle"><p><?php block_field( 'subtitle' ); ?></p></div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Accordion block - Genesis Custom Blocks | |
Plugin URI: https://www.damiencarbery.com | |
Description: A simple accordion block created with Genesis Custom Blocks plugin. | |
Author: Damien Carbery | |
Version: 0.1 | |
*/ | |
add_filter( 'genesis_custom_blocks_template_path', 'dcwd_gcb_accordion_block_template_path', 10, 2 ); | |
function dcwd_gcb_accordion_block_template_path( $path, $template_names ) { | |
//error_log( 'Path: ' . var_export( $path, true ) ); | |
//error_log( 'Template names: ' . var_export( $template_names, true ) ); | |
foreach ( (array) $template_names as $template_name ) { | |
// If the Accordion block (preview or front end), return this directory. | |
if (( 'blocks/block-accordion-block.php' == $template_name ) || | |
( 'blocks/preview-accordion-block.php' == $template_name )) { | |
return __DIR__; | |
} | |
} | |
return $path; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Title/Subtitle block - Genesis Custom Blocks | |
Plugin URI: https://www.damiencarbery.com | |
Description: A simple title/subtitle block created with Genesis Custom Blocks plugin. | |
Author: Damien Carbery | |
Version: 0.1 | |
*/ | |
add_filter( 'genesis_custom_blocks_template_path', 'dcwd_gcb_title_subtitle_block_template_path', 10, 2 ); | |
function dcwd_gcb_title_subtitle_block_template_path( $path, $template_names ) { | |
foreach ( (array) $template_names as $template_name ) { | |
if ( 'blocks/block-title-subtitle-block.php' == $template_name ) { | |
return __DIR__; | |
} | |
} | |
return $path; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<details open="true" class="genesis-custom-block <?php block_field('className'); ?>"> | |
<summary class="item-title"><?php block_field( 'title' ); ?></summary> | |
<div class="item-content"><?php block_field( 'content' ); ?></div> | |
</details> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment