/** * Output the metabox */ public static function output($post) { $event = new SP_Event($post); list($labels, $columns, $stats, $teams) = $event->performance(true); $i = 0; foreach ($teams as $key => $team_id) { if (-1 == $team_id) { continue; } // Get results for players in the team $players = sp_array_between((array) get_post_meta($post->ID, 'sp_player', false), 0, $key); $players[] = -1; $data = sp_array_combine($players, sp_array_value($stats, $team_id, array())); // Determine if we need checkboxes if ('manual' == get_option('sportspress_event_performance_columns', 'auto') && $i == 0) { $has_checkboxes = true; } else { $has_checkboxes = false; } // Determine if we need extras if ('yes' == get_option('sportspress_event_show_extras', 'no')) { $show_extras = true; } else { $show_extras = false; } // Determine if we are splitting positions if ('yes' == get_option('sportspress_event_split_players_by_position', 'no')) { $split_positions = true; } else { $split_positions = false; } ?> <div> <?php if ($team_id) { ?> <p><strong><?php echo get_the_title($team_id); ?> </strong></p> <?php } elseif ($i) { ?> <br> <?php } ?> <?php self::table($labels, $columns, $data, $team_id, $has_checkboxes, $show_extras, $split_positions); ?> </div> <?php $i++; } }
/** * Output the metabox */ public static function output($post) { $event = new SP_Event($post); list($labels, $columns, $stats, $teams) = $event->performance(true); // Determine if we are splitting positions if ('yes' == get_option('sportspress_event_split_players_by_position', 'no')) { $split_positions = true; } else { $split_positions = false; } // Determine if we are splitting teams if ('yes' == get_option('sportspress_event_split_players_by_team', 'yes')) { $split_teams = true; } else { $split_teams = false; } // Determine if columns are auto or manual if ('manual' == get_option('sportspress_event_performance_columns', 'auto')) { $manual = true; } else { $manual = false; } // Determine if we need checkboxes if ($manual && $i == 0) { $has_checkboxes = true; } else { $has_checkboxes = false; } // Get positions $positions = array(); if (taxonomy_exists('sp_position')) { $args = array('hide_empty' => false, 'parent' => 0, 'include_children' => true); $positions = get_terms('sp_position', $args); } // Get status option if ('yes' == get_option('sportspress_event_show_status', 'yes')) { $status = true; } else { $status = false; } // Apply filters to labels $labels = apply_filters('sportspress_event_performance_labels_admin', $labels); self::tables($post->ID, $stats, $labels, $columns, $teams, $has_checkboxes, $split_positions, $split_teams, $positions, $status); }
/** * Output the metabox */ public static function output($post) { $event = new SP_Event($post); list($labels, $columns, $stats, $teams, $formats, $order) = $event->performance(true); if ('yes' == get_option('sportspress_event_performance_show_minutes', 'yes')) { $timeline = $event->timeline(true); } else { $timeline = false; } // Determine if columns are auto or manual if ('manual' == get_option('sportspress_event_performance_columns', 'auto')) { $manual = true; } else { $manual = false; } // Determine if we need checkboxes if ($manual) { $has_checkboxes = true; } else { $has_checkboxes = false; } // Get player number option $numbers = 'yes' == get_option('sportspress_event_show_player_numbers', 'yes') ? true : false; // Get positions $positions = array(); if ('yes' == get_option('sportspress_event_show_position', 'yes') && taxonomy_exists('sp_position')) { $args = array('hide_empty' => false, 'parent' => 0, 'include_children' => true); $positions = get_terms('sp_position', $args); } // Get status option if ('yes' == get_option('sportspress_event_show_status', 'yes')) { $status = true; } else { $status = false; } // Apply filters to labels $labels = apply_filters('sportspress_event_performance_labels_admin', $labels); // Check if individual mode $is_individual = get_option('sportspress_load_individual_mode_module', 'no') === 'yes' ? true : false; self::tables($post->ID, $stats, $labels, $columns, $teams, $has_checkboxes, $positions, $status, $formats, $order, $numbers, $is_individual, $timeline); }
/** * Output the metabox */ public static function output($post) { $event = new SP_Event($post); list($labels, $columns, $stats, $teams) = $event->performance(true); $i = 0; foreach ($teams as $key => $team_id) { if (-1 == $team_id) { continue; } // Get results for players in the team $players = sp_array_between((array) get_post_meta($post->ID, 'sp_player', false), 0, $key); $data = sp_array_combine($players, sp_array_value($stats, $team_id, array())); ?> <div> <?php if ($team_id) { ?> <p><strong><?php echo get_the_title($team_id); ?> </strong></p> <?php } elseif ($i) { ?> <br> <?php } ?> <?php self::table($labels, $columns, $data, $team_id, $i == 0); ?> </div> <?php $i++; } }
function sp_get_performance($post = 0) { $event = new SP_Event($post); return $event->performance(); }
if (!isset($id)) { $id = get_the_ID(); } $event = new SP_Event($id); // Return if no teams $teams = get_post_meta($id, 'sp_team', false); if (empty($teams)) { return; } // Return if no results $status = $event->status(); if ('results' !== $status) { return; } // Get performance $performance = $event->performance(); // The first row should be column labels $labels = apply_filters('sportspress_match_stats_labels', $performance[0]); // Remove position column label unset($labels['position']); // Create statistics template $template = array_fill_keys(array_flip($labels), 0); // Remove the first row to leave us with the actual data unset($performance[0]); // Remove empty teams from performance $performance = array_filter($performance); // Initialize statistics array $statistics = array(); // Loop through performance foreach ($performance as $team => $players) { // Continue if not a team