Skip to content

Instantly share code, notes, and snippets.

View daltonrooney's full-sized avatar

Dalton Rooney daltonrooney

View GitHub Profile
@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,
),
<?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 / get_stores_by_location.php
Last active June 29, 2023 14:14
Store locator with Advanced Custom Fields
<?php
function mbn_get_stores_by_location( $zip, $radius ) {
global $wpdb;
$radius = intval( $radius );
// we first need to get the source coordinates
$sql = "SELECT `latitude`, `longitude` FROM `wp_zip_codes` WHERE `zipcode` = '%s'";
$coords = $wpdb->get_row( $wpdb->prepare( $sql, $zip ) );
@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:
@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 / 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;
<?php $args = array(
'numberposts' => -1,
'offset' => 0,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'custom_post_type_here',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'custom_field_key_name',
<?php
/**
* The Header for the template.
*
* @package WordPress
*/
$pp_theme_version = '1.0';
?><!DOCTYPE html>
@daltonrooney
daltonrooney / gist:2570640
Created May 1, 2012 19:16
PSP 1.6.1 custom js
/*!
* jQuery imagesLoaded plugin v2.0.1
* http://github.com/desandro/imagesloaded
*
* MIT License. by Paul Irish et al.
*/
(function(a,b){var c="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";a.fn.imagesLoaded=function(k){var h=this,m=a.isFunction(a.Deferred)?a.Deferred():0,l=a.isFunction(m.notify),e=h.find("img").add(h.filter("img")),f=[],j=[],g=[];function i(){var n=a(j),o=a(g);if(m){if(g.length){m.reject(e,n,o)}else{m.resolve(e)}}if(a.isFunction(k)){k.call(h,e,n,o)
}}function d(n,o){if(n.src===c||a.inArray(n,f)!==-1){return}f.push(n);if(o){g.push(n)}else{j.push(n)}a.data(n,"imagesLoaded",{isBroken:o,src:n.src});if(l){m.notifyWith(a(n),[o,e,a(j),a(g)])}if(e.length===f.length){setTimeout(i);e.unbind(".imagesLoaded")}}if(!e.length){i()}else{e.bind("load.imagesLoaded error.imagesLoaded",function(n){d(n.target,n.type==="error")}).each(function(n,p){var q=p.src;var o=a.data(p,"imagesLoaded");if(o&&o.src===q){d(p,o.isBroken);return}if(p.complete&&p.naturalWidth!==b){d(p,p.naturalWidt
@daltonrooney
daltonrooney / typekit-plugin.php
Created April 4, 2012 16:52
Add custom scripts to header
<?php
/*
* Plugin Name: Add TypeKit scripts to header
*/
function my_theme_custom_head() { ?>
<script type="text/javascript">
/* Your custom scripts go here */
</script>