diff --git a/admin/templates/player-gallery.php b/admin/templates/player-gallery.php index 75493de0..038db1c9 100644 --- a/admin/templates/player-gallery.php +++ b/admin/templates/player-gallery.php @@ -6,6 +6,7 @@ if ( !function_exists( 'sportspress_player_gallery' ) ) { $id = get_the_ID(); $defaults = array( + 'number' => -1, 'orderby' => 'default', 'order' => 'ASC', 'itemtag' => 'dl', @@ -13,6 +14,7 @@ if ( !function_exists( 'sportspress_player_gallery' ) ) { 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail', + 'show_all_players_link' => false, ); $r = wp_parse_args( $args, $defaults ); @@ -59,8 +61,6 @@ if ( !function_exists( 'sportspress_player_gallery' ) ) { uasort( $data, 'sportspress_sort_list_players' ); endif; - $i = 0; - $gallery_style = $gallery_div = ''; if ( apply_filters( 'use_default_gallery_style', true ) ) $gallery_style = " @@ -86,28 +86,33 @@ if ( !function_exists( 'sportspress_player_gallery' ) ) { $gallery_div = "\n"; + if ( $r['show_all_players_link'] ) + $output .= '' . __( 'View all players', 'sportspress' ) . ''; + return apply_filters( 'sportspress_player_gallery', $output ); } diff --git a/admin/widgets/player-gallery.php b/admin/widgets/player-gallery.php new file mode 100644 index 00000000..29fb71c2 --- /dev/null +++ b/admin/widgets/player-gallery.php @@ -0,0 +1,102 @@ + 'widget_player_gallery widget_sp_player_gallery', 'description' => __( 'Display a gallery of players.', 'sportspress' ) ); + parent::__construct('sp_player_gallery', __( 'SportsPress Player Gallery', 'sportspress' ), $widget_ops); + } + + function widget( $args, $instance ) { + 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']; + $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_gallery( $id, array( 'number' => $number, 'orderby' => $orderby , 'order' => $order, 'show_all_players_link' => $show_all_players_link ) ); + echo '
'; + echo $after_widget; + } + + function update( $new_instance, $old_instance ) { + $instance = $old_instance; + $instance['title'] = strip_tags($new_instance['title']); + $instance['id'] = intval($new_instance['id']); + $instance['number'] = intval($new_instance['number']); + $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' => '', 'number' => 5, 'orderby' => 'default', 'order' => 'ASC', 'show_all_players_link' => true ) ); + $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']; +?> +

+

+ +

+ 'sp_list', + 'name' => $this->get_field_name('id'), + 'id' => $this->get_field_id('id'), + 'selected' => $id, + 'values' => 'ID', + 'class' => 'widefat', + ); + if ( ! sportspress_dropdown_pages( $args ) ): + sportspress_post_adder( 'sp_list', __( 'Add New', 'sportspress' ) ); + endif; + ?> +

+ +

+

+ +

+ array( + 'default' => __( 'Default', 'sportspress' ), + 'number' => __( 'Number', 'sportspress' ), + 'name' => __( 'Name', 'sportspress' ), + 'eventsplayed' => __( 'Played', 'sportspress' ) + ), + 'post_type' => 'sp_statistic', + 'name' => $this->get_field_name('orderby'), + 'id' => $this->get_field_id('orderby'), + 'selected' => $orderby, + 'values' => 'slug', + 'class' => 'sp-select-orderby widefat', + ); + if ( ! sportspress_dropdown_pages( $args ) ): + sportspress_post_adder( 'sp_list', __( 'Add New', 'sportspress' ) ); + endif; + ?> +

+ +

+

+ +

> +

+