Add widget option to show view full table link in league table

This commit is contained in:
Brian Miyaji
2014-03-06 22:39:05 +11:00
parent 5ea50608a5
commit a09f97d7af
2 changed files with 17 additions and 4 deletions

View File

@@ -10,12 +10,13 @@ class SportsPress_Widget_League_Table extends WP_Widget {
extract($args);
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
$id = empty($instance['id']) ? null : $instance['id'];
$columns = $instance['columns'];
$columns = empty($instance['columns']) ? null : $instance['columns'];
$show_full_table_link = empty($instance['show_full_table_link']) ? false : $instance['show_full_table_link'];
echo $before_widget;
if ( $title )
echo $before_title . $title . $after_title;
echo '<div id="sp_league_table_wrap">';
echo sportspress_league_table( $id, array( 'columns' => $columns ) );
echo sportspress_league_table( $id, array( 'columns' => $columns, 'show_full_table_link' => $show_full_table_link ) );
echo '</div>';
echo $after_widget;
}
@@ -25,15 +26,17 @@ class SportsPress_Widget_League_Table extends WP_Widget {
$instance['title'] = strip_tags($new_instance['title']);
$instance['id'] = intval($new_instance['id']);
$instance['columns'] = (array)$new_instance['columns'];
$instance['show_full_table_link'] = $new_instance['show_full_table_link'];
return $instance;
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '', 'columns' => null ) );
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '', 'columns' => null, 'show_full_table_link' => true ) );
$title = strip_tags($instance['title']);
$id = intval($instance['id']);
$columns = $instance['columns'];
$show_full_table_link = $instance['show_full_table_link'];
?>
<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>
@@ -73,6 +76,10 @@ class SportsPress_Widget_League_Table extends WP_Widget {
<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_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
}
}