Skip to content

Commit

Permalink
Use wp_safe_remote_get() to retreive remote .ics data
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanHerman committed Jun 20, 2024
1 parent b800b9b commit fee3add
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions includes/ical-parser/class-coblocks-ical.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
12 changes: 12 additions & 0 deletions src/blocks/events/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= '</div>';
Expand Down

0 comments on commit fee3add

Please sign in to comment.