Enable player performance icons instead of values

This commit is contained in:
Brian Miyaji
2014-08-14 20:29:51 +10:00
parent c835bf63f2
commit c3776b4838
7 changed files with 90 additions and 20 deletions

View File

@@ -249,7 +249,9 @@ table.widefat.sp-sortable-table tr:nth-child(2n-1) {
}
.sp-admin-config-table th.radio,
.sp-admin-config-table td.radio {
.sp-admin-config-table td.radio,
.sp-admin-config-table th.icon,
.sp-admin-config-table td.icon {
width: 1%;
text-align: center;
}

View File

@@ -51,6 +51,10 @@
content: "\f140";
position: absolute;
}
.sp-data-table .data-number,
.sp-data-table .data-rank {
width: 1px;
}
/* Pagination */
.sp-paginated-table {
@@ -126,6 +130,9 @@
.sp-event-performance .sub-out:before {
content: "\f142";
}
.sp-event-performance .sp-performance-icons {
width: 25%;
}
/* Event Calendar */
.sp-event-calendar tbody td, .sp-event-calendar thead th {

View File

@@ -79,14 +79,6 @@ class SP_Settings_Events extends SP_Settings_Page {
'id' => 'sportspress_event_show_logos',
'default' => 'yes',
'type' => 'checkbox',
),
array(
'title' => __( 'Venue', 'sportspress' ),
'desc' => __( 'Display maps', 'sportspress' ),
'id' => 'sportspress_event_show_maps',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
@@ -96,7 +88,7 @@ class SP_Settings_Events extends SP_Settings_Page {
'id' => 'sportspress_event_show_players',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
'checkboxgroup' => '',
),
array(
@@ -107,6 +99,26 @@ class SP_Settings_Events extends SP_Settings_Page {
'checkboxgroup' => 'end',
),
array(
'title' => __( 'Player Performance', 'sportspress' ),
'id' => 'sportspress_event_performance_mode',
'default' => 'values',
'type' => 'radio',
'options' => array(
'values' => __( 'Values', 'sportspress' ),
'icons' => __( 'Icons', 'sportspress' ),
),
),
array(
'title' => __( 'Venue', 'sportspress' ),
'desc' => __( 'Display maps', 'sportspress' ),
'id' => 'sportspress_event_show_maps',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'title' => __( 'Staff', 'sportspress' ),
'desc' => __( 'Display staff', 'sportspress' ),

View File

@@ -77,7 +77,7 @@
<table class="widefat sp-admin-config-table">
<thead>
<tr>
<th scope="col"><?php _e( 'Primary', 'sportspress' ); ?></th>
<th class="radio" scope="col"><?php _e( 'Primary', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Variables', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Description', 'sportspress' ); ?></th>
@@ -143,6 +143,7 @@
<table class="widefat sp-admin-config-table">
<thead>
<tr>
<th class="icon" scope="col"><?php _e( 'Icon', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Variable', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Description', 'sportspress' ); ?></th>
@@ -151,6 +152,7 @@
</thead>
<?php $i = 0; foreach ( $data as $row ): ?>
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
<td class="icon"><?php if ( has_post_thumbnail( $row->ID ) ) echo get_the_post_thumbnail( $row->ID, 'sportspress-fit-mini' ); ?></td>
<td class="row-title"><?php echo $row->post_title; ?></td>
<td><?php echo $row->post_name; ?></td>
<td><p class="description"><?php echo $row->post_excerpt; ?></p></td>

View File

@@ -295,7 +295,7 @@ class SP_Post_types {
'publicly_queryable' => false,
'exclude_from_search' => true,
'hierarchical' => false,
'supports' => array( 'title', 'page-attributes', 'excerpt' ),
'supports' => array( 'title', 'thumbnail', 'page-attributes', 'excerpt' ),
'has_archive' => false,
'show_in_nav_menus' => false,
'can_export' => false,

View File

@@ -153,6 +153,18 @@ function sportspress_gettext( $translated_text, $untranslated_text, $domain = nu
case 'Slug':
$translated_text = ( in_array( $typenow, array( 'sp_column', 'sp_statistic' ) ) ) ? __( 'Key', 'sportspress' ) : __( 'Variable', 'sportspress' );
break;
case 'Featured Image':
$translated_text = __( 'Icon', 'sportspress' );
break;
case 'Set Featured Image':
$translated_text = __( 'Select Icon', 'sportspress' );
break;
case 'Set featured image':
$translated_text = __( 'Add icon', 'sportspress' );
break;
case 'Remove featured image':
$translated_text = __( 'Remove icon', 'sportspress' );
break;
endswitch;
endif;

View File

@@ -31,6 +31,16 @@ $link_posts = get_option( 'sportspress_link_players', 'yes' ) == 'yes' ? true :
$sortable = get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false;
$scrollable = get_option( 'sportspress_enable_scrollable_tables', 'yes' ) == 'yes' ? true : false;
$responsive = get_option( 'sportspress_enable_responsive_tables', 'yes' ) == 'yes' ? true : false;
$mode = get_option( 'sportspress_event_performance_mode', 'values' );
// Get performance ids for icons
if ( $mode == 'icons' ):
$performance_ids = array();
$performance_posts = get_posts( array( 'posts_per_page' => -1, 'post_type' => 'sp_performance' ) );
foreach ( $performance_posts as $post ):
$performance_ids[ $post->post_name ] = $post->ID;
endforeach;
endif;
if ( is_array( $teams ) ):
foreach( $teams as $index => $team_id ):
@@ -63,9 +73,12 @@ if ( is_array( $teams ) ):
<?php if ( $has_players ): ?>
<th class="data-number">#</th>
<th class="data-name"><?php _e( 'Player', 'sportspress' ); ?></th>
<?php endif; foreach( $labels as $key => $label ): ?>
<?php endif; ?>
<?php if ( $mode == 'values' ): foreach( $labels as $key => $label ): ?>
<th class="data-<?php echo $key; ?>"><?php echo $label; ?></th>
<?php endforeach; ?>
<?php endforeach; else: ?>
<th class="sp-performance-icons">&nbsp;</th>
<?php endif; ?>
</tr>
</thead>
<?php if ( $show_players && $has_players ): ?>
@@ -116,16 +129,16 @@ if ( is_array( $teams ) ):
echo '<td class="data-name">' . $name . '</td>';
if ( $mode == 'icons' ); echo '<td class="sp-performance-icons">';
foreach( $labels as $key => $label ):
if ( $key == 'name' )
continue;
$value = '&mdash;';
if ( $key == 'position' ):
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
$position = get_term_by( 'id', $row[ $key ], 'sp_position' );
$value = $position->name;
else:
$value = '&mdash;';
if ( $position ) $value = $position->name;
endif;
else:
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
@@ -138,9 +151,19 @@ if ( is_array( $teams ) ):
$totals[ $key ] = 0;
endif;
$totals[ $key ] += $value;
if ( $mode == 'values' ):
echo '<td class="data-' . $key . '">' . $value . '</td>';
elseif ( intval( $value ) && $mode == 'icons' ):
$performance_id = sp_array_value( $performance_ids, $key, null );
if ( $performance_id && has_post_thumbnail( $performance_id ) ):
echo str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini' ) . ' ', $value );
endif;
endif;
endforeach;
if ( $mode == 'icons' ); echo '</td>';
echo '</tr>';
$i++;
@@ -160,6 +183,8 @@ if ( is_array( $teams ) ):
$row = $data[0];
if ( $mode == 'icons' ) echo '<td class="sp-performance-icons">';
foreach( $labels as $key => $label ):
if ( $key == 'name' )
continue;
@@ -170,8 +195,18 @@ if ( is_array( $teams ) ):
else:
$value = sp_array_value( $totals, $key, 0 );
endif;
if ( $mode == 'values' ):
echo '<td class="data-' . $key . '">' . $value . '</td>';
elseif ( intval( $value ) && $mode == 'icons' ):
$performance_id = sp_array_value( $performance_ids, $key, null );
if ( $performance_id && has_post_thumbnail( $performance_id ) ):
echo str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini' ) . ' ', $value );
endif;
endif;
endforeach;
if ( $mode == 'icons' ) echo '</td>';
?>
</tr>
</<?php echo ( $has_players ? 'tfoot' : 'tbody' ); ?>>