Add stars feature to box scores
This commit is contained in:
@@ -315,6 +315,11 @@ table.widefat.sp-data-table input.small-text {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
table.widefat.sp-data-table input.tiny-text {
|
||||
width: 25px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
table.widefat.sp-data-table input.name {
|
||||
min-width: 0;
|
||||
width: auto;
|
||||
|
||||
@@ -288,6 +288,9 @@
|
||||
.sp-event-performance .sp-performance-icons {
|
||||
width: 25%;
|
||||
}
|
||||
.sp-event-performance .sp-event-star {
|
||||
color: #f4d014;
|
||||
}
|
||||
|
||||
/* Event Performance (Icons) */
|
||||
.sp-event-performance-teams .sp-template-event-performance-icons {
|
||||
|
||||
@@ -20,7 +20,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$event = new SP_Event( $post );
|
||||
list( $labels, $columns, $stats, $teams, $formats, $order, $timed ) = $event->performance( true );
|
||||
list( $labels, $columns, $stats, $teams, $formats, $order, $timed, $stars ) = $event->performance( true );
|
||||
|
||||
if ( 'yes' == get_option( 'sportspress_event_performance_show_minutes', 'no' ) )
|
||||
$timeline = $event->timeline( true );
|
||||
@@ -62,7 +62,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
// Get status option
|
||||
$status = ! $is_individual;
|
||||
|
||||
self::tables( $post->ID, $stats, $labels, $columns, $teams, $has_checkboxes, $positions, $status, $formats, $order, $numbers, $is_individual, $timeline, $timed );
|
||||
self::tables( $post->ID, $stats, $labels, $columns, $teams, $has_checkboxes, $positions, $status, $formats, $order, $numbers, $is_individual, $timeline, $timed, $stars );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,12 +73,13 @@ class SP_Meta_Box_Event_Performance {
|
||||
update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array() ) );
|
||||
update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', array() ) );
|
||||
update_post_meta( $post_id, 'sp_timeline', sp_array_value( $_POST, 'sp_timeline', array() ) );
|
||||
update_post_meta( $post_id, 'sp_stars', sp_array_value( $_POST, 'sp_stars', array() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin edit tables
|
||||
*/
|
||||
public static function tables( $post_id, $stats = array(), $labels = array(), $columns = array(), $teams = array(), $has_checkboxes = false, $positions = array(), $status = true, $formats = array(), $order = array(), $numbers = true, $is_individual = false, $timeline = array(), $timed = array() ) {
|
||||
public static function tables( $post_id, $stats = array(), $labels = array(), $columns = array(), $teams = array(), $has_checkboxes = false, $positions = array(), $status = true, $formats = array(), $order = array(), $numbers = true, $is_individual = false, $timeline = array(), $timed = array(), $stars = array() ) {
|
||||
$sections = get_option( 'sportspress_event_performance_sections', -1 );
|
||||
|
||||
if ( $is_individual ) {
|
||||
@@ -113,7 +114,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
$player_timeline = false;
|
||||
endif;
|
||||
|
||||
self::row( $labels, $player_id, $player_performance, $team_id, $data, ! empty( $positions ), $status, false, $numbers, -1, $formats, $player_timeline, $timed );
|
||||
self::row( $labels, $player_id, $player_performance, $team_id, $data, ! empty( $positions ), $status, false, $numbers, -1, $formats, $player_timeline, $timed, $stars );
|
||||
endforeach;
|
||||
endforeach;
|
||||
?>
|
||||
@@ -142,7 +143,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
?>
|
||||
<div>
|
||||
<p><strong><?php echo get_the_title( $team_id ); ?></strong></p>
|
||||
<?php self::table( $labels, $columns, $data, $team_id, $has_checkboxes, $positions, $status, -1, $formats, $order, $numbers, $team_timeline, $timed ); ?>
|
||||
<?php self::table( $labels, $columns, $data, $team_id, $has_checkboxes, $positions, $status, -1, $formats, $order, $numbers, $team_timeline, $timed, $stars ); ?>
|
||||
<?php do_action( 'sportspress_after_event_performance_table_admin', $labels, $columns, $data, $team_id ); ?>
|
||||
</div>
|
||||
<?php } else { ?>
|
||||
@@ -224,7 +225,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
?>
|
||||
<div>
|
||||
<p><strong><?php echo get_the_title( $team_id ); ?> — <?php echo $section_label; ?></strong></p>
|
||||
<?php self::table( $labels[ $section_id ], $columns, $data[ $section_id ], $team_id, ( $has_checkboxes && 0 === $i ), $positions, $status, $section_id, $formats, $order, $numbers, $team_timeline, $timed ); ?>
|
||||
<?php self::table( $labels[ $section_id ], $columns, $data[ $section_id ], $team_id, ( $has_checkboxes && 0 === $i ), $positions, $status, $section_id, $formats, $order, $numbers, $team_timeline, $timed, $stars ); ?>
|
||||
<?php do_action( 'sportspress_after_event_performance_table_admin', $labels[ $section_id ], $columns, $data[ $section_id ], $team_id ); ?>
|
||||
</div>
|
||||
<?php
|
||||
@@ -238,7 +239,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
/**
|
||||
* Admin edit table
|
||||
*/
|
||||
public static function table( $labels = array(), $columns = array(), $data = array(), $team_id, $has_checkboxes = false, $positions = array(), $status = true, $section = -1, $formats = array(), $order = array(), $numbers = true, $team_timeline = array(), $timed = array() ) {
|
||||
public static function table( $labels = array(), $columns = array(), $data = array(), $team_id, $has_checkboxes = false, $positions = array(), $status = true, $section = -1, $formats = array(), $order = array(), $numbers = true, $team_timeline = array(), $timed = array(), $stars = array() ) {
|
||||
?>
|
||||
<div class="sp-data-table-container">
|
||||
<table class="widefat sp-data-table sp-performance-table sp-sortable-table">
|
||||
@@ -273,7 +274,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
$player_timeline = false;
|
||||
endif;
|
||||
|
||||
self::row( $labels, $player_id, $player_performance, $team_id, $data, ! empty( $positions ), $status, true, $numbers, $section, $formats, $player_timeline, $timed );
|
||||
self::row( $labels, $player_id, $player_performance, $team_id, $data, ! empty( $positions ), $status, true, $numbers, $section, $formats, $player_timeline, $timed, $stars );
|
||||
|
||||
endforeach;
|
||||
?>
|
||||
@@ -287,6 +288,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
* Admin edit table header
|
||||
*/
|
||||
public static function header( $columns = array(), $labels = array(), $positions = array(), $has_checkboxes = false, $status = true, $sortable = true, $numbers = true, $section = -1, $formats = array() ) {
|
||||
$stars_type = get_option( 'sportspress_event_performance_stars_type', 0 )
|
||||
?>
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -320,6 +322,9 @@ class SP_Meta_Box_Event_Performance {
|
||||
<?php _e( 'Status', 'sportspress' ); ?>
|
||||
</th>
|
||||
<?php } ?>
|
||||
<?php if ( $stars_type ) { ?>
|
||||
<th><i class="dashicons dashicons-star-filled" title="<?php 2 == $stars_type ? _e( 'Number of Stars', 'sportspress' ) : _e( 'Player of the Match', 'sportspress' ); ?>"></i></th>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<?php
|
||||
@@ -357,6 +362,9 @@ class SP_Meta_Box_Event_Performance {
|
||||
<?php if ( apply_filters( 'sportspress_event_performance_show_status', $status, $section ) ) { ?>
|
||||
<td> </td>
|
||||
<?php } ?>
|
||||
<?php if ( get_option( 'sportspress_event_performance_stars_type', 0 ) ) { ?>
|
||||
<td> </td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tfoot>
|
||||
@@ -366,9 +374,10 @@ class SP_Meta_Box_Event_Performance {
|
||||
/**
|
||||
* Admin edit table row
|
||||
*/
|
||||
public static function row( $labels = array(), $player_id = 0, $player_performance = array(), $team_id = 0, $data = array(), $positions = true, $status = true, $sortable = true, $numbers = true, $section = -1, $formats = array(), $player_timeline = array(), $timed = array() ) {
|
||||
public static function row( $labels = array(), $player_id = 0, $player_performance = array(), $team_id = 0, $data = array(), $positions = true, $status = true, $sortable = true, $numbers = true, $section = -1, $formats = array(), $player_timeline = array(), $timed = array(), $stars = array() ) {
|
||||
if ( $player_id <= 0 ) return;
|
||||
|
||||
$stars_type = get_option( 'sportspress_event_performance_stars_type', 0 );
|
||||
$value = sp_array_value( $player_performance, 'number', '' );
|
||||
?>
|
||||
<tr class="sp-row sp-post" data-player="<?php echo $player_id; ?>">
|
||||
@@ -469,6 +478,20 @@ class SP_Meta_Box_Event_Performance {
|
||||
<span class="description"><?php _e( 'mins', 'sportspress' ); ?></span>
|
||||
</td>
|
||||
<?php } ?>
|
||||
<?php if ( $stars_type ) { ?>
|
||||
<td>
|
||||
<?php
|
||||
switch ( $stars_type ) {
|
||||
case 1:
|
||||
echo '<input type="checkbox" name="sp_stars[' . $player_id . ']" value="1" ' . checked( sp_array_value( $stars, $player_id, '' ) == '', false, false ) . '>';
|
||||
break;
|
||||
case 2:
|
||||
echo '<input type="text" name="sp_stars[' . $player_id . ']" class="tiny-text sp-player-stars-input sp-sync-input" value="' . sp_array_value( $stars, $player_id, '' ) . '">';
|
||||
break;
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -355,6 +355,18 @@ class SP_Settings_Events extends SP_Settings_Page {
|
||||
),
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Awards', 'sportspress' ),
|
||||
'id' => 'sportspress_event_performance_stars_type',
|
||||
'default' => 0,
|
||||
'type' => 'radio',
|
||||
'options' => array(
|
||||
__( 'None', 'sportspress' ),
|
||||
__( 'Player of the Match', 'sportspress' ),
|
||||
__( 'Number of Stars', 'sportspress' ),
|
||||
),
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Positions', 'sportspress' ),
|
||||
'desc' => __( 'Top-level only', 'sportspress' ),
|
||||
|
||||
@@ -99,6 +99,7 @@ class SP_Event extends SP_Custom_Post{
|
||||
$labels = array();
|
||||
$formats = array();
|
||||
$timed = array();
|
||||
$stars = array();
|
||||
$equations = array();
|
||||
foreach ( $vars as $var ) {
|
||||
$labels[ $var->post_name ] = $var->post_title;
|
||||
@@ -129,6 +130,10 @@ class SP_Event extends SP_Custom_Post{
|
||||
}
|
||||
|
||||
$order = (array)get_post_meta( $this->ID, 'sp_order', true );
|
||||
|
||||
if ( get_option( 'sportspress_event_performance_stars_type', 0 ) ) {
|
||||
$stars = (array)get_post_meta( $this->ID, 'sp_stars', true );
|
||||
}
|
||||
|
||||
$labels = apply_filters( 'sportspress_event_performance_labels', $labels, $this );
|
||||
$columns = get_post_meta( $this->ID, 'sp_columns', true );
|
||||
@@ -151,7 +156,7 @@ class SP_Event extends SP_Custom_Post{
|
||||
endif;
|
||||
|
||||
if ( $admin ):
|
||||
return array( $labels, $columns, $performance, $teams, $formats, $order, $timed );
|
||||
return array( $labels, $columns, $performance, $teams, $formats, $order, $timed, $stars );
|
||||
else:
|
||||
// Add position to performance labels
|
||||
if ( taxonomy_exists( 'sp_position' ) ):
|
||||
@@ -633,6 +638,10 @@ class SP_Event extends SP_Custom_Post{
|
||||
update_post_meta( $this->ID, 'sp_results', $meta );
|
||||
}
|
||||
|
||||
public function stars() {
|
||||
return get_post_meta( $this->ID, 'sp_stars', true );
|
||||
}
|
||||
|
||||
public function lineup_filter( $v ) {
|
||||
return sp_array_value( $v, 'status', 'lineup' ) == 'lineup';
|
||||
}
|
||||
|
||||
@@ -1459,6 +1459,7 @@ function sp_get_text_options() {
|
||||
__( 'Past Teams', 'sportspress' ),
|
||||
__( 'Photo', 'sportspress' ),
|
||||
__( 'Player', 'sportspress' ),
|
||||
__( 'Player of the Match', 'sportspress' ),
|
||||
__( 'Players', 'sportspress' ),
|
||||
__( 'Pos', 'sportspress' ),
|
||||
__( 'Position', 'sportspress' ),
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: SportsPress Player Of The Match
|
||||
Plugin URI: http://themeboy.com/
|
||||
Description: Add player of the match to SportsPress events.
|
||||
Author: ThemeBoy
|
||||
Author URI: http://themeboy.com/
|
||||
Version: 2.5
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Player_Of_The_Match' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Player Of The Match Class
|
||||
*
|
||||
* @class SportsPress_Player_Of_The_Match
|
||||
* @version 2.5
|
||||
*/
|
||||
class SportsPress_Player_Of_The_Match {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
add_filter( 'sportspress_text', array( $this, 'add_text_options' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_PLAYER_OF_THE_MATCH_VERSION' ) )
|
||||
define( 'SP_PLAYER_OF_THE_MATCH_VERSION', '2.5' );
|
||||
|
||||
if ( !defined( 'SP_PLAYER_OF_THE_MATCH_URL' ) )
|
||||
define( 'SP_PLAYER_OF_THE_MATCH_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
if ( !defined( 'SP_PLAYER_OF_THE_MATCH_DIR' ) )
|
||||
define( 'SP_PLAYER_OF_THE_MATCH_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add text options
|
||||
*/
|
||||
public function add_text_options( $options = array() ) {
|
||||
return array_merge( $options, array(
|
||||
__( 'Player of the Match', 'sportspress' ),
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
new SportsPress_Player_Of_The_Match();
|
||||
@@ -90,6 +90,11 @@ if ( ! isset( $subs ) ) $subs = array();
|
||||
$name = '<a href="' . $permalink . '">' . $name . '</a>';
|
||||
endif;
|
||||
|
||||
$player_stars = sp_array_value( $stars, $player_id, 0 );
|
||||
if ( $player_stars ):
|
||||
$name .= ' <span class="sp-event-stars">' . str_repeat( '<i class="sp-event-star dashicons dashicons-star-filled" title="' . __( 'Player of the Match', 'sportspress' ) . '"></i>', $player_stars ) . '<span>';
|
||||
endif;
|
||||
|
||||
if ( array_key_exists( $player_id, $lineup_sub_relation ) ):
|
||||
$name .= ' <span class="sub-in" title="' . get_the_title( $lineup_sub_relation[ $player_id ] ) . '">' . sp_array_value( sp_array_value( $data, $lineup_sub_relation[ $player_id ], array() ), 'number', null ) . '</span>';
|
||||
elseif ( isset( $row['sub'] ) && $row['sub'] ):
|
||||
|
||||
@@ -35,6 +35,7 @@ if ( is_array( $teams ) ):
|
||||
|
||||
$event = new SP_Event( $id );
|
||||
$performance = $event->performance();
|
||||
$stars = $event->stars();
|
||||
|
||||
$link_posts = get_option( 'sportspress_link_players', 'yes' ) == 'yes' ? true : false;
|
||||
$scrollable = get_option( 'sportspress_enable_scrollable_tables', 'yes' ) == 'yes' ? true : false;
|
||||
@@ -121,6 +122,7 @@ if ( is_array( $teams ) ):
|
||||
'mode' => $mode,
|
||||
'data' => $data,
|
||||
'event' => $event,
|
||||
'stars' => $stars,
|
||||
'link_posts' => $link_posts,
|
||||
'performance_ids' => isset( $performance_ids ) ? $performance_ids : null,
|
||||
'primary' => 'primary' == $total ? $primary : null,
|
||||
@@ -230,6 +232,7 @@ if ( is_array( $teams ) ):
|
||||
'mode' => $mode,
|
||||
'data' => $data[ $section_id ],
|
||||
'event' => $event,
|
||||
'stars' => $stars,
|
||||
'link_posts' => $link_posts,
|
||||
'performance_ids' => isset( $performance_ids ) ? $performance_ids : null,
|
||||
'primary' => 'primary' == $total ? $primary : null,
|
||||
@@ -266,6 +269,7 @@ if ( is_array( $teams ) ):
|
||||
'mode' => $mode,
|
||||
'data' => $data,
|
||||
'event' => $event,
|
||||
'stars' => $stars,
|
||||
'link_posts' => $link_posts,
|
||||
'performance_ids' => isset( $performance_ids ) ? $performance_ids : null,
|
||||
'primary' => 'primary' == $total ? $primary : null,
|
||||
|
||||
Reference in New Issue
Block a user