Skip to content

Instantly share code, notes, and snippets.

View justintadlock's full-sized avatar

Justin Tadlock justintadlock

View GitHub Profile
@justintadlock
justintadlock / parent-theme-mod-fallback.php
Last active June 20, 2021 22:38
Get theme mods that fall back to the stored parent theme mod if child theme is active.
<?php
/**
* The purpose of this code is to show how you can use theme mods that will fall back to
* the already-set mods of the parent theme. So, when a child theme is active, the code
* checks, in the following order: 1) child theme mod, 2) parent theme mod, 3) default.
*/
function jt_get_theme_mod( $name, $default = false ) {
if ( is_child_theme() )
<?php
add_action( 'admin_init', function() {
remove_action(
is_multisite() ? 'network_admin_notices' : 'admin_notices',
[ 'DUP_PRO_UI_Alert', 'licenseAlertCheck' ]
);
}, 11 );
@justintadlock
justintadlock / functions.php
Created April 29, 2021 14:23
Remove block-templates support from Gutenberg.
<?php
// Drop the below in theme functions.php.
add_action( 'after_setup_theme', function() {
remove_theme_support( 'block-templates' );
} );
@justintadlock
justintadlock / fse-outreach-7.html
Created May 26, 2021 23:10
FSE Outreach #7 portfolio template built with TT1 Blocks.
<!-- wp:cover {"url":"http://localhost/wp-content/uploads/2021/05/pexels-mohamed-almari-368893-scaled.jpg","id":4995,"minHeight":100,"minHeightUnit":"vh","contentPosition":"center center","align":"full","style":{"spacing":{"padding":{"top":"2rem","right":"3rem","bottom":"2rem","left":"3rem"}}}} -->
<div class="wp-block-cover alignfull has-background-dim" style="padding-top:2rem;padding-right:3rem;padding-bottom:2rem;padding-left:3rem;min-height:100vh"><img class="wp-block-cover__image-background wp-image-4995" alt="" src="http://localhost/wp-content/uploads/2021/05/pexels-mohamed-almari-368893-scaled.jpg" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:columns {"verticalAlignment":"top"} -->
<div class="wp-block-columns are-vertically-aligned-top"><!-- wp:column {"verticalAlignment":"top","width":"33.33%"} -->
<div class="wp-block-column is-vertically-aligned-top" style="flex-basis:33.33%"><!-- wp:image {"id":5033,"width":42,"height":42,"sizeSlug":"thumbnail","linkDestination":"n
@justintadlock
justintadlock / theme.json
Created May 31, 2021 02:05
Block theme color naming scheme
{
"settings": {
"defaults": {
"color": {
"palette": [
{
"slug": "transparent",
"color": "transparent",
"name" : "Transparent"
},
@justintadlock
justintadlock / cover-offset-styles.php
Created June 4, 2021 04:06
Offset left and right Cover block styles
<?php
add_action( 'init', function() {
register_block_style( 'core/cover', [
'name' => 'offset-left',
'label' => __( 'Offset Left' ),
'inline_style' =>
'.wp-block-cover.is-style-offset-left > .wp-block-cover__inner-container {
background-color: inherit;
@justintadlock
justintadlock / tiles-progress-percent-side.php
Last active June 11, 2021 02:15
Moves the "percent" metadata next to the bar for Tiles Progress Bar Block
<?php
register_block_style( 'tiles/progress', [
'name' => 'percent-side',
'label' => 'Percent Side',
'inline_style' => '
.wp-block-tiles-progress.is-style-percent-side {
line-height: 1;
}
.wp-block-tiles-progress.is-style-percent-side .wp-block-tiles-progress__background,
<?php
$block_styles = [
'core/button' => [
'fill-white' => __( 'Fill White', 'frost' ),
'outline-white' => __( 'Outline White', 'frost' )
]
];
foreach ( $block_styles as $block => $styles ) {
@justintadlock
justintadlock / wood-frame.html
Created December 19, 2021 22:02
Block pattern for a wooden picture frame using Jeff Chandler's picture.
<!-- wp:cover {"url":"http://localhost/wp-content/uploads/2021/12/Wood066_1K_Color.jpg","id":8923,"isRepeated":true,"dimRatio":30,"overlayColor":"foreground","minHeight":0,"isDark":false,"align":"wide","style":{"spacing":{"padding":{"top":"0.25rem","right":"0.25rem","bottom":"0.25rem","left":"0.25rem"}}}} -->
<div class="wp-block-cover alignwide is-light is-repeated" style="padding-top:0.25rem;padding-right:0.25rem;padding-bottom:0.25rem;padding-left:0.25rem;background-image:url(http://localhost/wp-content/uploads/2021/12/Wood066_1K_Color.jpg)"><span aria-hidden="true" class="has-foreground-background-color has-background-dim-30 wp-block-cover__gradient-background has-background-dim"></span><div class="wp-block-cover__inner-container"><!-- wp:group {"align":"wide","style":{"border":{"width":"2px","style":"solid"}},"borderColor":"foreground"} -->
<div class="wp-block-group alignwide has-border-color has-foreground-border-color" style="border-style:solid;border-width:2px"><!-- wp:cover {"url":"http://localhost/
@justintadlock
justintadlock / pattern-cover-audio-social.html
Created December 29, 2021 23:58
Cover block pattern with audio player and social links.
<!-- wp:cover {"url":"https://pd.w.org/2021/12/63161c1f1d83e8218.20535107-2048x1365.jpg","id":8980,"dimRatio":70,"overlayColor":"foreground","minHeight":320,"contentPosition":"center center"} -->
<div class="wp-block-cover" style="min-height:320px"><span aria-hidden="true" class="has-foreground-background-color has-background-dim-70 wp-block-cover__gradient-background has-background-dim"></span><img class="wp-block-cover__image-background wp-image-8980" alt="" src="https://pd.w.org/2021/12/63161c1f1d83e8218.20535107-2048x1365.jpg" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:group {"borderColor":"background"} -->
<div class="wp-block-group has-border-color has-background-border-color"><!-- wp:cover {"dimRatio":20,"minHeight":320,"customGradient":"linear-gradient(135deg,rgb(255,206,236) 0%,rgb(152,150,240) 100%)","contentPosition":"center center","isDark":false,"style":{"spacing":{"padding":{"top":"2rem","right":"2rem","bottom":"2rem","left":"2rem"}}}} -->
<div class="wp-block-