Skip to content

Instantly share code, notes, and snippets.

View dancameron's full-sized avatar
💭
🍻Cheersing

Dan Cameron dancameron

💭
🍻Cheersing
View GitHub Profile
@dancameron
dancameron / functions.php
Last active August 28, 2015 15:21
Sort Predefined Line Items
<?php // don't include this in your functions.php
function sort_predefined_line_items( $items ) {
// somehow sort items, via uasort and custom callback
return $items;
}
add_filter( 'si_items_and_products', 'sort_predefined_line_items' );
@dancameron
dancameron / functions.php
Created August 28, 2015 20:42
Caldera Compatibility
<?php // don't include this in your functions.php
function deregister_select2_for_caldera( $items ) {
if ( ! class_exists( 'SI_Controller' ) ) {
return;
}
if ( SI_Controller::is_si_admin() ) {
wp_deregister_script( 'cf-select2minjs' );
wp_deregister_style( 'cf-select2css' );
}
@dancameron
dancameron / demo-shortcode.php
Last active August 29, 2015 14:04
Shortcode to retrieve remote form - ninjademo.com
<?php
/**
* Add the remote form via AJAX or php get.
* Shortcode is [sa-create-demo-form]
* Currently no attributes are used even though they could be used
* so that the $demo_url variable doesn't need to be updated manually below.
*
* @param array $atts shortcode atts
* @return string Create demo form.
*/
<?php
/*
Plugin Name: NinjaDemo AJAX Callbacks
Plugin URI: https://sproutapps.co/
Description: Allow for the demo form to be remotely retreived.
Author: Sprout Apps
Version: 0.8
Author URI: https://sproutapps.co
*/
@dancameron
dancameron / functions.php
Created August 18, 2014 03:39
Fix for Recurring EDD Payments with Discounts (Paypal).
<?php
// filter paypal because of discount
function sa_mod_paypal_gateway_data( $paypal_args = array(), $purchase_data = array() ) {
if ( isset( $paypal_args['cmd'] ) && $paypal_args['cmd'] == '_xclick-subscriptions' ) {
$paypal_args['sra'] = '3'; // change failed attempts.
if ( $paypal_args['a3'] < 0.00 && isset( $purchase_data['discount'] ) ) {
// Fix recurring amount
$paypal_args['a3'] += $purchase_data['discount'];
// fix single item, it matches the recurring amount.
@dancameron
dancameron / functions.php
Created September 8, 2014 22:02
EDD Recurring Payments & Discounts
<?php
function modify_edd_get_discount_amount( $amount, $code_id ) {
// Download requirements
$download_id = 49;
// Coupon code filtered
$dcodes = array( 'YOUDONTHINKIKNOW', 'WHATYOURETRYINGTODO?', 'NICETRY!!' );
// Filter only the discount code above
$code = edd_get_discount_code( $code_id );
if ( in_array( $code, $dcodes ) ) {
// Check cart of requirements before filtering amount
@dancameron
dancameron / functions.php
Created September 8, 2014 22:14
EDD Recurring Payments & Discounts
<?php
function modify_edd_get_cart_content_details_item_discount_amount( $discount, $item ) {
// We are only worried about SI at this point.
if ( $item['id'] == 49 ) {
// Don't apply a discount since it should come off the signupfee.
return 0;
}
return $discount;
}
add_filter( 'edd_get_cart_content_details_item_discount_amount', 'modify_edd_get_cart_content_details_item_discount_amount', 10, 2 );
@dancameron
dancameron / edd_templates_checkout_cart.php
Created September 8, 2014 22:33
EDD Recurring Payments & Discounts
<script type="text/javascript" charset="utf-8">
jQuery( 'body' ).on({
edd_discount_applied: function() {
window.location.reload();
jQuery('.edd_cart_discount_row').hide();
},
edd_discount_removed: function() {
window.location.reload();
jQuery('.edd_cart_amount').each(function() {
jQuery(this).text('...');
@dancameron
dancameron / invoice-es.php
Created September 10, 2014 23:58
SA Template Example
<?php
/**
* SA Template Name: Spanish Template
*
*/
do_action( 'pre_si_invoice_view' ); ?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
@dancameron
dancameron / functions.php
Created October 7, 2014 15:05
Manually Setting Locale for Sprout Invoices
<?php
/**
* Placed in the functions.php file of your theme this filter will override
* the local used by Sprout Invoices (which is the local WordPress is configured to use).
*
* nl_NL is the local in this example, change it to your local.
*/
function set_sprout_invoices_locale() {
return 'nl_NL'; // change nl_NL and leave the single quotes.
}