Skip to content

Instantly share code, notes, and snippets.

View braginteractive's full-sized avatar

Brad Williams braginteractive

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / site.js
Created April 11, 2017 22:20
Toggle the search bar in WordPress
jQuery(document).ready(function($){
$('.fa-search').on('click', function() {
$('.search-bar').slideToggle();
});
});
@braginteractive
braginteractive / _header.scss
Created April 11, 2017 22:15
Styles used for the Search Bar
.search-bar {
display: none;
padding: 2rem 0;
background-color: $brand-success;
box-shadow: inset 0px 1px 30px -2px rgba(0,0,0,0.75);
}
.fa-search {
&:hover {
color: rgba(255, 255, 255, 0.75);
@braginteractive
braginteractive / header.php
Created April 11, 2017 22:11
Search form for jQuery toggle in WordPress
<div class="search-bar">
<div class="container">
<div class="row">
<div class="col-md-8 offset-md-2">
<?php get_search_form(); ?>
</div><!-- .col-md-8 -->
</div><!-- .row -->
</div><!-- .container -->
</div><!-- .search-bar -->
@braginteractive
braginteractive / header.php
Created April 11, 2017 22:10
Search icon from Navigation
<span class="navbar-text">
<i class="fa fa-search" aria-hidden="true"></i>
</span>
@braginteractive
braginteractive / extras.php
Created April 11, 2017 21:58
Filter to add class to WordPress tags
<?php
/**
* Add Class to Tags
*/
function helpwp_add_tag_class($links) {
return str_replace('<a href="', '<a class="tag btn btn-sm btn-primary" href="', $links);
}
add_filter( "term_links-post_tag", 'helpwp_add_tag_class');