Skip to content

Instantly share code, notes, and snippets.

View chrisdc's full-sized avatar

Christopher Crouch chrisdc

View GitHub Profile
@chrisdc
chrisdc / Responsive-Order-Table.markdown
Created June 16, 2014 08:14
A Pen by Christopher Crouch.
@chrisdc
chrisdc / navigation.js
Last active June 16, 2016 15:39
An alternative navigation.js that makes dropdown menus keyboard accessible in _s.
/**
* navigation.js
*
* Handles toggling the navigation menu for small screens and enabling tab support for dropdown menus.
*/
( function() {
var container, button, menu, links;
container = document.getElementById( 'site-navigation' );
if ( ! container )
@chrisdc
chrisdc / plugin.php
Created July 31, 2014 12:51
Wordpress Plugin Template
<?php
/**
* Plugin Name: My Plugin
* Plugin URI: https://example.com/plugin/
* Description: An amazing WordPress plugin.
* Version: 1.0
* Author: [Author Name]
* Author URI: https://example.com/author/
* License: GPL2
* Text Domain: myplugin
@chrisdc
chrisdc / term-meta.php
Last active July 7, 2021 17:57
Add a custom meta box to the new/edit category pages. The meta data is saved to the array term_meta[], which can handle further fields in the future. Based on: https://pippinsplugins.com/adding-custom-meta-fields-to-taxonomies/
<?php
/**
* Add a custom meta box to the new/edit category pages.
* The meta data is saved to the array term_meta[], which can handle further
* fields in the future.
*
* Based on: https://pippinsplugins.com/adding-custom-meta-fields-to-taxonomies/
*/
/**
@chrisdc
chrisdc / navigation.js
Last active November 2, 2018 19:49
Object Orientated navigation.js
( function() {
function Menu( containerId, options ) {
var container,
menu,
button;
function init() {
container = document.getElementById( containerId );
if ( ! container ) {
@chrisdc
chrisdc / events.js
Last active August 29, 2015 14:08
Publish/subscribe module
/**
* A simple Publish/subscribe javascript module based on code by David Walsh:
* http://davidwalsh.name/pubsub-javascript
*/
var events = (function(){
// Holds the subscribed topics.
var topics = {};
return {
subscribe: function( topic, callback ) {
@chrisdc
chrisdc / .jscsrc
Last active November 2, 2018 19:48
Options file for JSCS
{
"disallowKeywordsOnNewLine": ["else"],
"disallowMixedSpacesAndTabs": "smart",
"disallowNewlineBeforeBlockStatements": true,
"disallowSpaceAfterObjectKeys": true,
"disallowSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"disallowTrailingWhitespace": true,
"requireBlocksOnNewline": true,
@chrisdc
chrisdc / gist:e99763a1d9da1aaf99a1
Last active August 29, 2015 14:23
Bootstrap Template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap Template</title>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
@chrisdc
chrisdc / Vagrantfile
Created March 1, 2016 00:06
Vagrant Setup
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 80, host: 8080
@chrisdc
chrisdc / log-message.js
Created September 24, 2018 10:31
Mocking globals in Jest.
function logMessage(message) {
console.log(message);
}
module.exports = logMessage