Skip to content

Instantly share code, notes, and snippets.

View daronspence's full-sized avatar

Daron daronspence

View GitHub Profile
@daronspence
daronspence / Custom-Taxonomy-Meta-Box.php
Last active February 11, 2016 23:40
Add code to custom taxonomy meta boxes
<?php
register_taxonomy( 'acme_custom_taxonomy', array( 'my_cpt', 'post' ), array(
'meta_box_cb' => 'acme_metabox_cb',
) );
function acme_metabox_cb( $post, $box ){
// Render the default hierarchical meta box form
post_categories_meta_box( $post, $box );
@daronspence
daronspence / pagination.php
Created January 27, 2016 22:50
WordPress Pagination Bar (1,2,3,4,...,87,88)
<?php
function pagination_bar() {
global $wp_query;
$total_pages = $wp_query->max_num_pages;
if ($total_pages > 1){
$current_page = max(1, get_query_var('paged'));
echo paginate_links(array(
<?php
// https://github.com/daverogers/serverpilot-php
require_once('serverpilot-php/lib/ServerPilot.php');
$clientid = "cid_XXXXXXXXX";
$apikey = "XXXXXXXXXXXXXX";
$appid = "XXXXXXXXXX";
$priv = trim(file_get_contents('/etc/letsencrypt/live/DOMAINNAME/privkey.pem'));
$cert = trim(file_get_contents('/etc/letsencrypt/live/DOMAINNAME/fullchain.pem'));
@daronspence
daronspence / showpassword.js
Last active December 14, 2015 21:50
Show Password for Active Field
(
function(){
document.activeElement.setAttribute('type', 'text');
}
)();
// Encoded // javascript:(function()%7Bdocument.activeElement.setAttribute('type'%2C 'text')%7D)()
@daronspence
daronspence / advent-of-code-day-4-part-2.js
Created December 6, 2015 05:07
Advent of Code Day 4 Part 2
// Crypto JS MD5 library was used. https://code.google.com/p/crypto-js/#MD5
var CryptoJS = require('./md5');
var MD5 = CryptoJS.Crypto.MD5;
var input = 'ckczppom';
var adventCoin = 0;
@daronspence
daronspence / advent-of-code-day-4-part-1.js
Last active December 9, 2015 18:09
Advent of Code - Day 4 Solution
// Crypto JS MD5 library was used. https://code.google.com/p/crypto-js/#MD5
var CryptoJS = require('./md5');
var MD5 = CryptoJS.Crypto.MD5;
var input = 'ckczppom';
var adventCoin = 0;
@daronspence
daronspence / custom-button.php
Created September 21, 2015 21:44
Custom button for WordPress post editor
<?php
// Callback function to insert 'styleselect' into the $buttons array
function prefix_mce_buttons( $buttons ) {
array_unshift( $buttons, 'styleselect' );
//var_dump($buttons);
return $buttons;
}
// Register our callback to the appropriate filter
// _2 places the new button on the second line
@daronspence
daronspence / payload-filter.php
Last active August 29, 2015 14:26
wpMandrill $payload Filter
<?php
# You'll need PHP 5.3+ to run this code as is. http://php.net/manual/en/functions.anonymous.php
// This action fires for an ajax event. Change it to whatever hook you need.
add_action( 'wp_ajax_todo_invite_friend', function(){
// We're only going to apply the filter when this specific action is triggered
add_filter( 'mandrill_payload', function( $payload ){
@daronspence
daronspence / invite.html
Created August 5, 2015 02:00
Mandrill ToDo Invite Template
<html>
<body>
<h2 mc:edit="title"></h2>
<p>
This message was generated from <a href="http://todo.daronspence.com/">ToDo App</a>. Come by and check out what we're all about :)
</p>
<div mc:edit="main""></div>
<?php
/*
Template Name: Restuarant Menu Template
*/
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">