From b885665f21b7fe6da725b3a3fd52b0e6df1c397f Mon Sep 17 00:00:00 2001
From: Brian Miyaji
Date: Mon, 17 Mar 2014 22:55:24 +1100
Subject: [PATCH] Add options to widgets
---
admin/templates/events-calendar.php | 2 +-
admin/templates/events-list.php | 2 +-
admin/templates/player-list.php | 9 +++++++++
admin/widgets/player-list.php | 16 ++++++++++++++--
4 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/admin/templates/events-calendar.php b/admin/templates/events-calendar.php
index 0ee4e8a4..d13aeac7 100644
--- a/admin/templates/events-calendar.php
+++ b/admin/templates/events-calendar.php
@@ -197,7 +197,7 @@ if ( !function_exists( 'sportspress_events_calendar' ) ) {
$calendar_output .= "\n\t\n\t\n\t";
if ( $id && $r['show_all_events_link'] )
- $calendar_output .= '' . __( 'View all events', 'sportspress' ) . '';
+ $calendar_output .= '' . __( 'View all events', 'sportspress' ) . '';
return apply_filters( 'sportspress_events_calendar', $calendar_output );
diff --git a/admin/templates/events-list.php b/admin/templates/events-list.php
index 7f80f000..3c6bc99e 100644
--- a/admin/templates/events-list.php
+++ b/admin/templates/events-list.php
@@ -117,7 +117,7 @@ if ( !function_exists( 'sportspress_events_list' ) ) {
$output .= '' . '';
if ( $id && $r['show_all_events_link'] )
- $output .= '' . __( 'View all events', 'sportspress' ) . '';
+ $output .= '' . __( 'View all events', 'sportspress' ) . '';
$output .= '';
diff --git a/admin/templates/player-list.php b/admin/templates/player-list.php
index b300883b..ac17ec2c 100644
--- a/admin/templates/player-list.php
+++ b/admin/templates/player-list.php
@@ -6,9 +6,11 @@ if ( !function_exists( 'sportspress_player_list' ) ) {
$id = get_the_ID();
$defaults = array(
+ 'number' => -1,
'statistics' => null,
'orderby' => 'default',
'order' => 'ASC',
+ 'show_all_players_link' => false,
);
$r = wp_parse_args( $args, $defaults );
@@ -55,7 +57,11 @@ if ( !function_exists( 'sportspress_player_list' ) ) {
$i = 0;
+ if ( is_int( $r['number'] ) && $r['number'] > 0 )
+ $limit = $r['number'];
+
foreach( $data as $player_id => $row ):
+ if ( isset( $limit ) && $i >= $limit ) continue;
$name = sportspress_array_value( $row, 'name', null );
if ( ! $name ) continue;
@@ -89,6 +95,9 @@ if ( !function_exists( 'sportspress_player_list' ) ) {
$output .= '' . '' . '';
+ if ( $r['show_all_players_link'] )
+ $output .= '' . __( 'View all players', 'sportspress' ) . '';
+
return apply_filters( 'sportspress_player_list', $output );
}
diff --git a/admin/widgets/player-list.php b/admin/widgets/player-list.php
index e5aa19dd..37115f09 100644
--- a/admin/widgets/player-list.php
+++ b/admin/widgets/player-list.php
@@ -10,14 +10,16 @@ class SportsPress_Widget_Player_list 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'];
+ $number = empty($instance['number']) ? null : $instance['number'];
$statistics = $instance['statistics'];
$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'];
echo $before_widget;
if ( $title )
echo $before_title . $title . $after_title;
echo '';
- echo sportspress_player_list( $id, array( 'statistics' => $statistics, 'orderby' => $orderby , 'order' => $order ) );
+ echo sportspress_player_list( $id, array( 'number' => $number, 'statistics' => $statistics, 'orderby' => $orderby , 'order' => $order, 'show_all_players_link' => $show_all_players_link ) );
echo '
';
echo $after_widget;
}
@@ -26,20 +28,24 @@ class SportsPress_Widget_Player_list extends WP_Widget {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['id'] = intval($new_instance['id']);
+ $instance['number'] = intval($new_instance['number']);
$instance['statistics'] = (array)$new_instance['statistics'];
$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'];
return $instance;
}
function form( $instance ) {
- $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '', 'statistics' => null, 'orderby' => 'default', 'order' => 'ASC' ) );
+ $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '', 'number' => 5, 'statistics' => null, 'orderby' => 'default', 'order' => 'ASC', 'show_all_players_link' => true ) );
$title = strip_tags($instance['title']);
$id = intval($instance['id']);
+ $number = intval($instance['number']);
$statistics = $instance['statistics'];
$orderby = strip_tags($instance['orderby']);
$order = strip_tags($instance['order']);
+ $show_all_players_link = $instance['show_all_players_link'];
?>
@@ -60,6 +66,9 @@ class SportsPress_Widget_Player_list extends WP_Widget {
?>
+
+
+
>
+
+ >
+