. ************************************************************************** In short, this plugin is free to use by anyone and everyone. You are welcome to use it on a commercial site or whatever you want. However, I do very much appreciate donations for all of my time and effort, although they obviously aren't required for you to use this plugin. You can even just buy me a beer ( http://www.viper007bond.com/donate/ ). If you sell this code (i.e. are a web developer selling features provided via this plugin to clients), it would be very nice if you threw some of your profits my way. After all, you are profiting off my hard work. ;) Thanks and enjoy this plugin! ************************************************************************** If you're here looking for how to add support for both TinyMCE 2 and TinyMCE 3 buttons, then you'll need to check out the legacy version of this plugin. The version you are looking at only supports WordPress 2.6 and newer to keep the code of this plugin siginificantly simpler as well as encourage people to update. The legacy version can be found here: http://downloads.wordpress.org/plugin/vipers-video-quicktags.5.4.4.zip **************************************************************************/ class VipersVideoQuicktags { var $version = '6.2.19'; var $settings = array(); var $defaultsettings = array(); var $swfobjects = array(); var $usedids = array(); var $standardcss; var $cssalignments; var $flvskins = array(); var $wpheadrun = FALSE; var $adminwarned = FALSE; var $customfeedtext; // Class initialization function VipersVideoQuicktags() { global $wpmu_version, $shortcode_tags, $wp_scripts; // This version of VVQ requires WordPress 2.8+ if ( !function_exists('esc_attr') ) { load_plugin_textdomain( 'vipers-video-quicktags', '/wp-content/plugins/vipers-video-quicktags/localization' ); // Old format if ( isset( $_GET['activate'] ) ) { wp_redirect( 'plugins.php?deactivate=true' ); exit(); } else { // Replicate deactivate_plugins() $current = get_option('active_plugins'); $plugins = array( 'vipers-video-quicktags/vipers-video-quicktags.php', 'vipers-video-quicktags.php' ); foreach ( $plugins as $plugin ) { if( !in_array( $plugin, $current ) ) continue; array_splice( $current, array_search( $plugin, $current ), 1 ); // Fixed Array-fu! } update_option('active_plugins', $current); add_action( 'admin_notices', array(&$this, 'WPVersionTooOld') ); return; } } // Redirect the old settings page to the new one for any old links if ( is_admin() && isset($_GET['page']) && 'vipers-video-quicktags.php' == $_GET['page'] ) { wp_redirect( admin_url( 'options-general.php?page=vipers-video-quicktags' ) ); exit(); } // For debugging (this is limited to localhost installs since it's not nonced) if ( !empty($_GET['resetalloptions']) && 'localhost' == $_SERVER['HTTP_HOST'] && is_admin() && 'vipers-video-quicktags' == $_GET['page'] ) { update_option( 'vvq_options', array() ); wp_redirect( admin_url( 'options-general.php?page=vipers-video-quicktags&defaults=true' ) ); exit(); } // Load up the localization file if we're using WordPress in a different language // Place it in this plugin's "localization" folder and name it "vipers-video-quicktags-[value in wp-config].mo" load_plugin_textdomain( 'vipers-video-quicktags', FALSE, '/vipers-video-quicktags/localization' ); // Create default settings array $this->defaultsettings = apply_filters( 'vvq_defaultsettings', array( 'youtube' => array( 'button' => 1, 'width' => 425, 'height' => 344, 'color1' => '#666666', 'color2' => '#EFEFEF', 'border' => 0, 'rel' => 0, 'fs' => 1, 'autoplay' => 0, 'loop' => 0, 'showsearch' => 0, 'showinfo' => 0, 'hd' => 0, 'previewurl' => 'http://www.youtube.com/watch?v=zlfKdbWwruY', 'aspectratio' => 1, ), 'googlevideo' => array( 'button' => 0, 'width' => 400, 'height' => 326, 'autoplay' => 0, 'fs' => 1, 'previewurl' => 'http://video.google.com/videoplay?docid=-6006084025483872237', 'aspectratio' => 1, ), 'vimeo' => array( 'button' => 1, 'width' => 400, 'height' => 300, 'color' => '#00ADEF', 'portrait' => 0, 'title' => 1, 'byline' => 1, 'fullscreen' => 1, 'previewurl' => 'http://www.vimeo.com/240975', 'aspectratio' => 1, ), 'dailymotion' => array( 'button' => 1, 'width' => 480, 'height' => 221, 'backgroundcolor' => '#DEDEDE', 'glowcolor' => '#FFFFFF', 'foregroundcolor' => '#333333', 'seekbarcolor' => '#FFC300', 'autoplay' => 0, 'related' => 0, 'previewurl' => 'http://www.dailymotion.com/video/x4cqyl_ferrari-p45-owner-exclusive-intervi_auto', 'aspectratio' => 1, ), 'veoh' => array( 'button' => 1, 'width' => 540, 'height' => 438, 'aspectratio' => 1, ), 'viddler' => array( 'button' => 0, ), 'metacafe' => array( 'button' => 0, 'width' => 400, 'height' => 345, 'aspectratio' => 1, ), 'bliptv' => array( 'button' => 1, 'width' => 400, 'height' => 330, 'aspectratio' => 1, ), 'wpvideo' => array( 'button' => 0, 'width' => 605, 'height' => 452, 'aspectratio' => 1, ), 'flickrvideo' => array( 'button' => 0, 'width' => 400, 'height' => 300, 'aspectratio' => 1, ), 'spike' => array( 'button' => 0, 'width' => 448, 'height' => 365, 'aspectratio' => 1, ), 'myspace' => array( 'button' => 0, 'width' => 425, 'height' => 360, 'aspectratio' => 1, ), 'flv' => array( 'button' => 0, // Agree to license 'width' => 400, 'height' => 320, 'skin' => '', 'customcolors' => 0, 'backcolor' => '#FFFFFF', 'frontcolor' => '#000000', 'lightcolor' => '#000000', 'screencolor' => '#000000', 'flashvars' => '', 'previewurl' => 'http://gdata.youtube.com/feeds/api/standardfeeds/recently_featured', ), 'quicktime' => array( 'button' => 0, // Marginal support, plugin focus is Flash 'width' => 400, 'height' => 300, 'dynamicload' => 1, ), 'videofile' => array( 'button' => 0, // Shit support 'width' => 400, 'height' => 300, 'usewmp' => 1, ), 'flash' => array( 'width' => 400, 'height' => 300, ), 'alignment' => 'center', 'tinymceline' => 1, 'customcss' => '', 'customfeedtext' => '', ) ); // Default customfeedtext. Change it via the settings page. $this->customfeedtext = '' . __( 'Click here to view the embedded video.', 'vipers-video-quicktags' ) . ''; $usersettings = (array) get_option('vvq_options'); // Upgrade settings $upgrade = false; if ( empty($usersettings['version']) ) $usersettings['version'] = '1.0.0'; if ( -1 == version_compare( $usersettings['version'], '6.0.0' ) ) { // Reset buttons foreach ( $this->defaultsettings as $type => $setting ) { if ( !is_array($this->defaultsettings[$type]) ) continue; if ( isset($usersettings[$type]['button']) ) unset($usersettings[$type]['button']); } $upgrade = true; } if ( -1 == version_compare( $usersettings['version'], '6.1.0' ) ) { // Custom FLV colors $colors = array( 'backcolor', 'frontcolor', 'lightcolor', 'screencolor' ); foreach ( $colors as $color ) { if ( !empty($usersettings['flv'][$color]) && $usersettings['flv'][$color] != $this->defaultsettings['flv'][$color] ) $usersettings['flv']['customcolors'] = 1; } $upgrade = true; } if ( -1 == version_compare( $usersettings['version'], '6.1.23' ) ) { // Change default YouTube preview video to one supporting HD (rather than only HQ) if ( !empty($usersettings['youtube']) && !empty($usersettings['youtube']['previewurl']) && 'http://www.youtube.com/watch?v=stdJd598Dtg' === $usersettings['youtube']['previewurl'] ) $usersettings['youtube']['previewurl'] = $this->defaultsettings['youtube']['previewurl']; $upgrade = true; } if ( -1 == version_compare( $usersettings['version'], '6.2.10' ) ) { if ( false !== strpos( $usersettings['customfeedtext'], '
' ) || false !== strpos( $usersettings['customfeedtext'], '
' ) ) $usersettings['customfeedtext'] = str_replace( array( '', '
' ), '', $usersettings['customfeedtext'] ); $upgrade = true; } if ( $upgrade ) { $usersettings['version'] = $this->version; update_option( 'vvq_options', $usersettings ); } // Use the defaults as a base, merge in any user defined changes $this->settings = $this->defaultsettings; if ( $usersettings !== $this->defaultsettings ) { foreach ( (array) $usersettings as $key1 => $value1 ) { if ( is_array($value1) ) { foreach ( $value1 as $key2 => $value2 ) { $this->settings[$key1][$key2] = $value2; } } else { $this->settings[$key1] = $value1; } } } // Register general hooks add_action( 'admin_menu', array(&$this, 'RegisterSettingsPage') ); add_filter( 'plugin_action_links', array(&$this, 'AddPluginActionLink'), 10, 2 ); add_action( 'admin_post_vvqsettings', array(&$this, 'POSTHandler') ); add_action( 'wp_head', array(&$this, 'Head') ); add_action( 'admin_head', array(&$this, 'Head') ); add_action( 'the_content', array(&$this, 'SWFObjectCalls'), 50 ); add_filter( 'widget_text', 'do_shortcode', 11 ); // Videos in the text widget add_action( 'widget_text', array(&$this, 'SWFObjectCalls'), 50 ); // Hide the donate button on WPMU installs as admins probably don't want it there if ( !empty($wpmu_version) ) add_filter( 'vvq_donatebutton', array(&$this, 'ReturnFalse'), 5 ); // Register shortcodes add_shortcode( 'youtube', array(&$this, 'shortcode_youtube') ); add_shortcode( 'googlevideo', array(&$this, 'shortcode_googlevideo') ); add_shortcode( 'gvideo', array(&$this, 'shortcode_googlevideo') ); // Not the preferred format add_shortcode( 'dailymotion', array(&$this, 'shortcode_dailymotion') ); add_shortcode( 'vimeo', array(&$this, 'shortcode_vimeo') ); add_shortcode( 'veoh', array(&$this, 'shortcode_veoh') ); add_shortcode( 'viddler', array(&$this, 'shortcode_viddler') ); add_shortcode( 'metacafe', array(&$this, 'shortcode_metacafe') ); add_shortcode( 'blip.tv', array(&$this, 'shortcode_bliptv') ); add_shortcode( 'bliptv', array(&$this, 'shortcode_bliptv') ); // Not the preferred format add_shortcode( 'flickr video', array(&$this, 'shortcode_flickrvideo') ); // WordPress.com add_shortcode( 'flickrvideo', array(&$this, 'shortcode_flickrvideo') ); // Normal format add_shortcode( 'ifilm', array(&$this, 'shortcode_ifilm') ); add_shortcode( 'spike', array(&$this, 'shortcode_ifilm') ); add_shortcode( 'myspace', array(&$this, 'shortcode_myspace') ); add_shortcode( 'stage6', array(&$this, 'shortcode_stage6') ); // Stage6 = dead, but we still need to handle it add_shortcode( 'flv', array(&$this, 'shortcode_flv') ); add_shortcode( 'quicktime', array(&$this, 'shortcode_quicktime') ); add_shortcode( 'flash', array(&$this, 'shortcode_flash') ); add_shortcode( 'videofile', array(&$this, 'shortcode_videofile') ); add_shortcode( 'video', array(&$this, 'shortcode_videofile') ); // Legacy add_shortcode( 'avi', array(&$this, 'shortcode_videofile') ); // Legacy add_shortcode( 'mpeg', array(&$this, 'shortcode_videofile') ); // Legacy add_shortcode( 'wmv', array(&$this, 'shortcode_videofile') ); // Legacy // Anarchy Media Plugin / Kimili Flash Embed support but only if those plugins aren't enabled if ( !class_exists('KimiliFlashEmbed') && !function_exists('kml_flashembed') && !isset($shortcode_tags['kml_flashembed']) ) add_shortcode( 'kml_flashembed', array(&$this, 'shortcode_flash') ); // VideoPress support but only if the official plugin isn't installed if ( !function_exists('videopress_shortcode') && !isset($shortcode_tags['wpvideo']) ) add_shortcode( 'wpvideo', array(&$this, 'shortcode_videopress') ); // Register other scripts and styles wp_enqueue_script( 'swfobject' ); wp_register_script( 'qtobject', plugins_url('/vipers-video-quicktags/resources/qtobject.js'), array(), '1.0.2' ); if ( is_admin() ) { // Settings page only if ( isset($_GET['page']) && 'vipers-video-quicktags' == $_GET['page'] ) { add_action( 'admin_head', array(&$this, 'StyleTweaks' ) ); wp_enqueue_script( 'farbtastic' ); wp_enqueue_style( 'farbtastic' ); } // Editor pages only if ( in_array( basename($_SERVER['PHP_SELF']), apply_filters( 'vvq_editor_pages', array('post-new.php', 'page-new.php', 'post.php', 'page.php') ) ) ) { add_action( 'admin_head', array(&$this, 'EditorCSS') ); add_action( 'admin_footer', array(&$this, 'OutputjQueryDialogDiv') ); wp_enqueue_script( 'jquery-ui-dialog' ); wp_enqueue_style( 'vvq-jquery-ui', plugins_url('/vipers-video-quicktags/resources/vvq-jquery-ui.css'), array(), $this->version, 'screen' ); // Register editor button hooks add_filter( 'tiny_mce_version', array(&$this, 'tiny_mce_version') ); add_filter( 'mce_external_plugins', array(&$this, 'mce_external_plugins') ); add_action( 'edit_form_advanced', array(&$this, 'AddQuicktagsAndFunctions') ); add_action( 'edit_page_form', array(&$this, 'AddQuicktagsAndFunctions') ); if ( 1 == $this->settings['tinymceline'] ) { add_filter( 'mce_buttons', array(&$this, 'mce_buttons') ); } else { add_filter( 'mce_buttons_' . $this->settings['tinymceline'], array(&$this, 'mce_buttons') ); } } } if ( 1 == $this->settings['quicktime']['dynamicload'] ) add_action( 'wp_head', array(&$this, 'MaybeEnqueueQuicktimeJavascript'), 1 ); else wp_enqueue_script( 'qtobject' ); // Set up the CSS $this->cssalignments = array( 'left' => 'margin: 10px auto 10px 0;', 'center' => 'margin: 10px auto;', 'right' => 'margin: 10px 0 10px auto;', 'floatleft' => 'float: left;\n margin: 10px 10px 10px 0;', 'floatright' => 'float: right;\n margin: 10px 0 10px 10px;', ); $this->standardcss = '.vvqbox { display: block; max-width: 100%; visibility: visible !important; /* alignment CSS placeholder */ } .vvqbox img { max-width: 100%; height: 100%; } .vvqbox object { max-width: 100%; }'; $this->flvskins = apply_filters( 'vvq_flvskins', array( '' => __('Default', 'vipers-video-quicktags'), '3dpixelstyle' => __('3D Pixel Style', 'vipers-video-quicktags'), 'atomicred' => __('Atomic Red', 'vipers-video-quicktags'), 'bekle' => __('Bekle (Overlay)', 'vipers-video-quicktags'), 'bluemetal' => __('Blue Metal', 'vipers-video-quicktags'), 'comet' => __('Comet', 'vipers-video-quicktags'), 'controlpanel' => __('Control Panel', 'vipers-video-quicktags'), 'dangdang' => __('Dang Dang', 'vipers-video-quicktags'), 'fashion' => __('Fashion', 'vipers-video-quicktags'), 'festival' => __('Festival', 'vipers-video-quicktags'), 'grungetape' => __('Grunge Tape', 'vipers-video-quicktags'), 'icecreamsneaka' => __('Ice Cream Sneaka', 'vipers-video-quicktags'), 'kleur' => __('Kleur', 'vipers-video-quicktags'), 'magma' => __('Magma', 'vipers-video-quicktags'), 'metarby10' => __('Metarby 10', 'vipers-video-quicktags'), 'modieus' => __('Modieus (Stylish)', 'vipers-video-quicktags'), 'modieus_slim' => __('Modieus (Stylish) Slim', 'vipers-video-quicktags'), 'nacht' => __('Nacht', 'vipers-video-quicktags'), 'neon' => __('Neon', 'vipers-video-quicktags'), 'pearlized' => __('Pearlized', 'vipers-video-quicktags'), 'pixelize' => __('Pixelize', 'vipers-video-quicktags'), 'playcasso' => __('Play Casso', 'vipers-video-quicktags'), 'schoon' => __('Schoon', 'vipers-video-quicktags'), 'silverywhite' => __('Silvery White', 'vipers-video-quicktags'), 'simple' => __('Simple', 'vipers-video-quicktags'), 'snel' => __('Snel', 'vipers-video-quicktags'), 'stijl' => __('Stijl', 'vipers-video-quicktags'), 'traganja' => __('Traganja', 'vipers-video-quicktags'), ) ); } // This function gets called when the minimum WordPress version isn't met function WPVersionTooOld() { echo '' . sprintf( __( 'Viper\'s Video Quicktags requires WordPress 2.8 or newer. Please upgrade! By not upgrading, your blog is likely to be hacked.', 'vipers-video-quicktags' ), 'http://codex.wordpress.org/Upgrading_WordPress', 'http://wordpress.org/development/2009/09/keep-wordpress-secure/' ) . "
';
}
}
// If a URL wasn't passed, assume a video ID was passed instead
else {
$embedpath = 'v/' . $content;
$fallbacklink = 'http://www.youtube.com/watch?v=' . $content;
$fallbackcontent = '
';
}
// Setup the parameters
$color1 = $color2 = $border = $autoplay = $loop = $showsearch = $showinfo = $hd = '';
if ( '' != $atts['color1'] && $this->defaultsettings['youtube']['color1'] != $atts['color1'] )
$color1 = '&color1=0x' . str_replace( '#', '', $atts['color1'] );
if ( '' != $atts['color2'] && $this->defaultsettings['youtube']['color2'] != $atts['color2'] )
$color2 = '&color2=0x' . str_replace( '#', '', $atts['color2'] );
if ( $atts['border'] )
$border = '&border=1';
if ( $atts['autoplay'] )
$autoplay = '&autoplay=1';
if ( $atts['loop'] )
$loop = '&loop=1';
if ( $atts['hd'] )
$hd = '&hd=1';
$rel = ( 1 == $atts['rel'] ) ? '1' : '0';
$fs = ( 1 == $atts['fs'] ) ? '1' : '0';
$showsearch = ( 1 == $atts['showsearch'] ) ? '1' : '0';
$showinfo = ( 1 == $atts['showinfo'] ) ? '1' : '0';
$objectid = $this->videoid('youtube');
$this->swfobjects[$objectid] = array(
'width' => $atts['width'],
'height' => $atts['height'],
'url' => 'http://www.youtube.com/' . $embedpath . $color1 . $color2 . $border . '&rel=' . $rel . '&fs=' . $fs . '&showsearch=' . $showsearch . '&showinfo=' . $showinfo . $autoplay . $loop . $hd,
);
return '' . $fallbackcontent . '';
}
// Handle Google Video shortcodes
function shortcode_googlevideo( $atts, $content = '' ) {
$origatts = $atts;
$content = $this->wpuntexturize( $content );
// Handle WordPress.com shortcode format
if ( isset($atts[0]) ) {
$atts = $this->attributefix( $atts );
$content = $atts[0];
unset($atts[0]);
}
if ( empty($content) )
return $this->error( sprintf( __('No URL or video ID was passed to the %s BBCode', 'vipers-video-quicktags'), __('Google Video', 'vipers-video-quicktags') ) );
if ( is_feed() )
return $this->postlink();
// Set any missing $atts items to the defaults
$atts = shortcode_atts(array(
'width' => $this->settings['googlevideo']['width'],
'height' => $this->settings['googlevideo']['height'],
'autoplay' => $this->settings['googlevideo']['autoplay'],
'fs' => $this->settings['googlevideo']['fs'],
), $atts);
// Allow other plugins to modify these values (for example based on conditionals)
$atts = apply_filters( 'vvq_shortcodeatts', $atts, 'googlevideo', $origatts );
// If a URL was passed
if ( 'http://' == substr( $content, 0, 7 ) ) {
preg_match( '#http://video\.google\.([A-Za-z.]{2,5})/videoplay\?docid=([\d-]+)(.*?)#i', $content, $matches );
if ( empty($matches) || empty($matches[2]) ) return $this->error( sprintf( __('Unable to parse URL, check for correct %s format', 'vipers-video-quicktags'), __('Google Video', 'vipers-video-quicktags') ) );
$videoid = $matches[2];
}
// If a URL wasn't passed, assume a video ID was passed instead
else {
$videoid = $content;
}
// Setup the parameters
$flashvars = array();
if ( 1 == $atts['autoplay'] ) $flashvars['autoplay'] = '1';
if ( 1 == $atts['fs'] ) $flashvars['fs'] = 'true';
$objectid = $this->videoid('googlevideo');
$this->swfobjects[$objectid] = array( 'width' => $atts['width'], 'height' => $atts['height'], 'url' => 'http://video.google.com/googleplayer.swf?docid=' . $videoid, 'flashvars' => $flashvars );
return 'http://video.google.com/videoplay?docid=' . $videoid . '';
}
// Handle DailyMotion shortcodes
function shortcode_dailymotion( $atts, $content = '' ) {
$origatts = $atts;
$content = $this->wpuntexturize( $content );
if ( empty($content) )
return $this->error( sprintf( __('No URL or video ID was passed to the %s BBCode', 'vipers-video-quicktags'), __('YouTube', 'vipers-video-quicktags') ) );
if ( is_feed() )
return $this->postlink();
// Set any missing $atts items to the defaults
$atts = shortcode_atts(array(
'width' => $this->settings['dailymotion']['width'],
'height' => $this->settings['dailymotion']['height'],
'backgroundcolor' => $this->settings['dailymotion']['backgroundcolor'],
'glowcolor' => $this->settings['dailymotion']['glowcolor'],
'foregroundcolor' => $this->settings['dailymotion']['foregroundcolor'],
'seekbarcolor' => $this->settings['dailymotion']['seekbarcolor'],
'autoplay' => $this->settings['dailymotion']['autoplay'],
'related' => $this->settings['dailymotion']['related'],
), $atts);
// Allow other plugins to modify these values (for example based on conditionals)
$atts = apply_filters( 'vvq_shortcodeatts', $atts, 'dailymotion', $origatts );
// If a URL was passed
if ( 'http://' == substr( $content, 0, 7 ) ) {
//http://www.dailymotion.com/visited/search/top%2Bgear/video/x347lz_bugatti-veyron-407-kmh-la-plus-rapi_shortfilms
preg_match( '#http://(www.dailymotion|dailymotion)\.com/(.+)/([0-9a-zA-Z]+)\_(.*?)#i', $content, $matches );
if ( empty($matches) || empty($matches[3]) ) return $this->error( sprintf( __('Unable to parse URL, check for correct %s format', 'vipers-video-quicktags'), __('DailyMotion', 'vipers-video-quicktags') ) );
$videoid = $matches[3];
}
// If a URL wasn't passed, assume a video ID was passed instead
else {
$videoid = $content;
}
// Setup the parameters
$backgroundcolor = $glowcolor = $foregroundcolor = $seekbarcolor = '';
if ( '' != $atts['backgroundcolor'] && $this->defaultsettings['dailymotion']['backgroundcolor'] != $atts['backgroundcolor'] ) $backgroundcolor = 'background:' . str_replace( '#', '', $atts['backgroundcolor'] ) . ';';
if ( '' != $atts['glowcolor'] && $this->defaultsettings['dailymotion']['glowcolor'] != $atts['glowcolor'] ) $glowcolor = 'glow:' . str_replace( '#', '', $atts['glowcolor'] ) . ';';
if ( '' != $atts['foregroundcolor'] && $this->defaultsettings['dailymotion']['foregroundcolor'] != $atts['foregroundcolor'] ) $foregroundcolor = 'foreground:' . str_replace( '#', '', $atts['foregroundcolor'] ) . ';';
if ( '' != $atts['seekbarcolor'] && $this->defaultsettings['dailymotion']['seekbarcolor'] != $atts['seekbarcolor'] ) $seekbarcolor = 'special:' . str_replace( '#', '', $atts['seekbarcolor'] ) . ';';
$autoplay = ( 1 == $atts['autoplay'] ) ? '1' : '0';
$related = ( 1 == $atts['related'] ) ? '1' : '0';
$objectid = $this->videoid('dailymotion');
$this->swfobjects[$objectid] = array( 'width' => $atts['width'], 'height' => $atts['height'], 'url' => 'http://www.dailymotion.com/swf/' . $videoid . '&colors=' . $backgroundcolor . $glowcolor . $foregroundcolor . $seekbarcolor . '&autoPlay=' . $autoplay . '&related=' . $related );
return 'http://www.dailymotion.com/video' . $videoid . '';
}
// Handle Vimeo shortcodes
function shortcode_vimeo( $atts, $content = '' ) {
$origatts = $atts;
$content = $this->wpuntexturize( $content );
// Handle malformed WordPress.com shortcode format
if ( isset($atts[0]) ) {
$atts = $this->attributefix( $atts );
$content = $atts[0];
unset($atts[0]);
}
if ( empty($content) )
return $this->error( sprintf( __('No URL or video ID was passed to the %s BBCode', 'vipers-video-quicktags'), __('Vimeo', 'vipers-video-quicktags') ) );
if ( is_feed() )
return $this->postlink();
// Set any missing $atts items to the defaults
$atts = shortcode_atts(array(
'width' => $this->settings['vimeo']['width'],
'height' => $this->settings['vimeo']['height'],
'color' => $this->settings['vimeo']['color'],
'portrait' => $this->settings['vimeo']['portrait'],
'title' => $this->settings['vimeo']['title'],
'byline' => $this->settings['vimeo']['byline'],
'fullscreen' => $this->settings['vimeo']['fullscreen'],
), $atts);
// Allow other plugins to modify these values (for example based on conditionals)
$atts = apply_filters( 'vvq_shortcodeatts', $atts, 'vimeo', $origatts );
// If a URL was passed
if ( 'http://' == substr( $content, 0, 7 ) ) {
preg_match( '#http://(www.vimeo|vimeo)\.com(/|/clip:)(\d+)(.*?)#i', $content, $matches );
if ( empty($matches) || empty($matches[3]) ) return $this->error( sprintf( __('Unable to parse URL, check for correct %s format', 'vipers-video-quicktags'), __('Vimeo', 'vipers-video-quicktags') ) );
$videoid = $matches[3];
}
// If a URL wasn't passed, assume a video ID was passed instead
else {
$videoid = $content;
}
// Setup the parameters
$portrait = ( 1 == $atts['portrait'] ) ? '1' : '0';
$title = ( 1 == $atts['title'] ) ? '1' : '0';
$byline = ( 1 == $atts['byline'] ) ? '1' : '0';
$fullscreen = ( 1 == $atts['fullscreen'] ) ? '1' : '0';
$objectid = $this->videoid('vimeo');
// Gotta pass these via flashvars rather than the URL to keep for valid XHTML (Vimeo doesn't like &'s)
$flashvars = array(
'server' => 'www.vimeo.com',
'clip_id' => $videoid,
'show_portrait' => $portrait,
'show_title' => $title,
'show_byline' => $byline,
'fullscreen' => $fullscreen,
);
if ( '' != $atts['color'] && $this->defaultsettings['vimeo']['color'] != $atts['color'] )
$flashvars['color'] = str_replace( '#', '', $atts['color'] );
$this->swfobjects[$objectid] = array( 'width' => $atts['width'], 'height' => $atts['height'], 'url' => 'http://www.vimeo.com/moogaloop.swf', 'flashvars' => $flashvars );
return 'http://www.vimeo.com/' . $videoid . '';
}
// Handle Veoh shortcodes
function shortcode_veoh( $atts, $content = '' ) {
$origatts = $atts;
$content = $this->wpuntexturize( $content );
if ( empty($content) )
return $this->error( sprintf( __('No URL or video ID was passed to the %s BBCode', 'vipers-video-quicktags'), __('Veoh', 'vipers-video-quicktags') ) );
if ( is_feed() )
return $this->postlink();
// Set any missing $atts items to the defaults
$atts = shortcode_atts(array(
'width' => $this->settings['veoh']['width'],
'height' => $this->settings['veoh']['height'],
'autoplay' => 0,
), $atts);
// Allow other plugins to modify these values (for example based on conditionals)
$atts = apply_filters( 'vvq_shortcodeatts', $atts, 'veoh', $origatts );
// If a URL was passed
if ( 'http://' == substr( $content, 0, 7 ) ) {
$videoid = null;
// Old format
preg_match( '#http://(www.veoh|veoh)\.com/videos/([0-9a-zA-Z]+)(.*?)#i', $content, $matches );
if ( !empty($matches) && !empty($matches[2]) )
$videoid = $matches[2];
// Must be the new format then
if ( empty($videoid) ) {
preg_match( '#http://(www.veoh|veoh)\.com/(.*?)/watch/([0-9a-zA-Z]+)(.*?)#i', $content, $matches );
if ( !empty($matches) && !empty($matches[3]) )
$videoid = $matches[3];
}
if ( empty($videoid) )
return $this->error( sprintf( __('Unable to parse URL, check for correct %s format', 'vipers-video-quicktags'), __('Veoh', 'vipers-video-quicktags') ) );
}
// If a URL wasn't passed, assume a video ID was passed instead
else {
$videoid = $content;
}
$objectid = $this->videoid('veoh');
// Gotta pass these via flashvars rather than the URL to keep for valid XHTML (Veoh doesn't like &'s)
$flashvars = array(
'permalinkId' => $videoid,
'id' => 'anonymous',
'player' => 'videodetailsembedded',
'affiliateId' => '',
'videoAutoPlay' => $atts['autoplay'],
);
$this->swfobjects[$objectid] = array( 'width' => $atts['width'], 'height' => $atts['height'], 'url' => 'http://www.veoh.com/veohplayer.swf', 'flashvars' => $flashvars );
return 'http://www.veoh.com/videos/' . $videoid . '';
}
// Handle Viddler shortcodes
function shortcode_viddler( $atts, $content = '' ) {
$origatts = $atts;
if ( empty($atts['id']) )
return $this->error( __('Sorry, but the only format that is supported for Viddler is the WordPress.com-style format rather than the URL. You can find it in the "Embed This" window.', 'vipers-video-quicktags') );
if ( is_feed() )
return $this->postlink();
// Set any missing $atts items to the defaults
$atts = shortcode_atts(array(
'id' => '',
), $atts);
// Allow other plugins to modify these values (for example based on conditionals)
$atts = apply_filters( 'vvq_shortcodeatts', $atts, 'viddler', $origatts );
// Parse WordPress.com shortcode format
preg_match( '#(.*?)(&|&\#038;|&)w=(\d+)(&|&\#038;|&)h=(\d+)#i', $atts['id'], $matches );
$videoid = $matches[1];
$width = $matches[3];
$height = $matches[5];
if ( empty($videoid) || empty($width) || empty($height) ) return $this->error( sprintf( __('An invalid %s shortcode format was used. Please check your code.', 'vipers-video-quicktags'), __('Viddler', 'vipers-video-quicktags') ) );
$objectid = $this->videoid('viddler');
$this->swfobjects[$objectid] = array( 'width' => $width, 'height' => $height, 'url' => 'http://www.viddler.com/player/' . $videoid . '/' );
return '' . sprintf( __('Please enable Javascript and Flash to view this %3$s video.', 'vipers-video-quicktags'), 'http://www.google.com/support/bin/answer.py?answer=23852', 'http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash', __('Viddler', 'vipers-video-quicktags') ) . '';
}
// Handle Metacafe shortcodes
function shortcode_metacafe( $atts, $content = '' ) {
$origatts = $atts;
$content = $this->wpuntexturize( $content );
if ( empty($content) )
return $this->error( sprintf( __('No URL or video ID was passed to the %s BBCode', 'vipers-video-quicktags'), __('Metacafe', 'vipers-video-quicktags') ) );
if ( is_feed() )
return $this->postlink();
// Set any missing $atts items to the defaults
$atts = shortcode_atts(array(
'width' => $this->settings['metacafe']['width'],
'height' => $this->settings['metacafe']['height'],
), $atts);
// Allow other plugins to modify these values (for example based on conditionals)
$atts = apply_filters( 'vvq_shortcodeatts', $atts, 'metacafe', $origatts );
// If a URL was passed
if ( 'http://' == substr( $content, 0, 7 ) ) {
preg_match( '#http://(www.metacafe|metacafe)\.com/watch/(.*?)/(.*?)#i', $content, $matches );
if ( empty($matches) || empty($matches[2]) ) return $this->error( sprintf( __('Unable to parse URL, check for correct %s format', 'vipers-video-quicktags'), __('Metacafe', 'vipers-video-quicktags') ) );
$videoid = $matches[2];
}
// If a URL wasn't passed, assume a video ID was passed instead
else {
$videoid = $content;
}
$objectid = $this->videoid('metacafe');
$this->swfobjects[$objectid] = array( 'width' => $atts['width'], 'height' => $atts['height'], 'url' => 'http://www.metacafe.com/fplayer/' . $videoid . '/vipers_video_quicktags.swf' );
return '';
}
// Handle Blip.tv shortcodes
function shortcode_bliptv( $atts ) {
$origatts = $atts;
if ( empty($atts[0]) )
return $this->error( __('Sorry, but the only format that is supported for Blip.tv is the WordPress.com-style format. You can find it at Share -> Embed -> WordPress.com.', 'vipers-video-quicktags') );
if ( is_feed() )
return $this->postlink();
// Set any missing $atts items to the defaults
$atts = shortcode_atts(array(
0 => '',
'width' => $this->settings['bliptv']['width'],
'height' => $this->settings['bliptv']['height'],
), $atts);
// Allow other plugins to modify these values (for example based on conditionals)
$atts = apply_filters( 'vvq_shortcodeatts', $atts, 'bliptv', $origatts );
// Parse WordPress.com shortcode format
$params = $this->parse_str_periods( $atts[0] );
if ( empty($params['?posts_id']) ) return $this->error( sprintf( __('An invalid %s shortcode format was used. Please check your code.', 'vipers-video-quicktags'), __('Blip.tv', 'vipers-video-quicktags') ) );
$videoid = $params['?posts_id'];
$objectid = $this->videoid('bliptv');
$this->swfobjects[$objectid] = array( 'width' => $atts['width'], 'height' => $atts['height'], 'url' => 'http://blip.tv/scripts/flash/showplayer.swf?file=http://blip.tv/rss/flash/' . $videoid );
return '' . sprintf( __('Please enable Javascript and Flash to view this %3$s video.', 'vipers-video-quicktags'), 'http://www.google.com/support/bin/answer.py?answer=23852', 'http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash', __('Blip.tv', 'vipers-video-quicktags') ) . '';
}
// Handle VideoPress (WordPress.com) shortcodes
function shortcode_videopress( $atts ) {
$origatts = $atts;
if ( is_feed() )
return $this->postlink();
// Set any missing $atts items to the defaults
$atts = shortcode_atts(array(
0 => '',
'w' => false,
'width' => false,
'h' => false,
'height' => false,
), $atts);
// Allow other plugins to modify these values (for example based on conditionals)
$atts = apply_filters( 'vvq_shortcodeatts', $atts, 'videopress', $origatts );
if ( empty($atts[0]) )
return $this->error( sprintf( __('An invalid %s shortcode format was used. Please check your code.', 'vipers-video-quicktags'), __('VideoPress', 'vipers-video-quicktags') ) );
$atts['w'] = (int) $atts['w'];
$atts['width'] = (int) $atts['width'];
$atts['h'] = (int) $atts['h'];
$atts['height'] = (int) $atts['height'];
if ( $atts['w'] )
$atts['width'] = $atts['w'];
if ( !$atts['width'] )
$atts['width'] = $this->settings['wpvideo']['width'];
if ( $atts['h'] )
$atts['height'] = $atts['h'];
if ( !$atts['height'] )
$atts['height'] = round( ( $atts['width'] / $this->settings['wpvideo']['width'] ) * $this->settings['wpvideo']['height'] );
$objectid = $this->videoid('wpvideo');
$this->swfobjects[$objectid] = array( 'width' => $atts['width'], 'height' => $atts['height'], 'url' => 'http://s0.videopress.com/player.swf?v=1.01', 'flashvars' => array( 'guid' => $atts[0], 'seamlesstabbing' => 'true', 'overstretch' => 'true' ) );
return '' . sprintf( __('Please enable Javascript and Flash to view this %3$s video.', 'vipers-video-quicktags'), 'http://www.google.com/support/bin/answer.py?answer=23852', 'http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash', __('VideoPress', 'vipers-video-quicktags') ) . '';
}
// Handle Flickr videos
function shortcode_flickrvideo( $atts, $content = '' ) {
$origatts = $atts;
$content = $this->wpuntexturize( $content );
// Handle WordPress.com shortcode format
if ( isset($atts[0]) ) {
$atts = $this->attributefix( $atts );
$content = $atts[0];
unset($atts[0]);
}
if ( empty($content) )
return $this->error( sprintf( __('No URL or video ID was passed to the %s BBCode', 'vipers-video-quicktags'), __('Flickr Video', 'vipers-video-quicktags') ) );
if ( is_feed() )
return $this->postlink();
// Set any missing $atts items to the defaults
$atts = shortcode_atts(array(
'width' => $this->settings['flickrvideo']['width'],
'height' => $this->settings['flickrvideo']['height'],
'showinfobox' => 1,
), $atts);
// Allow other plugins to modify these values (for example based on conditionals)
$atts = apply_filters( 'vvq_shortcodeatts', $atts, 'flickrvideo', $origatts );
// If a URL was passed
if ( 'http://' == substr( $content, 0, 7 ) ) {
preg_match( '#http://(www.flickr|flickr)\.com/photos/(.+)/(\d+)(.*?)#i', $content, $matches );
if ( empty($matches) || empty($matches[3]) ) return $this->error( sprintf( __('Unable to parse URL, check for correct %s format', 'vipers-video-quicktags'), __('Flickr Video', 'vipers-video-quicktags') ) );
$videoid = $matches[3];
}
// If a URL wasn't passed, assume a video ID was passed instead
else {
$videoid = $content;
}
// Setup the parameters
$showinfobox = ( 1 == $atts['showinfobox'] ) ? 'true' : 'false';
$objectid = $this->videoid('flickrvideo');
$this->swfobjects[$objectid] = array( 'width' => $atts['width'], 'height' => $atts['height'], 'url' => 'http://www.flickr.com/apps/video/stewart.swf?v=1.161', 'flashvars' => array( 'photo_id' => $videoid, 'flickr_show_info_box' => $showinfobox ) );
return '' . __('Flickr Video', 'vipers-video-quicktags') . '';
}
// Handle IFILM aka Spike shortcodes for backwards compatibility
function shortcode_ifilm( $atts, $content = '' ) {
$origatts = $atts;
$content = $this->wpuntexturize( $content );
if ( empty($content) )
return $this->error( sprintf( __('No URL or video ID was passed to the %s BBCode', 'vipers-video-quicktags'), __('IFILM/Spike', 'vipers-video-quicktags') ) );
if ( is_feed() )
return $this->postlink();
// Set any missing $atts items to the defaults
$atts = shortcode_atts(array(
'width' => $this->settings['spike']['width'],
'height' => $this->settings['spike']['height'],
), $atts);
// Allow other plugins to modify these values (for example based on conditionals)
$atts = apply_filters( 'vvq_shortcodeatts', $atts, 'spike', $origatts );
// If a URL was passed
if ( 'http://' == substr( $content, 0, 7 ) ) {
preg_match( '#http://(www.ifilm|ifilm|www.spike|spike)\.com/(.+)/(\d+)#i', $content, $matches );
if ( empty($matches) || empty($matches[3]) ) return $this->error( sprintf( __('Unable to parse URL, check for correct %s format', 'vipers-video-quicktags'), __('IFILM/Spike', 'vipers-video-quicktags') ) );
$videoid = $matches[3];
}
// If a URL wasn't passed, assume a video ID was passed instead
else {
$videoid = $content;
}
$objectid = $this->videoid('ifilm');
$this->swfobjects[$objectid] = array( 'width' => $atts['width'], 'height' => $atts['height'], 'url' => 'http://www.spike.com/efp', 'flashvars' => array( 'flvbaseclip' => $videoid ) );
return 'http://www.spike.com/video/' . $videoid . '';
}
// Handle MySpace videos
function shortcode_myspace( $atts, $content = '' ) {
$origatts = $atts;
$content = $this->wpuntexturize( $content );
if ( empty($content) )
return $this->error( sprintf( __('No URL or video ID was passed to the %s BBCode', 'vipers-video-quicktags'), __('MySpace', 'vipers-video-quicktags') ) );
if ( is_feed() )
return $this->postlink();
// Set any missing $atts items to the defaults
$atts = shortcode_atts(array(
'width' => $this->settings['myspace']['width'],
'height' => $this->settings['myspace']['height'],
), $atts);
// Allow other plugins to modify these values (for example based on conditionals)
$atts = apply_filters( 'vvq_shortcodeatts', $atts, 'myspace', $origatts );
// If a URL was passed
if ( 'http://' == substr( $content, 0, 7 ) ) {
preg_match( '#http://(vids.myspace|myspacetv)\.com/index\.cfm\?fuseaction=vids\.individual(.+)videoid=(\d+)#i', $content, $matches ); // Had issues with the "&"
if ( empty($matches) || empty($matches[3]) ) return $this->error( sprintf( __('Unable to parse URL, check for correct %s format', 'vipers-video-quicktags'), __('MySpace', 'vipers-video-quicktags') ) );
$videoid = $matches[3];
}
// If a URL wasn't passed, assume a video ID was passed instead
else {
$videoid = $content;
}
$objectid = $this->videoid('myspace');
$this->swfobjects[$objectid] = array( 'width' => $atts['width'], 'height' => $atts['height'], 'url' => 'http://mediaservices.myspace.com/services/media/embed.aspx/m=' . $videoid );
return 'http://myspacetv.com/index.cfm?fuseaction=vids.individual&videoid=' . $videoid . '';
}
// Handle FLV videos
function shortcode_flv( $atts, $content = '' ) {
$origatts = $atts;
$content = $this->wpuntexturize( $content );
if ( empty($content) )
return $this->error( sprintf( __('No URL was passed to the %s BBCode', 'vipers-video-quicktags'), __('FLV', 'vipers-video-quicktags') ) );
if ( is_feed() )
return $this->postlink();
// Set any missing $atts items to the defaults
$atts = shortcode_atts( array(
'width' => $this->settings['flv']['width'],
'height' => $this->settings['flv']['height'],
'image' => false,
'customcolors' => $this->settings['flv']['customcolors'],
'backcolor' => $this->settings['flv']['backcolor'],
'frontcolor' => $this->settings['flv']['frontcolor'],
'lightcolor' => $this->settings['flv']['lightcolor'],
'screencolor' => $this->settings['flv']['screencolor'],
'volume' => false,
'bufferlength' => false,
'flashvars' => '',
), $atts );
// Allow other plugins to modify these values (for example based on conditionals)
$atts = apply_filters( 'vvq_shortcodeatts', $atts, 'flv', $origatts );
// Start setting up the flashvars
$flashvars = array(
'wmode' => 'transparent', // Allow skins with transparency to have the background color shine through (props rich)
'file' => $content,
'volume' => 100,
'bufferlength' => 15,
);
// Skin
if ( !empty($this->settings['flv']['skin']) && !empty($this->flvskins[$this->settings['flv']['skin']]) )
$flashvars['skin'] = plugins_url('/vipers-video-quicktags/resources/jw-flv-player/skins/' . $this->settings['flv']['skin'] . '.swf');
// Custom colors
if ( 1 == $atts['customcolors'] || !empty($origatts['backcolor']) )
$flashvars['backcolor'] = str_replace( '#', '', $atts['backcolor'] );
if ( 1 == $atts['customcolors'] || !empty($origatts['frontcolor']) )
$flashvars['frontcolor'] = str_replace( '#', '', $atts['frontcolor'] );
if ( 1 == $atts['customcolors'] || !empty($origatts['lightcolor']) )
$flashvars['lightcolor'] = str_replace( '#', '', $atts['lightcolor'] );
if ( 1 == $atts['customcolors'] || !empty($origatts['screencolor']) )
$flashvars['screencolor'] = str_replace( '#', '', $atts['screencolor'] );
// Copy in the defaults from the settings page
if ( !empty($this->settings['flv']['flashvars']) ) {
$params = $this->parse_str_periods( $this->settings['flv']['flashvars'] );
$flashvars = array_merge( $flashvars, $params );
}
// Copy in any one-off passed flashvars added via the "flashvars" parameter
if ( !empty($atts['flashvars']) ) {
$atts['flashvars'] = $this->wpuntexturize( str_replace( '&', '&', $atts['flashvars'] ) );
$params = $this->parse_str_periods( $atts['flashvars'] );
$flashvars = array_merge( $flashvars, $params );
}
// Add in additional one-off parameters
if ( false !== $atts['image'] )
$flashvars['image'] = $atts['image'];
if ( false !== $atts['volume'] )
$flashvars['volume'] = (int) $atts['volume'];
if ( false !== $atts['bufferlength'] )
$flashvars['bufferlength'] = (int) $atts['bufferlength'];
// No image yet? Okay, default to the URL to the video but .jpg instead of the existing extension
if ( !isset($flashvars['image']) && '.' == substr( $content, -4, 1 ) )
$flashvars['image'] = substr( $content, 0, -4 ) . '.jpg';
// Check if link is a RTMP stream and adjust accordingly if so
if ( 'rtmp' == substr( $content, 0 ,4 ) ) {
$flv_pos = strrpos( $content, '/' );
$flashvars['file'] = substr( $content, $flv_pos + 1 );
$flashvars['streamer'] = substr( $content, 0, $flv_pos );
}
$objectid = $this->videoid('flv');
$swfurl = plugins_url('/vipers-video-quicktags/resources/jw-flv-player/player.swf');
$this->swfobjects[$objectid] = array( 'width' => $atts['width'], 'height' => $atts['height'], 'url' => $swfurl, 'flashvars' => $flashvars );
return '' . htmlspecialchars( $content ) . '';
}
// Handle major pain in the ass Quicktime video files
function shortcode_quicktime( $atts, $content = '' ) {
$origatts = $atts;
$content = $this->wpuntexturize( $content );
if ( empty($content) )
return $this->error( sprintf( __('No URL was passed to the %s BBCode', 'vipers-video-quicktags'), __('Quicktime', 'vipers-video-quicktags') ) );
if ( is_feed() )
return $this->postlink();
// Set any missing $atts items to the defaults
$atts = shortcode_atts(array(
'width' => $this->settings['quicktime']['width'],
'height' => $this->settings['quicktime']['height'],
'autostart' => 0, // Deprecated (wrong name)
'autoplay' => 0,
'useplaceholder' => 0,
'placeholder' => str_replace( '.mov', '.jpg', $content ),
'controller' => 1,
), $atts);
// Allow other plugins to modify these values (for example based on conditionals)
$atts = apply_filters( 'vvq_shortcodeatts', $atts, 'quicktime', $origatts );
if ( 1 == $atts['useplaceholder'] && !empty($atts['placeholder']) ) {
$mov = $atts['placeholder'];
$href = ' myQTObject.addParam("href", "' . $content . '"); myQTObject.addParam("target", "myself");';
} else {
$mov = $content;
$href = '';
}
if ( 1 == $atts['autostart'] )
$autoplay = 'true';
else
$autoplay = ( 1 == $atts['autoplay'] ) ? 'true' : 'false';
$controller = ( 1 == $atts['controller'] ) ? 'true' : 'false';
return '';
}
// Handle super-duper pain in the ass regular video files
function shortcode_videofile( $atts, $content = '' ) {
$origatts = $atts;
$content = $this->wpuntexturize( $content );
if ( empty($content) )
return $this->error( sprintf( __('No URL was passed to the %s BBCode', 'vipers-video-quicktags'), __('generic video', 'vipers-video-quicktags') ) );
if ( is_feed() )
return $this->postlink();
// Set any missing $atts items to the defaults
$atts = shortcode_atts(array(
'width' => $this->settings['videofile']['width'],
'height' => $this->settings['videofile']['height'],
'usewmp' => $this->settings['videofile']['usewmp'],
), $atts);
// Allow other plugins to modify these values (for example based on conditionals)
$atts = apply_filters( 'vvq_shortcodeatts', $atts, 'videofile', $origatts );
// This is semi-temporary. Embedding generic video files is a major pain in the ass, so this part of the plugin is kinda half-heartedly coded.
if ( 1 == $atts['usewmp'] && FALSE !== strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') ) {
$atts['height'] = $atts['height'] + 64; // Compensate for the player controls
return '';
} else {
// Determine the MIME type
$mimetypes = apply_filters( 'vvqvideomimes', array(
'asf' => 'video/x-ms-asf',
'asx' => 'video/x-ms-asf',
'avi' => 'video/avi',
'm1v' => 'video/mpeg',
'mp3' => 'video/mpeg',
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'wmv' => 'video/x-ms-wmv',
) );
$mimetype = $mimetypes[array_pop(explode('.', $content))];
if ( empty($mimetype) ) $mimetype = 'video/mpeg'; // If we don't know the MIME type, just pick something (MPEG)
return '';
}
}
// Generic Flash embed allowing you to embed any type of Flash-based video
function shortcode_flash( $atts, $content = '' ) {
$origatts = $atts;
$content = $this->wpuntexturize( $content );
if ( !empty($atts['movie']) )
$content = $atts['movie'];
if ( empty($content) )
return $this->error( sprintf( __('No URL was passed to the %s BBCode', 'vipers-video-quicktags'), __('generic Flash embed', 'vipers-video-quicktags') ) );
if ( is_feed() )
return $this->postlink();
// Set any missing $atts items to the defaults
$atts = shortcode_atts(array(
'width' => $this->settings['flash']['width'],
'height' => $this->settings['flash']['height'],
'flashvars' => '',
), $atts);
// Allow other plugins to modify these values (for example based on conditionals)
$atts = apply_filters( 'vvq_shortcodeatts', $atts, 'flash', $origatts );
// Create Flashvars
$flashvars = array();
if ( !empty($atts['flashvars']) ) {
$atts['flashvars'] = str_replace( array('#038;', '&'), '&', $atts['flashvars'] ); // Fix formatting applied by WordPress
$params = $this->parse_str_periods( $atts['flashvars'] );
foreach ( $params as $key => $value )
$flashvars[$key] = $value;
}
$objectid = $this->videoid('flash');
$this->swfobjects[$objectid] = array( 'width' => $atts['width'], 'height' => $atts['height'], 'url' => $content, 'flashvars' => $flashvars );
return '' . sprintf( __('Please enable Javascript and Flash to view this %3$s video.', 'vipers-video-quicktags'), 'http://www.google.com/support/bin/answer.py?answer=23852', 'http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash', __('Flash', 'vipers-video-quicktags') ) . '';
}
// Output the SWFObject calls that replace all of the placeholders created by the shortcode handlers with the Flash videos (this is per post now)
function SWFObjectCalls( $content ) {
global $wpmu_version;
if ( is_feed() || empty($this->swfobjects) ) return $content;
// Abort if wp_head() is missing from the theme
//if ( FALSE == $this->wpheadrun ) return $content;
$content .= "\n\n";
// Clear outputted calls
$this->swfobjects = array();
return $content;
}
// WordPress' js_escape() won't allow <, >, or " -- instead it converts it to an HTML entity. This is a "fixed" function that's used when needed.
function js_escape($text) {
$safe_text = addslashes($text);
$safe_text = preg_replace('/(x)?0*(?(1)27|39);?/i', "'", stripslashes($safe_text));
$safe_text = preg_replace("/\r?\n/", "\\n", addslashes($safe_text));
$safe_text = str_replace('\\\n', '\n', $safe_text);
return apply_filters('js_escape', $safe_text, $text);
}
// This function always return FALSE (who woulda guessed?)
function ReturnFalse() { return FALSE; }
}
// Start this plugin once all other plugins are fully loaded
add_action( 'init', 'VipersVideoQuicktags' ); function VipersVideoQuicktags() { global $VipersVideoQuicktags; $VipersVideoQuicktags = new VipersVideoQuicktags(); }
?>