Skip to content

Instantly share code, notes, and snippets.

View seb86's full-sized avatar
🚀

Sébastien Dumont seb86

🚀
View GitHub Profile
@seb86
seb86 / gist:a5446e0608e79e66b42b569cdcad9925
Created August 21, 2017 13:42 — forked from woogist/gist:5692886
Sample WooCommerce Points & Rewards 3rd Party Plugin Integration
<?php
// Add the action setting
add_filter( 'wc_points_rewards_action_settings', 'points_rewards_newsletter_action_settings' );
function points_rewards_newsletter_action_settings( $settings ) {
$settings[] = array(
'title' => __( 'Points earned for newsletter signup' ),
'desc_tip' => __( 'Enter the amount of points earned when a customer signs up for a newsletter via MailChimp.' ),
@seb86
seb86 / alnp-add-theme-support.php
Last active September 12, 2018 15:33
Declare support for Auto Load Next Post in a theme. Last two values are for Auto Load Next Post v1.5.0+ only!
/**
* Add theme support for Auto Load Next Post by setting the
* theme selectors to be applied once the theme is activated.
*/
function add_alnp_theme_support() {
add_theme_support( 'auto-load-next-post', array(
'content_container' => 'main.site-main',
'title_selector' => 'h1.entry-title',
'navigation_container' => 'nav.post-navigation',
'comments_container' => 'div#comments',
@seb86
seb86 / setup-gitconfig.sh
Created June 20, 2017 14:45
Sets up your local repository .gitconfig file.
#!/bin/sh
set -e
git config --local include.path ../.gitconfig
echo "Your local .gitconfig is now setup!"
exit 1;
@seb86
seb86 / .gitconfig
Created June 20, 2017 13:57
My Git Aliases
[alias]
# Creates a new branch on your local machine and switches into this branch.
newbie = "!git checkout -b $(git branch-name)"
# Push the current branch to the remote "origin", and set it to track
# the upstream branch
publish = "!git push -u origin $(git branch-name)"
# Delete the remote version of the current branch
unpublish = "!git push origin :$(git branch-name)"
@seb86
seb86 / .htaccess
Created April 19, 2017 14:39
Generic htaccess redirect www to non-www
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
@seb86
seb86 / wc-ajax-cart-check.php
Created April 6, 2017 22:48
Removes Ajax to run on the frontpage with WC to check if the cart has any items added. Saves about 2 seconds average of load time.
add_action( 'wp_enqueue_scripts', 'dequeue_woocommerce_cart_fragments', 11);
function dequeue_woocommerce_cart_fragments() {
if ( is_front_page() ) {
wp_dequeue_script('wc-cart-fragments');
}
}
@seb86
seb86 / wp-install-core-sub-dir.sh
Created April 6, 2017 20:55 — forked from polevaultweb/wp-install-core-sub-dir.sh
This script installs WordPress inside a sub directory
#!/bin/bash
# Installation:
# Install the script in one of the folders in your PATH. Make sure it has execute permissions (i.e. chmod +x wp-install-core-sub-dir).
#Usage:
# $ mkdir mysite
# $ cd mysite
<?
// <readme>
/*
This is a lite version of Olark's and Intercom's functionality (without the chat part).
It lets you get feedback from users on your site to your email.
And you won't have to rely on another company anymore!
#killyourdependencies
@seb86
seb86 / gist:d7a16fb67a99e99230221762045f7d90
Last active July 20, 2016 17:22
Gets the shipping cost for the product from the assigned shipping class
/**
* Returns the shipping cost from the shipping class assigned to the product.
*
* @param object $product
* @return string
*/
function get_shipping_cost( $product ) {
$shipping_method = apply_filters( 'woocommerce_default_single_product_shipping_method', 'flat_rate' );
$shipping = new WC_Shipping();
@seb86
seb86 / woocommerce_products_sold_single_product.php
Created May 17, 2016 18:14 — forked from kloon/woocommerce_products_sold_single_product.php
WooCommerce display number of products sold on single product page
<?php
add_action( 'woocommerce_single_product_summary', 'wc_product_sold_count', 11 );
function wc_product_sold_count() {
global $product;
$units_sold = get_post_meta( $product->id, 'total_sales', true );
echo '<p>' . sprintf( __( 'Units Sold: %s', 'woocommerce' ), $units_sold ) . '</p>';
}
?>