*/ /* */ /* Copyright (c) 2006-2007 Shawn Van Every */ /* */ /* This program is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU General Public License */ /* as published by the Free Software Foundation; either version 2 */ /* of the License, or (at your option) any later version. */ /* */ /* See file LICENSE for further informations on licensing terms. */ /* */ /* This program is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ /* along with this program; if not, write to the Free Software Foundation, */ /* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* */ /* --------------------------------------------------------------------------*/ /* Plugin Name: QuickTime Posting Plugin URI: http://www.walking-productions.com/QuickTimePostWPP/ Description: Create QuickTime Object and Embed Tags in posts [QUICKTIME file width height] OR: [QUICKTIME file poster_file width height] OR: [QUICKTIME file width height true true] OR: [QUICKTIME file poster_file width height true true] In the last two versions, the first "true" is for whether or not it should autoplay and the second for whether or not the controller should be visible. The other possibility is to say "false" for either of these arguments. New with Version 1.3b, uses JavaScript methods to get around the annoying Alert regarding running ActiveX controls on Windows IE browsers. Thanks to Steven Dowd (http://steven-dowd.co.uk/) for pointing out the solution and thanks to 360rage for describing it further (http://www.360rage.com/eolas-microsoft.php). Notes: At some point this should probably use Apple's JavaScript file for doing this: AC_QuickTime.js http://developer.apple.com/internet/ieembedprep.html 1.3.4b, added GPL Language 1.3.3b, added 'the_excerpt' filter so that on templates like hemingway the plugin will display the movie if the tag is used in the excerpt. Also fixed a typo which may have prevented some of the arguments not to be parsed correctly when using all of the options (poster, autoplay and controller). 1.3.2b, fixed "site_url" issue for those users whose blog is in a different place than their wordpress install. 1.3.1b, closer to XHTML compliance. The PARAM tags now have ending slashes. Also, using JavaScript to no rely upon the wp_head function. Checking to see if it is defined before using it. Author: Shawn Van Every Version: 1.3.3b Author URI: http://www.walking-productions.com/shawn.html */ $stag = "[QUICKTIME "; $etag = "]"; function quicktime_post($the_content) { GLOBAL $stag, $etag; $spos = strpos($the_content, $stag); if ($spos !== false) { $epos = strpos($the_content, $etag, $spos); $spose = $spos + strlen($stag); $slen = $epos - $spose; $tagargs = substr($the_content, $spose, $slen); $the_args = explode(" ", $tagargs); if (sizeof($the_args) == 3) { list($file,$width,$height) = explode(" ", $tagargs); $tags = generate_tags($file,$width,$height); $new_content = substr($the_content,0,$spos); $new_content .= $tags; $new_content .= substr($the_content,($epos+1)); } else if (sizeof($the_args) == 4) { list($file,$poster,$width,$height) = explode(" ", $tagargs); $tags = generate_tags($file,$width,$height,$poster); $new_content = substr($the_content,0,$spos); $new_content .= $tags; $new_content .= substr($the_content,($epos+1)); } else if (sizeof($the_args) == 5) { list($file,$width,$height,$autoplay,$controller) = explode(" ",$tagargs); $poster = ""; $tags = generate_tags($file,$width,$height,$poster,$autoplay,$controller); $new_content = substr($the_content,0,$spos); $new_content .= $tags; $new_content .= substr($the_content,($epos+1)); } else if (sizeof($the_args) == 6) { list($file,$poster,$width,$height,$autoplay,$controller) = explode(" ",$tagargs); $tags = generate_tags($file,$width,$height,$poster,$autoplay,$controller); $new_content = substr($the_content,0,$spos); $new_content .= $tags; $new_content .= substr($the_content,($epos+1)); } if ($epos+1 < strlen($the_content)) { $new_content = quicktime_post($new_content); } return $new_content; } else { return $the_content; } } function generate_tags($file, $width, $height, $poster = "", $autoplay = "false", $controller = "") { $script_tags = "\n\n"; $script_tags .= "\n"; return $script_tags; } function quicktime_post_js() { $linktojs = get_bloginfo('wpurl') . "/wp-content/plugins/quicktimepost.js"; echo "\n\n"; } add_filter('the_content', 'quicktime_post'); add_filter('the_excerpt','quicktime_post'); add_action('wp_head','quicktime_post_js'); ?>