Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created February 4, 2012 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jchristopher/1739071 to your computer and use it in GitHub Desktop.
Save jchristopher/1739071 to your computer and use it in GitHub Desktop.
Basic instantiation of an "Image of the Month" WordPress Widget
<?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
function __construct()
{
$widget_ops = array(
'classname' => 'image_otm',
'description' => __( 'Image of the Month' )
);
parent::__construct( 'image_otm', __( 'Image of the Month' ), $widget_ops );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment