Option to display photos in player list close #28

This commit is contained in:
Brian Miyaji
2014-08-14 23:03:30 +10:00
parent c3776b4838
commit 5bcd97a5d2
4 changed files with 42 additions and 2 deletions

View File

@@ -109,6 +109,25 @@
max-height: 2em;
}
/* Player List */
.sp-player-list td {
line-height: 2em;
}
.sp-player-list .data-name .player-photo {
width: 2em;
height: 2em;
margin-right: 0.25em;
display: block;
float: left;
text-align: center;
}
.sp-player-list .data-name .player-photo img {
width: auto;
height: auto;
max-width: 2em;
max-height: 2em;
}
/* Button */
.sp-button {
border: none;

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta_Boxes
* @version 1.0.2
* @version 1.3
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -37,6 +37,7 @@ class SP_Meta_Box_List_Data {
* Admin edit table
*/
public static function table( $columns = array(), $data = array(), $placeholders = array(), $adjustments = array() ) {
$show_player_photo = get_option( 'sportspress_list_show_photos', 'no' ) == 'yes' ? true : false;
?>
<ul class="subsubsub sp-table-bar">
<li><a href="#sp-table-values" class="current"><?php _e( 'Values', 'sportspress' ); ?></a></li> |
@@ -77,6 +78,7 @@ class SP_Meta_Box_List_Data {
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
<td><?php echo ( $number ? $number : '&nbsp;' ); ?></td>
<td>
<?php if ( $show_player_photo ) echo get_the_post_thumbnail( $player_id, 'sportspress-fit-mini' ); ?>
<span class="sp-default-value">
<span class="sp-default-value-input"><?php echo $default_name; ?></span>
<a class="dashicons dashicons-edit sp-edit" title="<?php _e( 'Edit', 'sportspress' ); ?>"></a>

View File

@@ -58,6 +58,14 @@ class SP_Settings_Players extends SP_Settings_Page {
array( 'title' => __( 'Player Lists', 'sportspress' ), 'type' => 'title', 'id' => 'list_options' ),
array(
'title' => __( 'Players', 'sportspress' ),
'desc' => __( 'Display photos', 'sportspress' ),
'id' => 'sportspress_list_show_photos',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Pagination', 'sportspress' ),
'desc' => __( 'Paginate', 'sportspress' ),

View File

@@ -18,6 +18,7 @@ $defaults = array(
'orderby' => 'default',
'order' => 'ASC',
'show_all_players_link' => false,
'show_player_photo' => get_option( 'sportspress_list_show_photos', 'yes' ) == 'yes' ? true : false,
'link_posts' => get_option( 'sportspress_link_players', 'yes' ) == 'yes' ? true : false,
'link_teams' => get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false,
'sortable' => get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false,
@@ -117,12 +118,22 @@ foreach ( $groups as $group ):
$output .= '<td class="data-number">' . sp_array_value( $row, 'number', '&nbsp;' ) . '</td>';
endif;
$name_class = '';
if ( $show_player_photo ):
if ( has_post_thumbnail( $player_id ) ):
$logo = get_the_post_thumbnail( $player_id, 'sportspress-fit-icon' );
$name = '<span class="player-photo">' . $logo . '</span>' . $name;
$name_class .= ' has-photo';
endif;
endif;
if ( $link_posts ):
$permalink = get_post_permalink( $player_id );
$name = '<a href="' . $permalink . '">' . $name . '</a>';
endif;
$output .= '<td class="data-name">' . $name . '</td>';
$output .= '<td class="data-name' . $name_class . '">' . $name . '</td>';
if ( array_key_exists( 'team', $labels ) ):
$team = sp_array_value( $row, 'team', get_post_meta( $id, 'sp_team', true ) );