diff --git a/assets/css/admin.css b/assets/css/admin.css
index 3f5eb4d8..73a6fcd2 100644
--- a/assets/css/admin.css
+++ b/assets/css/admin.css
@@ -24,6 +24,10 @@
content: "\f334";
}
+.post-state-format.post-format-standings:before, .post-format-icon.post-format-standings:before, a.post-state-format.format-standings:before {
+ content: "\f185";
+}
+
.post-state-format.post-format-list:before, .post-format-icon.post-format-list:before, a.post-state-format.format-list:before {
content: "\f163";
}
diff --git a/assets/css/sportspress.css b/assets/css/sportspress.css
index dfde8ea2..b3432ab1 100644
--- a/assets/css/sportspress.css
+++ b/assets/css/sportspress.css
@@ -191,6 +191,11 @@
max-height: 2em;
}
+/* Team Gallery */
+.sp-template-team-gallery img {
+ padding: 1em;
+}
+
/* Player List */
.sp-player-list td {
line-height: 2em;
diff --git a/assets/js/admin/editor-lang.php b/assets/js/admin/editor-lang.php
index 6aee3108..d46119de 100644
--- a/assets/js/admin/editor-lang.php
+++ b/assets/js/admin/editor-lang.php
@@ -6,6 +6,7 @@ $options = array(
'event' => array(
'details', 'results', 'performance'
),
+ 'team' => array(),
'player' => array(
'details', 'statistics'
),
@@ -14,6 +15,7 @@ $options = array(
$options = apply_filters( 'sportspress_shortcodes', $options );
foreach ( $options as $name => $group ) {
+ if ( empty( $group ) ) continue;
$shortcodes .= $name . '[' . implode( '|', $group ) . ']';
}
@@ -30,7 +32,8 @@ $raw = apply_filters( 'sportspress_tinymce_strings', array(
'performance' => __( 'Box Score', 'sportspress' ),
'calendar' => __( 'Calendar', 'sportspress' ),
'statistics' => __( 'Statistics', 'sportspress' ),
- 'table' => __( 'League Table', 'sportspress' ),
+ 'team' => __( 'Team', 'sportspress' ),
+ 'standings' => __( 'League Table', 'sportspress' ),
'player' => __( 'Player', 'sportspress' ),
'list' => __( 'List', 'sportspress' ),
'blocks' => __( 'Blocks', 'sportspress' ),
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-format.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-format.php
new file mode 100644
index 00000000..df667141
--- /dev/null
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-format.php
@@ -0,0 +1,39 @@
+ID, 'sp_format', true );
+ ?>
+
+
@@ -971,7 +971,7 @@ class SP_AJAX {
args.orderby = $div.find('[name=orderby]').val();
args.order = $div.find('[name=order]').val();
args.show_all_events_link = $div.find('[name=show_all_events_link]:checked').length;
- } else if ( 'league_table' == type ) {
+ } else if ( 'team_standings' == type ) {
args.title = $div.find('[name=title]').val();
args.number = $div.find('[name=number]').val();
args.columns = $div.find('[name="columns[]"]:checked').map(function() { return this.value; }).get().join(',');
diff --git a/includes/class-sp-formats.php b/includes/class-sp-formats.php
index 50208c95..f3423863 100644
--- a/includes/class-sp-formats.php
+++ b/includes/class-sp-formats.php
@@ -32,6 +32,10 @@ class SP_Formats {
'list' => __( 'List', 'sportspress' ),
'blocks' => __( 'Blocks', 'sportspress' ),
),
+ 'table' => array(
+ 'standings' => __( 'Standings', 'sportspress' ),
+ 'gallery' => __( 'Gallery', 'sportspress' ),
+ ),
'list' => array(
'list' => __( 'List', 'sportspress' ),
'gallery' => __( 'Gallery', 'sportspress' ),
diff --git a/includes/class-sp-shortcodes.php b/includes/class-sp-shortcodes.php
index 081a687e..f135efef 100644
--- a/includes/class-sp-shortcodes.php
+++ b/includes/class-sp-shortcodes.php
@@ -16,19 +16,21 @@ class SP_Shortcodes {
public static function init() {
// Define shortcodes
$shortcodes = array(
- 'event_results' => __CLASS__ . '::event_results',
- 'event_details' => __CLASS__ . '::event_details',
- 'event_performance' => __CLASS__ . '::event_performance',
- 'countdown' => __CLASS__ . '::countdown',
- 'player_details' => __CLASS__ . '::player_details',
- 'player_statistics' => __CLASS__ . '::player_statistics',
- 'staff' => __CLASS__ . '::staff',
- 'event_calendar' => __CLASS__ . '::event_calendar',
- 'event_list' => __CLASS__ . '::event_list',
- 'event_blocks' => __CLASS__ . '::event_blocks',
- 'league_table' => __CLASS__ . '::league_table',
- 'player_list' => __CLASS__ . '::player_list',
- 'player_gallery' => __CLASS__ . '::player_gallery',
+ 'event_results' => __CLASS__ . '::event_results',
+ 'event_details' => __CLASS__ . '::event_details',
+ 'event_performance' => __CLASS__ . '::event_performance',
+ 'countdown' => __CLASS__ . '::countdown',
+ 'player_details' => __CLASS__ . '::player_details',
+ 'player_statistics' => __CLASS__ . '::player_statistics',
+ 'staff' => __CLASS__ . '::staff',
+ 'event_calendar' => __CLASS__ . '::event_calendar',
+ 'event_list' => __CLASS__ . '::event_list',
+ 'event_blocks' => __CLASS__ . '::event_blocks',
+ 'league_table' => __CLASS__ . '::league_table',
+ 'team_standings' => __CLASS__ . '::league_table',
+ 'team_gallery' => __CLASS__ . '::team_gallery',
+ 'player_list' => __CLASS__ . '::player_list',
+ 'player_gallery' => __CLASS__ . '::player_gallery',
);
foreach ( $shortcodes as $shortcode => $function ) {
@@ -144,7 +146,7 @@ class SP_Shortcodes {
}
/**
- * League table shortcode.
+ * League table (team standings) shortcode.
*
* @access public
* @param mixed $atts
@@ -154,6 +156,17 @@ class SP_Shortcodes {
return self::shortcode_wrapper( array( 'SP_Shortcode_League_Table', 'output' ), $atts );
}
+ /**
+ * Team gallery shortcode.
+ *
+ * @access public
+ * @param mixed $atts
+ * @return string
+ */
+ public static function team_gallery( $atts ) {
+ return self::shortcode_wrapper( array( 'SP_Shortcode_Team_Gallery', 'output' ), $atts );
+ }
+
/**
* Player details shortcode.
*
diff --git a/includes/shortcodes/class-sp-shortcode-team-gallery.php b/includes/shortcodes/class-sp-shortcode-team-gallery.php
new file mode 100644
index 00000000..56aea69c
--- /dev/null
+++ b/includes/shortcodes/class-sp-shortcode-team-gallery.php
@@ -0,0 +1,24 @@
+formats->table ) && 'standings' !== $format )
+ sp_get_template( 'team-' . $format . '.php', array( 'id' => $id ) );
+ else
+ sp_get_template( 'league-table.php', array( 'id' => $id ) );
}
}
diff --git a/modules/sportspress-league-tables.php b/modules/sportspress-league-tables.php
index 9f56525e..876605ae 100644
--- a/modules/sportspress-league-tables.php
+++ b/modules/sportspress-league-tables.php
@@ -185,6 +185,13 @@ class SportsPress_League_Tables {
'context' => 'side',
'priority' => 'default',
),
+ 'format' => array(
+ 'title' => __( 'Layout', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Table_Format::save',
+ 'output' => 'SP_Meta_Box_Table_Format::output',
+ 'context' => 'side',
+ 'priority' => 'default',
+ ),
'details' => array(
'title' => __( 'Details', 'sportspress' ),
'save' => 'SP_Meta_Box_Table_Details::save',
@@ -209,7 +216,8 @@ class SportsPress_League_Tables {
* @return array
*/
public function add_shortcodes( $shortcodes ) {
- $shortcodes['table'] = array( 'table' );
+ $shortcodes['team'][] = 'standings';
+ $shortcodes['team'][] = 'gallery';
return $shortcodes;
}
diff --git a/presets/target-sports/golf.json b/presets/target-sports/golf.json
index e844d7a1..ed4c1966 100644
--- a/presets/target-sports/golf.json
+++ b/presets/target-sports/golf.json
@@ -7,12 +7,12 @@
{ "name" : "Finish", "condition" : "else", "description" : "Finished" }
],
"results": [
- { "name" : "Score", "equation" : "$strokes", "description" : "Total score" },
+ { "name" : "Par", "equation" : "$strokes - $par", "description" : "Reported score", "primary" : 1 },
{ "name" : "FH", "description" : "Fairways hit" },
{ "name" : "GIR", "description" : "Greens in regulation" },
{ "name" : "Avg. Drive", "id" : "avgdrive", "description" : "Average drive (yards)" },
{ "name" : "Putts", "description" : "Number of putts" },
- { "name" : "Par", "equation" : "$strokes - $par", "description" : "Reported score", "primary" : 1 }
+ { "name" : "Score", "equation" : "$strokes", "description" : "Total score" }
],
"performance": [
{ "name" : "1", "id" : "one", "description" : "Hole 1" },
diff --git a/templates/event-results.php b/templates/event-results.php
index fa8e5935..c15a4f8c 100644
--- a/templates/event-results.php
+++ b/templates/event-results.php
@@ -23,9 +23,6 @@ if ( ! isset( $caption ) ) $caption = __( 'Results', 'sportspress' );
// Get event result data
$data = $event->results();
-// Apply filters to results data
-$data = apply_filters( 'sportspress_event_results', $data, $id );
-
// The first row should be column labels
$labels = $data[0];
diff --git a/templates/team-gallery-thumbnail.php b/templates/team-gallery-thumbnail.php
new file mode 100644
index 00000000..df577a78
--- /dev/null
+++ b/templates/team-gallery-thumbnail.php
@@ -0,0 +1,41 @@
+ null,
+ 'icontag' => 'dt',
+ 'captiontag' => 'dd',
+ 'caption' => null,
+ 'size' => 'sportspress-crop-medium',
+ 'link_posts' => get_option( 'sportspress_link_teams', 'yes' ) == 'yes' ? true : false,
+);
+
+extract( $defaults, EXTR_SKIP );
+
+// Add caption tag if has caption
+if ( $captiontag && $caption )
+ $caption = '<' . $captiontag . ' class="wp-caption-text gallery-caption small-3 columns">' . wptexturize( $caption ) . '' . $captiontag . '>';
+
+if ( $link_posts )
+ $caption = '
' . $caption . '';
+
+if ( has_post_thumbnail( $id ) )
+ $thumbnail = get_the_post_thumbnail( $id, $size );
+else
+ $thumbnail = '

';
+
+echo "<{$itemtag} class='gallery-item'>";
+echo "
+ <{$icontag} class='gallery-icon portrait'>"
+ . '
' . $thumbnail . ''
+ . "{$icontag}>";
+echo $caption;
+echo "{$itemtag}>";
diff --git a/templates/team-gallery.php b/templates/team-gallery.php
new file mode 100644
index 00000000..5811d590
--- /dev/null
+++ b/templates/team-gallery.php
@@ -0,0 +1,160 @@
+ get_the_ID(),
+ 'title' => false,
+ 'number' => -1,
+ 'orderby' => 'default',
+ 'order' => 'ASC',
+ 'itemtag' => 'dl',
+ 'icontag' => 'dt',
+ 'captiontag' => 'dd',
+ 'columns' => 3,
+ 'size' => 'sportspress-crop-medium',
+ 'show_all_teams_link' => false,
+ 'link_posts' => get_option( 'sportspress_link_teams', 'yes' ) == 'yes' ? true : false,
+);
+
+extract( $defaults, EXTR_SKIP );
+
+// Determine number of teams to display
+if ( -1 === $number ):
+ $number = (int) get_post_meta( $id, 'sp_number', true );
+ if ( $number <= 0 ) $number = -1;
+endif;
+
+$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-team-gallery-' . $id;
+
+$table = new SP_League_Table( $id );
+$data = $table->data();
+
+// Remove the first row to leave us with the actual data
+unset( $data[0] );
+
+if ( $orderby == 'default' ):
+ $orderby = $table->orderby;
+ $order = $table->order;
+elseif ( $orderby == 'rand' ):
+ uasort( $data, 'sp_sort_random' );
+else:
+ $table->priorities = array(
+ array(
+ 'key' => $orderby,
+ 'order' => $order,
+ ),
+ );
+ uasort( $data, array( $table, 'sort' ) );
+endif;
+
+if ( $title )
+ echo '
' . $title . '
';
+
+$gallery_style = $gallery_div = '';
+if ( apply_filters( 'use_default_gallery_style', ! $html5 ) )
+ $gallery_style = "
+ ";
+$size_class = sanitize_html_class( $size );
+$gallery_div = "
";
+echo apply_filters( 'gallery_style', $gallery_style . "\n\t\t" );
+?>
+
+ 0 )
+ $limit = $number;
+
+ $i = 0;
+
+ $gallery = '';
+
+ foreach( $data as $team_id => $row ):
+
+ if ( isset( $limit ) && $i >= $limit ) continue;
+
+ $caption = get_the_title( $team_id );
+ $caption = trim( $caption );
+
+ ob_start();
+
+ sp_get_template( 'team-gallery-thumbnail.php', array(
+ 'id' => $team_id,
+ 'itemtag' => $itemtag,
+ 'icontag' => $icontag,
+ 'captiontag' => $captiontag,
+ 'caption' => $caption,
+ 'size' => $size,
+ 'link_posts' => $link_posts,
+ ) );
+
+ $gallery .= ob_get_clean();
+
+ $i++;
+
+ endforeach;
+
+ echo '
';
+
+ echo '
';
+
+ echo $gallery;
+
+ if ( ! $html5 && $columns > 0 && ++$i % $columns == 0 ) {
+ echo '
';
+ }
+
+ echo '
';
+
+ if ( $show_all_teams_link ) {
+ echo '
';
+ }
+
+ echo '
';
+
+ if ( ! $html5 && $columns > 0 && ++$i % $columns == 0 ) {
+ echo '
';
+ }
+
+echo "
\n";
+?>
\ No newline at end of file