Skip to content

Instantly share code, notes, and snippets.

View daltonrooney's full-sized avatar

Dalton Rooney daltonrooney

View GitHub Profile
<?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,
),
<?php
/**
* Filter the output of image_downsize() to return dynamically generated images for intermediate or inline sizes.
*
* <p>Because Wordpress generates all image sizes on first upload, if you change
* theme or size settings after the upload, there won't be a matching file for
* the requested size.<br/>
* This filter addresses the problem of the default downsize process laoding
* a large file and scaling it down in the browser if it doesn't find the right
* size image. This can cause large files to be loaded unnecessarily and will
@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 / paypal_sub_exclude_woocom.php
Last active November 11, 2021 08:34
Exclude PayPal gateway for WooCommerce subscriptions
/* $productCategoryID includes all subscription products */
function cart_includes_subscription_category() {
$productCategoryID = 10;
global $woocommerce;
$product_in_cart = false;
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) :
$_product = $values['data'];
$terms = get_the_terms( $_product->id, 'product_cat' );
if ( $terms ) :
foreach ($terms as $term) :
@daltonrooney
daltonrooney / plugin.php
Last active May 10, 2016 15:10
overwrite the_content() with WP template output
<?php
/* Retrieve the rendered content generated by Advanced Custom Fields and your template and
* save it to the_content field. Overwrites existing content. Useful for Yoast SEO analysis compatibility
* and acts as a fallback if the user ever changes themes.
*/
/* Requires simplehtmldom, get it here: http://simplehtmldom.sourceforge.net */
require 'simplehtmldom.php';
add_action('acf/save_post', 'mctc_acf_save_post', 1);
@daltonrooney
daltonrooney / wp_custom_title_placeholder_text.php
Created September 24, 2015 18:46 — forked from isGabe/wp_custom_title_placeholder_text.php
WordPress: Custom placeholder text for custom post type title input box #snippet #WordPress
<?php
/*
replacing the default "Enter title here" placeholder text in the title input box
with something more descriptive can be helpful for custom post types
place this code in your theme's functions.php or relevant file
source: http://flashingcursor.com/wordpress/change-the-enter-title-here-text-in-wordpress-963
*/
@daltonrooney
daltonrooney / acf-page-ancestor-location-rule.php
Created October 5, 2015 22:18 — forked from Hube2/acf-page-ancestor-location-rule.php
Advanced Custom Fields - Page Ancestor Custom Location Rule
<?php
/*
ACF cusomt location rule : Page Ancestor
*/
add_filter('acf/location/rule_types', 'acf_location_rules_page_ancestor');
function acf_location_rules_page_ancestor($choices) {
$choices['Page']['page_ancestor'] = 'Page Ancestor';
return $choices;
}
@daltonrooney
daltonrooney / acf-page-granparent-location-rule.php
Created October 5, 2015 22:18 — forked from Hube2/acf-page-granparent-location-rule.php
Advanced Custom Fields - Page Grandparent Custom Location Rule
<?php
/*
Adds a custom location rule to ACF to select page grandparent
*/
add_filter('acf/location/rule_types', 'acf_location_rules_page_grandparent');
function acf_location_rules_page_grandparent($choices) {
$choices['Page']['page_grandparent'] = 'Page Grandparent';
return $choices;
@daltonrooney
daltonrooney / jquery.ba-htmldoc.js
Created November 30, 2015 22:39 — forked from cowboy/jquery.ba-htmldoc.js
jQuery htmlDoc "fixer" - get HTML, HEAD, BODY in your $(html) - NEEDS TESTING
/*!
* jQuery htmlDoc "fixer" - v0.2pre - 8/8/2011
* http://benalman.com/projects/jquery-misc-plugins/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($) {