From 6bf57e27b95a78eb9f381cf18d5622f9f44deb58 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Wed, 2 Mar 2016 23:08:48 +1100 Subject: [PATCH] Add api functions --- includes/sp-api-functions.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/includes/sp-api-functions.php b/includes/sp-api-functions.php index 49cca3da..d8e0c3ac 100644 --- a/includes/sp-api-functions.php +++ b/includes/sp-api-functions.php @@ -34,6 +34,18 @@ function sp_get_posts( $post_type = 'post', $args = array() ) { return get_posts( $args ); } +function sp_get_leagues( $post = 0, $ids = true ) { + $terms = get_the_terms( $post, 'sp_league' ); + if ( $terms && $ids ) $terms = wp_list_pluck( $terms, 'term_id' ); + return $terms; +} + +function sp_get_seasons( $post = 0, $ids = true ) { + $terms = get_the_terms( $post, 'sp_season' ); + if ( $terms && $ids ) $terms = wp_list_pluck( $terms, 'term_id' ); + return $terms; +} + /* * Event functions */ @@ -181,6 +193,12 @@ function sp_get_logo( $post = 0, $size = 'icon', $attr = array() ) { return get_the_post_thumbnail( $post, 'sportspress-fit-' . $size, $attr ); } +function sp_get_logo_url( $post = 0, $size = 'icon' ) { + $thumbnail_id = get_post_thumbnail_id( $post ); + $src = wp_get_attachment_image_src( $thumbnail_id, $size, false ); + return $src[0]; +} + function sp_get_abbreviation( $post = 0 ) { return get_post_meta ( $post, 'sp_abbreviation', true ); }