Skip to content

Instantly share code, notes, and snippets.

View jaredwilli's full-sized avatar
🏄‍♂️

Jared Williams jaredwilli

🏄‍♂️
View GitHub Profile
@jaredwilli
jaredwilli / carrot.js
Created January 2, 2011 13:55
a framework in the making
(function() {
// Establish the root object, `window` in the browser, or `global` on the server.
var root = window.document;
var JL = function( selector, context ) {
// The JL object is actually just the init constructor 'enhanced'
return new JL.fn.init( selector, context );
},
// A simple way to check for HTML strings or ID strings
<?php
/**
* Custom Metabox for uploading post image attachments
* Created by Jared Williams - http://new2wp.com
*/
add_action( 'admin_init', 'add_attachment' );
add_action( 'save_post', 'update_attachment' );
add_action( 'post_edit_form_tag', 'form_multipart_encoding' );
//add_action( 'manage_posts_custom_column', 'product_custom_columns' );
//add_filter( 'manage_edit-product_columns', 'product_edit_columns' );
<?php
function update_attachment() {
global $post;
wp_update_attachment_metadata( $post->ID, $_POST['a_image'] );
if( !empty( $_FILES['a_image']['name'] )) {
require_once( ABSPATH . 'wp-admin/includes/file.php' );
$override['action'] = 'editpost';
$file = wp_handle_upload( $_FILES['a_image'], $override );
<?php
/**
* Name: Attachments Metabox Uploader
* Author: Jared Williams - http://new2wp.com
* Description: This is for adding a custom metabox to post types which enables you to add/remove
* post attachments that you can upload and enter the meta information for right on the edit page.
* Version: 0.1.0
*
* @usage: In order to add this to a post type you need to find the word 'product' and replace
* it with whatever the post type is you want to use it on.
///////////////////////////////////////////////////////////////////////////////////////////
// CODE TO ADD POST PER PAGE FILTER
///////////////////////////////////////////////////////////////////////////////////////////
add_filter( 'edit_posts_per_page', 'reorder_edit_posts_per_page', 10, 2 );
function reorder_edit_posts_per_page( $per_page, $post_type ) {
// CHECK USER PERMISSIONS
if ( !current_user_can('edit_others_pages') )
return;
$post_type_object = get_post_type_object( $post_type );
@jaredwilli
jaredwilli / nav-menu.js
Created February 10, 2011 14:48
WordPress navmenu sortable drag/drop script unpacked
var wpNavMenu;
(function (b) {
var a = wpNavMenu = {
options: {
menuItemDepthPerLevel: 30,
globalMaxDepth: 11
},
menuList: undefined,
targetList: undefined,
menusChanged: false,
/*!
* jQuery whenthen - v0.2 - 3/12/2011
* http://benalman.com/
*
* Copyright (c) 2011 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($){
@jaredwilli
jaredwilli / preloader.js
Created May 7, 2011 19:16 — forked from adamesque/preloader.js
Uses jQuery's new Deferred object to help with image loading
/**
* Helper function for passing arrays of promises to $.when
*/
jQuery.whenArray = function ( array ) {
return jQuery.when.apply( this, array );
};
/**
* Accepts a single image src or an array of image srcs.
@jaredwilli
jaredwilli / gist:1005782
Created June 3, 2011 02:55
get images from folder
<?php
$size = $_POST['size'] ? $_POST['size'] : 'm';
$dir = @dir( $_POST['dir'] . $size ) ? @dir( $_POST['dir'] . $size ) : @dir( 'images' . $size );
while(( $file = $dir->read() ) !== false ) {
return $file;
}
$dir->close();
?>
@jaredwilli
jaredwilli / gameengines.md
Created July 26, 2011 17:46 — forked from bebraw/gameengines.md
List of JS game engines. You can find a wikified version at https://github.com/bebraw/jswiki/wiki/Game-Engines. Feel free to modify that. I sync it here every once in a while.

IMPORTANT! Remember to check out the wiki page at https://github.com/bebraw/jswiki/wiki/Game-Engines for the most up to date version.

Name Latest Release Size (KB) License Type Unit Tests Docs Repository Notes
Akihabara 1.3.1 (2011/05) 453 GPL2, MIT Classic Repro no API github Intended for making classic arcade-style games in JS+HTML5
Aves Commer-cial Obsolete. Company bought by Zynga. E3 2010 Aves Engine Prototype "Suburban World"
bdge github Badly Design Game Engine, an HTML5 Javascript game engine [Demo](h