Quantcast
Channel: Brian Shaffer » PHP » Brian Shaffer
Viewing all articles
Browse latest Browse all 7

How to fix WordPress to Tumblr video importing

$
0
0

Videos on Tumblr come in all shapes and sizes. Youtube & Metacafe videos are done in iframes, directly uploaded ones in  html5, and then there are all the Javascript players in between. If you’re having issues with the videos importing, it most likely is because of the way WordPress sanitizes the Tumblr posts.

WordPress removes iframes from posts

That’s the main issue. Luckily, there is a solution to disable the WordPress filters while you’re importing.

Below line 411 in tumblr-importer.php, add this line:

kses_remove_filters();

Making your code look like:

do_action( 'tumblr_importing_post', $post );
kses_remove_filters();
$id = wp_insert_post( $post );

And then down on line 434 add this:

kses_init_filters();

Making your code look like:

$this->save_vars();
kses_init_filters();
} while ( false != ($post = next($imported_posts) ) && $this->have_time() );

The kses filters are in place to help prevent malicious code from being imported, and the code above simply disabled them before the import, and then reenabled them once it was completed. Since we probably trust YouTube and the other video sources, we’re allowing the iframes to live inside posts.

You’ll have to do the same modifications if you’re importing drafts. Just add the code to lines 482 and 494 respectively. You can download the importer with my modifications here (make sure you remove the .txt extension).


Viewing all articles
Browse latest Browse all 7

Latest Images

Trending Articles





Latest Images