From fee3add296fb92d65518937eb99ca2dc7c1ca445 Mon Sep 17 00:00:00 2001 From: Evan Herman Date: Thu, 20 Jun 2024 15:55:31 -0400 Subject: [PATCH] Use wp_safe_remote_get() to retreive remote .ics data --- includes/ical-parser/class-coblocks-ical.php | 9 +++++++++ src/blocks/events/index.php | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/includes/ical-parser/class-coblocks-ical.php b/includes/ical-parser/class-coblocks-ical.php index 8cce152087c..db56f22b2bc 100644 --- a/includes/ical-parser/class-coblocks-ical.php +++ b/includes/ical-parser/class-coblocks-ical.php @@ -2711,6 +2711,15 @@ protected function is_file_or_url( $filename ) { * @throws \Exception Exception thrown on error. */ protected function file_or_url( $filename ) { + // If this is a URL, let's use wp_safe_remote_get instead. + if ( filter_var( $filename, FILTER_VALIDATE_URL ) ) { + $request = wp_safe_remote_get( $filename ); + if ( is_wp_error( $request ) ) { + return false; + } + return explode( "\n", wp_remote_retrieve_body( $request ) ); + } + $options = array(); if ( ! empty( $this->http_basic_auth ) || ! empty( $this->http_user_agent ) ) { $options['http'] = array(); diff --git a/src/blocks/events/index.php b/src/blocks/events/index.php index 3e47eb9f772..bf7f3a861bd 100644 --- a/src/blocks/events/index.php +++ b/src/blocks/events/index.php @@ -169,6 +169,18 @@ function coblocks_render_coblocks_events_block( $attributes, $content ) { $location ); + } else { + + $events_layout .= coblocks_render_single_day_event_item( + $start_date, + $month, + $year, + $title, + $description, + null, + $location + ); + } $events_layout .= '';