Clean up spaces, tabs, indentation, and bracket formatting

This commit is contained in:
Brian Miyaji
2021-11-10 15:41:40 +09:00
parent e58beb1201
commit 3dff686a00
285 changed files with 29638 additions and 24147 deletions

View File

@@ -2,26 +2,36 @@
class SP_Widget_Birthdays extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'widget_sportspress widget_birthdays widget_sp_birthdays', 'description' => __( 'Display players and staff on their birthday.', 'sportspress' ) );
parent::__construct('sportspress-birthdays', __( 'Birthdays', 'sportspress' ), $widget_ops);
$widget_ops = array(
'classname' => 'widget_sportspress widget_birthdays widget_sp_birthdays',
'description' => __( 'Display players and staff on their birthday.', 'sportspress' ),
);
parent::__construct( 'sportspress-birthdays', __( 'Birthdays', 'sportspress' ), $widget_ops );
}
function widget( $args, $instance ) {
extract($args);
$title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base );
$date = empty( $instance['date']) ? 'day' : strip_tags($instance['date'] );
$birthday_format = empty( $instance['birthday_format']) ? 'birthday' : strip_tags( $instance['birthday_format'] );
extract( $args );
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
$date = empty( $instance['date'] ) ? 'day' : strip_tags( $instance['date'] );
$birthday_format = empty( $instance['birthday_format'] ) ? 'birthday' : strip_tags( $instance['birthday_format'] );
do_action( 'sportspress_before_widget', $args, $instance, 'birthdays' );
echo $before_widget;
if ( $title )
if ( $title ) {
echo $before_title . $title . $after_title;
}
// Action to hook into
do_action( 'sportspress_before_widget_template', $args, $instance, 'birthdays' );
sp_get_template( 'birthdays.php', array( 'date' => $date, 'birthday_format' => $birthday_format ) );
sp_get_template(
'birthdays.php',
array(
'date' => $date,
'birthday_format' => $birthday_format,
)
);
// Action to hook into
do_action( 'sportspress_after_widget_template', $args, $instance, 'birthdays' );
@@ -31,9 +41,9 @@ class SP_Widget_Birthdays extends WP_Widget {
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['date'] = strip_tags( $new_instance['date'] );
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['date'] = strip_tags( $new_instance['date'] );
$instance['birthday_format'] = strip_tags( $new_instance['birthday_format'] );
// Filter to hook into
@@ -43,39 +53,46 @@ class SP_Widget_Birthdays extends WP_Widget {
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'date' => 'day', 'birthday_format' => 'birthday' ) );
$title = strip_tags( $instance['title'] );
$date = strip_tags( $instance['date'] );
$options = array(
'day' => __( 'Today', 'sportspress' ),
'week' => __( 'This week', 'sportspress' ),
$instance = wp_parse_args(
(array) $instance,
array(
'title' => '',
'date' => 'day',
'birthday_format' => 'birthday',
)
);
$title = strip_tags( $instance['title'] );
$date = strip_tags( $instance['date'] );
$options = array(
'day' => __( 'Today', 'sportspress' ),
'week' => __( 'This week', 'sportspress' ),
'month' => __( 'This month', 'sportspress' ),
);
$birthday_format = strip_tags( $instance['birthday_format'] );
$birthday_format = strip_tags( $instance['birthday_format'] );
$birthday_options = array(
'hide' => __( 'Hide', 'sportspress' ),
'birthday' => __( 'Birthday', 'sportspress' ),
'age' => __( 'Age', 'sportspress' ),
'hide' => __( 'Hide', 'sportspress' ),
'birthday' => __( 'Birthday', 'sportspress' ),
'age' => __( 'Age', 'sportspress' ),
'birthdayage' => __( 'Birthday (Age)', 'sportspress' ),
);
// Action to hook into
do_action( 'sportspress_before_widget_template_form', $this, $instance, 'birthdays' );
?>
<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>
<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>
<p>
<label for="<?php echo $this->get_field_id('date'); ?>"><?php _e( 'Birthday:', 'sportspress' ); ?></label>
<select name="<?php echo $this->get_field_name('date'); ?>" id="<?php echo $this->get_field_id('date'); ?>" class="postform widefat">
<label for="<?php echo $this->get_field_id( 'date' ); ?>"><?php _e( 'Birthday:', 'sportspress' ); ?></label>
<select name="<?php echo $this->get_field_name( 'date' ); ?>" id="<?php echo $this->get_field_id( 'date' ); ?>" class="postform widefat">
<?php foreach ( $options as $value => $label ) { ?>
<option value="<?php echo $value; ?>" <?php selected( $value, $date ); ?>><?php echo $label; ?></option>
<?php } ?>
</select>
</p>
<p>
<label for="<?php echo $this->get_field_id('birthday_format'); ?>"><?php _e( 'Format:', 'sportspress' ); ?></label>
<select name="<?php echo $this->get_field_name('birthday_format'); ?>" id="<?php echo $this->get_field_id('birthday_format'); ?>" class="postform widefat">
<label for="<?php echo $this->get_field_id( 'birthday_format' ); ?>"><?php _e( 'Format:', 'sportspress' ); ?></label>
<select name="<?php echo $this->get_field_name( 'birthday_format' ); ?>" id="<?php echo $this->get_field_id( 'birthday_format' ); ?>" class="postform widefat">
<?php foreach ( $birthday_options as $value => $label ) { ?>
<option value="<?php echo $value; ?>" <?php selected( $value, $birthday_format ); ?>><?php echo esc_html( $label ); ?></option>
<?php } ?>

View File

@@ -2,35 +2,54 @@
class SP_Widget_Countdown extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'widget_sportspress widget_countdown widget_sp_countdown', 'description' => __( 'A clock that counts down to an upcoming event.', 'sportspress' ) );
parent::__construct('sportspress-countdown', __( 'Countdown', 'sportspress' ), $widget_ops);
$widget_ops = array(
'classname' => 'widget_sportspress widget_countdown widget_sp_countdown',
'description' => __( 'A clock that counts down to an upcoming event.', 'sportspress' ),
);
parent::__construct( 'sportspress-countdown', __( 'Countdown', 'sportspress' ), $widget_ops );
}
function widget( $args, $instance ) {
extract($args);
$title = apply_filters('widget_title', empty($instance['title']) ? null : $instance['title'], $instance, $this->id_base);
$caption = empty($instance['caption']) ? null : $instance['caption'];
$calendar = empty($instance['calendar']) ? null : $instance['calendar'];
$team = empty($instance['team']) ? null : $instance['team'];
$id = empty($instance['id']) ? null : $instance['id'];
$show_venue = empty($instance['show_venue']) ? false : $instance['show_venue'];
$show_league = empty($instance['show_league']) ? false : $instance['show_league'];
$show_date = empty($instance['show_date']) ? false : $instance['show_date'];
$show_excluded = empty($instance['show_excluded']) ? false : $instance['show_excluded'];
$order = empty($instance['order']) ? false : $instance['order'];
$orderby = empty($instance['orderby']) ? false : $instance['orderby'];
$show_status = empty($instance['show_status']) ? false : $instance['show_status'];
extract( $args );
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? null : $instance['title'], $instance, $this->id_base );
$caption = empty( $instance['caption'] ) ? null : $instance['caption'];
$calendar = empty( $instance['calendar'] ) ? null : $instance['calendar'];
$team = empty( $instance['team'] ) ? null : $instance['team'];
$id = empty( $instance['id'] ) ? null : $instance['id'];
$show_venue = empty( $instance['show_venue'] ) ? false : $instance['show_venue'];
$show_league = empty( $instance['show_league'] ) ? false : $instance['show_league'];
$show_date = empty( $instance['show_date'] ) ? false : $instance['show_date'];
$show_excluded = empty( $instance['show_excluded'] ) ? false : $instance['show_excluded'];
$order = empty( $instance['order'] ) ? false : $instance['order'];
$orderby = empty( $instance['orderby'] ) ? false : $instance['orderby'];
$show_status = empty( $instance['show_status'] ) ? false : $instance['show_status'];
do_action( 'sportspress_before_widget', $args, $instance, 'countdown' );
echo $before_widget;
if ( $title )
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( 'calendar' => $calendar, 'team' => $team, 'id' => $id, 'title' => $caption, 'show_venue' => $show_venue, 'show_league' => $show_league, 'show_date' => $show_date, 'show_excluded' => $show_excluded, 'order' => $order, 'orderby' => $orderby, 'show_status' => $show_status ) );
sp_get_template(
'countdown.php',
array(
'calendar' => $calendar,
'team' => $team,
'id' => $id,
'title' => $caption,
'show_venue' => $show_venue,
'show_league' => $show_league,
'show_date' => $show_date,
'show_excluded' => $show_excluded,
'order' => $order,
'orderby' => $orderby,
'show_status' => $show_status,
)
);
// Action to hook into
do_action( 'sportspress_after_widget_template', $args, $instance, 'countdown' );
@@ -40,19 +59,19 @@ class SP_Widget_Countdown extends WP_Widget {
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['calendar'] = intval($new_instance['calendar']);
$instance['team'] = intval($new_instance['team']);
$instance['caption'] = strip_tags($new_instance['caption']);
$instance['id'] = intval($new_instance['id']);
$instance['show_venue'] = intval($new_instance['show_venue']);
$instance['show_league'] = intval($new_instance['show_league']);
$instance['show_date'] = intval($new_instance['show_date']);
$instance['show_excluded'] = intval($new_instance['show_excluded']);
$instance['order'] = strip_tags($new_instance['order']);
$instance['orderby'] = strip_tags($new_instance['orderby']);
$instance['show_status'] = strip_tags($new_instance['show_status']);
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['calendar'] = intval( $new_instance['calendar'] );
$instance['team'] = intval( $new_instance['team'] );
$instance['caption'] = strip_tags( $new_instance['caption'] );
$instance['id'] = intval( $new_instance['id'] );
$instance['show_venue'] = intval( $new_instance['show_venue'] );
$instance['show_league'] = intval( $new_instance['show_league'] );
$instance['show_date'] = intval( $new_instance['show_date'] );
$instance['show_excluded'] = intval( $new_instance['show_excluded'] );
$instance['order'] = strip_tags( $new_instance['order'] );
$instance['orderby'] = strip_tags( $new_instance['orderby'] );
$instance['show_status'] = strip_tags( $new_instance['show_status'] );
// Filter to hook into
$instance = apply_filters( 'sportspress_widget_update', $instance, $new_instance, $old_instance, 'countdown' );
@@ -61,112 +80,128 @@ class SP_Widget_Countdown extends WP_Widget {
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'calendar' => '', 'team' => '', 'id' => '', 'caption' => '', 'show_venue' => false, 'show_league' => false, 'show_date' => false, 'show_excluded' => false, 'order' => '', 'orderby' => '', 'show_status' => true ) );
$title = strip_tags($instance['title']);
$caption = strip_tags($instance['caption']);
$calendar = intval($instance['calendar']);
$team = intval($instance['team']);
$id = intval($instance['id']);
$show_venue = intval($instance['show_venue']);
$show_league = intval($instance['show_league']);
$show_date = intval($instance['show_date']);
$show_excluded = intval($instance['show_excluded']);
$order = strip_tags($instance['order']);
$orderby = strip_tags($instance['orderby']);
$show_status = intval($instance['show_status']);
$instance = wp_parse_args(
(array) $instance,
array(
'title' => '',
'calendar' => '',
'team' => '',
'id' => '',
'caption' => '',
'show_venue' => false,
'show_league' => false,
'show_date' => false,
'show_excluded' => false,
'order' => '',
'orderby' => '',
'show_status' => true,
)
);
$title = strip_tags( $instance['title'] );
$caption = strip_tags( $instance['caption'] );
$calendar = intval( $instance['calendar'] );
$team = intval( $instance['team'] );
$id = intval( $instance['id'] );
$show_venue = intval( $instance['show_venue'] );
$show_league = intval( $instance['show_league'] );
$show_date = intval( $instance['show_date'] );
$show_excluded = intval( $instance['show_excluded'] );
$order = strip_tags( $instance['order'] );
$orderby = strip_tags( $instance['orderby'] );
$show_status = intval( $instance['show_status'] );
// 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>
<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>
<p><label for="<?php echo $this->get_field_id('caption'); ?>"><?php _e( 'Heading:', 'sportspress' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('caption'); ?>" name="<?php echo $this->get_field_name('caption'); ?>" type="text" value="<?php echo esc_attr($caption); ?>" /></p>
<p><label for="<?php echo $this->get_field_id( 'caption' ); ?>"><?php _e( 'Heading:', 'sportspress' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'caption' ); ?>" name="<?php echo $this->get_field_name( 'caption' ); ?>" type="text" value="<?php echo esc_attr( $caption ); ?>" /></p>
<p class="sp-dropdown-filter"><label for="<?php echo $this->get_field_id('calendar'); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Calendar', 'sportspress' ) ); ?></label>
<p class="sp-dropdown-filter"><label for="<?php echo $this->get_field_id( 'calendar' ); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Calendar', 'sportspress' ) ); ?></label>
<?php
$args = array(
'post_type' => 'sp_calendar',
'name' => $this->get_field_name('calendar'),
'id' => $this->get_field_id('calendar'),
'selected' => $calendar,
'post_type' => 'sp_calendar',
'name' => $this->get_field_name( 'calendar' ),
'id' => $this->get_field_id( 'calendar' ),
'selected' => $calendar,
'show_option_all' => __( 'All', 'sportspress' ),
'values' => 'ID',
'class' => 'widefat',
'values' => 'ID',
'class' => 'widefat',
);
if ( ! sp_dropdown_pages( $args ) ):
if ( ! sp_dropdown_pages( $args ) ) :
sp_post_adder( 'sp_calendar', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p class="sp-dropdown-filter"><label for="<?php echo $this->get_field_id('orderby'); ?>"><?php printf( __( 'Sort by:', 'sportspress' ) ); ?></label>
<select name="<?php echo $this->get_field_name('orderby'); ?>" class="postform widefat">
<p class="sp-dropdown-filter"><label for="<?php echo $this->get_field_id( 'orderby' ); ?>"><?php printf( __( 'Sort by:', 'sportspress' ) ); ?></label>
<select name="<?php echo $this->get_field_name( 'orderby' ); ?>" class="postform widefat">
<option value="" <?php selected( 'default', $orderby ); ?>><?php _e( 'Default', 'sportspress' ); ?></option>
<option value="date" <?php selected( 'date', $orderby ); ?>><?php _e( 'Date', 'sportspress' ); ?></option>
<option value="day" <?php selected( 'day', $orderby ); ?>><?php _e( 'Match Day', 'sportspress' ); ?></option>
</select>
</p>
<p class="sp-dropdown-filter"><label for="<?php echo $this->get_field_id('order'); ?>"><?php printf( __( 'Sort Order:', 'sportspress' ) ); ?></label>
<select name="<?php echo $this->get_field_name('order'); ?>" class="postform widefat">
<p class="sp-dropdown-filter"><label for="<?php echo $this->get_field_id( 'order' ); ?>"><?php printf( __( 'Sort Order:', 'sportspress' ) ); ?></label>
<select name="<?php echo $this->get_field_name( 'order' ); ?>" class="postform widefat">
<option value="ASC" <?php selected( 'ASC', $order ); ?>><?php _e( 'Ascending', 'sportspress' ); ?></option>
<option value="DESC" <?php selected( 'DESC', $order ); ?>><?php _e( 'Descending', 'sportspress' ); ?></option>
</select>
</p>
<p class="sp-dropdown-filter"><label for="<?php echo $this->get_field_id('team'); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Team', 'sportspress' ) ); ?></label>
<p class="sp-dropdown-filter"><label for="<?php echo $this->get_field_id( 'team' ); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Team', 'sportspress' ) ); ?></label>
<?php
$args = array(
'post_type' => 'sp_team',
'name' => $this->get_field_name('team'),
'id' => $this->get_field_id('team'),
'selected' => $team,
'post_type' => 'sp_team',
'name' => $this->get_field_name( 'team' ),
'id' => $this->get_field_id( 'team' ),
'selected' => $team,
'show_option_all' => __( 'All', 'sportspress' ),
'values' => 'ID',
'class' => 'widefat',
'values' => 'ID',
'class' => 'widefat',
);
if ( ! sp_dropdown_pages( $args ) ):
if ( ! sp_dropdown_pages( $args ) ) :
sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p class="sp-dropdown-target"><label for="<?php echo $this->get_field_id('id'); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Event', 'sportspress' ) ); ?></label>
<p class="sp-dropdown-target"><label for="<?php echo $this->get_field_id( 'id' ); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Event', 'sportspress' ) ); ?></label>
<?php
$args = array(
'post_type' => 'sp_event',
'name' => $this->get_field_name('id'),
'id' => $this->get_field_id('id'),
'selected' => $id,
'post_type' => 'sp_event',
'name' => $this->get_field_name( 'id' ),
'id' => $this->get_field_id( 'id' ),
'selected' => $id,
'show_option_all' => __( '(Auto)', 'sportspress' ),
'values' => 'ID',
'class' => 'widefat',
'show_dates' => true,
'post_status' => 'future',
'filter' => 'sp_team',
'values' => 'ID',
'class' => 'widefat',
'show_dates' => true,
'post_status' => 'future',
'filter' => 'sp_team',
);
if ( ! sp_dropdown_pages( $args ) ):
if ( ! sp_dropdown_pages( $args ) ) :
sp_post_adder( 'sp_event', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_venue'); ?>" name="<?php echo $this->get_field_name('show_venue'); ?>" value="1" <?php checked( $show_venue, 1 ); ?>>
<label for="<?php echo $this->get_field_id('show_venue'); ?>"><?php _e( 'Display venue', 'sportspress' ); ?></label></p>
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id( 'show_venue' ); ?>" name="<?php echo $this->get_field_name( 'show_venue' ); ?>" value="1" <?php checked( $show_venue, 1 ); ?>>
<label for="<?php echo $this->get_field_id( 'show_venue' ); ?>"><?php _e( 'Display venue', 'sportspress' ); ?></label></p>
<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>
<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>
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_date'); ?>" name="<?php echo $this->get_field_name('show_date'); ?>" value="1" <?php checked( $show_date, 1 ); ?>>
<label for="<?php echo $this->get_field_id('show_date'); ?>"><?php _e( 'Display date', 'sportspress' ); ?></label></p>
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id( 'show_date' ); ?>" name="<?php echo $this->get_field_name( 'show_date' ); ?>" value="1" <?php checked( $show_date, 1 ); ?>>
<label for="<?php echo $this->get_field_id( 'show_date' ); ?>"><?php _e( 'Display date', 'sportspress' ); ?></label></p>
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_excluded'); ?>" name="<?php echo $this->get_field_name('show_excluded'); ?>" value="1" <?php checked( $show_excluded, 1 ); ?>>
<label for="<?php echo $this->get_field_id('show_excluded'); ?>"><?php _e( 'Display excluded events', 'sportspress' ); ?></label></p>
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id( 'show_excluded' ); ?>" name="<?php echo $this->get_field_name( 'show_excluded' ); ?>" value="1" <?php checked( $show_excluded, 1 ); ?>>
<label for="<?php echo $this->get_field_id( 'show_excluded' ); ?>"><?php _e( 'Display excluded events', 'sportspress' ); ?></label></p>
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_status'); ?>" name="<?php echo $this->get_field_name('show_status'); ?>" value="1" <?php checked( $show_status, 1 ); ?>>
<label for="<?php echo $this->get_field_id('show_status'); ?>"><?php _e( 'Display event status', 'sportspress' ); ?></label></p>
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id( 'show_status' ); ?>" name="<?php echo $this->get_field_name( 'show_status' ); ?>" value="1" <?php checked( $show_status, 1 ); ?>>
<label for="<?php echo $this->get_field_id( 'show_status' ); ?>"><?php _e( 'Display event status', 'sportspress' ); ?></label></p>
<?php
// Action to hook into

View File

@@ -2,43 +2,66 @@
class SP_Widget_Event_Blocks extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'widget_sportspress widget_sp_event_blocks', 'description' => __( 'A list of events.', 'sportspress' ) );
parent::__construct('sportspress-event-blocks', __( 'Event Blocks', 'sportspress' ), $widget_ops);
$widget_ops = array(
'classname' => 'widget_sportspress widget_sp_event_blocks',
'description' => __( 'A list of events.', 'sportspress' ),
);
parent::__construct( 'sportspress-event-blocks', __( 'Event Blocks', 'sportspress' ), $widget_ops );
}
function widget( $args, $instance ) {
extract($args);
$id = empty($instance['id']) ? null : $instance['id'];
extract( $args );
$id = empty( $instance['id'] ) ? null : $instance['id'];
if ( $id && 'yes' == get_option( 'sportspress_widget_unique', 'no' ) && get_the_ID() === $id ) {
$format = get_post_meta( $id, 'sp_format', true );
if ( 'blocks' == $format ) return;
if ( 'blocks' == $format ) {
return;
}
}
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
$caption = empty($instance['caption']) ? null : $instance['caption'];
$status = empty($instance['status']) ? 'default' : $instance['status'];
$date = empty($instance['date']) ? 'default' : $instance['date'];
$date_from = empty($instance['date_from']) ? 'default' : $instance['date_from'];
$date_to = empty($instance['date_to']) ? 'default' : $instance['date_to'];
$date_past = empty($instance['date_past']) ? 'default' : $instance['date_past'];
$date_future = empty($instance['date_future']) ? 'default' : $instance['date_future'];
$date_relative = empty($instance['date_relative']) ? 'default' : $instance['date_relative'];
$day = empty($instance['day']) ? 'default' : $instance['day'];
$number = empty($instance['number']) ? null : $instance['number'];
$order = empty($instance['order']) ? 'default' : $instance['order'];
$show_all_events_link = empty($instance['show_all_events_link']) ? false : $instance['show_all_events_link'];
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
$caption = empty( $instance['caption'] ) ? null : $instance['caption'];
$status = empty( $instance['status'] ) ? 'default' : $instance['status'];
$date = empty( $instance['date'] ) ? 'default' : $instance['date'];
$date_from = empty( $instance['date_from'] ) ? 'default' : $instance['date_from'];
$date_to = empty( $instance['date_to'] ) ? 'default' : $instance['date_to'];
$date_past = empty( $instance['date_past'] ) ? 'default' : $instance['date_past'];
$date_future = empty( $instance['date_future'] ) ? 'default' : $instance['date_future'];
$date_relative = empty( $instance['date_relative'] ) ? 'default' : $instance['date_relative'];
$day = empty( $instance['day'] ) ? 'default' : $instance['day'];
$number = empty( $instance['number'] ) ? null : $instance['number'];
$order = empty( $instance['order'] ) ? 'default' : $instance['order'];
$show_all_events_link = empty( $instance['show_all_events_link'] ) ? false : $instance['show_all_events_link'];
do_action( 'sportspress_before_widget', $args, $instance, 'event-blocks' );
echo $before_widget;
if ( $title )
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, 'title' => $caption, 'status' => $status, 'date' => $date, 'date_from' => $date_from, 'date_to' => $date_to, 'date_past' => $date_past, 'date_future' => $date_future, 'date_relative' => $date_relative, 'day' => $day, 'number' => $number, 'order' => $order, 'show_all_events_link' => $show_all_events_link ) );
sp_get_template(
'event-blocks.php',
array(
'id' => $id,
'title' => $caption,
'status' => $status,
'date' => $date,
'date_from' => $date_from,
'date_to' => $date_to,
'date_past' => $date_past,
'date_future' => $date_future,
'date_relative' => $date_relative,
'day' => $day,
'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' );
@@ -48,20 +71,20 @@ class SP_Widget_Event_Blocks extends WP_Widget {
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['id'] = intval($new_instance['id']);
$instance['caption'] = strip_tags($new_instance['caption']);
$instance['status'] = $new_instance['status'];
$instance['date'] = $new_instance['date'];
$instance['date_from'] = $new_instance['date_from'];
$instance['date_to'] = $new_instance['date_to'];
$instance['date_past'] = $new_instance['date_past'];
$instance['date_future'] = $new_instance['date_future'];
$instance['date_relative'] = $new_instance['date_relative'];
$instance['day'] = $new_instance['day'];
$instance['number'] = intval($new_instance['number']);
$instance['order'] = strip_tags($new_instance['order']);
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['id'] = intval( $new_instance['id'] );
$instance['caption'] = strip_tags( $new_instance['caption'] );
$instance['status'] = $new_instance['status'];
$instance['date'] = $new_instance['date'];
$instance['date_from'] = $new_instance['date_from'];
$instance['date_to'] = $new_instance['date_to'];
$instance['date_past'] = $new_instance['date_past'];
$instance['date_future'] = $new_instance['date_future'];
$instance['date_relative'] = $new_instance['date_relative'];
$instance['day'] = $new_instance['day'];
$instance['number'] = intval( $new_instance['number'] );
$instance['order'] = strip_tags( $new_instance['order'] );
$instance['show_all_events_link'] = $new_instance['show_all_events_link'];
// Filter to hook into
@@ -71,82 +94,112 @@ class SP_Widget_Event_Blocks extends WP_Widget {
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => null, 'caption' => '', 'status' => 'default', 'date' => 'default', 'date_from' => date_i18n( 'Y-m-d' ), 'date_to' => date_i18n( 'Y-m-d' ), 'date_past' => 7, 'date_future' => 7, 'date_relative' => false, 'day' => '', 'number' => 5, 'order' => 'default', 'show_all_events_link' => true ) );
$title = strip_tags($instance['title']);
$id = intval($instance['id']);
$caption = strip_tags($instance['caption']);
$status = $instance['status'];
$date = $instance['date'];
$date_from = $instance['date_from'];
$date_to = $instance['date_to'];
$date_past = $instance['date_past'];
$date_future = $instance['date_future'];
$date_relative = $instance['date_relative'];
$day = $instance['day'];
$number = intval($instance['number']);
$order = strip_tags($instance['order']);
$instance = wp_parse_args(
(array) $instance,
array(
'title' => '',
'id' => null,
'caption' => '',
'status' => 'default',
'date' => 'default',
'date_from' => date_i18n( 'Y-m-d' ),
'date_to' => date_i18n( 'Y-m-d' ),
'date_past' => 7,
'date_future' => 7,
'date_relative' => false,
'day' => '',
'number' => 5,
'order' => 'default',
'show_all_events_link' => true,
)
);
$title = strip_tags( $instance['title'] );
$id = intval( $instance['id'] );
$caption = strip_tags( $instance['caption'] );
$status = $instance['status'];
$date = $instance['date'];
$date_from = $instance['date_from'];
$date_to = $instance['date_to'];
$date_past = $instance['date_past'];
$date_future = $instance['date_future'];
$date_relative = $instance['date_relative'];
$day = $instance['day'];
$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>
<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>
<p><label for="<?php echo $this->get_field_id('caption'); ?>"><?php _e( 'Heading:', 'sportspress' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('caption'); ?>" name="<?php echo $this->get_field_name('caption'); ?>" type="text" value="<?php echo esc_attr($caption); ?>" /></p>
<p><label for="<?php echo $this->get_field_id( 'caption' ); ?>"><?php _e( 'Heading:', 'sportspress' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'caption' ); ?>" name="<?php echo $this->get_field_name( 'caption' ); ?>" type="text" value="<?php echo esc_attr( $caption ); ?>" /></p>
<p><label for="<?php echo $this->get_field_id('id'); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Calendar', 'sportspress' ) ); ?></label>
<p><label for="<?php echo $this->get_field_id( 'id' ); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Calendar', 'sportspress' ) ); ?></label>
<?php
$args = array(
'post_type' => 'sp_calendar',
'post_type' => 'sp_calendar',
'show_option_all' => __( 'All', 'sportspress' ),
'name' => $this->get_field_name('id'),
'id' => $this->get_field_id('id'),
'selected' => $id,
'values' => 'ID',
'class' => 'sp-event-calendar-select widefat',
'name' => $this->get_field_name( 'id' ),
'id' => $this->get_field_id( 'id' ),
'selected' => $id,
'values' => 'ID',
'class' => 'sp-event-calendar-select widefat',
);
if ( ! sp_dropdown_pages( $args ) ):
if ( ! sp_dropdown_pages( $args ) ) :
sp_post_adder( 'sp_calendar', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p><label for="<?php echo $this->get_field_id('status'); ?>"><?php _e( 'Status:', 'sportspress' ); ?></label>
<p><label for="<?php echo $this->get_field_id( 'status' ); ?>"><?php _e( 'Status:', 'sportspress' ); ?></label>
<?php
$args = array(
'show_option_default' => __( 'Default', 'sportspress' ),
'name' => $this->get_field_name('status'),
'id' => $this->get_field_id('status'),
'selected' => $status,
'class' => 'sp-event-status-select widefat',
'name' => $this->get_field_name( 'status' ),
'id' => $this->get_field_id( 'status' ),
'selected' => $status,
'class' => 'sp-event-status-select widefat',
);
sp_dropdown_statuses( $args );
?>
</p>
<div class="sp-date-selector">
<p><label for="<?php echo $this->get_field_id('date'); ?>"><?php _e( 'Date:', 'sportspress' ); ?></label>
<p><label for="<?php echo $this->get_field_id( 'date' ); ?>"><?php _e( 'Date:', 'sportspress' ); ?></label>
<?php
$args = array(
'show_option_default' => __( 'Default', 'sportspress' ),
'name' => $this->get_field_name('date'),
'id' => $this->get_field_id('date'),
'selected' => $date,
'class' => 'sp-event-date-select widefat',
'name' => $this->get_field_name( 'date' ),
'id' => $this->get_field_id( 'date' ),
'selected' => $date,
'class' => 'sp-event-date-select widefat',
);
sp_dropdown_dates( $args );
?>
</p>
<div class="sp-date-range<?php if ( 'range' !== $date ): ?> hidden<?php endif; ?>">
<p class="sp-date-range-absolute<?php if ( $date_relative ): ?> hidden<?php endif; ?>">
<div class="sp-date-range
<?php
if ( 'range' !== $date ) :
?>
hidden<?php endif; ?>">
<p class="sp-date-range-absolute
<?php
if ( $date_relative ) :
?>
hidden<?php endif; ?>">
<input type="text" name="<?php echo $this->get_field_name( 'date_from' ); ?>" value="<?php echo $date_from; ?>" placeholder="yyyy-mm-dd" size="10">
:
<input type="text" name="<?php echo $this->get_field_name( 'date_to' ); ?>" value="<?php echo $date_to; ?>" placeholder="yyyy-mm-dd" size="10">
</p>
<p class="sp-date-range-relative<?php if ( ! $date_relative ): ?> hidden<?php endif; ?>">
<p class="sp-date-range-relative
<?php
if ( ! $date_relative ) :
?>
hidden<?php endif; ?>">
<?php _e( 'Past', 'sportspress' ); ?>
<input type="number" min="0" step="1" class="tiny-text" name="<?php echo $this->get_field_name( 'date_past' ); ?>" value="<?php echo $date_past; ?>">
&rarr;
@@ -164,21 +217,25 @@ class SP_Widget_Event_Blocks extends WP_Widget {
</div>
</div>
<p><label for="<?php echo $this->get_field_id('day'); ?>"><?php _e( 'Match Day:', 'sportspress' ); ?></label>
<input id="<?php echo $this->get_field_id('day'); ?>" name="<?php echo $this->get_field_name('day'); ?>" type="text" placeholder="<?php _e( 'All', 'sportspress' ); ?>" value="<?php echo esc_attr($day); ?>" size="10"></p>
<p><label for="<?php echo $this->get_field_id( 'day' ); ?>"><?php _e( 'Match Day:', 'sportspress' ); ?></label>
<input id="<?php echo $this->get_field_id( 'day' ); ?>" name="<?php echo $this->get_field_name( 'day' ); ?>" type="text" placeholder="<?php _e( 'All', 'sportspress' ); ?>" value="<?php echo esc_attr( $day ); ?>" size="10"></p>
<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e( 'Number of events to show:', 'sportspress' ); ?></label>
<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo esc_attr($number); ?>" size="3"></p>
<p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of events to show:', 'sportspress' ); ?></label>
<input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="text" value="<?php echo esc_attr( $number ); ?>" size="3"></p>
<p><label for="<?php echo $this->get_field_id('order'); ?>"><?php _e( 'Sort Order:', 'sportspress' ); ?></label>
<select name="<?php echo $this->get_field_name('order'); ?>" id="<?php echo $this->get_field_id('order'); ?>" class="sp-select-order widefat">
<p><label for="<?php echo $this->get_field_id( 'order' ); ?>"><?php _e( 'Sort Order:', 'sportspress' ); ?></label>
<select name="<?php echo $this->get_field_name( 'order' ); ?>" id="<?php echo $this->get_field_id( 'order' ); ?>" class="sp-select-order widefat">
<option value="default" <?php selected( 'default', $order ); ?>><?php _e( 'Default', 'sportspress' ); ?></option>
<option value="ASC" <?php selected( 'ASC', $order ); ?>><?php _e( 'Ascending', 'sportspress' ); ?></option>
<option value="DESC" <?php selected( 'DESC', $order ); ?>><?php _e( 'Descending', 'sportspress' ); ?></option>
</select></p>
<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>
<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
// Action to hook into

View File

@@ -2,40 +2,61 @@
class SP_Widget_Event_Calendar extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'widget_sportspress widget_calendar widget_sp_event_calendar', 'description' => __( 'A calendar of events.', 'sportspress' ) );
parent::__construct('sportspress-event-calendar', __( 'Event Calendar', 'sportspress' ), $widget_ops);
$widget_ops = array(
'classname' => 'widget_sportspress widget_calendar widget_sp_event_calendar',
'description' => __( 'A calendar of events.', 'sportspress' ),
);
parent::__construct( 'sportspress-event-calendar', __( 'Event Calendar', 'sportspress' ), $widget_ops );
}
function widget( $args, $instance ) {
extract($args);
extract( $args );
$id = empty($instance['id']) ? null : $instance['id'];
$id = empty( $instance['id'] ) ? null : $instance['id'];
if ( $id && 'yes' == get_option( 'sportspress_widget_unique', 'no' ) && get_the_ID() === $id ) {
$format = get_post_meta( $id, 'sp_format', true );
if ( 'calendar' == $format ) return;
if ( 'calendar' == $format ) {
return;
}
}
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
$status = empty($instance['status']) ? 'default' : $instance['status'];
$date = empty($instance['date']) ? 'default' : $instance['date'];
$date_from = empty($instance['date_from']) ? 'default' : $instance['date_from'];
$date_to = empty($instance['date_to']) ? 'default' : $instance['date_to'];
$date_past = empty($instance['date_past']) ? 'default' : $instance['date_past'];
$date_future = empty($instance['date_future']) ? 'default' : $instance['date_future'];
$date_relative = empty($instance['date_relative']) ? 'default' : $instance['date_relative'];
$day = empty($instance['day']) ? 'default' : $instance['day'];
$show_all_events_link = empty($instance['show_all_events_link']) ? false : $instance['show_all_events_link'];
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
$status = empty( $instance['status'] ) ? 'default' : $instance['status'];
$date = empty( $instance['date'] ) ? 'default' : $instance['date'];
$date_from = empty( $instance['date_from'] ) ? 'default' : $instance['date_from'];
$date_to = empty( $instance['date_to'] ) ? 'default' : $instance['date_to'];
$date_past = empty( $instance['date_past'] ) ? 'default' : $instance['date_past'];
$date_future = empty( $instance['date_future'] ) ? 'default' : $instance['date_future'];
$date_relative = empty( $instance['date_relative'] ) ? 'default' : $instance['date_relative'];
$day = empty( $instance['day'] ) ? 'default' : $instance['day'];
$show_all_events_link = empty( $instance['show_all_events_link'] ) ? false : $instance['show_all_events_link'];
do_action( 'sportspress_before_widget', $args, $instance, 'event-calendar' );
echo $before_widget;
if ( $title )
if ( $title ) {
echo $before_title . $title . $after_title;
}
// 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, 'date_past' => $date_past, 'date_future' => $date_future, 'date_relative' => $date_relative, 'caption_tag' => 'caption', 'day' => $day, 'show_all_events_link' => $show_all_events_link ) );
sp_get_template(
'event-calendar.php',
array(
'id' => $id,
'status' => $status,
'date' => $date,
'date_from' => $date_from,
'date_to' => $date_to,
'date_past' => $date_past,
'date_future' => $date_future,
'date_relative' => $date_relative,
'caption_tag' => 'caption',
'day' => $day,
'show_all_events_link' => $show_all_events_link,
)
);
// Action to hook into
do_action( 'sportspress_after_widget_template', $args, $instance, 'event-calendar' );
@@ -45,17 +66,17 @@ class SP_Widget_Event_Calendar extends WP_Widget {
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['id'] = intval($new_instance['id']);
$instance['status'] = $new_instance['status'];
$instance['date'] = $new_instance['date'];
$instance['date_from'] = $new_instance['date_from'];
$instance['date_to'] = $new_instance['date_to'];
$instance['date_past'] = $new_instance['date_past'];
$instance['date_future'] = $new_instance['date_future'];
$instance['date_relative'] = $new_instance['date_relative'];
$instance['day'] = $new_instance['day'];
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['id'] = intval( $new_instance['id'] );
$instance['status'] = $new_instance['status'];
$instance['date'] = $new_instance['date'];
$instance['date_from'] = $new_instance['date_from'];
$instance['date_to'] = $new_instance['date_to'];
$instance['date_past'] = $new_instance['date_past'];
$instance['date_future'] = $new_instance['date_future'];
$instance['date_relative'] = $new_instance['date_relative'];
$instance['day'] = $new_instance['day'];
$instance['show_all_events_link'] = $new_instance['show_all_events_link'];
// Filter to hook into
@@ -65,76 +86,103 @@ class SP_Widget_Event_Calendar extends WP_Widget {
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => null, 'status' => 'default', 'date' => 'default', 'date_from' => date_i18n( 'Y-m-d' ), 'date_to' => date_i18n( 'Y-m-d' ), 'date_past' => 7, 'date_future' => 7, 'date_relative' => false, 'day' => '', 'show_all_events_link' => false ) );
$title = strip_tags($instance['title']);
$id = intval($instance['id']);
$status = $instance['status'];
$date = $instance['date'];
$date_from = $instance['date_from'];
$date_to = $instance['date_to'];
$date_past = $instance['date_past'];
$date_future = $instance['date_future'];
$date_relative = $instance['date_relative'];
$day = $instance['day'];
$instance = wp_parse_args(
(array) $instance,
array(
'title' => '',
'id' => null,
'status' => 'default',
'date' => 'default',
'date_from' => date_i18n( 'Y-m-d' ),
'date_to' => date_i18n( 'Y-m-d' ),
'date_past' => 7,
'date_future' => 7,
'date_relative' => false,
'day' => '',
'show_all_events_link' => false,
)
);
$title = strip_tags( $instance['title'] );
$id = intval( $instance['id'] );
$status = $instance['status'];
$date = $instance['date'];
$date_from = $instance['date_from'];
$date_to = $instance['date_to'];
$date_past = $instance['date_past'];
$date_future = $instance['date_future'];
$date_relative = $instance['date_relative'];
$day = $instance['day'];
$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>
<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>
<p><label for="<?php echo $this->get_field_id('id'); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Calendar', 'sportspress' ) ); ?></label>
<p><label for="<?php echo $this->get_field_id( 'id' ); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Calendar', 'sportspress' ) ); ?></label>
<?php
$args = array(
'post_type' => 'sp_calendar',
'post_type' => 'sp_calendar',
'show_option_all' => __( 'All', 'sportspress' ),
'name' => $this->get_field_name('id'),
'id' => $this->get_field_id('id'),
'selected' => $id,
'values' => 'ID',
'class' => 'sp-event-calendar-select widefat',
'name' => $this->get_field_name( 'id' ),
'id' => $this->get_field_id( 'id' ),
'selected' => $id,
'values' => 'ID',
'class' => 'sp-event-calendar-select widefat',
);
if ( ! sp_dropdown_pages( $args ) ):
if ( ! sp_dropdown_pages( $args ) ) :
sp_post_adder( 'sp_calendar', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p><label for="<?php echo $this->get_field_id('status'); ?>"><?php _e( 'Status:', 'sportspress' ); ?></label>
<p><label for="<?php echo $this->get_field_id( 'status' ); ?>"><?php _e( 'Status:', 'sportspress' ); ?></label>
<?php
$args = array(
'show_option_default' => __( 'Default', 'sportspress' ),
'name' => $this->get_field_name('status'),
'id' => $this->get_field_id('status'),
'selected' => $status,
'class' => 'sp-event-status-select widefat',
'name' => $this->get_field_name( 'status' ),
'id' => $this->get_field_id( 'status' ),
'selected' => $status,
'class' => 'sp-event-status-select widefat',
);
sp_dropdown_statuses( $args );
?>
</p>
<div class="sp-date-selector">
<p><label for="<?php echo $this->get_field_id('date'); ?>"><?php _e( 'Date:', 'sportspress' ); ?></label>
<p><label for="<?php echo $this->get_field_id( 'date' ); ?>"><?php _e( 'Date:', 'sportspress' ); ?></label>
<?php
$args = array(
'show_option_default' => __( 'Default', 'sportspress' ),
'name' => $this->get_field_name('date'),
'id' => $this->get_field_id('date'),
'selected' => $date,
'class' => 'sp-event-date-select widefat',
'name' => $this->get_field_name( 'date' ),
'id' => $this->get_field_id( 'date' ),
'selected' => $date,
'class' => 'sp-event-date-select widefat',
);
sp_dropdown_dates( $args );
?>
</p>
<div class="sp-date-range<?php if ( 'range' !== $date ): ?> hidden<?php endif; ?>">
<p class="sp-date-range-absolute<?php if ( $date_relative ): ?> hidden<?php endif; ?>">
<div class="sp-date-range
<?php
if ( 'range' !== $date ) :
?>
hidden<?php endif; ?>">
<p class="sp-date-range-absolute
<?php
if ( $date_relative ) :
?>
hidden<?php endif; ?>">
<input type="text" name="<?php echo $this->get_field_name( 'date_from' ); ?>" value="<?php echo $date_from; ?>" placeholder="yyyy-mm-dd" size="10">
:
<input type="text" name="<?php echo $this->get_field_name( 'date_to' ); ?>" value="<?php echo $date_to; ?>" placeholder="yyyy-mm-dd" size="10">
</p>
<p class="sp-date-range-relative<?php if ( ! $date_relative ): ?> hidden<?php endif; ?>">
<p class="sp-date-range-relative
<?php
if ( ! $date_relative ) :
?>
hidden<?php endif; ?>">
<?php _e( 'Past', 'sportspress' ); ?>
<input type="number" min="0" step="1" class="tiny-text" name="<?php echo $this->get_field_name( 'date_past' ); ?>" value="<?php echo $date_past; ?>">
&rarr;
@@ -152,11 +200,15 @@ class SP_Widget_Event_Calendar extends WP_Widget {
</div>
</div>
<p><label for="<?php echo $this->get_field_id('day'); ?>"><?php _e( 'Match Day:', 'sportspress' ); ?></label>
<input id="<?php echo $this->get_field_id('day'); ?>" name="<?php echo $this->get_field_name('day'); ?>" type="text" placeholder="<?php _e( 'All', 'sportspress' ); ?>" value="<?php echo esc_attr($day); ?>" size="10"></p>
<p><label for="<?php echo $this->get_field_id( 'day' ); ?>"><?php _e( 'Match Day:', 'sportspress' ); ?></label>
<input id="<?php echo $this->get_field_id( 'day' ); ?>" name="<?php echo $this->get_field_name( 'day' ); ?>" type="text" placeholder="<?php _e( 'All', 'sportspress' ); ?>" value="<?php echo esc_attr( $day ); ?>" size="10"></p>
<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>
<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
// Action to hook into

View File

@@ -2,44 +2,68 @@
class SP_Widget_Event_List extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'widget_sportspress widget_sp_event_list', 'description' => __( 'A list of events.', 'sportspress' ) );
parent::__construct('sportspress-event-list', __( 'Event List', 'sportspress' ), $widget_ops);
$widget_ops = array(
'classname' => 'widget_sportspress widget_sp_event_list',
'description' => __( 'A list of events.', 'sportspress' ),
);
parent::__construct( 'sportspress-event-list', __( 'Event List', 'sportspress' ), $widget_ops );
}
function widget( $args, $instance ) {
extract($args);
$id = empty($instance['id']) ? null : $instance['id'];
extract( $args );
$id = empty( $instance['id'] ) ? null : $instance['id'];
if ( $id && 'yes' == get_option( 'sportspress_widget_unique', 'no' ) && get_the_ID() === $id ) {
$format = get_post_meta( $id, 'sp_format', true );
if ( 'list' == $format ) return;
if ( 'list' == $format ) {
return;
}
}
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
$caption = empty($instance['caption']) ? null : $instance['caption'];
$status = empty($instance['status']) ? 'default' : $instance['status'];
$date = empty($instance['date']) ? 'default' : $instance['date'];
$date_from = empty($instance['date_from']) ? 'default' : $instance['date_from'];
$date_to = empty($instance['date_to']) ? 'default' : $instance['date_to'];
$date_past = empty($instance['date_past']) ? 'default' : $instance['date_past'];
$date_future = empty($instance['date_future']) ? 'default' : $instance['date_future'];
$date_relative = empty($instance['date_relative']) ? 'default' : $instance['date_relative'];
$day = empty($instance['day']) ? 'default' : $instance['day'];
$number = empty($instance['number']) ? null : $instance['number'];
$columns = empty($instance['columns']) ? null : $instance['columns'];
$order = empty($instance['order']) ? 'default' : $instance['order'];
$show_all_events_link = empty($instance['show_all_events_link']) ? false : $instance['show_all_events_link'];
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
$caption = empty( $instance['caption'] ) ? null : $instance['caption'];
$status = empty( $instance['status'] ) ? 'default' : $instance['status'];
$date = empty( $instance['date'] ) ? 'default' : $instance['date'];
$date_from = empty( $instance['date_from'] ) ? 'default' : $instance['date_from'];
$date_to = empty( $instance['date_to'] ) ? 'default' : $instance['date_to'];
$date_past = empty( $instance['date_past'] ) ? 'default' : $instance['date_past'];
$date_future = empty( $instance['date_future'] ) ? 'default' : $instance['date_future'];
$date_relative = empty( $instance['date_relative'] ) ? 'default' : $instance['date_relative'];
$day = empty( $instance['day'] ) ? 'default' : $instance['day'];
$number = empty( $instance['number'] ) ? null : $instance['number'];
$columns = empty( $instance['columns'] ) ? null : $instance['columns'];
$order = empty( $instance['order'] ) ? 'default' : $instance['order'];
$show_all_events_link = empty( $instance['show_all_events_link'] ) ? false : $instance['show_all_events_link'];
do_action( 'sportspress_before_widget', $args, $instance, 'event-list' );
echo $before_widget;
if ( $title )
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, 'title' => $caption, 'status' => $status, 'date' => $date, 'date_from' => $date_from, 'date_to' => $date_to, 'date_past' => $date_past, 'date_future' => $date_future, 'date_relative' => $date_relative, 'day' => $day, 'number' => $number, 'columns' => $columns, 'order' => $order, 'show_all_events_link' => $show_all_events_link ) );
sp_get_template(
'event-list.php',
array(
'id' => $id,
'title' => $caption,
'status' => $status,
'date' => $date,
'date_from' => $date_from,
'date_to' => $date_to,
'date_past' => $date_past,
'date_future' => $date_future,
'date_relative' => $date_relative,
'day' => $day,
'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' );
@@ -49,21 +73,21 @@ class SP_Widget_Event_List extends WP_Widget {
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['id'] = intval($new_instance['id']);
$instance['caption'] = strip_tags($new_instance['caption']);
$instance['status'] = $new_instance['status'];
$instance['date'] = $new_instance['date'];
$instance['date_from'] = $new_instance['date_from'];
$instance['date_to'] = $new_instance['date_to'];
$instance['date_past'] = $new_instance['date_past'];
$instance['date_future'] = $new_instance['date_future'];
$instance['date_relative'] = $new_instance['date_relative'];
$instance['day'] = $new_instance['day'];
$instance['number'] = intval($new_instance['number']);
$instance['columns'] = (array)$new_instance['columns'];
$instance['order'] = strip_tags($new_instance['order']);
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['id'] = intval( $new_instance['id'] );
$instance['caption'] = strip_tags( $new_instance['caption'] );
$instance['status'] = $new_instance['status'];
$instance['date'] = $new_instance['date'];
$instance['date_from'] = $new_instance['date_from'];
$instance['date_to'] = $new_instance['date_to'];
$instance['date_past'] = $new_instance['date_past'];
$instance['date_future'] = $new_instance['date_future'];
$instance['date_relative'] = $new_instance['date_relative'];
$instance['day'] = $new_instance['day'];
$instance['number'] = intval( $new_instance['number'] );
$instance['columns'] = (array) $new_instance['columns'];
$instance['order'] = strip_tags( $new_instance['order'] );
$instance['show_all_events_link'] = $new_instance['show_all_events_link'];
// Filter to hook into
@@ -73,21 +97,40 @@ class SP_Widget_Event_List extends WP_Widget {
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => null, 'caption' => '', 'status' => 'default', 'date' => 'default', 'date_from' => date_i18n( 'Y-m-d' ), 'date_to' => date_i18n( 'Y-m-d' ), 'date_past' => 7, 'date_future' => 7, 'date_relative' => false, 'day' => '', 'number' => 5, 'columns' => null, 'order' => 'default', 'show_all_events_link' => true ) );
$title = strip_tags($instance['title']);
$id = intval($instance['id']);
$caption = strip_tags($instance['caption']);
$status = $instance['status'];
$date = $instance['date'];
$date_from = $instance['date_from'];
$date_to = $instance['date_to'];
$date_past = $instance['date_past'];
$date_future = $instance['date_future'];
$date_relative = $instance['date_relative'];
$day = $instance['day'];
$number = intval($instance['number']);
$columns = $instance['columns'];
$order = strip_tags($instance['order']);
$instance = wp_parse_args(
(array) $instance,
array(
'title' => '',
'id' => null,
'caption' => '',
'status' => 'default',
'date' => 'default',
'date_from' => date_i18n( 'Y-m-d' ),
'date_to' => date_i18n( 'Y-m-d' ),
'date_past' => 7,
'date_future' => 7,
'date_relative' => false,
'day' => '',
'number' => 5,
'columns' => null,
'order' => 'default',
'show_all_events_link' => true,
)
);
$title = strip_tags( $instance['title'] );
$id = intval( $instance['id'] );
$caption = strip_tags( $instance['caption'] );
$status = $instance['status'];
$date = $instance['date'];
$date_from = $instance['date_from'];
$date_to = $instance['date_to'];
$date_past = $instance['date_past'];
$date_future = $instance['date_future'];
$date_relative = $instance['date_relative'];
$day = $instance['day'];
$number = intval( $instance['number'] );
$columns = $instance['columns'];
$order = strip_tags( $instance['order'] );
$show_all_events_link = $instance['show_all_events_link'];
$time_format = get_option( 'sportspress_event_list_time_format', 'combined' );
@@ -95,63 +138,75 @@ class SP_Widget_Event_List extends WP_Widget {
// 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>
<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>
<p><label for="<?php echo $this->get_field_id('caption'); ?>"><?php _e( 'Heading:', 'sportspress' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('caption'); ?>" name="<?php echo $this->get_field_name('caption'); ?>" type="text" value="<?php echo esc_attr($caption); ?>" /></p>
<p><label for="<?php echo $this->get_field_id( 'caption' ); ?>"><?php _e( 'Heading:', 'sportspress' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'caption' ); ?>" name="<?php echo $this->get_field_name( 'caption' ); ?>" type="text" value="<?php echo esc_attr( $caption ); ?>" /></p>
<p><label for="<?php echo $this->get_field_id('id'); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Calendar', 'sportspress' ) ); ?></label>
<p><label for="<?php echo $this->get_field_id( 'id' ); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Calendar', 'sportspress' ) ); ?></label>
<?php
$args = array(
'post_type' => 'sp_calendar',
'post_type' => 'sp_calendar',
'show_option_all' => __( 'All', 'sportspress' ),
'name' => $this->get_field_name('id'),
'id' => $this->get_field_id('id'),
'selected' => $id,
'values' => 'ID',
'class' => 'sp-event-calendar-select widefat',
'name' => $this->get_field_name( 'id' ),
'id' => $this->get_field_id( 'id' ),
'selected' => $id,
'values' => 'ID',
'class' => 'sp-event-calendar-select widefat',
);
if ( ! sp_dropdown_pages( $args ) ):
if ( ! sp_dropdown_pages( $args ) ) :
sp_post_adder( 'sp_calendar', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p><label for="<?php echo $this->get_field_id('status'); ?>"><?php _e( 'Status:', 'sportspress' ); ?></label>
<p><label for="<?php echo $this->get_field_id( 'status' ); ?>"><?php _e( 'Status:', 'sportspress' ); ?></label>
<?php
$args = array(
'show_option_default' => __( 'Default', 'sportspress' ),
'name' => $this->get_field_name('status'),
'id' => $this->get_field_id('status'),
'selected' => $status,
'class' => 'sp-event-status-select widefat',
'name' => $this->get_field_name( 'status' ),
'id' => $this->get_field_id( 'status' ),
'selected' => $status,
'class' => 'sp-event-status-select widefat',
);
sp_dropdown_statuses( $args );
?>
</p>
<div class="sp-date-selector">
<p><label for="<?php echo $this->get_field_id('date'); ?>"><?php _e( 'Date:', 'sportspress' ); ?></label>
<p><label for="<?php echo $this->get_field_id( 'date' ); ?>"><?php _e( 'Date:', 'sportspress' ); ?></label>
<?php
$args = array(
'show_option_default' => __( 'Default', 'sportspress' ),
'name' => $this->get_field_name('date'),
'id' => $this->get_field_id('date'),
'selected' => $date,
'class' => 'sp-event-date-select widefat',
'name' => $this->get_field_name( 'date' ),
'id' => $this->get_field_id( 'date' ),
'selected' => $date,
'class' => 'sp-event-date-select widefat',
);
sp_dropdown_dates( $args );
?>
</p>
<div class="sp-date-range<?php if ( 'range' !== $date ): ?> hidden<?php endif; ?>">
<p class="sp-date-range-absolute<?php if ( $date_relative ): ?> hidden<?php endif; ?>">
<div class="sp-date-range
<?php
if ( 'range' !== $date ) :
?>
hidden<?php endif; ?>">
<p class="sp-date-range-absolute
<?php
if ( $date_relative ) :
?>
hidden<?php endif; ?>">
<input type="text" name="<?php echo $this->get_field_name( 'date_from' ); ?>" value="<?php echo $date_from; ?>" placeholder="yyyy-mm-dd" size="10">
:
<input type="text" name="<?php echo $this->get_field_name( 'date_to' ); ?>" value="<?php echo $date_to; ?>" placeholder="yyyy-mm-dd" size="10">
</p>
<p class="sp-date-range-relative<?php if ( ! $date_relative ): ?> hidden<?php endif; ?>">
<p class="sp-date-range-relative
<?php
if ( ! $date_relative ) :
?>
hidden<?php endif; ?>">
<?php _e( 'Past', 'sportspress' ); ?>
<input type="number" min="0" step="1" class="tiny-text" name="<?php echo $this->get_field_name( 'date_past' ); ?>" value="<?php echo $date_past; ?>">
&rarr;
@@ -169,14 +224,14 @@ class SP_Widget_Event_List extends WP_Widget {
</div>
</div>
<p><label for="<?php echo $this->get_field_id('day'); ?>"><?php _e( 'Match Day:', 'sportspress' ); ?></label>
<input id="<?php echo $this->get_field_id('day'); ?>" name="<?php echo $this->get_field_name('day'); ?>" type="text" placeholder="<?php _e( 'All', 'sportspress' ); ?>" value="<?php echo esc_attr($day); ?>" size="10"></p>
<p><label for="<?php echo $this->get_field_id( 'day' ); ?>"><?php _e( 'Match Day:', 'sportspress' ); ?></label>
<input id="<?php echo $this->get_field_id( 'day' ); ?>" name="<?php echo $this->get_field_name( 'day' ); ?>" type="text" placeholder="<?php _e( 'All', 'sportspress' ); ?>" value="<?php echo esc_attr( $day ); ?>" size="10"></p>
<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e( 'Number of events to show:', 'sportspress' ); ?></label>
<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo esc_attr($number); ?>" size="3"></p>
<p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of events to show:', 'sportspress' ); ?></label>
<input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="text" value="<?php echo esc_attr( $number ); ?>" size="3"></p>
<p><label for="<?php echo $this->get_field_id('order'); ?>"><?php _e( 'Sort Order:', 'sportspress' ); ?></label>
<select name="<?php echo $this->get_field_name('order'); ?>" id="<?php echo $this->get_field_id('order'); ?>" class="sp-select-order widefat">
<p><label for="<?php echo $this->get_field_id( 'order' ); ?>"><?php _e( 'Sort Order:', 'sportspress' ); ?></label>
<select name="<?php echo $this->get_field_name( 'order' ); ?>" id="<?php echo $this->get_field_id( 'order' ); ?>" class="sp-select-order widefat">
<option value="default" <?php selected( 'default', $order ); ?>><?php _e( 'Default', 'sportspress' ); ?></option>
<option value="ASC" <?php selected( 'ASC', $order ); ?>><?php _e( 'Ascending', 'sportspress' ); ?></option>
<option value="DESC" <?php selected( 'DESC', $order ); ?>><?php _e( 'Descending', 'sportspress' ); ?></option>
@@ -185,7 +240,7 @@ class SP_Widget_Event_List extends WP_Widget {
<p class="sp-prefs">
<?php _e( 'Columns:', 'sportspress' ); ?><br>
<?php
$the_columns = array();
$the_columns = array();
$the_columns['event'] = __( 'Event', 'sportspress' );
if ( 'combined' === $time_format ) {
@@ -203,20 +258,28 @@ class SP_Widget_Event_List extends WP_Widget {
}
}
$the_columns['venue'] = __( 'Venue', 'sportspress' );
$the_columns['venue'] = __( 'Venue', 'sportspress' );
$the_columns['article'] = __( 'Article', 'sportspress' );
$the_columns['day'] = __( 'Match Day', 'sportspress' );
$the_columns['day'] = __( 'Match Day', 'sportspress' );
$field_name = $this->get_field_name('columns') . '[]';
$field_id = $this->get_field_id('columns');
$field_name = $this->get_field_name( 'columns' ) . '[]';
$field_id = $this->get_field_id( 'columns' );
?>
<?php foreach ( $the_columns as $key => $label ): ?>
<label class="button"><input name="<?php echo $field_name; ?>" type="checkbox" id="<?php echo $field_id . '-' . $key; ?>" value="<?php echo $key; ?>" <?php if ( $columns === null || in_array( $key, $columns ) ): ?>checked="checked"<?php endif; ?>><?php echo $label; ?></label>
<?php foreach ( $the_columns as $key => $label ) : ?>
<label class="button"><input name="<?php echo $field_name; ?>" type="checkbox" id="<?php echo $field_id . '-' . $key; ?>" value="<?php echo $key; ?>"
<?php
if ( $columns === null || in_array( $key, $columns ) ) :
?>
checked="checked"<?php endif; ?>><?php echo $label; ?></label>
<?php endforeach; ?>
</p>
<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>
<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
// Action to hook into

View File

@@ -2,36 +2,54 @@
class SP_Widget_League_Table extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'widget_sportspress widget_league_table widget_sp_league_table', 'description' => __( 'Display a league table.', 'sportspress' ) );
parent::__construct('sportspress-league-table', __( 'League Table', 'sportspress' ), $widget_ops);
$widget_ops = array(
'classname' => 'widget_sportspress widget_league_table widget_sp_league_table',
'description' => __( 'Display a league table.', 'sportspress' ),
);
parent::__construct( 'sportspress-league-table', __( 'League Table', 'sportspress' ), $widget_ops );
}
function widget( $args, $instance ) {
extract($args);
$id = empty($instance['id']) ? 0 : $instance['id'];
if ( $id <= 0 ) return;
if ( 'yes' == get_option( 'sportspress_widget_unique', 'no' ) && get_the_ID() === $id ) return;
extract( $args );
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
$caption = empty($instance['caption']) ? null : $instance['caption'];
$number = empty($instance['number']) ? null : $instance['number'];
$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'];
$id = empty( $instance['id'] ) ? 0 : $instance['id'];
if ( $id <= 0 ) {
return;
}
if ( 'yes' == get_option( 'sportspress_widget_unique', 'no' ) && get_the_ID() === $id ) {
return;
}
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
$caption = empty( $instance['caption'] ) ? null : $instance['caption'];
$number = empty( $instance['number'] ) ? null : $instance['number'];
$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'];
do_action( 'sportspress_before_widget', $args, $instance, 'league-table' );
echo $before_widget;
if ( $title )
if ( $title ) {
echo $before_title . $title . $after_title;
}
// Action to hook into
do_action( 'sportspress_before_widget_template', $args, $instance, 'league-table' );
sp_get_template( 'league-table.php', array( 'id' => $id, 'title' => $caption, '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,
'title' => $caption,
'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_template', $args, $instance, 'league-table' );
@@ -41,13 +59,13 @@ class SP_Widget_League_Table extends WP_Widget {
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['id'] = intval($new_instance['id']);
$instance['caption'] = strip_tags($new_instance['caption']);
$instance['number'] = intval($new_instance['number']);
$instance['columns'] = (array)$new_instance['columns'];
$instance['show_team_logo'] = $new_instance['show_team_logo'];
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['id'] = intval( $new_instance['id'] );
$instance['caption'] = strip_tags( $new_instance['caption'] );
$instance['number'] = intval( $new_instance['number'] );
$instance['columns'] = (array) $new_instance['columns'];
$instance['show_team_logo'] = $new_instance['show_team_logo'];
$instance['show_full_table_link'] = $new_instance['show_full_table_link'];
// Filter to hook into
@@ -57,70 +75,85 @@ class SP_Widget_League_Table extends WP_Widget {
}
function form( $instance ) {
$defaults = apply_filters( 'sportspress_widget_defaults', array( 'title' => '', 'id' => '', 'caption' => '', 'number' => 5, 'columns' => null, 'show_team_logo' => false, 'show_full_table_link' => true ) );
$instance = wp_parse_args( (array) $instance, $defaults );
$title = strip_tags($instance['title']);
$id = intval($instance['id']);
$caption = strip_tags($instance['caption']);
$number = intval($instance['number']);
$columns = $instance['columns'];
$show_team_logo = $instance['show_team_logo'];
$defaults = apply_filters(
'sportspress_widget_defaults',
array(
'title' => '',
'id' => '',
'caption' => '',
'number' => 5,
'columns' => null,
'show_team_logo' => false,
'show_full_table_link' => true,
)
);
$instance = wp_parse_args( (array) $instance, $defaults );
$title = strip_tags( $instance['title'] );
$id = intval( $instance['id'] );
$caption = strip_tags( $instance['caption'] );
$number = intval( $instance['number'] );
$columns = $instance['columns'];
$show_team_logo = $instance['show_team_logo'];
$show_full_table_link = $instance['show_full_table_link'];
// Action to hook into
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>
<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>
<p><label for="<?php echo $this->get_field_id('caption'); ?>"><?php _e( 'Heading:', 'sportspress' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('caption'); ?>" name="<?php echo $this->get_field_name('caption'); ?>" type="text" value="<?php echo esc_attr($caption); ?>" /></p>
<p><label for="<?php echo $this->get_field_id( 'caption' ); ?>"><?php _e( 'Heading:', 'sportspress' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'caption' ); ?>" name="<?php echo $this->get_field_name( 'caption' ); ?>" type="text" value="<?php echo esc_attr( $caption ); ?>" /></p>
<p><label for="<?php echo $this->get_field_id('id'); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'League Table', 'sportspress' ) ); ?></label>
<p><label for="<?php echo $this->get_field_id( 'id' ); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'League Table', 'sportspress' ) ); ?></label>
<?php
$args = array(
'post_type' => 'sp_table',
'name' => $this->get_field_name('id'),
'id' => $this->get_field_id('id'),
'post_type' => 'sp_table',
'name' => $this->get_field_name( 'id' ),
'id' => $this->get_field_id( 'id' ),
'show_option_none' => __( '&mdash; Select &mdash;', 'sportspress' ),
'selected' => $id,
'values' => 'ID',
'class' => 'widefat',
'selected' => $id,
'values' => 'ID',
'class' => 'widefat',
);
if ( ! sp_dropdown_pages( $args ) ):
if ( ! sp_dropdown_pages( $args ) ) :
sp_post_adder( 'sp_table', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e( 'Number of teams to show:', 'sportspress' ); ?></label>
<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo esc_attr($number); ?>" size="3"></p>
<p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of teams to show:', 'sportspress' ); ?></label>
<input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="text" value="<?php echo esc_attr( $number ); ?>" size="3"></p>
<p class="sp-prefs">
<?php _e( 'Columns:', 'sportspress' ); ?><br>
<?php
$args = array(
'post_type' => 'sp_column',
'numberposts' => -1,
<?php
$args = array(
'post_type' => 'sp_column',
'numberposts' => -1,
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC'
'orderby' => 'menu_order',
'order' => 'ASC',
);
$the_columns = get_posts( $args );
$field_name = $this->get_field_name('columns') . '[]';
$field_id = $this->get_field_id('columns');
$field_name = $this->get_field_name( 'columns' ) . '[]';
$field_id = $this->get_field_id( 'columns' );
?>
<?php foreach ( $the_columns as $column ): ?>
<label class="button"><input name="<?php echo $field_name; ?>" type="checkbox" id="<?php echo $field_id . '-' . $column->post_name; ?>" value="<?php echo $column->post_name; ?>" <?php if ( $columns === null || in_array( $column->post_name, $columns ) ): ?>checked="checked"<?php endif; ?>><?php echo $column->post_title; ?></label>
<?php foreach ( $the_columns as $column ) : ?>
<label class="button"><input name="<?php echo $field_name; ?>" type="checkbox" id="<?php echo $field_id . '-' . $column->post_name; ?>" value="<?php echo $column->post_name; ?>"
<?php
if ( $columns === null || in_array( $column->post_name, $columns ) ) :
?>
checked="checked"<?php endif; ?>><?php echo $column->post_title; ?></label>
<?php endforeach; ?>
</p>
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_team_logo'); ?>" name="<?php echo $this->get_field_name('show_team_logo'); ?>" value="1" <?php checked( $show_team_logo, 1 ); ?>>
<label for="<?php echo $this->get_field_id('show_team_logo'); ?>"><?php _e( 'Display logos', 'sportspress' ); ?></label><br>
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id( 'show_team_logo' ); ?>" name="<?php echo $this->get_field_name( 'show_team_logo' ); ?>" value="1" <?php checked( $show_team_logo, 1 ); ?>>
<label for="<?php echo $this->get_field_id( 'show_team_logo' ); ?>"><?php _e( 'Display logos', 'sportspress' ); ?></label><br>
<input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_full_table_link'); ?>" name="<?php echo $this->get_field_name('show_full_table_link'); ?>" value="1" <?php checked( $show_full_table_link, 1 ); ?>>
<label for="<?php echo $this->get_field_id('show_full_table_link'); ?>"><?php _e( 'Display link to view full table', 'sportspress' ); ?></label></p>
<input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id( 'show_full_table_link' ); ?>" name="<?php echo $this->get_field_name( 'show_full_table_link' ); ?>" value="1" <?php checked( $show_full_table_link, 1 ); ?>>
<label for="<?php echo $this->get_field_id( 'show_full_table_link' ); ?>"><?php _e( 'Display link to view full table', 'sportspress' ); ?></label></p>
<?php
// Action to hook into

View File

@@ -2,40 +2,60 @@
class SP_Widget_Player_Gallery extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'widget_sportspress widget_player_gallery widget_sp_player_gallery', 'description' => __( 'Display a gallery of players.', 'sportspress' ) );
parent::__construct('sportspress-player-gallery', __( 'Player Gallery', 'sportspress' ), $widget_ops);
$widget_ops = array(
'classname' => 'widget_sportspress widget_player_gallery widget_sp_player_gallery',
'description' => __( 'Display a gallery of players.', 'sportspress' ),
);
parent::__construct( 'sportspress-player-gallery', __( 'Player Gallery', 'sportspress' ), $widget_ops );
}
function widget( $args, $instance ) {
extract($args);
$id = empty($instance['id']) ? 0 : $instance['id'];
if ( $id <= 0 ) return;
if ( 'yes' == get_option( 'sportspress_widget_unique', 'no' ) && get_the_ID() === $id ) {
$format = get_post_meta( $id, 'sp_format', true );
if ( 'gallery' == $format ) return;
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);
$caption = empty($instance['caption']) ? null : $instance['caption'];
$number = empty($instance['number']) ? null : $instance['number'];
$columns = empty($instance['columns']) ? null : $instance['columns'];
$orderby = empty($instance['orderby']) ? 'default' : $instance['orderby'];
$order = empty($instance['order']) ? 'ASC' : $instance['order'];
$show_all_players_link = empty($instance['show_all_players_link']) ? false : $instance['show_all_players_link'];
if ( 'yes' == get_option( 'sportspress_widget_unique', 'no' ) && get_the_ID() === $id ) {
$format = get_post_meta( $id, 'sp_format', true );
if ( 'gallery' == $format ) {
return;
}
}
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
$caption = empty( $instance['caption'] ) ? null : $instance['caption'];
$number = empty( $instance['number'] ) ? null : $instance['number'];
$columns = empty( $instance['columns'] ) ? null : $instance['columns'];
$orderby = empty( $instance['orderby'] ) ? 'default' : $instance['orderby'];
$order = empty( $instance['order'] ) ? 'ASC' : $instance['order'];
$show_all_players_link = empty( $instance['show_all_players_link'] ) ? false : $instance['show_all_players_link'];
do_action( 'sportspress_before_widget', $args, $instance, 'player-gallery' );
echo $before_widget;
if ( $title )
if ( $title ) {
echo $before_title . $title . $after_title;
}
// Action to hook into
do_action( 'sportspress_before_widget_template', $args, $instance, 'player-gallery' );
sp_get_template( 'player-gallery.php', array( 'id' => $id, 'title' => $caption, 'number' => $number, 'columns' => $columns, 'orderby' => $orderby , 'order' => $order, 'grouping' => 0, 'show_all_players_link' => $show_all_players_link ) );
sp_get_template(
'player-gallery.php',
array(
'id' => $id,
'title' => $caption,
'number' => $number,
'columns' => $columns,
'orderby' => $orderby,
'order' => $order,
'grouping' => 0,
'show_all_players_link' => $show_all_players_link,
)
);
// Action to hook into
do_action( 'sportspress_after_widget_template', $args, $instance, 'player-gallery' );
@@ -45,14 +65,14 @@ class SP_Widget_Player_Gallery extends WP_Widget {
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['id'] = intval($new_instance['id']);
$instance['caption'] = strip_tags($new_instance['caption']);
$instance['number'] = intval($new_instance['number']);
$instance['columns'] = intval($new_instance['columns']);
$instance['orderby'] = strip_tags($new_instance['orderby']);
$instance['order'] = strip_tags($new_instance['order']);
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['id'] = intval( $new_instance['id'] );
$instance['caption'] = strip_tags( $new_instance['caption'] );
$instance['number'] = intval( $new_instance['number'] );
$instance['columns'] = intval( $new_instance['columns'] );
$instance['orderby'] = strip_tags( $new_instance['orderby'] );
$instance['order'] = strip_tags( $new_instance['order'] );
$instance['show_all_players_link'] = $new_instance['show_all_players_link'];
// Filter to hook into
@@ -62,80 +82,92 @@ class SP_Widget_Player_Gallery extends WP_Widget {
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '', 'caption' => '', 'number' => 5, 'columns' => 2, 'orderby' => 'default', 'order' => 'ASC', 'show_all_players_link' => true ) );
$title = strip_tags($instance['title']);
$id = intval($instance['id']);
$caption = strip_tags($instance['caption']);
$number = intval($instance['number']);
$columns = intval($instance['columns']);
$orderby = strip_tags($instance['orderby']);
$order = strip_tags($instance['order']);
$instance = wp_parse_args(
(array) $instance,
array(
'title' => '',
'id' => '',
'caption' => '',
'number' => 5,
'columns' => 2,
'orderby' => 'default',
'order' => 'ASC',
'show_all_players_link' => true,
)
);
$title = strip_tags( $instance['title'] );
$id = intval( $instance['id'] );
$caption = strip_tags( $instance['caption'] );
$number = intval( $instance['number'] );
$columns = intval( $instance['columns'] );
$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-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>
<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>
<p><label for="<?php echo $this->get_field_id('caption'); ?>"><?php _e( 'Heading:', 'sportspress' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('caption'); ?>" name="<?php echo $this->get_field_name('caption'); ?>" type="text" value="<?php echo esc_attr($caption); ?>" /></p>
<p><label for="<?php echo $this->get_field_id( 'caption' ); ?>"><?php _e( 'Heading:', 'sportspress' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'caption' ); ?>" name="<?php echo $this->get_field_name( 'caption' ); ?>" type="text" value="<?php echo esc_attr( $caption ); ?>" /></p>
<p><label for="<?php echo $this->get_field_id('id'); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Player List', 'sportspress' ) ); ?></label>
<p><label for="<?php echo $this->get_field_id( 'id' ); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Player List', 'sportspress' ) ); ?></label>
<?php
$args = array(
'post_type' => 'sp_list',
'name' => $this->get_field_name('id'),
'id' => $this->get_field_id('id'),
'selected' => $id,
'values' => 'ID',
'class' => 'widefat',
'name' => $this->get_field_name( 'id' ),
'id' => $this->get_field_id( 'id' ),
'selected' => $id,
'values' => 'ID',
'class' => 'widefat',
);
if ( ! sp_dropdown_pages( $args ) ):
if ( ! sp_dropdown_pages( $args ) ) :
sp_post_adder( 'sp_list', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e( 'Number of players to show:', 'sportspress' ); ?></label>
<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo esc_attr($number); ?>" size="3"></p>
<p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of players to show:', 'sportspress' ); ?></label>
<input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="text" value="<?php echo esc_attr( $number ); ?>" size="3"></p>
<p><label for="<?php echo $this->get_field_id('columns'); ?>"><?php _e( 'Columns:', 'sportspress' ); ?></label>
<input id="<?php echo $this->get_field_id('columns'); ?>" name="<?php echo $this->get_field_name('columns'); ?>" type="text" value="<?php echo esc_attr($columns); ?>" size="3"></p>
<p><label for="<?php echo $this->get_field_id( 'columns' ); ?>"><?php _e( 'Columns:', 'sportspress' ); ?></label>
<input id="<?php echo $this->get_field_id( 'columns' ); ?>" name="<?php echo $this->get_field_name( 'columns' ); ?>" type="text" value="<?php echo esc_attr( $columns ); ?>" size="3"></p>
<p><label for="<?php echo $this->get_field_id('orderby'); ?>"><?php _e( 'Sort by:', 'sportspress' ); ?></label>
<p><label for="<?php echo $this->get_field_id( 'orderby' ); ?>"><?php _e( 'Sort by:', 'sportspress' ); ?></label>
<?php
$args = array(
'prepend_options' => array(
'default' => __( 'Default', 'sportspress' ),
'number' => __( 'Squad Number', 'sportspress' ),
'name' => __( 'Name', 'sportspress' ),
'eventsplayed' => __( 'Played', 'sportspress' )
'default' => __( 'Default', 'sportspress' ),
'number' => __( 'Squad Number', 'sportspress' ),
'name' => __( 'Name', 'sportspress' ),
'eventsplayed' => __( 'Played', 'sportspress' ),
),
'append_options' => array(
'append_options' => array(
'rand' => __( 'Random', 'sportspress' ),
),
'post_type' => 'sp_performance',
'name' => $this->get_field_name('orderby'),
'id' => $this->get_field_id('orderby'),
'selected' => $orderby,
'values' => 'slug',
'class' => 'sp-select-orderby widefat',
'post_type' => 'sp_performance',
'name' => $this->get_field_name( 'orderby' ),
'id' => $this->get_field_id( 'orderby' ),
'selected' => $orderby,
'values' => 'slug',
'class' => 'sp-select-orderby widefat',
);
if ( ! sp_dropdown_pages( $args ) ):
if ( ! sp_dropdown_pages( $args ) ) :
sp_post_adder( 'sp_list', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p><label for="<?php echo $this->get_field_id('order'); ?>"><?php _e( 'Sort Order:', 'sportspress' ); ?></label>
<select name="<?php echo $this->get_field_name('order'); ?>" id="<?php echo $this->get_field_id('order'); ?>" class="sp-select-order widefat" <?php disabled( $orderby, 'default' ); ?>>
<p><label for="<?php echo $this->get_field_id( 'order' ); ?>"><?php _e( 'Sort Order:', 'sportspress' ); ?></label>
<select name="<?php echo $this->get_field_name( 'order' ); ?>" id="<?php echo $this->get_field_id( 'order' ); ?>" class="sp-select-order widefat" <?php disabled( $orderby, 'default' ); ?>>
<option value="ASC" <?php selected( 'ASC', $order ); ?>><?php _e( 'Ascending', 'sportspress' ); ?></option>
<option value="DESC" <?php selected( 'DESC', $order ); ?>><?php _e( 'Descending', 'sportspress' ); ?></option>
</select></p>
<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>
<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
// Action to hook into

View File

@@ -2,40 +2,60 @@
class SP_Widget_Player_list extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'widget_sportspress widget_player_list widget_sp_player_list', 'description' => __( 'Display a list of players.', 'sportspress' ) );
parent::__construct('sportspress-player-list', __( 'Player List', 'sportspress' ), $widget_ops);
$widget_ops = array(
'classname' => 'widget_sportspress widget_player_list widget_sp_player_list',
'description' => __( 'Display a list of players.', 'sportspress' ),
);
parent::__construct( 'sportspress-player-list', __( 'Player List', 'sportspress' ), $widget_ops );
}
function widget( $args, $instance ) {
extract($args);
$id = empty($instance['id']) ? 0 : $instance['id'];
if ( $id <= 0 ) return;
if ( 'yes' == get_option( 'sportspress_widget_unique', 'no' ) && get_the_ID() === $id ) {
$format = get_post_meta( $id, 'sp_format', true );
if ( 'list' == $format ) return;
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);
$caption = empty($instance['caption']) ? null : $instance['caption'];
$number = empty($instance['number']) ? null : $instance['number'];
$columns = $instance['columns'];
$orderby = empty($instance['orderby']) ? 'default' : $instance['orderby'];
$order = empty($instance['order']) ? 'ASC' : $instance['order'];
$show_all_players_link = empty($instance['show_all_players_link']) ? false : $instance['show_all_players_link'];
if ( 'yes' == get_option( 'sportspress_widget_unique', 'no' ) && get_the_ID() === $id ) {
$format = get_post_meta( $id, 'sp_format', true );
if ( 'list' == $format ) {
return;
}
}
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
$caption = empty( $instance['caption'] ) ? null : $instance['caption'];
$number = empty( $instance['number'] ) ? null : $instance['number'];
$columns = $instance['columns'];
$orderby = empty( $instance['orderby'] ) ? 'default' : $instance['orderby'];
$order = empty( $instance['order'] ) ? 'ASC' : $instance['order'];
$show_all_players_link = empty( $instance['show_all_players_link'] ) ? false : $instance['show_all_players_link'];
do_action( 'sportspress_before_widget', $args, $instance, 'player-list' );
echo $before_widget;
if ( $title )
if ( $title ) {
echo $before_title . $title . $after_title;
}
// Action to hook into
do_action( 'sportspress_before_widget_template', $args, $instance, 'player-list' );
sp_get_template( 'player-list.php', array( 'id' => $id, 'title' => $caption, 'number' => $number, 'columns' => $columns, 'orderby' => $orderby, 'order' => $order, 'grouping' => 0, 'show_all_players_link' => $show_all_players_link ) );
sp_get_template(
'player-list.php',
array(
'id' => $id,
'title' => $caption,
'number' => $number,
'columns' => $columns,
'orderby' => $orderby,
'order' => $order,
'grouping' => 0,
'show_all_players_link' => $show_all_players_link,
)
);
// Action to hook into
do_action( 'sportspress_after_widget_template', $args, $instance, 'player-list' );
@@ -45,14 +65,14 @@ class SP_Widget_Player_list extends WP_Widget {
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['id'] = intval($new_instance['id']);
$instance['caption'] = strip_tags($new_instance['caption']);
$instance['number'] = intval($new_instance['number']);
$instance['columns'] = (array)$new_instance['columns'];
$instance['orderby'] = strip_tags($new_instance['orderby']);
$instance['order'] = strip_tags($new_instance['order']);
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['id'] = intval( $new_instance['id'] );
$instance['caption'] = strip_tags( $new_instance['caption'] );
$instance['number'] = intval( $new_instance['number'] );
$instance['columns'] = (array) $new_instance['columns'];
$instance['orderby'] = strip_tags( $new_instance['orderby'] );
$instance['order'] = strip_tags( $new_instance['order'] );
$instance['show_all_players_link'] = $new_instance['show_all_players_link'];
// Filter to hook into
@@ -62,105 +82,127 @@ class SP_Widget_Player_list extends WP_Widget {
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '', 'caption' => '', 'number' => 5, 'columns' => null, 'orderby' => 'default', 'order' => 'ASC', 'show_all_players_link' => true ) );
$title = strip_tags($instance['title']);
$id = intval($instance['id']);
$caption = strip_tags($instance['caption']);
$number = intval($instance['number']);
$columns = $instance['columns'];
$orderby = strip_tags($instance['orderby']);
$order = strip_tags($instance['order']);
$instance = wp_parse_args(
(array) $instance,
array(
'title' => '',
'id' => '',
'caption' => '',
'number' => 5,
'columns' => null,
'orderby' => 'default',
'order' => 'ASC',
'show_all_players_link' => true,
)
);
$title = strip_tags( $instance['title'] );
$id = intval( $instance['id'] );
$caption = strip_tags( $instance['caption'] );
$number = intval( $instance['number'] );
$columns = $instance['columns'];
$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>
<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>
<p><label for="<?php echo $this->get_field_id('caption'); ?>"><?php _e( 'Heading:', 'sportspress' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('caption'); ?>" name="<?php echo $this->get_field_name('caption'); ?>" type="text" value="<?php echo esc_attr($caption); ?>" /></p>
<p><label for="<?php echo $this->get_field_id( 'caption' ); ?>"><?php _e( 'Heading:', 'sportspress' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'caption' ); ?>" name="<?php echo $this->get_field_name( 'caption' ); ?>" type="text" value="<?php echo esc_attr( $caption ); ?>" /></p>
<p><label for="<?php echo $this->get_field_id('id'); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Player List', 'sportspress' ) ); ?></label>
<p><label for="<?php echo $this->get_field_id( 'id' ); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Player List', 'sportspress' ) ); ?></label>
<?php
$args = array(
'post_type' => 'sp_list',
'name' => $this->get_field_name('id'),
'id' => $this->get_field_id('id'),
'selected' => $id,
'values' => 'ID',
'class' => 'widefat',
'name' => $this->get_field_name( 'id' ),
'id' => $this->get_field_id( 'id' ),
'selected' => $id,
'values' => 'ID',
'class' => 'widefat',
);
if ( ! sp_dropdown_pages( $args ) ):
if ( ! sp_dropdown_pages( $args ) ) :
sp_post_adder( 'sp_list', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e( 'Number of players to show:', 'sportspress' ); ?></label>
<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo esc_attr($number); ?>" size="3"></p>
<p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of players to show:', 'sportspress' ); ?></label>
<input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="text" value="<?php echo esc_attr( $number ); ?>" size="3"></p>
<p class="sp-prefs">
<?php _e( 'Performance:', 'sportspress' ); ?><br>
<?php
$args = array(
'post_type' => array( 'sp_metric', 'sp_performance', 'sp_statistic' ),
'numberposts' => -1,
<?php
$args = array(
'post_type' => array( 'sp_metric', 'sp_performance', 'sp_statistic' ),
'numberposts' => -1,
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC'
'orderby' => 'menu_order',
'order' => 'ASC',
);
$the_columns = get_posts( $args );
$field_name = $this->get_field_name('columns') . '[]';
$field_id = $this->get_field_id('columns');
$field_name = $this->get_field_name( 'columns' ) . '[]';
$field_id = $this->get_field_id( 'columns' );
?>
<label class="button"><input name="<?php echo $field_name; ?>" type="checkbox" id="<?php echo $field_id; ?>-number" value="number" <?php if ( $columns === null || in_array( 'number', $columns ) ): ?>checked="checked"<?php endif; ?>><?php
if ( 'default' == $orderby ) {
_e( 'Rank', 'sportspress' );
echo '/';
_e( 'Squad Number', 'sportspress' );
} elseif ( in_array( $orderby, array( 'number', 'name' ) ) ) {
_e( 'Squad Number', 'sportspress' );
} else {
_e( 'Rank', 'sportspress' );
}
?></label>
<?php foreach ( $the_columns as $column ): ?>
<label class="button"><input name="<?php echo $field_name; ?>" type="checkbox" id="<?php echo $field_id . '-' . $column->post_name; ?>" value="<?php echo $column->post_name; ?>" <?php if ( $columns === null || in_array( $column->post_name, $columns ) ): ?>checked="checked"<?php endif; ?>><?php echo $column->post_title; ?></label>
<label class="button"><input name="<?php echo $field_name; ?>" type="checkbox" id="<?php echo $field_id; ?>-number" value="number"
<?php
if ( $columns === null || in_array( 'number', $columns ) ) :
?>
checked="checked"<?php endif; ?>>
<?php
if ( 'default' == $orderby ) {
_e( 'Rank', 'sportspress' );
echo '/';
_e( 'Squad Number', 'sportspress' );
} elseif ( in_array( $orderby, array( 'number', 'name' ) ) ) {
_e( 'Squad Number', 'sportspress' );
} else {
_e( 'Rank', 'sportspress' );
}
?>
</label>
<?php foreach ( $the_columns as $column ) : ?>
<label class="button"><input name="<?php echo $field_name; ?>" type="checkbox" id="<?php echo $field_id . '-' . $column->post_name; ?>" value="<?php echo $column->post_name; ?>"
<?php
if ( $columns === null || in_array( $column->post_name, $columns ) ) :
?>
checked="checked"<?php endif; ?>><?php echo $column->post_title; ?></label>
<?php endforeach; ?>
</p>
<p><label for="<?php echo $this->get_field_id('orderby'); ?>"><?php _e( 'Sort by:', 'sportspress' ); ?></label>
<p><label for="<?php echo $this->get_field_id( 'orderby' ); ?>"><?php _e( 'Sort by:', 'sportspress' ); ?></label>
<?php
$args = array(
'prepend_options' => array(
'default' => __( 'Default', 'sportspress' ),
'number' => __( 'Squad Number', 'sportspress' ),
'name' => __( 'Name', 'sportspress' ),
'eventsplayed' => __( 'Played', 'sportspress' )
'default' => __( 'Default', 'sportspress' ),
'number' => __( 'Squad Number', 'sportspress' ),
'name' => __( 'Name', 'sportspress' ),
'eventsplayed' => __( 'Played', 'sportspress' ),
),
'post_type' => array( 'sp_metric', 'sp_performance', 'sp_statistic' ),
'name' => $this->get_field_name('orderby'),
'id' => $this->get_field_id('orderby'),
'selected' => $orderby,
'values' => 'slug',
'class' => 'sp-select-orderby widefat',
'post_type' => array( 'sp_metric', 'sp_performance', 'sp_statistic' ),
'name' => $this->get_field_name( 'orderby' ),
'id' => $this->get_field_id( 'orderby' ),
'selected' => $orderby,
'values' => 'slug',
'class' => 'sp-select-orderby widefat',
);
if ( ! sp_dropdown_pages( $args ) ):
if ( ! sp_dropdown_pages( $args ) ) :
sp_post_adder( 'sp_list', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p><label for="<?php echo $this->get_field_id('order'); ?>"><?php _e( 'Sort Order:', 'sportspress' ); ?></label>
<select name="<?php echo $this->get_field_name('order'); ?>" id="<?php echo $this->get_field_id('order'); ?>" class="sp-select-order widefat" <?php disabled( $orderby, 'default' ); ?>>
<p><label for="<?php echo $this->get_field_id( 'order' ); ?>"><?php _e( 'Sort Order:', 'sportspress' ); ?></label>
<select name="<?php echo $this->get_field_name( 'order' ); ?>" id="<?php echo $this->get_field_id( 'order' ); ?>" class="sp-select-order widefat" <?php disabled( $orderby, 'default' ); ?>>
<option value="ASC" <?php selected( 'ASC', $order ); ?>><?php _e( 'Ascending', 'sportspress' ); ?></option>
<option value="DESC" <?php selected( 'DESC', $order ); ?>><?php _e( 'Descending', 'sportspress' ); ?></option>
</select></p>
<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>
<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
// Action to hook into

View File

@@ -2,20 +2,24 @@
class SP_Widget_Staff extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'widget_sportspress widget_staff widget_sp_staff', 'description' => __( 'Display a single staff member.', 'sportspress' ) );
parent::__construct('sportspress-staff', __( 'Staff', 'sportspress' ), $widget_ops);
$widget_ops = array(
'classname' => 'widget_sportspress widget_staff widget_sp_staff',
'description' => __( 'Display a single staff member.', 'sportspress' ),
);
parent::__construct( 'sportspress-staff', __( 'Staff', 'sportspress' ), $widget_ops );
}
function widget( $args, $instance ) {
extract($args);
$title = apply_filters('widget_title', empty($instance['title']) ? null : $instance['title'], $instance, $this->id_base);
$id = empty($instance['id']) ? null : $instance['id'];
extract( $args );
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? null : $instance['title'], $instance, $this->id_base );
$id = empty( $instance['id'] ) ? null : $instance['id'];
do_action( 'sportspress_before_widget', $args, $instance, 'staff' );
echo $before_widget;
if ( $title )
if ( $title ) {
echo $before_title . $title . $after_title;
}
// Action to hook into
do_action( 'sportspress_before_widget_template', $args, $instance, 'staff' );
@@ -33,9 +37,9 @@ class SP_Widget_Staff extends WP_Widget {
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['id'] = intval($new_instance['id']);
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['id'] = intval( $new_instance['id'] );
// Filter to hook into
$instance = apply_filters( 'sportspress_widget_update', $instance, $new_instance, $old_instance, 'staff' );
@@ -44,27 +48,33 @@ class SP_Widget_Staff extends WP_Widget {
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '' ) );
$title = strip_tags($instance['title']);
$id = intval($instance['id']);
$instance = wp_parse_args(
(array) $instance,
array(
'title' => '',
'id' => '',
)
);
$title = strip_tags( $instance['title'] );
$id = intval( $instance['id'] );
// Action to hook into
do_action( 'sportspress_before_widget_template_form', $this, $instance, 'staff' );
?>
<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>
<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>
<p><label for="<?php echo $this->get_field_id('id'); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Staff', 'sportspress' ) ); ?></label>
<p><label for="<?php echo $this->get_field_id( 'id' ); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Staff', 'sportspress' ) ); ?></label>
<?php
$args = array(
'post_type' => 'sp_staff',
'name' => $this->get_field_name('id'),
'id' => $this->get_field_id('id'),
'selected' => $id,
'values' => 'ID',
'class' => 'widefat',
'name' => $this->get_field_name( 'id' ),
'id' => $this->get_field_id( 'id' ),
'selected' => $id,
'values' => 'ID',
'class' => 'widefat',
);
if ( ! sp_dropdown_pages( $args ) ):
if ( ! sp_dropdown_pages( $args ) ) :
sp_post_adder( 'sp_staff', __( 'Add New', 'sportspress' ) );
endif;
?>

View File

@@ -2,39 +2,58 @@
class SP_Widget_Team_Gallery extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'widget_sportspress widget_team_gallery widget_sp_team_gallery', 'description' => __( 'Display a gallery of teams.', 'sportspress' ) );
parent::__construct('sportspress-team-gallery', __( 'Team Gallery', 'sportspress' ), $widget_ops);
$widget_ops = array(
'classname' => 'widget_sportspress widget_team_gallery widget_sp_team_gallery',
'description' => __( 'Display a gallery of teams.', 'sportspress' ),
);
parent::__construct( 'sportspress-team-gallery', __( 'Team Gallery', 'sportspress' ), $widget_ops );
}
function widget( $args, $instance ) {
extract($args);
$id = empty($instance['id']) ? 0 : $instance['id'];
if ( $id <= 0 ) return;
if ( 'yes' == get_option( 'sportspress_widget_unique', 'no' ) && get_the_ID() === $id ) {
$format = get_post_meta( $id, 'sp_format', true );
if ( 'gallery' == $format ) return;
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);
$caption = empty($instance['caption']) ? null : $instance['caption'];
$number = empty($instance['number']) ? null : $instance['number'];
$columns = empty($instance['columns']) ? null : $instance['columns'];
$orderby = empty($instance['orderby']) ? 'default' : $instance['orderby'];
$show_all_teams_link = empty($instance['show_all_teams_link']) ? false : $instance['show_all_teams_link'];
if ( 'yes' == get_option( 'sportspress_widget_unique', 'no' ) && get_the_ID() === $id ) {
$format = get_post_meta( $id, 'sp_format', true );
if ( 'gallery' == $format ) {
return;
}
}
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
$caption = empty( $instance['caption'] ) ? null : $instance['caption'];
$number = empty( $instance['number'] ) ? null : $instance['number'];
$columns = empty( $instance['columns'] ) ? null : $instance['columns'];
$orderby = empty( $instance['orderby'] ) ? 'default' : $instance['orderby'];
$show_all_teams_link = empty( $instance['show_all_teams_link'] ) ? false : $instance['show_all_teams_link'];
do_action( 'sportspress_before_widget', $args, $instance, 'team-gallery' );
echo $before_widget;
if ( $title )
if ( $title ) {
echo $before_title . $title . $after_title;
}
// Action to hook into
do_action( 'sportspress_before_widget_template', $args, $instance, 'team-gallery' );
sp_get_template( 'team-gallery.php', array( 'id' => $id, 'title' => $caption, 'number' => $number, 'columns' => $columns, 'orderby' => $orderby , 'grouping' => 0, 'show_all_teams_link' => $show_all_teams_link ) );
sp_get_template(
'team-gallery.php',
array(
'id' => $id,
'title' => $caption,
'number' => $number,
'columns' => $columns,
'orderby' => $orderby,
'grouping' => 0,
'show_all_teams_link' => $show_all_teams_link,
)
);
// Action to hook into
do_action( 'sportspress_after_widget_template', $args, $instance, 'team-gallery' );
@@ -44,13 +63,13 @@ class SP_Widget_Team_Gallery extends WP_Widget {
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['id'] = intval($new_instance['id']);
$instance['caption'] = strip_tags($new_instance['caption']);
$instance['number'] = intval($new_instance['number']);
$instance['columns'] = intval($new_instance['columns']);
$instance['orderby'] = strip_tags($new_instance['orderby']);
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['id'] = intval( $new_instance['id'] );
$instance['caption'] = strip_tags( $new_instance['caption'] );
$instance['number'] = intval( $new_instance['number'] );
$instance['columns'] = intval( $new_instance['columns'] );
$instance['orderby'] = strip_tags( $new_instance['orderby'] );
$instance['show_all_teams_link'] = $new_instance['show_all_teams_link'];
// Filter to hook into
@@ -60,55 +79,66 @@ class SP_Widget_Team_Gallery extends WP_Widget {
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '', 'caption' => '', 'number' => 5, 'columns' => 2, 'orderby' => 'default', 'show_all_teams_link' => true ) );
$title = strip_tags($instance['title']);
$id = intval($instance['id']);
$caption = strip_tags($instance['caption']);
$number = intval($instance['number']);
$columns = intval($instance['columns']);
$orderby = strip_tags($instance['orderby']);
$instance = wp_parse_args(
(array) $instance,
array(
'title' => '',
'id' => '',
'caption' => '',
'number' => 5,
'columns' => 2,
'orderby' => 'default',
'show_all_teams_link' => true,
)
);
$title = strip_tags( $instance['title'] );
$id = intval( $instance['id'] );
$caption = strip_tags( $instance['caption'] );
$number = intval( $instance['number'] );
$columns = intval( $instance['columns'] );
$orderby = strip_tags( $instance['orderby'] );
$show_all_teams_link = $instance['show_all_teams_link'];
// Action to hook into
do_action( 'sportspress_before_widget_template_form', $this, $instance, 'team-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>
<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>
<p><label for="<?php echo $this->get_field_id('caption'); ?>"><?php _e( 'Heading:', 'sportspress' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('caption'); ?>" name="<?php echo $this->get_field_name('caption'); ?>" type="text" value="<?php echo esc_attr($caption); ?>" /></p>
<p><label for="<?php echo $this->get_field_id( 'caption' ); ?>"><?php _e( 'Heading:', 'sportspress' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'caption' ); ?>" name="<?php echo $this->get_field_name( 'caption' ); ?>" type="text" value="<?php echo esc_attr( $caption ); ?>" /></p>
<p><label for="<?php echo $this->get_field_id('id'); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'League Table', 'sportspress' ) ); ?></label>
<p><label for="<?php echo $this->get_field_id( 'id' ); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'League Table', 'sportspress' ) ); ?></label>
<?php
$args = array(
'post_type' => 'sp_table',
'name' => $this->get_field_name('id'),
'id' => $this->get_field_id('id'),
'selected' => $id,
'values' => 'ID',
'class' => 'widefat',
'name' => $this->get_field_name( 'id' ),
'id' => $this->get_field_id( 'id' ),
'selected' => $id,
'values' => 'ID',
'class' => 'widefat',
);
if ( ! sp_dropdown_pages( $args ) ):
if ( ! sp_dropdown_pages( $args ) ) :
sp_post_adder( 'sp_table', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e( 'Number of teams to show:', 'sportspress' ); ?></label>
<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo esc_attr($number); ?>" size="3"></p>
<p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of teams to show:', 'sportspress' ); ?></label>
<input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="text" value="<?php echo esc_attr( $number ); ?>" size="3"></p>
<p><label for="<?php echo $this->get_field_id('columns'); ?>"><?php _e( 'Columns:', 'sportspress' ); ?></label>
<input id="<?php echo $this->get_field_id('columns'); ?>" name="<?php echo $this->get_field_name('columns'); ?>" type="text" value="<?php echo esc_attr($columns); ?>" size="3"></p>
<p><label for="<?php echo $this->get_field_id( 'columns' ); ?>"><?php _e( 'Columns:', 'sportspress' ); ?></label>
<input id="<?php echo $this->get_field_id( 'columns' ); ?>" name="<?php echo $this->get_field_name( 'columns' ); ?>" type="text" value="<?php echo esc_attr( $columns ); ?>" size="3"></p>
<p><label for="<?php echo $this->get_field_id('orderby'); ?>"><?php _e( 'Sort by:', 'sportspress' ); ?></label>
<select id="<?php echo $this->get_field_id('orderby'); ?>" name="<?php echo $this->get_field_name('orderby'); ?>">
<p><label for="<?php echo $this->get_field_id( 'orderby' ); ?>"><?php _e( 'Sort by:', 'sportspress' ); ?></label>
<select id="<?php echo $this->get_field_id( 'orderby' ); ?>" name="<?php echo $this->get_field_name( 'orderby' ); ?>">
<option value="default" <?php selected( 'default', $orderby ); ?>><?php _e( 'Rank', 'sportspress' ); ?></option>
<option value="name" <?php selected( 'name', $orderby ); ?>><?php _e( 'Alphabetical', 'sportspress' ); ?></option>
<option value="rand" <?php selected( 'rand', $orderby ); ?>><?php _e( 'Random', 'sportspress' ); ?></option>
</select></p>
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_all_teams_link'); ?>" name="<?php echo $this->get_field_name('show_all_teams_link'); ?>" value="1" <?php checked( $show_all_teams_link, 1 ); ?>>
<label for="<?php echo $this->get_field_id('show_all_teams_link'); ?>"><?php _e( 'Display link to view all teams', 'sportspress' ); ?></label></p>
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id( 'show_all_teams_link' ); ?>" name="<?php echo $this->get_field_name( 'show_all_teams_link' ); ?>" value="1" <?php checked( $show_all_teams_link, 1 ); ?>>
<label for="<?php echo $this->get_field_id( 'show_all_teams_link' ); ?>"><?php _e( 'Display link to view all teams', 'sportspress' ); ?></label></p>
<?php
// Action to hook into