Skip to content

Instantly share code, notes, and snippets.

Avatar

Peter Wise petertwise

View GitHub Profile
@petertwise
petertwise / acf-install-license
Last active Jun 2, 2021 — forked from polevaultweb/acf_pro_license_constant.php
Define the Advanced Custom Fields Pro license key with a constant
View acf-install-license
#!/bin/bash
# Setup ACF Pro to use a license key in wp-config
#
# 1. Place your license key in a file called .acf-license-key somewhere your ssh user has access to it.
# Default is in your home directory: ~/.acf-license-key
# Change the setting below if you need to put it somewhere else
# 2. install this file in /usr/local/bin or someplace in your PATH
# 3. make sure you have WP CLI installed
# 4. run acf-install-license from the root of your wordpress install
@petertwise
petertwise / git-updater-upgrade
Last active May 27, 2021
Upgrade from github-updater 9.x to git-updater 10.x and git-updater-pro
View git-updater-upgrade
#!/bin/bash
# Upgrade from github-updater 9.x to git-updater 10.x and git-updater-pro
# Instructions:
# 1. make sure you have WP CLI installed
# 2. install this file in /usr/local/bin or the executable path of your choice and make sure it has execute permissions
# 3. make a file called .gitupdater-download-link with the your personal download link and save it to /user/local/bin
# 4. make a file called .gitupdater-license-key with the your pro license key and save it to /user/local/bin
# 5. cd into your website's root dir and run `git-updater-upgrade`
View gist:e2ef15bea3bfa044e8b8ae528a3b31bf
a:1:{s:5:"4.7.0";a:3:{s:4:"list";a:675:{s:8:"fa-500px";s:14:" 500px";s:15:"fa-address-book";s:21:" address-book";s:17:"fa-address-book-o";s:23:" address-book-o";s:15:"fa-address-card";s:21:" address-card";s:17:"fa-address-card-o";s:23:" address-card-o";s:9:"fa-adjust";s:15:" adjust";s:6:"fa-adn";s:12:" adn";s:15:"fa-align-center";s:21:" align-center";s:16:"fa-align-justify";s:22:" align-justify";s:13:"fa-align-left";s:19:" align-left";s:14:"fa-align-right";s:20:" align-right";s:9:"fa-amazon";s:15:" amazon";s:12:"fa-ambulance";s:18:" ambulance";s:38:"fa-american-sign-language-interpreting";s:44:" american-sign-language-interpreting";s:9:"fa-anchor";s:15:" anchor";s:10:"fa-android";s:16:" android";s:12:"fa-angellist";s:18:" angellist";s:20:"fa-angle-double-down";s:26:" angle-double-down";s:20:"fa-angle-double-left";s:26:" angle-double-left";s:21:"fa-angle-double
@petertwise
petertwise / fitgittags
Created Nov 23, 2020
Script to fix mixed tags in 0.0.0 and v0.0.0 formats that cause issues with GitHub updater
View fitgittags
# Script to fix mixed tags in 0.0.0 and v0.0.0 formats that cause issues with GitHub updater
# modified from https://stackoverflow.com/a/25939259/947370
# Loop over tags
git tag -l | while read -r tag
do
# skip if it's already in v0.0.0 format
if [[ $tag == v* ]] ;
then
@petertwise
petertwise / give_anonymous_email_tag.php
Last active Jun 13, 2020 — forked from rickalday/give_anonymous_email_tag.php
GiveWP Anonymous Donation Email Tag
View give_anonymous_email_tag.php
<?php
// Plugin Name: GiveWP Add Email Tag for Anonymous Checkbox
function give_anonymous_email_tag( $email_tags ) {
// Adds an email tag called {give_anonymous_status} to indicate whether the donor opted in or not.
$email_tags[] = array(
'tag' => 'give_anonymous_status', // The tag name.
'desc' => __( 'This outputs whether the donor opted-in to the anonymous option', 'give' ), // For admins.
'func' => 'render_give_anonymous_status_email_tag', // Callback to function below.
'context' => 'donation',
);
@petertwise
petertwise / admin.js
Last active Jun 2, 2020
Improve Data Entry and Accessibility when WordPress ACF after_title field group area is used. Tab order is now natural and overrides the core WP javascript that moves the focus to the_content after #title.
View admin.js
// Admin Functions
( function( $ ) {
// better accessiblity and data entry for ACF
$(document).ready( function() {
// if there is a an "after_title" field group
if ( $( '#acf_after_title-sortables' ).length ) {
// listen for keydown inside the main title field for any add/edit screen
$('body.post-new-php, body.post-php').on( 'keydown', '#title', function( e ) {
var keyCode = event.keyCode || event.which;
// if the key is tab
View givewp stripe styles json
### Settings > Advanced > Stripe > Stripe Styles
#### Base Style
{
"color": "#333",
"fontWeight": "300",
"fontFamily": "Merriweather, serif",
"fontSize": "16px",
"letterSpacing": "0.5px",
@petertwise
petertwise / active-cpt-menu-trail.php
Last active May 6, 2020
On the single view of any WordPress custom post type item, make the archive menu item for that post type active
View active-cpt-menu-trail.php
<?php
// on the single view of any custom post type item, make the archive menu item for that post type active
// set the global scope variables
$current_menu_parent = null;
$current_menu_item = null;
// STEP 1: loop through all the menu items and find the current and parent items
function squarecandy_active_items_prepare( $classes ) {
@petertwise
petertwise / sync-remote
Created Oct 23, 2019
Bash Script to pull down WordPress database and files from a remote server
View sync-remote
#!/bin/bash
# BEFORE YOU START:
# replace all instances of exampleproject with your real project usernames and local and remote paths
# make a backup of current local db
wp db export --add-drop-table
echo "✅ Make a backup of your current database state."
@petertwise
petertwise / newsite.sh
Created Oct 23, 2019
A small script for quickly whipping up a new WordPress site on localhost
View newsite.sh
#!/bin/bash
# Don't forget to enter your own email on line 19 and user Sites dir path on line 20
# set the slug
read -p "Enter the slug for the new site:" SLUG
# set the mysql password
read -s -p "Enter a MySQL password:" MYSQLPASS
# setup the directory and basic settings