Apple_Actions\Index\Section::get_sections PHP Method

get_sections() public method

Cache for 5 minutes to avoid too many API requests.
public get_sections ( ) : array
return array
    public function get_sections()
    {
        if (false === ($sections = get_transient('apple_news_sections'))) {
            $sections = array();
            $channel = $this->get_setting('api_channel');
            if (!empty($channel)) {
                try {
                    $apple_news_sections = $this->get_api()->get_sections($channel);
                    $sections = !empty($apple_news_sections->data) ? $apple_news_sections->data : array();
                } catch (\Apple_Push_API\Request\Request_Exception $e) {
                    $sections = array();
                }
                set_transient('apple_news_sections', $sections, 300);
            }
        }
        return $sections;
    }