diff --git a/assets/css/admin.css b/assets/css/admin.css index 73a6fcd2..d1081e65 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -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; diff --git a/assets/css/sportspress.css b/assets/css/sportspress.css index b3432ab1..dd4d9e7a 100644 --- a/assets/css/sportspress.css +++ b/assets/css/sportspress.css @@ -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 { diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php index 35f666d2..541cc2a9 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php @@ -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 { ?>

- +
@@ -224,7 +225,7 @@ class SP_Meta_Box_Event_Performance { ?>

- +
@@ -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 ) ?> @@ -320,6 +322,9 @@ class SP_Meta_Box_Event_Performance { + + + + + + @@ -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', '' ); ?> @@ -469,6 +478,20 @@ class SP_Meta_Box_Event_Performance { + + + __( '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' ), diff --git a/includes/class-sp-event.php b/includes/class-sp-event.php index 4fcc56a8..8b214db8 100644 --- a/includes/class-sp-event.php +++ b/includes/class-sp-event.php @@ -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'; } diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index 375b75ff..d53bc89a 100644 --- a/includes/sp-core-functions.php +++ b/includes/sp-core-functions.php @@ -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' ), diff --git a/modules/sportspress-player-of-the-match.php b/modules/sportspress-player-of-the-match.php deleted file mode 100644 index 86e0a229..00000000 --- a/modules/sportspress-player-of-the-match.php +++ /dev/null @@ -1,60 +0,0 @@ -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(); diff --git a/templates/event-performance-table.php b/templates/event-performance-table.php index 83518c88..9c8e4e12 100644 --- a/templates/event-performance-table.php +++ b/templates/event-performance-table.php @@ -90,6 +90,11 @@ if ( ! isset( $subs ) ) $subs = array(); $name = '' . $name . ''; endif; + $player_stars = sp_array_value( $stars, $player_id, 0 ); + if ( $player_stars ): + $name .= ' ' . str_repeat( '', $player_stars ) . ''; + endif; + if ( array_key_exists( $player_id, $lineup_sub_relation ) ): $name .= ' ' . sp_array_value( sp_array_value( $data, $lineup_sub_relation[ $player_id ], array() ), 'number', null ) . ''; elseif ( isset( $row['sub'] ) && $row['sub'] ): diff --git a/templates/event-performance.php b/templates/event-performance.php index b0f27d1a..581cd08b 100644 --- a/templates/event-performance.php +++ b/templates/event-performance.php @@ -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,
   
+ '; + break; + case 2: + echo ''; + break; + } + ?> +