Skip to content

Instantly share code, notes, and snippets.

View clifgriffin's full-sized avatar

Clifton Griffin clifgriffin

View GitHub Profile
<?php
class Foo {
var $bar;
function Foo() {
add_action('shopp_init', array($this, 'register_session_variable') );
}
function register_session_variable() {
Shopping::restore('bar', $this->bar);
@clifgriffin
clifgriffin / gist:9810754
Created March 27, 2014 15:53
Fix for Shopp 1.2.x and WordPress 3.7+
<?php
// add to functions.php
add_action('shopp_storefront_init', 'shopp_storefront_wp37_compat');
function shopp_storefront_wp37_compat() {
add_filter('archive_template', array(ShoppStorefront(), 'pages') );
}
@clifgriffin
clifgriffin / gist:9915168
Last active August 29, 2015 13:57
Loading adhoc collections of products by ID(s)
<?php
$product_ids = array(12, 14);
ShoppCollection( new ProductCollection );
ShoppCollection()->slug = 'adhoc-collection';
ShoppCollection()->load( array(
'where' => array('p.id IN (' . implode(',', $product_ids) . ')')
));
shopp('storefront.collection');
@clifgriffin
clifgriffin / 0_reuse_code.js
Created June 2, 2014 12:39
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@clifgriffin
clifgriffin / gist:30c5fd0d2554561be818
Last active August 29, 2015 14:04
How to get post thumbnail URL in WordPress the right way
<?php
// Don't include opening PHP tag!
$thumbnail_url = wp_get_attachment_url( get_post_thumbnail_id() );
@clifgriffin
clifgriffin / gist:7fdc2fe480c3e20949d6
Created October 14, 2014 17:15
Wildcard Virtual Host for XAMPP
<VirtualHost *:80>
VirtualDocumentRoot /Applications/XAMPP/xamppfiles/htdocs/sites/%-2+
</VirtualHost>
<?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);