Add actions and filters to widgets
This commit is contained in:
@@ -16,7 +16,15 @@ class SP_Widget_Countdown 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, 'countdown' );
|
||||
|
||||
sp_get_template( 'countdown.php', array( 'team' => $team, 'id' => $id, 'show_venue' => $show_venue, 'show_league' => $show_league ) );
|
||||
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_after_widget_template', $args, $instance, 'countdown' );
|
||||
|
||||
echo $after_widget;
|
||||
}
|
||||
|
||||
@@ -28,6 +36,9 @@ class SP_Widget_Countdown extends WP_Widget {
|
||||
$instance['show_venue'] = intval($new_instance['show_venue']);
|
||||
$instance['show_league'] = intval($new_instance['show_league']);
|
||||
|
||||
// Filter to hook into
|
||||
$instance = apply_filters( 'sportspress_widget_update', $instance, $new_instance, $old_instance, 'countdown' );
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
@@ -38,7 +49,10 @@ class SP_Widget_Countdown extends WP_Widget {
|
||||
$id = intval($instance['id']);
|
||||
$show_venue = intval($instance['show_venue']);
|
||||
$show_league = intval($instance['show_league']);
|
||||
?>
|
||||
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_before_widget_template_form', $this, $instance, 'countdown' );
|
||||
?>
|
||||
<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>
|
||||
|
||||
@@ -84,7 +98,10 @@ class SP_Widget_Countdown extends WP_Widget {
|
||||
|
||||
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_league'); ?>" name="<?php echo $this->get_field_name('show_league'); ?>" value="1" <?php checked( $show_league, 1 ); ?>>
|
||||
<label for="<?php echo $this->get_field_id('show_league'); ?>"><?php _e( 'Display league', 'sportspress' ); ?></label></p>
|
||||
<?php
|
||||
|
||||
<?php
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_after_widget_template_form', $this, $instance, 'countdown' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,15 @@ class SP_Widget_Event_Calendar extends WP_Widget {
|
||||
echo $before_widget;
|
||||
if ( $title )
|
||||
echo $before_title . $title . $after_title;
|
||||
echo '<div id="calendar_wrap">';
|
||||
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_before_widget_template', $args, $instance, 'event-calendar' );
|
||||
|
||||
sp_get_template( 'event-calendar.php', array( 'id' => $id, 'status' => $status, 'date' => $date, 'date_from' => $date_from, 'date_to' => $date_to, 'caption_tag' => 'caption', 'show_all_events_link' => $show_all_events_link ) );
|
||||
echo '</div>';
|
||||
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_after_widget_template', $args, $instance, 'event-calendar' );
|
||||
|
||||
echo $after_widget;
|
||||
}
|
||||
|
||||
@@ -34,6 +40,9 @@ class SP_Widget_Event_Calendar extends WP_Widget {
|
||||
$instance['date_to'] = $new_instance['date_to'];
|
||||
$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-calendar' );
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
@@ -46,7 +55,10 @@ class SP_Widget_Event_Calendar extends WP_Widget {
|
||||
$date_from = $instance['date_from'];
|
||||
$date_to = $instance['date_to'];
|
||||
$show_all_events_link = $instance['show_all_events_link'];
|
||||
?>
|
||||
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_before_widget_template_form', $this, $instance, 'event-calendar' );
|
||||
?>
|
||||
<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>
|
||||
|
||||
@@ -102,7 +114,10 @@ class SP_Widget_Event_Calendar 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-calendar' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,15 @@ class SP_Widget_Event_List 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-list' );
|
||||
|
||||
sp_get_template( 'event-list.php', array( 'id' => $id, 'status' => $status, 'date' => $date, 'date_from' => $date_from, 'date_to' => $date_to, 'number' => $number, 'columns' => $columns, 'order' => $order, 'show_all_events_link' => $show_all_events_link ) );
|
||||
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_after_widget_template', $args, $instance, 'event-list' );
|
||||
|
||||
echo $after_widget;
|
||||
}
|
||||
|
||||
@@ -38,6 +46,9 @@ class SP_Widget_Event_List 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-list' );
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
@@ -53,7 +64,10 @@ class SP_Widget_Event_List extends WP_Widget {
|
||||
$columns = $instance['columns'];
|
||||
$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-list' );
|
||||
?>
|
||||
<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>
|
||||
|
||||
@@ -136,7 +150,10 @@ class SP_Widget_Event_List 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-list' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,26 +8,25 @@ class SP_Widget_League_Table extends WP_Widget {
|
||||
|
||||
function widget( $args, $instance ) {
|
||||
extract($args);
|
||||
$id = empty($instance['id']) ? 0 : $instance['id'];
|
||||
if ( $id <= 0 ) return;
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
|
||||
$id = empty($instance['id']) ? null : $instance['id'];
|
||||
$number = empty($instance['number']) ? null : $instance['number'];
|
||||
$columns = empty($instance['columns']) ? null : $instance['columns'];
|
||||
$columns = empty($instance['columns']) ? array() : $instance['columns'];
|
||||
$show_team_logo = empty($instance['show_team_logo']) ? false : $instance['show_team_logo'];
|
||||
$show_full_table_link = empty($instance['show_full_table_link']) ? false : $instance['show_full_table_link'];
|
||||
echo $before_widget;
|
||||
if ( $title )
|
||||
echo $before_title . $title . $after_title;
|
||||
echo '<div id="sp_league_table_wrap">';
|
||||
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_before_widget', $args, $instance, 'league-table' );
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_before_widget_template', $args, $instance, 'league-table' );
|
||||
|
||||
sp_get_template( 'league-table.php', array( 'id' => $id, 'number' => $number, 'columns' => $columns, 'show_full_table_link' => $show_full_table_link, 'show_team_logo' => $show_team_logo ) );
|
||||
sp_get_template( 'league-table.php', array( 'id' => $id, 'number' => $number, 'columns' => $columns, 'show_full_table_link' => $show_full_table_link, 'show_team_logo' => $show_team_logo ) );
|
||||
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_after_widget', $args, $instance, 'league-table' );
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_after_widget_template', $args, $instance, 'league-table' );
|
||||
|
||||
echo '</div>';
|
||||
echo $after_widget;
|
||||
}
|
||||
|
||||
@@ -40,7 +39,7 @@ class SP_Widget_League_Table extends WP_Widget {
|
||||
$instance['show_team_logo'] = $new_instance['show_team_logo'];
|
||||
$instance['show_full_table_link'] = $new_instance['show_full_table_link'];
|
||||
|
||||
// Action to hook into
|
||||
// Filter to hook into
|
||||
$instance = apply_filters( 'sportspress_widget_update', $instance, $new_instance, $old_instance, 'league-table' );
|
||||
|
||||
return $instance;
|
||||
@@ -57,7 +56,7 @@ class SP_Widget_League_Table extends WP_Widget {
|
||||
$show_full_table_link = $instance['show_full_table_link'];
|
||||
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_before_widget_form', $this, $instance, 'league-table' );
|
||||
do_action( 'sportspress_before_widget_template_form', $this, $instance, 'league-table' );
|
||||
?>
|
||||
<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>
|
||||
@@ -68,6 +67,7 @@ class SP_Widget_League_Table extends WP_Widget {
|
||||
'post_type' => 'sp_table',
|
||||
'name' => $this->get_field_name('id'),
|
||||
'id' => $this->get_field_id('id'),
|
||||
'show_option_none' => __( '— Select —', 'sportspress' ),
|
||||
'selected' => $id,
|
||||
'values' => 'ID',
|
||||
'class' => 'widefat',
|
||||
@@ -109,7 +109,7 @@ class SP_Widget_League_Table extends WP_Widget {
|
||||
|
||||
<?php
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_after_widget_form', $this, $instance, 'league-table' );
|
||||
do_action( 'sportspress_after_widget_template_form', $this, $instance, 'league-table' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,9 @@ class SP_Widget_Player_Gallery extends WP_Widget {
|
||||
|
||||
function widget( $args, $instance ) {
|
||||
extract($args);
|
||||
$id = empty($instance['id']) ? 0 : $instance['id'];
|
||||
if ( $id <= 0 ) return;
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
|
||||
$id = empty($instance['id']) ? null : $instance['id'];
|
||||
$number = empty($instance['number']) ? null : $instance['number'];
|
||||
$columns = empty($instance['columns']) ? null : $instance['columns'];
|
||||
$orderby = empty($instance['orderby']) ? 'default' : $instance['orderby'];
|
||||
@@ -19,9 +20,15 @@ class SP_Widget_Player_Gallery extends WP_Widget {
|
||||
echo $before_widget;
|
||||
if ( $title )
|
||||
echo $before_title . $title . $after_title;
|
||||
echo '<div id="sp_player_gallery_wrap">';
|
||||
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_before_widget_template', $args, $instance, 'player-gallery' );
|
||||
|
||||
sp_get_template( 'player-gallery.php', array( 'id' => $id, 'number' => $number, 'columns' => $columns, 'orderby' => $orderby , 'order' => $order, 'grouping' => 0, 'show_all_players_link' => $show_all_players_link, 'show_names_on_hover' => $show_names_on_hover ) );
|
||||
echo '</div>';
|
||||
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_after_widget_template', $args, $instance, 'player-gallery' );
|
||||
|
||||
echo $after_widget;
|
||||
}
|
||||
|
||||
@@ -36,6 +43,9 @@ class SP_Widget_Player_Gallery extends WP_Widget {
|
||||
$instance['show_all_players_link'] = $new_instance['show_all_players_link'];
|
||||
$instance['show_names_on_hover'] = $new_instance['show_names_on_hover'];
|
||||
|
||||
// Filter to hook into
|
||||
$instance = apply_filters( 'sportspress_widget_update', $instance, $new_instance, $old_instance, 'player-gallery' );
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
@@ -49,7 +59,10 @@ class SP_Widget_Player_Gallery extends WP_Widget {
|
||||
$order = strip_tags($instance['order']);
|
||||
$show_all_players_link = $instance['show_all_players_link'];
|
||||
$show_names_on_hover = $instance['show_names_on_hover'];
|
||||
?>
|
||||
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_before_widget_template_form', $this, $instance, 'player-gallery' );
|
||||
?>
|
||||
<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>
|
||||
|
||||
@@ -108,7 +121,10 @@ class SP_Widget_Player_Gallery extends WP_Widget {
|
||||
|
||||
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_names_on_hover'); ?>" name="<?php echo $this->get_field_name('show_names_on_hover'); ?>" value="1" <?php checked( $show_names_on_hover, 1 ); ?>>
|
||||
<label for="<?php echo $this->get_field_id('show_names_on_hover'); ?>"><?php _e( 'Display player names on hover', 'sportspress' ); ?></label></p>
|
||||
<?php
|
||||
|
||||
<?php
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_after_widget_template_form', $this, $instance, 'player-gallery' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,9 @@ class SP_Widget_Player_list extends WP_Widget {
|
||||
|
||||
function widget( $args, $instance ) {
|
||||
extract($args);
|
||||
$id = empty($instance['id']) ? 0 : $instance['id'];
|
||||
if ( $id <= 0 ) return;
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
|
||||
$id = empty($instance['id']) ? null : $instance['id'];
|
||||
$number = empty($instance['number']) ? null : $instance['number'];
|
||||
$columns = $instance['columns'];
|
||||
$orderby = empty($instance['orderby']) ? 'default' : $instance['orderby'];
|
||||
@@ -18,9 +19,15 @@ class SP_Widget_Player_list extends WP_Widget {
|
||||
echo $before_widget;
|
||||
if ( $title )
|
||||
echo $before_title . $title . $after_title;
|
||||
echo '<div id="sp_player_list_wrap">';
|
||||
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_before_widget_template', $args, $instance, 'player-list' );
|
||||
|
||||
sp_get_template( 'player-list.php', array( 'id' => $id, 'number' => $number, 'columns' => $columns, 'orderby' => $orderby, 'order' => $order, 'grouping' => 0, 'show_all_players_link' => $show_all_players_link ) );
|
||||
echo '</div>';
|
||||
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_after_widget_template', $args, $instance, 'player-list' );
|
||||
|
||||
echo $after_widget;
|
||||
}
|
||||
|
||||
@@ -34,6 +41,9 @@ class SP_Widget_Player_list extends WP_Widget {
|
||||
$instance['order'] = strip_tags($new_instance['order']);
|
||||
$instance['show_all_players_link'] = $new_instance['show_all_players_link'];
|
||||
|
||||
// Filter to hook into
|
||||
$instance = apply_filters( 'sportspress_widget_update', $instance, $new_instance, $old_instance, 'player-list' );
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
@@ -46,7 +56,10 @@ class SP_Widget_Player_list extends WP_Widget {
|
||||
$orderby = strip_tags($instance['orderby']);
|
||||
$order = strip_tags($instance['order']);
|
||||
$show_all_players_link = $instance['show_all_players_link'];
|
||||
?>
|
||||
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_before_widget_template_form', $this, $instance, 'player-list' );
|
||||
?>
|
||||
<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>
|
||||
|
||||
@@ -119,7 +132,10 @@ class SP_Widget_Player_list extends WP_Widget {
|
||||
|
||||
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_all_players_link'); ?>" name="<?php echo $this->get_field_name('show_all_players_link'); ?>" value="1" <?php checked( $show_all_players_link, 1 ); ?>>
|
||||
<label for="<?php echo $this->get_field_id('show_all_players_link'); ?>"><?php _e( 'Display link to view all players', 'sportspress' ); ?></label></p>
|
||||
<?php
|
||||
|
||||
<?php
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_after_widget_template_form', $this, $instance, 'player-list' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user