Skip to content

Instantly share code, notes, and snippets.

View geilt's full-sized avatar

Alexander Conroy geilt

View GitHub Profile
@geilt
geilt / get_term_meta.php
Created May 9, 2013 08:09
get_term_meta
<?php
if(!function_exists('get_term_meta')):
function get_term_meta($term, $taxonomy, $key, $single = false ){
if(!$taxonomy && !$term):
return false;
endif;
if(!is_numeric($term)):
$term = get_term_by('slug', $term, $taxonomy);
$term = $term->term_id;
endif;
@geilt
geilt / theme_options.php
Created June 4, 2013 20:34
Theme Options Drop in
<?php
add_action( 'admin_init', 'theme_options_init' );
add_action( 'admin_menu', 'theme_options_add_page' );
/**
* Init plugin options to white list our options
*/
function theme_options_init(){
register_setting( 'ABTmedical_options', 'ABTmedical_theme_options', 'theme_options_validate' );
@geilt
geilt / registry.class.php
Created July 11, 2013 17:22
Registry Class
<?php
/**
* Registry
* Used as an Object Store of all Data used through a page load. It is a static class with a protected static variable.
* All Data is meant to be built off the registry that needs to be passed around instead of using Global Variables
* @package SimpulFramework
* @version 1.0
*/
class Registry{
protected static $object = array();
@geilt
geilt / database.class.php
Last active November 22, 2016 18:41
SimpulSections (Wordpress Post Type Database)
<?php
/**
* Database
* @package SimpulFramework
* @version 1.0
*/
//Start the Database Singleton. Yes I know they are evil.
try {
$dbh = new SimpulPDO_mySQL("mysql:host=" . DB_HOST . ";dbname=". DB_NAME, DB_USER, DB_PASSWORD);
$dbh->setAttribute( SimpulPDO_mySQL::ATTR_ERRMODE, SimpulPDO_mySQL::ERRMODE_EXCEPTION );
@geilt
geilt / grab-and-save.php
Created November 19, 2013 06:58
Grab and Save into folder based on category if we have a post_id and a category. Makes a category directory if it doesn't exist in uploads.
<?php
/*
Plugin Name: Grab & Save
Plugin URI: http://digitalmemo.neobie.net/grab-save
Author: Lim Kai Yang
Author URI: http://digitalmemo.neobie.net
Modified: @geilt
Modified On: 11/19/2013
Version: 1.0.4
Description: This plugin allows you to fetch the remote image and save to your local wordpress.
@geilt
geilt / api-controllers-DropboxController.js
Last active August 29, 2015 14:05
Sails Dropbox oAuth
var passport = require('passport'),
qs = require('querystring'),
request = require('request-promise');
module.exports = {
authenticate: passport.authenticate('dropbox'),
callback: passport.authenticate('dropbox', {
failureRedirect: '/options?' + qs.stringify({success: 'Dropbox failed authentication.'}),
successRedirect: '/options?' + qs.stringify({success: 'Dropbox connected.'})
}),
@geilt
geilt / gist:817ff32b20414ddd5a16
Created August 27, 2014 20:10
jQuery $.load into Variable.
var url = 'http://www.google.com';
var load = $('<div>');
var content = '';
load.load(url, function(result){
content = load.html();
});
@geilt
geilt / social-share.php
Last active December 6, 2021 19:18
Social Share
//Example with Wordpress
$url = get_the_permalink();
$image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumb' );
$description = get_the_excerpt();
$title = get_the_title();
echo get_share_link($url, $image, $title, $description, 'facebook');
echo get_share_link($url, $image, $title, $description, 'twitter');
echo get_share_link($url, $image, $title, $description, 'reddit');
@geilt
geilt / highlight-menu
Created September 12, 2014 17:25
Highlight a menu item based on URL. Modify to your needs
/**
* Highlight Current Menu Item
*/
var currentLocation = window.location.pathname;
$('#top-menu a').each( function(){
if( $(this).attr('href') == currentLocation ){
$(this).closest('li').addClass('active');
$(this).closest('.main_menu').addClass('active');
}
});
@geilt
geilt / gist:97889b63b1951d40bb4e
Last active August 29, 2015 14:06
Combining Tables in Waterline with Promises.
function findArgs(params, callback) {
params.args.sort = { key : 1, order: 0};
var type = '';
if(params.args.hasOwnProperty('type')) {
type = params.args.type;
delete params.args.type;
}
var finder = Meta.find(params.args)
.then( function(meta) {