Add a podcast quicktag to Wordpress editor

This tutorial adds a button to the Wordpress post/page editor in code view, to add a link to a podcast file in your post and therefore also your RSS feed - so that you should end up with this:-

podcastbutton.gif


it also serves as a good intro to hacking around with quicktags in general… you will need a little bit of skill with code for this…

Locate /wp-includes/quicktags.js and make 3 edits

At approx line 60: between the two blocks for

edButtons[edButtons.length] =
new edButton(’ed_link’
,’link’
,”
,’</a>’
,’a’
); // special case

and

edButtons[edButtons.length] =
new edButton(’ed_block’ ……

add this code

edButtons[edButtons.length] =
new edButton('ed_podcastlink'
,'podcast'
,''
,'</a>'
,'a'
); // special case

- this places the button in the quicktags toolbar (change to suit…)

2. At approx line 160: replace the whole of function edShowButton(button, i) with this:-

function edShowButton(button, i) {
if (button.id == 'ed_img') {
document.write('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertImage(edCanvas);" value="' + button.display + '" />');
}
else if (button.id == 'ed_link') {
document.write('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertLink(edCanvas, ' + i + ');" value="' + button.display + '" />');
}
else if (button.id == 'ed_podcastlink') {
document.write('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertPodcastLink(edCanvas, ' + i + ');" value="' + button.display + '" />');
}
else {
document.write('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertTag(edCanvas, ' + i + ');" value="' + button.display + '" />');
}
}

3. At the end of the file, approx line 400: add this function edited to the path you will be using to your podcast link image

function edInsertPodcastLink(myField, i, defaultValue) {
if (!defaultValue) {
defaultValue = 'http://';
}
if (!edCheckOpenTags(i)) {
var URL = prompt('Location of podcast file:' ,defaultValue);
if (URL) {
edButtons[i].tagStart = '<a href="' + URL + '"><img src="http://mysite.com/path/to/images/podcast.gif" />'; edInsertTag(myField, i);
}
} else {
edInsertTag(myField, i);v
}
}

Bookmark:
These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Google
  • Facebook
  • Furl
  • NewsVine
  • Reddit
  • StumbleUpon
  • Sphinn
  • Technorati

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment