Display 3 different shortcodes for event sections

This commit is contained in:
Brian Miyaji
2014-04-18 22:33:30 +10:00
parent 0384fb7425
commit 16429008a9
6 changed files with 111 additions and 30 deletions

View File

@@ -23,7 +23,18 @@ class SP_Meta_Box_Event_Shortcode {
<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="[event <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
<p>
<strong><?php _e( 'Results', 'sportspress' ); ?></strong>
</p>
<p><input type="text" value="[event_results <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
<p>
<strong><?php _e( 'Details', 'sportspress' ); ?></strong>
</p>
<p><input type="text" value="[event_details <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
<p>
<strong><?php _e( 'Performance', 'sportspress' ); ?></strong>
</p>
<p><input type="text" value="[event_performance <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
<?php
}
}

View File

@@ -112,7 +112,7 @@ class SP_Post_types {
'hierarchical' => true,
'rewrite' => array( 'slug' => get_option( 'sportspress_venue_slug', 'venue' ) ),
);
$object_types = array( 'sp_event', 'sp_calendar', 'attachment' );
$object_types = array( 'sp_event', 'sp_calendar' );
register_taxonomy( 'sp_venue', $object_types, $args );
foreach ( $object_types as $object_type ):
register_taxonomy_for_object_type( 'sp_league', $object_type );
@@ -141,7 +141,7 @@ class SP_Post_types {
'hierarchical' => true,
'rewrite' => array( 'slug' => get_option( 'sportspress_position_slug', 'position' ) ),
);
$object_types = array( 'sp_player', 'sp_performance', 'sp_metric', 'attachment' );
$object_types = array( 'sp_player', 'sp_performance', 'sp_metric' );
register_taxonomy( 'sp_position', $object_types, $args );
foreach ( $object_types as $object_type ):
register_taxonomy_for_object_type( 'sp_league', $object_type );
@@ -417,7 +417,7 @@ class SP_Post_types {
'exclude_from_search' => false,
'hierarchical' => true,
'rewrite' => array( 'slug' => get_option( 'sportspress_teams_slug', 'teams' ) ),
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes' ),
'supports' => array( 'title', 'author', 'thumbnail', 'page-attributes' ),
'has_archive' => true,
'show_in_nav_menus' => true,
'menu_icon' => 'dashicons-shield-alt',
@@ -478,7 +478,7 @@ class SP_Post_types {
'exclude_from_search' => false,
'hierarchical' => false,
'rewrite' => array( 'slug' => get_option( 'sportspress_players_slug', 'players' ) ),
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'page-attributes' ),
'supports' => array( 'title', 'author', 'thumbnail', 'excerpt', 'page-attributes' ),
'has_archive' => true,
'show_in_nav_menus' => true,
'menu_icon' => 'dashicons-groups',

View File

@@ -16,16 +16,16 @@ class SP_Shortcodes {
public static function init() {
// Define shortcodes
$shortcodes = array(
'event' => __CLASS__ . '::event',
'event_results' => __CLASS__ . '::event_results',
'event_details' => __CLASS__ . '::event_details',
'event_performance' => __CLASS__ . '::event_performance',
'countdown' => __CLASS__ . '::countdown',
'event_list' => __CLASS__ . '::event_list',
'event_calendar' => __CLASS__ . '::event_calendar',
// 'team' => __CLASS__ . '::team',
'league_table' => __CLASS__ . '::league_table',
// 'player' => __CLASS__ . '::player',
'player_metrics' => __CLASS__ . '::player_metrics',
'player_list' => __CLASS__ . '::player_list',
'player_gallery' => __CLASS__ . '::player_gallery',
// 'staff' => __CLASS__ . '::staff',
);
foreach ( $shortcodes as $shortcode => $function ) {
@@ -62,14 +62,36 @@ class SP_Shortcodes {
}
/**
* Event shortcode.
* Event results shortcode.
*
* @access public
* @param mixed $atts
* @return string
*/
public static function event( $atts ) {
return self::shortcode_wrapper( array( 'SP_Shortcode_Event', 'output' ), $atts );
public static function event_results( $atts ) {
return self::shortcode_wrapper( array( 'SP_Shortcode_Event_Results', 'output' ), $atts );
}
/**
* Event details shortcode.
*
* @access public
* @param mixed $atts
* @return string
*/
public static function event_details( $atts ) {
return self::shortcode_wrapper( array( 'SP_Shortcode_Event_Details', 'output' ), $atts );
}
/**
* Event performance shortcode.
*
* @access public
* @param mixed $atts
* @return string
*/
public static function event_performance( $atts ) {
return self::shortcode_wrapper( array( 'SP_Shortcode_Event_Performance', 'output' ), $atts );
}
/**
@@ -106,14 +128,14 @@ class SP_Shortcodes {
}
/**
* Team shortcode.
* Team columns shortcode.
*
* @access public
* @param mixed $atts
* @return string
*/
public static function team( $atts ) {
return self::shortcode_wrapper( array( 'SP_Shortcode_Team', 'output' ), $atts );
public static function team_columns( $atts ) {
return self::shortcode_wrapper( array( 'SP_Shortcode_Team_Columns', 'output' ), $atts );
}
/**
@@ -128,14 +150,14 @@ class SP_Shortcodes {
}
/**
* Player shortcode.
* Player performance shortcode.
*
* @access public
* @param mixed $atts
* @return string
*/
public static function player( $atts ) {
return self::shortcode_wrapper( array( 'SP_Shortcode_Player', 'output' ), $atts );
public static function player_performance( $atts ) {
return self::shortcode_wrapper( array( 'SP_Shortcode_Player_Performance', 'output' ), $atts );
}
/**

View File

@@ -1,16 +1,16 @@
<?php
/**
* Event Shortcode
* Event Details Shortcode
*
* @author ThemeBoy
* @category Shortcodes
* @package SportsPress/Shortcodes/Event
* @version 0.7
* @package SportsPress/Shortcodes/Event_Details
* @version 0.8
*/
class SP_Shortcode_Event {
class SP_Shortcode_Event_Details {
/**
* Output the event shortcode.
* Output the event details shortcode.
*
* @param array $atts
*/
@@ -19,6 +19,6 @@ class SP_Shortcode_Event {
if ( ! isset( $atts['id'] ) && isset( $atts[0] ) && is_numeric( $atts[0] ) )
$atts['id'] = $atts[0];
sp_get_template( 'event.php', $atts );
sp_get_template( 'event-details.php', $atts );
}
}

View File

@@ -0,0 +1,24 @@
<?php
/**
* Event Performance Shortcode
*
* @author ThemeBoy
* @category Shortcodes
* @package SportsPress/Shortcodes/Event_Performance
* @version 0.8
*/
class SP_Shortcode_Event_Performance {
/**
* Output the event performance 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( 'event-performance.php', $atts );
}
}

View File

@@ -0,0 +1,24 @@
<?php
/**
* Event Results Shortcode
*
* @author ThemeBoy
* @category Shortcodes
* @package SportsPress/Shortcodes/Event_Results
* @version 0.8
*/
class SP_Shortcode_Event_Results {
/**
* Output the event results 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( 'event-results.php', $atts );
}
}