Add option to turn on and off player numbers in player list widget

This commit is contained in:
Brian Miyaji
2015-12-29 15:20:07 +11:00
parent f0a36da63f
commit bf5585d805

View File

@@ -8,8 +8,16 @@ class SP_Widget_Player_list extends WP_Widget {
function widget( $args, $instance ) {
extract($args);
$id = empty($instance['id']) ? 0 : $instance['id'];
if ( $id <= 0 ) return;
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'];
@@ -107,6 +115,17 @@ class SP_Widget_Player_list extends WP_Widget {
$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>
<?php endforeach; ?>