function sp_the_seasons($post = 0, $delimiter = ', ') { $terms = sp_get_seasons($post, false); $arr = array(); if ($terms) { foreach ($terms as $term) { $arr[] = $term->name; } } echo implode($delimiter, $arr); }
/** * Prepare the item for the REST response * * @param mixed $item WordPress representation of the item. * @param WP_REST_Request $request Request object. * @return mixed */ public function prepare_item_for_response($post, $request) { $data = array('id' => $post->ID, 'guid' => array('raw' => $post->guid, 'rendered' => apply_filters('get_the_guid', $post->guid)), 'slug' => $post->post_name, 'link' => get_permalink($post->ID), 'title' => array('raw' => $post->post_title, 'rendered' => get_the_title($post->ID)), 'content' => array('raw' => $post->post_content, 'rendered' => apply_filters('the_content', $post->post_content)), 'featured_media' => (int) get_post_thumbnail_id($post->ID), 'abbreviation' => sp_get_abbreviation($post->ID), 'leagues' => sp_get_leagues($post->ID), 'seasons' => sp_get_seasons($post->ID), 'venues' => sp_get_venues($post->ID)); return $data; }