Add single player shortcodes

This commit is contained in:
Brian Miyaji
2014-07-12 02:31:42 +10:00
parent da3bf43787
commit 563f646866
5 changed files with 109 additions and 0 deletions

View File

@@ -150,6 +150,7 @@ class SP_Admin_Meta_Boxes {
add_meta_box( 'sp_editordiv', __( 'Description', 'sportspress' ), 'SP_Meta_Box_Table_Editor::output', 'sp_table', 'normal', 'low' ); add_meta_box( 'sp_editordiv', __( 'Description', 'sportspress' ), 'SP_Meta_Box_Table_Editor::output', 'sp_table', 'normal', 'low' );
// Players // Players
add_meta_box( 'sp_shortcodediv', __( 'Shortcodes', 'sportspress' ), 'SP_Meta_Box_Player_Shortcode::output', 'sp_player', 'side', 'default' );
add_meta_box( 'sp_columnsdiv', __( 'Columns', 'sportspress' ), 'SP_Meta_Box_Player_Columns::output', 'sp_player', 'side', 'default' ); add_meta_box( 'sp_columnsdiv', __( 'Columns', 'sportspress' ), 'SP_Meta_Box_Player_Columns::output', 'sp_player', 'side', 'default' );
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Player_Details::output', 'sp_player', 'side', 'default' ); add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Player_Details::output', 'sp_player', 'side', 'default' );
add_meta_box( 'sp_metricsdiv', __( 'Metrics', 'sportspress' ), 'SP_Meta_Box_Player_Metrics::output', 'sp_player', 'side', 'default' ); add_meta_box( 'sp_metricsdiv', __( 'Metrics', 'sportspress' ), 'SP_Meta_Box_Player_Metrics::output', 'sp_player', 'side', 'default' );

View File

@@ -0,0 +1,36 @@
<?php
/**
* Player Shortcode
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta_Boxes
* @version 1.2
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Player_Shortcode
*/
class SP_Meta_Box_Player_Shortcode {
/**
* Output the metabox
*/
public static function output( $post ) {
?>
<p class="howto">
<?php _e( 'Copy this code and paste it into your post, page or text widget content.', 'sportspress' ); ?>
</p>
<p>
<strong><?php _e( 'Details', 'sportspress' ); ?></strong>
</p>
<p><input type="text" value="[player_details <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
<p>
<strong><?php _e( 'Statistics', 'sportspress' ); ?></strong>
</p>
<p><input type="text" value="[player_statistics <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
<?php
}
}

View File

@@ -24,6 +24,8 @@ class SP_Shortcodes {
'event_list' => __CLASS__ . '::event_list', 'event_list' => __CLASS__ . '::event_list',
'event_blocks' => __CLASS__ . '::event_blocks', 'event_blocks' => __CLASS__ . '::event_blocks',
'league_table' => __CLASS__ . '::league_table', 'league_table' => __CLASS__ . '::league_table',
'player_details' => __CLASS__ . '::player_details',
'player_statistics' => __CLASS__ . '::player_statistics',
'player_list' => __CLASS__ . '::player_list', 'player_list' => __CLASS__ . '::player_list',
'player_gallery' => __CLASS__ . '::player_gallery', 'player_gallery' => __CLASS__ . '::player_gallery',
); );
@@ -160,6 +162,28 @@ class SP_Shortcodes {
return self::shortcode_wrapper( array( 'SP_Shortcode_League_Table', 'output' ), $atts ); return self::shortcode_wrapper( array( 'SP_Shortcode_League_Table', 'output' ), $atts );
} }
/**
* Player details shortcode.
*
* @access public
* @param mixed $atts
* @return string
*/
public static function player_details( $atts ) {
return self::shortcode_wrapper( array( 'SP_Shortcode_Player_Details', 'output' ), $atts );
}
/**
* Player statistics shortcode.
*
* @access public
* @param mixed $atts
* @return string
*/
public static function player_statistics( $atts ) {
return self::shortcode_wrapper( array( 'SP_Shortcode_Player_Statistics', 'output' ), $atts );
}
/** /**
* Player performance shortcode. * Player performance shortcode.
* *

View File

@@ -0,0 +1,24 @@
<?php
/**
* Player Details Shortcode
*
* @author ThemeBoy
* @category Shortcodes
* @package SportsPress/Shortcodes/Player_Details
* @version 1.2
*/
class SP_Shortcode_Player_Details {
/**
* Output the player details 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( 'player-details.php', $atts );
}
}

View File

@@ -0,0 +1,24 @@
<?php
/**
* Player Statistics Shortcode
*
* @author ThemeBoy
* @category Shortcodes
* @package SportsPress/Shortcodes/Player_Statistics
* @version 1.2
*/
class SP_Shortcode_Player_Statistics {
/**
* Output the player statistics 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( 'player-statistics.php', $atts );
}
}