Skip to content

Instantly share code, notes, and snippets.

View wturnerharris's full-sized avatar

Wes Turner-Harris wturnerharris

View GitHub Profile
<link rel="icon" type="image/x-icon" href="<?php bloginfo('template_url'); ?>/im/favicon.png"/>
<!--[if IE]><link rel="shortcut icon" href="path/to/favicon.ico"><![endif]-->
@wturnerharris
wturnerharris / deploy.php
Last active December 24, 2015 10:08
Auto-deployment script for php, github, apache.
<?php
/**
* Auto Deployment Script for GitHub and Apache.
*
*
* @since deploy 0.1
*/
$auth = md5('SECRET_PHRASE'); // set a private hash to validate against
if ( empty($_REQUEST['auth']) || $_REQUEST['auth'] != $auth) exit;
@wturnerharris
wturnerharris / class-membership.php
Last active February 15, 2019 12:46
Class to make things members-only in WordPress.--This class depends on a custom capability called 'is_approved_member' for user member access and the custom post meta key '_members_only' as a post-level custom field.
<?php
/**
* Custom class for WP_Membership routines.
*
*
* @package WP_Membership
* @since WP_Membership 0.1
*/
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
@wturnerharris
wturnerharris / class-rewrite-rules.php
Created November 11, 2013 13:52
This class is an example of how to add rewrite rules and the actions to take should the rewrite be matched.
<?php
/**
* WP_Theme_Rewrites Class for WordPress.
*
*/
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
exit("Do not access this file directly.");
class WP_Theme_Rewrites {
@wturnerharris
wturnerharris / class-backend-tables.php
Created November 11, 2013 14:29
This is an example of extending the default class for tables in the admin section, WP_List_Table. It does take some setup arguments, but works and looks seamlessly within WordPress.
<?php
if(!class_exists('WP_List_Table')) require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
/**
* Extended class for displaying a list of items in an HTML table.
*
* @usage
* // be sure to modify the display_rows function to customize the output of the rows
* $args = array(
@wturnerharris
wturnerharris / gateway-braintree.php
Created November 13, 2013 04:02
BrainTree extensions for Events Manager Pro Requires Braintree PHP libraries available via composer or direct download: https://www.braintreepayments.com/assets/client_libraries/php/braintree-php-2.23.1.tar.gz
<?php
if ( class_exists('EM_Gateway') ) :
class BraintreeGateway extends EM_Gateway {
var $gateway = 'braintree';
var $title = 'BrainTree';
var $status = 4;
var $status_txt = 'Processing (BrainTree)';
var $button_enabled = false;
var $supports_multiple_bookings = true;
@wturnerharris
wturnerharris / em-speaker.php
Created November 13, 2013 04:17
Added a new taxonomy for Events Manager, which facilitates adding Event Speakers to events. The taxonomy includes the title, description, and an image.
<?php
if( defined('EM_TAXONOMY_CATEGORY') ) {
define('EM_TAXONOMY_SPEAKER','event-speakers');
define('EM_TAXONOMY_SPEAKER_SLUG', 'event/speakers');
function parse_event_cat_query( ){
global $wp_query, $post;
if( is_tax(EM_TAXONOMY_SPEAKER)||is_tax(EM_TAXONOMY_CATEGORY) ){
unset($wp_query->query_vars['meta_query']);
@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'));
@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 / 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