Skip to content

Instantly share code, notes, and snippets.

Avatar

Justin Tadlock justintadlock

View GitHub Profile
@justintadlock
justintadlock / customize-control-palette.php
Created May 4, 2015
Customize Control: Color Palette
View customize-control-palette.php
<?php
/**
* Customize control class to handle color palettes.
*
* @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
@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' => '',
@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;
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
View th-api.php
<?php
/**
* Plugin Name: Theme Hybrid - API
* Plugin URI: http://themehybrid.com
* Description: API for ThemeHybrid.com
* Version: 0.1.0
* Author: Justin Tadlock
* Author URI: http://justintadlock.com
*/
@justintadlock
justintadlock / attr.php
Created Oct 7, 2013
Hybrid Core framework attributes proposal
View attr.php
<?php
/**
* HTML attribute functions and filters. The purposes of this is to provide a way for theme/plugin devs
* to hook into the attributes for specific HTML elements and create new or modify existing attributes.
* This is sort of like `body_class()`, `post_class()`, and `comment_class()` on steroids. Plus, it
* handles attributes for many more elements. The biggest benefit of using this is to provide richer
* microdata while being forward compatible with the ever-changing Web. Currently, the default microdata
* vocabulary supported is Schema.org.
*/
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
*/
@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/
*/
@justintadlock
justintadlock / in-main-loop.php
Last active Oct 30, 2017
A conditional tag for checking if we're in the core WP main query + loop.
View in-main-loop.php
<?php
/**
* Conditional to test if we're in the loop of the main query on a WordPress page.
* Please note that checking `in_the_loop() && is_main_query()` will NOT work in
* this scenario.
*/
add_action( 'loop_start', 'my_loop_start' );
add_action( 'loop_end', 'my_loop_end' );