Skip to content

Instantly share code, notes, and snippets.

View bhubbard's full-sized avatar
:octocat:
Hello

Brandon Hubbard bhubbard

:octocat:
Hello
View GitHub Profile
@bhubbard
bhubbard / update-woo-order-billing-when-user-saves-address.php
Created May 12, 2021 18:46 — forked from zgordon/update-woo-order-billing-when-user-saves-address.php
Update WooCommerce Order Address Dynamically When Customer Updates Their Address
<?php
add_action( 'woocommerce_customer_save_address', 'jsforwp_update_address_for_orders', 10, 2 );
function jsforwp_update_address_for_orders( $user_id ) {
$customer_meta = get_user_meta( $user_id );
$customer_orders = get_posts( array(
'numberposts' => -1,
'meta_key' => '_customer_user',
<?php
/**
* Postmark Headers for Gravity Forms.
*
* @param [type] $email Email.
* @param [type] $message_format Message Format.
* @param [type] $notification Notification.
*/
function postmark_headers_for_gravityforms( $email, $message_format, $notification, $entry ) {
$entry_id = $entry['id'] ?? '';
https://gist.github.com/paulund/6687336
https://wpdatatables.com/crud-system-in-wordpress/
https://www.davidangulo.xyz/how-to-create-crud-operations-plugin-in-wordpress/
https://wpdataaccess.com/2020/04/08/how-to-use-wp-data-access-classes-in-your-own-php-code/
https://paulund.co.uk/crud-queries-for-wordpress-custom-tables
@bhubbard
bhubbard / upgrade_example.php
Created March 16, 2020 17:56
A better example of an upgrade file.
<?php
/* Exit if accessed directly. */
defined( 'ABSPATH' ) || exit;
// Require WordPress Upgrade.
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
function upgrade_v2() {
@bhubbard
bhubbard / google_cloud_functions.php
Created January 12, 2020 23:18
A simple class to trigger Google Cloud Functions.
<?php
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'Google_Cloud_Functions' ) ) {
/**
* Google Cloud Functions
*/
#!/usr/bin/env bash
command -v bc > /dev/null || { echo "bc was not found. Please install bc."; exit 1; }
{ command -v drill > /dev/null && dig=drill; } || { command -v dig > /dev/null && dig=dig; } || { echo "dig was not found. Please install dnsutils."; exit 1; }
NAMESERVERS=`cat /etc/resolv.conf | grep ^nameserver | cut -d " " -f 2 | sed 's/\(.*\)/&#&/'`
PROVIDERS="
@bhubbard
bhubbard / delete-orphans-usermeta.sql
Created April 8, 2019 19:51 — forked from carlosleopoldo/delete-orphans-usermeta.sql
Delete all orphans user meta in WordPress
DELETE FROM wp_usermeta
WHERE NOT EXISTS (
SELECT * FROM wp_users
WHERE wp_usermeta.user_id = wp_users.ID
)
#!/usr/bin/env bash
# purpose delete inactive WordPress themes
WPPATH=""
WPFLAGS="--path=${WPPATH} --skip-plugins --skip-themes --allow-root"
THEMEEXCEPTIONS=(
twentynineteen
)
.dataTables_info {
float:right;
margin-right:7px;
padding:10px;
}
.dataTables_paginate {
float:right;
height:28px;
margin-top:3px;
<?php
/**
* Portable PHP password hashing framework.
*
* @package phpass
* @since 2.5.0
* @version 0.3 / WordPress
* @link http://www.openwall.com/phpass/
*/