Add options to toggle individual templates per post type

This commit is contained in:
Brian Miyaji
2014-10-22 18:51:25 +11:00
parent 5d144aacfb
commit 13cb8cbada
14 changed files with 404 additions and 233 deletions

View File

@@ -47,13 +47,61 @@ class SP_Settings_Events extends SP_Settings_Page {
'id' => 'sportspress_link_events',
'default' => 'yes',
'type' => 'checkbox',
),
array(
'title' => __( 'Display', 'sportspress' ),
'desc' => __( 'Logos', 'sportspress' ),
'id' => 'sportspress_event_show_logos',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => __( 'Link venues', 'sportspress' ),
'id' => 'sportspress_link_venues',
'default' => 'no',
'desc' => __( 'Results', 'sportspress' ),
'id' => 'sportspress_event_show_results',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Details', 'sportspress' ),
'id' => 'sportspress_event_show_details',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Venue', 'sportspress' ),
'id' => 'sportspress_event_show_venue',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Players', 'sportspress' ),
'id' => 'sportspress_event_show_players',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Staff', 'sportspress' ),
'id' => 'sportspress_event_show_staff',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Total', 'sportspress' ),
'id' => 'sportspress_event_show_total',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
@@ -73,31 +121,6 @@ class SP_Settings_Events extends SP_Settings_Page {
array( 'type' => 'delimiter' ),
array(
'title' => __( 'Teams', 'sportspress' ),
'desc' => __( 'Display logos', 'sportspress' ),
'id' => 'sportspress_event_show_logos',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => __( 'Display players', 'sportspress' ),
'id' => 'sportspress_event_show_players',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Display total', 'sportspress' ),
'id' => 'sportspress_event_show_total',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'title' => __( 'Player Performance', 'sportspress' ),
'id' => 'sportspress_event_performance_mode',
@@ -110,7 +133,7 @@ class SP_Settings_Events extends SP_Settings_Page {
),
array(
'title' => __( 'Venue', 'sportspress' ),
'title' => __( 'Venues', 'sportspress' ),
'desc' => __( 'Display maps', 'sportspress' ),
'id' => 'sportspress_event_show_maps',
'default' => 'yes',
@@ -119,12 +142,11 @@ class SP_Settings_Events extends SP_Settings_Page {
),
array(
'title' => __( 'Staff', 'sportspress' ),
'desc' => __( 'Display staff', 'sportspress' ),
'id' => 'sportspress_event_show_staff',
'default' => 'yes',
'desc' => __( 'Link venues', 'sportspress' ),
'id' => 'sportspress_link_venues',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'start',
'checkboxgroup' => 'end',
),
array(

View File

@@ -46,6 +46,23 @@ class SP_Settings_Players extends SP_Settings_Page {
'type' => 'checkbox',
),
array(
'title' => __( 'Display', 'sportspress' ),
'desc' => __( 'Photo', 'sportspress' ),
'id' => 'sportspress_player_show_photo',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => __( 'Details', 'sportspress' ),
'id' => 'sportspress_player_show_details',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'title' => __( 'Nationality', 'sportspress' ),
'desc' => __( 'Display national flags', 'sportspress' ),

View File

@@ -48,6 +48,23 @@ class SP_Settings_Staff extends SP_Settings_Page {
'type' => 'checkbox',
),
array(
'title' => __( 'Display', 'sportspress' ),
'desc' => __( 'Photo', 'sportspress' ),
'id' => 'sportspress_staff_show_photo',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => __( 'Details', 'sportspress' ),
'id' => 'sportspress_staff_show_details',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'title' => __( 'Nationality', 'sportspress' ),
'desc' => __( 'Display national flags', 'sportspress' ),

View File

@@ -48,6 +48,39 @@ class SP_Settings_Teams extends SP_Settings_Page {
'type' => 'checkbox',
),
array(
'title' => __( 'Display', 'sportspress' ),
'desc' => __( 'Logo', 'sportspress' ),
'id' => 'sportspress_team_show_logo',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => __( 'Details', 'sportspress' ),
'id' => 'sportspress_team_show_details',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Visit Site', 'sportspress' ),
'id' => 'sportspress_team_show_link',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'title' => __( 'Venue', 'sportspress' ),
'desc' => __( 'Link venues', 'sportspress' ),
'id' => 'sportspress_team_link_venues',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Abbreviation', 'sportspress' ),
'desc' => __( 'Abbreviate team names', 'sportspress' ),

View File

@@ -186,6 +186,32 @@ if ( ! function_exists( 'sportspress_output_team_link' ) ) {
sp_get_template( 'team-link.php' );
}
}
if ( ! function_exists( 'sportspress_output_team_logo' ) ) {
/**
* Output the team logo.
*
* @access public
* @subpackage Team/Logo
* @return void
*/
function sportspress_output_team_logo() {
sp_get_template( 'team-logo.php' );
}
}
if ( ! function_exists( 'sportspress_output_team_details' ) ) {
/**
* Output the team details.
*
* @access public
* @subpackage Team/Details
* @return void
*/
function sportspress_output_team_details() {
sp_get_template( 'team-details.php' );
}
}
if ( ! function_exists( 'sportspress_output_team_tables' ) ) {
/**
@@ -231,13 +257,26 @@ if ( ! function_exists( 'sportspress_output_league_table' ) ) {
/** Single Player ********************************************************/
if ( ! function_exists( 'sportspress_output_player_photo' ) ) {
/**
* Output the player photo.
*
* @access public
* @subpackage Player/Photo
* @return void
*/
function sportspress_output_player_photo() {
sp_get_template( 'player-photo.php' );
}
}
if ( ! function_exists( 'sportspress_output_player_details' ) ) {
/**
* Output the player metrics.
* Output the player details.
*
* @access public
* @subpackage Player/Metrics
* @subpackage Player/Details
* @return void
*/
function sportspress_output_player_details() {
@@ -281,13 +320,26 @@ if ( ! function_exists( 'sportspress_output_player_list' ) ) {
/** Single Staff ********************************************************/
if ( ! function_exists( 'sportspress_output_staff_photo' ) ) {
/**
* Output the staff photo.
*
* @access public
* @subpackage Staff/Photo
* @return void
*/
function sportspress_output_staff_photo() {
sp_get_template( 'staff-photo.php' );
}
}
if ( ! function_exists( 'sportspress_output_staff_details' ) ) {
/**
* Output the staff metrics.
* Output the staff details.
*
* @access public
* @subpackage Staff/Metrics
* @subpackage Staff/Details
* @return void
*/
function sportspress_output_staff_details() {

View File

@@ -30,8 +30,9 @@ add_action( 'get_the_generator_xhtml', 'sp_generator_tag', 10, 2 );
* @see sportspress_output_event_details()
* @see sportspress_output_event_venue()
* @see sportspress_output_event_performance()
* @see sportspress_output_br_tag()
*/
add_action( 'sportspress_single_event_content', 'sportspress_output_event_logos', 5 );
add_action( 'sportspress_single_event_content', 'sportspress_output_event_logos', 0 );
add_action( 'sportspress_single_event_content', 'sportspress_output_event_video', 10 );
add_action( 'sportspress_single_event_content', 'sportspress_output_event_results', 20 );
add_action( 'sportspress_single_event_content', 'sportspress_output_event_details', 30 );
@@ -43,6 +44,7 @@ add_action( 'sportspress_single_event_content', 'sportspress_output_br_tag', 100
* Single Calendar Content
*
* @see sportspress_output_calendar()
* @see sportspress_output_br_tag()
*/
add_action( 'sportspress_single_calendar_content', 'sportspress_output_calendar', 10 );
add_action( 'sportspress_single_calendar_content', 'sportspress_output_br_tag', 100 );
@@ -50,20 +52,29 @@ add_action( 'sportspress_single_calendar_content', 'sportspress_output_br_tag',
/**
* Single Team Content
*
* @see sportspress_output_team_link()
* @see sportspress_output_team_tables()
* @see sportspress_output_team_logo()
* @see sportspress_output_team_details()
* @see sportspress_output_team_lists()
* @see sportspress_output_team_tables()
* @see sportspress_output_br_tag()
*/
add_action( 'sportspress_single_team_content', 'sportspress_output_team_logo', 0 );
add_action( 'sportspress_single_team_content', 'sportspress_output_team_details', 10 );
add_action( 'sportspress_single_team_content', 'sportspress_output_team_lists', 20 );
add_action( 'sportspress_single_team_content', 'sportspress_output_team_tables', 30 );
add_action( 'sportspress_single_team_content', 'sportspress_output_br_tag', 100 );
/**
* After Single Team
* @see sportspress_output_team_link()
*/
add_action( 'sportspress_after_single_team', 'sportspress_output_team_link', 10 );
/**
* Single Table Content
*
* @see sportspress_output_league_table()
* @see sportspress_output_br_tag()
*/
add_action( 'sportspress_single_table_content', 'sportspress_output_league_table', 10 );
add_action( 'sportspress_single_table_content', 'sportspress_output_br_tag', 100 );
@@ -71,9 +82,12 @@ add_action( 'sportspress_single_table_content', 'sportspress_output_br_tag', 100
/**
* Single Player Content
*
* @see sportspress_output_player_photo()
* @see sportspress_output_player_details()
* @see sportspress_output_player_statistics()
* @see sportspress_output_br_tag()
*/
add_action( 'sportspress_single_player_content', 'sportspress_output_player_photo', 0 );
add_action( 'sportspress_single_player_content', 'sportspress_output_player_details', 10 );
add_action( 'sportspress_single_player_content', 'sportspress_output_player_statistics', 20 );
add_action( 'sportspress_single_player_content', 'sportspress_output_br_tag', 100 );
@@ -82,6 +96,7 @@ add_action( 'sportspress_single_player_content', 'sportspress_output_br_tag', 10
* Single List Content
*
* @see sportspress_output_player_list()
* @see sportspress_output_br_tag()
*/
add_action( 'sportspress_single_list_content', 'sportspress_output_player_list', 10 );
add_action( 'sportspress_single_list_content', 'sportspress_output_br_tag', 100 );
@@ -89,8 +104,11 @@ add_action( 'sportspress_single_list_content', 'sportspress_output_br_tag', 100
/**
* Single Staff Content
*
* @see sportspress_output_staff_photo()
* @see sportspress_output_staff_details()
* @see sportspress_output_br_tag()
*/
add_action( 'sportspress_single_staff_content', 'sportspress_output_staff_photo', 0 );
add_action( 'sportspress_single_staff_content', 'sportspress_output_staff_details', 10 );
add_action( 'sportspress_single_staff_content', 'sportspress_output_br_tag', 100 );

View File

@@ -8,6 +8,7 @@
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( get_option( 'sportspress_event_show_details', 'yes' ) === 'no' ) return;
if ( ! isset( $id ) )
$id = get_the_ID();

View File

@@ -8,17 +8,19 @@
*/
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();
if ( get_option( 'sportspress_event_show_logos', 'yes' ) == 'yes' ):
$teams = get_post_meta( $id, 'sp_team' );
$teams = array_filter( $teams );
if ( $teams ):
$teams = get_post_meta( $id, 'sp_team' );
$teams = array_filter( $teams );
if ( $teams ):
$team_logos = array();
foreach ( $teams as $team ):
$team_logos[] = get_the_post_thumbnail( $team, 'sportspress-fit-icon' );
$logo = get_the_post_thumbnail( $team, 'sportspress-fit-icon' );
if ( get_option( 'sportspress_link_teams', 'no' ) == 'yes' ) $logo = '<a href="' . get_post_permalink( $team ) . '">' . $logo . '</a>';
$team_logos[] = $logo;
endforeach;
$team_logos = array_filter( $team_logos );
if ( ! empty( $team_logos ) ):
@@ -27,5 +29,4 @@ if ( get_option( 'sportspress_event_show_logos', 'yes' ) == 'yes' ):
echo implode( ' ' . $delimiter . ' ', $team_logos );
echo '</div>';
endif;
endif;
endif;

View File

@@ -9,39 +9,46 @@
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
$show_players = get_option( 'sportspress_event_show_players', 'yes' ) === 'yes' ? true : false;
$show_staff = get_option( 'sportspress_event_show_staff', 'yes' ) === 'yes' ? true : false;
$show_total = get_option( 'sportspress_event_show_total', 'yes' ) === 'yes' ? true : false;
if ( ! $show_players && ! $show_staff && ! $show_total ) return;
if ( ! isset( $id ) )
$id = get_the_ID();
$event = new SP_Event( $id );
$performance = $event->performance();
// The first row should be column labels
$labels = $performance[0];
// Remove the first row to leave us with the actual data
unset( $performance[0] );
$performance = array_filter( $performance );
$teams = get_post_meta( $id, 'sp_team', false );
$status = $event->status();
$show_players = get_option( 'sportspress_event_show_players', 'yes' ) == 'yes' ? true : false;
$link_posts = get_option( 'sportspress_link_players', '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' );
if ( is_array( $teams ) ):
// Get performance ids for icons
if ( $mode == 'icons' ):
$event = new SP_Event( $id );
$performance = $event->performance();
// The first row should be column labels
$labels = $performance[0];
// Remove the first row to leave us with the actual data
unset( $performance[0] );
$performance = array_filter( $performance );
$status = $event->status();
$link_posts = get_option( 'sportspress_link_players', '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;
endif;
if ( is_array( $teams ) ):
foreach( $teams as $index => $team_id ):
if ( ! $team_id ) continue;
@@ -49,10 +56,7 @@ if ( is_array( $teams ) ):
$players = sp_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $index );
$has_players = sizeof( $players ) > 1;
if ( ! $has_players ):
if ( $status != 'results' ) continue;
elseif ( get_option( 'sportspress_event_show_total', 'yes' ) != 'yes' ) continue;
endif;
$show_players = $show_players && $has_players;
$totals = array();
@@ -62,15 +66,16 @@ if ( is_array( $teams ) ):
<div class="sp-template sp-template-event-performance">
<h4 class="sp-table-caption"><?php echo get_the_title( $team_id ); ?></h4>
<?php
if ( get_option( 'sportspress_event_show_staff', 'yes' ) == 'yes' ):
if ( $show_staff ):
sp_get_template( 'event-staff.php', array( 'id' => $id, 'index' => $index ) );
endif;
?>
<?php if ( $show_players || $show_total ): ?>
<div class="sp-table-wrapper<?php if ( $scrollable ) { ?> sp-scrollable-table-wrapper<?php } ?>">
<table class="sp-event-performance sp-data-table <?php if ( $responsive ) { ?> sp-responsive-table<?php } ?>">
<thead>
<tr>
<?php if ( $has_players ): ?>
<?php if ( $show_players ): ?>
<th class="data-number">#</th>
<th class="data-name"><?php _e( 'Player', 'sportspress' ); ?></th>
<?php endif; ?>
@@ -81,7 +86,7 @@ if ( is_array( $teams ) ):
<?php endif; ?>
</tr>
</thead>
<?php if ( $show_players && $has_players ): ?>
<?php if ( $show_players ): ?>
<tbody>
<?php
@@ -172,11 +177,11 @@ if ( is_array( $teams ) ):
?>
</tbody>
<?php endif; ?>
<?php if ( $status == 'results' && get_option( 'sportspress_event_show_total', 'yes' ) == 'yes' && array_key_exists( 0, $data ) ): ?>
<<?php echo ( $show_players && $has_players ? 'tfoot' : 'tbody' ); ?>>
<?php if ( $status == 'results' && $show_total && array_key_exists( 0, $data ) ): ?>
<<?php echo ( $show_players ? 'tfoot' : 'tbody' ); ?>>
<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">
<?php
if ( $has_players ):
if ( $show_players ):
echo '<td class="data-number">&nbsp;</td>';
echo '<td class="data-name">' . __( 'Total', 'sportspress' ) . '</td>';
endif;
@@ -209,10 +214,11 @@ if ( is_array( $teams ) ):
if ( $mode == 'icons' ) echo '</td>';
?>
</tr>
</<?php echo ( $has_players ? 'tfoot' : 'tbody' ); ?>>
</<?php echo ( $show_players ? 'tfoot' : 'tbody' ); ?>>
<?php endif; ?>
</table>
</div>
<?php endif; ?>
</div>
<?php
endforeach;

View File

@@ -8,6 +8,7 @@
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( get_option( 'sportspress_event_show_results', 'yes' ) === 'no' ) return;
if ( ! isset( $id ) )
$id = get_the_ID();

View File

@@ -8,6 +8,7 @@
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( get_option( 'sportspress_event_show_venue', 'yes' ) === 'no' ) return;
if ( ! isset( $id ) )
$id = get_the_ID();

View File

@@ -4,10 +4,11 @@
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
* @version 1.4
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( get_option( 'sportspress_player_show_details', 'yes' ) === 'no' ) return;
if ( ! isset( $id ) )
$id = get_the_ID();
@@ -66,15 +67,14 @@ if ( $past_teams ):
$data[ __( 'Past Teams', 'sportspress' ) ] = implode( ', ', $teams );
endif;
$output = '<div class="sp-list-wrapper">' .
'<dl class="sp-player-details">';
$output = '<div class="sp-template sp-template-player-details sp-template-details"><div class="sp-list-wrapper"><dl class="sp-player-details">';
foreach( $data as $label => $value ):
$output .= '<dt>' . $label . '<dd>' . $value . '</dd>';
$output .= '<dt>' . $label . '</dt><dd>' . $value . '</dd>';
endforeach;
$output .= '</dl></div>';
$output .= '</dl></div></div>';
echo $output;

View File

@@ -4,10 +4,11 @@
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
* @version 1.4
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( get_option( 'sportspress_staff_show_details', 'yes' ) === 'no' ) return;
if ( ! isset( $id ) )
$id = get_the_ID();
@@ -48,12 +49,12 @@ $output = '<div class="sp-list-wrapper">' .
foreach( $data as $label => $value ):
$output .= '<dt>' . $label . '<dd>' . $value . '</dd>';
$output .= '<dt>' . $label . '</dt><dd>' . $value . '</dd>';
endforeach;
$output .= '</dl></div>';
?>
<div class="sp-template sp-template-staff-details">
<div class="sp-template sp-template-staff-details sp-template-details">
<?php echo $output; ?>
</div>

View File

@@ -8,6 +8,7 @@
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( get_option( 'sportspress_team_show_link', 'yes' ) === 'no' ) return;
if ( ! isset( $id ) )
$id = get_the_ID();