Skip to content

Instantly share code, notes, and snippets.

View lkoudal's full-sized avatar

Lars Koudal lkoudal

View GitHub Profile
@vovafeldman
vovafeldman / purchaseCompleted.php
Last active April 8, 2021 16:53
Freemius Purchase Completion JavaScript Callback Filter
<?php
// Add GA tracking only if user opted-in OR if non-WP.org compliant product.
function my_after_purchase_js( $js_function ) {
return 'function ( response ) {
/**
* Since the user just entered their personal & billing information, agreed to the TOS & privacy,
* know they are running within a secure iframe from an external domain, they implicitly permit tracking
* this purchase. So initizlizing GA here (after the purchase), is legitimate.
*/
ga('create', 'UA-XXXXXXX', 'auto');
@Mte90
Mte90 / snippet.php
Last active February 24, 2021 18:25
Custom WordPress Error Handler. Support Query Monitor and can be used as mu-plugin.
<?php
/*
* Plugin Name: Better errors
* Description: Better errors in log
* Author: Daniele Scasciafratte
* Version: 1.0
* Author URI: http://codeat.co
*/
function handleError($code, $description, $file = null, $line = null, $context = null) {
@dkwiebe
dkwiebe / gist:477d5f8af91022357ef13324a06a130e
Last active October 30, 2018 18:00
Retrieve Subscription products from WooCommerce
SELECT subscription_line_items.subscription_id,
subscriptions.post_status,
product.id AS product_id,
product.post_title AS product_name,
product.post_status,
mo.product_type,
subscription_line_items.qty,
subscription_line_items.product_total,
subscription_meta.currency,
subscription_meta.billing_period,
<?php
/**
* Sports-bench-team-rest-controller.php
*
* Creates a REST API controller for teams
*
* @package Sports Bench
*
* @author Jacob Martella
*
<?php
/*
This script will allow you to send a custom email from anywhere within wordpress
but using the woocommerce template so that your emails look the same.
Created by [email protected] on 27th of July 2017
Put the script below into a function or anywhere you want to send a custom email
*/
@brycejacobson
brycejacobson / functions.php
Last active April 4, 2025 05:07
Add message to WooCommerce email if shipping method is local pickup.
<?php
add_action( 'woocommerce_email_before_order_table', 'add_order_email_instructions', 10, 2 );
function add_order_email_instructions( $order, $sent_to_admin ) {
$shipping_method = @array_shift( $order->get_shipping_methods() );
$shipping_method_id = $shipping_method['method_id'];
if ( ! $sent_to_admin ) {
@rynaldos-zz
rynaldos-zz / wc-no-order-again.php
Last active January 14, 2021 13:19
[WooCommerce] Remove the "order again" button
remove_action( 'woocommerce_order_details_after_order_table', 'woocommerce_order_again_button' );
//Did this help? Donate me some BTC: 1BEsm8VMkYhSFJ92cvUYwxCtsfsB2rBfiG
@tameemsafi
tameemsafi / emails.php
Last active July 29, 2024 21:04
Send an email programmatically in wordpress with wp_mail using the woocommerce transaction emails template.
<?php
// Define a constant to use with html emails
define("HTML_EMAIL_HEADERS", array('Content-Type: text/html; charset=UTF-8'));
// @email - Email address of the reciever
// @subject - Subject of the email
// @heading - Heading to place inside of the woocommerce template
// @message - Body content (can be HTML)
function send_email_woocommerce_style($email, $subject, $heading, $message) {
@nunomorgadinho
nunomorgadinho / gist:b2d8e5b8f5fec5b0ed946b24fa288a91
Created February 10, 2017 13:30
PHPCS + WordPress Coding Standards
# Install brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install composer
brew install homebrew/php/composer
### PHPCS
composer global require "squizlabs/php_codesniffer=*"
# Add to your .bash_profile
@anoopranawat
anoopranawat / wphtsp-timeline-post-slug.php
Created October 17, 2016 06:39
Function to change the 'Timeline and History Slider Pro' Post type Slug
<?php
// Function to change the `Timeline and History Slider Pro` post type slug
function wphtsp_modify_timeline_post_slug( $slug ){
$slug = 'timeline_slider_slug'; // Write your desired slug
return $slug;
}
add_filter( 'wphtsp_post_slug', 'wphtsp_modify_timeline_post_slug' );
?>