From 3b551c460a064a6c8f0468d411d2159511ef16c1 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Thu, 17 Sep 2015 12:25:35 +1000 Subject: [PATCH] Add API function to get main performance --- includes/sp-api-functions.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/includes/sp-api-functions.php b/includes/sp-api-functions.php index 7c1d0aba..22927073 100644 --- a/includes/sp-api-functions.php +++ b/includes/sp-api-functions.php @@ -96,6 +96,16 @@ function sp_get_winner( $post = 0 ) { return $event->winner(); } +function sp_get_main_performance_option() { + $main_performance = get_option( 'sportspress_primary_performance', null ); + if ( $main_performance ) return $main_performance; + $options = get_posts( array( 'post_type' => 'sp_performance', 'posts_per_page' => 1, 'orderby' => 'menu_order', 'order' => 'ASC' ) ); + if ( ! $options ) return null; + $performance = reset( $options ); + $slug = $performance->post_name; + return $slug; +} + function sp_get_performance( $post = 0 ) { $event = new SP_Event( $post ); return $event->performance();