Skip to content

Instantly share code, notes, and snippets.

View braginteractive's full-sized avatar

Brad Williams braginteractive

View GitHub Profile
@braginteractive
braginteractive / tracking.php
Last active April 11, 2017 22:41
Add Google Analytics to WordPress
<?php
/**
* Add Tracking Scripts
*/
function helpwp_google_analytics() { ?>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
@braginteractive
braginteractive / functions.php
Created April 11, 2017 22:44
Add tracking to functions.php
<?php
/**
* Tracking Codes
*/
require get_template_directory() . '/inc/tracking.php';
@braginteractive
braginteractive / functions.php
Created April 14, 2017 15:40
Twenty Seventeen Child WordPress Theme
<?php
function my_theme_enqueue_styles() {
$parent_style = 'twentyseventeen-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
wp_get_theme()->get('Version')
@braginteractive
braginteractive / gulpfile.js
Created April 18, 2017 18:40
Gulp file for WordPress Theme
// Load all the modules from package.json
var gulp = require( 'gulp' ),
plumber = require( 'gulp-plumber' ),
autoprefixer = require('gulp-autoprefixer'),
watch = require( 'gulp-watch' ),
jshint = require( 'gulp-jshint' ),
stylish = require( 'jshint-stylish' ),
uglify = require( 'gulp-uglify' ),
rename = require( 'gulp-rename' ),
notify = require( 'gulp-notify' ),
@braginteractive
braginteractive / widgets.php
Created April 18, 2017 21:20
Resister the Contact widget area in WordPress theme
<?php
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function helpwp_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Sidebar', 'helpwp' ),
'id' => 'sidebar-1',
@braginteractive
braginteractive / tgm-plugin-activation.php
Created May 1, 2017 21:08
TGM Plugin Activation file for Kirki
<?php
/**
* This file represents an example of the code that themes would use to register
* the required plugins.
*
* It is expected that theme authors would copy and paste this code into their
* functions.php file, and amend to suit.
*
* @see http://tgmpluginactivation.com/configuration/ for detailed documentation.
*
@braginteractive
braginteractive / customizer.php
Last active May 12, 2017 15:59
Kirki code to add Typography to WordPress theme
<?php
/**
* StrapPress Theme Customizer
*
* @package StrapPress
*/
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
@braginteractive
braginteractive / customizer.php
Last active May 12, 2017 16:09
Hero Banner settings for WordPress Customizer
<?php
if ( class_exists( 'Kirki' ) ) {
/**
* Add the theme configuration
*/
Kirki::add_config( 'strappress_theme', array(
'option_type' => 'theme_mod',
'capability' => 'edit_theme_options',
) );
@braginteractive
braginteractive / template-home.php
Created May 10, 2017 18:17
Code to display Hero Banner and Text
<?php
$hero_image = get_theme_mod( 'hero_image', '' );
$hero_text = get_theme_mod( 'hero_text', '' );
?>
<div class="sp-hero" style="background-image: url('<?php echo esc_url( $hero_image ); ?>')">
<h1><?php echo $hero_text; ?></h1>
</div>
@braginteractive
braginteractive / template-home.php
Created May 10, 2017 18:22
Get Template Part for Homepage banner
<?php get_template_part( 'template-parts/home/hero', 'banner' ); ?>