/**
  * Returns formatted data
  *
  * @access public
  * @param bool $admin
  * @return array
  */
 public function data($admin = false)
 {
     $league_ids = sp_get_the_term_ids($this->ID, 'sp_league');
     $season_ids = sp_get_the_term_ids($this->ID, 'sp_season');
     $table_stats = (array) get_post_meta($this->ID, 'sp_teams', true);
     $usecolumns = get_post_meta($this->ID, 'sp_columns', true);
     $adjustments = get_post_meta($this->ID, 'sp_adjustments', true);
     $select = get_post_meta($this->ID, 'sp_select', true);
     // Get labels from result variables
     $result_labels = (array) sp_get_var_labels('sp_result');
     // Get labels from outcome variables
     $outcome_labels = (array) sp_get_var_labels('sp_outcome');
     // Get teams automatically if set to auto
     if ('auto' == $select) {
         $team_ids = array();
         $args = array('post_type' => 'sp_team', 'numberposts' => -1, 'posts_per_page' => -1, 'order' => 'ASC', 'tax_query' => array('relation' => 'AND'));
         if ($league_ids) {
             $args['tax_query'][] = array('taxonomy' => 'sp_league', 'field' => 'id', 'terms' => $league_ids);
         }
         if ($season_ids) {
             $args['tax_query'][] = array('taxonomy' => 'sp_season', 'field' => 'id', 'terms' => $season_ids);
         }
         $teams = get_posts($args);
         if ($teams && is_array($teams)) {
             foreach ($teams as $team) {
                 $team_ids[] = $team->ID;
             }
         }
     } else {
         $team_ids = (array) get_post_meta($this->ID, 'sp_team', false);
     }
     // Get all leagues populated with stats where available
     $tempdata = sp_array_combine($team_ids, $table_stats);
     // Create entry for each team in totals
     $totals = array();
     $placeholders = array();
     // Initialize incremental counter
     $this->pos = 0;
     $this->counter = 0;
     // Initialize team compare
     $this->compare = null;
     // Initialize streaks counter
     $streaks = array();
     // Initialize last counters
     $last5s = array();
     $last10s = array();
     // Initialize record counters
     $homerecords = array();
     $awayrecords = array();
     foreach ($team_ids as $team_id) {
         if (!$team_id) {
             continue;
         }
         // Initialize team streaks counter
         $streaks[$team_id] = array('name' => '', 'count' => 0, 'fire' => 1);
         // Initialize team last counters
         $last5s[$team_id] = array();
         $last10s[$team_id] = array();
         // Initialize team record counters
         $homerecords[$team_id] = array();
         $awayrecords[$team_id] = array();
         // Add outcome types to team last and record counters
         foreach ($outcome_labels as $key => $value) {
             $last5s[$team_id][$key] = 0;
             $last10s[$team_id][$key] = 0;
             $homerecords[$team_id][$key] = 0;
             $awayrecords[$team_id][$key] = 0;
         }
         // Initialize team totals
         $totals[$team_id] = array('eventsplayed' => 0, 'eventsplayed_home' => 0, 'eventsplayed_away' => 0, 'eventsplayed_venue' => 0, 'eventminutes' => 0, 'eventminutes_home' => 0, 'eventminutes_away' => 0, 'eventminutes_venue' => 0, 'streak' => 0, 'streak_home' => 0, 'streak_away' => 0, 'streak_venue' => 0);
         foreach ($result_labels as $key => $value) {
             $totals[$team_id][$key . 'for'] = 0;
             $totals[$team_id][$key . 'for_home'] = 0;
             $totals[$team_id][$key . 'for_away'] = 0;
             $totals[$team_id][$key . 'for_venue'] = 0;
             $totals[$team_id][$key . 'against'] = 0;
             $totals[$team_id][$key . 'against_home'] = 0;
             $totals[$team_id][$key . 'against_away'] = 0;
             $totals[$team_id][$key . 'against_venue'] = 0;
         }
         foreach ($outcome_labels as $key => $value) {
             $totals[$team_id][$key] = 0;
             $totals[$team_id][$key . '_home'] = 0;
             $totals[$team_id][$key . '_away'] = 0;
             $totals[$team_id][$key . '_venue'] = 0;
         }
         // Get static stats
         $static = get_post_meta($team_id, 'sp_columns', true);
         if ('yes' == get_option('sportspress_team_column_editing', 'no') && $league_ids && $season_ids) {
             // Add static stats to placeholders
             foreach ($league_ids as $league_id) {
                 foreach ($season_ids as $season_id) {
                     $placeholders[$team_id] = (array) sp_array_value(sp_array_value($static, $league_id, array()), $season_id, array());
                 }
             }
         }
     }
     $args = array('post_type' => 'sp_event', 'post_status' => array('publish', 'future'), 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'post_date', 'order' => 'DESC', 'meta_query' => array(array('key' => 'sp_format', 'value' => apply_filters('sportspress_competitive_event_formats', array('league')), 'compare' => 'IN')), 'tax_query' => array('relation' => 'AND'));
     if ($league_ids) {
         $args['tax_query'][] = array('taxonomy' => 'sp_league', 'field' => 'id', 'terms' => $league_ids);
     }
     if ($season_ids) {
         $args['tax_query'][] = array('taxonomy' => 'sp_season', 'field' => 'id', 'terms' => $season_ids);
     }
     $args = apply_filters('sportspress_table_data_event_args', $args);
     $events = get_posts($args);
     $e = 0;
     // Event loop
     foreach ($events as $event) {
         $results = (array) get_post_meta($event->ID, 'sp_results', true);
         $minutes = get_post_meta($event->ID, 'sp_minutes', true);
         if ($minutes === '') {
             $minutes = get_option('sportspress_event_minutes', 90);
         }
         $i = 0;
         foreach ($results as $team_id => $team_result) {
             if (!in_array($team_id, $team_ids)) {
                 continue;
             }
             if ($team_result) {
                 foreach ($team_result as $key => $value) {
                     if ($key == 'outcome') {
                         if (!is_array($value)) {
                             $value = array($value);
                         }
                         foreach ($value as $outcome) {
                             // Increment events played and outcome count
                             if (array_key_exists($team_id, $totals) && is_array($totals[$team_id]) && array_key_exists($outcome, $totals[$team_id])) {
                                 $totals[$team_id]['eventsplayed']++;
                                 $totals[$team_id]['eventminutes'] += $minutes;
                                 $totals[$team_id][$outcome]++;
                                 // Add to home or away stats
                                 if (0 === $i) {
                                     $totals[$team_id]['eventsplayed_home']++;
                                     $totals[$team_id]['eventminutes_home'] += $minutes;
                                     $totals[$team_id][$outcome . '_home']++;
                                 } else {
                                     $totals[$team_id]['eventsplayed_away']++;
                                     $totals[$team_id]['eventminutes_away'] += $minutes;
                                     $totals[$team_id][$outcome . '_away']++;
                                 }
                                 // Add to venue stats
                                 if (sp_is_home_venue($team_id, $event->ID)) {
                                     $totals[$team_id]['eventsplayed_venue']++;
                                     $totals[$team_id]['eventminutes_venue'] += $minutes;
                                     $totals[$team_id][$outcome . '_venue']++;
                                 }
                             }
                             if ($outcome && $outcome != '-1') {
                                 // Add to streak counter
                                 if ($streaks[$team_id]['fire'] && ($streaks[$team_id]['name'] == '' || $streaks[$team_id]['name'] == $outcome)) {
                                     $streaks[$team_id]['name'] = $outcome;
                                     $streaks[$team_id]['count']++;
                                 } else {
                                     $streaks[$team_id]['fire'] = 0;
                                 }
                                 // Add to last 5 counter if sum is less than 5
                                 if (array_key_exists($team_id, $last5s) && array_key_exists($outcome, $last5s[$team_id]) && array_sum($last5s[$team_id]) < 5) {
                                     $last5s[$team_id][$outcome]++;
                                 }
                                 // Add to last 10 counter if sum is less than 10
                                 if (array_key_exists($team_id, $last10s) && array_key_exists($outcome, $last10s[$team_id]) && array_sum($last10s[$team_id]) < 10) {
                                     $last10s[$team_id][$outcome]++;
                                 }
                                 // Add to home or away record
                                 if (0 === $i) {
                                     if (array_key_exists($team_id, $homerecords) && array_key_exists($outcome, $homerecords[$team_id])) {
                                         $homerecords[$team_id][$outcome]++;
                                     }
                                 } else {
                                     if (array_key_exists($team_id, $awayrecords) && array_key_exists($outcome, $awayrecords[$team_id])) {
                                         $awayrecords[$team_id][$outcome]++;
                                     }
                                 }
                             }
                         }
                     } else {
                         if (array_key_exists($team_id, $totals) && is_array($totals[$team_id]) && array_key_exists($key . 'for', $totals[$team_id])) {
                             $totals[$team_id][$key . 'for'] += $value;
                             $totals[$team_id][$key . 'for' . ($e + 1)] = $value;
                             // Add to home or away stats
                             if (0 === $i) {
                                 $totals[$team_id][$key . 'for_home'] += $value;
                             } else {
                                 $totals[$team_id][$key . 'for_away'] += $value;
                             }
                             // Add to venue stats
                             if (sp_is_home_venue($team_id, $event->ID)) {
                                 $totals[$team_id][$key . 'for_venue'] += $value;
                             }
                             foreach ($results as $other_team_id => $other_result) {
                                 if ($other_team_id != $team_id && array_key_exists($key . 'against', $totals[$team_id])) {
                                     $totals[$team_id][$key . 'against'] += sp_array_value($other_result, $key, 0);
                                     $totals[$team_id][$key . 'against' . ($e + 1)] = sp_array_value($other_result, $key, 0);
                                     // Add to home or away stats
                                     if (0 === $i) {
                                         $totals[$team_id][$key . 'against_home'] += sp_array_value($other_result, $key, 0);
                                     } else {
                                         $totals[$team_id][$key . 'against_away'] += sp_array_value($other_result, $key, 0);
                                     }
                                     // Add to venue stats
                                     if (sp_is_home_venue($team_id, $event->ID)) {
                                         $totals[$team_id][$key . 'against_venue'] += sp_array_value($other_result, $key, 0);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             $i++;
         }
         $e++;
     }
     foreach ($streaks as $team_id => $streak) {
         // Compile streaks counter and add to totals
         if ($streak['name']) {
             $args = array('name' => $streak['name'], 'post_type' => 'sp_outcome', 'post_status' => 'publish', 'posts_per_page' => 1, 'orderby' => 'menu_order', 'order' => 'ASC');
             $outcomes = get_posts($args);
             if ($outcomes) {
                 $outcome = reset($outcomes);
                 $abbreviation = get_post_meta($outcome->ID, 'sp_abbreviation', true);
                 if (!$abbreviation) {
                     $abbreviation = substr($outcome->post_title, 0, 1);
                 }
                 $totals[$team_id]['streak'] = $abbreviation . $streak['count'];
             } else {
                 $totals[$team_id]['streak'] = null;
             }
         } else {
             $totals[$team_id]['streak'] = null;
         }
     }
     foreach ($last5s as $team_id => $last5) {
         // Add last 5 to totals
         $totals[$team_id]['last5'] = $last5;
     }
     foreach ($last10s as $team_id => $last10) {
         // Add last 10 to totals
         $totals[$team_id]['last10'] = $last10;
     }
     foreach ($homerecords as $team_id => $homerecord) {
         // Add home record to totals
         $totals[$team_id]['homerecord'] = $homerecord;
     }
     foreach ($awayrecords as $team_id => $awayrecord) {
         // Add away record to totals
         $totals[$team_id]['awayrecord'] = $awayrecord;
     }
     $args = array('post_type' => 'sp_column', 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC');
     $stats = get_posts($args);
     $columns = array();
     $this->priorities = array();
     foreach ($stats as $stat) {
         // Get post meta
         $meta = get_post_meta($stat->ID);
         // Add equation to object
         $stat->equation = sp_array_value(sp_array_value($meta, 'sp_equation', array()), 0, null);
         $stat->precision = sp_array_value(sp_array_value($meta, 'sp_precision', array()), 0, 0);
         // Add column name to columns
         $columns[$stat->post_name] = $stat->post_title;
         // Add order to priorities if priority is set and does not exist in array already
         $priority = sp_array_value(sp_array_value($meta, 'sp_priority', array()), 0, 0);
         if ($priority && !array_key_exists($priority, $this->priorities)) {
             $this->priorities[$priority] = array('column' => $stat->post_name, 'order' => sp_array_value(sp_array_value($meta, 'sp_order', array()), 0, 'DESC'));
         }
     }
     // Sort priorities in descending order
     ksort($this->priorities);
     // Initialize games back column variable
     $gb_column = null;
     // Fill in empty placeholder values for each team
     foreach ($team_ids as $team_id) {
         if (!$team_id) {
             continue;
         }
         foreach ($stats as $stat) {
             if (sp_array_value(sp_array_value($placeholders, $team_id, array()), $stat->post_name, '') == '') {
                 if ($stat->equation == null) {
                     $placeholder = sp_array_value(sp_array_value($adjustments, $team_id, array()), $stat->post_name, null);
                     if ($placeholder == null) {
                         $placeholder = '-';
                     }
                 } else {
                     // Solve
                     $placeholder = sp_solve($stat->equation, sp_array_value($totals, $team_id, array()), $stat->precision);
                     if ('$gamesback' == $stat->equation) {
                         $gb_column = $stat->post_name;
                     }
                     if (!in_array($stat->equation, array('$gamesback', '$streak', '$last5', '$last10', '$homerecord', '$awayrecord'))) {
                         // Adjustments
                         $adjustment = sp_array_value($adjustments, $team_id, array());
                         if ($adjustment != 0) {
                             $placeholder += sp_array_value($adjustment, $stat->post_name, 0);
                             $placeholder = number_format($placeholder, $stat->precision, '.', '');
                         }
                     }
                 }
                 $placeholders[$team_id][$stat->post_name] = $placeholder;
             }
         }
     }
     // Find win and loss variables for games back
     $w = $l = null;
     if ($gb_column) {
         $args = array('post_type' => 'sp_outcome', 'numberposts' => 1, 'posts_per_page' => 1, 'meta_query' => array(array('key' => 'sp_condition', 'value' => '>')));
         $outcomes = get_posts($args);
         if ($outcomes) {
             $outcome = reset($outcomes);
             if (is_array($stats)) {
                 foreach ($stats as $stat) {
                     if ('$' . $outcome->post_name == $stat->equation) {
                         $w = $stat->post_name;
                     }
                 }
             }
         }
         // Calculate games back
         $args = array('post_type' => 'sp_outcome', 'numberposts' => 1, 'posts_per_page' => 1, 'meta_query' => array(array('key' => 'sp_condition', 'value' => '<')));
         $outcomes = get_posts($args);
         if ($outcomes) {
             $outcome = reset($outcomes);
             if (is_array($stats)) {
                 foreach ($stats as $stat) {
                     if ('$' . $outcome->post_name == $stat->equation) {
                         $l = $stat->post_name;
                     }
                 }
             }
         }
     }
     // Merge the data and placeholders arrays
     $merged = array();
     foreach ($placeholders as $team_id => $team_data) {
         // Add team name to row
         $merged[$team_id] = array();
         $team_data['name'] = get_the_title($team_id);
         foreach ($team_data as $key => $value) {
             // Use static data if key exists and value is not empty, else use placeholder
             if (array_key_exists($team_id, $tempdata) && array_key_exists($key, $tempdata[$team_id]) && $tempdata[$team_id][$key] != '') {
                 $merged[$team_id][$key] = $tempdata[$team_id][$key];
             } else {
                 $merged[$team_id][$key] = $value;
             }
         }
     }
     uasort($merged, array($this, 'sort'));
     // Calculate position of teams for ties
     foreach ($merged as $team_id => $team_columns) {
         $merged[$team_id]['pos'] = $this->calculate_pos($team_columns);
     }
     // Rearrange data array to reflect values
     $data = array();
     foreach ($merged as $key => $value) {
         $data[$key] = $tempdata[$key];
     }
     if ($admin) {
         $this->add_gb($placeholders, $w, $l, $gb_column);
         return array($columns, $usecolumns, $data, $placeholders, $merged);
     } else {
         $this->add_gb($merged, $w, $l, $gb_column);
         if (!is_array($usecolumns)) {
             $usecolumns = array();
         }
         $labels = array_merge(array('pos' => __('Pos', 'sportspress'), 'name' => __('Team', 'sportspress')), $columns);
         $merged[0] = $labels;
         return $merged;
     }
 }
예제 #2
0
 /**
  * Returns formatted data
  *
  * @access public
  * @param bool $admin
  * @return array
  */
 public function columns($league_id)
 {
     $seasons = (array) get_the_terms($this->ID, 'sp_season');
     $columns = (array) get_post_meta($this->ID, 'sp_columns', true);
     // Get labels from result variables
     $result_labels = (array) sp_get_var_labels('sp_result');
     // Get labels from outcome variables
     $outcome_labels = (array) sp_get_var_labels('sp_outcome');
     // Generate array of all season ids and season names
     $div_ids = array();
     $season_names = array();
     foreach ($seasons as $season) {
         if (is_object($season) && property_exists($season, 'term_id') && property_exists($season, 'name')) {
             $div_ids[] = $season->term_id;
             $season_names[$season->term_id] = $season->name;
         }
     }
     $div_ids[] = 0;
     $season_names[0] = __('Total', 'sportspress');
     $data = array();
     // Get all seasons populated with data where available
     $data = sp_array_combine($div_ids, sp_array_value($columns, $league_id, array()));
     // Get equations from column variables
     $equations = sp_get_var_equations('sp_column');
     // Initialize placeholders array
     $placeholders = array();
     foreach ($div_ids as $div_id) {
         $totals = array('eventsplayed' => 0, 'eventsplayed_home' => 0, 'eventsplayed_away' => 0, 'eventsplayed_venue' => 0, 'eventminutes' => 0, 'eventminutes_home' => 0, 'eventminutes_away' => 0, 'eventminutes_venue' => 0, 'streak' => 0, 'streak_home' => 0, 'streak_away' => 0, 'streak_venue' => 0, 'last5' => null, 'last10' => null, 'homerecord' => null, 'awayrecord' => null);
         foreach ($result_labels as $key => $value) {
             $totals[$key . 'for'] = 0;
             $totals[$key . 'for_home'] = 0;
             $totals[$key . 'for_away'] = 0;
             $totals[$key . 'for_venue'] = 0;
             $totals[$key . 'against'] = 0;
             $totals[$key . 'against_home'] = 0;
             $totals[$key . 'against_away'] = 0;
             $totals[$key . 'against_venue'] = 0;
         }
         foreach ($outcome_labels as $key => $value) {
             $totals[$key] = 0;
             $totals[$key . '_home'] = 0;
             $totals[$key . '_away'] = 0;
             $totals[$key . '_venue'] = 0;
         }
         // Initialize streaks counter
         $streak = array('name' => '', 'count' => 0, 'fire' => 1);
         // Initialize last counters
         $last5 = array();
         $last10 = array();
         // Initialize record counters
         $homerecord = array();
         $awayrecord = array();
         // Add outcome types to last and record counters
         foreach ($outcome_labels as $key => $value) {
             $last5[$key] = 0;
             $last10[$key] = 0;
             $homerecord[$key] = 0;
             $awayrecord[$key] = 0;
         }
         // Get all events involving the team in current season
         $args = array('post_type' => 'sp_event', 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'post_date', 'order' => 'DESC', 'meta_query' => array('relation' => 'AND', array('key' => 'sp_team', 'value' => $this->ID), array('key' => 'sp_format', 'value' => apply_filters('sportspress_competitive_event_formats', array('league')), 'compare' => 'IN')), 'tax_query' => array('relation' => 'AND'));
         if ($league_id) {
             $args['tax_query'][] = array('taxonomy' => 'sp_league', 'field' => 'id', 'terms' => $league_id);
         }
         if ($div_id) {
             $args['tax_query'][] = array('taxonomy' => 'sp_season', 'field' => 'id', 'terms' => $div_id);
         }
         $args = apply_filters('sportspress_team_data_event_args', $args);
         $events = get_posts($args);
         $e = 0;
         foreach ($events as $event) {
             $results = (array) get_post_meta($event->ID, 'sp_results', true);
             $minutes = get_post_meta($event->ID, 'sp_minutes', true);
             if ($minutes === '') {
                 $minutes = get_option('sportspress_event_minutes', 90);
             }
             $i = 0;
             foreach ($results as $team_id => $team_result) {
                 if (is_array($team_result)) {
                     foreach ($team_result as $key => $value) {
                         if ($team_id == $this->ID) {
                             if ($key == 'outcome') {
                                 // Convert to array
                                 if (!is_array($value)) {
                                     $value = array($value);
                                 }
                                 foreach ($value as $outcome) {
                                     // Increment events played and outcome count
                                     if (array_key_exists($outcome, $totals)) {
                                         $totals['eventsplayed']++;
                                         $totals['eventminutes'] += $minutes;
                                         $totals[$outcome]++;
                                         // Add to home or away stats
                                         if (0 === $i) {
                                             $totals['eventsplayed_home']++;
                                             $totals['eventminutes_home'] += $minutes;
                                             $totals[$outcome . '_home']++;
                                         } else {
                                             $totals['eventsplayed_away']++;
                                             $totals['eventminutes_away'] += $minutes;
                                             $totals[$outcome . '_away']++;
                                         }
                                         // Add to venue stats
                                         if (sp_is_home_venue($team_id, $event->ID)) {
                                             $totals['eventsplayed_venue']++;
                                             $totals['eventminutes_venue'] += $minutes;
                                             $totals[$outcome . '_venue']++;
                                         }
                                     }
                                     if ($outcome && $outcome != '-1') {
                                         // Add to streak counter
                                         if ($streak['fire'] && ($streak['name'] == '' || $streak['name'] == $outcome)) {
                                             $streak['name'] = $outcome;
                                             $streak['count']++;
                                         } else {
                                             $streak['fire'] = 0;
                                         }
                                         // Add to last 5 counter if sum is less than 5
                                         if (array_key_exists($outcome, $last5) && array_sum($last5) < 5) {
                                             $last5[$outcome]++;
                                         }
                                         // Add to last 10 counter if sum is less than 10
                                         if (array_key_exists($outcome, $last10) && array_sum($last10) < 10) {
                                             $last10[$outcome]++;
                                         }
                                         // Add to home or away record
                                         if (0 === $i) {
                                             if (array_key_exists($outcome, $homerecord)) {
                                                 $homerecord[$outcome]++;
                                             }
                                         } else {
                                             if (array_key_exists($outcome, $awayrecord)) {
                                                 $awayrecord[$outcome]++;
                                             }
                                         }
                                     }
                                 }
                             } else {
                                 if (array_key_exists($key . 'for', $totals)) {
                                     $totals[$key . 'for'] += $value;
                                     $totals[$key . 'for' . ($e + 1)] = $value;
                                     // Add to home or away stats
                                     if (0 === $i) {
                                         $totals[$key . 'for_home'] += $value;
                                     } else {
                                         $totals[$key . 'for_away'] += $value;
                                     }
                                     // Add to venue stats
                                     if (sp_is_home_venue($team_id, $event->ID)) {
                                         $totals[$key . 'for_venue'] += $value;
                                     }
                                 }
                             }
                         } else {
                             if ($key != 'outcome') {
                                 if (array_key_exists($key . 'against', $totals)) {
                                     $totals[$key . 'against'] += $value;
                                     $totals[$key . 'against' . ($e + 1)] = $value;
                                     // Add to home or away stats
                                     if (0 === $i) {
                                         $totals[$key . 'against_home'] += $value;
                                     } else {
                                         $totals[$key . 'against_away'] += $value;
                                     }
                                     // Add to venue stats
                                     if (sp_is_home_venue($team_id, $event->ID)) {
                                         $totals[$key . 'against_venue'] += $value;
                                     }
                                 }
                             }
                         }
                     }
                 }
                 $i++;
             }
             $e++;
         }
         // Compile streaks counter and add to totals
         $args = array('name' => $streak['name'], 'post_type' => 'sp_outcome', 'post_status' => 'publish', 'posts_per_page' => 1, 'orderby' => 'menu_order', 'order' => 'ASC');
         $outcomes = get_posts($args);
         if ($outcomes) {
             $outcome = reset($outcomes);
             $abbreviation = get_post_meta($outcome->ID, 'sp_abbreviation', true);
             if (!$abbreviation) {
                 $abbreviation = substr($outcome->post_title, 0, 1);
             }
             $totals['streak'] = $abbreviation . $streak['count'];
         }
         // Add last and record counters to totals
         $totals['last5'] = $last5;
         $totals['last10'] = $last10;
         $totals['homerecord'] = $homerecord;
         $totals['awayrecord'] = $awayrecord;
         // Generate array of placeholder values for each league
         $placeholders[$div_id] = array();
         foreach ($equations as $key => $value) {
             if ('$gamesback' == $value['equation']) {
                 $placeholders[$div_id][$key] = __('(Auto)', 'sportspress');
             } else {
                 $placeholders[$div_id][$key] = sp_solve($value['equation'], $totals, $value['precision']);
             }
         }
     }
     // Get columns from column variables
     $columns = sp_get_var_labels('sp_column');
     return array($columns, $data, $placeholders);
 }