Use template function and load as needed
This commit is contained in:
@@ -9,25 +9,31 @@ add_filter( 'get_the_content', 'sportspress_the_content' );
|
||||
|
||||
function sportspress_default_event_content( $content ) {
|
||||
if ( is_singular( 'sp_event' ) && in_the_loop() ):
|
||||
$details = sportspress_event_details();
|
||||
$results = sportspress_event_results();
|
||||
$performance = sportspress_event_performance();
|
||||
$staff = sportspress_event_staff();
|
||||
$id = get_the_ID();
|
||||
|
||||
// Video
|
||||
$video_url = get_post_meta( $id, 'sp_video', true );
|
||||
if ( $video_url ):
|
||||
global $wp_embed;
|
||||
$video = $wp_embed->autoembed( $video_url );
|
||||
else:
|
||||
$video = '';
|
||||
endif;
|
||||
if ( $results ):
|
||||
$content = $video . $results . $details . $performance . $staff . $content;
|
||||
else:
|
||||
$venue = sportspress_event_venue();
|
||||
$content = $video . $details . $venue . $performance . $staff . $content;
|
||||
echo $wp_embed->autoembed( $video_url );
|
||||
endif;
|
||||
|
||||
// Results
|
||||
sp_get_template( 'event-results.php' );
|
||||
|
||||
// Details
|
||||
sp_get_template( 'event-details.php' );
|
||||
|
||||
// Venue
|
||||
sp_get_template( 'event-venue.php' );
|
||||
|
||||
// Performance
|
||||
sp_get_template( 'event-performance.php' );
|
||||
|
||||
// Staff
|
||||
sp_get_template( 'event-staff.php' );
|
||||
endif;
|
||||
|
||||
return $content;
|
||||
}
|
||||
add_filter( 'the_content', 'sportspress_default_event_content', 7 );
|
||||
@@ -38,13 +44,17 @@ function sportspress_default_calendar_content( $content ) {
|
||||
$format = get_post_meta( $id, 'sp_format', true );
|
||||
switch ( $format ):
|
||||
case 'list':
|
||||
$calendar = sportspress_event_list( $id );
|
||||
sp_get_template( 'event-list.php', array(
|
||||
'id' => $id
|
||||
) );
|
||||
break;
|
||||
default:
|
||||
$calendar = sportspress_event_calendar( $id, false );
|
||||
sp_get_template( 'event-calendar.php', array(
|
||||
'id' => $id,
|
||||
'initial' => false
|
||||
) );
|
||||
break;
|
||||
endswitch;
|
||||
$content = $calendar . $content;
|
||||
endif;
|
||||
return $content;
|
||||
}
|
||||
@@ -52,8 +62,7 @@ add_filter( 'the_content', 'sportspress_default_calendar_content' );
|
||||
|
||||
function sportspress_default_team_content( $content ) {
|
||||
if ( is_singular( 'sp_team' ) && in_the_loop() ):
|
||||
$columns = sportspress_team_columns();
|
||||
$content = $content . $columns;
|
||||
sp_get_template( 'team-columns.php' );
|
||||
endif;
|
||||
return $content;
|
||||
}
|
||||
@@ -75,10 +84,11 @@ function sportspress_default_table_content( $content ) {
|
||||
endif;
|
||||
$title = '';
|
||||
if ( sizeof( $terms ) )
|
||||
$title = '<h4 class="sp-table-caption">' . implode( ' — ', $terms ) . '</h4>';
|
||||
$table = sportspress_league_table();
|
||||
echo '<h4 class="sp-table-caption">' . implode( ' — ', $terms ) . '</h4>';
|
||||
|
||||
sp_get_template( 'league-table.php' );
|
||||
$excerpt = has_excerpt() ? wpautop( get_the_excerpt() ) : '';
|
||||
$content = $title . $table . $content . $excerpt;
|
||||
$content = $content . $excerpt;
|
||||
endif;
|
||||
return $content;
|
||||
}
|
||||
@@ -86,9 +96,8 @@ add_filter( 'the_content', 'sportspress_default_table_content' );
|
||||
|
||||
function sportspress_default_player_content( $content ) {
|
||||
if ( is_singular( 'sp_player' ) && in_the_loop() ):
|
||||
$metrics = sportspress_player_metrics();
|
||||
$performance = sportspress_player_performance();
|
||||
$content .= $metrics . $performance;
|
||||
sp_get_template( 'player-metrics.php' );
|
||||
sp_get_template( 'player-performance.php' );
|
||||
endif;
|
||||
return $content;
|
||||
}
|
||||
@@ -100,13 +109,12 @@ function sportspress_default_list_content( $content ) {
|
||||
$format = get_post_meta( $id, 'sp_format', true );
|
||||
switch ( $format ):
|
||||
case 'gallery':
|
||||
$list = sportspress_player_gallery( $id );
|
||||
sp_get_template( 'player-gallery.php' );
|
||||
break;
|
||||
default:
|
||||
$list = sportspress_player_list( $id );
|
||||
sp_get_template( 'player-list.php' );
|
||||
break;
|
||||
endswitch;
|
||||
$content = $list . $content;
|
||||
endif;
|
||||
return $content;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
function sportspress_widget_text( $content ) {
|
||||
if ( ! preg_match( '/\[[\r\n\t ]*(countdown|league-table|event(s)-(calendar|list)|player-(list|gallery))?[\r\n\t ].*?\]/', $content ) )
|
||||
if ( ! preg_match( '/\[[\r\n\t ]*(countdown|league_table|event(s)_(calendar|list)|player_(list|gallery))?[\r\n\t ].*?\]/', $content ) )
|
||||
return $content;
|
||||
|
||||
$content = do_shortcode( $content );
|
||||
|
||||
@@ -62,7 +62,7 @@ function sportspress_calendar_shortcode_meta( $post ) {
|
||||
<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 $the_format; ?> <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
|
||||
<p><input type="text" value="[event_<?php echo $the_format; ?> <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ function sportspress_list_shortcode_meta( $post ) {
|
||||
<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="[player-<?php echo $the_format; ?> <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
|
||||
<p><input type="text" value="[player_<?php echo $the_format; ?> <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ function sportspress_table_shortcode_meta( $post ) {
|
||||
<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="[league-table <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
|
||||
<p><input type="text" value="[league_table <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
function sportspress_league_term_init() {
|
||||
$labels = array(
|
||||
'name' => __( 'Leagues', 'sportspress' ),
|
||||
'singular_name' => __( 'League', 'sportspress' ),
|
||||
'all_items' => __( 'All', 'sportspress' ),
|
||||
'edit_item' => __( 'Edit League', 'sportspress' ),
|
||||
'view_item' => __( 'View', 'sportspress' ),
|
||||
'update_item' => __( 'Update', 'sportspress' ),
|
||||
'add_new_item' => __( 'Add New', 'sportspress' ),
|
||||
'new_item_name' => __( 'Name', 'sportspress' ),
|
||||
'parent_item' => __( 'Parent', 'sportspress' ),
|
||||
'parent_item_colon' => __( 'Parent:', 'sportspress' ),
|
||||
'search_items' => __( 'Search', 'sportspress' ),
|
||||
'not_found' => __( 'No results found.', 'sportspress' ),
|
||||
);
|
||||
$args = array(
|
||||
'label' => __( 'Leagues', 'sportspress' ),
|
||||
'labels' => $labels,
|
||||
'public' => true,
|
||||
'show_in_nav_menus' => false,
|
||||
'show_tagcloud' => false,
|
||||
'hierarchical' => true,
|
||||
'rewrite' => array( 'slug' => get_option( 'sportspress_league_slug', 'league' ) ),
|
||||
);
|
||||
$object_types = array( 'sp_event', 'sp_calendar', 'sp_team', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' );
|
||||
register_taxonomy( 'sp_league', $object_types, $args );
|
||||
foreach ( $object_types as $object_type ):
|
||||
register_taxonomy_for_object_type( 'sp_league', $object_type );
|
||||
endforeach;
|
||||
}
|
||||
add_action( 'init', 'sportspress_league_term_init' );
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
function sportspress_position_term_init() {
|
||||
$labels = array(
|
||||
'name' => __( 'Positions', 'sportspress' ),
|
||||
'singular_name' => __( 'Position', 'sportspress' ),
|
||||
'all_items' => __( 'All', 'sportspress' ),
|
||||
'edit_item' => __( 'Edit Position', 'sportspress' ),
|
||||
'view_item' => __( 'View', 'sportspress' ),
|
||||
'update_item' => __( 'Update', 'sportspress' ),
|
||||
'add_new_item' => __( 'Add New', 'sportspress' ),
|
||||
'new_item_name' => __( 'Name', 'sportspress' ),
|
||||
'parent_item' => __( 'Parent', 'sportspress' ),
|
||||
'parent_item_colon' => __( 'Parent:', 'sportspress' ),
|
||||
'search_items' => __( 'Search', 'sportspress' ),
|
||||
'not_found' => __( 'No results found.', 'sportspress' ),
|
||||
);
|
||||
$args = array(
|
||||
'label' => __( 'Positions', 'sportspress' ),
|
||||
'labels' => $labels,
|
||||
'public' => true,
|
||||
'show_in_nav_menus' => false,
|
||||
'show_tagcloud' => false,
|
||||
'hierarchical' => true,
|
||||
'rewrite' => array( 'slug' => get_option( 'sportspress_position_slug', 'position' ) ),
|
||||
);
|
||||
$object_types = array( 'sp_player', 'sp_performance', 'sp_metric', 'attachment' );
|
||||
register_taxonomy( 'sp_position', $object_types, $args );
|
||||
foreach ( $object_types as $object_type ):
|
||||
register_taxonomy_for_object_type( 'sp_league', $object_type );
|
||||
endforeach;
|
||||
}
|
||||
add_action( 'init', 'sportspress_position_term_init' );
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
function sportspress_season_term_init() {
|
||||
$labels = array(
|
||||
'name' => __( 'Seasons', 'sportspress' ),
|
||||
'singular_name' => __( 'Season', 'sportspress' ),
|
||||
'all_items' => __( 'All', 'sportspress' ),
|
||||
'edit_item' => __( 'Edit Season', 'sportspress' ),
|
||||
'view_item' => __( 'View', 'sportspress' ),
|
||||
'update_item' => __( 'Update', 'sportspress' ),
|
||||
'add_new_item' => __( 'Add New', 'sportspress' ),
|
||||
'new_item_name' => __( 'Name', 'sportspress' ),
|
||||
'parent_item' => __( 'Parent', 'sportspress' ),
|
||||
'parent_item_colon' => __( 'Parent:', 'sportspress' ),
|
||||
'search_items' => __( 'Search', 'sportspress' ),
|
||||
'not_found' => __( 'No results found.', 'sportspress' ),
|
||||
);
|
||||
$args = array(
|
||||
'label' => __( 'Seasons', 'sportspress' ),
|
||||
'labels' => $labels,
|
||||
'public' => true,
|
||||
'show_in_nav_menus' => false,
|
||||
'show_tagcloud' => false,
|
||||
'hierarchical' => true,
|
||||
'rewrite' => array( 'slug' => get_option( 'sportspress_season_slug', 'season' ) ),
|
||||
);
|
||||
$object_types = array( 'sp_event', 'sp_calendar', 'sp_team', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' );
|
||||
register_taxonomy( 'sp_season', $object_types, $args );
|
||||
foreach ( $object_types as $object_type ):
|
||||
register_taxonomy_for_object_type( 'sp_league', $object_type );
|
||||
endforeach;
|
||||
}
|
||||
add_action( 'init', 'sportspress_season_term_init' );
|
||||
@@ -1,36 +1,4 @@
|
||||
<?php
|
||||
function sportspress_venue_term_init() {
|
||||
$labels = array(
|
||||
'name' => __( 'Venues', 'sportspress' ),
|
||||
'singular_name' => __( 'Venue', 'sportspress' ),
|
||||
'all_items' => __( 'All', 'sportspress' ),
|
||||
'edit_item' => __( 'Edit Venue', 'sportspress' ),
|
||||
'view_item' => __( 'View', 'sportspress' ),
|
||||
'update_item' => __( 'Update', 'sportspress' ),
|
||||
'add_new_item' => __( 'Add New', 'sportspress' ),
|
||||
'new_item_name' => __( 'Name', 'sportspress' ),
|
||||
'parent_item' => __( 'Parent', 'sportspress' ),
|
||||
'parent_item_colon' => __( 'Parent:', 'sportspress' ),
|
||||
'search_items' => __( 'Search', 'sportspress' ),
|
||||
'not_found' => __( 'No results found.', 'sportspress' ),
|
||||
);
|
||||
$args = array(
|
||||
'label' => __( 'Venues', 'sportspress' ),
|
||||
'labels' => $labels,
|
||||
'public' => true,
|
||||
'show_in_nav_menus' => false,
|
||||
'show_tagcloud' => false,
|
||||
'hierarchical' => true,
|
||||
'rewrite' => array( 'slug' => get_option( 'sportspress_venue_slug', 'venue' ) ),
|
||||
);
|
||||
$object_types = array( 'sp_event', 'sp_calendar', 'attachment' );
|
||||
register_taxonomy( 'sp_venue', $object_types, $args );
|
||||
foreach ( $object_types as $object_type ):
|
||||
register_taxonomy_for_object_type( 'sp_league', $object_type );
|
||||
endforeach;
|
||||
}
|
||||
add_action( 'init', 'sportspress_venue_term_init' );
|
||||
|
||||
function sportspress_venue_edit_form_fields( $term ) {
|
||||
$t_id = $term->term_id;
|
||||
$term_meta = get_option( "taxonomy_$t_id" ); ?>
|
||||
|
||||
@@ -56,6 +56,9 @@
|
||||
height: 320px;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
.sp-google-map img {
|
||||
max-width: none !important;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 40em) {
|
||||
.sp-responsive-table {
|
||||
|
||||
164
includes/class-sp-post-types.php
Normal file
164
includes/class-sp-post-types.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* Post types
|
||||
*
|
||||
* Registers post types and taxonomies
|
||||
*
|
||||
* @class SP_Post_types
|
||||
* @version 0.7
|
||||
* @package SportsPress/Classes/Products
|
||||
* @category Class
|
||||
* @author ThemeBoy
|
||||
*/
|
||||
class SP_Post_types {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'init', array( __CLASS__, 'register_taxonomies' ), 5 );
|
||||
add_action( 'init', array( __CLASS__, 'register_post_types' ), 5 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register SportsPress taxonomies.
|
||||
*/
|
||||
public static function register_taxonomies() {
|
||||
if ( taxonomy_exists( 'product_type' ) )
|
||||
return;
|
||||
|
||||
do_action( 'sportspress_register_taxonomy' );
|
||||
|
||||
$labels = array(
|
||||
'name' => __( 'Leagues', 'sportspress' ),
|
||||
'singular_name' => __( 'League', 'sportspress' ),
|
||||
'all_items' => __( 'All', 'sportspress' ),
|
||||
'edit_item' => __( 'Edit League', 'sportspress' ),
|
||||
'view_item' => __( 'View', 'sportspress' ),
|
||||
'update_item' => __( 'Update', 'sportspress' ),
|
||||
'add_new_item' => __( 'Add New', 'sportspress' ),
|
||||
'new_item_name' => __( 'Name', 'sportspress' ),
|
||||
'parent_item' => __( 'Parent', 'sportspress' ),
|
||||
'parent_item_colon' => __( 'Parent:', 'sportspress' ),
|
||||
'search_items' => __( 'Search', 'sportspress' ),
|
||||
'not_found' => __( 'No results found.', 'sportspress' ),
|
||||
);
|
||||
$args = array(
|
||||
'label' => __( 'Leagues', 'sportspress' ),
|
||||
'labels' => $labels,
|
||||
'public' => true,
|
||||
'show_in_nav_menus' => false,
|
||||
'show_tagcloud' => false,
|
||||
'hierarchical' => true,
|
||||
'rewrite' => array( 'slug' => get_option( 'sportspress_league_slug', 'league' ) ),
|
||||
);
|
||||
$object_types = array( 'sp_event', 'sp_calendar', 'sp_team', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' );
|
||||
register_taxonomy( 'sp_league', $object_types, $args );
|
||||
foreach ( $object_types as $object_type ):
|
||||
register_taxonomy_for_object_type( 'sp_league', $object_type );
|
||||
endforeach;
|
||||
|
||||
$labels = array(
|
||||
'name' => __( 'Seasons', 'sportspress' ),
|
||||
'singular_name' => __( 'Season', 'sportspress' ),
|
||||
'all_items' => __( 'All', 'sportspress' ),
|
||||
'edit_item' => __( 'Edit Season', 'sportspress' ),
|
||||
'view_item' => __( 'View', 'sportspress' ),
|
||||
'update_item' => __( 'Update', 'sportspress' ),
|
||||
'add_new_item' => __( 'Add New', 'sportspress' ),
|
||||
'new_item_name' => __( 'Name', 'sportspress' ),
|
||||
'parent_item' => __( 'Parent', 'sportspress' ),
|
||||
'parent_item_colon' => __( 'Parent:', 'sportspress' ),
|
||||
'search_items' => __( 'Search', 'sportspress' ),
|
||||
'not_found' => __( 'No results found.', 'sportspress' ),
|
||||
);
|
||||
$args = array(
|
||||
'label' => __( 'Seasons', 'sportspress' ),
|
||||
'labels' => $labels,
|
||||
'public' => true,
|
||||
'show_in_nav_menus' => false,
|
||||
'show_tagcloud' => false,
|
||||
'hierarchical' => true,
|
||||
'rewrite' => array( 'slug' => get_option( 'sportspress_season_slug', 'season' ) ),
|
||||
);
|
||||
$object_types = array( 'sp_event', 'sp_calendar', 'sp_team', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' );
|
||||
register_taxonomy( 'sp_season', $object_types, $args );
|
||||
foreach ( $object_types as $object_type ):
|
||||
register_taxonomy_for_object_type( 'sp_league', $object_type );
|
||||
endforeach;
|
||||
|
||||
$labels = array(
|
||||
'name' => __( 'Venues', 'sportspress' ),
|
||||
'singular_name' => __( 'Venue', 'sportspress' ),
|
||||
'all_items' => __( 'All', 'sportspress' ),
|
||||
'edit_item' => __( 'Edit Venue', 'sportspress' ),
|
||||
'view_item' => __( 'View', 'sportspress' ),
|
||||
'update_item' => __( 'Update', 'sportspress' ),
|
||||
'add_new_item' => __( 'Add New', 'sportspress' ),
|
||||
'new_item_name' => __( 'Name', 'sportspress' ),
|
||||
'parent_item' => __( 'Parent', 'sportspress' ),
|
||||
'parent_item_colon' => __( 'Parent:', 'sportspress' ),
|
||||
'search_items' => __( 'Search', 'sportspress' ),
|
||||
'not_found' => __( 'No results found.', 'sportspress' ),
|
||||
);
|
||||
$args = array(
|
||||
'label' => __( 'Venues', 'sportspress' ),
|
||||
'labels' => $labels,
|
||||
'public' => true,
|
||||
'show_in_nav_menus' => false,
|
||||
'show_tagcloud' => false,
|
||||
'hierarchical' => true,
|
||||
'rewrite' => array( 'slug' => get_option( 'sportspress_venue_slug', 'venue' ) ),
|
||||
);
|
||||
$object_types = array( 'sp_event', 'sp_calendar', 'attachment' );
|
||||
register_taxonomy( 'sp_venue', $object_types, $args );
|
||||
foreach ( $object_types as $object_type ):
|
||||
register_taxonomy_for_object_type( 'sp_league', $object_type );
|
||||
endforeach;
|
||||
|
||||
$labels = array(
|
||||
'name' => __( 'Positions', 'sportspress' ),
|
||||
'singular_name' => __( 'Position', 'sportspress' ),
|
||||
'all_items' => __( 'All', 'sportspress' ),
|
||||
'edit_item' => __( 'Edit Position', 'sportspress' ),
|
||||
'view_item' => __( 'View', 'sportspress' ),
|
||||
'update_item' => __( 'Update', 'sportspress' ),
|
||||
'add_new_item' => __( 'Add New', 'sportspress' ),
|
||||
'new_item_name' => __( 'Name', 'sportspress' ),
|
||||
'parent_item' => __( 'Parent', 'sportspress' ),
|
||||
'parent_item_colon' => __( 'Parent:', 'sportspress' ),
|
||||
'search_items' => __( 'Search', 'sportspress' ),
|
||||
'not_found' => __( 'No results found.', 'sportspress' ),
|
||||
);
|
||||
$args = array(
|
||||
'label' => __( 'Positions', 'sportspress' ),
|
||||
'labels' => $labels,
|
||||
'public' => true,
|
||||
'show_in_nav_menus' => false,
|
||||
'show_tagcloud' => false,
|
||||
'hierarchical' => true,
|
||||
'rewrite' => array( 'slug' => get_option( 'sportspress_position_slug', 'position' ) ),
|
||||
);
|
||||
$object_types = array( 'sp_player', 'sp_performance', 'sp_metric', 'attachment' );
|
||||
register_taxonomy( 'sp_position', $object_types, $args );
|
||||
foreach ( $object_types as $object_type ):
|
||||
register_taxonomy_for_object_type( 'sp_league', $object_type );
|
||||
endforeach;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register core post types
|
||||
*/
|
||||
public static function register_post_types() {
|
||||
|
||||
do_action( 'sportspress_register_post_type' );
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
new SP_Post_types();
|
||||
125
includes/class-sp-shortcodes.php
Normal file
125
includes/class-sp-shortcodes.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
* SP_Shortcodes class.
|
||||
*
|
||||
* @class SP_Shortcodes
|
||||
* @version 0.7
|
||||
* @package SportsPress/Classes
|
||||
* @category Class
|
||||
* @author ThemeBoy
|
||||
*/
|
||||
class SP_Shortcodes {
|
||||
|
||||
/**
|
||||
* Init shortcodes
|
||||
*/
|
||||
public static function init() {
|
||||
// Define shortcodes
|
||||
$shortcodes = array(
|
||||
'countdown' => __CLASS__ . '::countdown',
|
||||
'event_list' => __CLASS__ . '::event_list',
|
||||
'event_calendar' => __CLASS__ . '::event_calendar',
|
||||
'league_table' => __CLASS__ . '::league_table',
|
||||
'player_list' => __CLASS__ . '::player_list',
|
||||
'player_gallery' => __CLASS__ . '::player_gallery',
|
||||
);
|
||||
|
||||
foreach ( $shortcodes as $shortcode => $function ) {
|
||||
add_shortcode( $shortcode, $function );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcode Wrapper
|
||||
*
|
||||
* @param mixed $function
|
||||
* @param array $atts (default: array())
|
||||
* @return string
|
||||
*/
|
||||
public static function shortcode_wrapper(
|
||||
$function,
|
||||
$atts = array(),
|
||||
$wrapper = array(
|
||||
'class' => 'sportspress',
|
||||
'before' => null,
|
||||
'after' => null
|
||||
)
|
||||
) {
|
||||
ob_start();
|
||||
|
||||
$before = empty( $wrapper['before'] ) ? '<div class="' . esc_attr( $wrapper['class'] ) . '">' : $wrapper['before'];
|
||||
$after = empty( $wrapper['after'] ) ? '</div>' : $wrapper['after'];
|
||||
|
||||
echo $before;
|
||||
call_user_func( $function, $atts );
|
||||
echo $after;
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Countdown shortcode.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $atts
|
||||
* @return string
|
||||
*/
|
||||
public static function countdown( $atts ) {
|
||||
return self::shortcode_wrapper( array( 'SP_Shortcode_Countdown', 'output' ), $atts );
|
||||
}
|
||||
|
||||
/**
|
||||
* Event calendar shortcode.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $atts
|
||||
* @return string
|
||||
*/
|
||||
public static function event_calendar( $atts ) {
|
||||
return self::shortcode_wrapper( array( 'SP_Shortcode_Event_Calendar', 'output' ), $atts );
|
||||
}
|
||||
|
||||
/**
|
||||
* Event list shortcode.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $atts
|
||||
* @return string
|
||||
*/
|
||||
public static function event_list( $atts ) {
|
||||
return self::shortcode_wrapper( array( 'SP_Shortcode_Event_List', 'output' ), $atts );
|
||||
}
|
||||
|
||||
/**
|
||||
* League table shortcode.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $atts
|
||||
* @return string
|
||||
*/
|
||||
public static function league_table( $atts ) {
|
||||
return self::shortcode_wrapper( array( 'SP_Shortcode_League_Table', 'output' ), $atts );
|
||||
}
|
||||
|
||||
/**
|
||||
* Player list shortcode.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $atts
|
||||
* @return string
|
||||
*/
|
||||
public static function player_list( $atts ) {
|
||||
return self::shortcode_wrapper( array( 'SP_Shortcode_Player_List', 'output' ), $atts );
|
||||
}
|
||||
|
||||
/**
|
||||
* Player gallery shortcode.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $atts
|
||||
* @return string
|
||||
*/
|
||||
public static function player_gallery( $atts ) {
|
||||
return self::shortcode_wrapper( array( 'SP_Shortcode_Player_Gallery', 'output' ), $atts );
|
||||
}
|
||||
}
|
||||
24
includes/shortcodes/class-sp-shortcode-countdown.php
Normal file
24
includes/shortcodes/class-sp-shortcode-countdown.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Countdown Shortcode
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Shortcodes
|
||||
* @package SportsPress/Shortcodes/Countdown
|
||||
* @version 0.7
|
||||
*/
|
||||
class SP_Shortcode_Countdown {
|
||||
|
||||
/**
|
||||
* Output the countdown 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( 'countdown.php', $atts );
|
||||
}
|
||||
}
|
||||
24
includes/shortcodes/class-sp-shortcode-event-calendar.php
Normal file
24
includes/shortcodes/class-sp-shortcode-event-calendar.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Event Calendar Shortcode
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Shortcodes
|
||||
* @package SportsPress/Shortcodes/Event_Calendar
|
||||
* @version 0.7
|
||||
*/
|
||||
class SP_Shortcode_Event_Calendar {
|
||||
|
||||
/**
|
||||
* Output the event calendar 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-calendar.php', $atts );
|
||||
}
|
||||
}
|
||||
24
includes/shortcodes/class-sp-shortcode-event-list.php
Normal file
24
includes/shortcodes/class-sp-shortcode-event-list.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Event List Shortcode
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Shortcodes
|
||||
* @package SportsPress/Shortcodes/Event_List
|
||||
* @version 0.7
|
||||
*/
|
||||
class SP_Shortcode_Event_List {
|
||||
|
||||
/**
|
||||
* Output the event list 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-list.php', $atts );
|
||||
}
|
||||
}
|
||||
24
includes/shortcodes/class-sp-shortcode-league-table.php
Normal file
24
includes/shortcodes/class-sp-shortcode-league-table.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* League Table Shortcode
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Shortcodes
|
||||
* @package SportsPress/Shortcodes/League_Table
|
||||
* @version 0.7
|
||||
*/
|
||||
class SP_Shortcode_League_Table {
|
||||
|
||||
/**
|
||||
* Output the league table 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( 'league-table.php', $atts );
|
||||
}
|
||||
}
|
||||
24
includes/shortcodes/class-sp-shortcode-player-gallery.php
Normal file
24
includes/shortcodes/class-sp-shortcode-player-gallery.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Player Gallery Shortcode
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Shortcodes
|
||||
* @package SportsPress/Shortcodes/Player_Gallery
|
||||
* @version 0.7
|
||||
*/
|
||||
class SP_Shortcode_Player_Gallery {
|
||||
|
||||
/**
|
||||
* Output the player 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( 'player-gallery.php', $atts );
|
||||
}
|
||||
}
|
||||
24
includes/shortcodes/class-sp-shortcode-player-list.php
Normal file
24
includes/shortcodes/class-sp-shortcode-player-list.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Player List Shortcode
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Shortcodes
|
||||
* @package SportsPress/Shortcodes/Player_List
|
||||
* @version 0.7
|
||||
*/
|
||||
class SP_Shortcode_Player_List {
|
||||
|
||||
/**
|
||||
* Output the player list 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-list.php', $atts );
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* SportsPress Core Functions
|
||||
*
|
||||
* General core functions available on both the front-end and admin.
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Core
|
||||
* @package SportsPress/Functions
|
||||
* @version 0.7
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
/**
|
||||
* Get templates passing attributes and including the file.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $template_name
|
||||
* @param array $args (default: array())
|
||||
* @param string $template_path (default: '')
|
||||
* @param string $default_path (default: '')
|
||||
* @return void
|
||||
*/
|
||||
function sp_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
|
||||
if ( $args && is_array( $args ) ) {
|
||||
extract( $args );
|
||||
}
|
||||
|
||||
$located = sp_locate_template( $template_name, $template_path, $default_path );
|
||||
|
||||
if ( ! file_exists( $located ) ) {
|
||||
_doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '0.7' );
|
||||
return;
|
||||
}
|
||||
|
||||
do_action( 'sportspress_before_template_part', $template_name, $template_path, $located, $args );
|
||||
|
||||
include( $located );
|
||||
|
||||
do_action( 'sportspress_after_template_part', $template_name, $template_path, $located, $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate a template and return the path for inclusion.
|
||||
*
|
||||
* This is the load order:
|
||||
*
|
||||
* yourtheme / $template_path / $template_name
|
||||
* yourtheme / $template_name
|
||||
* $default_path / $template_name
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $template_name
|
||||
* @param string $template_path (default: '')
|
||||
* @param string $default_path (default: '')
|
||||
* @return string
|
||||
*/
|
||||
function sp_locate_template( $template_name, $template_path = '', $default_path = '' ) {
|
||||
if ( ! $template_path ) {
|
||||
$template_path = SP()->template_path();
|
||||
}
|
||||
|
||||
if ( ! $default_path ) {
|
||||
$default_path = SP()->plugin_path() . '/templates/';
|
||||
}
|
||||
|
||||
// Look within passed path within the theme - this is priority
|
||||
$template = locate_template(
|
||||
array(
|
||||
trailingslashit( $template_path ) . $template_name,
|
||||
$template_name
|
||||
)
|
||||
);
|
||||
|
||||
// Get default template
|
||||
if ( ! $template ) {
|
||||
$template = $default_path . $template_name;
|
||||
}
|
||||
|
||||
// Return what we found
|
||||
return apply_filters('sportspress_locate_template', $template, $template_name, $template_path);
|
||||
}
|
||||
|
||||
/* deprecated functions below */
|
||||
|
||||
if( !function_exists( 'date_diff' ) ) {
|
||||
class DateInterval {
|
||||
public $y;
|
||||
|
||||
@@ -15,227 +15,171 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
function sportspress_flush_rewrite_rules() {
|
||||
return sp_flush_rewrite_rules();
|
||||
}
|
||||
|
||||
function sportspress_nonce() {
|
||||
return sp_nonce();
|
||||
}
|
||||
|
||||
function sportspress_array_between( $array = array(), $delimiter = 0, $index = 0 ) {
|
||||
return sp_array_between( $array, $delimiter, $index );
|
||||
}
|
||||
|
||||
function sportspress_array_value( $arr = array(), $key = 0, $default = null ) {
|
||||
return sp_array_value( $arr, $key, $default );
|
||||
}
|
||||
|
||||
function sportspress_array_combine( $keys = array(), $values = array() ) {
|
||||
return sp_array_combine( $keys, $values );
|
||||
}
|
||||
|
||||
function sportspress_numbers_to_words( $str ) {
|
||||
return sp_numbers_to_words( $str );
|
||||
}
|
||||
|
||||
function sportspress_get_the_term_id( $post_id, $taxonomy, $index ) {
|
||||
return sp_get_the_term_id( $post_id, $taxonomy, $index );
|
||||
}
|
||||
|
||||
function sportspress_get_post_views( $post_id ) {
|
||||
return sp_get_post_views( $post_id );
|
||||
}
|
||||
|
||||
function sportspress_set_post_views( $post_id ) {
|
||||
return sp_set_post_views( $post_id );
|
||||
}
|
||||
|
||||
function sportspress_get_post_precision( $post_id ) {
|
||||
return sp_get_post_precision( $post_id );
|
||||
}
|
||||
|
||||
function sportspress_get_post_calculate( $post_id ) {
|
||||
return sp_get_post_calculate( $post_id );
|
||||
}
|
||||
|
||||
function sportspress_get_post_equation( $post_id ) {
|
||||
return sp_get_post_equation( $post_id );
|
||||
}
|
||||
|
||||
function sportspress_get_post_order( $post_id ) {
|
||||
return sp_get_post_order( $post_id );
|
||||
}
|
||||
|
||||
function sportspress_get_config_formats() {
|
||||
return sp_get_config_formats();
|
||||
}
|
||||
|
||||
function sportspress_dropdown_taxonomies( $args = array() ) {
|
||||
return sp_dropdown_taxonomies( $args );
|
||||
}
|
||||
|
||||
function sportspress_dropdown_pages( $args = array() ) {
|
||||
return sp_dropdown_pages( $args );
|
||||
}
|
||||
|
||||
function sportspress_posts( $post_id = null, $meta = 'post' ) {
|
||||
return sp_posts( $post_id, $meta );
|
||||
}
|
||||
|
||||
function sportspress_post_checklist( $post_id = null, $meta = 'post', $display = 'block', $filter = null, $index = null ) {
|
||||
return sp_post_checklist( $post_id, $meta, $display, $filter, $index );
|
||||
}
|
||||
|
||||
function sportspress_calculate_selector( $post_id, $selected = null ) {
|
||||
return sp_calculate_selector( $post_id, $selected);
|
||||
}
|
||||
|
||||
function sportspress_get_equation_optgroup_array( $post_id, $type = null, $variations = null, $defaults = null, $totals = true ) {
|
||||
return sp_get_equation_optgroup_array( $post_id, $type, $variations, $defaults, $totals );
|
||||
}
|
||||
|
||||
function sportspress_equation_selector( $post_id, $selected = null, $groups = array() ) {
|
||||
return sp_equation_selector( $post_id, $selected, $groups );
|
||||
}
|
||||
|
||||
function sportspress_get_term_names( $id = null, $post_type = null ) {
|
||||
return sp_get_term_names( $id, $post_type );
|
||||
}
|
||||
|
||||
function sportspress_get_var_labels( $post_type ) {
|
||||
return sp_get_var_labels( $post_type );
|
||||
}
|
||||
|
||||
function sportspress_get_var_equations( $post_type ) {
|
||||
return sp_get_var_equations( $post_type );
|
||||
}
|
||||
|
||||
function sportspress_get_var_calculates( $post_type ) {
|
||||
return sp_get_var_calculates( $post_type );
|
||||
}
|
||||
|
||||
function sportspress_edit_calendar_table( $data = array(), $usecolumns = null ) {
|
||||
return sp_edit_calendar_table( $data, $usecolumns );
|
||||
}
|
||||
|
||||
function sportspress_edit_league_table( $columns = array(), $usecolumns = null, $data = array(), $placeholders = array() ) {
|
||||
return sp_edit_league_table( $columns, $usecolumns, $data, $placeholders );
|
||||
}
|
||||
|
||||
function sportspress_edit_player_list_table( $columns = array(), $usecolumns = null, $data = array(), $placeholders = array() ) {
|
||||
return sp_edit_player_list_table( $columns, $usecolumns, $data, $placeholders );
|
||||
}
|
||||
|
||||
function sportspress_edit_team_columns_table( $league_id, $columns = array(), $data = array(), $placeholders = array(), $merged = array(), $seasons = array(), $readonly = true ) {
|
||||
return sp_edit_team_columns_table( $league_id, $columns, $data, $placeholders, $merged, $seasons, $readonly );
|
||||
}
|
||||
|
||||
function sportspress_edit_player_performance_table( $id = null, $league_id, $columns = array(), $data = array(), $placeholders = array(), $merged = array(), $seasons_teams = array(), $readonly = true ) {
|
||||
return sp_edit_player_performance_table( $id, $league_id, $columns, $data, $placeholders, $merged, $seasons_teams, $readonly );
|
||||
}
|
||||
|
||||
function sportspress_edit_event_results_table( $columns = array(), $data = array() ) {
|
||||
return sp_edit_event_results_table( $columns, $data );
|
||||
}
|
||||
|
||||
function sportspress_event_player_status_selector( $team_id, $player_id, $value = null ) {
|
||||
return sp_event_player_status_selector( $team_id, $player_id, $value );
|
||||
}
|
||||
|
||||
function sportspress_event_player_sub_selector( $team_id, $player_id, $value, $data = array() ) {
|
||||
return sp_event_player_sub_selector( $team_id, $player_id, $value, $data );
|
||||
}
|
||||
|
||||
function sportspress_edit_event_players_table( $columns = array(), $data = array(), $team_id ) {
|
||||
return sp_edit_event_players_table( $columns, $data, $team_id );
|
||||
}
|
||||
|
||||
function sportspress_player_nationality_selector( $value = null ) {
|
||||
return sp_player_nationality_selector( $value );
|
||||
}
|
||||
|
||||
function sportspress_post_adder( $post_type = 'post', $label = null ) {
|
||||
return sp_post_adder( $post_type, $label );
|
||||
}
|
||||
|
||||
function sportspress_taxonomy_adder( $taxonomy = 'category', $post_type = 'post', $label = null ) {
|
||||
return sp_taxonomy_adder( $taxonomy, $post_type, $label );
|
||||
}
|
||||
|
||||
function sportspress_update_post_meta( $post_id, $meta_key, $meta_value, $default = null ) {
|
||||
return sp_update_post_meta( $post_id, $meta_key, $meta_value, $default );
|
||||
}
|
||||
|
||||
function sportspress_update_post_meta_recursive( $post_id, $meta_key, $meta_value ) {
|
||||
return sp_update_post_meta_recursive( $post_id, $meta_key, $meta_value );
|
||||
}
|
||||
|
||||
function sportspress_render_option_field( $group, $name, $type = 'text' ) {
|
||||
return sp_render_option_field( $group, $name, $type );
|
||||
}
|
||||
|
||||
function sportspress_get_eos_safe_slug( $title, $post_id = 'var' ) {
|
||||
return sp_get_eos_safe_slug( $title, $post_id );
|
||||
}
|
||||
|
||||
function sportspress_solve( $equation, $vars, $precision = 0 ) {
|
||||
return sp_solve( $equation, $vars, $precision );
|
||||
}
|
||||
|
||||
function sportspress_event_players_lineup_filter( $arr ) {
|
||||
return sp_event_players_lineup_filter( $arr );
|
||||
}
|
||||
|
||||
function sportspress_event_players_sub_filter( $arr ) {
|
||||
return sp_event_players_sub_filter( $arr );
|
||||
}
|
||||
|
||||
function sportspress_get_calendar_data( $post_id = null, $admin = false ) {
|
||||
return sp_get_calendar_data( $post_id, $admin );
|
||||
}
|
||||
|
||||
function sportspress_get_team_columns_data( $post_id, $league_id, $admin = false ) {
|
||||
return sp_get_team_columns_data( $post_id, $league_id, $admin );
|
||||
}
|
||||
|
||||
function sportspress_get_league_table_data( $post_id, $breakdown = false ) {
|
||||
return sp_get_league_table_data( $post_id, $breakdown );
|
||||
}
|
||||
|
||||
function sportspress_sort_sports ( $a, $b ) {
|
||||
return sp_sort_sports( $a, $b );
|
||||
}
|
||||
|
||||
function sportspress_sort_table_teams ( $a, $b ) {
|
||||
return sp_sort_table_teams( $a, $b );
|
||||
}
|
||||
|
||||
function sportspress_get_player_list_data( $post_id, $admin = false ) {
|
||||
return sp_get_player_list_data( $post_id, $admin );
|
||||
}
|
||||
|
||||
function sportspress_get_player_roster_data( $post_id, $admin = false ) {
|
||||
return sp_get_player_roster_data( $post_id, $admin );
|
||||
}
|
||||
|
||||
function sportspress_sort_list_players ( $a, $b ) {
|
||||
return sp_sort_list_players( $a, $b );
|
||||
}
|
||||
|
||||
function sportspress_get_player_metrics_data( $post_id ) {
|
||||
return sp_get_player_metrics_data( $post_id );
|
||||
}
|
||||
|
||||
function sportspress_get_player_performance_data( $post_id, $league_id, $admin = false ) {
|
||||
return sp_get_player_performance_data( $post_id, $league_id, $admin );
|
||||
}
|
||||
|
||||
function sportspress_get_next_event( $args = array() ) {
|
||||
return sp_get_next_event( $args );
|
||||
}
|
||||
|
||||
function sportspress_delete_duplicate_post( &$post ) {
|
||||
return sp_delete_duplicate_post( &$post );
|
||||
}
|
||||
|
||||
function sportspress_highlight_admin_menu( $p = 'options-general.php', $s = 'sportspress' ) {
|
||||
return sp_highlight_admin_menu( $p, $s );
|
||||
}
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sportspress_countdown' ) ) {
|
||||
function sportspress_countdown( $id = null, $args = array() ) {
|
||||
|
||||
$show_league = sportspress_array_value( $args, 'show_league', null );
|
||||
|
||||
if ( $id ):
|
||||
$post = get_post( $id );
|
||||
else:
|
||||
$args = array();
|
||||
if ( isset( $args['team'] ) )
|
||||
$args = array( 'key' => 'sp_team', 'value' => $args['team'] );
|
||||
$post = sportspress_get_next_event( $args );
|
||||
endif;
|
||||
|
||||
$output = '';
|
||||
|
||||
if ( isset( $post ) ):
|
||||
$output .= '<div id="sp-countdown-wrapper">';
|
||||
$output .= '<h3 class="event-name"><a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a></h3>';
|
||||
|
||||
if ( $show_league ):
|
||||
$leagues = get_the_terms( $post->ID, 'sp_league' );
|
||||
if ( $leagues ):
|
||||
foreach( $leagues as $league ):
|
||||
$term = get_term( $league->term_id, 'sp_league' );
|
||||
$output .= '<h5 class="event-league">' . $term->name . '</h5>';
|
||||
endforeach;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
$now = new DateTime( current_time( 'mysql', 0 ) );
|
||||
$date = new DateTime( $post->post_date );
|
||||
$interval = date_diff( $now, $date );
|
||||
|
||||
$output .= '<p class="countdown sp-countdown"><time datetime="' . $post->post_date . '" data-countdown="' . str_replace( '-', '/', $post->post_date ) . '">' .
|
||||
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->days ) ) . ' <small>' . __( 'days', 'sportspress' ) . '</small></span> ' .
|
||||
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->h ) ) . ' <small>' . __( 'hrs', 'sportspress' ) . '</small></span> ' .
|
||||
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->i ) ) . ' <small>' . __( 'mins', 'sportspress' ) . '</small></span> ' .
|
||||
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->s ) ) . ' <small>' . __( 'secs', 'sportspress' ) . '</small></span>' .
|
||||
'</time></p>';
|
||||
|
||||
$output .= '</div>';
|
||||
else:
|
||||
return false;
|
||||
endif;
|
||||
|
||||
return apply_filters( 'sportspress_countdown', $output );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function sportspress_countdown_shortcode( $atts ) {
|
||||
if ( isset( $atts['id'] ) ):
|
||||
$id = $atts['id'];
|
||||
unset( $atts['id'] );
|
||||
elseif( isset( $atts[0] ) ):
|
||||
$id = $atts[0];
|
||||
unset( $atts[0] );
|
||||
else:
|
||||
$id = null;
|
||||
endif;
|
||||
return sportspress_countdown( $id, $atts );
|
||||
}
|
||||
add_shortcode('countdown', 'sportspress_countdown_shortcode');
|
||||
@@ -1,222 +0,0 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sportspress_event_calendar' ) ) {
|
||||
function sportspress_event_calendar( $id = null, $initial = true, $args = array() ) {
|
||||
|
||||
global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
|
||||
|
||||
// Quick check. If we have no posts at all, abort!
|
||||
if ( ! $posts )
|
||||
return;
|
||||
|
||||
$defaults = array(
|
||||
'caption_tag' => 'h4',
|
||||
'show_all_events_link' => false,
|
||||
);
|
||||
|
||||
$r = wp_parse_args( $args, $defaults );
|
||||
|
||||
if ( $id ):
|
||||
$events = sportspress_get_calendar_data( $id );
|
||||
$event_ids = array();
|
||||
foreach ( $events as $event ):
|
||||
$event_ids[] = $event->ID;
|
||||
endforeach;
|
||||
$in = 'AND ID IN (' . implode( ', ', $event_ids ) . ')';
|
||||
else:
|
||||
$in = '';
|
||||
endif;
|
||||
|
||||
$caption_tag = $r['caption_tag'];
|
||||
|
||||
// week_begins = 0 stands for Sunday
|
||||
$week_begins = intval(get_option('start_of_week'));
|
||||
|
||||
// Get year and month from query vars
|
||||
$year = isset( $_GET['sp_year'] ) ? $_GET['sp_year'] : $year;
|
||||
$monthnum = isset( $_GET['sp_month'] ) ? $_GET['sp_month'] : $monthnum;
|
||||
|
||||
// Let's figure out when we are
|
||||
if ( !empty($monthnum) && !empty($year) ) {
|
||||
$thismonth = ''.zeroise(intval($monthnum), 2);
|
||||
$thisyear = ''.intval($year);
|
||||
} elseif ( !empty($w) ) {
|
||||
// We need to get the month from MySQL
|
||||
$thisyear = ''.intval(substr($m, 0, 4));
|
||||
$d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
|
||||
$thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
|
||||
} elseif ( !empty($m) ) {
|
||||
$thisyear = ''.intval(substr($m, 0, 4));
|
||||
if ( strlen($m) < 6 )
|
||||
$thismonth = '01';
|
||||
else
|
||||
$thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
|
||||
} else {
|
||||
$thisyear = gmdate('Y', current_time('timestamp'));
|
||||
$thismonth = gmdate('m', current_time('timestamp'));
|
||||
}
|
||||
|
||||
$unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
|
||||
$last_day = date('t', $unixmonth);
|
||||
|
||||
// Get the next and previous month and year with at least one post
|
||||
$previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
|
||||
FROM $wpdb->posts
|
||||
WHERE post_date < '$thisyear-$thismonth-01'
|
||||
AND post_type = 'sp_event' AND ( post_status = 'publish' OR post_status = 'future' )
|
||||
$in
|
||||
ORDER BY post_date DESC
|
||||
LIMIT 1");
|
||||
$next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
|
||||
FROM $wpdb->posts
|
||||
WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
|
||||
AND post_type = 'sp_event' AND ( post_status = 'publish' OR post_status = 'future' )
|
||||
$in
|
||||
ORDER BY post_date ASC
|
||||
LIMIT 1");
|
||||
|
||||
/* translators: Calendar caption: 1: month name, 2: 4-digit year */
|
||||
$calendar_caption = _x('%1$s %2$s', 'calendar caption', 'sportspress');
|
||||
$calendar_output = '
|
||||
<div class="sp-calendar-wrapper">
|
||||
<table id="wp-calendar" class="sp-calendar sp-event-calendar">
|
||||
<' . $caption_tag . ' class="sp-table-caption">' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</' . $caption_tag . '>
|
||||
<thead>
|
||||
<tr>';
|
||||
|
||||
$myweek = array();
|
||||
|
||||
for ( $wdcount=0; $wdcount<=6; $wdcount++ ) {
|
||||
$myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
|
||||
}
|
||||
|
||||
foreach ( $myweek as $wd ) {
|
||||
$day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
|
||||
$wd = esc_attr($wd);
|
||||
$calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
|
||||
}
|
||||
|
||||
$calendar_output .= '
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tfoot>
|
||||
<tr>';
|
||||
|
||||
if ( $previous ) {
|
||||
$calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a data-tooltip data-options="disable_for_touch:true" class="has-tooltip tip-right" href="' . add_query_arg( array( 'sp_year' => $previous->year, 'sp_month' => $previous->month ) ) . '" title="' . esc_attr( sprintf(_x('%1$s %2$s', 'calendar caption', 'sportspress'), $wp_locale->get_month($previous->month), date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year)))) . '">« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>';
|
||||
} else {
|
||||
$calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>';
|
||||
}
|
||||
|
||||
$calendar_output .= "\n\t\t".'<td class="pad"> </td>';
|
||||
|
||||
if ( $next ) {
|
||||
$calendar_output .= "\n\t\t".'<td colspan="3" id="next"><a data-tooltip data-options="disable_for_touch:true" class="has-tooltip tip-left" href="' . add_query_arg( array( 'sp_year' => $next->year, 'sp_month' => $next->month ) ) . '" title="' . esc_attr( sprintf(_x('%1$s %2$s', 'calendar caption', 'sportspress'), $wp_locale->get_month($next->month), date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) ) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' »</a></td>';
|
||||
} else {
|
||||
$calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>';
|
||||
}
|
||||
|
||||
$calendar_output .= '
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<tbody>
|
||||
<tr>';
|
||||
|
||||
// Get days with posts
|
||||
$dayswithposts = $wpdb->get_results("SELECT DAYOFMONTH(post_date), ID
|
||||
FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
|
||||
AND post_type = 'sp_event' AND ( post_status = 'publish' OR post_status = 'future' )
|
||||
$in
|
||||
AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N);
|
||||
if ( $dayswithposts ) {
|
||||
foreach ( (array) $dayswithposts as $daywith ) {
|
||||
$daywithpost[ $daywith[0] ][] = $daywith[1];
|
||||
}
|
||||
} else {
|
||||
$daywithpost = array();
|
||||
}
|
||||
|
||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false)
|
||||
$ak_title_separator = "\n";
|
||||
else
|
||||
$ak_title_separator = ', ';
|
||||
|
||||
$ak_titles_for_day = array();
|
||||
$ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom "
|
||||
."FROM $wpdb->posts "
|
||||
."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' "
|
||||
."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' "
|
||||
."AND post_type = 'sp_event' AND ( post_status = 'publish' OR post_status = 'future' ) "
|
||||
."$in"
|
||||
);
|
||||
if ( $ak_post_titles ) {
|
||||
foreach ( (array) $ak_post_titles as $ak_post_title ) {
|
||||
|
||||
/** This filter is documented in wp-includes/post-template.php */
|
||||
$post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title, $ak_post_title->ID ) );
|
||||
|
||||
if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
|
||||
$ak_titles_for_day['day_'.$ak_post_title->dom] = '';
|
||||
if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
|
||||
$ak_titles_for_day["$ak_post_title->dom"] = $post_title;
|
||||
else
|
||||
$ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title;
|
||||
}
|
||||
}
|
||||
|
||||
// See how much we should pad in the beginning
|
||||
$pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
|
||||
if ( 0 != $pad )
|
||||
$calendar_output .= "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad"> </td>';
|
||||
|
||||
$daysinmonth = intval(date('t', $unixmonth));
|
||||
for ( $day = 1; $day <= $daysinmonth; ++$day ) {
|
||||
if ( isset($newrow) && $newrow )
|
||||
$calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
|
||||
$newrow = false;
|
||||
|
||||
if ( $day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp')) )
|
||||
$calendar_output .= '<td id="today">';
|
||||
else
|
||||
$calendar_output .= '<td>';
|
||||
|
||||
if ( array_key_exists($day, $daywithpost) ) // any posts today?
|
||||
$calendar_output .= '<a data-tooltip data-options="disable_for_touch:true" class="has-tip" href="' . ( sizeof( $daywithpost[ $day ] ) > 1 ? add_query_arg( array( 'post_type' => 'sp_event' ), get_day_link( $thisyear, $thismonth, $day ) ) . '" title="' . sprintf( '%s events', ( sizeof( $daywithpost[ $day ] ) ) ) : get_permalink( $daywithpost[ $day ][0] ) . '" title="' . esc_attr( $ak_titles_for_day[ $day ] ) ) . "\">$day</a>";
|
||||
else
|
||||
$calendar_output .= $day;
|
||||
$calendar_output .= '</td>';
|
||||
|
||||
if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) )
|
||||
$newrow = true;
|
||||
}
|
||||
|
||||
$pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
|
||||
if ( $pad != 0 && $pad != 7 )
|
||||
$calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'"> </td>';
|
||||
|
||||
$calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>\n\t</div>";
|
||||
|
||||
if ( $id && $r['show_all_events_link'] )
|
||||
$calendar_output .= '<a class="sp-calendar-link" href="' . get_permalink( $id ) . '">' . __( 'View all events', 'sportspress' ) . '</a>';
|
||||
|
||||
return apply_filters( 'sportspress_event_calendar', $calendar_output );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function sportspress_event_calendar_shortcode( $atts ) {
|
||||
if ( isset( $atts['id'] ) ):
|
||||
$id = $atts['id'];
|
||||
unset( $atts['id'] );
|
||||
elseif( isset( $atts[0] ) ):
|
||||
$id = $atts[0];
|
||||
unset( $atts[0] );
|
||||
else:
|
||||
$id = null;
|
||||
endif;
|
||||
$initial = isset( $atts['initial'] ) ? $atts['initial'] : true;
|
||||
return sportspress_event_calendar( $id, $initial, $atts );
|
||||
}
|
||||
add_shortcode('event-calendar', 'sportspress_event_calendar_shortcode');
|
||||
add_shortcode('events-calendar', 'sportspress_event_calendar_shortcode');
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sportspress_event_details' ) ) {
|
||||
function sportspress_event_details( $id = null ) {
|
||||
|
||||
if ( ! $id )
|
||||
$id = get_the_ID();
|
||||
|
||||
$date = get_the_time( get_option('date_format'), $id );
|
||||
$time = get_the_time( get_option('time_format'), $id );
|
||||
$leagues = get_the_terms( $id, 'sp_league' );
|
||||
$seasons = get_the_terms( $id, 'sp_season' );
|
||||
|
||||
$data = array( __( 'Date', 'sportspress' ) => $date, __( 'Time', 'sportspress' ) => $time );
|
||||
|
||||
if ( $leagues ):
|
||||
$league = array_pop( $leagues );
|
||||
$data[ __( 'League', 'sportspress' ) ] = $league->name;
|
||||
endif;
|
||||
|
||||
if ( $seasons ):
|
||||
$season = array_pop( $seasons );
|
||||
$data[ __( 'Season', 'sportspress' ) ] = $season->name;
|
||||
endif;
|
||||
|
||||
$output = '<h3>' . __( 'Details', 'sportspress' ) . '</h3>';
|
||||
|
||||
$output .= '<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-event-details sp-data-table"><tbody>';
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach( $data as $label => $value ):
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
$output .= '<th>' . $label . '</th>';
|
||||
$output .= '<td>' . $value . '</td>';
|
||||
$output .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody></table></div>';
|
||||
|
||||
return apply_filters( 'sportspress_event_details', $output );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sportspress_event_list' ) ) {
|
||||
function sportspress_event_list( $id = null, $args = '' ) {
|
||||
|
||||
global $sportspress_options;
|
||||
$main_result = sportspress_array_value( $sportspress_options, 'main_result', null );
|
||||
|
||||
$defaults = array(
|
||||
'show_all_events_link' => false,
|
||||
);
|
||||
|
||||
$r = wp_parse_args( $args, $defaults );
|
||||
|
||||
$output = '<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-event-list sp-data-table sp-responsive-table">' . '<thead>' . '<tr>';
|
||||
|
||||
list( $data, $usecolumns ) = sportspress_get_calendar_data( $id, true );
|
||||
|
||||
if ( isset( $r['columns'] ) )
|
||||
$usecolumns = $r['columns'];
|
||||
|
||||
$output .= '<th class="column-date">' . __( 'Date', 'sportspress' ). '</th>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'event', $usecolumns ) )
|
||||
$output .= '<th class="column-event">' . __( 'Event', 'sportspress' ). '</th>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'teams', $usecolumns ) )
|
||||
$output .= '<th class="column-teams">' . __( 'Teams', 'sportspress' ). '</th>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'time', $usecolumns ) )
|
||||
$output .= '<th class="column-time">' . __( 'Time', 'sportspress' ). '</th>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'article', $usecolumns ) )
|
||||
$output .= '<th class="column-article">' . __( 'Article', 'sportspress' ). '</th>';
|
||||
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
|
||||
$i = 0;
|
||||
foreach ( $data as $event ):
|
||||
$teams = get_post_meta( $event->ID, 'sp_team' );
|
||||
$results = get_post_meta( $event->ID, 'sp_results', true );
|
||||
$video = get_post_meta( $event->ID, 'sp_video', true );
|
||||
|
||||
$output .= '<tr class="sp-row sp-post' . ( $i % 2 == 0 ? ' alternate' : '' ) . '">';
|
||||
|
||||
$output .= '<td class="column-date">' . get_post_time( get_option( 'date_format' ), false, $event ) . '</td>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'event', $usecolumns ) )
|
||||
$output .= '<td class="column-event">' . $event->post_title . '</td>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'teams', $usecolumns ) ):
|
||||
$output .= '<td class="column-teams">';
|
||||
|
||||
$teams = get_post_meta( $event->ID, 'sp_team', false );
|
||||
if ( $teams ):
|
||||
foreach ( $teams as $team ):
|
||||
$name = get_the_title( $team );
|
||||
if ( $name ):
|
||||
$team_results = sportspress_array_value( $results, $team, null );
|
||||
|
||||
if ( $main_result ):
|
||||
$team_result = sportspress_array_value( $team_results, $main_result, null );
|
||||
else:
|
||||
if ( is_array( $team_results ) ):
|
||||
end( $team_results );
|
||||
$team_result = prev( $team_results );
|
||||
else:
|
||||
$team_result = null;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
$output .= $name;
|
||||
|
||||
if ( $team_result != null ):
|
||||
$output .= ' (' . $team_result . ')';
|
||||
endif;
|
||||
|
||||
$output .= '<br>';
|
||||
endif;
|
||||
endforeach;
|
||||
else:
|
||||
$output .= '—';
|
||||
endif;
|
||||
|
||||
$output .= '</td>';
|
||||
endif;
|
||||
|
||||
if ( $usecolumns == null || in_array( 'time', $usecolumns ) )
|
||||
$output .= '<td class="column-time">' . get_post_time( get_option( 'time_format' ), false, $event ) . '</td>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'article', $usecolumns ) ):
|
||||
$output .= '<td class="column-article">
|
||||
<a href="' . get_permalink( $event->ID ) . '#sp_articlediv">';
|
||||
|
||||
if ( $video ):
|
||||
$output .= '<div class="dashicons dashicons-video-alt"></div>';
|
||||
elseif ( has_post_thumbnail( $event->ID ) ):
|
||||
$output .= '<div class="dashicons dashicons-camera"></div>';
|
||||
endif;
|
||||
if ( $event->post_content !== null ):
|
||||
if ( $event->post_status == 'publish' ):
|
||||
$output .= __( 'Recap', 'sportspress' );
|
||||
else:
|
||||
$output .= __( 'Preview', 'sportspress' );
|
||||
endif;
|
||||
endif;
|
||||
|
||||
$output .= '</a>
|
||||
</td>';
|
||||
endif;
|
||||
|
||||
$output .= '</tr>';
|
||||
|
||||
$i++;
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody>' . '</table>';
|
||||
|
||||
if ( $id && $r['show_all_events_link'] )
|
||||
$output .= '<a class="sp-calendar-link" href="' . get_permalink( $id ) . '">' . __( 'View all events', 'sportspress' ) . '</a>';
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
return apply_filters( 'sportspress_event_list', $output );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function sportspress_event_list_shortcode( $atts ) {
|
||||
if ( isset( $atts['id'] ) ):
|
||||
$id = $atts['id'];
|
||||
unset( $atts['id'] );
|
||||
elseif( isset( $atts[0] ) ):
|
||||
$id = $atts[0];
|
||||
unset( $atts[0] );
|
||||
else:
|
||||
$id = null;
|
||||
endif;
|
||||
return sportspress_event_list( $id, $atts );
|
||||
}
|
||||
add_shortcode('event-list', 'sportspress_event_list_shortcode');
|
||||
add_shortcode('events-list', 'sportspress_event_list_shortcode');
|
||||
@@ -1,126 +0,0 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sportspress_event_performance' ) ) {
|
||||
function sportspress_event_performance( $id = null ) {
|
||||
global $sportspress_options;
|
||||
|
||||
if ( ! $id )
|
||||
$id = get_the_ID();
|
||||
|
||||
$teams = (array)get_post_meta( $id, 'sp_team', false );
|
||||
$staff = (array)get_post_meta( $id, 'sp_staff', false );
|
||||
$stats = (array)get_post_meta( $id, 'sp_players', true );
|
||||
$performance_labels = sportspress_get_var_labels( 'sp_performance' );
|
||||
$link_posts = sportspress_array_value( $sportspress_options, 'event_performance_link_posts', true );
|
||||
$sortable = sportspress_array_value( $sportspress_options, 'event_performance_sortable', true );
|
||||
$responsive = sportspress_array_value( $sportspress_options, 'event_performance_responsive', true );
|
||||
|
||||
$output = '';
|
||||
|
||||
foreach( $teams as $key => $team_id ):
|
||||
if ( ! $team_id ) continue;
|
||||
|
||||
$totals = array();
|
||||
|
||||
// Get results for players in the team
|
||||
$players = sportspress_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $key );
|
||||
$data = sportspress_array_combine( $players, sportspress_array_value( $stats, $team_id, array() ) );
|
||||
|
||||
$output .= '<h3>' . get_the_title( $team_id ) . '</h3>';
|
||||
|
||||
$output .= '<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-event-performance sp-data-table' . ( $responsive ? ' sp-responsive-table' : '' ) . ( $sortable ? ' sp-sortable-table' : '' ) . '">' . '<thead>' . '<tr>';
|
||||
|
||||
$output .= '<th class="data-number">#</th>';
|
||||
$output .= '<th class="data-number">' . __( 'Player', 'sportspress' ) . '</th>';
|
||||
|
||||
foreach( $performance_labels as $key => $label ):
|
||||
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach( $data as $player_id => $row ):
|
||||
|
||||
if ( ! $player_id )
|
||||
continue;
|
||||
|
||||
$name = get_the_title( $player_id );
|
||||
|
||||
if ( ! $name )
|
||||
continue;
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||
|
||||
// Player number
|
||||
$output .= '<td class="data-number">' . $number . '</td>';
|
||||
|
||||
if ( $link_posts ):
|
||||
$permalink = get_post_permalink( $player_id );
|
||||
$name = '<a href="' . $permalink . '">' . $name . '</a>';
|
||||
endif;
|
||||
|
||||
$output .= '<td class="data-name">' . $name . '</td>';
|
||||
|
||||
foreach( $performance_labels as $key => $label ):
|
||||
if ( $key == 'name' )
|
||||
continue;
|
||||
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
|
||||
$value = $row[ $key ];
|
||||
else:
|
||||
$value = 0;
|
||||
endif;
|
||||
if ( ! array_key_exists( $key, $totals ) ):
|
||||
$totals[ $key ] = 0;
|
||||
endif;
|
||||
$totals[ $key ] += $value;
|
||||
$output .= '<td class="data-' . $key . '">' . $value . '</td>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody>';
|
||||
|
||||
if ( array_key_exists( 0, $data ) ):
|
||||
|
||||
$output .= '<tfoot><tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||
|
||||
// Player number
|
||||
$output .= '<td class="data-number"> </td>';
|
||||
$output .= '<td class="data-name">' . __( 'Total', 'sportspress' ) . '</td>';
|
||||
|
||||
$row = $data[0];
|
||||
|
||||
foreach( $performance_labels as $key => $label ):
|
||||
if ( $key == 'name' ):
|
||||
continue;
|
||||
endif;
|
||||
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
|
||||
$value = $row[ $key ];
|
||||
else:
|
||||
$value = sportspress_array_value( $totals, $key, 0 );
|
||||
endif;
|
||||
$output .= '<td class="data-' . $key . '">' . $value . '</td>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr></tfoot>';
|
||||
|
||||
endif;
|
||||
|
||||
$output .= '</table>' . '</div>';
|
||||
|
||||
endforeach;
|
||||
|
||||
return apply_filters( 'sportspress_event_performance', $output );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sportspress_event_results' ) ) {
|
||||
function sportspress_event_results( $id = null ) {
|
||||
|
||||
if ( ! $id )
|
||||
$id = get_the_ID();
|
||||
|
||||
$teams = (array)get_post_meta( $id, 'sp_team', false );
|
||||
$results = array_filter( sportspress_array_combine( $teams, (array)get_post_meta( $id, 'sp_results', true ) ), 'array_filter' );
|
||||
$result_labels = sportspress_get_var_labels( 'sp_result' );
|
||||
|
||||
$output = '';
|
||||
|
||||
// Initialize and check
|
||||
$table_rows = '';
|
||||
|
||||
$i = 0;
|
||||
|
||||
if ( empty( $results ) )
|
||||
return false;
|
||||
|
||||
foreach( $results as $team_id => $result ):
|
||||
if ( sportspress_array_value( $result, 'outcome', '-1' ) != '-1' ):
|
||||
|
||||
unset( $result['outcome'] );
|
||||
|
||||
$table_rows .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
$table_rows .= '<td class="data-name">' . get_the_title( $team_id ) . '</td>';
|
||||
|
||||
foreach( $result_labels as $key => $label ):
|
||||
if ( $key == 'name' )
|
||||
continue;
|
||||
if ( array_key_exists( $key, $result ) && $result[ $key ] != '' ):
|
||||
$value = $result[ $key ];
|
||||
else:
|
||||
$value = '—';
|
||||
endif;
|
||||
$table_rows .= '<td class="data-' . $key . '">' . $value . '</td>';
|
||||
endforeach;
|
||||
|
||||
$table_rows .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
if ( empty( $table_rows ) ):
|
||||
|
||||
return false;
|
||||
|
||||
else:
|
||||
|
||||
$output .= '<h3>' . __( 'Results', 'sportspress' ) . '</h3>';
|
||||
|
||||
$output .= '<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-event-results sp-data-table sp-responsive-table"><thead>' .
|
||||
'<th class="data-name">' . __( 'Team', 'sportspress' ) . '</th>';
|
||||
foreach( $result_labels as $key => $label ):
|
||||
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||
endforeach;
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
$output .= $table_rows;
|
||||
$output .= '</tbody>' . '</table>' . '</div>';
|
||||
|
||||
endif;
|
||||
|
||||
return apply_filters( 'sportspress_event_results', $output );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sportspress_event_staff' ) ) {
|
||||
function sportspress_event_staff( $id = null ) {
|
||||
|
||||
if ( ! $id )
|
||||
$id = get_the_ID();
|
||||
$staff = (array)get_post_meta( $id, 'sp_staff', false );
|
||||
|
||||
$output = '';
|
||||
|
||||
return apply_filters( 'sportspress_event_staff', $output );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sportspress_event_venue' ) ) {
|
||||
function sportspress_event_venue( $id = null ) {
|
||||
|
||||
if ( ! $id )
|
||||
$id = get_the_ID();
|
||||
|
||||
$venues = get_the_terms( $id, 'sp_venue' );
|
||||
|
||||
$output = '';
|
||||
|
||||
if ( ! $venues )
|
||||
return $output;
|
||||
|
||||
foreach( $venues as $venue ):
|
||||
|
||||
$t_id = $venue->term_id;
|
||||
$term_meta = get_option( "taxonomy_$t_id" );
|
||||
|
||||
$address = sportspress_array_value( $term_meta, 'sp_address', '' );
|
||||
$latitude = sportspress_array_value( $term_meta, 'sp_latitude', 0 );
|
||||
$longitude = sportspress_array_value( $term_meta, 'sp_longitude', 0 );
|
||||
|
||||
$output .= '<h3>' . __( 'Venue', 'sportspress' ) . '</h3>';
|
||||
$output .= '<p><a href="' . get_term_link( $t_id, 'sp_venue' ) . '">' . $venue->name . '</a><br><small>' . $address . '</small></p>';
|
||||
if ( $latitude != null && $longitude != null )
|
||||
$output .= '<div class="sp-google-map" data-address="' . $address . '" data-latitude="' . $latitude . '" data-longitude="' . $longitude . '"></div>';
|
||||
|
||||
endforeach;
|
||||
|
||||
return apply_filters( 'sportspress_event_venue', $output );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sportspress_league_table' ) ) {
|
||||
function sportspress_league_table( $id = null, $args = '' ) {
|
||||
|
||||
if ( ! $id || ! is_numeric( $id ) )
|
||||
$id = get_the_ID();
|
||||
|
||||
global $sportspress_options;
|
||||
|
||||
$defaults = array(
|
||||
'number' => -1,
|
||||
'columns' => null,
|
||||
'show_full_table_link' => false,
|
||||
'show_team_logo' => sportspress_array_value( $sportspress_options, 'league_table_show_team_logo', false ),
|
||||
'link_posts' => sportspress_array_value( $sportspress_options, 'league_table_link_posts', false ),
|
||||
'sortable' => sportspress_array_value( $sportspress_options, 'league_table_sortable', true ),
|
||||
'responsive' => sportspress_array_value( $sportspress_options, 'league_table_responsive', true ),
|
||||
);
|
||||
|
||||
$r = wp_parse_args( $args, $defaults );
|
||||
|
||||
$output = '<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-league-table sp-data-table' . ( $r['responsive'] ? ' sp-responsive-table' : '' ) . ( $r['sortable'] ? ' sp-sortable-table' : '' ) . '">' . '<thead>' . '<tr>';
|
||||
|
||||
$data = sportspress_get_league_table_data( $id );
|
||||
|
||||
// The first row should be column labels
|
||||
$labels = $data[0];
|
||||
|
||||
// Remove the first row to leave us with the actual data
|
||||
unset( $data[0] );
|
||||
|
||||
$columns = sportspress_array_value( $r, 'columns', null );
|
||||
|
||||
if ( ! $columns )
|
||||
$columns = get_post_meta( $id, 'sp_columns', true );
|
||||
|
||||
if ( ! is_array( $columns ) )
|
||||
$columns = explode( ',', $columns );
|
||||
|
||||
$output .= '<th class="data-rank">' . __( 'Pos', 'sportspress' ) . '</th>';
|
||||
|
||||
foreach( $labels as $key => $label ):
|
||||
if ( ! is_array( $columns ) || $key == 'name' || in_array( $key, $columns ) )
|
||||
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
|
||||
$i = 0;
|
||||
|
||||
if ( is_int( $r['number'] ) && $r['number'] > 0 )
|
||||
$limit = $r['number'];
|
||||
|
||||
foreach( $data as $team_id => $row ):
|
||||
|
||||
if ( isset( $limit ) && $i >= $limit ) continue;
|
||||
|
||||
$name = sportspress_array_value( $row, 'name', null );
|
||||
if ( ! $name ) continue;
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
// Rank
|
||||
$output .= '<td class="data-rank">' . ( $i + 1 ) . '</td>';
|
||||
|
||||
if ( $r['show_team_logo'] )
|
||||
$name = get_the_post_thumbnail( $team_id, 'sportspress-fit-icon', array( 'class' => 'team-logo' ) ) . ' ' . $name;
|
||||
|
||||
if ( $r['link_posts'] ):
|
||||
$permalink = get_post_permalink( $team_id );
|
||||
$name = '<a href="' . $permalink . '">' . $name . '</a>';
|
||||
endif;
|
||||
|
||||
$output .= '<td class="data-name">' . $name . '</td>';
|
||||
|
||||
foreach( $labels as $key => $value ):
|
||||
if ( $key == 'name' )
|
||||
continue;
|
||||
if ( ! is_array( $columns ) || in_array( $key, $columns ) )
|
||||
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody>' . '</table>';
|
||||
|
||||
if ( $r['show_full_table_link'] )
|
||||
$output .= '<a class="sp-league-table-link" href="' . get_permalink( $id ) . '">' . __( 'View full table', 'sportspress' ) . '</a>';
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
return apply_filters( 'sportspress_league_table', $output, $id );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function sportspress_league_table_shortcode( $atts ) {
|
||||
if ( isset( $atts['id'] ) ):
|
||||
$id = $atts['id'];
|
||||
unset( $atts['id'] );
|
||||
elseif( isset( $atts[0] ) ):
|
||||
$id = $atts[0];
|
||||
unset( $atts[0] );
|
||||
else:
|
||||
$id = null;
|
||||
endif;
|
||||
return sportspress_league_table( $id, $atts );
|
||||
}
|
||||
add_shortcode('league-table', 'sportspress_league_table_shortcode');
|
||||
@@ -1,151 +0,0 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sportspress_player_gallery' ) ) {
|
||||
function sportspress_player_gallery( $id = null, $args = '' ) {
|
||||
|
||||
if ( ! $id )
|
||||
$id = get_the_ID();
|
||||
|
||||
global $sportspress_options;
|
||||
|
||||
$defaults = array(
|
||||
'number' => -1,
|
||||
'orderby' => 'default',
|
||||
'order' => 'ASC',
|
||||
'itemtag' => 'dl',
|
||||
'icontag' => 'dt',
|
||||
'captiontag' => 'dd',
|
||||
'columns' => 3,
|
||||
'size' => 'thumbnail',
|
||||
'show_all_players_link' => false,
|
||||
'show_names_on_hover' => sportspress_array_value( $sportspress_options, 'player_gallery_show_names_on_hover', true ),
|
||||
);
|
||||
|
||||
$r = wp_parse_args( $args, $defaults );
|
||||
|
||||
$itemtag = tag_escape( $r['itemtag'] );
|
||||
$captiontag = tag_escape( $r['captiontag'] );
|
||||
$icontag = tag_escape( $r['icontag'] );
|
||||
$valid_tags = wp_kses_allowed_html( 'post' );
|
||||
if ( ! isset( $valid_tags[ $itemtag ] ) )
|
||||
$itemtag = 'dl';
|
||||
if ( ! isset( $valid_tags[ $captiontag ] ) )
|
||||
$captiontag = 'dd';
|
||||
if ( ! isset( $valid_tags[ $icontag ] ) )
|
||||
$icontag = 'dt';
|
||||
|
||||
$columns = intval( $r['columns'] );
|
||||
$itemwidth = $columns > 0 ? floor(100/$columns) : 100;
|
||||
$size = $r[ 'size' ];
|
||||
$float = is_rtl() ? 'right' : 'left';
|
||||
|
||||
$selector = 'sp-player-gallery-' . $id;
|
||||
|
||||
$data = sportspress_get_player_list_data( $id );
|
||||
|
||||
// The first row should be column labels
|
||||
$labels = $data[0];
|
||||
|
||||
// Remove the first row to leave us with the actual data
|
||||
unset( $data[0] );
|
||||
|
||||
$performance = sportspress_array_value( $r, 'performance', null );
|
||||
|
||||
if ( $r['orderby'] == 'default' ):
|
||||
$r['orderby'] = get_post_meta( $id, 'sp_orderby', true );
|
||||
$r['order'] = get_post_meta( $id, 'sp_order', true );
|
||||
else:
|
||||
global $sportspress_performance_priorities;
|
||||
$sportspress_performance_priorities = array(
|
||||
array(
|
||||
'key' => $r['orderby'],
|
||||
'order' => $r['order'],
|
||||
),
|
||||
);
|
||||
uasort( $data, 'sportspress_sort_list_players' );
|
||||
endif;
|
||||
|
||||
$gallery_style = $gallery_div = '';
|
||||
if ( apply_filters( 'use_default_gallery_style', true ) )
|
||||
$gallery_style = "
|
||||
<style type='text/css'>
|
||||
#{$selector} {
|
||||
margin: auto;
|
||||
}
|
||||
#{$selector} .gallery-item {
|
||||
float: {$float};
|
||||
margin-top: 10px;
|
||||
text-align: center;
|
||||
width: {$itemwidth}%;
|
||||
}
|
||||
#{$selector} img {
|
||||
border: 2px solid #cfcfcf;
|
||||
}
|
||||
#{$selector} .gallery-caption {
|
||||
margin-left: 0;
|
||||
}
|
||||
/* see gallery_shortcode() in wp-includes/media.php */
|
||||
</style>";
|
||||
$size_class = sanitize_html_class( $size );
|
||||
$gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
|
||||
$output = apply_filters( 'gallery_style', $gallery_style . "\n\t\t" . $gallery_div );
|
||||
|
||||
$i = 0;
|
||||
|
||||
if ( is_int( $r['number'] ) && $r['number'] > 0 )
|
||||
$limit = $r['number'];
|
||||
|
||||
foreach( $data as $player_id => $performance ):
|
||||
|
||||
if ( $r['show_names_on_hover'] ):
|
||||
$caption = get_the_title( $player_id );
|
||||
else:
|
||||
$caption = null;
|
||||
endif;
|
||||
|
||||
$thumbnail = get_the_post_thumbnail( $player_id, $size );
|
||||
|
||||
if ( $thumbnail ):
|
||||
if ( isset( $limit ) && $i >= $limit ) continue;
|
||||
$output .= "<{$itemtag} class='gallery-item'>";
|
||||
$output .= "
|
||||
<{$icontag} class='gallery-icon portrait'>"
|
||||
. '<a href="' . get_permalink( $player_id ) . '">' . $thumbnail . '</a>'
|
||||
. "</{$icontag}>";
|
||||
if ( $captiontag && trim( $caption ) ) {
|
||||
$output .= '<a href="' . get_permalink( $player_id ) . '">' . "
|
||||
<{$captiontag} class='wp-caption-text gallery-caption'>
|
||||
" . wptexturize($caption) . "
|
||||
</{$captiontag}>" . '</a>';
|
||||
}
|
||||
$output .= "</{$itemtag}>";
|
||||
if ( $columns > 0 && ++$i % $columns == 0 )
|
||||
$output .= '<br style="clear: both" />';
|
||||
endif;
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= "
|
||||
<br style='clear: both;' />
|
||||
</div>\n";
|
||||
|
||||
if ( $r['show_all_players_link'] )
|
||||
$output .= '<a class="sp-player-list-link" href="' . get_permalink( $id ) . '">' . __( 'View all players', 'sportspress' ) . '</a>';
|
||||
|
||||
return apply_filters( 'sportspress_player_gallery', $output );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function sportspress_player_gallery_shortcode( $atts ) {
|
||||
if ( isset( $atts['id'] ) ):
|
||||
$id = $atts['id'];
|
||||
unset( $atts['id'] );
|
||||
elseif( isset( $atts[0] ) ):
|
||||
$id = $atts[0];
|
||||
unset( $atts[0] );
|
||||
else:
|
||||
$id = null;
|
||||
endif;
|
||||
return sportspress_player_gallery( $id, $atts );
|
||||
}
|
||||
add_shortcode('player-gallery', 'sportspress_player_gallery_shortcode');
|
||||
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sportspress_player_league_performance' ) ) {
|
||||
function sportspress_player_league_performance( $league, $id = null ) {
|
||||
|
||||
if ( ! $league )
|
||||
return false;
|
||||
|
||||
if ( ! $id )
|
||||
$id = get_the_ID();
|
||||
|
||||
$data = sportspress_get_player_performance_data( $id, $league->term_id );
|
||||
|
||||
// The first row should be column labels
|
||||
$labels = $data[0];
|
||||
|
||||
// Remove the first row to leave us with the actual data
|
||||
unset( $data[0] );
|
||||
|
||||
// Skip if there are no rows in the table
|
||||
if ( empty( $data ) )
|
||||
return false;
|
||||
|
||||
$output = '<h4 class="sp-table-caption">' . $league->name . '</h4>' .
|
||||
'<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-player-performance sp-data-table sp-responsive-table">' . '<thead>' . '<tr>';
|
||||
|
||||
foreach( $labels as $key => $label ):
|
||||
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach( $data as $season_id => $row ):
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
foreach( $labels as $key => $value ):
|
||||
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody>' . '</table>' . '</div>';
|
||||
|
||||
return apply_filters( 'sportspress_player_league_performance', $output );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sportspress_player_list' ) ) {
|
||||
function sportspress_player_list( $id = null, $args = '' ) {
|
||||
|
||||
if ( ! $id )
|
||||
$id = get_the_ID();
|
||||
|
||||
global $sportspress_options;
|
||||
|
||||
$defaults = array(
|
||||
'number' => -1,
|
||||
'performance' => null,
|
||||
'orderby' => 'default',
|
||||
'order' => 'ASC',
|
||||
'show_all_players_link' => false,
|
||||
'link_posts' => sportspress_array_value( $sportspress_options, 'player_list_link_posts', true ),
|
||||
'sortable' => sportspress_array_value( $sportspress_options, 'player_list_sortable', true ),
|
||||
'responsive' => sportspress_array_value( $sportspress_options, 'player_list_responsive', true ),
|
||||
);
|
||||
|
||||
$r = wp_parse_args( $args, $defaults );
|
||||
|
||||
$output = '<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-player-list sp-data-table' . ( $r['responsive'] ? ' sp-responsive-table' : '' ) . ( $r['sortable'] ? ' sp-sortable-table' : '' ) . '">' . '<thead>' . '<tr>';
|
||||
|
||||
$data = sportspress_get_player_list_data( $id );
|
||||
|
||||
// The first row should be column labels
|
||||
$labels = $data[0];
|
||||
|
||||
// Remove the first row to leave us with the actual data
|
||||
unset( $data[0] );
|
||||
|
||||
$performance = sportspress_array_value( $r, 'performance', null );
|
||||
|
||||
if ( $r['orderby'] == 'default' ):
|
||||
$r['orderby'] = get_post_meta( $id, 'sp_orderby', true );
|
||||
$r['order'] = get_post_meta( $id, 'sp_order', true );
|
||||
else:
|
||||
global $sportspress_performance_priorities;
|
||||
$sportspress_performance_priorities = array(
|
||||
array(
|
||||
'key' => $r['orderby'],
|
||||
'order' => $r['order'],
|
||||
),
|
||||
);
|
||||
uasort( $data, 'sportspress_sort_list_players' );
|
||||
endif;
|
||||
|
||||
if ( in_array( $r['orderby'], array( 'number', 'name' ) ) ):
|
||||
$output .= '<th class="data-number">#</th>';
|
||||
else:
|
||||
$output .= '<th class="data-rank">' . __( 'Rank', 'sportspress' ) . '</th>';
|
||||
endif;
|
||||
|
||||
foreach( $labels as $key => $label ):
|
||||
if ( ! is_array( $performance ) || $key == 'name' || in_array( $key, $performance ) )
|
||||
$output .= '<th class="data-' . $key . '">'. $label . '</th>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
|
||||
$i = 0;
|
||||
|
||||
if ( is_int( $r['number'] ) && $r['number'] > 0 )
|
||||
$limit = $r['number'];
|
||||
|
||||
foreach( $data as $player_id => $row ):
|
||||
if ( isset( $limit ) && $i >= $limit ) continue;
|
||||
|
||||
$name = sportspress_array_value( $row, 'name', null );
|
||||
if ( ! $name ) continue;
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
// Rank or number
|
||||
if ( isset( $r['orderby'] ) && $r['orderby'] != 'number' ):
|
||||
$output .= '<td class="data-rank">' . ( $i + 1 ) . '</td>';
|
||||
else:
|
||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||
$output .= '<td class="data-number">' . ( $number ? $number : ' ' ) . '</td>';
|
||||
endif;
|
||||
|
||||
if ( $r['link_posts'] ):
|
||||
$permalink = get_post_permalink( $player_id );
|
||||
$name = '<a href="' . $permalink . '">' . $name . '</a>';
|
||||
endif;
|
||||
|
||||
$output .= '<td class="data-name">' . $name . '</td>';
|
||||
|
||||
foreach( $labels as $key => $value ):
|
||||
if ( $key == 'name' )
|
||||
continue;
|
||||
if ( ! is_array( $performance ) || in_array( $key, $performance ) )
|
||||
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody>' . '</table>' . '</div>';
|
||||
|
||||
if ( $r['show_all_players_link'] )
|
||||
$output .= '<a class="sp-player-list-link" href="' . get_permalink( $id ) . '">' . __( 'View all players', 'sportspress' ) . '</a>';
|
||||
|
||||
return apply_filters( 'sportspress_player_list', $output );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function sportspress_player_list_shortcode( $atts ) {
|
||||
if ( isset( $atts['id'] ) ):
|
||||
$id = $atts['id'];
|
||||
unset( $atts['id'] );
|
||||
elseif( isset( $atts[0] ) ):
|
||||
$id = $atts[0];
|
||||
unset( $atts[0] );
|
||||
else:
|
||||
$id = null;
|
||||
endif;
|
||||
return sportspress_player_list( $id, $atts );
|
||||
}
|
||||
add_shortcode('player-list', 'sportspress_player_list_shortcode');
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sportspress_player_metrics' ) ) {
|
||||
function sportspress_player_metrics( $id = null, $args = '' ) {
|
||||
|
||||
if ( ! $id )
|
||||
$id = get_the_ID();
|
||||
|
||||
global $sportspress_countries;
|
||||
|
||||
global $sportspress_options;
|
||||
|
||||
$defaults = array(
|
||||
'show_nationality_flag' => sportspress_array_value( $sportspress_options, 'player_show_nationality_flag', true ),
|
||||
);
|
||||
|
||||
$r = wp_parse_args( $args, $defaults );
|
||||
|
||||
$nationality = get_post_meta( $id, 'sp_nationality', true );
|
||||
$current_team = get_post_meta( $id, 'sp_current_team', true );
|
||||
$past_teams = get_post_meta( $id, 'sp_past_team', false );
|
||||
$metrics = sportspress_get_player_metrics_data( $id );
|
||||
|
||||
$common = array();
|
||||
if ( $nationality ):
|
||||
$country_name = sportspress_array_value( $sportspress_countries, $nationality, null );
|
||||
$common[ __( 'Nationality', 'sportspress' ) ] = $country_name ? ( $r['show_nationality_flag'] ? '<img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . '/assets/images/flags/' . strtolower( $nationality ) . '.png" alt="' . $nationality . '"> ' : '' ) . $country_name : '—';
|
||||
endif;
|
||||
|
||||
$data = array_merge( $common, $metrics );
|
||||
|
||||
if ( $current_team )
|
||||
$data[ __( 'Current Team', 'sportspress' ) ] = '<a href="' . get_post_permalink( $current_team ) . '">' . get_the_title( $current_team ) . '</a>';
|
||||
|
||||
if ( $past_teams ):
|
||||
$teams = array();
|
||||
foreach ( $past_teams as $team ):
|
||||
$teams[] = '<a href="' . get_post_permalink( $team ) . '">' . get_the_title( $team ) . '</a>';
|
||||
endforeach;
|
||||
$data[ __( 'Past Teams', 'sportspress' ) ] = implode( ', ', $teams );
|
||||
endif;
|
||||
|
||||
$output = '<div class="sp-list-wrapper">' .
|
||||
'<dl class="sp-player-metrics">';
|
||||
|
||||
foreach( $data as $label => $value ):
|
||||
|
||||
$output .= '<dt>' . $label . '<dd>' . $value . '</dd>';
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= '</dl></div>';
|
||||
|
||||
return apply_filters( 'sportspress_player_metrics', $output );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sportspress_player_performance' ) ) {
|
||||
function sportspress_player_performance( $id = null ) {
|
||||
|
||||
if ( ! $id )
|
||||
$id = get_the_ID();
|
||||
|
||||
$leagues = get_the_terms( $id, 'sp_league' );
|
||||
|
||||
$output = '';
|
||||
|
||||
// Loop through performance for each league
|
||||
if ( is_array( $leagues ) ):
|
||||
foreach ( $leagues as $league ):
|
||||
$output .= sportspress_player_league_performance( $league, $id );
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
return apply_filters( 'sportspress_player_performance', $output );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sportspress_player_roster' ) ) {
|
||||
function sportspress_player_roster( $id = null, $args = '' ) {
|
||||
|
||||
if ( ! $id )
|
||||
$id = get_the_ID();
|
||||
|
||||
$defaults = array(
|
||||
'performance' => null,
|
||||
'orderby' => 'default',
|
||||
'order' => 'ASC',
|
||||
);
|
||||
|
||||
$r = wp_parse_args( $args, $defaults );
|
||||
|
||||
$output = '';
|
||||
|
||||
$data = sportspress_get_player_roster_data( $id );
|
||||
|
||||
// The first row should be column labels
|
||||
$labels = $data[0];
|
||||
|
||||
// Remove the first row to leave us with the actual data
|
||||
unset( $data[0] );
|
||||
|
||||
$performance = sportspress_array_value( $r, 'performance', null );
|
||||
|
||||
if ( $r['orderby'] == 'default' ):
|
||||
$r['orderby'] = get_post_meta( $id, 'sp_orderby', true );
|
||||
$r['order'] = get_post_meta( $id, 'sp_order', true );
|
||||
else:
|
||||
global $sportspress_performance_priorities;
|
||||
$sportspress_performance_priorities = array(
|
||||
array(
|
||||
'key' => $r['orderby'],
|
||||
'order' => $r['order'],
|
||||
),
|
||||
);
|
||||
uasort( $data, 'sportspress_sort_list_players' );
|
||||
endif;
|
||||
|
||||
$positions = get_terms ( 'sp_position' );
|
||||
|
||||
foreach ( $positions as $position ):
|
||||
$rows = '';
|
||||
$i = 0;
|
||||
|
||||
foreach ( $data as $player_id => $row ):
|
||||
|
||||
if ( ! in_array( $position->term_id, $row['positions']) )
|
||||
continue;
|
||||
|
||||
$rows .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
// Rank or number
|
||||
if ( isset( $r['orderby'] ) && $r['orderby'] != 'number' ):
|
||||
$rows .= '<td class="data-rank">' . ( $i + 1 ) . '</td>';
|
||||
else:
|
||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||
$rows .= '<td class="data-number">' . ( $number ? $number : ' ' ) . '</td>';
|
||||
endif;
|
||||
|
||||
// Name as link
|
||||
$permalink = get_post_permalink( $player_id );
|
||||
$name = sportspress_array_value( $row, 'name', sportspress_array_value( $row, 'name', ' ' ) );
|
||||
$rows .= '<td class="data-name">' . '<a href="' . $permalink . '">' . $name . '</a></td>';
|
||||
|
||||
foreach( $labels as $key => $value ):
|
||||
if ( $key == 'name' )
|
||||
continue;
|
||||
if ( ! is_array( $performance ) || in_array( $key, $performance ) )
|
||||
$rows .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||
endforeach;
|
||||
|
||||
$rows .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
if ( ! empty( $rows ) ):
|
||||
$output .= '<h4 class="sp-table-caption">' . $position->name . '</h4>';
|
||||
$output .= '<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-player-list sp-player-roster sp-data-table sp-responsive-table">' . '<thead>' . '<tr>';
|
||||
if ( in_array( $r['orderby'], array( 'number', 'name' ) ) ):
|
||||
$output .= '<th class="data-number">#</th>';
|
||||
else:
|
||||
$output .= '<th class="data-rank">' . __( 'Rank', 'sportspress' ) . '</th>';
|
||||
endif;
|
||||
|
||||
foreach( $labels as $key => $label ):
|
||||
if ( ! is_array( $performance ) || $key == 'name' || in_array( $key, $performance ) )
|
||||
$output .= '<th class="data-' . $key . '">'. $label . '</th>';
|
||||
endforeach;
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>' . $rows . '</tbody>' . '</table>' . '</div>';
|
||||
endif;
|
||||
|
||||
endforeach;
|
||||
|
||||
return apply_filters( 'sportspress_player_roster', $output );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sportspress_team_columns' ) ) {
|
||||
function sportspress_team_columns( $id = null ) {
|
||||
|
||||
if ( ! $id )
|
||||
$id = get_the_ID();
|
||||
|
||||
$leagues = get_the_terms( $id, 'sp_league' );
|
||||
|
||||
if ( ! $leagues )
|
||||
return false;
|
||||
|
||||
$output = '';
|
||||
|
||||
// Loop through data for each league
|
||||
foreach ( $leagues as $league ):
|
||||
|
||||
$data = sportspress_get_team_columns_data( $id, $league->term_id );
|
||||
|
||||
if ( sizeof( $data ) <= 1 )
|
||||
continue;
|
||||
|
||||
// The first row should be column labels
|
||||
$labels = $data[0];
|
||||
|
||||
// Remove the first row to leave us with the actual data
|
||||
unset( $data[0] );
|
||||
|
||||
$output .= '<h4 class="sp-table-caption">' . $league->name . '</h4>' .
|
||||
'<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-team-columns sp-data-table sp-responsive-table">' . '<thead>' . '<tr>';
|
||||
|
||||
foreach( $labels as $key => $label ):
|
||||
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach( $data as $season_id => $row ):
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
foreach( $labels as $key => $value ):
|
||||
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody>' . '</table>' . '</div>';
|
||||
|
||||
|
||||
endforeach;
|
||||
|
||||
return apply_filters( 'sportspress_team_columns', $output );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -82,6 +82,13 @@ final class SportsPress {
|
||||
* @return SportsPress
|
||||
*/
|
||||
public function __construct() {
|
||||
// Auto-load classes on demand
|
||||
if ( function_exists( "__autoload" ) ) {
|
||||
spl_autoload_register( "__autoload" );
|
||||
}
|
||||
|
||||
spl_autoload_register( array( $this, 'autoload' ) );
|
||||
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
@@ -91,12 +98,56 @@ final class SportsPress {
|
||||
// Hooks
|
||||
add_action( 'widgets_init', array( $this, 'include_widgets' ) );
|
||||
add_action( 'init', array( $this, 'init' ), 0 );
|
||||
add_action( 'init', array( 'SP_Shortcodes', 'init' ) );
|
||||
add_action( 'after_setup_theme', array( $this, 'setup_environment' ) );
|
||||
|
||||
// Loaded action
|
||||
do_action( 'sportspress_loaded' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto-load SP classes on demand to reduce memory consumption.
|
||||
*
|
||||
* @param mixed $class
|
||||
* @return void
|
||||
*/
|
||||
public function autoload( $class ) {
|
||||
|
||||
$class = strtolower( $class );
|
||||
|
||||
if ( strpos( $class, 'sp_shortcode_' ) === 0 ) {
|
||||
|
||||
$path = $this->plugin_path() . '/includes/shortcodes/';
|
||||
$file = 'class-' . str_replace( '_', '-', $class ) . '.php';
|
||||
|
||||
if ( is_readable( $path . $file ) ) {
|
||||
include_once( $path . $file );
|
||||
return;
|
||||
}
|
||||
|
||||
} elseif ( strpos( $class, 'sp_meta_box' ) === 0 ) {
|
||||
|
||||
$path = $this->plugin_path() . '/includes/admin/post-types/meta-boxes/';
|
||||
$file = 'class-' . str_replace( '_', '-', $class ) . '.php';
|
||||
|
||||
if ( is_readable( $path . $file ) ) {
|
||||
include_once( $path . $file );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( strpos( $class, 'sp_' ) === 0 ) {
|
||||
|
||||
$path = $this->plugin_path() . '/includes/';
|
||||
$file = 'class-' . str_replace( '_', '-', $class ) . '.php';
|
||||
|
||||
if ( is_readable( $path . $file ) ) {
|
||||
include_once( $path . $file );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Define SP Constants
|
||||
*/
|
||||
@@ -124,24 +175,6 @@ final class SportsPress {
|
||||
include_once( 'includes/sp-core-functions.php' );
|
||||
include_once( 'includes/sp-deprecated-functions.php' );
|
||||
|
||||
// Templates
|
||||
include_once( 'includes/templates/countdown.php' );
|
||||
include_once( 'includes/templates/event-details.php' );
|
||||
include_once( 'includes/templates/event-performance.php' );
|
||||
include_once( 'includes/templates/event-results.php' );
|
||||
include_once( 'includes/templates/event-staff.php' );
|
||||
include_once( 'includes/templates/event-venue.php' );
|
||||
include_once( 'includes/templates/event-calendar.php' );
|
||||
include_once( 'includes/templates/event-list.php' );
|
||||
include_once( 'includes/templates/league-table.php' );
|
||||
include_once( 'includes/templates/player-league-performance.php' );
|
||||
include_once( 'includes/templates/player-list.php' );
|
||||
//include_once( 'includes/templates/player-roster.php' );
|
||||
include_once( 'includes/templates/player-gallery.php' );
|
||||
include_once( 'includes/templates/player-metrics.php' );
|
||||
include_once( 'includes/templates/player-performance.php' );
|
||||
include_once( 'includes/templates/team-columns.php' );
|
||||
|
||||
// Options
|
||||
include_once( 'admin/settings/settings.php' );
|
||||
include_once( 'admin/settings/options-general.php' );
|
||||
@@ -168,11 +201,15 @@ final class SportsPress {
|
||||
include_once( 'admin/post-types/staff.php' );
|
||||
//include_once( 'admin/post-types/directory.php' );
|
||||
|
||||
if ( ! is_admin() ) {
|
||||
$this->frontend_includes();
|
||||
}
|
||||
|
||||
// Post types
|
||||
include_once( 'includes/class-sp-post-types.php' ); // Registers post types
|
||||
|
||||
// Terms
|
||||
include_once( 'admin/terms/league.php' );
|
||||
include_once( 'admin/terms/season.php' );
|
||||
include_once( 'admin/terms/venue.php' );
|
||||
include_once( 'admin/terms/position.php' );
|
||||
|
||||
// Tools
|
||||
include_once( 'admin/tools/importers.php' );
|
||||
@@ -218,6 +255,7 @@ final class SportsPress {
|
||||
* Include required frontend files.
|
||||
*/
|
||||
public function frontend_includes() {
|
||||
include_once( 'includes/class-sp-shortcodes.php' ); // Shortcodes class
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
43
templates/countdown.php
Normal file
43
templates/countdown.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
if ( isset( $id ) ):
|
||||
$post = get_post( $id );
|
||||
else:
|
||||
$args = array();
|
||||
if ( isset( $team ) )
|
||||
$args = array( 'key' => 'sp_team', 'value' => $team );
|
||||
$post = sportspress_get_next_event( $args );
|
||||
endif;
|
||||
|
||||
$output = '';
|
||||
|
||||
if ( isset( $post ) ):
|
||||
$output .= '<div id="sp-countdown-wrapper">';
|
||||
$output .= '<h3 class="event-name"><a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a></h3>';
|
||||
|
||||
if ( isset( $show_league ) && $show_league ):
|
||||
$leagues = get_the_terms( $post->ID, 'sp_league' );
|
||||
if ( $leagues ):
|
||||
foreach( $leagues as $league ):
|
||||
$term = get_term( $league->term_id, 'sp_league' );
|
||||
$output .= '<h5 class="event-league">' . $term->name . '</h5>';
|
||||
endforeach;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
$now = new DateTime( current_time( 'mysql', 0 ) );
|
||||
$date = new DateTime( $post->post_date );
|
||||
$interval = date_diff( $now, $date );
|
||||
|
||||
$output .= '<p class="countdown sp-countdown"><time datetime="' . $post->post_date . '" data-countdown="' . str_replace( '-', '/', $post->post_date ) . '">' .
|
||||
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->days ) ) . ' <small>' . __( 'days', 'sportspress' ) . '</small></span> ' .
|
||||
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->h ) ) . ' <small>' . __( 'hrs', 'sportspress' ) . '</small></span> ' .
|
||||
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->i ) ) . ' <small>' . __( 'mins', 'sportspress' ) . '</small></span> ' .
|
||||
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->s ) ) . ' <small>' . __( 'secs', 'sportspress' ) . '</small></span>' .
|
||||
'</time></p>';
|
||||
|
||||
$output .= '</div>';
|
||||
else:
|
||||
return false;
|
||||
endif;
|
||||
|
||||
echo apply_filters( 'sportspress_countdown', $output );
|
||||
200
templates/event-calendar.php
Normal file
200
templates/event-calendar.php
Normal file
@@ -0,0 +1,200 @@
|
||||
<?php
|
||||
global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
|
||||
|
||||
// Quick check. If we have no posts at all, abort!
|
||||
if ( ! $posts )
|
||||
return;
|
||||
|
||||
$defaults = array(
|
||||
'id' => null,
|
||||
'initial' => true,
|
||||
'caption_tag' => 'h4',
|
||||
'show_all_events_link' => false,
|
||||
);
|
||||
|
||||
extract( $defaults, EXTR_SKIP );
|
||||
|
||||
if ( isset( $id ) ):
|
||||
$events = sportspress_get_calendar_data( $id );
|
||||
$event_ids = array();
|
||||
foreach ( $events as $event ):
|
||||
$event_ids[] = $event->ID;
|
||||
endforeach;
|
||||
$in = 'AND ID IN (' . implode( ', ', $event_ids ) . ')';
|
||||
else:
|
||||
$in = '';
|
||||
endif;
|
||||
|
||||
// week_begins = 0 stands for Sunday
|
||||
$week_begins = intval(get_option('start_of_week'));
|
||||
|
||||
// Get year and month from query vars
|
||||
$year = isset( $_GET['sp_year'] ) ? $_GET['sp_year'] : $year;
|
||||
$monthnum = isset( $_GET['sp_month'] ) ? $_GET['sp_month'] : $monthnum;
|
||||
|
||||
// Let's figure out when we are
|
||||
if ( !empty($monthnum) && !empty($year) ) {
|
||||
$thismonth = ''.zeroise(intval($monthnum), 2);
|
||||
$thisyear = ''.intval($year);
|
||||
} elseif ( !empty($w) ) {
|
||||
// We need to get the month from MySQL
|
||||
$thisyear = ''.intval(substr($m, 0, 4));
|
||||
$d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
|
||||
$thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
|
||||
} elseif ( !empty($m) ) {
|
||||
$thisyear = ''.intval(substr($m, 0, 4));
|
||||
if ( strlen($m) < 6 )
|
||||
$thismonth = '01';
|
||||
else
|
||||
$thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
|
||||
} else {
|
||||
$thisyear = gmdate('Y', current_time('timestamp'));
|
||||
$thismonth = gmdate('m', current_time('timestamp'));
|
||||
}
|
||||
|
||||
$unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
|
||||
$last_day = date('t', $unixmonth);
|
||||
|
||||
// Get the next and previous month and year with at least one post
|
||||
$previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
|
||||
FROM $wpdb->posts
|
||||
WHERE post_date < '$thisyear-$thismonth-01'
|
||||
AND post_type = 'sp_event' AND ( post_status = 'publish' OR post_status = 'future' )
|
||||
$in
|
||||
ORDER BY post_date DESC
|
||||
LIMIT 1");
|
||||
$next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
|
||||
FROM $wpdb->posts
|
||||
WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
|
||||
AND post_type = 'sp_event' AND ( post_status = 'publish' OR post_status = 'future' )
|
||||
$in
|
||||
ORDER BY post_date ASC
|
||||
LIMIT 1");
|
||||
|
||||
/* translators: Calendar caption: 1: month name, 2: 4-digit year */
|
||||
$calendar_caption = _x('%1$s %2$s', 'calendar caption', 'sportspress');
|
||||
$calendar_output = '
|
||||
<div class="sp-calendar-wrapper">
|
||||
<table id="wp-calendar" class="sp-calendar sp-event-calendar">
|
||||
<' . $caption_tag . ' class="sp-table-caption">' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</' . $caption_tag . '>
|
||||
<thead>
|
||||
<tr>';
|
||||
|
||||
$myweek = array();
|
||||
|
||||
for ( $wdcount=0; $wdcount<=6; $wdcount++ ) {
|
||||
$myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
|
||||
}
|
||||
|
||||
foreach ( $myweek as $wd ) {
|
||||
$day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
|
||||
$wd = esc_attr($wd);
|
||||
$calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
|
||||
}
|
||||
|
||||
$calendar_output .= '
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tfoot>
|
||||
<tr>';
|
||||
|
||||
if ( $previous ) {
|
||||
$calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a data-tooltip data-options="disable_for_touch:true" class="has-tooltip tip-right" href="' . add_query_arg( array( 'sp_year' => $previous->year, 'sp_month' => $previous->month ) ) . '" title="' . esc_attr( sprintf(_x('%1$s %2$s', 'calendar caption', 'sportspress'), $wp_locale->get_month($previous->month), date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year)))) . '">« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>';
|
||||
} else {
|
||||
$calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>';
|
||||
}
|
||||
|
||||
$calendar_output .= "\n\t\t".'<td class="pad"> </td>';
|
||||
|
||||
if ( $next ) {
|
||||
$calendar_output .= "\n\t\t".'<td colspan="3" id="next"><a data-tooltip data-options="disable_for_touch:true" class="has-tooltip tip-left" href="' . add_query_arg( array( 'sp_year' => $next->year, 'sp_month' => $next->month ) ) . '" title="' . esc_attr( sprintf(_x('%1$s %2$s', 'calendar caption', 'sportspress'), $wp_locale->get_month($next->month), date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) ) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' »</a></td>';
|
||||
} else {
|
||||
$calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>';
|
||||
}
|
||||
|
||||
$calendar_output .= '
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<tbody>
|
||||
<tr>';
|
||||
|
||||
// Get days with posts
|
||||
$dayswithposts = $wpdb->get_results("SELECT DAYOFMONTH(post_date), ID
|
||||
FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
|
||||
AND post_type = 'sp_event' AND ( post_status = 'publish' OR post_status = 'future' )
|
||||
$in
|
||||
AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N);
|
||||
if ( $dayswithposts ) {
|
||||
foreach ( (array) $dayswithposts as $daywith ) {
|
||||
$daywithpost[ $daywith[0] ][] = $daywith[1];
|
||||
}
|
||||
} else {
|
||||
$daywithpost = array();
|
||||
}
|
||||
|
||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false)
|
||||
$ak_title_separator = "\n";
|
||||
else
|
||||
$ak_title_separator = ', ';
|
||||
|
||||
$ak_titles_for_day = array();
|
||||
$ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom "
|
||||
."FROM $wpdb->posts "
|
||||
."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' "
|
||||
."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' "
|
||||
."AND post_type = 'sp_event' AND ( post_status = 'publish' OR post_status = 'future' ) "
|
||||
."$in"
|
||||
);
|
||||
if ( $ak_post_titles ) {
|
||||
foreach ( (array) $ak_post_titles as $ak_post_title ) {
|
||||
|
||||
/** This filter is documented in wp-includes/post-template.php */
|
||||
$post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title, $ak_post_title->ID ) );
|
||||
|
||||
if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
|
||||
$ak_titles_for_day['day_'.$ak_post_title->dom] = '';
|
||||
if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
|
||||
$ak_titles_for_day["$ak_post_title->dom"] = $post_title;
|
||||
else
|
||||
$ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title;
|
||||
}
|
||||
}
|
||||
|
||||
// See how much we should pad in the beginning
|
||||
$pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
|
||||
if ( 0 != $pad )
|
||||
$calendar_output .= "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad"> </td>';
|
||||
|
||||
$daysinmonth = intval(date('t', $unixmonth));
|
||||
for ( $day = 1; $day <= $daysinmonth; ++$day ) {
|
||||
if ( isset($newrow) && $newrow )
|
||||
$calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
|
||||
$newrow = false;
|
||||
|
||||
if ( $day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp')) )
|
||||
$calendar_output .= '<td id="today">';
|
||||
else
|
||||
$calendar_output .= '<td>';
|
||||
|
||||
if ( array_key_exists($day, $daywithpost) ) // any posts today?
|
||||
$calendar_output .= '<a data-tooltip data-options="disable_for_touch:true" class="has-tip" href="' . ( sizeof( $daywithpost[ $day ] ) > 1 ? add_query_arg( array( 'post_type' => 'sp_event' ), get_day_link( $thisyear, $thismonth, $day ) ) . '" title="' . sprintf( '%s events', ( sizeof( $daywithpost[ $day ] ) ) ) : get_permalink( $daywithpost[ $day ][0] ) . '" title="' . esc_attr( $ak_titles_for_day[ $day ] ) ) . "\">$day</a>";
|
||||
else
|
||||
$calendar_output .= $day;
|
||||
$calendar_output .= '</td>';
|
||||
|
||||
if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) )
|
||||
$newrow = true;
|
||||
}
|
||||
|
||||
$pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
|
||||
if ( $pad != 0 && $pad != 7 )
|
||||
$calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'"> </td>';
|
||||
|
||||
$calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>\n\t</div>";
|
||||
|
||||
if ( $id && $show_all_events_link )
|
||||
$calendar_output .= '<a class="sp-calendar-link" href="' . get_permalink( $id ) . '">' . __( 'View all events', 'sportspress' ) . '</a>';
|
||||
|
||||
echo apply_filters( 'sportspress_event_calendar', $calendar_output );
|
||||
42
templates/event-details.php
Normal file
42
templates/event-details.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
if ( ! isset( $id ) )
|
||||
$id = get_the_ID();
|
||||
|
||||
$date = get_the_time( get_option('date_format'), $id );
|
||||
$time = get_the_time( get_option('time_format'), $id );
|
||||
$leagues = get_the_terms( $id, 'sp_league' );
|
||||
$seasons = get_the_terms( $id, 'sp_season' );
|
||||
|
||||
$data = array( __( 'Date', 'sportspress' ) => $date, __( 'Time', 'sportspress' ) => $time );
|
||||
|
||||
if ( $leagues ):
|
||||
$league = array_pop( $leagues );
|
||||
$data[ __( 'League', 'sportspress' ) ] = $league->name;
|
||||
endif;
|
||||
|
||||
if ( $seasons ):
|
||||
$season = array_pop( $seasons );
|
||||
$data[ __( 'Season', 'sportspress' ) ] = $season->name;
|
||||
endif;
|
||||
|
||||
$output = '<h3>' . __( 'Details', 'sportspress' ) . '</h3>';
|
||||
|
||||
$output .= '<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-event-details sp-data-table"><tbody>';
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach( $data as $label => $value ):
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
$output .= '<th>' . $label . '</th>';
|
||||
$output .= '<td>' . $value . '</td>';
|
||||
$output .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody></table></div>';
|
||||
|
||||
echo apply_filters( 'sportspress_event_details', $output );
|
||||
121
templates/event-list.php
Normal file
121
templates/event-list.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
global $sportspress_options;
|
||||
$main_result = sportspress_array_value( $sportspress_options, 'main_result', null );
|
||||
|
||||
$defaults = array(
|
||||
'show_all_events_link' => false,
|
||||
);
|
||||
|
||||
extract( $defaults, EXTR_SKIP );
|
||||
|
||||
$output = '<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-event-list sp-data-table sp-responsive-table">' . '<thead>' . '<tr>';
|
||||
|
||||
list( $data, $usecolumns ) = sportspress_get_calendar_data( $id, true );
|
||||
|
||||
if ( isset( $columns ) )
|
||||
$usecolumns = $columns;
|
||||
|
||||
$output .= '<th class="column-date">' . __( 'Date', 'sportspress' ). '</th>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'event', $usecolumns ) )
|
||||
$output .= '<th class="column-event">' . __( 'Event', 'sportspress' ). '</th>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'teams', $usecolumns ) )
|
||||
$output .= '<th class="column-teams">' . __( 'Teams', 'sportspress' ). '</th>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'time', $usecolumns ) )
|
||||
$output .= '<th class="column-time">' . __( 'Time', 'sportspress' ). '</th>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'article', $usecolumns ) )
|
||||
$output .= '<th class="column-article">' . __( 'Article', 'sportspress' ). '</th>';
|
||||
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
|
||||
$i = 0;
|
||||
foreach ( $data as $event ):
|
||||
$teams = get_post_meta( $event->ID, 'sp_team' );
|
||||
$results = get_post_meta( $event->ID, 'sp_results', true );
|
||||
$video = get_post_meta( $event->ID, 'sp_video', true );
|
||||
|
||||
$output .= '<tr class="sp-row sp-post' . ( $i % 2 == 0 ? ' alternate' : '' ) . '">';
|
||||
|
||||
$output .= '<td class="column-date">' . get_post_time( get_option( 'date_format' ), false, $event ) . '</td>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'event', $usecolumns ) )
|
||||
$output .= '<td class="column-event">' . $event->post_title . '</td>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'teams', $usecolumns ) ):
|
||||
$output .= '<td class="column-teams">';
|
||||
|
||||
$teams = get_post_meta( $event->ID, 'sp_team', false );
|
||||
if ( $teams ):
|
||||
foreach ( $teams as $team ):
|
||||
$name = get_the_title( $team );
|
||||
if ( $name ):
|
||||
$team_results = sportspress_array_value( $results, $team, null );
|
||||
|
||||
if ( $main_result ):
|
||||
$team_result = sportspress_array_value( $team_results, $main_result, null );
|
||||
else:
|
||||
if ( is_array( $team_results ) ):
|
||||
end( $team_results );
|
||||
$team_result = prev( $team_results );
|
||||
else:
|
||||
$team_result = null;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
$output .= $name;
|
||||
|
||||
if ( $team_result != null ):
|
||||
$output .= ' (' . $team_result . ')';
|
||||
endif;
|
||||
|
||||
$output .= '<br>';
|
||||
endif;
|
||||
endforeach;
|
||||
else:
|
||||
$output .= '—';
|
||||
endif;
|
||||
|
||||
$output .= '</td>';
|
||||
endif;
|
||||
|
||||
if ( $usecolumns == null || in_array( 'time', $usecolumns ) )
|
||||
$output .= '<td class="column-time">' . get_post_time( get_option( 'time_format' ), false, $event ) . '</td>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'article', $usecolumns ) ):
|
||||
$output .= '<td class="column-article">
|
||||
<a href="' . get_permalink( $event->ID ) . '#sp_articlediv">';
|
||||
|
||||
if ( $video ):
|
||||
$output .= '<div class="dashicons dashicons-video-alt"></div>';
|
||||
elseif ( has_post_thumbnail( $event->ID ) ):
|
||||
$output .= '<div class="dashicons dashicons-camera"></div>';
|
||||
endif;
|
||||
if ( $event->post_content !== null ):
|
||||
if ( $event->post_status == 'publish' ):
|
||||
$output .= __( 'Recap', 'sportspress' );
|
||||
else:
|
||||
$output .= __( 'Preview', 'sportspress' );
|
||||
endif;
|
||||
endif;
|
||||
|
||||
$output .= '</a>
|
||||
</td>';
|
||||
endif;
|
||||
|
||||
$output .= '</tr>';
|
||||
|
||||
$i++;
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody>' . '</table>';
|
||||
|
||||
if ( $id && $show_all_events_link )
|
||||
$output .= '<a class="sp-calendar-link" href="' . get_permalink( $id ) . '">' . __( 'View all events', 'sportspress' ) . '</a>';
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
echo apply_filters( 'sportspress_event_list', $output );
|
||||
121
templates/event-performance.php
Normal file
121
templates/event-performance.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
global $sportspress_options;
|
||||
|
||||
if ( ! isset( $id ) )
|
||||
$id = get_the_ID();
|
||||
|
||||
$teams = (array)get_post_meta( $id, 'sp_team', false );
|
||||
$staff = (array)get_post_meta( $id, 'sp_staff', false );
|
||||
$stats = (array)get_post_meta( $id, 'sp_players', true );
|
||||
$performance_labels = sportspress_get_var_labels( 'sp_performance' );
|
||||
$link_posts = sportspress_array_value( $sportspress_options, 'event_performance_link_posts', true );
|
||||
$sortable = sportspress_array_value( $sportspress_options, 'event_performance_sortable', true );
|
||||
$responsive = sportspress_array_value( $sportspress_options, 'event_performance_responsive', true );
|
||||
|
||||
$output = '';
|
||||
|
||||
foreach( $teams as $key => $team_id ):
|
||||
if ( ! $team_id ) continue;
|
||||
|
||||
$totals = array();
|
||||
|
||||
// Get results for players in the team
|
||||
$players = sportspress_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $key );
|
||||
$data = sportspress_array_combine( $players, sportspress_array_value( $stats, $team_id, array() ) );
|
||||
|
||||
$output .= '<h3>' . get_the_title( $team_id ) . '</h3>';
|
||||
|
||||
$output .= '<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-event-performance sp-data-table' . ( $responsive ? ' sp-responsive-table' : '' ) . ( $sortable ? ' sp-sortable-table' : '' ) . '">' . '<thead>' . '<tr>';
|
||||
|
||||
$output .= '<th class="data-number">#</th>';
|
||||
$output .= '<th class="data-number">' . __( 'Player', 'sportspress' ) . '</th>';
|
||||
|
||||
foreach( $performance_labels as $key => $label ):
|
||||
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach( $data as $player_id => $row ):
|
||||
|
||||
if ( ! $player_id )
|
||||
continue;
|
||||
|
||||
$name = get_the_title( $player_id );
|
||||
|
||||
if ( ! $name )
|
||||
continue;
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||
|
||||
// Player number
|
||||
$output .= '<td class="data-number">' . $number . '</td>';
|
||||
|
||||
if ( $link_posts ):
|
||||
$permalink = get_post_permalink( $player_id );
|
||||
$name = '<a href="' . $permalink . '">' . $name . '</a>';
|
||||
endif;
|
||||
|
||||
$output .= '<td class="data-name">' . $name . '</td>';
|
||||
|
||||
foreach( $performance_labels as $key => $label ):
|
||||
if ( $key == 'name' )
|
||||
continue;
|
||||
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
|
||||
$value = $row[ $key ];
|
||||
else:
|
||||
$value = 0;
|
||||
endif;
|
||||
if ( ! array_key_exists( $key, $totals ) ):
|
||||
$totals[ $key ] = 0;
|
||||
endif;
|
||||
$totals[ $key ] += $value;
|
||||
$output .= '<td class="data-' . $key . '">' . $value . '</td>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody>';
|
||||
|
||||
if ( array_key_exists( 0, $data ) ):
|
||||
|
||||
$output .= '<tfoot><tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||
|
||||
// Player number
|
||||
$output .= '<td class="data-number"> </td>';
|
||||
$output .= '<td class="data-name">' . __( 'Total', 'sportspress' ) . '</td>';
|
||||
|
||||
$row = $data[0];
|
||||
|
||||
foreach( $performance_labels as $key => $label ):
|
||||
if ( $key == 'name' ):
|
||||
continue;
|
||||
endif;
|
||||
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
|
||||
$value = $row[ $key ];
|
||||
else:
|
||||
$value = sportspress_array_value( $totals, $key, 0 );
|
||||
endif;
|
||||
$output .= '<td class="data-' . $key . '">' . $value . '</td>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr></tfoot>';
|
||||
|
||||
endif;
|
||||
|
||||
$output .= '</table>' . '</div>';
|
||||
|
||||
endforeach;
|
||||
|
||||
echo apply_filters( 'sportspress_event_performance', $output );
|
||||
66
templates/event-results.php
Normal file
66
templates/event-results.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
if ( ! isset( $id ) )
|
||||
$id = get_the_ID();
|
||||
|
||||
$teams = (array)get_post_meta( $id, 'sp_team', false );
|
||||
$results = array_filter( sportspress_array_combine( $teams, (array)get_post_meta( $id, 'sp_results', true ) ), 'array_filter' );
|
||||
$result_labels = sportspress_get_var_labels( 'sp_result' );
|
||||
|
||||
$output = '';
|
||||
|
||||
// Initialize and check
|
||||
$table_rows = '';
|
||||
|
||||
$i = 0;
|
||||
|
||||
if ( empty( $results ) )
|
||||
return false;
|
||||
|
||||
foreach( $results as $team_id => $result ):
|
||||
if ( sportspress_array_value( $result, 'outcome', '-1' ) != '-1' ):
|
||||
|
||||
unset( $result['outcome'] );
|
||||
|
||||
$table_rows .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
$table_rows .= '<td class="data-name">' . get_the_title( $team_id ) . '</td>';
|
||||
|
||||
foreach( $result_labels as $key => $label ):
|
||||
if ( $key == 'name' )
|
||||
continue;
|
||||
if ( array_key_exists( $key, $result ) && $result[ $key ] != '' ):
|
||||
$value = $result[ $key ];
|
||||
else:
|
||||
$value = '—';
|
||||
endif;
|
||||
$table_rows .= '<td class="data-' . $key . '">' . $value . '</td>';
|
||||
endforeach;
|
||||
|
||||
$table_rows .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
if ( empty( $table_rows ) ):
|
||||
|
||||
return false;
|
||||
|
||||
else:
|
||||
|
||||
$output .= '<h3>' . __( 'Results', 'sportspress' ) . '</h3>';
|
||||
|
||||
$output .= '<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-event-results sp-data-table sp-responsive-table"><thead>' .
|
||||
'<th class="data-name">' . __( 'Team', 'sportspress' ) . '</th>';
|
||||
foreach( $result_labels as $key => $label ):
|
||||
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||
endforeach;
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
$output .= $table_rows;
|
||||
$output .= '</tbody>' . '</table>' . '</div>';
|
||||
|
||||
endif;
|
||||
|
||||
echo $output;
|
||||
8
templates/event-staff.php
Normal file
8
templates/event-staff.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
if ( ! isset( $id ) )
|
||||
$id = get_the_ID();
|
||||
$staff = (array)get_post_meta( $id, 'sp_staff', false );
|
||||
|
||||
$output = '';
|
||||
|
||||
echo apply_filters( 'sportspress_event_staff', $output );
|
||||
28
templates/event-venue.php
Normal file
28
templates/event-venue.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
if ( ! isset( $id ) )
|
||||
$id = get_the_ID();
|
||||
|
||||
$venues = get_the_terms( $id, 'sp_venue' );
|
||||
|
||||
$output = '';
|
||||
|
||||
if ( ! $venues )
|
||||
return $output;
|
||||
|
||||
foreach( $venues as $venue ):
|
||||
|
||||
$t_id = $venue->term_id;
|
||||
$term_meta = get_option( "taxonomy_$t_id" );
|
||||
|
||||
$address = sportspress_array_value( $term_meta, 'sp_address', '' );
|
||||
$latitude = sportspress_array_value( $term_meta, 'sp_latitude', 0 );
|
||||
$longitude = sportspress_array_value( $term_meta, 'sp_longitude', 0 );
|
||||
|
||||
$output .= '<h3>' . __( 'Venue', 'sportspress' ) . '</h3>';
|
||||
$output .= '<p><a href="' . get_term_link( $t_id, 'sp_venue' ) . '">' . $venue->name . '</a><br><small>' . $address . '</small></p>';
|
||||
if ( $latitude != null && $longitude != null )
|
||||
$output .= '<div class="sp-google-map" data-address="' . $address . '" data-latitude="' . $latitude . '" data-longitude="' . $longitude . '"></div>';
|
||||
|
||||
endforeach;
|
||||
|
||||
echo apply_filters( 'sportspress_event_venue', $output );
|
||||
90
templates/league-table.php
Normal file
90
templates/league-table.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
global $sportspress_options;
|
||||
|
||||
$defaults = array(
|
||||
'id' => get_the_ID(),
|
||||
'number' => -1,
|
||||
'columns' => null,
|
||||
'show_full_table_link' => false,
|
||||
'show_team_logo' => sportspress_array_value( $sportspress_options, 'league_table_show_team_logo', false ),
|
||||
'link_posts' => sportspress_array_value( $sportspress_options, 'league_table_link_posts', false ),
|
||||
'sortable' => sportspress_array_value( $sportspress_options, 'league_table_sortable', true ),
|
||||
'responsive' => sportspress_array_value( $sportspress_options, 'league_table_responsive', true ),
|
||||
);
|
||||
|
||||
extract( $defaults, EXTR_SKIP );
|
||||
|
||||
$output = '<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-league-table sp-data-table' . ( $responsive ? ' sp-responsive-table' : '' ) . ( $sortable ? ' sp-sortable-table' : '' ) . '">' . '<thead>' . '<tr>';
|
||||
|
||||
$data = sportspress_get_league_table_data( $id );
|
||||
|
||||
// The first row should be column labels
|
||||
$labels = $data[0];
|
||||
|
||||
// Remove the first row to leave us with the actual data
|
||||
unset( $data[0] );
|
||||
|
||||
if ( ! $columns )
|
||||
$columns = get_post_meta( $id, 'sp_columns', true );
|
||||
|
||||
if ( ! is_array( $columns ) )
|
||||
$columns = explode( ',', $columns );
|
||||
|
||||
$output .= '<th class="data-rank">' . __( 'Pos', 'sportspress' ) . '</th>';
|
||||
|
||||
foreach( $labels as $key => $label ):
|
||||
if ( ! is_array( $columns ) || $key == 'name' || in_array( $key, $columns ) )
|
||||
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
|
||||
$i = 0;
|
||||
|
||||
if ( is_int( $number ) && $number > 0 )
|
||||
$limit = $number;
|
||||
|
||||
foreach( $data as $team_id => $row ):
|
||||
|
||||
if ( isset( $limit ) && $i >= $limit ) continue;
|
||||
|
||||
$name = sportspress_array_value( $row, 'name', null );
|
||||
if ( ! $name ) continue;
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
// Rank
|
||||
$output .= '<td class="data-rank">' . ( $i + 1 ) . '</td>';
|
||||
|
||||
if ( $show_team_logo )
|
||||
$name = get_the_post_thumbnail( $team_id, 'sportspress-fit-icon', array( 'class' => 'team-logo' ) ) . ' ' . $name;
|
||||
|
||||
if ( $link_posts ):
|
||||
$permalink = get_post_permalink( $team_id );
|
||||
$name = '<a href="' . $permalink . '">' . $name . '</a>';
|
||||
endif;
|
||||
|
||||
$output .= '<td class="data-name">' . $name . '</td>';
|
||||
|
||||
foreach( $labels as $key => $value ):
|
||||
if ( $key == 'name' )
|
||||
continue;
|
||||
if ( ! is_array( $columns ) || in_array( $key, $columns ) )
|
||||
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody>' . '</table>';
|
||||
|
||||
if ( $show_full_table_link )
|
||||
$output .= '<a class="sp-league-table-link" href="' . get_permalink( $id ) . '">' . __( 'View full table', 'sportspress' ) . '</a>';
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
echo $output;
|
||||
133
templates/player-gallery.php
Normal file
133
templates/player-gallery.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
global $sportspress_options;
|
||||
|
||||
$defaults = array(
|
||||
'id' => get_the_ID(),
|
||||
'number' => -1,
|
||||
'orderby' => 'default',
|
||||
'order' => 'ASC',
|
||||
'itemtag' => 'dl',
|
||||
'icontag' => 'dt',
|
||||
'captiontag' => 'dd',
|
||||
'columns' => 3,
|
||||
'size' => 'thumbnail',
|
||||
'show_all_players_link' => false,
|
||||
'show_names_on_hover' => sportspress_array_value( $sportspress_options, 'player_gallery_show_names_on_hover', true ),
|
||||
);
|
||||
|
||||
extract( $defaults, EXTR_SKIP );
|
||||
|
||||
$itemtag = tag_escape( $itemtag );
|
||||
$captiontag = tag_escape( $captiontag );
|
||||
$icontag = tag_escape( $icontag );
|
||||
$valid_tags = wp_kses_allowed_html( 'post' );
|
||||
if ( ! isset( $valid_tags[ $itemtag ] ) )
|
||||
$itemtag = 'dl';
|
||||
if ( ! isset( $valid_tags[ $captiontag ] ) )
|
||||
$captiontag = 'dd';
|
||||
if ( ! isset( $valid_tags[ $icontag ] ) )
|
||||
$icontag = 'dt';
|
||||
|
||||
$columns = intval( $columns );
|
||||
$itemwidth = $columns > 0 ? floor(100/$columns) : 100;
|
||||
$size = $size;
|
||||
$float = is_rtl() ? 'right' : 'left';
|
||||
|
||||
$selector = 'sp-player-gallery-' . $id;
|
||||
|
||||
$data = sportspress_get_player_list_data( $id );
|
||||
|
||||
// The first row should be column labels
|
||||
$labels = $data[0];
|
||||
|
||||
// Remove the first row to leave us with the actual data
|
||||
unset( $data[0] );
|
||||
|
||||
if ( $orderby == 'default' ):
|
||||
$orderby = get_post_meta( $id, 'sp_orderby', true );
|
||||
$order = get_post_meta( $id, 'sp_order', true );
|
||||
else:
|
||||
global $sportspress_performance_priorities;
|
||||
$sportspress_performance_priorities = array(
|
||||
array(
|
||||
'key' => $orderby,
|
||||
'order' => $order,
|
||||
),
|
||||
);
|
||||
uasort( $data, 'sportspress_sort_list_players' );
|
||||
endif;
|
||||
|
||||
$gallery_style = $gallery_div = '';
|
||||
if ( apply_filters( 'use_default_gallery_style', true ) )
|
||||
$gallery_style = "
|
||||
<style type='text/css'>
|
||||
#{$selector} {
|
||||
margin: auto;
|
||||
}
|
||||
#{$selector} .gallery-item {
|
||||
float: {$float};
|
||||
margin-top: 10px;
|
||||
text-align: center;
|
||||
width: {$itemwidth}%;
|
||||
}
|
||||
#{$selector} img {
|
||||
border: 2px solid #cfcfcf;
|
||||
}
|
||||
#{$selector} .gallery-caption {
|
||||
margin-left: 0;
|
||||
}
|
||||
/* see gallery_shortcode() in wp-includes/media.php */
|
||||
</style>";
|
||||
$size_class = sanitize_html_class( $size );
|
||||
$gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
|
||||
$output = apply_filters( 'gallery_style', $gallery_style . "\n\t\t" . $gallery_div );
|
||||
|
||||
$i = 0;
|
||||
|
||||
if ( is_int( $number ) && $number > 0 )
|
||||
$limit = $number;
|
||||
|
||||
foreach( $data as $player_id => $performance ):
|
||||
|
||||
if ( $show_names_on_hover ):
|
||||
$caption = get_the_title( $player_id );
|
||||
$player_number = get_post_meta( $player_id, 'sp_number', true );
|
||||
if ( $player_number ):
|
||||
$caption = '<strong>' . $player_number . '</strong> ' . $caption;
|
||||
endif;
|
||||
else:
|
||||
$caption = null;
|
||||
endif;
|
||||
|
||||
if ( isset( $limit ) && $i >= $limit )
|
||||
continue;
|
||||
|
||||
if ( has_post_thumbnail( $player_id ) ):
|
||||
$thumbnail = get_the_post_thumbnail( $player_id, $size );
|
||||
|
||||
$output .= "<{$itemtag} class='gallery-item'>";
|
||||
$output .= "
|
||||
<{$icontag} class='gallery-icon portrait'>"
|
||||
. '<a href="' . get_permalink( $player_id ) . '">' . $thumbnail . '</a>'
|
||||
. "</{$icontag}>";
|
||||
if ( $captiontag && trim( $caption ) ) {
|
||||
$output .= '<a href="' . get_permalink( $player_id ) . '">' . "
|
||||
<{$captiontag} class='wp-caption-text gallery-caption'>
|
||||
" . wptexturize($caption) . "
|
||||
</{$captiontag}>" . '</a>';
|
||||
}
|
||||
$output .= "</{$itemtag}>";
|
||||
if ( $columns > 0 && ++$i % $columns == 0 )
|
||||
$output .= '<br style="clear: both" />';
|
||||
endif;
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= "
|
||||
<br style='clear: both;' />
|
||||
</div>\n";
|
||||
|
||||
if ( $show_all_players_link )
|
||||
$output .= '<a class="sp-player-list-link" href="' . get_permalink( $id ) . '">' . __( 'View all players', 'sportspress' ) . '</a>';
|
||||
|
||||
echo apply_filters( 'sportspress_player_gallery', $output );
|
||||
48
templates/player-league-performance.php
Normal file
48
templates/player-league-performance.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
if ( ! isset( $league ) )
|
||||
return false;
|
||||
|
||||
if ( ! isset( $id ) )
|
||||
$id = get_the_ID();
|
||||
|
||||
$data = sportspress_get_player_performance_data( $id, $league->term_id );
|
||||
|
||||
// The first row should be column labels
|
||||
$labels = $data[0];
|
||||
|
||||
// Remove the first row to leave us with the actual data
|
||||
unset( $data[0] );
|
||||
|
||||
// Skip if there are no rows in the table
|
||||
if ( empty( $data ) )
|
||||
return false;
|
||||
|
||||
$output = '<h4 class="sp-table-caption">' . $league->name . '</h4>' .
|
||||
'<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-player-performance sp-data-table sp-responsive-table">' . '<thead>' . '<tr>';
|
||||
|
||||
foreach( $labels as $key => $label ):
|
||||
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach( $data as $season_id => $row ):
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
foreach( $labels as $key => $value ):
|
||||
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody>' . '</table>' . '</div>';
|
||||
|
||||
echo apply_filters( 'sportspress_player_league_performance', $output );
|
||||
102
templates/player-list.php
Normal file
102
templates/player-list.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
global $sportspress_options;
|
||||
|
||||
$defaults = array(
|
||||
'id' => get_the_ID(),
|
||||
'number' => -1,
|
||||
'performance' => null,
|
||||
'orderby' => 'default',
|
||||
'order' => 'ASC',
|
||||
'show_all_players_link' => false,
|
||||
'link_posts' => sportspress_array_value( $sportspress_options, 'player_list_link_posts', true ),
|
||||
'sortable' => sportspress_array_value( $sportspress_options, 'player_list_sortable', true ),
|
||||
'responsive' => sportspress_array_value( $sportspress_options, 'player_list_responsive', true ),
|
||||
);
|
||||
|
||||
extract( $defaults, EXTR_SKIP );
|
||||
|
||||
$output = '<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-player-list sp-data-table' . ( $responsive ? ' sp-responsive-table' : '' ) . ( $sortable ? ' sp-sortable-table' : '' ) . '">' . '<thead>' . '<tr>';
|
||||
|
||||
$data = sportspress_get_player_list_data( $id );
|
||||
|
||||
// The first row should be column labels
|
||||
$labels = $data[0];
|
||||
|
||||
// Remove the first row to leave us with the actual data
|
||||
unset( $data[0] );
|
||||
|
||||
if ( $orderby == 'default' ):
|
||||
$orderby = get_post_meta( $id, 'sp_orderby', true );
|
||||
$order = get_post_meta( $id, 'sp_order', true );
|
||||
else:
|
||||
global $sportspress_performance_priorities;
|
||||
$sportspress_performance_priorities = array(
|
||||
array(
|
||||
'key' => $orderby,
|
||||
'order' => $order,
|
||||
),
|
||||
);
|
||||
uasort( $data, 'sportspress_sort_list_players' );
|
||||
endif;
|
||||
|
||||
if ( in_array( $orderby, array( 'number', 'name' ) ) ):
|
||||
$output .= '<th class="data-number">#</th>';
|
||||
else:
|
||||
$output .= '<th class="data-rank">' . __( 'Rank', 'sportspress' ) . '</th>';
|
||||
endif;
|
||||
|
||||
foreach( $labels as $key => $label ):
|
||||
if ( ! is_array( $performance ) || $key == 'name' || in_array( $key, $performance ) )
|
||||
$output .= '<th class="data-' . $key . '">'. $label . '</th>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
|
||||
$i = 0;
|
||||
|
||||
if ( is_int( $number ) && $number > 0 )
|
||||
$limit = $number;
|
||||
|
||||
foreach( $data as $player_id => $row ):
|
||||
if ( isset( $limit ) && $i >= $limit ) continue;
|
||||
|
||||
$name = sportspress_array_value( $row, 'name', null );
|
||||
if ( ! $name ) continue;
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
// Rank or number
|
||||
if ( isset( $orderby ) && $orderby != 'number' ):
|
||||
$output .= '<td class="data-rank">' . ( $i + 1 ) . '</td>';
|
||||
else:
|
||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||
$output .= '<td class="data-number">' . ( $number ? $number : ' ' ) . '</td>';
|
||||
endif;
|
||||
|
||||
if ( $link_posts ):
|
||||
$permalink = get_post_permalink( $player_id );
|
||||
$name = '<a href="' . $permalink . '">' . $name . '</a>';
|
||||
endif;
|
||||
|
||||
$output .= '<td class="data-name">' . $name . '</td>';
|
||||
|
||||
foreach( $labels as $key => $value ):
|
||||
if ( $key == 'name' )
|
||||
continue;
|
||||
if ( ! is_array( $performance ) || in_array( $key, $performance ) )
|
||||
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody>' . '</table>' . '</div>';
|
||||
|
||||
if ( $show_all_players_link )
|
||||
$output .= '<a class="sp-player-list-link" href="' . get_permalink( $id ) . '">' . __( 'View all players', 'sportspress' ) . '</a>';
|
||||
|
||||
echo apply_filters( 'sportspress_player_list', $output );
|
||||
50
templates/player-metrics.php
Normal file
50
templates/player-metrics.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
if ( ! isset( $id ) )
|
||||
$id = get_the_ID();
|
||||
|
||||
global $sportspress_countries;
|
||||
|
||||
global $sportspress_options;
|
||||
|
||||
$defaults = array(
|
||||
'show_nationality_flag' => sportspress_array_value( $sportspress_options, 'player_show_nationality_flag', true ),
|
||||
);
|
||||
|
||||
extract( $defaults, EXTR_SKIP );
|
||||
|
||||
$nationality = get_post_meta( $id, 'sp_nationality', true );
|
||||
$current_team = get_post_meta( $id, 'sp_current_team', true );
|
||||
$past_teams = get_post_meta( $id, 'sp_past_team', false );
|
||||
$metrics = sportspress_get_player_metrics_data( $id );
|
||||
|
||||
$common = array();
|
||||
if ( $nationality ):
|
||||
$country_name = sportspress_array_value( $sportspress_countries, $nationality, null );
|
||||
$common[ __( 'Nationality', 'sportspress' ) ] = $country_name ? ( $show_nationality_flag ? '<img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . '/assets/images/flags/' . strtolower( $nationality ) . '.png" alt="' . $nationality . '"> ' : '' ) . $country_name : '—';
|
||||
endif;
|
||||
|
||||
$data = array_merge( $common, $metrics );
|
||||
|
||||
if ( $current_team )
|
||||
$data[ __( 'Current Team', 'sportspress' ) ] = '<a href="' . get_post_permalink( $current_team ) . '">' . get_the_title( $current_team ) . '</a>';
|
||||
|
||||
if ( $past_teams ):
|
||||
$teams = array();
|
||||
foreach ( $past_teams as $team ):
|
||||
$teams[] = '<a href="' . get_post_permalink( $team ) . '">' . get_the_title( $team ) . '</a>';
|
||||
endforeach;
|
||||
$data[ __( 'Past Teams', 'sportspress' ) ] = implode( ', ', $teams );
|
||||
endif;
|
||||
|
||||
$output = '<div class="sp-list-wrapper">' .
|
||||
'<dl class="sp-player-metrics">';
|
||||
|
||||
foreach( $data as $label => $value ):
|
||||
|
||||
$output .= '<dt>' . $label . '<dd>' . $value . '</dd>';
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= '</dl></div>';
|
||||
|
||||
echo apply_filters( 'sportspress_player_metrics', $output );
|
||||
14
templates/player-performance.php
Normal file
14
templates/player-performance.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
if ( ! isset( $id ) )
|
||||
$id = get_the_ID();
|
||||
|
||||
$leagues = get_the_terms( $id, 'sp_league' );
|
||||
|
||||
// Loop through performance for each league
|
||||
if ( is_array( $leagues ) ):
|
||||
foreach ( $leagues as $league ):
|
||||
sp_get_template( 'player-league-performance.php', array(
|
||||
'league' => $league
|
||||
) );
|
||||
endforeach;
|
||||
endif;
|
||||
97
templates/player-roster.php
Normal file
97
templates/player-roster.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
if ( ! $id )
|
||||
$id = get_the_ID();
|
||||
|
||||
$defaults = array(
|
||||
'performance' => null,
|
||||
'orderby' => 'default',
|
||||
'order' => 'ASC',
|
||||
);
|
||||
|
||||
$r = wp_parse_args( $args, $defaults );
|
||||
|
||||
$output = '';
|
||||
|
||||
$data = sportspress_get_player_roster_data( $id );
|
||||
|
||||
// The first row should be column labels
|
||||
$labels = $data[0];
|
||||
|
||||
// Remove the first row to leave us with the actual data
|
||||
unset( $data[0] );
|
||||
|
||||
$performance = sportspress_array_value( $r, 'performance', null );
|
||||
|
||||
if ( $r['orderby'] == 'default' ):
|
||||
$r['orderby'] = get_post_meta( $id, 'sp_orderby', true );
|
||||
$r['order'] = get_post_meta( $id, 'sp_order', true );
|
||||
else:
|
||||
global $sportspress_performance_priorities;
|
||||
$sportspress_performance_priorities = array(
|
||||
array(
|
||||
'key' => $r['orderby'],
|
||||
'order' => $r['order'],
|
||||
),
|
||||
);
|
||||
uasort( $data, 'sportspress_sort_list_players' );
|
||||
endif;
|
||||
|
||||
$positions = get_terms ( 'sp_position' );
|
||||
|
||||
foreach ( $positions as $position ):
|
||||
$rows = '';
|
||||
$i = 0;
|
||||
|
||||
foreach ( $data as $player_id => $row ):
|
||||
|
||||
if ( ! in_array( $position->term_id, $row['positions']) )
|
||||
continue;
|
||||
|
||||
$rows .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
// Rank or number
|
||||
if ( isset( $r['orderby'] ) && $r['orderby'] != 'number' ):
|
||||
$rows .= '<td class="data-rank">' . ( $i + 1 ) . '</td>';
|
||||
else:
|
||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||
$rows .= '<td class="data-number">' . ( $number ? $number : ' ' ) . '</td>';
|
||||
endif;
|
||||
|
||||
// Name as link
|
||||
$permalink = get_post_permalink( $player_id );
|
||||
$name = sportspress_array_value( $row, 'name', sportspress_array_value( $row, 'name', ' ' ) );
|
||||
$rows .= '<td class="data-name">' . '<a href="' . $permalink . '">' . $name . '</a></td>';
|
||||
|
||||
foreach( $labels as $key => $value ):
|
||||
if ( $key == 'name' )
|
||||
continue;
|
||||
if ( ! is_array( $performance ) || in_array( $key, $performance ) )
|
||||
$rows .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||
endforeach;
|
||||
|
||||
$rows .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
if ( ! empty( $rows ) ):
|
||||
$output .= '<h4 class="sp-table-caption">' . $position->name . '</h4>';
|
||||
$output .= '<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-player-list sp-player-roster sp-data-table sp-responsive-table">' . '<thead>' . '<tr>';
|
||||
if ( in_array( $r['orderby'], array( 'number', 'name' ) ) ):
|
||||
$output .= '<th class="data-number">#</th>';
|
||||
else:
|
||||
$output .= '<th class="data-rank">' . __( 'Rank', 'sportspress' ) . '</th>';
|
||||
endif;
|
||||
|
||||
foreach( $labels as $key => $label ):
|
||||
if ( ! is_array( $performance ) || $key == 'name' || in_array( $key, $performance ) )
|
||||
$output .= '<th class="data-' . $key . '">'. $label . '</th>';
|
||||
endforeach;
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>' . $rows . '</tbody>' . '</table>' . '</div>';
|
||||
endif;
|
||||
|
||||
endforeach;
|
||||
|
||||
echo apply_filters( 'sportspress_player_roster', $output );
|
||||
57
templates/team-columns.php
Normal file
57
templates/team-columns.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
if ( ! isset( $id ) )
|
||||
$id = get_the_ID();
|
||||
|
||||
$leagues = get_the_terms( $id, 'sp_league' );
|
||||
|
||||
if ( ! $leagues )
|
||||
return false;
|
||||
|
||||
$output = '';
|
||||
|
||||
// Loop through data for each league
|
||||
foreach ( $leagues as $league ):
|
||||
|
||||
$data = sportspress_get_team_columns_data( $id, $league->term_id );
|
||||
|
||||
if ( sizeof( $data ) <= 1 )
|
||||
continue;
|
||||
|
||||
// The first row should be column labels
|
||||
$labels = $data[0];
|
||||
|
||||
// Remove the first row to leave us with the actual data
|
||||
unset( $data[0] );
|
||||
|
||||
$output .= '<h4 class="sp-table-caption">' . $league->name . '</h4>' .
|
||||
'<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-team-columns sp-data-table sp-responsive-table">' . '<thead>' . '<tr>';
|
||||
|
||||
foreach( $labels as $key => $label ):
|
||||
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach( $data as $season_id => $row ):
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
foreach( $labels as $key => $value ):
|
||||
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody>' . '</table>' . '</div>';
|
||||
|
||||
|
||||
endforeach;
|
||||
|
||||
echo apply_filters( 'sportspress_team_columns', $output );
|
||||
Reference in New Issue
Block a user