Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/*
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
You can’t perform that action at this time.