Skip to content

Instantly share code, notes, and snippets.

Craig Wayne craigiswayne

View GitHub Profile
craigiswayne / cssFromElement.js
Last active Apr 18, 2019
Extract all computed css from an element
View cssFromElement.js
function getAllCSS(element){
if( !element instanceof HTMLElement ){
console.warn("Select a valid HTML Element before proceeding");
return '';
let cssString = '';
const cssObj = window.getComputedStyle(element);
let cssAttributes = [];
craigiswayne /
Created Jan 26, 2019
Batch Create WordPress Posts via wp-cli
# Creates 30 dummy posts with featured images via
for i in {1..31}
echo "Creating $POST_TYPE_SINGULAR_NAME i = [$i]";
post_id=$(wp post create --post_name="Entrant $i" --post_title="Entry $i" --post_type="$POST_TYPE_SLUG" --post_status=publish --post_author=1 --post_date="1987-10-$i 00:00:00" --porcelain --allow-root);
echo "post_id = [$post_id]";
craigiswayne /
Last active Nov 3, 2018
Gravity Forms Post Image Upload Preview

Gravity Forms Post Image Upload Preview

This is the snippet I use for immediately previewing an image loaded with gravity forms post type

var fileInputImageUploader = fileInputImageUploader || {};

Object.assign( fileInputImageUploader, {
  options: {
    inputSelector: 'form input[type=file]',
craigiswayne /
Last active Oct 28, 2018
Create WordPress Posts with Featured Images from WP-CLI
for i in {1..20}
post_title="$post_type_singular $i";
post_id=$(wp post create --post_author=admin --post_type=$post_type --post_status=publish --post_content="$post_title Content" --post_title="$post_title" --post_excerpt="$post_title Excerpt" --porcelain);
wp media import "$i.jpeg" --post_id=$post_id --title="Random Image for $post_title" --caption="$post_title Caption" --alt="$post_title Alternative Text" --desc="$post_title Desciption" --featured_image;
craigiswayne / functions.php
Created Sep 20, 2018
How to Render YouTube Video in WordPress (given the URL)
View functions.php
$ytURL =;
echo wp_oembed_get( $ytURL );
craigiswayne /
Last active Jan 29, 2019
Install WP-CLI, Composer and Imagick on Digital Ocean WordPress Droplet (Ubuntu 16)
echo "Installing WP-CLI...";
curl -O
php wp-cli.phar --info
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
echo "Installing Composer...";
sudo apt-get update;
sudo apt-get install curl php-cli php-mbstring git unzip -y;
cd ~;
craigiswayne / composer.json
Last active Oct 8, 2018
Requiring non composer package in composer
View composer.json
"repositories": [
"type": "package",
"package": {
"name": "vendor-name/package-name",
"version": "dev-master",
"type": "library",
"source": {
"url": "",
"type": "git",
craigiswayne / Gravity_Boots.php
Created Jul 10, 2018
Bootstrap 3 styles for Gravity Forms
View Gravity_Boots.php
if( !is_admin() && class_exists('\DOMDocument' ) ){
* Checks if a gravity form has been submitted
* @return bool
function form_submitted(){
return isset( $_POST['gform_submit'] ) && '1' === $_POST['gform_submit'];
craigiswayne /
Last active Jun 25, 2018
Debugging the function
* Debugging function
* Overwrites the origin function so that you can see the call stack
* And debug variables
* @see
*/ = function( URL, name, specs, replace ){"Debugging the function");
console.log("URL : " + URL);
console.log("name : " + name);
craigiswayne /
Created Jun 8, 2018
How i tried to test my Travis Build Locally (for PHP)

How i tried to test my Travis Build Locally (for PHP)

TLDR; didn't work

docker run --name travis-debug -dit travisci/ci-garnet:packer-1512502276-986baf0 /sbin/init
docker exec -it travis-debug bash -l

From inside the docker container

You can’t perform that action at this time.