Adding embed rules for non-oEmbed Zippyshare
-
Following the rules of the non-oEmbed way of registring a embed profile, I cannot get this thing to work. Now I have this piece of code added to my functions.php in the active template directory:
<?php function wp_embed_handler_zippyshare( $matches, $attr, $url, $rawattr ) { $embed = sprintf( 'http://%1$s.zippyshare.com/v/%2$s/file.html', esc_attr($matches[1]), esc_attr($matches[2]) ); return apply_filters( 'embed_zippyshare', $embed, $matches, $attr, $url, $rawattr ); } ?> <?php function register_embed_handlers() { wp_embed_register_handler( 'zippyshare', '#<script type=\"text/javascript\">var zippywww=\"[\d]+\";var zippyfile=\"[\d]+\";var zippydown=\"ffffff\";var zippyfront=\"000000\";var zippyback=\"ffffff\";var zippylight=\"000000\";var zippywidth=365;var zippyauto=false;var zippyvol=80;</script><script type="text/javascript" src=\"http://api\.zippyshare\.com/api/embed\.js\"></script>', 'wp_embed_handler_zippyshare' ); } add_action('wp', 'register_embed_handlers'); ?>Did I placed the backslashes correctly and can I suppose the [\d]+ are picking up matches 1 and 2 correctly?
Viewing 2 replies - 1 through 2 (of 2 total)
-
Ah, found some wrong things… This is my current code, but, still does nothing:
<?php function wp_embed_handler_zippyshare( $matches, $attr, $url, $rawattr ) { $embed = sprintf( '<script type="text/javascript">var zippywww="%1$s";var zippyfile="%2$s";var zippydown="ffffff";var zippyfront="000000";var zippyback="ffffff";var zippylight="000000";var zippywidth=365;var zippyauto=false;var zippyvol=80;</script><script type="text/javascript" src="http://api.zippyshare.com/api/embed.js"></script>', esc_attr($matches[1]), esc_attr($matches[2]) ); return apply_filters( 'embed_zippyshare', $embed, $matches, $attr, $url, $rawattr ); } ?> <?php function register_embed_handlers() { wp_embed_register_handler( 'zippyshare', '#http://([\d]+)\.zippyshare\.com/v/([\d]+)/file\.html', 'wp_embed_handler_zippyshare' ); } add_action('wp', 'register_embed_handlers'); ?>Is it allowed to use just twice ([\d]+) or must I close the latest match with the (.+?) ?
<?php function wp_embed_handler_zippyshare( $matches, $attr, $url, $rawattr ) { $embed = sprintf( '<script type="text/javascript">var zippywww="%1$s";var zippyfile="%2$s";var zippydown="ffffff";var zippyfront="000000";var zippyback="ffffff";var zippylight="000000";var zippywidth=365;var zippyauto=false;var zippyvol=80;</script><script type="text/javascript" src="http://api.zippyshare.com/api/embed.js"></script>', esc_attr($matches[1]), esc_attr($matches[2]) ); return apply_filters( 'embed_zippyshare', $embed, $matches, $attr, $url, $rawattr ); } ?> <?php function register_embed_handlers() { wp_embed_register_handler( 'zippyshare', '#http://([\d]+)\.zippyshare\.com/v/(.+?)/file\.html($|&)#i', 'wp_embed_handler_zippyshare' ); } add_action('wp', 'register_embed_handlers'); ?>
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Adding embed rules for non-oEmbed Zippyshare’ is closed to new replies.