Skip to content

Instantly share code, notes, and snippets.

View mboynes's full-sized avatar

Matthew Boynes mboynes

View GitHub Profile
@mboynes
mboynes / ks_timesheet.js
Created February 20, 2014 14:52
Global keyboard shortcut for the Bonus Time Redmine plugin
viewRmTimesheet = function() {
var timesheet_link = $('.bonus-time');
if (timesheet_link.length > 0) {
ks_dispatcher.go(timesheet_link.attr('href'));
}
}
if ( ks_dispatcher && ks_dispatcher.ks_managers && ks_dispatcher.ks_managers.length && ks_dispatcher.ks_managers[0] && ks_dispatcher.ks_managers[0].keys ) {
ks_dispatcher.ks_managers[0].keys.t = {
press: viewRmTimesheet.bind(this),
@mboynes
mboynes / functions.php
Created February 28, 2014 04:00
WPSE 135707
<?php
function add_video_post_type() {
$labels = array(
'name' => _x( 'Videos', 'Post Type General Name', 'kibble' ),
'singular_name' => _x( 'Video', 'Post Type Singular Name', 'kibble' ),
'menu_name' => __( 'Videos', 'kibble' ),
'parent_item_colon' => __( 'Parent Item:', 'kibble' ),
'all_items' => __( 'All Items', 'kibble' ),
@mboynes
mboynes / html_attributes.js
Last active August 29, 2015 13:57
Get html attributes from a given html tag
function get_html_attributes(s) {
var reg = /\s+([^\t\n\r\f \/>"'=]+)(?:\s*=\s*(['"])(.*?)\2)?/,attr = {};
while ((result = reg.exec(s)) !== null) {
attr[result[1]] = result[3];
s = s.replace(reg,'');
}
return attr;
}
<?php
/**
* Sidebar Picker
*/
if ( !class_exists( 'My_Sidebar_Picker' ) ) :
class My_Sidebar_Picker {
@mboynes
mboynes / user_recon.php
Last active August 29, 2015 14:01
Check a file of email addresses against the WP User database to see if they're in use or not. This is not part of a command; it can be added to any.
<?php
/**
* Check a file of email addresses against the user database to see if those
* email addresses are currently in use.
*
* ## OPTIONS
*
* <file>
* : The file of users to import.
@mboynes
mboynes / server.js
Created October 21, 2014 23:39
Simple node server
var http = require("http")
, url = require("url")
, path = require("path")
, fs = require("fs")
, qs = require('querystring')
, tasks = {}
, port = process.argv[2] || 8888
, next_id = 1
;
@mboynes
mboynes / wp
Created October 28, 2014 16:45
wp wrapper for vagrant
#!/bin/bash
ARGS="$@"
DIR=`pwd 2>&1`
if [[ $DIR == *www* ]]; then
if [[ $ARGS != *--url* ]]; then
SITE=`pwd | sed 's/.*\/www\///' | cut -d "/" -f 1 2>&1`
if [[ $SITE == "wordpress" ]]; then
ARGS="$ARGS --url=wp.dev"
elif [[ $SITE == "trunk" ]]; then
#!/bin/bash
# Testing changes
# Usage: ./distribute_user.sh [username] [role]
ARGS="$@"
echo "Adding user $1 as $2 to all sites"
SITES=$(wp site list --field=url --format=csv)
for site in $SITES
@mboynes
mboynes / codesniffer.ruleset.xml
Created March 20, 2015 15:42
WordPress Codesniffer ruleset starting point
<?xml version="1.0"?>
<ruleset name="WordPress Theme Coding Standards Configuration">
<!-- Set a description for this ruleset. -->
<description>Code standard rules to check against a WordPress Theme.</description>
<exclude-pattern>tests/*</exclude-pattern>
<exclude-pattern>inc/cli.php</exclude-pattern>
<!-- Include the WordPress VIP ruleset -->
<rule ref="WordPress-VIP">
@mboynes
mboynes / fieldmanager-demo-1.php
Last active August 29, 2015 14:19
Demo for fieldmanager.org
<?php
// put this in functions.php or an include file
add_action( 'fm_post_post', function() {
$fm = new Fieldmanager_Group( array(
'name' => 'contact_information',
'children' => array(
'name' => new Fieldmanager_Textfield( __( 'Name', 'your-domain' ) ),
'phone_number' => new Fieldmanager_Textfield( __( 'Phone Number', 'your-domain' ) ),
'website' => new Fieldmanager_Link( __( 'Website', 'your-domain' ) ),
),