diff --git a/admin/hooks/the-content.php b/admin/hooks/the-content.php index 170f5f66..28f499d0 100644 --- a/admin/hooks/the-content.php +++ b/admin/hooks/the-content.php @@ -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 = '

' . implode( ' — ', $terms ) . '

'; - $table = sportspress_league_table(); + echo '

' . implode( ' — ', $terms ) . '

'; + + 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; } diff --git a/admin/hooks/widget-text.php b/admin/hooks/widget-text.php index 5bf97f58..fe37153f 100644 --- a/admin/hooks/widget-text.php +++ b/admin/hooks/widget-text.php @@ -1,6 +1,6 @@

-

+

-

+

-

+

__( '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' ); diff --git a/admin/terms/position.php b/admin/terms/position.php deleted file mode 100644 index 38d1a4e4..00000000 --- a/admin/terms/position.php +++ /dev/null @@ -1,32 +0,0 @@ - __( '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' ); diff --git a/admin/terms/season.php b/admin/terms/season.php deleted file mode 100644 index 3fb4680a..00000000 --- a/admin/terms/season.php +++ /dev/null @@ -1,32 +0,0 @@ - __( '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' ); diff --git a/admin/terms/venue.php b/admin/terms/venue.php index d8acc565..a825e989 100644 --- a/admin/terms/venue.php +++ b/admin/terms/venue.php @@ -1,36 +1,4 @@ __( '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" ); ?> diff --git a/assets/css/sportspress.css b/assets/css/sportspress.css index c5de223e..89ac8789 100644 --- a/assets/css/sportspress.css +++ b/assets/css/sportspress.css @@ -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 { diff --git a/includes/class-sp-post-types.php b/includes/class-sp-post-types.php new file mode 100644 index 00000000..8faa5f5e --- /dev/null +++ b/includes/class-sp-post-types.php @@ -0,0 +1,164 @@ + __( '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(); diff --git a/includes/class-sp-shortcodes.php b/includes/class-sp-shortcodes.php new file mode 100644 index 00000000..bfdfb8c8 --- /dev/null +++ b/includes/class-sp-shortcodes.php @@ -0,0 +1,125 @@ + __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'] ) ? '
' : $wrapper['before']; + $after = empty( $wrapper['after'] ) ? '
' : $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 ); + } +} diff --git a/includes/shortcodes/class-sp-shortcode-countdown.php b/includes/shortcodes/class-sp-shortcode-countdown.php new file mode 100644 index 00000000..69308dc5 --- /dev/null +++ b/includes/shortcodes/class-sp-shortcode-countdown.php @@ -0,0 +1,24 @@ +%s 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; diff --git a/includes/sp-deprecated-functions.php b/includes/sp-deprecated-functions.php index 10d025a3..42bf6510 100644 --- a/includes/sp-deprecated-functions.php +++ b/includes/sp-deprecated-functions.php @@ -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 ); } diff --git a/includes/templates/countdown.php b/includes/templates/countdown.php deleted file mode 100644 index c36bed4f..00000000 --- a/includes/templates/countdown.php +++ /dev/null @@ -1,65 +0,0 @@ - 'sp_team', 'value' => $args['team'] ); - $post = sportspress_get_next_event( $args ); - endif; - - $output = ''; - - if ( isset( $post ) ): - $output .= '
'; - $output .= '

' . $post->post_title . '

'; - - 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 .= '
' . $term->name . '
'; - endforeach; - endif; - endif; - - $now = new DateTime( current_time( 'mysql', 0 ) ); - $date = new DateTime( $post->post_date ); - $interval = date_diff( $now, $date ); - - $output .= '

'; - - $output .= '
'; - 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'); diff --git a/includes/templates/event-calendar.php b/includes/templates/event-calendar.php deleted file mode 100644 index 8b418c65..00000000 --- a/includes/templates/event-calendar.php +++ /dev/null @@ -1,222 +0,0 @@ - '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 = ' -
- - <' . $caption_tag . ' class="sp-table-caption">' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . ' - - '; - - $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"; - } - - $calendar_output .= ' - - - - - '; - - if ( $previous ) { - $calendar_output .= "\n\t\t".''; - } else { - $calendar_output .= "\n\t\t".''; - } - - $calendar_output .= "\n\t\t".''; - - if ( $next ) { - $calendar_output .= "\n\t\t".''; - } else { - $calendar_output .= "\n\t\t".''; - } - - $calendar_output .= ' - - - - - '; - - // 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".''; - - $daysinmonth = intval(date('t', $unixmonth)); - for ( $day = 1; $day <= $daysinmonth; ++$day ) { - if ( isset($newrow) && $newrow ) - $calendar_output .= "\n\t\n\t\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 .= ''; - - 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".''; - - $calendar_output .= "\n\t\n\t\n\t
$day_name
« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '  ' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' » 
 
'; - else - $calendar_output .= ''; - - if ( array_key_exists($day, $daywithpost) ) // any posts today? - $calendar_output .= '$day"; - else - $calendar_output .= $day; - $calendar_output .= ' 
\n\t
"; - - if ( $id && $r['show_all_events_link'] ) - $calendar_output .= '' . __( 'View all events', 'sportspress' ) . ''; - - 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'); diff --git a/includes/templates/event-details.php b/includes/templates/event-details.php deleted file mode 100644 index 84fa7512..00000000 --- a/includes/templates/event-details.php +++ /dev/null @@ -1,48 +0,0 @@ - $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 = '

' . __( 'Details', 'sportspress' ) . '

'; - - $output .= '
' . - ''; - - $i = 0; - - foreach( $data as $label => $value ): - - $output .= ''; - $output .= ''; - $output .= ''; - $output .= ''; - - $i++; - - endforeach; - - $output .= '
' . $label . '' . $value . '
'; - - return apply_filters( 'sportspress_event_details', $output ); - - } -} diff --git a/includes/templates/event-list.php b/includes/templates/event-list.php deleted file mode 100644 index e782d7bc..00000000 --- a/includes/templates/event-list.php +++ /dev/null @@ -1,142 +0,0 @@ - false, - ); - - $r = wp_parse_args( $args, $defaults ); - - $output = '
' . - '' . '' . ''; - - list( $data, $usecolumns ) = sportspress_get_calendar_data( $id, true ); - - if ( isset( $r['columns'] ) ) - $usecolumns = $r['columns']; - - $output .= ''; - - if ( $usecolumns == null || in_array( 'event', $usecolumns ) ) - $output .= ''; - - if ( $usecolumns == null || in_array( 'teams', $usecolumns ) ) - $output .= ''; - - if ( $usecolumns == null || in_array( 'time', $usecolumns ) ) - $output .= ''; - - if ( $usecolumns == null || in_array( 'article', $usecolumns ) ) - $output .= ''; - - $output .= '' . '' . ''; - - $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 .= ''; - - $output .= ''; - - if ( $usecolumns == null || in_array( 'event', $usecolumns ) ) - $output .= ''; - - if ( $usecolumns == null || in_array( 'teams', $usecolumns ) ): - $output .= ''; - endif; - - if ( $usecolumns == null || in_array( 'time', $usecolumns ) ) - $output .= ''; - - if ( $usecolumns == null || in_array( 'article', $usecolumns ) ): - $output .= ''; - endif; - - $output .= ''; - - $i++; - endforeach; - - $output .= '' . '
' . __( 'Date', 'sportspress' ). '' . __( 'Event', 'sportspress' ). '' . __( 'Teams', 'sportspress' ). '' . __( 'Time', 'sportspress' ). '' . __( 'Article', 'sportspress' ). '
' . get_post_time( get_option( 'date_format' ), false, $event ) . '' . $event->post_title . ''; - - $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 .= '
'; - endif; - endforeach; - else: - $output .= '—'; - endif; - - $output .= '
' . get_post_time( get_option( 'time_format' ), false, $event ) . ' - '; - - if ( $video ): - $output .= '
'; - elseif ( has_post_thumbnail( $event->ID ) ): - $output .= '
'; - endif; - if ( $event->post_content !== null ): - if ( $event->post_status == 'publish' ): - $output .= __( 'Recap', 'sportspress' ); - else: - $output .= __( 'Preview', 'sportspress' ); - endif; - endif; - - $output .= '
-
'; - - if ( $id && $r['show_all_events_link'] ) - $output .= '' . __( 'View all events', 'sportspress' ) . ''; - - $output .= '
'; - - 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'); diff --git a/includes/templates/event-performance.php b/includes/templates/event-performance.php deleted file mode 100644 index 629f3f8c..00000000 --- a/includes/templates/event-performance.php +++ /dev/null @@ -1,126 +0,0 @@ - $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 .= '

' . get_the_title( $team_id ) . '

'; - - $output .= '
' . - '' . '' . ''; - - $output .= ''; - $output .= ''; - - foreach( $performance_labels as $key => $label ): - $output .= ''; - endforeach; - - $output .= '' . '' . ''; - - $i = 0; - - foreach( $data as $player_id => $row ): - - if ( ! $player_id ) - continue; - - $name = get_the_title( $player_id ); - - if ( ! $name ) - continue; - - $output .= ''; - - $number = get_post_meta( $player_id, 'sp_number', true ); - - // Player number - $output .= ''; - - if ( $link_posts ): - $permalink = get_post_permalink( $player_id ); - $name = '' . $name . ''; - endif; - - $output .= ''; - - 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 .= ''; - endforeach; - - $output .= ''; - - $i++; - - endforeach; - - $output .= ''; - - if ( array_key_exists( 0, $data ) ): - - $output .= ''; - - $number = get_post_meta( $player_id, 'sp_number', true ); - - // Player number - $output .= ''; - $output .= ''; - - $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 .= ''; - endforeach; - - $output .= ''; - - endif; - - $output .= '
#' . __( 'Player', 'sportspress' ) . '' . $label . '
' . $number . '' . $name . '' . $value . '
 ' . __( 'Total', 'sportspress' ) . '' . $value . '
' . '
'; - - endforeach; - - return apply_filters( 'sportspress_event_performance', $output ); - - } -} diff --git a/includes/templates/event-results.php b/includes/templates/event-results.php deleted file mode 100644 index 9da25994..00000000 --- a/includes/templates/event-results.php +++ /dev/null @@ -1,72 +0,0 @@ - $result ): - if ( sportspress_array_value( $result, 'outcome', '-1' ) != '-1' ): - - unset( $result['outcome'] ); - - $table_rows .= ''; - - $table_rows .= '' . get_the_title( $team_id ) . ''; - - 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 .= '' . $value . ''; - endforeach; - - $table_rows .= ''; - - $i++; - - endif; - endforeach; - - if ( empty( $table_rows ) ): - - return false; - - else: - - $output .= '

' . __( 'Results', 'sportspress' ) . '

'; - - $output .= '
' . - '' . - ''; - foreach( $result_labels as $key => $label ): - $output .= ''; - endforeach; - $output .= '' . '' . ''; - $output .= $table_rows; - $output .= '' . '
' . __( 'Team', 'sportspress' ) . '' . $label . '
' . '
'; - - endif; - - return apply_filters( 'sportspress_event_results', $output ); - - } -} diff --git a/includes/templates/event-staff.php b/includes/templates/event-staff.php deleted file mode 100644 index be2a0fdb..00000000 --- a/includes/templates/event-staff.php +++ /dev/null @@ -1,14 +0,0 @@ -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 .= '

' . __( 'Venue', 'sportspress' ) . '

'; - $output .= '

' . $venue->name . '
' . $address . '

'; - if ( $latitude != null && $longitude != null ) - $output .= '
'; - - endforeach; - - return apply_filters( 'sportspress_event_venue', $output ); - - } -} diff --git a/includes/templates/league-table.php b/includes/templates/league-table.php deleted file mode 100644 index 53529ee6..00000000 --- a/includes/templates/league-table.php +++ /dev/null @@ -1,114 +0,0 @@ - -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 = '
' . - '' . '' . ''; - - $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 .= ''; - - foreach( $labels as $key => $label ): - if ( ! is_array( $columns ) || $key == 'name' || in_array( $key, $columns ) ) - $output .= ''; - endforeach; - - $output .= '' . '' . ''; - - $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 .= ''; - - // Rank - $output .= ''; - - 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 = '' . $name . ''; - endif; - - $output .= ''; - - foreach( $labels as $key => $value ): - if ( $key == 'name' ) - continue; - if ( ! is_array( $columns ) || in_array( $key, $columns ) ) - $output .= ''; - endforeach; - - $output .= ''; - - $i++; - - endforeach; - - $output .= '' . '
' . __( 'Pos', 'sportspress' ) . '' . $label . '
' . ( $i + 1 ) . '' . $name . '' . sportspress_array_value( $row, $key, '—' ) . '
'; - - if ( $r['show_full_table_link'] ) - $output .= '' . __( 'View full table', 'sportspress' ) . ''; - - $output .= '
'; - - 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'); diff --git a/includes/templates/player-gallery.php b/includes/templates/player-gallery.php deleted file mode 100644 index 3ff55692..00000000 --- a/includes/templates/player-gallery.php +++ /dev/null @@ -1,151 +0,0 @@ - -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 = " - "; - $size_class = sanitize_html_class( $size ); - $gallery_div = "\n"; - - if ( $r['show_all_players_link'] ) - $output .= '' . __( 'View all players', 'sportspress' ) . ''; - - 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'); diff --git a/includes/templates/player-league-performance.php b/includes/templates/player-league-performance.php deleted file mode 100644 index 2418c391..00000000 --- a/includes/templates/player-league-performance.php +++ /dev/null @@ -1,54 +0,0 @@ -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 = '

' . $league->name . '

' . - '
' . - '' . '' . ''; - - foreach( $labels as $key => $label ): - $output .= ''; - endforeach; - - $output .= '' . '' . ''; - - $i = 0; - - foreach( $data as $season_id => $row ): - - $output .= ''; - - foreach( $labels as $key => $value ): - $output .= ''; - endforeach; - - $output .= ''; - - $i++; - - endforeach; - - $output .= '' . '
' . $label . '
' . sportspress_array_value( $row, $key, '—' ) . '
' . '
'; - - return apply_filters( 'sportspress_player_league_performance', $output ); - - } -} diff --git a/includes/templates/player-list.php b/includes/templates/player-list.php deleted file mode 100644 index c3805563..00000000 --- a/includes/templates/player-list.php +++ /dev/null @@ -1,126 +0,0 @@ - -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 = '
' . - '' . '' . ''; - - $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 .= ''; - else: - $output .= ''; - endif; - - foreach( $labels as $key => $label ): - if ( ! is_array( $performance ) || $key == 'name' || in_array( $key, $performance ) ) - $output .= ''; - endforeach; - - $output .= '' . '' . ''; - - $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 .= ''; - - // Rank or number - if ( isset( $r['orderby'] ) && $r['orderby'] != 'number' ): - $output .= ''; - else: - $number = get_post_meta( $player_id, 'sp_number', true ); - $output .= ''; - endif; - - if ( $r['link_posts'] ): - $permalink = get_post_permalink( $player_id ); - $name = '' . $name . ''; - endif; - - $output .= ''; - - foreach( $labels as $key => $value ): - if ( $key == 'name' ) - continue; - if ( ! is_array( $performance ) || in_array( $key, $performance ) ) - $output .= ''; - endforeach; - - $output .= ''; - - $i++; - - endforeach; - - $output .= '' . '
#' . __( 'Rank', 'sportspress' ) . ''. $label . '
' . ( $i + 1 ) . '' . ( $number ? $number : ' ' ) . '' . $name . '' . sportspress_array_value( $row, $key, '—' ) . '
' . '
'; - - if ( $r['show_all_players_link'] ) - $output .= '' . __( 'View all players', 'sportspress' ) . ''; - - 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'); \ No newline at end of file diff --git a/includes/templates/player-metrics.php b/includes/templates/player-metrics.php deleted file mode 100644 index 0731f3ea..00000000 --- a/includes/templates/player-metrics.php +++ /dev/null @@ -1,56 +0,0 @@ - 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'] ? '' . $nationality . ' ' : '' ) . $country_name : '—'; - endif; - - $data = array_merge( $common, $metrics ); - - if ( $current_team ) - $data[ __( 'Current Team', 'sportspress' ) ] = '' . get_the_title( $current_team ) . ''; - - if ( $past_teams ): - $teams = array(); - foreach ( $past_teams as $team ): - $teams[] = '' . get_the_title( $team ) . ''; - endforeach; - $data[ __( 'Past Teams', 'sportspress' ) ] = implode( ', ', $teams ); - endif; - - $output = '
' . - '
'; - - foreach( $data as $label => $value ): - - $output .= '
' . $label . '
' . $value . '
'; - - endforeach; - - $output .= '
'; - - return apply_filters( 'sportspress_player_metrics', $output ); - - } -} diff --git a/includes/templates/player-performance.php b/includes/templates/player-performance.php deleted file mode 100644 index 3483c94e..00000000 --- a/includes/templates/player-performance.php +++ /dev/null @@ -1,22 +0,0 @@ - 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 .= ''; - - // Rank or number - if ( isset( $r['orderby'] ) && $r['orderby'] != 'number' ): - $rows .= '' . ( $i + 1 ) . ''; - else: - $number = get_post_meta( $player_id, 'sp_number', true ); - $rows .= '' . ( $number ? $number : ' ' ) . ''; - endif; - - // Name as link - $permalink = get_post_permalink( $player_id ); - $name = sportspress_array_value( $row, 'name', sportspress_array_value( $row, 'name', ' ' ) ); - $rows .= '' . '' . $name . ''; - - foreach( $labels as $key => $value ): - if ( $key == 'name' ) - continue; - if ( ! is_array( $performance ) || in_array( $key, $performance ) ) - $rows .= '' . sportspress_array_value( $row, $key, '—' ) . ''; - endforeach; - - $rows .= ''; - - $i++; - - endforeach; - - if ( ! empty( $rows ) ): - $output .= '

' . $position->name . '

'; - $output .= '
' . - '' . '' . ''; - if ( in_array( $r['orderby'], array( 'number', 'name' ) ) ): - $output .= ''; - else: - $output .= ''; - endif; - - foreach( $labels as $key => $label ): - if ( ! is_array( $performance ) || $key == 'name' || in_array( $key, $performance ) ) - $output .= ''; - endforeach; - $output .= '' . '' . '' . $rows . '' . '
#' . __( 'Rank', 'sportspress' ) . ''. $label . '
' . '
'; - endif; - - endforeach; - - return apply_filters( 'sportspress_player_roster', $output ); - - } -} diff --git a/includes/templates/team-columns.php b/includes/templates/team-columns.php deleted file mode 100644 index ff0f2c03..00000000 --- a/includes/templates/team-columns.php +++ /dev/null @@ -1,63 +0,0 @@ -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 .= '

' . $league->name . '

' . - '
' . - '' . '' . ''; - - foreach( $labels as $key => $label ): - $output .= ''; - endforeach; - - $output .= '' . '' . ''; - - $i = 0; - - foreach( $data as $season_id => $row ): - - $output .= ''; - - foreach( $labels as $key => $value ): - $output .= ''; - endforeach; - - $output .= ''; - - $i++; - - endforeach; - - $output .= '' . '
' . $label . '
' . sportspress_array_value( $row, $key, '—' ) . '
' . '
'; - - - endforeach; - - return apply_filters( 'sportspress_team_columns', $output ); - - } -} diff --git a/sportspress.php b/sportspress.php index e8cb346e..607cfbf6 100644 --- a/sportspress.php +++ b/sportspress.php @@ -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 } /** diff --git a/templates/countdown.php b/templates/countdown.php new file mode 100644 index 00000000..336e5776 --- /dev/null +++ b/templates/countdown.php @@ -0,0 +1,43 @@ + 'sp_team', 'value' => $team ); + $post = sportspress_get_next_event( $args ); +endif; + +$output = ''; + +if ( isset( $post ) ): + $output .= '
'; + $output .= '

' . $post->post_title . '

'; + + 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 .= '
' . $term->name . '
'; + endforeach; + endif; + endif; + + $now = new DateTime( current_time( 'mysql', 0 ) ); + $date = new DateTime( $post->post_date ); + $interval = date_diff( $now, $date ); + + $output .= '

'; + + $output .= '
'; +else: + return false; +endif; + +echo apply_filters( 'sportspress_countdown', $output ); diff --git a/templates/event-calendar.php b/templates/event-calendar.php new file mode 100644 index 00000000..93472ec2 --- /dev/null +++ b/templates/event-calendar.php @@ -0,0 +1,200 @@ + 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 = ' +
+ +<' . $caption_tag . ' class="sp-table-caption">' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . ' + +'; + +$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"; +} + +$calendar_output .= ' + + + + +'; + +if ( $previous ) { + $calendar_output .= "\n\t\t".''; +} else { + $calendar_output .= "\n\t\t".''; +} + +$calendar_output .= "\n\t\t".''; + +if ( $next ) { + $calendar_output .= "\n\t\t".''; +} else { + $calendar_output .= "\n\t\t".''; +} + +$calendar_output .= ' + + + + +'; + +// 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".''; + +$daysinmonth = intval(date('t', $unixmonth)); +for ( $day = 1; $day <= $daysinmonth; ++$day ) { + if ( isset($newrow) && $newrow ) + $calendar_output .= "\n\t\n\t\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 .= ''; + + 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".''; + +$calendar_output .= "\n\t\n\t\n\t
$day_name
« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '  ' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' » 
 
'; + else + $calendar_output .= ''; + + if ( array_key_exists($day, $daywithpost) ) // any posts today? + $calendar_output .= '$day"; + else + $calendar_output .= $day; + $calendar_output .= ' 
\n\t
"; + +if ( $id && $show_all_events_link ) + $calendar_output .= '' . __( 'View all events', 'sportspress' ) . ''; + +echo apply_filters( 'sportspress_event_calendar', $calendar_output ); diff --git a/templates/event-details.php b/templates/event-details.php new file mode 100644 index 00000000..3070d922 --- /dev/null +++ b/templates/event-details.php @@ -0,0 +1,42 @@ + $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 = '

' . __( 'Details', 'sportspress' ) . '

'; + +$output .= '
' . + ''; + +$i = 0; + +foreach( $data as $label => $value ): + + $output .= ''; + $output .= ''; + $output .= ''; + $output .= ''; + + $i++; + +endforeach; + +$output .= '
' . $label . '' . $value . '
'; + +echo apply_filters( 'sportspress_event_details', $output ); diff --git a/templates/event-list.php b/templates/event-list.php new file mode 100644 index 00000000..af4b26cc --- /dev/null +++ b/templates/event-list.php @@ -0,0 +1,121 @@ + false, +); + +extract( $defaults, EXTR_SKIP ); + +$output = '
' . + '' . '' . ''; + +list( $data, $usecolumns ) = sportspress_get_calendar_data( $id, true ); + +if ( isset( $columns ) ) + $usecolumns = $columns; + +$output .= ''; + +if ( $usecolumns == null || in_array( 'event', $usecolumns ) ) + $output .= ''; + +if ( $usecolumns == null || in_array( 'teams', $usecolumns ) ) + $output .= ''; + +if ( $usecolumns == null || in_array( 'time', $usecolumns ) ) + $output .= ''; + +if ( $usecolumns == null || in_array( 'article', $usecolumns ) ) + $output .= ''; + +$output .= '' . '' . ''; + +$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 .= ''; + + $output .= ''; + + if ( $usecolumns == null || in_array( 'event', $usecolumns ) ) + $output .= ''; + + if ( $usecolumns == null || in_array( 'teams', $usecolumns ) ): + $output .= ''; + endif; + + if ( $usecolumns == null || in_array( 'time', $usecolumns ) ) + $output .= ''; + + if ( $usecolumns == null || in_array( 'article', $usecolumns ) ): + $output .= ''; + endif; + + $output .= ''; + + $i++; +endforeach; + +$output .= '' . '
' . __( 'Date', 'sportspress' ). '' . __( 'Event', 'sportspress' ). '' . __( 'Teams', 'sportspress' ). '' . __( 'Time', 'sportspress' ). '' . __( 'Article', 'sportspress' ). '
' . get_post_time( get_option( 'date_format' ), false, $event ) . '' . $event->post_title . ''; + + $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 .= '
'; + endif; + endforeach; + else: + $output .= '—'; + endif; + + $output .= '
' . get_post_time( get_option( 'time_format' ), false, $event ) . ' + '; + + if ( $video ): + $output .= '
'; + elseif ( has_post_thumbnail( $event->ID ) ): + $output .= '
'; + endif; + if ( $event->post_content !== null ): + if ( $event->post_status == 'publish' ): + $output .= __( 'Recap', 'sportspress' ); + else: + $output .= __( 'Preview', 'sportspress' ); + endif; + endif; + + $output .= '
+
'; + +if ( $id && $show_all_events_link ) + $output .= '' . __( 'View all events', 'sportspress' ) . ''; + +$output .= '
'; + +echo apply_filters( 'sportspress_event_list', $output ); diff --git a/templates/event-performance.php b/templates/event-performance.php new file mode 100644 index 00000000..c7f939e9 --- /dev/null +++ b/templates/event-performance.php @@ -0,0 +1,121 @@ + $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 .= '

' . get_the_title( $team_id ) . '

'; + + $output .= '
' . + '' . '' . ''; + + $output .= ''; + $output .= ''; + + foreach( $performance_labels as $key => $label ): + $output .= ''; + endforeach; + + $output .= '' . '' . ''; + + $i = 0; + + foreach( $data as $player_id => $row ): + + if ( ! $player_id ) + continue; + + $name = get_the_title( $player_id ); + + if ( ! $name ) + continue; + + $output .= ''; + + $number = get_post_meta( $player_id, 'sp_number', true ); + + // Player number + $output .= ''; + + if ( $link_posts ): + $permalink = get_post_permalink( $player_id ); + $name = '' . $name . ''; + endif; + + $output .= ''; + + 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 .= ''; + endforeach; + + $output .= ''; + + $i++; + + endforeach; + + $output .= ''; + + if ( array_key_exists( 0, $data ) ): + + $output .= ''; + + $number = get_post_meta( $player_id, 'sp_number', true ); + + // Player number + $output .= ''; + $output .= ''; + + $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 .= ''; + endforeach; + + $output .= ''; + + endif; + + $output .= '
#' . __( 'Player', 'sportspress' ) . '' . $label . '
' . $number . '' . $name . '' . $value . '
 ' . __( 'Total', 'sportspress' ) . '' . $value . '
' . '
'; + +endforeach; + +echo apply_filters( 'sportspress_event_performance', $output ); diff --git a/templates/event-results.php b/templates/event-results.php new file mode 100644 index 00000000..713b67c1 --- /dev/null +++ b/templates/event-results.php @@ -0,0 +1,66 @@ + $result ): + if ( sportspress_array_value( $result, 'outcome', '-1' ) != '-1' ): + + unset( $result['outcome'] ); + + $table_rows .= ''; + + $table_rows .= '' . get_the_title( $team_id ) . ''; + + 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 .= '' . $value . ''; + endforeach; + + $table_rows .= ''; + + $i++; + + endif; +endforeach; + +if ( empty( $table_rows ) ): + + return false; + +else: + + $output .= '

' . __( 'Results', 'sportspress' ) . '

'; + + $output .= '
' . + '' . + ''; + foreach( $result_labels as $key => $label ): + $output .= ''; + endforeach; + $output .= '' . '' . ''; + $output .= $table_rows; + $output .= '' . '
' . __( 'Team', 'sportspress' ) . '' . $label . '
' . '
'; + +endif; + +echo $output; diff --git a/templates/event-staff.php b/templates/event-staff.php new file mode 100644 index 00000000..0605b48f --- /dev/null +++ b/templates/event-staff.php @@ -0,0 +1,8 @@ +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 .= '

' . __( 'Venue', 'sportspress' ) . '

'; + $output .= '

' . $venue->name . '
' . $address . '

'; + if ( $latitude != null && $longitude != null ) + $output .= '
'; + +endforeach; + +echo apply_filters( 'sportspress_event_venue', $output ); diff --git a/templates/league-table.php b/templates/league-table.php new file mode 100644 index 00000000..c126b87a --- /dev/null +++ b/templates/league-table.php @@ -0,0 +1,90 @@ + 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 = '
' . + '' . '' . ''; + +$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 .= ''; + +foreach( $labels as $key => $label ): + if ( ! is_array( $columns ) || $key == 'name' || in_array( $key, $columns ) ) + $output .= ''; +endforeach; + +$output .= '' . '' . ''; + +$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 .= ''; + + // Rank + $output .= ''; + + 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 = '' . $name . ''; + endif; + + $output .= ''; + + foreach( $labels as $key => $value ): + if ( $key == 'name' ) + continue; + if ( ! is_array( $columns ) || in_array( $key, $columns ) ) + $output .= ''; + endforeach; + + $output .= ''; + + $i++; + +endforeach; + +$output .= '' . '
' . __( 'Pos', 'sportspress' ) . '' . $label . '
' . ( $i + 1 ) . '' . $name . '' . sportspress_array_value( $row, $key, '—' ) . '
'; + +if ( $show_full_table_link ) + $output .= '' . __( 'View full table', 'sportspress' ) . ''; + +$output .= '
'; + +echo $output; diff --git a/templates/player-gallery.php b/templates/player-gallery.php new file mode 100644 index 00000000..fbddcf44 --- /dev/null +++ b/templates/player-gallery.php @@ -0,0 +1,133 @@ + 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 = " + "; +$size_class = sanitize_html_class( $size ); +$gallery_div = "\n"; + +if ( $show_all_players_link ) + $output .= '' . __( 'View all players', 'sportspress' ) . ''; + +echo apply_filters( 'sportspress_player_gallery', $output ); diff --git a/templates/player-league-performance.php b/templates/player-league-performance.php new file mode 100644 index 00000000..628f39c9 --- /dev/null +++ b/templates/player-league-performance.php @@ -0,0 +1,48 @@ +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 = '

' . $league->name . '

' . + '
' . + '' . '' . ''; + +foreach( $labels as $key => $label ): + $output .= ''; +endforeach; + +$output .= '' . '' . ''; + +$i = 0; + +foreach( $data as $season_id => $row ): + + $output .= ''; + + foreach( $labels as $key => $value ): + $output .= ''; + endforeach; + + $output .= ''; + + $i++; + +endforeach; + +$output .= '' . '
' . $label . '
' . sportspress_array_value( $row, $key, '—' ) . '
' . '
'; + +echo apply_filters( 'sportspress_player_league_performance', $output ); diff --git a/templates/player-list.php b/templates/player-list.php new file mode 100644 index 00000000..f6061e5e --- /dev/null +++ b/templates/player-list.php @@ -0,0 +1,102 @@ + 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 = '
' . + '' . '' . ''; + +$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 .= ''; +else: + $output .= ''; +endif; + +foreach( $labels as $key => $label ): + if ( ! is_array( $performance ) || $key == 'name' || in_array( $key, $performance ) ) + $output .= ''; +endforeach; + +$output .= '' . '' . ''; + +$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 .= ''; + + // Rank or number + if ( isset( $orderby ) && $orderby != 'number' ): + $output .= ''; + else: + $number = get_post_meta( $player_id, 'sp_number', true ); + $output .= ''; + endif; + + if ( $link_posts ): + $permalink = get_post_permalink( $player_id ); + $name = '' . $name . ''; + endif; + + $output .= ''; + + foreach( $labels as $key => $value ): + if ( $key == 'name' ) + continue; + if ( ! is_array( $performance ) || in_array( $key, $performance ) ) + $output .= ''; + endforeach; + + $output .= ''; + + $i++; + +endforeach; + +$output .= '' . '
#' . __( 'Rank', 'sportspress' ) . ''. $label . '
' . ( $i + 1 ) . '' . ( $number ? $number : ' ' ) . '' . $name . '' . sportspress_array_value( $row, $key, '—' ) . '
' . '
'; + +if ( $show_all_players_link ) + $output .= '' . __( 'View all players', 'sportspress' ) . ''; + +echo apply_filters( 'sportspress_player_list', $output ); diff --git a/templates/player-metrics.php b/templates/player-metrics.php new file mode 100644 index 00000000..82973632 --- /dev/null +++ b/templates/player-metrics.php @@ -0,0 +1,50 @@ + 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 ? '' . $nationality . ' ' : '' ) . $country_name : '—'; +endif; + +$data = array_merge( $common, $metrics ); + +if ( $current_team ) + $data[ __( 'Current Team', 'sportspress' ) ] = '' . get_the_title( $current_team ) . ''; + +if ( $past_teams ): + $teams = array(); + foreach ( $past_teams as $team ): + $teams[] = '' . get_the_title( $team ) . ''; + endforeach; + $data[ __( 'Past Teams', 'sportspress' ) ] = implode( ', ', $teams ); +endif; + +$output = '
' . + '
'; + +foreach( $data as $label => $value ): + + $output .= '
' . $label . '
' . $value . '
'; + +endforeach; + +$output .= '
'; + +echo apply_filters( 'sportspress_player_metrics', $output ); diff --git a/templates/player-performance.php b/templates/player-performance.php new file mode 100644 index 00000000..a6dcf377 --- /dev/null +++ b/templates/player-performance.php @@ -0,0 +1,14 @@ + $league + ) ); + endforeach; +endif; diff --git a/templates/player-roster.php b/templates/player-roster.php new file mode 100644 index 00000000..4abe05c6 --- /dev/null +++ b/templates/player-roster.php @@ -0,0 +1,97 @@ + 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 .= ''; + + // Rank or number + if ( isset( $r['orderby'] ) && $r['orderby'] != 'number' ): + $rows .= '' . ( $i + 1 ) . ''; + else: + $number = get_post_meta( $player_id, 'sp_number', true ); + $rows .= '' . ( $number ? $number : ' ' ) . ''; + endif; + + // Name as link + $permalink = get_post_permalink( $player_id ); + $name = sportspress_array_value( $row, 'name', sportspress_array_value( $row, 'name', ' ' ) ); + $rows .= '' . '' . $name . ''; + + foreach( $labels as $key => $value ): + if ( $key == 'name' ) + continue; + if ( ! is_array( $performance ) || in_array( $key, $performance ) ) + $rows .= '' . sportspress_array_value( $row, $key, '—' ) . ''; + endforeach; + + $rows .= ''; + + $i++; + + endforeach; + + if ( ! empty( $rows ) ): + $output .= '

' . $position->name . '

'; + $output .= '
' . + '' . '' . ''; + if ( in_array( $r['orderby'], array( 'number', 'name' ) ) ): + $output .= ''; + else: + $output .= ''; + endif; + + foreach( $labels as $key => $label ): + if ( ! is_array( $performance ) || $key == 'name' || in_array( $key, $performance ) ) + $output .= ''; + endforeach; + $output .= '' . '' . '' . $rows . '' . '
#' . __( 'Rank', 'sportspress' ) . ''. $label . '
' . '
'; + endif; + +endforeach; + +echo apply_filters( 'sportspress_player_roster', $output ); diff --git a/templates/team-columns.php b/templates/team-columns.php new file mode 100644 index 00000000..8d531cf6 --- /dev/null +++ b/templates/team-columns.php @@ -0,0 +1,57 @@ +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 .= '

' . $league->name . '

' . + '
' . + '' . '' . ''; + + foreach( $labels as $key => $label ): + $output .= ''; + endforeach; + + $output .= '' . '' . ''; + + $i = 0; + + foreach( $data as $season_id => $row ): + + $output .= ''; + + foreach( $labels as $key => $value ): + $output .= ''; + endforeach; + + $output .= ''; + + $i++; + + endforeach; + + $output .= '' . '
' . $label . '
' . sportspress_array_value( $row, $key, '—' ) . '
' . '
'; + + +endforeach; + +echo apply_filters( 'sportspress_team_columns', $output );