/** * Output the metabox */ public static function output($post) { $player = new SP_Player($post); $leagues = get_the_terms($post->ID, 'sp_league'); $league_num = sizeof($leagues); // Loop through statistics for each league if ($leagues) { $i = 0; foreach ($leagues as $league) { ?> <p><strong><?php echo $league->name; ?> </strong></p> <?php list($columns, $data, $placeholders, $merged, $seasons_teams) = $player->data($league->term_id, true); self::table($post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, $i == 0); $i++; } } ?> <p><strong><?php _e('Career Total', 'sportspress'); ?> </strong></p> <?php list($columns, $data, $placeholders, $merged, $seasons_teams) = $player->data(0, true); self::table($post->ID, 0, $columns, $data, $placeholders, $merged, $seasons_teams); }
/** * Output the metabox */ public static function output($post) { $player = new SP_Player($post); $leagues = get_the_terms($post->ID, 'sp_league'); $league_num = sizeof($leagues); $sections = get_option('sportspress_player_performance_sections', -1); if ($leagues) { if (-1 == $sections) { // Loop through statistics for each league $i = 0; foreach ($leagues as $league) { ?> <p><strong><?php echo $league->name; ?> </strong></p> <?php list($columns, $data, $placeholders, $merged, $seasons_teams, $has_checkboxes) = $player->data($league->term_id, true); self::table($post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, $has_checkboxes && $i == 0); $i++; } } else { // Determine order of sections if (1 == $sections) { $section_order = array(1 => __('Defense', 'sportspress'), 0 => __('Offense', 'sportspress')); } else { $section_order = array(__('Offense', 'sportspress'), __('Defense', 'sportspress')); } $s = 0; foreach ($section_order as $section_id => $section_label) { // Loop through statistics for each league $i = 0; foreach ($leagues as $league) { ?> <p><strong><?php echo $league->name; ?> — <?php echo $section_label; ?> </strong></p> <?php list($columns, $data, $placeholders, $merged, $seasons_teams, $has_checkboxes) = $player->data($league->term_id, true, $section_id); self::table($post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, $has_checkboxes && $i == 0 && $s == 0, $s == 0); $i++; } $s++; } } } }
exit; } // Exit if accessed directly if (get_option('sportspress_player_show_statistics', 'yes') === 'no') { return; } if (!isset($id)) { $id = get_the_ID(); } $player = new SP_Player($id); $scrollable = get_option('sportspress_enable_scrollable_tables', 'yes') == 'yes' ? true : false; $leagues = get_the_terms($id, 'sp_league'); // Loop through statistics for each league if (is_array($leagues)) { foreach ($leagues as $league) { $data = $player->data($league->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)) { continue; } $output = '<h4 class="sp-table-caption">' . $league->name . '</h4>' . '<div class="sp-table-wrapper">' . '<table class="sp-player-statistics sp-data-table' . ($scrollable ? ' sp-scrollable-table' : '') . '">' . '<thead>' . '<tr>'; foreach ($labels as $key => $label) { $output .= '<th class="data-' . $key . '">' . $label . '</th>'; } $output .= '</tr>' . '</thead>' . '<tbody>'; $i = 0; foreach ($data as $season_id => $row) {
$player_sections = array_merge($player_sections, sp_get_term_sections($position->term_id)); } } // Determine order of sections if (1 == $sections) { $section_order = array(1 => __('Defense', 'sportspress'), 0 => __('Offense', 'sportspress')); } elseif (0 == $sections) { $section_order = array(__('Offense', 'sportspress'), __('Defense', 'sportspress')); } else { $section_order = array(-1 => null); } // Loop through statistics for each league if (is_array($leagues)) { foreach ($section_order as $section_id => $section_label) { if (-1 !== $section_id && !empty($player_sections) && !in_array($section_id, $player_sections)) { continue; } if (sizeof($leagues) > 1) { printf('<h3 class="sp-post-caption sp-player-statistics-section">%s</h3>', $section_label); } foreach ($leagues as $league) { $caption = $league->name; if (null !== $section_label) { if (sizeof($leagues) === 1) { $caption = $section_label; } } sp_get_template('player-statistics-league.php', array('data' => $player->data($league->term_id, false, $section_id), 'league' => $league, 'caption' => $caption, 'scrollable' => $scrollable)); } } }
$section_order = array(1 => __('Defense', 'sportspress'), 0 => __('Offense', 'sportspress')); } elseif (0 == $sections) { $section_order = array(__('Offense', 'sportspress'), __('Defense', 'sportspress')); } else { $section_order = array(-1 => null); } // Loop through statistics for each league if (is_array($leagues)) { foreach ($section_order as $section_id => $section_label) { if (-1 !== $section_id && !empty($player_sections) && !in_array($section_id, $player_sections)) { continue; } if (sizeof($leagues) > 1) { printf('<h3 class="sp-post-caption sp-player-statistics-section">%s</h3>', $section_label); } foreach ($leagues as $league) { $caption = $league->name; if (null !== $section_label) { if (sizeof($leagues) === 1) { $caption = $section_label; } } $args = array('data' => $player->data($league->term_id, false, $section_id), 'caption' => $caption, 'scrollable' => $scrollable); if (!$show_teams) { $args['hide_teams'] = true; } sp_get_template('player-statistics-league.php', $args); } sp_get_template('player-statistics-league.php', array('data' => $player->data(0, false, $section_id), 'caption' => __('Career Total', 'sportspress'), 'scrollable' => $scrollable, 'hide_teams' => true)); } }