Skip to content

Instantly share code, notes, and snippets.

@keithnorm
Created September 5, 2009 21:52
Show Gist options
  • Save keithnorm/181528 to your computer and use it in GitHub Desktop.
Save keithnorm/181528 to your computer and use it in GitHub Desktop.
(function() {
var DOM = tinymce.DOM;
var each = tinymce.each;
// Load plugin specific language pack
tinymce.PluginManager.requireLangPack('wordpress');
tinymce.create('tinymce.plugins.WPAudio', {
init : function(ed, url) {
ed.onPostProcess.add(function(ed, o) {
if (o.get)
o.content = o.content.replace(/<a href=\"((http|https):\/\/([a-z0-9]+)[\-\.]?([a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?[\/\?][[\S]*]?)?)\">.+<\/a>/g, function(tag, url, protocol) {
if(url.match(/.+\.mp3$/))
return '[wpaudio: url="' + url + '"]';
return tag;
});
});
}
});
tinymce.PluginManager.add('wp_audio', tinymce.plugins.WPAudio);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment