Created
July 16, 2010 07:51
-
-
Save mikeschinkel/478078 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Makes WordPress' PressThis use vimeo short code instead of <object>/<embed> tags. | |
Add this to the WordPress theme's function.php file. | |
Addresses the Vimeo question from StackExchange here: | |
http://webapps.stackexchange.com/questions/3834/customizing-press-this-quick-posting-for-wordpress | |
*/ | |
add_action('admin_print_footer_scripts','greatjakes_admin_print_footer_scripts'); | |
function greatjakes_admin_print_footer_scripts() { | |
if ($_SERVER['PHP_SELF']=='/wp-admin/press-this.php') { | |
$script=<<<SCRIPT | |
<script type="text/javascript"> | |
var intervalId; | |
var embedCode; | |
function monitorEmbedCode() { | |
embedCode = jQuery("#embed-code").val(); | |
if (embedCode!=null) { | |
window.clearInterval(intervalId); | |
var matches = embedCode.match(/clip_id=([0-9]+)&/g); | |
var output = ''; | |
var clipId = 0; | |
for (var i=0; i<matches.length; i+=2 ) { | |
clipId = parseInt(matches[i].replace(/(.+=)([0-9]+)(&)/,'$2')); | |
output += '[vimeo clip_id="' + clipId + '" width="400" height="225"]\\n'; | |
} | |
jQuery("#embed-code").val(output); | |
} | |
} | |
intervalId = window.setInterval(monitorEmbedCode,100); | |
</script> | |
SCRIPT; | |
echo $script; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment