} // Exit if accessed directly if (get_option('sportspress_event_show_statistics', 'yes') === 'no') { return; } 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);
function sp_get_status($post = 0) { $event = new SP_Event($post); return $event->status(); }
/** * Add class to body */ public function body_class($classes = array()) { if ('sp_event' == get_post_type() && 'yes' == get_option('sportspress_event_show_statistics', 'yes') && 'icons' == get_option('sportspress_event_performance_mode', 'values')) { $event = new SP_Event(get_the_ID()); $status = $event->status(); if ('results' !== $status) { return $classes; } $classes[] = 'sp-inline-statistics'; } return $classes; }