Skip to content

Instantly share code, notes, and snippets.

Jon Christopher jchristopher

Block or report user

Report or block jchristopher

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jchristopher
jchristopher / ITI_Widget_Image_OTM.php
Created Feb 4, 2012
Basic instantiation of an "Image of the Month" WordPress Widget
View ITI_Widget_Image_OTM.php
<?php
// we can only use this Widget if the plugin is active
if( class_exists( 'WidgetImageField' ) )
add_action( 'widgets_init', create_function( '', "register_widget( 'ITI_Widget_Image_OTM' );" ) );
class ITI_Widget_Image_OTM extends WP_Widget
{
var $image_field = 'image'; // the image field ID
@jchristopher
jchristopher / gist:1739100
Created Feb 4, 2012
The form() for our Image of the Month Widget
View gist:1739100
<?php
function form( $instance )
{
$headline = esc_attr( isset( $instance['headline'] ) ? $instance['headline'] : '' );
$image_id = esc_attr( isset( $instance[$this->image_field] ) ? $instance[$this->image_field] : 0 );
$blurb = esc_attr( isset( $instance['blurb'] ) ? $instance['blurb'] : '' );
$image = new WidgetImageField( $this, $image_id );
?>
@jchristopher
jchristopher / gist:1739167
Created Feb 4, 2012
The update() for our Image of the Month Widget
View gist:1739167
<?php
function update( $new_instance, $old_instance )
{
$instance = $old_instance;
$instance['headline'] = strip_tags( $new_instance['headline'] );
$instance[$this->image_field] = intval( strip_tags( $new_instance[$this->image_field] ) );
$instance['blurb'] = strip_tags( $new_instance['blurb'] );
@jchristopher
jchristopher / gist:1739179
Created Feb 4, 2012
The widget() function for our Image of the Month Widget
View gist:1739179
<?php
function widget( $args, $instance )
{
extract($args);
$headline = $instance['headline'];
$image_id = $instance[$this->image_field];
$blurb = $instance['blurb'];
@jchristopher
jchristopher / gist:1739212
Created Feb 4, 2012
Our final Image of the Month WordPress Widget
View gist:1739212
<?php
// we can only use this Widget if the plugin is active
if( class_exists( 'WidgetImageField' ) )
add_action( 'widgets_init', create_function( '', "register_widget( 'ITI_Widget_Image_OTM' );" ) );
class ITI_Widget_Image_OTM extends WP_Widget
{
var $image_field = 'image'; // the image field ID
@jchristopher
jchristopher / home.php
Created Feb 27, 2012
Handlebars.js & WordPress Templates - Home
View home.php
<?php
/* Template Name: Home */
global $post;
global $handlebars;
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'handlebars',
get_bloginfo( 'stylesheet_directory' ) . '/js/handlebars.js',
@jchristopher
jchristopher / team-member-spotlight.php
Created Feb 27, 2012
Handlebars.js & WordPress Templates - Team Member Spotlight
View team-member-spotlight.php
<?php global $handlebars; ?>
<?php if( !$handlebars && has_post_thumbnail() ) : ?>
<?php $headshot = wp_get_attachment_image_src( get_post_thumbnail_id(), 'thumbnail' ); ?>
<img src="<?php echo $headshot[0]; ?>" alt="Headshot" class="alignleft" />
<?php elseif( $handlebars ) : ?>
{{#if headshot}}
@jchristopher
jchristopher / gist:1923303
Created Feb 27, 2012
Handlebars.js & WordPress Templates - Handlebars Template
View gist:1923303
<script id="team-member-spotlight-template" type="text/x-handlebars-template">
{{#if headshot}}
<img src="{{headshot}}" alt="Headshot of {{name}}" class="alignleft" />
{{/if}}
<h3>{{name}}</h3>
<p><a href="{{permalink}}">View more details</a></p>
</script>
@jchristopher
jchristopher / team.php
Created Feb 27, 2012
Handlebars.js & WordPress Templates - Team Page Template
View team.php
<?php
/* Template Name: Team */
global $post;
// if it's an ajax request, return our JSON
if( isset( $_POST['ajax'] ) )
{
$args = array(
@jchristopher
jchristopher / class-iti-cap-limiter.php
Created Mar 7, 2012
[WordPress] Prevents the creation of full Administrators by client accounts
View class-iti-cap-limiter.php
<?php
/**
* Prevents the creation of full Administrators by client accounts
* Forked from JPB_User_Caps (unable to locate origin)
*
* @return void
* @author Jonathan Christopher
*/
if( is_admin() )
You can’t perform that action at this time.