Rich Tabor – Twitter: @richard_tabor
Previously:
Founded ThemeBeans, CoBlocks & Block Gallery
WordPress Reviewer, Envato
Today's goal:
Design is...
Design is...
Design is...
<?php
register_block_style(
'core/button',
array(
'name' => '3d',
'label' => __( '3D' ),
'inline_style' => '.wp-block-button.is-style-3d .wp-block-button__link { box-shadow: inset 0 -3px 0 0 rgba(0,0,0,0.25); }',
)
);
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { registerBlockStyle } from '@wordpress/blocks';
wp.blocks.registerBlockStyle( 'core/button', {
name: '3d',
label: __( '3D', 'textdomain' ),
isDefault: false,
} );
function blocktalk_enqueue() {
wp_enqueue_script(
'blocktalk-script',
plugins_url( 'blocktalk.js', __FILE__ ),
array( 'wp-blocks', 'wp-dom-ready', 'wp-edit-post' ),
filemtime( plugin_dir_path( __FILE__ ) . '/blocktalk.js' )
);
}
add_action( 'enqueue_block_editor_assets', 'blocktalk_enqueue' );
wp.domReady( function() {
wp.blocks.registerBlockStyle( 'core/button', [
{
name: '3d',
label: '3D',
isDefault: true,
}
]);
} );
Altered Reality
20+ image filters for the Image block
WordPress Plugin
CoBlocks
Checkbox style applied to the core List block
WordPress Plugin
function blocktalk_enqueue() {
wp_enqueue_script(
'blocktalk-script',
plugins_url( 'blocktalk.js', __FILE__ ),
array( 'wp-blocks', 'wp-dom-ready', 'wp-edit-post' ),
filemtime( plugin_dir_path( __FILE__ ) . '/blocktalk.js' )
);
}
add_action( 'enqueue_block_editor_assets', 'blocktalk_enqueue' );
wp.domReady( function() {
wp.blocks.unregisterBlockStyle( 'core/quote', 'large' );
} );
import { Path, SVG } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { registerBlockVariation } from '@wordpress/blocks';
registerBlockVariation( 'coblocks/form', {
name: 'event-registration',
label: __( 'Event registration', 'coblocks' ),
icon: '',
innerBlocks: [
[ 'coblocks/field-name', { label: __( 'Full name', 'textdomain' ), hasLastName: true } ],
[ 'coblocks/field-email', { required: false } ],
[ 'coblocks/field-textarea', { label: __( 'Dietary needs?', 'textdomain' ), required: true } ],
[ 'coblocks/field-checkbox', { label: __( 'I will follow the Code of Conduct', 'textdomain' ), options: [ __( 'Yes', 'textdomain' ) ] } ],
],
submitButtonText: __( 'Register', 'textdomain' ),
scope: [ 'block' ],
} );
wp.domReady( function() {
wp.blocks.registerBlockVariation( 'coblocks/form', {
name: 'event-registration',
label: 'Event registration',
icon: '',
innerBlocks: [
[ 'coblocks/field-name', { label: 'Full name', hasLastName: true } ],
[ 'coblocks/field-email', { required: false } ],
[ 'coblocks/field-textarea', { label: 'Dietary needs?', required: true } ],
[ 'coblocks/field-checkbox', { label: 'I will follow the Code of Conduct', options: [ 'Yes' ] } ],
],
submitButtonText: 'Register',
scope: [ 'block' ],
} );
} );
function blocktalk_register_block_patterns() {
if ( function_exists( 'register_pattern' ) ) {
register_pattern(
'blocktalk/highlight-feature',
array(
'title' => __( 'Highlight feature', 'textdomain' ),
'content' => "<!-- wp:group {\"backgroundColor\":\"primary\",\"align\":\"full\"} -->\n<div class=\"wp-block-group alignfull has-primary-background-color has-background\"><div class=\"wp-block-group__inner-container\"><!-- wp:paragraph {\"customFontSize\":45,\"lineHeight\":1.56} -->\n<p style=\"font-size:45px;line-height:1.56\" class=\"has-custom-lineheight\">Curabitur blandit tempus port titor um sociis lorem.</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:columns -->\n<div class=\"wp-block-columns\"><!-- wp:column -->\n<div class=\"wp-block-column\"><!-- wp:paragraph -->\n<p>Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam quis risus eget urna mollis ornare vel eu leo.</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:buttons -->\n<div class=\"wp-block-buttons\"><!-- wp:button {\"backgroundColor\":\"background\",\"textColor\":\"primary\"} -->\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link has-text-color has-primary-color has-background has-background-background-color\">Learn more</a></div>\n<!-- /wp:button --></div>\n<!-- /wp:buttons --></div>\n<!-- /wp:column -->\n\n<!-- wp:column -->\n<div class=\"wp-block-column\"><!-- wp:paragraph -->\n<p>Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam quis risus eget urna mollis ornare vel eu leo.</p>\n<!-- /wp:paragraph --></div>\n<!-- /wp:column --></div>\n<!-- /wp:columns --></div></div>\n<!-- /wp:group -->",
)
);
}
}
add_action( 'init', 'blocktalk_register_block_patterns' );
<?php
function blocktalk_setup_theme() {
add_theme_support( 'editor-color-palette', array(
array(
'name' => __( 'Primary', 'textdomain' ),
'slug' => 'primary',
'color' => '#a156b4',
),
array(
'name' => __( 'Secondary', 'textdomain' ),
'slug' => 'secondary',
'color' => '#d0a5db',
),
) );
}
add_action( 'after_setup_theme', 'blocktalk_setup_theme' );
.has-primary-background-color {
background-color: #a156b4;
}
.has-primary-color {
color: #a156b4;
}
.has-secondary-background-color {
background-color: #d0a5db;
}
.has-secondary-color {
color: #d0a5db;
}
<?php
function blocktalk_setup_theme() {
add_theme_support( 'editor-font-sizes', array(
array(
'name' => __( 'Small', 'textdomain' ),
'slug' => 'small',
'size' => 14,
),
array(
'name' => __( 'Large', 'textdomain' ),
'slug' => 'large',
'size' => 36,
),
) );
}
add_action( 'after_setup_theme', 'blocktalk_setup_theme' );
.has-small-font-size {
font-size: 14px;
}
.has-large-font-size {
font-size: 36px;
}
<?php
function blocktalk_setup_theme() {
add_theme_support( 'editor-gradient-presets',
array(
array(
'name' => __( 'Vivid cyan blue to vivid purple', 'textdomain' ),
'gradient' => 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)',
'slug' => 'vivid-cyan-blue-to-vivid-purple'
),
)
);
}
add_action( 'after_setup_theme', 'blocktalk_setup_theme' );
.has-vivid-cyan-blue-to-vivid-purple-gradient-background {
background: linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%);
}