Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes a conflict with WP 3.5 shortcode handling #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 34 additions & 35 deletions argo-audio-player.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<?php
/**
* @package Argo_Audio_Player
* @version 1.0
* @version 1.1
*/
/*
Plugin Name: Argo Audio Player
Plugin URI: https://github.com/argoproject/argo-audio-player
Description: The Argo Audio Player Plugin.
Author: Project Argo, Mission Data
Version: 1.0
Version: 1.1
Author URI:
License: GPLv2
*/

/* The Argo Audio Player Plugin class - so we don't have function naming conflicts */
class ArgoAudioPlayer {

/* Initialize the plugin */
function init() {

/**
* Add the "audio" shortcode for use in posts
* We call all other functions from within the argo_audio_shortcode function
Expand Down Expand Up @@ -54,12 +54,12 @@ function ArgoWPFooter() {
/* Load up the SoundManager 2 javascript files into the footer */
echo "<script src='".plugins_url(null,__FILE__)."/js/sm.min.js'></script>";
echo "<script src='".plugins_url(null, __FILE__)."/js/sm.playlist.js'></script>";


/* Setup the SoundManager 2 swf directories*/
echo "<script>
soundManager.url = '".plugins_url(null,__FILE__)."/swf/';

function setTheme(sTheme) {
var o = document.getElementsByTagName('ul')[0];
o.className = 'playlist'+(sTheme?' '+sTheme:'');
Expand All @@ -68,23 +68,23 @@ function setTheme(sTheme) {
soundManager.onready(function() {
// SM2 is ready to play audio!
});

</script>";
}

}

/*
* DISABLE DEFAULT FUNCTIONALITY
*/

function disable_builtin_caption( $shcode, $html ) {
return $html;
}
//add_filter( 'image_add_caption_shortcode', 'disable_builtin_caption', 15, 2 );
/*
* END DISABLE DEFAULT FUNCTIONALITY
*/

/*
* AUDIO EDITOR MARKUP CUSTOMIZATIONS
*/
Expand All @@ -96,10 +96,10 @@ function argo_audio_editor_markup( $href, $title, $caption ) {
}
$out .= sprintf( '<a href="%s" class="%s">%s</a>', $href, 'exclude', 'Download' );
$out .= "</li></ul>";

return $out;
}

/*
* SHORTCODES
*/
Expand All @@ -110,32 +110,31 @@ function argo_audio_shortcode( $atts, $content ) {
$html = ArgoAudioPlayer::argo_audio_editor_markup( $href, $title, $content );
return $html;
}

// construct shortcode for audio embeds
function argo_audio_editor_shortcode( $html, $href, $title ) {
return sprintf( '[audio href="%s" title="%s"]Insert caption here[/audio]', $href, $title );
}
// construct shortcode for audio embeds
function argo_audio_editor_media_gallery_shortcode( $html, $send_id, $attachment ) {
$title = '';
$href = '';
if (preg_match("/\.mp3|\.ogg|\.mp4|\.wav|\.m4a/",$html)) {
/* Get the title from the html */
preg_match("/\>.+\</",$html,$title);
$title = $title[0];
$title = preg_replace("/\>|\</","",$title);
$title = preg_replace("/_/"," ",$title);
/* Get the url of the file from the html */
preg_match("/\'.+\'/",$html,$href);
$href = $href[0];
$href = preg_replace("/\'/","",$href);
return sprintf( '[audio href="%s" title="%s"]Insert caption here[/audio]', $href, $title );
} else {
return;

}

$title = '';
$href = '';
if (preg_match("/\.mp3|\.ogg|\.mp4|\.wav|\.m4a/",$html)) {
/* Get the title from the html */
preg_match("/\>.+\</",$html,$title);
$title = $title[0];
$title = preg_replace("/\>|\</","",$title);
$title = preg_replace("/_/"," ",$title);
/* Get the url of the file from the html */
preg_match("/\'.+\'/",$html,$href);
$href = $href[0];
$href = preg_replace("/\'/","",$href);
return sprintf( '[audio href="%s" title="%s"]Insert caption here[/audio]', $href, $title );
} else {
return $html;
}
}

/*
* ADMIN PRESENTATION CUSTOMIZATIONS
*/
Expand All @@ -147,8 +146,8 @@ function argo_tweak_upload_tabs( $defaults ) {
}
// XXX: it does more harm than good to comment this out.
//add_filter( 'media_upload_tabs', 'argo_tweak_upload_tabs', 12, 1 );


/*
* END ADMIN PRESENTATION CUSTOMIZATIONS
*/
Expand Down