Add inline and block option to event logos
This commit is contained in:
@@ -333,6 +333,29 @@
|
||||
clear: both;
|
||||
}
|
||||
|
||||
/* Event Logos Block */
|
||||
.sp-template-event-logos-block .team-logo {
|
||||
float: none;
|
||||
max-width: none;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.sp-template-event-logos-block .team-logo img {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.sp-template-event-logos-block .sp-team-name {
|
||||
display: block;
|
||||
clear: both;
|
||||
vertical-align: middle;
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.sp-template-event-logos-block .sp-event-results {
|
||||
font-size: 36px;
|
||||
}
|
||||
|
||||
/* Countdowns */
|
||||
.sp-template-countdown .event-name {
|
||||
clear: both;
|
||||
@@ -456,4 +479,38 @@
|
||||
.sp-template-photo + .sp-post-content {
|
||||
clear: none;
|
||||
}
|
||||
|
||||
.sp-template-event-logos-block .team-logo {
|
||||
width: 33%;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.sp-template-event-logos-block .team-logo img {
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.sp-template-event-logos-block .logo-odd {
|
||||
text-align: left;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.sp-template-event-logos-block .logo-even {
|
||||
text-align: right;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.sp-template-event-logos-block .logo-odd img {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.sp-template-event-logos-block .logo-even img {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.sp-template-event-logos-block .sp-team-name {
|
||||
display: inline;
|
||||
clear: none;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,6 +217,17 @@ class SP_Settings_Events extends SP_Settings_Page {
|
||||
),
|
||||
|
||||
apply_filters( 'sportspress_event_logo_options', array(
|
||||
array(
|
||||
'title' => __( 'Layout', 'sportspress' ),
|
||||
'id' => 'sportspress_event_logos_format',
|
||||
'default' => 'inline',
|
||||
'type' => 'radio',
|
||||
'options' => array(
|
||||
'inline' => __( 'Inline', 'sportspress' ),
|
||||
'block' => __( 'Block', 'sportspress' ),
|
||||
),
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Display', 'sportspress' ),
|
||||
'desc' => __( 'Name', 'sportspress' ),
|
||||
|
||||
71
templates/event-logos-block.php
Normal file
71
templates/event-logos-block.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* Event Logos Block
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @package SportsPress/Templates
|
||||
* @version 2.0.16
|
||||
*/
|
||||
?>
|
||||
<div class="sp-template sp-template-event-blocks sp-template-event-logos-block">
|
||||
<div class="sp-table-wrapper">
|
||||
<table class="sp-event-blocks sp-data-table" data-sp-rows="1">
|
||||
<thead><tr><th></th></tr></thead> <?php # Required for DataTables ?>
|
||||
<tbody>
|
||||
<tr class="sp-row sp-post alternate">
|
||||
<td>
|
||||
<?php
|
||||
$j = 0;
|
||||
foreach( $teams as $team ):
|
||||
$j++;
|
||||
|
||||
if ( has_post_thumbnail ( $team ) ) {
|
||||
$logo = get_the_post_thumbnail( $team, 'sportspress-fit-icon' );
|
||||
} else {
|
||||
$logo = '';
|
||||
}
|
||||
|
||||
if ( $show_team_names ) {
|
||||
if ( $j % 2 ) {
|
||||
$logo .= ' <strong class="sp-team-name">' . sp_get_team_name( $team, $abbreviate_teams ) . '</strong>';
|
||||
} else {
|
||||
$logo = '<strong class="sp-team-name">' . sp_get_team_name( $team, $abbreviate_teams ) . '</strong> ' . $logo;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $link_teams ):
|
||||
$logo = '<a class="team-logo logo-' . ( $j % 2 ? 'odd' : 'even' ) . '" href="' . get_permalink( $team, false, true ) . '" title="' . get_the_title( $team ) . '">' . $logo . '</a>';
|
||||
else:
|
||||
$logo = '<span class="team-logo logo-' . ( $j % 2 ? 'odd' : 'even' ) . '" title="' . get_the_title( $team ) . '">' . $logo . '</span>';
|
||||
endif;
|
||||
|
||||
echo $logo;
|
||||
endforeach;
|
||||
?>
|
||||
<time class="sp-event-date" datetime="<?php echo get_the_time( 'Y-m-d H:i:s' ); ?>">
|
||||
<?php echo get_the_time( get_option( 'date_format' ) ); ?>
|
||||
</time>
|
||||
<?php
|
||||
|
||||
if ( $show_time ) {
|
||||
?>
|
||||
<h5 class="sp-event-results">
|
||||
<?php echo '<span class="sp-result">' . apply_filters( 'sportspress_event_blocks_team_result_or_time', sp_get_time( $id ), $id ) . '</span>'; ?>
|
||||
</h5>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( $show_results ) {
|
||||
?>
|
||||
<h5 class="sp-event-results">
|
||||
<?php echo '<span class="sp-result">' . implode( '</span> - <span class="sp-result">', apply_filters( 'sportspress_event_blocks_team_result_or_time', $results, $id ) ) . '</span>'; ?>
|
||||
</h5>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
63
templates/event-logos-inline.php
Normal file
63
templates/event-logos-inline.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Event Logos Inline
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @package SportsPress/Templates
|
||||
* @version 2.0.16
|
||||
*/
|
||||
|
||||
$team_logos = array();
|
||||
$i = 0;
|
||||
foreach ( $teams as $team ):
|
||||
if ( ! has_post_thumbnail( $team ) ) {
|
||||
$logo = '';
|
||||
} else {
|
||||
$logo = get_the_post_thumbnail( $team, 'sportspress-fit-icon' );
|
||||
}
|
||||
|
||||
$alt = sizeof( $teams ) == 2 && $i % 2;
|
||||
|
||||
// Add team name
|
||||
if ( $show_team_names ) {
|
||||
if ( $alt ) {
|
||||
$logo .= ' <strong class="sp-team-name">' . sp_get_team_name( $team, $abbreviate_teams ) . '</strong>';
|
||||
} else {
|
||||
$logo = '<strong class="sp-team-name">' . sp_get_team_name( $team, $abbreviate_teams ) . '</strong> ' . $logo;
|
||||
}
|
||||
}
|
||||
|
||||
// Add link
|
||||
if ( $link_teams ) $logo = '<a href="' . get_post_permalink( $team ) . '">' . $logo . '</a>';
|
||||
|
||||
// Add result
|
||||
if ( $show_results && ! empty( $results ) ) {
|
||||
$team_result = array_shift( $results );
|
||||
$team_result = apply_filters( 'sportspress_event_logos_team_result', $team_result, $id, $team );
|
||||
if ( $alt ) {
|
||||
$logo = '<strong class="sp-team-result">' . $team_result . '</strong> ' . $logo;
|
||||
} else {
|
||||
$logo .= ' <strong class="sp-team-result">' . $team_result . '</strong>';
|
||||
}
|
||||
}
|
||||
|
||||
// Add logo to array
|
||||
if ( '' !== $logo ) {
|
||||
$team_logos[] = '<span class="sp-team-logo">' . $logo . '</span>';
|
||||
$i++;
|
||||
}
|
||||
endforeach;
|
||||
$team_logos = array_filter( $team_logos );
|
||||
if ( ! empty( $team_logos ) ):
|
||||
echo '<div class="sp-template sp-template-event-logos"><div class="sp-event-logos sp-event-logos-' . sizeof( $teams ) . '">';
|
||||
|
||||
// Assign delimiter
|
||||
if ( $show_time && sizeof( $teams ) <= 2 ) {
|
||||
$delimiter = '<strong class="sp-event-logos-time sp-team-result">' . get_the_time( get_option('time_format'), $id ) . '</strong>';
|
||||
} else {
|
||||
$delimiter = get_option( 'sportspress_event_teams_delimiter', 'vs' );
|
||||
}
|
||||
|
||||
echo implode( ' ' . $delimiter . ' ', $team_logos );
|
||||
echo '</div></div>';
|
||||
endif;
|
||||
@@ -10,13 +10,21 @@
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( get_option( 'sportspress_event_show_logos', 'yes' ) === 'no' ) return;
|
||||
|
||||
if ( ! isset( $id ) )
|
||||
$id = get_the_ID();
|
||||
|
||||
$teams = get_post_meta( $id, 'sp_team' );
|
||||
$teams = array_filter( $teams, 'sp_filter_positive' );
|
||||
|
||||
if ( ! $teams ) return;
|
||||
|
||||
$layout = get_option( 'sportspress_event_logos_format', 'inline' );
|
||||
|
||||
$show_team_names = get_option( 'sportspress_event_logos_show_team_names', 'no' ) === 'yes' ? true : false;
|
||||
$show_time = get_option( 'sportspress_event_logos_show_time', 'no' ) === 'yes' ? true : false;
|
||||
$show_results = get_option( 'sportspress_event_logos_show_results', 'no' ) === 'yes' ? true : false;
|
||||
$abbreviate_teams = get_option( 'sportspress_abbreviate_teams', 'yes' ) === 'yes' ? true : false;
|
||||
|
||||
if ( ! isset( $id ) )
|
||||
$id = get_the_ID();
|
||||
$link_teams = get_option( 'sportspress_link_teams', 'no' ) === 'yes' ? true : false;
|
||||
|
||||
if ( $show_results ) {
|
||||
$results = sp_get_main_results( $id );
|
||||
@@ -27,61 +35,13 @@ if ( $show_results ) {
|
||||
}
|
||||
}
|
||||
|
||||
$teams = get_post_meta( $id, 'sp_team' );
|
||||
$teams = array_filter( $teams, 'sp_filter_positive' );
|
||||
if ( $teams ):
|
||||
$team_logos = array();
|
||||
$i = 0;
|
||||
foreach ( $teams as $team ):
|
||||
if ( ! has_post_thumbnail( $team ) ) {
|
||||
$logo = '';
|
||||
} else {
|
||||
$logo = get_the_post_thumbnail( $team, 'sportspress-fit-icon' );
|
||||
}
|
||||
|
||||
$alt = sizeof( $teams ) == 2 && $i % 2;
|
||||
|
||||
// Add team name
|
||||
if ( $show_team_names ) {
|
||||
if ( $alt ) {
|
||||
$logo .= ' <strong class="sp-team-name">' . sp_get_team_name( $team, $abbreviate_teams ) . '</strong>';
|
||||
} else {
|
||||
$logo = '<strong class="sp-team-name">' . sp_get_team_name( $team, $abbreviate_teams ) . '</strong> ' . $logo;
|
||||
}
|
||||
}
|
||||
|
||||
// Add link
|
||||
if ( get_option( 'sportspress_link_teams', 'no' ) == 'yes' ) $logo = '<a href="' . get_post_permalink( $team ) . '">' . $logo . '</a>';
|
||||
|
||||
// Add result
|
||||
if ( $show_results && ! empty( $results ) ) {
|
||||
$team_result = array_shift( $results );
|
||||
$team_result = apply_filters( 'sportspress_event_logos_team_result', $team_result, $id, $team );
|
||||
if ( $alt ) {
|
||||
$logo = '<strong class="sp-team-result">' . $team_result . '</strong> ' . $logo;
|
||||
} else {
|
||||
$logo .= ' <strong class="sp-team-result">' . $team_result . '</strong>';
|
||||
}
|
||||
}
|
||||
|
||||
// Add logo to array
|
||||
if ( '' !== $logo ) {
|
||||
$team_logos[] = '<span class="sp-team-logo">' . $logo . '</span>';
|
||||
$i++;
|
||||
}
|
||||
endforeach;
|
||||
$team_logos = array_filter( $team_logos );
|
||||
if ( ! empty( $team_logos ) ):
|
||||
echo '<div class="sp-template sp-template-event-logos"><div class="sp-event-logos sp-event-logos-' . sizeof( $teams ) . '">';
|
||||
|
||||
// Assign delimiter
|
||||
if ( $show_time && sizeof( $teams ) <= 2 ) {
|
||||
$delimiter = '<strong class="sp-event-logos-time sp-team-result">' . get_the_time( get_option('time_format'), $id ) . '</strong>';
|
||||
} else {
|
||||
$delimiter = get_option( 'sportspress_event_teams_delimiter', 'vs' );
|
||||
}
|
||||
|
||||
echo implode( ' ' . $delimiter . ' ', $team_logos );
|
||||
echo '</div></div>';
|
||||
endif;
|
||||
endif;
|
||||
sp_get_template( 'event-logos-' . $layout . '.php', array(
|
||||
'id' => $id,
|
||||
'teams' => $teams,
|
||||
'results' => $results,
|
||||
'show_team_names' => $show_team_names,
|
||||
'show_time' => $show_time,
|
||||
'show_results' => $show_results,
|
||||
'abbreviate_teams' => $abbreviate_teams,
|
||||
'link_teams' => $link_teams,
|
||||
) );
|
||||
Reference in New Issue
Block a user