Add team gallery template

This commit is contained in:
Brian Miyaji
2017-06-06 15:22:33 +10:00
parent 18a417adf3
commit 2cb7a7528b
15 changed files with 334 additions and 29 deletions

View File

@@ -0,0 +1,39 @@
<?php
/**
* Table Format
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta_Boxes
* @version 2.3
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Table_Format
*/
class SP_Meta_Box_Table_Format {
/**
* Output the metabox
*/
public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
$the_format = get_post_meta( $post->ID, 'sp_format', true );
?>
<div id="post-formats-select">
<?php foreach ( SP()->formats->table as $key => $format ): ?>
<input type="radio" name="sp_format" class="post-format" id="post-format-<?php echo $key; ?>" value="<?php echo $key; ?>" <?php checked( true, ( $key == 'standings' && ! $the_format ) || $the_format == $key ); ?>> <label for="post-format-<?php echo $key; ?>" class="post-format-icon post-format-<?php echo $key; ?>"><?php echo $format; ?></label><br>
<?php endforeach; ?>
</div>
<?php
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_format', sp_array_value( $_POST, 'sp_format', 'standings' ) );
}
}

View File

@@ -19,11 +19,13 @@ class SP_Meta_Box_Table_Shortcode {
* Output the metabox
*/
public static function output( $post ) {
$the_format = get_post_meta( $post->ID, 'sp_format', true );
if ( ! $the_format ) $the_format = 'standings';
?>
<p class="howto">
<?php _e( 'Copy this code and paste it into your post, page or text widget content.', 'sportspress' ); ?>
</p>
<p><input type="text" value="<?php sp_shortcode_template( 'league_table', $post->ID ); ?>" readonly="readonly" class="code widefat"></p>
<p><input type="text" value="<?php sp_shortcode_template( 'team_' . $the_format, $post->ID ); ?>" readonly="readonly" class="code widefat"></p>
<?php
}
}

View File

@@ -30,7 +30,7 @@ class SP_AJAX {
'event_calendar_shortcode' => false,
'event_list_shortcode' => false,
'event_blocks_shortcode' => false,
'table_table_shortcode' => false,
'team_standings_shortcode' => false,
'player_details_shortcode' => false,
'player_statistics_shortcode' => false,
'player_list_shortcode' => false,
@@ -610,11 +610,11 @@ class SP_AJAX {
}
/**
* AJAX league_table shortcode
* AJAX team_standings shortcode
*/
public function table_table_shortcode() {
public function team_standings_shortcode() {
?>
<div class="wrap sp-thickbox-content" id="sp-thickbox-league_table">
<div class="wrap sp-thickbox-content" id="sp-thickbox-team_standings">
<p>
<label>
<?php _e( 'Title:', 'sportspress' ); ?>
@@ -673,7 +673,7 @@ class SP_AJAX {
</p>
<?php do_action( 'sportspress_ajax_shortcode_form', 'league-table' ); ?>
<p class="submit">
<input type="button" class="button-primary" value="<?php _e( 'Insert Shortcode', 'sportspress' ); ?>" onclick="insertSportsPress('league_table');" />
<input type="button" class="button-primary" value="<?php _e( 'Insert Shortcode', 'sportspress' ); ?>" onclick="insertSportsPress('team_standings');" />
<a class="button-secondary" onclick="tb_remove();" title="<?php _e( 'Cancel', 'sportspress' ); ?>"><?php _e( 'Cancel', 'sportspress' ); ?></a>
</p>
</div>
@@ -971,7 +971,7 @@ class SP_AJAX {
args.orderby = $div.find('[name=orderby]').val();
args.order = $div.find('[name=order]').val();
args.show_all_events_link = $div.find('[name=show_all_events_link]:checked').length;
} else if ( 'league_table' == type ) {
} else if ( 'team_standings' == type ) {
args.title = $div.find('[name=title]').val();
args.number = $div.find('[name=number]').val();
args.columns = $div.find('[name="columns[]"]:checked').map(function() { return this.value; }).get().join(',');

View File

@@ -32,6 +32,10 @@ class SP_Formats {
'list' => __( 'List', 'sportspress' ),
'blocks' => __( 'Blocks', 'sportspress' ),
),
'table' => array(
'standings' => __( 'Standings', 'sportspress' ),
'gallery' => __( 'Gallery', 'sportspress' ),
),
'list' => array(
'list' => __( 'List', 'sportspress' ),
'gallery' => __( 'Gallery', 'sportspress' ),

View File

@@ -16,19 +16,21 @@ class SP_Shortcodes {
public static function init() {
// Define shortcodes
$shortcodes = array(
'event_results' => __CLASS__ . '::event_results',
'event_details' => __CLASS__ . '::event_details',
'event_performance' => __CLASS__ . '::event_performance',
'countdown' => __CLASS__ . '::countdown',
'player_details' => __CLASS__ . '::player_details',
'player_statistics' => __CLASS__ . '::player_statistics',
'staff' => __CLASS__ . '::staff',
'event_calendar' => __CLASS__ . '::event_calendar',
'event_list' => __CLASS__ . '::event_list',
'event_blocks' => __CLASS__ . '::event_blocks',
'league_table' => __CLASS__ . '::league_table',
'player_list' => __CLASS__ . '::player_list',
'player_gallery' => __CLASS__ . '::player_gallery',
'event_results' => __CLASS__ . '::event_results',
'event_details' => __CLASS__ . '::event_details',
'event_performance' => __CLASS__ . '::event_performance',
'countdown' => __CLASS__ . '::countdown',
'player_details' => __CLASS__ . '::player_details',
'player_statistics' => __CLASS__ . '::player_statistics',
'staff' => __CLASS__ . '::staff',
'event_calendar' => __CLASS__ . '::event_calendar',
'event_list' => __CLASS__ . '::event_list',
'event_blocks' => __CLASS__ . '::event_blocks',
'league_table' => __CLASS__ . '::league_table',
'team_standings' => __CLASS__ . '::league_table',
'team_gallery' => __CLASS__ . '::team_gallery',
'player_list' => __CLASS__ . '::player_list',
'player_gallery' => __CLASS__ . '::player_gallery',
);
foreach ( $shortcodes as $shortcode => $function ) {
@@ -144,7 +146,7 @@ class SP_Shortcodes {
}
/**
* League table shortcode.
* League table (team standings) shortcode.
*
* @access public
* @param mixed $atts
@@ -154,6 +156,17 @@ class SP_Shortcodes {
return self::shortcode_wrapper( array( 'SP_Shortcode_League_Table', 'output' ), $atts );
}
/**
* Team gallery shortcode.
*
* @access public
* @param mixed $atts
* @return string
*/
public static function team_gallery( $atts ) {
return self::shortcode_wrapper( array( 'SP_Shortcode_Team_Gallery', 'output' ), $atts );
}
/**
* Player details shortcode.
*

View File

@@ -0,0 +1,24 @@
<?php
/**
* Team Gallery Shortcode
*
* @author ThemeBoy
* @category Shortcodes
* @package SportsPress/Shortcodes/Team_Gallery
* @version 2.3.2
*/
class SP_Shortcode_Team_Gallery {
/**
* Output the team gallery shortcode.
*
* @param array $atts
*/
public static function output( $atts ) {
if ( ! isset( $atts['id'] ) && isset( $atts[0] ) && is_numeric( $atts[0] ) )
$atts['id'] = $atts[0];
sp_get_template( 'team-gallery.php', $atts );
}
}

View File

@@ -330,7 +330,12 @@ if ( ! function_exists( 'sportspress_output_league_table' ) ) {
* @return void
*/
function sportspress_output_league_table() {
sp_get_template( 'league-table.php' );
$id = get_the_ID();
$format = get_post_meta( $id, 'sp_format', true );
if ( array_key_exists( $format, SP()->formats->table ) && 'standings' !== $format )
sp_get_template( 'team-' . $format . '.php', array( 'id' => $id ) );
else
sp_get_template( 'league-table.php', array( 'id' => $id ) );
}
}