This file contains hidden or 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 | |
/** | |
* Render columns block with extra class | |
* | |
* @param string $block_content The block content about to be rendered. | |
* @param array $block The full block, including name and attributes. | |
* @return string | |
*/ | |
function render_columns_block_class( $block_content, $block ) { |
This file contains hidden or 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
.fa.fa-twitter{ | |
font-family:sans-serif; | |
} | |
.fa.fa-twitter::before{ | |
content:"𝕏"; | |
font-size:1.2em; | |
} |
This file contains hidden or 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 | |
/** | |
* ACF Block Template. | |
* | |
* @param array $block The block settings and attributes. | |
* @param string $content The block inner HTML (empty). | |
* @param bool $is_preview True during backend preview render. | |
* @param int $post_id The post ID the block is rendering content against. | |
* This is either the post ID currently being displayed inside a query loop, | |
* or the post ID of the post hosting this block. |
This file contains hidden or 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 | |
/** | |
* Helper function to import the ACF field group if it doesn't exist. | |
* | |
* @return void | |
*/ | |
function example_import_acf_field_group() { | |
if ( function_exists( 'acf_import_field_group' ) ) { | |
// Get all json files from the /acf-field-groups directory in your plugin. |
This file contains hidden or 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: Block Pattern Preview | |
* Description: Allows you to preview block patterns on the frontend of your website. | |
* Author: Brian Coords | |
* Author URI: https://www.briancoords.com | |
* Version: 0.0.1 | |
* License: GPL v2 or later | |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html | |
* |
This file contains hidden or 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 | |
function my_body_classes( $classes ){ | |
if ( is_page( 'about' ) ) { | |
$classes[] = 'page-about'; | |
} | |
return $classes; | |
} |
This file contains hidden or 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
import { useSelect } from '@wordpress/data'; | |
/** | |
* AttachmentImage | |
* | |
* This component is used to display an image from the media library. | |
* It's meant as a JS companion to the PHP function `wp_get_attachment_image()`. | |
* | |
* @link https://www.briancoords.com/getting-wordpress-media-library-images-in-javascript/ |
This file contains hidden or 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 | |
/** | |
* All of the parameters passed to the function where this file is being required are accessible in this scope: | |
* | |
* @param array $attributes The array of attributes for this block. | |
* @param string $content Rendered block output. ie. <InnerBlocks.Content />. | |
* @param WP_Block $block The instance of the WP_Block class that represents the block being rendered. | |
* | |
* @package gutenberg-examples | |
*/ |
This file contains hidden or 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
wp.domReady( () => { | |
let blocks = wp.blocks.getBlockTypes().map( ( block ) => block.name ); | |
blocks.forEach( ( block ) => { | |
if ( block.indexOf( 'core/' ) === 0 ) { | |
wp.blocks.unregisterBlockType( block ); | |
} | |
}); | |
} ); |