Support » Plugin: Audio Player » How can I add a Download Button to the Audio Player?

Viewing 6 replies - 1 through 6 (of 6 total)
  • I figured out how to add a download link.

    Use the WP plug-in editor to edit audio-player/audio-player.php. Find the sendToEditor() function, starting around line 696. In this short function, there’s a block:

    if (strlen($matches[5]) > 0) {
    	$html = preg_replace("/]$/i", "|titles=" . $matches[5] . "]", $html);

    Add the following line immediately after that block:

    $html .= " <a href='" . $matches[3] . "'>[download]</a>";

    This will insert a [download] link just after (or below) the player, when you use the “Add Audio” button in your post, then the “Audio Player” button, and finally the “Insert into Post” button. In your Audio Player plugin settings, “Replace [audio] syntax” must be enabled, and “Replace all links to mp3 files” must be disabled.

    If you want a button, you could add a class to the link in the above code, and use some CSS to style it, or just hard code a button of your choice.

    This is a pretty crude shortcut, but it does work.

    Thanks man, you are awesome! Been waiting forever for a work around!

    Much Appreciated,
    Joe [ Signature moderated. ]

    Yeah, now if I can only get this to work in WP version 3.3.2. 🙁

    Mr. Shiv, did you figure out how to get it to work in 3.3.2?

    Actually, it does work in 3.3.2 now. After a lot of frustration, I discovered that my hand-rolled theme had this crucial line in the wrong location:

    <?php wp_head(); ?>

    This bit of code should go in your header.php file. In my case, I was also using header.php to bring in some design elements from elsewhere on the site (i.e. outside of the WP blog portion of my site). Somehow this additional include() broke the functionality of wp_head(). After moving the wp_head() line down a bit in header.php, everything started working correctly.

    I did this manually (once upon a time).. not hard if you don’t have to enter too many 🙂

    • I manually add a link to the file in wordpress
    • disabled the function to auto-insert the player
    • style the link using css in my theme

    I did a walk through on my site back in 2008 🙂
    Add a download button to WordPress Audio Player.

    You can find explicit instructions and a button to match the player.

    Never got around to making it into a plugin.. (which I reckon I’d do if there were filter hooks inside Martins player)

    hope it helps, tim

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How can I add a Download Button to the Audio Player?’ is closed to new replies.