Skip to content

Commit

Permalink
Ensure that the enclosure is saved right
Browse files Browse the repository at this point in the history
  • Loading branch information
akirk committed Nov 29, 2024
1 parent 2a27209 commit ca22646
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions feed-parsers/class-feed-item.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,28 @@ public function __get( $key ) {
case 'updated_date':
case 'date':
return gmdate( 'Y-m-d H:i:s', $this->data[ $key ] );
case 'meta':
$meta = $this->data['meta'];
if ( isset( $meta['enclosure'] ) ) {
if ( isset( $meta['enclosure']['url'] ) ) {
$url = $meta['enclosure']['url'];
$len = '';
if ( isset( $meta['enclosure']['length'] ) ) {
$len = $meta['enclosure']['length'];
}
$mime = '';
if ( isset( $meta['enclosure']['mime'] ) ) {
$mime = $meta['enclosure']['mime'];
}

$meta['enclosure'] = "$url\n$len\n$mime\n";
} else {
// An enclosure only makes sense if it has a URL.
unset( $meta['enclosure'] );
}
}

return $meta;
}

return $this->data[ $key ];
Expand Down

0 comments on commit ca22646

Please sign in to comment.