37 lines
1.4 KiB
PHP
37 lines
1.4 KiB
PHP
<?php
|
|
class SportsPress_Widget_Events_Calendar extends WP_Widget {
|
|
|
|
function __construct() {
|
|
$widget_ops = array('classname' => 'widget_calendar widget_sp_events_calendar', 'description' => __( 'A calendar of events.', 'sportspress' ) );
|
|
parent::__construct('sp_events_calendar', __( 'SportsPress Events Calendar', 'sportspress' ), $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">';
|
|
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:', 'sportspress' ); ?></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
|
|
}
|
|
}
|
|
add_action( 'widgets_init', create_function( '', 'return register_widget( "SportsPress_Widget_Events_Calendar" );' ) );
|