Im currently in the process of writing a plugin that allows me to import content from a different Content Management System into WordPress.
Almost everything works as I want it to: Each entry gets saved with title, content and featured image. I even managed to transfer and update images within the content area. But now im struggling with one last problem.
If theres an embedded video (youtube/vimeo) in the content, and I save this as an iframe, it doesn't behave the same way as the wordpress oEmbeds.
Normally when you paste a url to a video in the WordPress editor, it generates the embed code for you, while only saving the url to the database. Im not really sure how this works, but even if I strip out the iframe from the html, and add only the url, it still requires me to go to the post, and press update, in order for the iframe to work in the front end.
Another thing i have realised, is that WordPress don't actually save
tags to the database, but if I insert the data from this other CMS, all the html tags gets inserted with it (of course). If I then go to the post and press update - all the data gets formatted nicely.
Is there a function that i can use to "prepare" the raw html coming from this other WYSISYG, before saving it to the wordpress database? Or is there a way to save the embeds, in order to make them work?
I feel like WordPress core must be using a function when saving from the editor to the database - but I can't seem to find anything about such a function.
Any clarification on this subject is appreciated.