Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Rich Tabor richtabor

🎯
Focusing
View GitHub Profile
View add-colors-and-gradients-to-gutenberg.php
/**
* Block Editor Settings.
* Add custom colors and gradients to the editor.
*/
function tabor_add_colors_and_gradients() {
$colors = array(
'primary' => '#db1c7d',
'secondary' => '#a528f0',
'tertiary' => '#90cbff',
View register-block-category.php
function tabor_register_block_categories() {
if ( class_exists( 'WP_Block_Patterns_Registry' ) ) {
register_block_pattern_category(
'hero',
array( 'label' => _x( 'Hero', 'Block pattern category', 'textdomain' ) )
);
}
}
View block-variation-enqueue.php
function block_variation_example_enqueue() {
wp_enqueue_script(
'block-variation-example-script',
plugins_url( 'index.js', __FILE__ ),
array( 'wp-blocks', 'wp-dom-ready', 'wp-edit-post' ),
filemtime( plugin_dir_path( __FILE__ ) . '/block-variation-example.js' )
);
}
add_action( 'enqueue_block_editor_assets', 'block_variation_example_enqueue' );
View block-variation-example.js
wp.domReady( function() {
wp.blocks.registerBlockVariation( 'coblocks/form', {
name: 'event-registration',
title: 'Event Registration',
icon: '<svg height="48" viewBox="0 0 48 48" width="48" xmlns="http://www.w3.org/2000/svg"><path d="m18 10h-14v2h14zm2-8h-1v-2h-2v2h-12v-2h-2v2h-1c-1.11 0-1.99.9-1.99 2l-.01 16c0 1.1.89 2 2 2h18c1.1 0 2-.9 2-2v-16c0-1.1-.9-2-2-2zm0 18h-18v-13h18zm-5-5h-6-5v2h11z" transform="translate(13 14)"/></svg>',
innerBlocks: [
[ 'coblocks/field-name', { label: 'Full name', hasLastName: true } ],
[ 'coblocks/field-email', { required: true } ],
[ 'coblocks/field-radio', { label: 'How do you use WordPress?', required: true, options: [ 'I write', 'I design', 'I develop', 'I manage', 'I am new to WordPress!'] } ],
[ 'coblocks/field-checkbox', { label: 'I’m on a gluten-free diet', options: [ 'Yes', 'No' ], required: true } ],
View gist:c047bd3f74828147abd595ec65c612d4
--body-bg-color: #e0ded5
--body-color: #433f40
body {
background-color: var(--body-bg-color, #fff);
color: var(--body-color, #000);
}
View has_block.php
<?php
if ( has_block( 'blockgallery/masonry' ) ) {
// Do something, if the Block Gallery Masonry block is added to this page.
}
@richtabor
richtabor / function.php
Last active Jan 4, 2019 — forked from deeman/function.php
WooCommerce. Single product. Remove Additional Information
View function.php
/**
* Modify 'More Information' tab.
*/
function ava_child_product_additional_information_heading() {
return __( 'More Stuff', 'ava' );
}
add_filter('woocommerce_product_additional_information_heading', 'ava_child_product_additional_information_heading');
View add-fonts-to-gutenberg.php
// Enqueue fonts in the editor.
add_editor_style( york_fonts_url() );}
View editor-fonts.scss
body {
color: $color__text-main;
font-family: $font__body;
font-size: $font__size-md;
@media screen and (min-width: 599px) {
font-size: $font__size_base;
}
}
View block-widths.scss
.wp-block {
max-width: $content__width;
&[data-align="wide"] {
max-width: $content__width--wide;
}
&[data-align="full"] {
max-width: none;
}
You can’t perform that action at this time.