Created
June 17, 2013 20:25
Revisions
-
isGabe revised this gist
Jun 17, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ /* * Basic WordPress Widget Code * Save to: /wp-content/theme/widgets.php * in functions.php or appropriate place: if ($wp_version >= 2.8) require_once(TEMPLATEPATH.'/widgets.php'); * */ class MyWidgetName extends WP_Widget -
isGabe created this gist
Jun 17, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ <?php /* * Basic WordPress Widget Code * Save to: /wp-content/theme/widgets.php * * */ class MyWidgetName extends WP_Widget { function MyWidgetName() { $widget_ops = array('classname' => 'MyWidgetName', 'description' => 'My Widget Description' ); $this->WP_Widget('MyWidgetName', 'My Widget Title', $widget_ops); } function form($instance) { $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); $title = $instance['title']; ?> <p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p> <?php } function update($new_instance, $old_instance) { $instance = $old_instance; $instance['title'] = $new_instance['title']; return $instance; } function widget($args, $instance) { extract($args, EXTR_SKIP); echo $before_widget; $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']); if (!empty($title)) echo '<h3 class="widget-title">' . $title . '</h3>'; // WIDGET CODE GOES HERE } } add_action( 'widgets_init', create_function('', 'return register_widget("MyWidgetName");') ); ?>