Add option to show or hide logos or photos in event blocks

This commit is contained in:
Brian Miyaji
2016-05-24 16:54:32 +10:00
parent 3ec2eca9de
commit 9ca1e03448
3 changed files with 27 additions and 15 deletions

View File

@@ -5,7 +5,7 @@ Plugin URI: http://themeboy.com/
Description: Add event calendars to SportsPress. Description: Add event calendars to SportsPress.
Author: ThemeBoy Author: ThemeBoy
Author URI: http://themeboy.com/ Author URI: http://themeboy.com/
Version: 2.0 Version: 2.0.7
*/ */
// Exit if accessed directly // Exit if accessed directly
@@ -17,7 +17,7 @@ if ( ! class_exists( 'SportsPress_Calendars' ) ) :
* Main SportsPress Calendars Class * Main SportsPress Calendars Class
* *
* @class SportsPress_Calendars * @class SportsPress_Calendars
* @version 2.0 * @version 2.0.7
*/ */
class SportsPress_Calendars { class SportsPress_Calendars {
@@ -49,7 +49,7 @@ class SportsPress_Calendars {
*/ */
private function define_constants() { private function define_constants() {
if ( !defined( 'SP_CALENDARS_VERSION' ) ) if ( !defined( 'SP_CALENDARS_VERSION' ) )
define( 'SP_CALENDARS_VERSION', '2.0' ); define( 'SP_CALENDARS_VERSION', '2.0.7' );
if ( !defined( 'SP_CALENDARS_URL' ) ) if ( !defined( 'SP_CALENDARS_URL' ) )
define( 'SP_CALENDARS_URL', plugin_dir_url( __FILE__ ) ); define( 'SP_CALENDARS_URL', plugin_dir_url( __FILE__ ) );
@@ -311,6 +311,14 @@ class SportsPress_Calendars {
'type' => 'checkbox', 'type' => 'checkbox',
), ),
array(
'title' => __( 'Teams', 'sportspress' ),
'desc' => __( 'Display logos', 'sportspress' ),
'id' => 'sportspress_event_blocks_show_logos',
'default' => 'yes',
'type' => 'checkbox',
),
array( array(
'title' => __( 'Details', 'sportspress' ), 'title' => __( 'Details', 'sportspress' ),
'desc' => __( 'Display competition', 'sportspress' ), 'desc' => __( 'Display competition', 'sportspress' ),

View File

@@ -240,6 +240,7 @@ When you upgrade to one of the SportsPress Pro licenses, you can simply activate
== Changelog == == Changelog ==
= 2.0.7 = = 2.0.7 =
* Feature - Add option to show or hide logos or photos in event blocks.
* Tweak - Combine reverse teams option for results and box score. * Tweak - Combine reverse teams option for results and box score.
* Fix - Add filter to template output for extensions. * Fix - Add filter to template output for extensions.

View File

@@ -4,7 +4,7 @@
* *
* @author ThemeBoy * @author ThemeBoy
* @package SportsPress/Templates * @package SportsPress/Templates
* @version 2.0 * @version 2.0.7
*/ */
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -21,6 +21,7 @@ $defaults = array(
'venue' => null, 'venue' => null,
'team' => null, 'team' => null,
'number' => -1, 'number' => -1,
'show_team_logo' => get_option( 'sportspress_event_blocks_show_logos', 'yes' ) == 'yes' ? true : false,
'link_teams' => get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false, 'link_teams' => get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false,
'link_events' => get_option( 'sportspress_link_events', 'yes' ) == 'yes' ? true : false, 'link_events' => get_option( 'sportspress_link_events', 'yes' ) == 'yes' ? true : false,
'paginated' => get_option( 'sportspress_event_blocks_paginated', 'yes' ) == 'yes' ? true : false, 'paginated' => get_option( 'sportspress_event_blocks_paginated', 'yes' ) == 'yes' ? true : false,
@@ -91,18 +92,20 @@ if ( $title )
$teams = array_filter( $teams, 'sp_filter_positive' ); $teams = array_filter( $teams, 'sp_filter_positive' );
$logos = array(); $logos = array();
$j = 0; if ( $show_team_logo ):
foreach( $teams as $team ): $j = 0;
$j++; foreach( $teams as $team ):
if ( has_post_thumbnail ( $team ) ): $j++;
if ( $link_teams ): if ( has_post_thumbnail ( $team ) ):
$logo = '<a class="team-logo logo-' . ( $j % 2 ? 'odd' : 'even' ) . '" href="' . get_permalink( $team, false, true ) . '" title="' . get_the_title( $team ) . '">' . get_the_post_thumbnail( $team, 'sportspress-fit-icon' ) . '</a>'; if ( $link_teams ):
else: $logo = '<a class="team-logo logo-' . ( $j % 2 ? 'odd' : 'even' ) . '" href="' . get_permalink( $team, false, true ) . '" title="' . get_the_title( $team ) . '">' . get_the_post_thumbnail( $team, 'sportspress-fit-icon' ) . '</a>';
$logo = '<span class="team-logo logo-' . ( $j % 2 ? 'odd' : 'even' ) . '" title="' . get_the_title( $team ) . '">' . get_the_post_thumbnail( $team, 'sportspress-fit-icon' ) . '</span>'; else:
$logo = '<span class="team-logo logo-' . ( $j % 2 ? 'odd' : 'even' ) . '" title="' . get_the_title( $team ) . '">' . get_the_post_thumbnail( $team, 'sportspress-fit-icon' ) . '</span>';
endif;
$logos[] = $logo;
endif; endif;
$logos[] = $logo; endforeach;
endif; endif;
endforeach;
?> ?>
<tr class="sp-row sp-post<?php echo ( $i % 2 == 0 ? ' alternate' : '' ); ?>"> <tr class="sp-row sp-post<?php echo ( $i % 2 == 0 ? ' alternate' : '' ); ?>">
<td> <td>