Skip to content

Instantly share code, notes, and snippets.

View Kevinlearynet's full-sized avatar

Kevinleary.net Kevinlearynet

View GitHub Profile
/**
* Woo: Custom Download View
*
* Enable custom download box from plugin, if plugin is de-activated
* fallback to woocommerce default.
*/
function rapid_mydownloads( $template, $slug, $name ) {
if ( $template == 'myaccount/my-downloads.php' && function_exists( 'rapid_show_custom_download_box' ) ) {
global $woocommerce;
rapid_show_custom_download_box();
@Kevinlearynet
Kevinlearynet / auth0-migration.php
Created July 8, 2014 14:28
WP Admin page to assist with a migration of users to Auth0 authentication and login
/**
* Auth0 Migration: Admin Page
*
* Provide a UI in the WP admin for migrating users to Auth0
*/
public function auth0_admin_page() {
// requires admin privledges
if ( current_user_can('manage_options') ) {
@Kevinlearynet
Kevinlearynet / _elements.html
Last active August 29, 2015 14:15
Static Site Engines with Node + Express Code Samples
# Elements
Fundamental building blocks of MIT Technology Review's digital styles.
## Doctype
{{ organization }} makes use of certain HTML elements and CSS properties that require the use of the HTML5 doctype. Include it at the beginning of all your projects.
### HTML
```html
<!DOCTYPE html>
<html lang="en">
@Kevinlearynet
Kevinlearynet / controller.js
Last active August 29, 2015 14:20
Hapi.js plugin to autoversion files based on when they last changed: `/file.js?v={mtime_timestamp}`
/**
* DFP Test Page Controller
*
* This pulls in the data we need to output
* a story URL
*
* @pattern /dfp/
*/
'use strict';
@Kevinlearynet
Kevinlearynet / gist:6f25c676f257b9acad79
Created May 7, 2015 16:09
Hapi's prerequisite methods
/**
* /in/profile/edit
*/
'edit': {
auth: {
mode: "try",
strategy: global.__config.cookie.strategy
},
plugins: {
"hapi-auth-cookie": {
.navbar__mobile-search__close {
display: none;
@include mq($nav-02) {
@include input-default;
display: block;
@include absolute(20px 20px n n);
@include size(20px);
background: #fff;
@Kevinlearynet
Kevinlearynet / meta-setup.php
Created March 16, 2012 18:59
Migrating existing custom field values into a meta box created with the WordPress WP Alchemy Meta Box Class
<?php
include_once( plugin_dir_path( __FILE__ ) . 'classes/MetaBox.php' );
include_once( plugin_dir_path( __FILE__ ) . 'classes/MediaAccess.php' );
$meta_boxname = new WPAlchemy_MetaBox( array(
'id' => '_boxname_meta',
'title' => 'Metabox Name',
'template' => plugin_dir_path( __FILE__ ) . 'meta-template.php',
'mode' => WPALCHEMY_MODE_EXTRACT,
) );
@Kevinlearynet
Kevinlearynet / widget-helper.php
Created September 13, 2012 13:13
These functions can be added to Matt Varone's widget helper class (https://github.com/sksmatt/WordPress-Widgets-Helper-Class) to add a Media Upload field to a WordPress widget
/**
* Load Media Upload Scripts
*
* Load the JS & CSS needed for the media upload field
*/
function enqueue_scripts() {
// Only load on widgets screen
$screen = get_current_screen();
if ( $screen->id != 'widgets' )
@Kevinlearynet
Kevinlearynet / template-curated-archive.php
Created October 10, 2012 12:55
Curated Content Query
<?php
/**
* Template Name: Around The Web
*
* The template for displaying a curated resources Archive.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package _s
* @since _s 1.0
@Kevinlearynet
Kevinlearynet / google-cdn-jquery-wordpress
Created October 10, 2012 14:50
Google CDN Hosted jQuery in WordPress
/**
* Google hosted jQuery
*/
function google_hosted_jquery( $src, $handle ) {
// Only run for jQuery
if ( $handle == "jquery" ) {
$parse_url = parse_url( $src );
$version = str_replace( 'ver=', '', $parse_url['query'] );
return "//ajax.googleapis.com/ajax/libs/jquery/$version/jquery.min.js";