Move calendar into its own widget
This commit is contained in:
36
admin/widgets/calendar.php
Normal file
36
admin/widgets/calendar.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
class SportsPress_Widget_Calendar extends WP_Widget {
|
||||
|
||||
function __construct() {
|
||||
$widget_ops = array('classname' => 'widget_calendar sp_widget_calendar', 'description' => __( 'A calendar of your site’s Events.') );
|
||||
parent::__construct('sp_calendar', __('Events Calendar'), $widget_ops);
|
||||
}
|
||||
|
||||
function widget( $args, $instance ) {
|
||||
extract($args);
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
|
||||
echo $before_widget;
|
||||
if ( $title )
|
||||
echo $before_title . $title . $after_title;
|
||||
echo '<div id="calendar_wrap sp_calendar_wrap">';
|
||||
echo sportspress_events_calendar();
|
||||
echo '</div>';
|
||||
echo $after_widget;
|
||||
}
|
||||
|
||||
function update( $new_instance, $old_instance ) {
|
||||
$instance = $old_instance;
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
function form( $instance ) {
|
||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
|
||||
$title = strip_tags($instance['title']);
|
||||
?>
|
||||
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
|
||||
<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); ?>" /></p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user