benecaster_feed_sync_import_data
Filters the data array built from an RSS item before a draft episode is created during feed sync. Reshapes only the keys it documents — title, content, description_rss, post_date (UTC, Y-m-d H:i:s from <pubDate>, '' when absent; return UTC, and the draft stores it as post_date_gmt with the site-local equivalent in post_date), audio_url, file_size, mime_type, duration, episode_number, season_number, episode_type, explicit, author, episode_artwork, source_guid, source_link — a key you invent is ignored. Use to transform or augment imported data — for example, to parse a custom RSS namespace and map it to a Benecaster custom field.
audio_url holds the enclosure URL whether the file is audio or video. After your callback, a video/… mime_type, or a .mp4, .m4v or .mov URL when the type is blank or neither audio nor video, stores the file as the episode’s video URL with primary media set to video; anything else is stored as the audio URL. Changing mime_type or the URL therefore also changes where the file lands.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$data |
array |
— | Episode data array built from the RSS item |
$rss_item |
SimpleXMLElement |
— | The RSS item being imported |
$show_id |
int |
— | ID of the show |
Returns:
array
Example
add_filter( 'benecaster_feed_sync_import_data', function( $data, $rss_item, $show_id ) {
// Pull a custom <myshow:sponsor> RSS element and map it to a Benecaster custom field.
$ns = $rss_item->children( 'https://myshow.example.com/rss/1.0' );
$sponsor = isset( $ns->sponsor ) ? (string) $ns->sponsor : '';
if ( $sponsor ) {
$data['meta']['_episode_sponsor'] = sanitize_text_field( $sponsor );
}
return $data;
}, 10, 3 );
Notes
source_link is the item's <link>, the episode's page on the old host, already validated
(http/https with a host, at most 2048 characters); '' when the item has none or it's unusable. It becomes the
_benecaster_source_link post meta. Your value is validated again after the filter: set it to another URL to
replace it, or unset it or set it to '' to store no link. A non-http value is dropped, not stored.
Need this built rather than just documented? See our services →