Merge globals into single file, load options, and add text settings page

This commit is contained in:
Brian Miyaji
2014-03-18 16:39:53 +11:00
parent ee33f7b630
commit 37ebe39620
25 changed files with 748 additions and 497 deletions

View File

@@ -9,10 +9,12 @@ class SP_Widget_Countdown extends WP_Widget {
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'];
$show_league = empty($instance['show_league']) ? false : $instance['show_league'];
echo $before_widget;
if ( $title )
echo $before_title . $title . $after_title;
echo sportspress_countdown( $instance );
echo sportspress_countdown( $id, array( 'show_league' => $show_league ) );
echo $after_widget;
}
@@ -26,7 +28,7 @@ class SP_Widget_Countdown extends WP_Widget {
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'event' => '', 'show_league' => 0 ) );
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'event' => '', 'show_league' => false ) );
$title = strip_tags($instance['title']);
$event = intval($instance['event']);
$show_league = intval($instance['show_league']);

View File

@@ -14,11 +14,12 @@ class SportsPress_Widget_Player_Gallery extends WP_Widget {
$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'];
$show_names_on_hover = empty($instance['show_names_on_hover']) ? false : $instance['show_names_on_hover'];
echo $before_widget;
if ( $title )
echo $before_title . $title . $after_title;
echo '<div id="sp_player_list_wrap">';
echo sportspress_player_gallery( $id, array( 'number' => $number, 'orderby' => $orderby , 'order' => $order, 'show_all_players_link' => $show_all_players_link ) );
echo '<div id="sp_player_gallery_wrap">';
echo sportspress_player_gallery( $id, array( 'number' => $number, 'orderby' => $orderby , 'order' => $order, 'show_all_players_link' => $show_all_players_link, 'show_names_on_hover' => $show_names_on_hover ) );
echo '</div>';
echo $after_widget;
}
@@ -31,18 +32,20 @@ class SportsPress_Widget_Player_Gallery extends WP_Widget {
$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'];
$instance['show_names_on_hover'] = $new_instance['show_names_on_hover'];
return $instance;
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '', 'number' => 5, 'orderby' => 'default', 'order' => 'ASC', 'show_all_players_link' => true ) );
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '', 'number' => 5, 'orderby' => 'default', 'order' => 'ASC', 'show_all_players_link' => true, 'show_names_on_hover' => false ) );
$title = strip_tags($instance['title']);
$id = intval($instance['id']);
$number = intval($instance['number']);
$orderby = strip_tags($instance['orderby']);
$order = strip_tags($instance['order']);
$show_all_players_link = $instance['show_all_players_link'];
$show_names_on_hover = $instance['show_names_on_hover'];
?>
<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>
@@ -96,6 +99,9 @@ class SportsPress_Widget_Player_Gallery extends WP_Widget {
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_all_players_link'); ?>" name="<?php echo $this->get_field_name('show_all_players_link'); ?>" value="1" <?php checked( $show_all_players_link, 1 ); ?>>
<label for="<?php echo $this->get_field_id('show_all_players_link'); ?>"><?php _e( 'Display link to view all players', 'sportspress' ); ?></label></p>
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_names_on_hover'); ?>" name="<?php echo $this->get_field_name('show_names_on_hover'); ?>" value="1" <?php checked( $show_names_on_hover, 1 ); ?>>
<label for="<?php echo $this->get_field_id('show_names_on_hover'); ?>"><?php _e( 'Display player names on hover', 'sportspress' ); ?></label></p>
<?php
}
}