Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeschinkel/478078 to your computer and use it in GitHub Desktop.
Save mikeschinkel/478078 to your computer and use it in GitHub Desktop.
/*
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