Skip to content

Instantly share code, notes, and snippets.

View clifgriffin's full-sized avatar

Clifton Griffin clifgriffin

View GitHub Profile
<?php
/*
Plugin Name: Gist Watermark
Plugin URI: http://clifgriffin.com
Description: Nothing really.
Version: 1.0
Author: Clifton H. Griffin II
Author URI: http://clifgriffin.com
*/
<?php
add_filter('shopp_order_event_emails','disable_customer_order_notifications');
function disable_customer_order_notifications ($messages) {
print_r($messages);
unset($messages['customer']);
print_r($messages); die;
return $messages;
}
add_action('wp_ajax_update_shipping', 'update_shipping');
add_action('wp_ajax_nopriv_update_shipping', 'update_shipping');
function update_shipping() {
// Update shipping
$dest = array(
'shipping' => array(
'postcode' => $_REQUEST['postcode'],
'country' => $_REQUEST['country']
)
<?php
add_action( 'acf/save_post', 'hb_shopp_card_variations', 20 );
function hb_shopp_card_variations() {
gc_enable();
if( ! isset($_REQUEST['fields']) ) return;
ini_set('memory_limit', '356M');
set_time_limit(0);
global $post;
$images = get_children('post_type=attachment&post_mime_type=image&post_parent=' . $post->ID . '&orderby=menu_order&order=ASC');
foreach($images as $img) {
$image_attributes = wp_get_attachment_image_src($img->ID, "products");
$src = $image_attributes[0];
if(!empty($src)) {
echo "<img src='$src' />";
add_action('wp', 'handle_advanced_filter_collection');
function handle_advanced_filter_collection() {
if( is_catalog_frontpage() ) {
if(isset($_REQUEST['bc'])) {
$bc = $_REQUEST['bc'];
shopp('storefront','category',"slug=$bc&load=true");
$title = '&title=' . shopp('collection','get-name');
} elseif( !isset($_REQUEST['search']) ) {
$title = "&title=Gallery Products";
@clifgriffin
clifgriffin / gist:6092443
Created July 26, 2013 21:39
Parse current branch name from Git repository and conditionally set WordPress database name.
<?php
$git_head = file('.git/HEAD', FILE_USE_INCLUDE_PATH);
$git_head = $git_head[0]; //get the string from the array
$git_head = explode("/", $git_head); //separate out by the "/" in the string
$branch_name = trim($git_head[2]); //get the one that is always the branch name
if($branch_name == "master")
{
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress_local');
<?php
class ExamplePlugin {
var $settings = array();
var $prefix = "example_";
public function __construct() {
$this->settings = $this->get_settings_obj( $this->prefix );
add_action('admin_init', array($this, 'save_settings') );
}
<?php
/*
Plugin Name: P-Ntil Quote Source
Plugin URI: http://luketeaford.com/plugins/pntil-quote-source
Description: A plugin to add author and source to quote post formats. Last updated 8/7/2013.
Version: 0.1
Author: Luke Teaford
Author URI: http://luketeaford.com
License: GPL2
*/
@clifgriffin
clifgriffin / gist:6184402
Last active December 20, 2015 19:38
Two equally bad approaches to jQuery development (I think)
// I often find myself searching up the DOM tree with jQuery to access related items.
// Say, each item is in a li and I need to toggle other elements in that li.
// This usually takes the form of a blind man, counting floor tiles so he can find his way back,
// or similar. Either way, it feels like bad form and is probably very ineffienct.
// Solution A: Tag each relevant markup item with a particular ID attribute that is used to lookup related elements
jQuery("a.edit-todo-link").click(function(e) {
var todo_id = jQuery(this).attr('todo_id');
var parent_container = jQuery('li[todo_id=' + todo_id + ']');