Add actions and filters to widgets
This commit is contained in:
@@ -20,7 +20,15 @@ class SP_Widget_Event_Blocks extends WP_Widget {
|
||||
echo $before_widget;
|
||||
if ( $title )
|
||||
echo $before_title . $title . $after_title;
|
||||
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_before_widget_template', $args, $instance, 'event-blocks' );
|
||||
|
||||
sp_get_template( 'event-blocks.php', array( 'id' => $id, 'status' => $status, 'date' => $date, 'date_from' => $date_from, 'date_to' => $date_to, 'number' => $number, 'order' => $order, 'show_all_events_link' => $show_all_events_link ) );
|
||||
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_after_widget_template', $args, $instance, 'event-blocks' );
|
||||
|
||||
echo $after_widget;
|
||||
}
|
||||
|
||||
@@ -36,6 +44,9 @@ class SP_Widget_Event_Blocks extends WP_Widget {
|
||||
$instance['order'] = strip_tags($new_instance['order']);
|
||||
$instance['show_all_events_link'] = $new_instance['show_all_events_link'];
|
||||
|
||||
// Filter to hook into
|
||||
$instance = apply_filters( 'sportspress_widget_update', $instance, $new_instance, $old_instance, 'event-blocks' );
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
@@ -50,7 +61,10 @@ class SP_Widget_Event_Blocks extends WP_Widget {
|
||||
$number = intval($instance['number']);
|
||||
$order = strip_tags($instance['order']);
|
||||
$show_all_events_link = $instance['show_all_events_link'];
|
||||
?>
|
||||
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_before_widget_template_form', $this, $instance, 'event-blocks' );
|
||||
?>
|
||||
<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>
|
||||
|
||||
@@ -116,7 +130,10 @@ class SP_Widget_Event_Blocks extends WP_Widget {
|
||||
|
||||
<p class="sp-event-calendar-show-all-toggle<?php if ( ! $id ): ?> hidden<?php endif; ?>"><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_all_events_link'); ?>" name="<?php echo $this->get_field_name('show_all_events_link'); ?>" value="1" <?php checked( $show_all_events_link, 1 ); ?>>
|
||||
<label for="<?php echo $this->get_field_id('show_all_events_link'); ?>"><?php _e( 'Display link to view all events', 'sportspress' ); ?></label></p>
|
||||
<?php
|
||||
|
||||
<?php
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_after_widget_template_form', $this, $instance, 'event-blocks' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user