Skip to content

Instantly share code, notes, and snippets.

View douglaskarr's full-sized avatar

Douglas Karr douglaskarr

View GitHub Profile
@douglaskarr
douglaskarr / Dark OSX.css
Last active May 14, 2019 14:20
Dark OSX Theme for Espresso Editor
/*
@theme Dark OSX
@override-placeholders ruby, css, html, php
@author Douglas Karr - Based on the Railcasts theme
Colors
- #fff text
- #1f1f1f background
- #00b300 Green (Comments)
- rgba(251, 199, 111, 1.00) Yellow
@douglaskarr
douglaskarr / gravity_forms_subpage_access.php
Created April 25, 2018 16:45
Gravity Forms Access Subpages
<?php
/**
This code will go in your theme's functions.php file. Upon form submission,
it allows the user to access subpages. In this example, it's form ID 14 and the
registration page is 'product-tour' Once submitted, you may wish to redirect
the user to a page that has a TOC or something similar.
**/
// Indicate whether or not the product tour form (14) was submitted via Cookie
@douglaskarr
douglaskarr / delay_script.js
Created April 7, 2018 01:28
Delay the loading of an external script using jQuery
<script type="text/javascript">
window.setTimeout(function() {
jQuery.getScript( "//domain.com/script.js");
}, 500);
</script>
@douglaskarr
douglaskarr / event_tracking.html
Created March 22, 2018 16:16
Google Analytics Event Tracking using jQuery and outbound link with a class of button
<script type="text/javascript">
jQuery(function($) {
$(document).ready(function() {
$("a.button").each(function() {
var href = $(this).attr("href");
var target = $(this).attr("target");
var text = $(this).text();
$(this).click(function(event) { // captures the clicked link event
event.preventDefault(); // interrupts sending to the next page
// ga('send', 'timing', 'timingCategory', 'timingVar', timingValue, 'timingLabel'); // for GA
@douglaskarr
douglaskarr / dknm_rotatekewords_shortcode.php
Last active February 22, 2018 13:59
WordPress Shortcode to Rotate Keywords in a Sentence
<?php
// Add to your theme's functions.php file
// Usage: [rotatewords firstterm="Known" terms="Engaged, Retained, Loyal, Advocates" delay="1500" fadeout="500" fadein="100"]Are Your Customers Known?[/rotatewords]
// The first term you use will be rotated through.
wp_enqueue_script("jquery");
function dknm_keyword_rotate($atts, $content = "") {
@douglaskarr
douglaskarr / wp_list_child_pages.php
Created February 14, 2018 19:09
WordPress: Register a shortcode to list child pages on a parent page
<php
// Turn on excerpt support for pages by enabling them in your themes functions.php file
add_post_type_support( 'page', 'excerpt' );
/* Add the below function to your theme's functions.php file
** This has more capabilities than get_pages and wp_list_pages
** Usage: [list_subpages aclass="button" ifempty="Sorry, we currently don't have any job openings."]<h3>List of Jobs</h3>[/list_subpages]
*/
@douglaskarr
douglaskarr / shortcode_gravityforms_ab.php
Last active February 14, 2018 19:10
WordPress: Add A/B Testing Functionality to Gravity Forms
<?php
// Add to your functions.php theme file
// Modified slightly from Mediacause so all you need to do is add _ab to your shortcode and then specify your forms
// Credit: https://mediacause.org/ab-testing-forms-using-gravity-forms/
function shortcode_gravityforms_ab($atts){
$a = shortcode_atts( array(
'id' => '',
'title' => 'false',
'description' => 'false',