Skip to content

Instantly share code, notes, and snippets.

@danielbitzer
danielbitzer / file.php
Last active Oct 6, 2021
AutomateWoo - Action function to change subscription next payment date
View file.php
<?php
/**
* AutomateWoo action function to extend a subscription by 3 months.
*
* A note will be added to the subscription.
*
* Ensures that the dates near the end of the month are logically handled and do not shift to the start of the following month.
*
* Custom action function docs: https://automatewoo.com/docs/actions/custom-functions/
*
@GhazanfarMir
GhazanfarMir / Instructions.sh
Last active Nov 21, 2021
Install PHP7.2 NGINX and PHP7.2-FPM on Ubuntu 16.04
View Instructions.sh
########## Install NGINX ##############
# Install software-properties-common package to give us add-apt-repository package
sudo apt-get install -y software-properties-common
# Install latest nginx version from community maintained ppa
sudo add-apt-repository ppa:nginx/stable
# Update packages after adding ppa
@nerandell
nerandell / code-review-checklist.md
Last active Nov 12, 2021
PHP Code Review Guidelines
View code-review-checklist.md

Make sure these boxes are checked before submitting/approving the PR

General

  • The code works
  • The code is easy to understand
  • Follows coding conventions
  • Names are simple and if possible short
  • Names are spelt correctly
  • Names contain units where applicable
  • There are no usages of magic numbers
@carlodaniele
carlodaniele / kinsta-share-users.php
Last active Nov 8, 2021
A plugin to share users and usermeta tables between independent WordPress installations. This plugin requires CUSTOM_USER_TABLE and CUSTOM_USER_META_TABLE defined into wp-config file
View kinsta-share-users.php
<?php
/**
* @package Kinsta_Share_Users
* @version 1.0
*/
/*
Plugin Name: Kinsta Share Users
Plugin URI: http://wordpress.org/extend/plugins/#
Description: This is an example plugin for Kinsta blog readers
Author: Carlo Daniele
@helgatheviking
helgatheviking / kia_convert_country_code.php
Created Dec 7, 2015
Converts the WooCommerce country codes to 3-letter ISO codes
View kia_convert_country_code.php
<?php
/**
* Converts the WooCommerce country codes to 3-letter ISO codes
* https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
* @param string WooCommerce's 2 letter country code
* @return string ISO 3-letter country code
*/
function kia_convert_country_code( $country ) {
$countries = array(
'AF' => 'AFG', //Afghanistan
@wpscholar
wpscholar / create-admin-user.php
Last active Oct 11, 2021
Create a new admin user in WordPress via code. Drop this file in the mu-plugins directory and update the variables, then load a page in WordPress to create the user. Remove the file when done.
View create-admin-user.php
<?php
add_action( 'init', function () {
$username = 'admin';
$password = 'password';
$email_address = 'webmaster@mydomain.com';
if ( ! username_exists( $username ) ) {
$user_id = wp_create_user( $username, $password, $email_address );
@danielbachhuber
danielbachhuber / gist:c1554c1777dbb0460bfb
Created May 12, 2014
Serve a subset of terms at /term-slug instead of /tag/term-slug
View gist:c1554c1777dbb0460bfb
<?php
/**
* 'special-term' is a unique butterfly
*/
function dbx_get_special_terms() {
return array( 'special-term' );
}
/**
@BFTrick
BFTrick / woocommerce-only-ship-continental-us.php
Last active Aug 10, 2020
WooCommerce only ship to the continental US.
View woocommerce-only-ship-continental-us.php
<?php
/**
* Plugin Name: WooCommerce Only Ship to Continental US
* Plugin URI: https://gist.github.com/BFTrick/7805588
* Description: Only Ship to the Continental US
* Author: Patrick Rauland
* Author URI: http://patrickrauland.com/
* Version: 1.0.1
*
* This program is free software: you can redistribute it and/or modify
@woogist
woogist / gist:6267983
Created Aug 19, 2013
WooCommerce - Display checkout custom field on the order edition page
View gist:6267983
/**
* Display field value on the order edition page
**/
add_action( 'woocommerce_admin_order_data_after_billing_address', 'my_custom_checkout_field_display_admin_order_meta', 10, 1 );
function my_custom_checkout_field_display_admin_order_meta($order){
echo '<p><strong>'.__('My Field').':</strong> ' . $order->order_custom_fields['My Field'][0] . '</p>';
}