Skip to content

Instantly share code, notes, and snippets.

View wpscholar's full-sized avatar
😀
Happy

Micah Wood wpscholar

😀
Happy
View GitHub Profile
@wpscholar
wpscholar / remember-me.php
Created January 21, 2020 15:44
By default, WordPress will log you out when you close your browser. If you check 'Remember Me' WordPress will keep you logged in for 2 weeks. Your web browser stores a cookie that WordPress checks to see if you are logged in. It is possible to set the expiration for that cookie for longer than 2 weeks when a user checks the 'Remember Me' option.…
<?php
add_filter( 'auth_cookie_expiration', function() {
return 31556926; // 1 year in seconds
} );
<?php
/*
* Plugin Name: Auto-Redirect Root-Level Posts
* Plugin URI: https://gist.github.com/wpscholar/d37736b1b9c2439acf2289364e210bc5
* Description: Automatically redirects root level posts (e.g. /my-blog-post) to the new location (e.g. /blog/my-blog-post). Use anytime you update your post permalink structure from root-level to use a subdirectory prefix.
* Version: 1.0
* Author: Micah Wood
* Author URI: https://wpscholar.com
* License: GPL2
@wpscholar
wpscholar / buffer-to-stream.js
Created October 10, 2019 20:27
Convert a buffer to a stream in Node.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 October 10, 2019 20:26
Utility functions for base64 encoding/decoding for buffers in Node.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 September 18, 2019 14:11
This plugin will prevent WordPress from automatically generating an excerpt when one is not explicitly set.
<?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
<?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
<?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 13:22
Disable image zoom in the WooCommerce Product Gallery.
@wpscholar
wpscholar / simple-website-redirect-not-homepage.php
Last active May 25, 2019 14:49
A plugin to extend the Simple Website Redirect plugin and prevent redirects from happening on the homepage.
<?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 April 22, 2019 23:48
CircleCI Rsync Deployment
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