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
@wpscholar
wpscholar / buffer-to-stream.js
Created Oct 10, 2019
Convert a buffer to a stream in Node.js
View buffer-to-stream.js
/**
* Convert a buffer to a stream
*
* @param binary Buffer
* @returns Readable
*/
function bufferToStream(binary) {
return new Readable({
read() {
this.push(binary);
@wpscholar
wpscholar / base64.js
Created Oct 10, 2019
Utility functions for base64 encoding/decoding for buffers in Node.js
View base64.js
/**
* Take a file and convert to a base64 encoded string.
*
* @param buffer A Buffer instance.
* @returns {string} A base64 encoded string.
*/
function base64Encode(buffer) {
return new Buffer.from(buffer).toString('base64');
}
@wpscholar
wpscholar / disable-auto-generated-excerpts.php
Last active Sep 18, 2019
This plugin will prevent WordPress from automatically generating an excerpt when one is not explicitly set.
View disable-auto-generated-excerpts.php
<?php
/*
* Plugin Name: Disable Auto-Generated Excerpts
* Plugin URI: https://gist.github.com/wpscholar/8da60a1f2e1a89d07348491a11725597
* Description: This plugin will prevent WordPress from automatically generating an excerpt when one is not explicitly set.
* Version: 1.0
* Author: Micah Wood
* Author URI: https://wpscholar.com
* License: GPL2
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
View wp-rest-api-allow-all-cross-origin-requests.php
<?php
/*
* Plugin Name: WP REST API - Allow All CORS Requests
* Description: Adds headers to allow cross-origin requests to the WordPress REST API.
* Version: 1.0
* Plugin URI: https://gist.github.com/wpscholar/59f5708cba291a314375b2dedd104e1e
* Author: Micah Wood
* Author URI: https://wpscholar.com
*/
@wpscholar
wpscholar / wc-product-gallery-disable-zoom.php
Created May 29, 2019
Disable image zoom in the WooCommerce Product Gallery.
View wc-product-gallery-disable-zoom.php
@wpscholar
wpscholar / simple-website-redirect-not-homepage.php
Last active May 25, 2019
A plugin to extend the Simple Website Redirect plugin and prevent redirects from happening on the homepage.
View simple-website-redirect-not-homepage.php
<?php
/*
* Plugin Name: Simple Website Redirect - Don't redirect homepage
* Plugin URI: https://gist.github.com/wpscholar/122e6132b7ff58cc67019339283ca25a
* Description: A plugin to extend the Simple Website Redirect plugin and prevent redirects from happening on the homepage.
* Version: 1.0
* Author: Micah Wood
* Author URI: https://wpscholar.com
* License: GPL2
@wpscholar
wpscholar / config.yml
Created Apr 22, 2019
CircleCI Rsync Deployment
View config.yml
version: 2
jobs:
build_and_deploy:
docker:
- image: circleci/php:7.1-node-browsers
steps:
- checkout
- run: sudo apt update
- run: sudo apt-get install rsync
- run: sudo docker-php-ext-install zip
View ajax.js
var url = "";
var params = {
name: 'John',
email: 'webmaster@mysite.com'
};
var xhr = new XMLHttpRequest();
xhr.open('POST', url + '?' + buildQueryString(params));
@wpscholar
wpscholar / webpack.config.js
Last active Oct 20, 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) {
You can’t perform that action at this time.