Skip to content

Instantly share code, notes, and snippets.

View daltonrooney's full-sized avatar

Dalton Rooney daltonrooney

View GitHub Profile
@daltonrooney
daltonrooney / charlimit.js
Last active August 29, 2015 14:03
Visual character limit for textareas
(function($){
function addCharLimit(){
$('textarea').each(function(){
maxlength = $(this).attr("maxlength");
if ( maxlength !== undefined ) {
charContainer = $(this).parent().find('p.charleft').val();
if ( charContainer === undefined ) {
$(this).parent().append("<p class='charleft description'>");
}
charleft = maxlength - $(this).val().length;
@daltonrooney
daltonrooney / pagination.php
Created September 11, 2014 23:23
Numerical pagination for supplemental SearchWP engine
<!-- begin pagination -->
<?php if( $engine->maxNumPages > 1 ) :
echo '<nav class="pagination"><ul>';
$max = intval( $engine->maxNumPages );
/**ID of your custom search results page here**/
$permalink = get_permalink(479);
$prevPage = $swppg > 1 ? $swppg - 1 : false;
$nextPage = $swppg < $engine->maxNumPages ? $swppg + 1 : false;
@daltonrooney
daltonrooney / info.txt
Last active August 29, 2015 14:07
Add a downloadable product to a user's account when a WooCommerce Subscription is created
Let's say you run a WooCommerce subscription website, and you'd like to automatically add
a downloadable product to a subscriber's account when they activate their subscription.
Here's one way to do it:
<?php
/**
* Plugin Name: WooCommerce Disable PayPal for Subscriptions
* Plugin URI: https://gist.github.com/thenbrent/6641526
* Description: Want to disable PayPal for subscription purchases, but still offer it as an option for buying one-off products? Activate this plugin.
* Author: Brent Shepherd
* Author URI: http://find.brentshepherd.com/
* Version: 1.0
*
* This program is free software: you can redistribute it and/or modify
@daltonrooney
daltonrooney / wholesale_product_list.php
Last active August 29, 2015 14:11
Quick list of wholesale products for Woocommerce Wholesale Ordering plugin
<?php
function wholesale_product_list() {
$args = array(
'post_type' => 'product',
'meta_query' => array(
array(
'key' => '_wholesale_price',
'compare' => '!=',
'value' => 0,
),
@daltonrooney
daltonrooney / add_image_size.php
Created May 14, 2015 02:05
Add image sizes on the front end only
add_action( 'after_setup_theme', 'front_end_image_sizes' );
function front_end_image_sizes() {
//Only register these on the front end for our templates
if ( !is_admin() && ( !defined( 'DOING_AJAX' ) || !DOING_AJAX ) ) :
add_image_size( 'hero', 2000, 1000, false );
add_image_size( 'smallish', 400, 400, false );
add_image_size( 'tweener', 900, 700, false );
endif;
}
@daltonrooney
daltonrooney / portfolio-slideshow-min.js
Created August 6, 2011 11:41
Portfolio Slideshow custom
(function(a){a.fn.touchwipe=function(c){var b={min_move_x:20,min_move_y:20,wipeLeft:function(){},wipeRight:function(){},wipeUp:function(){},wipeDown:function(){},preventDefaultEvents:true};if(c){a.extend(b,c)}this.each(function(){var e;var d;var i=false;function h(){this.removeEventListener("touchmove",f);e=null;i=false}function f(m){if(b.preventDefaultEvents){m.preventDefault()}if(i){var j=m.touches[0].pageX;var n=m.touches[0].pageY;var l=e-j;var k=d-n;if(Math.abs(l)>=b.min_move_x){h();if(l>0){b.wipeLeft()
}else{b.wipeRight()}}else{if(Math.abs(k)>=b.min_move_y){h();if(k>0){b.wipeDown()}else{b.wipeUp()}}}}}function g(j){if(j.touches.length==1){e=j.touches[0].pageX;d=j.touches[0].pageY;i=true;this.addEventListener("touchmove",f,false)}}if("ontouchstart" in document.documentElement){this.addEventListener("touchstart",g,false)}});return this}})(jQuery);jQuery(document).ready(function(a){a(window).load(function(){var g,e,c,b,f;currSlide=new Array();tabSlide=new Array();g=portfolioSlideshowOptions.psLoader;
e=port
(function(a){a.fn.touchwipe=function(c){var b={min_move_x:20,min_move_y:20,wipeLeft:function(){},wipeRight:function(){},wipeUp:function(){},wipeDown:function(){},preventDefaultEvents:true};if(c){a.extend(b,c)}this.each(function(){var e;var d;var i=false;function h(){this.removeEventListener("touchmove",f);e=null;i=false}function f(m){if(b.preventDefaultEvents){m.preventDefault()}if(i){var j=m.touches[0].pageX;var n=m.touches[0].pageY;var l=e-j;var k=d-n;if(Math.abs(l)>=b.min_move_x){h();if(l>0){b.wipeLeft()
}else{b.wipeRight()}}else{if(Math.abs(k)>=b.min_move_y){h();if(k>0){b.wipeDown()}else{b.wipeUp()}}}}}function g(j){if(j.touches.length==1){e=j.touches[0].pageX;d=j.touches[0].pageY;i=true;this.addEventListener("touchmove",f,false)}}if("ontouchstart" in document.documentElement){this.addEventListener("touchstart",g,false)}});return this}})(jQuery);jQuery(document).ready(function(g){var f,d,b,a,e;currSlide=new Array();tabSlide=new Array();f=portfolioSlideshowOptions.psLoader;d=portfolioSlideshowOptions.psHas
@daltonrooney
daltonrooney / gist:1153929
Created August 18, 2011 12:05
Portfolio Slideshow 1.2.1 alt stylesheet
.portfolio-slideshow {
z-index: 0 !important
}
div.slideshow-wrapper {
visibility: hidden;
margin:0 0 10px 0;
}
/* clearfix */
@daltonrooney
daltonrooney / gist:1356238
Created November 10, 2011 21:10
Haiku custom
$('.player-container').css('visibility', 'visible').show();
/*Text Version*/
$("div[id^=haiku-text-player]").each(function() {
var num = this.id.match(/haiku-text-player(\d+)/)[1];
var ctrlId = "div#text-player-container" + num + " ul#player-buttons" + num;
var audioFile = $(ctrlId + " li.play a").attr("href");
$(this).jPlayer({