Skip to content

Instantly share code, notes, and snippets.

View robert1112's full-sized avatar
🎯
Focusing

Robert C robert1112

🎯
Focusing
View GitHub Profile
@shakeeb-mts
shakeeb-mts / functions.php
Last active October 7, 2018 16:01
Merge Subscriptions
<?php
/**
* Remove woocommerce and woo-subscriptions delete actions.
* @return [type] [description]
*/
function mts_remove_delete_actions() {
remove_action( 'delete_user', 'WC_Subscriptions_Manager::trash_users_subscriptions' );
remove_action( 'deleted_user', 'wc_reset_order_customer_id_on_deleted_user' );
}
<?php
/**
* Add $number param to woocommerce-subscriptions.
*
* @param int (optional) An interval in the range 1-6
* @param string (optional) One of day, week, month or year. If empty, all subscription ranges are returned.
* @since 2.0
*/
function wcs_get_subscription_period_strings( $number = 1, $period = '' ) {
@swaters2858
swaters2858 / call-for-payment-information.php
Created January 16, 2018 16:55
wc-custom-payment-gateways-by-sam
<?php
// Make sure WooCommerce is active
if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) return;
//Adds Child Gateway Class
add_action( 'plugins_loaded', 'init_call_for_payment_info' );
function init_call_for_payment_info() {
class WC_Gateway_Call_for_Payment_Info extends WC_Payment_Gateway {
//Construct Gateway
@zveronline
zveronline / haproxy-cloudflare
Last active September 29, 2023 07:17 — forked from sielay/gist:0aa4077829f35f5e0310f9e0cc9fdc71
Haproxy - Capture client IP when behind CloudFlare or not. Also keep x-forwarded-for in logs
acl from_cf src -f /etc/haproxy/cf-ips
http-request set-src req.hdr(CF-Connecting-IP) if from_cf
option forwardfor if-none
@lukecav
lukecav / wordpress.conf
Last active January 10, 2023 13:44
Docker image with Nginx front-end for WordPress PHP-FPM image - Updated NGNIX config - includes updated expires headers, browser caching and Gzip enabled.
# WordPress single site rules.
# Designed to be included in any server {} block.
# This order might seem weird - this is attempted to match last if rules below fail.
# http://wiki.nginx.org/HttpCoreModule
location / {
try_files $uri $uri/ /index.php?$args;
}
# Add trailing slash to */wp-admin requests.
@ethanpil
ethanpil / wp-secure.conf
Created May 12, 2017 16:16
Wordpress Security for NginX
# wp-secure.conf
#
#
# This file includes common security considerations for wordpress using nginx.
#
# The goal is to block actions which are usually dangerous to wordpress.
# Additionally, we block direct access to PHP files and folders which should not
# be accessed directly from a browser.
#
# Also have included exceptions for plugins that are known to require this access.
@section-io-gists
section-io-gists / CustomMaintenancePage.vcl
Last active August 29, 2023 07:49
Varnish 4 - Custom maintenance page
import std;
acl whitelist {
"123.123.123.123";
"216.3.128.12";
}
sub vcl_recv {
# If not a whitelisted IP, then display maintenance page. Requires std library.
if(std.ip(regsub(req.http.X-Forwarded-For, "[, ].*$", ""), client.ip) !~ whitelist) {
@moskalukigor
moskalukigor / variable-subscription.php
Created March 17, 2017 14:22
Custom Variable Subscription (Radio Button)
<?php
/**
* Variable subscription product add to cart
*
* @author Prospress
* @package WooCommerce-Subscriptions/Templates
* @version 2.0.9
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
@pjv
pjv / functions.php
Last active October 9, 2018 18:22
put into functions.php to make WooCommerce cart default to choosing the cheapest shipping option
// https://github.com/woothemes/woocommerce/issues/3641
// http://stackoverflow.com/questions/36300773/woocommerce-programmatically-changing-the-default-shipping-method
// guts of function straight copy of function get_default_method from WC v. 2.5.5 includes/class-wc-shipping.php
function plx_default_cheapest_shipping_method( $current_chosen_method, $available_methods ) {
$selection_priority = get_option( 'woocommerce_shipping_method_selection_priority', array() );
if ( ! empty( $available_methods ) ) {
@corsonr
corsonr / functions.php
Created September 28, 2016 08:33
Display WooCommerce product variations dropdown select on the shop page
<?php
// Display variations dropdowns on shop page for variable products
add_filter( 'woocommerce_loop_add_to_cart_link', 'woo_display_variation_dropdown_on_shop_page' );
function woo_display_variation_dropdown_on_shop_page() {
global $product;
if( $product->is_type( 'variable' )) {