Skip to content

Instantly share code, notes, and snippets.

Justin Tadlock justintadlock

Block or report user

Report or block justintadlock

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@justintadlock
justintadlock / parent-theme-mod-fallback.php
Last active Jan 16, 2019
Get theme mods that fall back to the stored parent theme mod if child theme is active.
View parent-theme-mod-fallback.php
<?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() )
@justintadlock
justintadlock / font-awesome.php
Last active Dec 10, 2018
PHP array of Font Awesome icons.
View font-awesome.php
<?php
// Font Awesome v. 4.6.
function jt_get_font_icons() {
return array(
'fa-glass' => 'f000',
'fa-music' => 'f001',
'fa-search' => 'f002',
'fa-envelope-o' => 'f003',
@justintadlock
justintadlock / one-theme-two-textdomains.php
Last active Jul 17, 2019
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 / functions.php
Created Mar 9, 2016
Allow "0" for EDD Members - includes/functions.php
View functions.php
<?php
/**
* Helper Functions
*
* @package EDDMembers\Functions
* @since 1.0.0
*/
// Exit if accessed directly
if( !defined( 'ABSPATH' ) ) {
@justintadlock
justintadlock / fonts.php
Last active Jul 13, 2016
Enqueue fonts in WP
View fonts.php
<?php
/**
* Functions for handling font enqueueing, registration, etc. This works with the
* Google Fonts API.
*
* Extending an idea from Jose Castaneda. This is a small script for loading Google fonts
* with an easy method for adding/removing/editing the fonts loaded via child theme.
*
* @link http://blog.josemcastaneda.com/2016/02/29/adding-removing-fonts-from-a-theme/
*/
View jeff-jetpack-infinite-scroll.php
<?php
/**
* @package ThemeName
* @version 0.1.0
* @author Your Name <you@youremailprovider.com>
* @copyright Copyright (c) 2013, Your Name
* @link http://yoursite.com/themes/theme-slug
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
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 );
View st-bakery-index.php
<?php
/**
* The template for displaying home page.
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site will use a
* different template.
*
* @package SKT Bakery
@justintadlock
justintadlock / control-select.php
Created Jun 7, 2015
Example customizer select control
View control-select.php
<?php
class Hybrid_Customize_Control_Select extends WP_Customize_Control {
public $type = 'select-custom';
public function to_json() {
parent::to_json();
$this->json['choices'] = $this->choices;
@justintadlock
justintadlock / customize-empty-default-color.php
Last active Aug 29, 2015
Customize color with empty default
View customize-empty-default-color.php
<?php
add_action( 'customize_register', 'my_customize_register' );
function my_customize_register( $wp_customize ) {
$wp_customize->add_setting(
'color_xyz',
array(
'default' => '',
You can’t perform that action at this time.