Skip to content

Instantly share code, notes, and snippets.

View wturnerharris's full-sized avatar

Wes Turner-Harris wturnerharris

View GitHub Profile
@wturnerharris
wturnerharris / xinitrc
Created January 20, 2015 20:35
X initialization script. This configures matchbox, resets chrome profile data, instructs the framebuffer to conform to explicit configuration, and starts an instance of chromium.
#!/bin/sh
while true; do
# Clean up previously running apps, gracefully at first then harshly
killall -TERM chromium 2>/dev/null;
killall -TERM matchbox-window-manager 2>/dev/null;
echo "Chrome and Matchbox terminated";
sleep 2;
killall -9 chromium 2>/dev/null;
@wturnerharris
wturnerharris / rc.local
Last active August 26, 2016 19:33
Multi-user runlevel script (rc.local) for rPi #1
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
@wturnerharris
wturnerharris / deploy.php
Last active October 3, 2016 04:18
This is a generic deployment script for pushing changes via github to a server. Use this with a github webhook. The script should produce deployment.log and deployment.html for any errors and html output respectively.
<?php
/**
* Auto Deployment Script for GitHub and Apache.
*
*
* @since deploy 0.1
*/
$auth = md5('SET_YOUR_SECRET'); // set a private hash to validate against, result is your github secret
$target_branch = 'staging'; // this is the absolute branch to track
@wturnerharris
wturnerharris / w3tc-mu.md
Last active May 21, 2021 18:48
Install procedures to enable W3TC as a WordPress MU (must-use) plugin.

###W3TC MU-Plugins Install

  1. ####Add Apache Rewrite Rule -> .htaccess:

    • RewriteRule ^wp-content/plugins/w3-total-cache(/.*|)$ /wp-content/mu-plugins/w3-total-cache$1 [L,NC]
  2. ####Add WP-Config Option -> wp-config.php:

    • define('W3TC_DIR', dirname(FILE).'/wp-content/mu-plugins/w3-total-cache');
  3. ####Add w3tc plugin -> mu-plugins/:

  • Upload entire plugin to mu-plugins/w3-total-cache/
@wturnerharris
wturnerharris / nav-walker.php
Last active November 25, 2021 05:41
Use custom walker to modify wp_nav_menu()
<?php
/* **** USAGE ****
* <?php wp_nav_menu( array(
* 'walker' => new custom_walker_nav_menu()
* )); ?>
*/
class custom_walker_nav_menu extends Walker {
var $tree_type = array( 'post_type', 'taxonomy', 'custom' );
@wturnerharris
wturnerharris / class-wp-profile-caps.php
Last active August 29, 2015 13:56
Class to display user capabilities in a table in the profile editor.
<?php
/**
* WP_Profile_Caps class.
*
*
* @package WP_Profile_Caps
* @since WP_Profile_Caps 0.1
*/
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
@wturnerharris
wturnerharris / functions.php
Created January 27, 2014 17:03
Override/Remove call to dynamic css in LaunchEffect: add to end of functions.php in main theme. In order to retain the css options for both premium and lite versions of LaunchEffect, you should first save the output from the dynamic css to the server and add as a link href in the Additional Scripts option of Launch Effect. <link rel="stylesheet"…
<?php
function return_void(){
exit;
}
add_action('wp_ajax_dynamic_css', 'return_void', 5);
add_action('wp_ajax_nopriv_dynamic_css', 'return_void', 5);
add_action('wp_ajax_dynamic_css_premium', 'return_void', 5);
add_action('wp_ajax_nopriv_dynamic_css_premium', 'return_void', 5);
@wturnerharris
wturnerharris / Hide_Gmail_Ads.js
Created January 11, 2014 19:52
Remove ad column from DOM in gmail and kill the remaining margin-right css property.
// ==UserScript==
// @name Hide Gmail Ads
// @namespace http://userscripts.org/users/540155
// @description Remove ad column from DOM in gmail and kill the remaining margin-right css property.
// @match https://mail.google.com/
// @include https://mail.google.com/*
// @include https://mail.google.com
// @grant GM_addStyle
// @version 0.1
// @copyright 2014+, You
@wturnerharris
wturnerharris / filter.thumbnail.functions.php
Created December 16, 2013 16:11
Filter function for WordPress: this adds an onload attribute onto the img element for calls that use the post_thumbnail_html filter such as get_the_post_thumbnail() or the_post_thumbnail()
/**
*
* Filter the post thumbnail html adding a javascript onload attribute.
*
* @param html(string)
* @return string
*/
function filter_thumbnail_html($html, $attr = false) {
if (empty($html)) return $html;
@wturnerharris
wturnerharris / wp_custom_admin.php
Created December 4, 2013 19:11
Custom admin implementation for WP backend. This snippet provides references to removing and adding backend pages as well as custom roles and capabilities.
class WP_Admin_Pages {
var $reset_roles = false,
$page_name = "member_approvals",
$board_votes = "board_votes";
function __construct() {
if ( ! function_exists( 'admin_url' ) ) return false;
if ( is_admin() ) {
add_action( 'init', array(&$this, 'rolescheck'));
add_action( 'admin_menu', array(&$this, 'add_admin_page'));