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 / cloudSettings
Last active May 28, 2020
Visual Studio Code Settings
View cloudSettings
{"lastUpload":"2020-05-28T15:18:36.179Z","extensionVersion":"v3.4.3"}
@wpscholar
wpscholar / prevent-plugin-updates.php
Created May 19, 2020
A WordPress MU plugin that can prevent plugin updates for specific plugins.
View prevent-plugin-updates.php
<?php
add_filter(
'site_transient_update_plugins',
function ( $transient ) {
$plugins = array(
'wordpress-seo/wp-seo.php',
);
foreach ( $plugins as $plugin ) {
@wpscholar
wpscholar / post-content-shortcode.php
Created May 22, 2020
A simple plugin providing a shortcode that will output the post content for a specific post ID.
View post-content-shortcode.php
<?php
/**
* Post Content Shortcode
*
* @package PostContentShortcode
* @author Micah Wood
* @copyright Copyright 2020 by Micah Wood - All rights reserved.
* @license GPL2.0-or-later
*
* @wordpress-plugin
@wpscholar
wpscholar / wp-snapshot-shortcode.php
Last active May 20, 2020
Shortcode displays snapshots of remote sites on your WordPress site.
View wp-snapshot-shortcode.php
<?php
/**
* This shortcode will allow you to create a snapshot of a remote website and post it
* on your WordPress site.
*
* [snapshot url="http://www.wordpress.org" alt="WordPress.org" width="400" height="300"]
*/
add_shortcode( 'snapshot', function ( $atts ) {
$atts = shortcode_atts( array(
@wpscholar
wpscholar / single.php
Created May 8, 2020
A custom Stellar Places template to show nearby places.
View single.php
<?php
$place = Stellar_Places::get_place_object( get_post() );
$nearby = Stellar_Places::get_places(
array(
'post__not_in' => array( get_the_ID() ),
'geo_query' => array(
'lat' => $place->latitude,
'lng' => $place->longitude,
'distance' => 1,
),
View wp-rest-api-demo.php
<?php
/*
* Plugin Name: WP REST API Demo
* Plugin URI: https://gist.github.com/wpscholar/693517420ca6c9e29e7719ef24e7e00f
* Description: A developer plugin designed for playing around with the WordPress REST API.
* Version: 1.0
* Author: Micah Wood
* Author URI: https://wpscholar.com
* License: GPL2
@wpscholar
wpscholar / .eslintignore
Last active Apr 28, 2020
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
@wpscholar
wpscholar / install-xdebug.sh
Created Apr 19, 2020
Install xdebug from the command line.
View install-xdebug.sh
# Use homebrew to switch PHP versions, run this command for each version as needed:
pecl install xdebug
@wpscholar
wpscholar / create-admin-user.php
Last active Apr 16, 2020
Create a new admin user in WordPress via code. Drop this file in the mu-plugins directory and update the variables, then load a page in WordPress to create the user. Remove the file when done.
View create-admin-user.php
<?php
add_action( 'init', function () {
$username = 'admin';
$password = 'password';
$email_address = 'webmaster@mydomain.com';
if ( ! username_exists( $username ) ) {
$user_id = wp_create_user( $username, $password, $email_address );
You can’t perform that action at this time.