Skip to content

Instantly share code, notes, and snippets.

View jasondavis's full-sized avatar

Jason Davis jasondavis

View GitHub Profile
@jasondavis
jasondavis / workflowy-with-image.js
Created July 15, 2016 04:03 — forked from dr2050/workflowy-with-image.js
workflowy-with-image.js
// ==UserScript==
// @name Workflowy markdown tags with images -> images
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://workflowy.com/*
// @grant none
// ==/UserScript==
@jasondavis
jasondavis / README.md
Created July 2, 2016 16:46 — forked from yckart/README.md
rawgit.com / rawgithub.com - Bookmarklet

A simple bookmarklet which makes our painful life a bit easier.

javascript:(function(b,a,c,d,e){if(/\.\w+$/.test(a))b.location=c+a.replace("/blob/","/");else if(e=prompt("Insert a filename:","index.html"))b.location=c+a.replace("/tree/","/")+(~a.indexOf(d)?"/":d)+e})(window,location.pathname,"http://rawgit.com","/master/");

The usage is quite simple:

Go to any repo where you like to preview a file, and execute the booklet. If the current url is a file, it should open the file directly, otherwise it will prompt for a filename (per default it is index.html).

@jasondavis
jasondavis / export-mysql.sql
Created July 2, 2016 01:21 — forked from paulund/export-mysql.sql
Make database import and export to remote server over SSH. When importing the file make sure it is on a location on the server. When exporting the file make sure you place it in the correct location.
mysqldump -p -u username -h hostname database_name > dbname.sql
@jasondavis
jasondavis / example-wp-list-table.php
Created July 2, 2016 01:04 — forked from paulund/example-wp-list-table.php
An example code of using the WP_List_Table class. With Pagination.
<?php
/*
* Plugin Name: Paulund WP List Table Example
* Description: An example of how to use the WP_List_Table class to display data in your WordPress Admin area
* Plugin URI: http://www.paulund.co.uk
* Author: Paul Underwood
* Author URI: http://www.paulund.co.uk
* Version: 1.0
* License: GPL2
*/
@jasondavis
jasondavis / wordpress-base-custom-data.php
Created July 1, 2016 23:08 — forked from paulund/wordpress-base-custom-data.php
A PHP class to handle CRUD functionality in WordPress default tables.
<?php
/**
* Abstract class which has helper functions to get data from the database
*/
abstract class Base_Custom_Data
{
/**
* The current table name
*
* @var boolean
@jasondavis
jasondavis / get_forms_list.php
Created June 21, 2016 18:17 — forked from mandava/get_forms_list.php
Get Forms List for Ninja Forms, Gravity Forms and Contact Form 7 WordPress Plugins
<?php
/** Ninja Forms */
function delight_ninja_forms() {
if ( function_exists('ninja_forms_get_all_forms') ) {
$nfs = ninja_forms_get_all_forms();
}
$nforms = array( '' => __('Select a Form', 'TEXT-DOMAIN') );
if( !empty( $nfs ) ) {
foreach($nfs as $form){
@jasondavis
jasondavis / model-order-meta.php
Created May 24, 2016 22:03 — forked from bradt/model-order-meta.php
Managing Custom Tables in WordPress
<?php
class WPAS_Model_Order_Meta extends WPAS_Model {
static $primary_key = 'order_id';
static function set_as_refunded( $order_id ) {
$data = array( 'is_refunded' => 1 );
$where = array( 'order_id' => $order_id );
self::update( $data, $where );
}
@jasondavis
jasondavis / filter_gf_select_optgroup.php
Created May 20, 2016 06:42 — forked from codearachnid/filter_gf_select_optgroup.php
Add the optgroup ability to Gravity Forms default select field.
/**
* Filter Gravity Forms select field display to wrap optgroups where defined
* USE:
* set the value of the select option to `optgroup` within the form editor. The
* filter will then automagically wrap the options following until the start of
* the next option group
*/
add_filter( 'gform_field_content', 'filter_gf_select_optgroup', 10, 2 );
function filter_gf_select_optgroup( $input, $field ) {
@jasondavis
jasondavis / wp-query-ref.php
Created May 20, 2016 03:37 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
@jasondavis
jasondavis / gist:098de8d2599e1e24ee04d9701f2a6108
Created April 20, 2016 06:12 — forked from da1nonly/gist:2057532
wordpress meta box urls
<?php
add_action('admin_init', 'add_meta_boxes', 1);
function add_meta_boxes() {
add_meta_box( 'repeatable-fields', 'Audio Playlist', 'repeatable_meta_box_display', 'post', 'normal', 'high');
}
function repeatable_meta_box_display() {
global $post;