get_the_ID(), 'title' => false, 'number' => -1, 'grouptag' => 'h4', 'columns' => null, 'grouping' => null, 'orderby' => 'default', 'order' => 'ASC', 'show_all_players_link' => false, 'show_title' => get_option( 'sportspress_list_show_title', 'yes' ) == 'yes' ? true : false, 'show_player_photo' => get_option( 'sportspress_list_show_photos', 'no' ) == 'yes' ? true : false, 'show_player_flag' => get_option( 'sportspress_list_show_flags', 'no' ) == 'yes' ? true : false, 'link_posts' => get_option( 'sportspress_link_players', 'yes' ) == 'yes' ? true : false, 'link_teams' => get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false, 'sortable' => get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false, 'scrollable' => get_option( 'sportspress_enable_scrollable_tables', 'yes' ) == 'yes' ? true : false, 'paginated' => get_option( 'sportspress_list_paginated', 'yes' ) == 'yes' ? true : false, 'rows' => get_option( 'sportspress_list_rows', 10 ), ); extract( $defaults, EXTR_SKIP ); // Backward compatibility if ( isset( $performance ) ) $columns = $performance; // Explode into array if ( null !== $columns && ! is_array( $columns ) ) $columns = explode( ',', $columns ); $list = new SP_Player_List( $id ); if ( isset( $columns ) && null !== $columns ): $list->columns = $columns; endif; $data = $list->data(); // 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 ( $grouping === null || $grouping === 'default' ): $grouping = $list->grouping; endif; if ( $orderby == 'default' ): $orderby = $list->orderby; $order = $list->order; else: $list->priorities = array( array( 'key' => $orderby, 'order' => $order, ), ); uasort( $data, array( $list, 'sort' ) ); endif; $output = ''; if ( $grouping === 'position' ): $groups = get_terms( 'sp_position', array( 'orderby' => 'slug' ) ); else: if ( $show_title && false === $title && $id ): $caption = $list->caption; if ( $caption ) $title = $caption; else $title = get_the_title( $id ); endif; if ( $title ) $output .= '<' . $grouptag . ' class="sp-table-caption">' . $title . '' . $grouptag . '>'; $group = new stdClass(); $group->term_id = null; $group->name = null; $group->slug = null; $groups = array( $group ); endif; foreach ( $groups as $group ): $output .= '
| # | '; else: $output .= '' . __( 'Rank', 'sportspress' ) . ' | '; endif; endif; foreach( $labels as $key => $label ): if ( $key !== 'number' && ( ! is_array( $columns ) || $key == 'name' || in_array( $key, $columns ) ) ) $output .= ''. $label . ' | '; endforeach; $output .= '|||
|---|---|---|---|---|---|
| ' . ( $i + 1 ) . ' | '; else: $output .= '' . sp_array_value( $row, 'number', ' ' ) . ' | '; endif; endif; $name_class = ''; if ( $show_player_photo ): if ( has_post_thumbnail( $player_id ) ): $logo = get_the_post_thumbnail( $player_id, 'sportspress-fit-icon' ); $name = '' . $logo . '' . $name; $name_class .= ' has-photo'; endif; endif; if ( $show_player_flag ): $player = new SP_Player( $player_id ); $nationalities = $player->nationalities(); if ( ! empty( $nationalities ) ): foreach ( $nationalities as $nationality ): $name = '' . $name . ' | '; if ( array_key_exists( 'team', $labels ) ): $team = sp_array_value( $row, 'team', get_post_meta( $id, 'sp_team', true ) ); $team_name = get_the_title( $team ); if ( $link_teams ): $team_name = '' . $team_name . ''; endif; $output .= '' . $team_name . ' | '; endif; if ( array_key_exists( 'position', $labels ) ): $position = sp_array_value( $row, 'position', null ); if ( null === $position || ! $position ): $positions = wp_strip_all_tags( get_the_term_list( $player_id, 'sp_position', '', ', ' ) ); else: $position_term = get_term_by( 'id', $position, 'sp_position', ARRAY_A ); $positions = sp_array_value( $position_term, 'name', '—' ); endif; $output .= '' . $positions . ' | '; endif; foreach( $labels as $key => $value ): if ( in_array( $key, array( 'number', 'name', 'team', 'position' ) ) ) continue; if ( ! is_array( $columns ) || in_array( $key, $columns ) ) $output .= '' . sp_array_value( $row, $key, '—' ) . ' | '; endforeach; $output .= '