Skip to content

Instantly share code, notes, and snippets.

View ericandrewlewis's full-sized avatar

Eric Lewis ericandrewlewis

View GitHub Profile
View gist:2969986
<?php
function prettybox($class, $func_name) {
echo '<div class="' . $class . '">';
call_user_func($func_name);
echo '</div>';
}
function main_page() {
@ericandrewlewis
ericandrewlewis / gist:3013007
Created June 28, 2012 18:14
Plugin bootstrapper with theme check
View gist:3013007
<?php
function bootstrapper() {
$theme = get_theme( get_current_theme() );
if ( $theme['Template'] !== 'your-theme' )
add_action( 'admin_notices', 'wrong_theme_notice' );
else
plugin_init();
View gist:3090793
function get_image_id_like_genesis_does() {
if ( has_post_thumbnail() )
$id = get_post_thumbnail_id();
else
$id = genesis_get_image_id( 0 );
return $id;
}
View gist:3106669
<VirtualHost *:80>
DocumentRoot "/Users/ericlewis/Sites/badgestack"
ServerName badgestack.dev
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/ericlewis/Sites/badgestack"
ServerName wcet.badgestack.dev
</VirtualHost>
View gist:3129529
// Accepts a UTC timestamp and outputs the Badgestack desired formatting
// in the locally set timezone based on the WP settting
function get_timestamp_locally_modified($timestamp) {
$date = new DateTime($timestamp, new DateTimeZone('UTC'));
date_timezone_set( $date, new DateTimeZone( get_option('timezone_string') ) );
$timestamp = $date->format( 'F j, Y \a\t h:ia' );
return $timestamp;
}
View gist:3437094
if ( $item_id
&& in_array( $item_id, $wds_class_game_items )
&& in_array( $author_id, $group_members )
&& ( ! $_GET['from_id']
|| $student_for == $_GET['from_id']
|| in_array( $_GET['from_id'], $students_nominated )
)
&& ( $view == 'all'
|| $view == $this_status
)
View gist:3498898
<?php
add_action('init', 'register_gallery_endpoint');
function register_gallery_endpoint() {
add_rewrite_endpoint( 'gallery', EP_PERMALINK );
}
add_action('template_redirect', 'catch_gallery_endpoint');
View gist:3698972
if ( $debug )
echo 1;
while ( $row = @mysql_fetch_object( $this->result ) ) {
$this->last_result[$num_rows] = $row;
$num_rows++;
}
if ( $debug )
echo 2;
View gist:3801007
foreach ( $stuff as $stuff_key => $bits ) {
foreach ( $bits as $bit_key => $bit ) {
$new[$bit_key][$stuff_key] = $bit;
}
}
View gist:3828659
Copyright 2012 Eric Lewis
Version: @@ver@@ Timestamp: @@timestamp@@
This software is licensed under the Apache License, Version 2.0 (the "Apache License") or the GNU
General Public License version 2 (the "GPL License"). You may choose either license to govern your
use of this software only upon the condition that you accept all of the terms of either the Apache
License or the GPL License.
You may obtain a copy of the Apache License and the GPL License in the LICENSE file, or at: