Navigation Menu

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
Created February 4, 2020 20:15
Square CSS for Sprout Invoices
<?php // don't include this line in your functions.php, since it already starts with it.
function _custom_si_pdf_service_scripts() {
ob_start(); ?>
<style type="text/css">
.sq-input {
height: 2em;
padding: .1em;
@dancameron
dancameron / functions.php
Created September 8, 2014 22:25
EDD Recurring Payments & Discounts
<?php
function modify_edd_cart_contents( $cart ) {
$discounts = edd_get_cart_discounts();
if ( !$discounts ) {
return $cart;
}
$dcodes = array( 'YOUDONTHINKIKNOW', 'WHATYOURETRYINGTODO?', 'NICETRY!!' );
// Filter only the discount code above
if ( !array_intersect( $discounts, $dcodes ) ) {
@dancameron
dancameron / functions.php
Last active February 19, 2022 08:57
Adding new Line Item Types
<?php // don't add this line since it's already in your functions.php file
/**
* Changing the line item labels/names and adding a new line item type.
*
*/
function add_new_line_item_types( $types = array() ) {
$array_of_new_types = array(
'tasks' => __( 'Labour' ), // change label for tasks
'product' => __( 'Equipment' ), // change labal for product
@dancameron
dancameron / webpack.mix.js
Created February 12, 2021 04:06
apazed: Combining admin.scss and app.css from SASS + PostCSS
mix
.js('resources/js/app.js', 'public/js')
.sass('resources/css/sass/app.scss', 'public/css/app.css')
.options({
processCssUrls: false,
postCss: [
require('postcss-import'),
//tailwindcss('./tailwind.config.js')
require('tailwindcss'),
]
@dancameron
dancameron / updater.php
Created September 19, 2012 02:49
Theme Updater Example.
<?php
if ( is_admin() ) {
add_filter( 'pre_set_site_transient_update_themes', 'gb_check_for_premium_theme_update' );
}
function gb_check_for_premium_theme_update( $transient ) {
$current_version = 1.2;
$api_key = get_option('theme_api_key'); // your theme options will need to have an option to add the API key.
$theme_slug = 'theme_slug'; // Change to match with API Key Manager
$api_url = 'http://yoursite.com/check-key/'; // change to your site
@dancameron
dancameron / functions.php
Created November 26, 2018 15:44
Filter Beacon for Help Scout Desk
<?php // don't include this line in your functions.php, since it already starts with it.
function hsd_filter_beacon() {
if ( is_page( array( 1, 2, 3 ) ) ) {
remove_action( 'wp_footer', array( 'HSD_Beacon', 'add_beacon' ) );
}
}
add_action( 'pre_get_posts', 'hsd_filter_beacon' );
@dancameron
dancameron / functions.php
Created January 27, 2020 21:10
Custom PDF CSS
<?php // don't include this line in your functions.php, since it already starts with it.
function _custom_si_pdf_service_scripts( $old_scripts_and_styles ) {
$scripts_and_styles = $old_scripts_and_styles; // remove this line if you don't want to remove the default styling and scripts
ob_start(); // place your custom styles and javascript below ?>
<style type="text/css">
@dancameron
dancameron / functions.php
Created January 14, 2020 15:59
Slate Compatibility with Client VAT
<?php // don't include this line in your functions.php, since it already starts with it.
remove_action( 'si_document_vcards', array( 'Woo_Tools', 'add_vat_number_to_doc' ) );
remove_action( 'si_document_client_addy', array( 'SI_Hearts_EU', 'maybe_add_vat' ) );
function add_vat_below_address( $address ) {
ob_start();
SI_Hearts_EU::maybe_add_vat();
$vat .= ob_get_clean();
@dancameron
dancameron / functions.php
Created January 14, 2020 15:49
Remove VAT added by Woocommerce
<?php // don't include this line in your functions.php, since it already starts with it.
remove_action( 'si_document_vcards', array( 'Woo_Tools', 'add_vat_number_to_doc' ) );
@dancameron
dancameron / functions.php
Last active January 13, 2020 15:41
Setting a new Line Item Default
<?php // don't include this line in your functions.php, since it already starts with it.
function _set_new_default_si_type( $types = array() ) {
unset( $types['service'] ); // remove the type you want to make a default
return array_merge( array( 'service' => __( 'Service', 'sprout-invoices' ) ), $types ); // add it back at the top of the list.
}
add_filter( 'si_line_item_types', '_set_new_default_si_type' );