Skip to content

Instantly share code, notes, and snippets.

View ChaseWiseman's full-sized avatar

Chase Wiseman ChaseWiseman

View GitHub Profile
@ChaseWiseman
ChaseWiseman / convert-post-meta.php
Last active December 27, 2015 09:50
A function for converting existing WordPress meta keys to new values.
/**
* Convert existing meta keys to new meta keys.
*
* @since x.x.x
*
* @global object $wpdb The current database.
*
* @param string $existing_key The existing meta key.
* @param string $new_key The new meta key.
* @param bool $remove_existing Optional. Whether to remove the old meta entries after conversion.
@ChaseWiseman
ChaseWiseman / load-modal.js
Last active November 23, 2019 17:02
Load modals as WordPress template parts via AJAX
$( function() {
var loadModal = function( modal ) {
$.post(
pinwheel_modals.ajax_url,
{
action: 'load_modal',
modal: modal
},
@ChaseWiseman
ChaseWiseman / phpcs.ruleset.xml
Created April 27, 2017 23:22
Sample SkyVerge WooCommerce coding standards
<?xml version="1.0"?>
<ruleset name="SkyVerge PHP Coding Standards">
<!-- See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
<!-- See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/blob/develop/WordPress-Core/ruleset.xml -->
<!-- Set a description for this ruleset. -->
<description>A custom set of code standard rules to check for WordPress themes and plugins.</description>
<!-- Include the WordPress ruleset, with exclusions. -->
<rule ref="WordPress">
<?php
/**
* Sets a unique Merchant ID depending on the order currency for Bambora transaction requests.
*
* @param array $request_data transaction request data
* @param \WC_Order $order order object
* @return array
*/
function sv_wc_bambora_set_currency_merchant_id( $request_data, $order ) {
@ChaseWiseman
ChaseWiseman / subcategory-madness.php
Created September 30, 2017 02:15
Subcategory madness
<?php // remove this if you don't need it
function riz_new_subcategory_hierarchy( $path ) {
$category = get_queried_object();
$parent_id = $category->category_parent;
if ( 123456 != $parent_id ) { // Your category ID
return $path;
<?php // Remove if not needed
/**
* Sets a dummy postcode if required by the CIM payment processor.
*/
function sv_wc_authorize_net_cim_set_uae_postcode( $data ) {
if ( ! empty( $data['billing_country'] ) && 'AE' === $data['billing_country'] ) {
$data['billing_postcode'] = '00000';
}
<?php // remove if not needed
add_filter( 'wc_first_data_payeezy_credit_card_perform_pre_auth', '__return_true' );
@ChaseWiseman
ChaseWiseman / plugin.php
Created August 3, 2018 23:41
WC Settings API Refactor
<?php
class WooCommerce {
public $settings;
public function init() {
// all that other fun init stuff
@ChaseWiseman
ChaseWiseman / disable-jilt-for-edd-js.php
Created February 25, 2020 18:33
Limit Jilt for EDD JS to logged-in users
<?php // only copy this line if needed
add_action( 'wp_enqueue_scripts', function() {
if ( ! is_user_logged_in() ) {
wp_dequeue_script( 'edd-jilt' );
}
}, 15 );
@ChaseWiseman
ChaseWiseman / woocommerce-twilio-sms-send-customer-notes.php
Last active April 21, 2020 01:20
Send SMS notifications to customers when a customer-facing note is added to an order
<?php // only include this if needed
/**
* Sends an SMS to the customer whenever a new customer note is added to an order.
*
* Customer notes usually trigger an email if enabled.
*/
add_action( 'woocommerce_new_customer_note', function( $args ) {
if ( ! class_exists( 'WC_Twilio_SMS_Notification' ) || empty( $args['order_id'] ) || empty( $args['customer_note'] ) ) {