Skip to content

Instantly share code, notes, and snippets.

View leoken's full-sized avatar

Erik James Albaugh leoken

  • Maintain Web
  • Long Beach, CA
  • X @leoken
View GitHub Profile
@leoken
leoken / db.php
Created September 23, 2011 22:40 — forked from rahims/db.php
Code for a basic SMS voting system. Full write-up here: http://www.twilio.com/blog/2011/05/how-to-create-a-simple-sms-voting-system-using-php.html
<?php
class DB {
const DB_NAME = 'votes.sqlite';
protected $db;
function __construct() {
$this->db = new PDO('sqlite:'.self::DB_NAME);
}
@leoken
leoken / .gitignore
Created November 11, 2013 10:31 — forked from redoPop/.gitignore
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
<?php
/*
GeoRSS formatted output for Google Maps
Authors: Alastair Mucklow, Chris Toppon
*/
//header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
//$more = 1;
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'" standalone="yes"?'.'>'; ?>
<?php
/**
* Hook in on activation
*/
global $pagenow;
if ( is_admin() && isset( $_GET['activated'] ) && $pagenow == 'themes.php' ) add_action( 'init', 'yourtheme_woocommerce_image_dimensions', 1 );
/**
* Define image sizes
*/
import requests
import json
username = 'my-user'
apikey = 'my-api-key'
url = 'https://test.my-marconi-server.com:443'
class Queue_Connection(object):
def __init__(self, username, apikey):
@leoken
leoken / top_level_parent_class.php
Created April 4, 2013 10:03
adds a class to the top level parent of a page or post
<?php
function top_level_parent_class($classes) {
global $post;
if (is_page() && !$post->post_parent && !is_front_page()) {
$classes[] = 'page-top-parent';
}
return $classes;
}
add_filter('body_class', 'top_level_parent_class');
@leoken
leoken / get-grandparent__grandparent_body_class.php
Created April 4, 2013 09:50
Adds a Grand Parent class to the body
<?php
function get_grandparent($page_id) {
$current_page = get_page($page_id);
if ($current_page->post_parent > 0) {
$parent_page = get_page($current_page->post_parent);
if ($parent_page->post_parent > 0) {
return $parent_page->post_parent;
} else {
return false;
<?php
/**
* Add 'class="span4"' to all widgets in the Content Bottom sidebar
*/
function bb_content_bottom_widget_class($params) {
if ($params[0]['id'] == 'roots-content-bottom') {
$class = 'class="span4 ';
$params[0]['before_widget'] = preg_replace('/class=\"/', "$class", $params[0]['before_widget'], 1);
}
<?php
/**
* Display a thumbnail from YouTube based off the embed code saved in the
* video post format metabox used by the CF Post Formats plugin
*
* @link https://github.com/crowdfavorite/wp-post-formats
* @link http://stackoverflow.com/a/6382259
*/
global $post;