diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-details.php index 7425b088..83327faa 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-details.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-details.php @@ -22,6 +22,7 @@ class SP_Meta_Box_List_Details { $league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 ); $season_id = sp_get_the_term_id( $post->ID, 'sp_season', 0 ); $team_id = get_post_meta( $post->ID, 'sp_team', true ); + $grouping = get_post_meta( $post->ID, 'sp_grouping', true ); $orderby = get_post_meta( $post->ID, 'sp_orderby', true ); $order = get_post_meta( $post->ID, 'sp_order', true ); ?> @@ -69,6 +70,13 @@ class SP_Meta_Box_List_Details { endif; ?>

+

+

+ +

$orderby, 'values' => 'slug', ); - if ( ! sp_dropdown_pages( $args ) ): - sp_post_adder( 'sp_list', __( 'Add New', 'sportspress' ) ); - endif; + sp_dropdown_pages( $args ); ?>

@@ -110,6 +116,7 @@ class SP_Meta_Box_List_Details { update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) ); wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_league', 0 ), 'sp_league' ); wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_season', 0 ), 'sp_season' ); + update_post_meta( $post_id, 'sp_grouping', sp_array_value( $_POST, 'sp_grouping', array() ) ); update_post_meta( $post_id, 'sp_orderby', sp_array_value( $_POST, 'sp_orderby', array() ) ); update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', array() ) ); sp_update_post_meta_recursive( $post_id, 'sp_player', sp_array_value( $_POST, 'sp_player', array() ) ); diff --git a/templates/player-gallery-thumbnail.php b/templates/player-gallery-thumbnail.php new file mode 100644 index 00000000..badf6a81 --- /dev/null +++ b/templates/player-gallery-thumbnail.php @@ -0,0 +1,50 @@ + null, + 'performance' => array(), + 'icontag' => 'dt', + 'captiontag' => 'dd', + 'caption' => null, + 'size' => 'thumbnail', + 'link_posts' => get_option( 'sportspress_list_link_players', 'yes' ) == 'yes' ? true : false, +); + +extract( $defaults, EXTR_SKIP ); + +// Add player number to caption if available +$player_number = get_post_meta( $id, 'sp_number', true ); +if ( $player_number ) + $caption = '' . $player_number . ' ' . $caption; + +// Add caption tag if has caption +if ( $captiontag && $caption ) + $caption = '<' . $captiontag . ' class="wp-caption-text gallery-caption small-3 columns">' . wptexturize( $caption ) . ''; + +if ( $link_posts ) + $caption = '' . $caption . ''; + +if ( isset( $limit ) && $i >= $limit ) + continue; + +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 . '' + . ""; +echo $caption; +echo ""; diff --git a/templates/player-gallery.php b/templates/player-gallery.php index d45554f2..992044db 100644 --- a/templates/player-gallery.php +++ b/templates/player-gallery.php @@ -12,6 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly $defaults = array( 'id' => get_the_ID(), 'number' => -1, + 'grouping' => null, 'orderby' => 'default', 'order' => 'ASC', 'itemtag' => 'dl', @@ -52,7 +53,14 @@ $labels = $data[0]; // Remove the first row to leave us with the actual data unset( $data[0] ); -if ( $orderby != 'default' ): +if ( ! $grouping || $grouping == 'default' ): + $grouping = $list->grouping; +endif; + +if ( $orderby == 'default' ): + $orderby = $list->orderby; + $order = $list->order; +else: $list->priorities = array( array( 'key' => $orderby, @@ -85,54 +93,50 @@ if ( apply_filters( 'use_default_gallery_style', true ) ) "; $size_class = sanitize_html_class( $size ); $gallery_div = "\n"; + +echo "\n"; if ( $show_all_players_link ) - $output .= '' . SP()->text->string('View all players') . ''; - -echo apply_filters( 'sportspress_player_gallery', $output ); + echo '' . SP()->text->string('View all players') . ''; diff --git a/templates/player-list.php b/templates/player-list.php index 754e8108..48afb228 100644 --- a/templates/player-list.php +++ b/templates/player-list.php @@ -13,6 +13,7 @@ $defaults = array( 'id' => get_the_ID(), 'number' => -1, 'performance' => null, + 'grouping' => null, 'orderby' => 'default', 'order' => 'ASC', 'show_all_players_link' => false, @@ -25,9 +26,6 @@ $defaults = array( extract( $defaults, EXTR_SKIP ); -$output = '
' . - '' . '' . ''; - $list = new SP_Player_List( $id ); $data = $list->data(); @@ -37,7 +35,14 @@ $labels = $data[0]; // Remove the first row to leave us with the actual data unset( $data[0] ); -if ( $orderby != 'default' ): +if ( ! $grouping || $grouping == 'default' ): + $grouping = $list->grouping; +endif; + +if ( $orderby == 'default' ): + $orderby = $list->orderby; + $order = $list->order; +else: $list->priorities = array( array( 'key' => $orderby, @@ -47,61 +52,82 @@ if ( $orderby != 'default' ): uasort( $data, array( $list, 'sort' ) ); endif; -if ( in_array( $orderby, array( 'number', 'name' ) ) ): - $output .= ''; +if ( $grouping == 'position' ): + $groups = get_terms( 'sp_position' ); else: - $output .= ''; + $group = new stdClass(); + $group->term_id = null; + $group->name = null; + $group->slug = null; + $groups = array( $group ); endif; -foreach( $labels as $key => $label ): - if ( ! is_array( $performance ) || $key == 'name' || in_array( $key, $performance ) ) - $output .= ''; -endforeach; +$output = ''; -$output .= '' . '' . ''; +foreach ( $groups as $group ): + if ( ! empty( $group->name ) ) + $output .= '

' . $group->name . '

'; -$i = 0; + $output .= '
' . + '
#' . SP()->text->string('Rank') . ''. $label . '
' . '' . ''; -if ( intval( $number ) > 0 ) - $limit = $number; - -foreach( $data as $player_id => $row ): - if ( isset( $limit ) && $i >= $limit ) continue; - - $name = sp_array_value( $row, 'name', null ); - if ( ! $name ) continue; - - $output .= ''; - - // Rank or number - if ( isset( $orderby ) && $orderby != 'number' ): - $output .= ''; + if ( in_array( $orderby, array( 'number', 'name' ) ) ): + $output .= ''; else: - $output .= ''; + $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 .= ''; + foreach( $labels as $key => $label ): + if ( ! is_array( $performance ) || $key == 'name' || in_array( $key, $performance ) ) + $output .= ''; endforeach; - $output .= ''; + $output .= '' . '' . ''; - $i++; + $i = 0; + if ( intval( $number ) > 0 ) + $limit = $number; + + foreach( $data as $player_id => $row ): if ( empty( $group->term_id ) || has_term( $group->term_id, 'sp_position', $player_id ) ): + + if ( isset( $limit ) && $i >= $limit ) continue; + + $name = sp_array_value( $row, 'name', null ); + if ( ! $name ) continue; + + $output .= ''; + + // Rank or number + if ( isset( $orderby ) && $orderby != 'number' ): + $output .= ''; + else: + $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++; + + endif; endforeach; + + $output .= '' . '
' . ( $i + 1 ) . '#' . sp_array_value( $row, 'number', ' ' ) . '' . SP()->text->string('Rank') . '' . $name . '' . sp_array_value( $row, $key, '—' ) . ''. $label . '
' . ( $i + 1 ) . '' . sp_array_value( $row, 'number', ' ' ) . '' . $name . '' . sp_array_value( $row, $key, '—' ) . '
' . '
'; endforeach; -$output .= '' . '' . ''; - if ( $show_all_players_link ) $output .= '' . SP()->text->string('View all players') . '';