Skip to content

Instantly share code, notes, and snippets.

@danielbitzer
danielbitzer / file.php
Last active May 18, 2023 15:31
AutomateWoo - Action function to change subscription next payment date
<?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 December 21, 2023 22:55
Install PHP7.2 NGINX and PHP7.2-FPM on Ubuntu 16.04
########## 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 January 9, 2024 15:03
PHP Code Review Guidelines

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 December 11, 2023 15:34
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
<?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 December 7, 2015 19:01
Converts the WooCommerce country codes to 3-letter ISO codes
<?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 February 27, 2024 11:54
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.
<?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 21:58
Serve a subset of terms at /term-slug instead of /tag/term-slug
<?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 December 7, 2023 08:47
WooCommerce only ship to the continental US.
<?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 August 19, 2013 11:06
WooCommerce - Display checkout custom field on the order edition page
/**
* 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>';
}