Skip to content

Instantly share code, notes, and snippets.

Avatar

Justin Tadlock justintadlock

View GitHub Profile
@justintadlock
justintadlock / customize-control-radio-image.php
Last active Sep 5, 2018
Customize Control: Radio Image
View customize-control-radio-image.php
<?php
/**
* The radio image customize control extends the WP_Customize_Control class. This class allows
* developers to create a list of image radio inputs.
*
* Note, the `$choices` array is slightly different than normal and should be in the form of
* `array(
* $value => array( 'url' => $image_url, 'label' => $text_label ),
* $value => array( 'url' => $image_url, 'label' => $text_label ),
* )`
View wp-api-backbone-underscore.php
<?php
add_action( 'wp_enqueue_scripts', 'jt_enqueue_scripts' );
function jt_enqueue_scripts() {
wp_enqueue_script( 'wp-api' );
wp_enqueue_script( 'wp-util' );
}
add_action( 'wp_footer', 'jt_print_post_template', 25 );
@justintadlock
justintadlock / customize-control-dropdown-terms.php
Created May 8, 2015
Dropdown taxonomy terms customizer control
View customize-control-dropdown-terms.php
<?php
/**
* A dropdown taxonomy terms `<select>` customizer control class.
*
* @package Hybrid
* @subpackage Classes
* @author Justin Tadlock <justin@justintadlock.com>
* @copyright Copyright (c) 2008 - 2015, Justin Tadlock
* @link http://themehybrid.com/hybrid-core
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
View single-post-schema.html
<!DOCTYPE html>
<html lang="en-EN">
<head>
<meta charset="UTF-8" />
<title>Test custom background &amp; header</title>
</head>
<body class="wordpress" itemscope="itemscope" itemtype="http://schema.org/WebPage">
@justintadlock
justintadlock / customize-control-background-image.php
Created Oct 14, 2013
Class for registering multiple default backgrounds in WrodPress themes.
View customize-control-background-image.php
<?php
/**
* Extends the WordPress background image customize control class, which allows a theme to register
* multiple default backgrounds for the user to choose from. To use this, the theme author
* should remove the 'background_image' control and add this control in its place.
*
* @since 0.1.0
* @author Justin Tadlock <justin@justintadlock.com>
* @copyright Copyright (c) 2013, Justin Tadlock
* @link http://justintadlock.com/archives/2013/10/13/registering-multiple-default-backgrounds
@justintadlock
justintadlock / hybrid-media-grabber.php
Last active Sep 3, 2020
Media grabber class in development.
View hybrid-media-grabber.php
<?php
/**
* Hybrid Media Grabber - A script for grabbing media related to a post.
*
* Hybrid Media Grabber is a script for pulling media either from the post content or attached to the
* post. It's an attempt to consolidate the various methods that users have used over the years to
* embed media into their posts. This script was written so that theme developers could grab that
* media and use it in interesting ways within their themes. For example, a theme could get a video
* and display it on archive pages alongside the post excerpt.
*
View remove-duplicator-pro-alert.php
<?php
add_action( 'admin_init', function() {
remove_action(
is_multisite() ? 'network_admin_notices' : 'admin_notices',
[ 'DUP_PRO_UI_Alert', 'licenseAlertCheck' ]
);
}, 11 );
@justintadlock
justintadlock / one-theme-two-textdomains.php
Last active Mar 23, 2021
How one theme can have two textdomains and still work with translation systems.
View one-theme-two-textdomains.php
<?php
/**
* The purpose of this file is to show how a theme can have multiple textdomains
* and still work with a single translation file. Translation tools like the
* one used on WordPress.org and Poedit are going to simply scan the project for
* text strings, regardless of the textdomain (and for good reasons that are
* not relevant here).
*
* The code below works with that system. It assumes that we have a single MO
* file based on the theme's textdomain. So, how can two textdomains work? It
@justintadlock
justintadlock / fse-outreach-7.html
Created May 26, 2021
FSE Outreach #7 portfolio template built with TT1 Blocks.
View fse-outreach-7.html
<!-- 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 / tiles-progress-percent-side.php
Last active Jun 11, 2021
Moves the "percent" metadata next to the bar for Tiles Progress Bar Block
View tiles-progress-percent-side.php
<?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,