-1, 'statistics' => null, 'orderby' => 'default', 'order' => 'ASC', 'show_all_players_link' => false, 'link_posts' => sportspress_array_value( $sportspress_options, 'player_list_link_posts', 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] ); $statistics = sportspress_array_value( $r, 'statistics', 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_statistic_priorities; $sportspress_statistic_priorities = array( array( 'statistic' => $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( $statistics ) || $key == 'name' || in_array( $key, $statistics ) ) $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( $statistics ) || in_array( $key, $statistics ) ) $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');