Skip to content

Instantly share code, notes, and snippets.

😀
Happy

Micah Wood wpscholar

😀
Happy
Block or report user

Report or block wpscholar

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View vagrant-cheat-sheet.md

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

Creating a VM

  • vagrant init -- Initialize Vagrant with a Vagrantfile and ./.vagrant directory, using no specified base image. Before you can do vagrant up, you'll need to specify a base image in the Vagrantfile.
  • vagrant init <boxpath> -- Initialize Vagrant with a specific box. To find a box, go to the public Vagrant box catalog. When you find one you like, just replace it's name with boxpath. For example, vagrant init ubuntu/trusty64.

Starting a VM

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
@wpscholar
wpscholar / functions.php
Last active Sep 14, 2019
Enqueueing IE conditional stylesheets in WordPress the right way
View functions.php
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_my_styles' );
/**
* Example callback function that demonstrates how to properly enqueue conditional stylesheets in WordPress for IE.
* IE10 and up does not support conditional comments in standards mode.
*
* @uses wp_style_add_data() WordPress function to add the conditional data.
* @link https://developer.wordpress.org/reference/functions/wp_style_add_data/
@wpscholar
wpscholar / array-insert-after.php
Created Nov 7, 2015
Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended to the end of the array.
View array-insert-after.php
<?php
/**
* Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended
* to the end of the array.
*
* @param array $array
* @param string $key
* @param array $new
*
@wpscholar
wpscholar / webpack.config.js
Created Mar 14, 2019
Get started with WebPack in WordPress today!
View webpack.config.js
'use strict';
const autoprefixer = require('autoprefixer');
const browsers = require('@wordpress/browserslist-config');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
const webpack = require('webpack');
module.exports = function (env, options) {
@wpscholar
wpscholar / remote-media-loader.php
Last active Sep 3, 2019
Load media from a remote site so you don't have to download the uploads directory.
View remote-media-loader.php
<?php
/**
* Loads media from a remote site when on a local dev environment.
* Eliminates the need to download the uploads directory from the remote site for testing purposes.
*/
if ( 'mydomain.dev' === $_SERVER['HTTP_HOST'] ):
add_filter( 'upload_dir', function ( $uploads ) {
$uploads['baseurl'] = 'http://mydomain.com/wp-content/uploads';
@wpscholar
wpscholar / cloudSettings
Last active Aug 22, 2019
Visual Studio Code Settings
View cloudSettings
{"lastUpload":"2019-08-22T18:39:00.396Z","extensionVersion":"v3.2.9"}
@wpscholar
wpscholar / excerpt.php
Created Jan 10, 2014
Generate an excerpt from provided content. Strips HTML, removes trailing punctuation and adds a 'more' string when text has been removed.
View excerpt.php
<?php
/**
* Get an excerpt
*
* @param string $content The content to be transformed
* @param int $length The number of words
* @param string $more The text to be displayed at the end, if shortened
* @return string
*/
@wpscholar
wpscholar / .eslintignore
Last active Aug 18, 2019
Webpack 4 Config for WordPress plugin, theme, and block development
View .eslintignore
**/*.min.js
**/*.build.js
**/node_modules/**
**/vendor/**
build
coverage
cypress
node_modules
vendor
View jquery.download-pdf-links.js
@wpscholar
wpscholar / get-value.php
Last active Aug 6, 2019
Get a value from an object or an array. Allows the ability to fetch a nested value from a heterogeneous multidimensional collection using dot notation.
View get-value.php
<?php
/**
* Get a value from an object or an array. Allows the ability to fetch a nested value from a
* heterogeneous multidimensional collection using dot notation.
*
* @param array|object $data
* @param string $key
* @param mixed $default
* @return mixed
You can’t perform that action at this time.