Skip to content

Instantly share code, notes, and snippets.

View wturnerharris's full-sized avatar

Wes Turner-Harris wturnerharris

View GitHub Profile
@wturnerharris
wturnerharris / mysql_procedure_loop_ids_and_insert.sql
Created April 17, 2019 16:25
Here's a mysql stored procedure to loop through the results of a select query that returns ids and performs an additional operation on each id.
DROP PROCEDURE IF EXISTS migrateById;
DELIMITER $$
CREATE PROCEDURE migrateById()
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE _post_id INT;
DECLARE migrate_ids CURSOR FOR
# modify the select statement to returns IDs, which will be assigned the variable `_post_id`
EXCLUDED_IDS = [
1234567890
]
DISCOUNT_CODE = "DISCOUNT_CODE"
DISCOUNT_PERCENTAGE = 0.70
discount = Input.cart.discount_code
if discount and discount.code == DISCOUNT_CODE
Input.cart.line_items.each do |line_item|
@wturnerharris
wturnerharris / update_postmeta_loop.sql
Created October 26, 2018 21:28
Stored procedure to migrate some meta fields to mapped ACF fields
DROP PROCEDURE IF EXISTS STEPBYSTEP;
DELIMITER ;;
CREATE PROCEDURE STEPBYSTEP()
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE POST_ID INT DEFAULT 0;
DECLARE cursor_results CURSOR FOR SELECT ID FROM wp_posts WHERE post_type = 'press_materials';
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN cursor_results;
@wturnerharris
wturnerharris / sf-prepare.sh
Created July 18, 2018 19:17
Prepare hotfix/release for gitflow, includes auto changelog, auto versioning, replacing style version
#!/bin/bash
####################################################################
## This prepare script is usually for finishing a release or hotfix.
##
## Assumptions: the hotfix/release branch has already been created.
## To start the hotfix/release, run with -s=yes
##
## From the hotfix/v0.0.0 or release/v0.0.0 branch, this script:
## - Updates the Changelog (automatically with commit messages)
@wturnerharris
wturnerharris / video-page.liquid
Last active July 16, 2018 14:48
Video Module
{% if video_url != blank %}
{% include 'video',
class: 'about__background__video',
url: video_embed,
loader: false
%}
{% endif %}
@wturnerharris
wturnerharris / footer with newsletter module include
Created March 27, 2018 19:46
Footer newsletter with Gravity Forms
@wturnerharris
wturnerharris / clean.sh
Created March 19, 2018 19:53
Setup process for a theme managed on WPE, without tracking entire WP install
#!/bin/bash
rm -rf *
git reset --hard HEAD
@wturnerharris
wturnerharris / gfaddon.php
Last active December 19, 2017 23:27
GF Addon Snippet using gform_post_payment_action
<?php
class GFDonorPerfectAddon extends GFFeedAddOn {
public function init() {
parent::init();
add_action( 'gform_post_payment_action', array( $this, 'post_payment_action_hook' ), 10, 2 );
}
@wturnerharris
wturnerharris / .bash_alias
Last active April 10, 2019 00:32
Some helpful bash aliases
#!/bin/bash
adduser()
{
if [ -z "$1" ] # Is parameter #1 zero length?
then
echo "-Parameters are zero length.-" # Or no parameter passed.
else
echo "-Parameter #1 is \"$1\".-"
fi
#!/bin/bash
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar --info
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
wp --info