. ************************************************************************** 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.0.0'; var $settings = array(); var $defaultsettings = array(); var $swfobjects = array(); var $standardcss; var $cssalignments; // Class initialization function VipersVideoQuicktags() { global $wp_db_version, $wpmu_version; // This version of VVQ requires WordPress 2.6+ if ( !function_exists('plugins_url') ) { 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() && '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 = array( 'youtube' => array( 'button' => 1, 'width' => 425, 'height' => 344, 'color1' => '#666666', 'color2' => '#EFEFEF', 'border' => 0, 'rel' => 1, 'fs' => 1, 'autoplay' => 0, 'loop' => 0, 'highqual' => 1, 'previewurl' => 'http://www.youtube.com/watch?v=stdJd598Dtg', 'aspectratio' => 1, ), 'googlevideo' => array( 'button' => 1, 'width' => 400, 'height' => 326, 'autoplay' => 0, 'previewurl' => 'http://video.google.com/videoplay?docid=-6006084025483872237', 'aspectratio' => 1, ), 'dailymotion' => array( 'button' => 1, 'width' => 420, 'height' => 336, 'backgroundcolor' => '#DEDEDE', 'glowcolor' => '#FFFFFF', 'foregroundcolor' => '#333333', 'seekbarcolor' => '#FFC300', 'autoplay' => 0, 'related' => 0, 'previewurl' => 'http://www.dailymotion.com/video/x347lz_bugatti-veyron-407-kmh-la-plus-rapi_shortfilms', '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, ), 'veoh' => array( 'button' => 1, 'width' => 540, 'height' => 438, 'aspectratio' => 1, ), 'viddler' => array( 'button' => 1, ), 'metacafe' => array( 'button' => 1, 'width' => 400, 'height' => 345, 'aspectratio' => 1, ), 'bliptv' => array( 'button' => 1, 'width' => 400, 'height' => 330, 'aspectratio' => 1, ), 'flickrvideo' => array( 'button' => 1, 'width' => 400, 'height' => 300, 'aspectratio' => 1, ), 'spike' => array( 'button' => 1, 'width' => 448, 'height' => 365, 'aspectratio' => 1, ), 'myspace' => array( 'button' => 1, 'width' => 425, 'height' => 360, 'aspectratio' => 1, ), 'flv' => array( 'button' => 0, // Agree to license 'width' => 400, 'height' => 300, 'backcolor' => '#FFFFFF', 'frontcolor' => '#000000', 'lightcolor' => '#000000', 'screencolor' => '#000000', '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', 'customcss' => '', ); // Setup the settings by using the default as a base and then adding in any changed values // This allows settings arrays from old versions to be used even though they are missing values $usersettings = (array) get_option('vvq_options'); $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; } } } // Force changes if upgrading if ( empty($this->settings['version']) || -1 == version_compare($this->settings['version'], '6.0.0') ) { $usersettings = (array) get_option('vvq_options'); foreach ( $this->defaultsettings as $type => $setting ) { if ( !is_array($this->defaultsettings[$type]) ) continue; if ( isset($usersettings[$type]['button']) ) unset($usersettings[$type]['button']); // Reset buttons } $usersettings['version'] = $this->version; update_option( 'vvq_options', $usersettings ); } // 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, 'Styles') ); add_action( 'wp_footer', array(&$this, 'SWFObjectCalls') ); add_filter( 'widget_text', 'do_shortcode', 11 ); // Videos in the text widget // Register scripts and styles wp_enqueue_script( 'swfobject', plugins_url('/vipers-video-quicktags/resources/swfobject.js'), array(), '2.1' ); wp_register_script( 'qtobject', plugins_url('/vipers-video-quicktags/resources/qtobject.js'), array(), '1.0.2' ); if ( is_admin() ) { // Settings page only if ( 'vipers-video-quicktags' == $_GET['page'] ) { add_action( 'admin_head', array(&$this, 'StyleTweaks' ) ); wp_enqueue_script( 'farbtastic', plugins_url('/vipers-video-quicktags/resources/farbtastic/farbtastic.js'), array('jquery'), '1.2' ); wp_enqueue_style( 'farbtastic', plugins_url('/vipers-video-quicktags/resources/farbtastic/farbtastic.css'), array(), '1.2', 'screen' ); } // 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') ); // If old version of jQuery UI, then replace it to fix a bug with the UI core if ( $wp_db_version < 8601 ) { wp_deregister_script( 'jquery-ui-core' ); wp_enqueue_script( 'jquery-ui-core', plugins_url('/vipers-video-quicktags/resources/jquery-ui/ui.core.js'), array('jquery'), '1.5.2' ); } wp_enqueue_script( 'jquery-ui-draggable', plugins_url('/vipers-video-quicktags/resources/jquery-ui/ui.draggable.js'), array('jquery-ui-core'), '1.5.2' ); wp_enqueue_script( 'jquery-ui-resizable', plugins_url('/vipers-video-quicktags/resources/jquery-ui/ui.resizable.js'), array('jquery-ui-core'), '1.5.2' ); wp_enqueue_script( 'jquery-ui-dialog', plugins_url('/vipers-video-quicktags/resources/jquery-ui/ui.dialog.js'), array('jquery-ui-core'), '1.5.2' ); wp_enqueue_style( 'vvq-jquery-ui', plugins_url('/vipers-video-quicktags/resources/jquery-ui/vvq-jquery-ui.css'), array(), $this->version, 'screen' ); } } if ( 1 == $this->settings['quicktime']['dynamicload'] ) add_action( 'wp_head', array(&$this, 'MaybeEnqueueQuicktimeJavascript'), 1 ); else wp_enqueue_script( 'qtobject' ); // 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( 'video', array(&$this, 'shortcode_videofile') ); add_shortcode( 'flash', array(&$this, 'shortcode_flash') ); // Register editor button hooks add_filter( 'mce_external_plugins', array(&$this, 'mce_external_plugins') ); add_filter( 'mce_buttons_3', array(&$this, 'mce_buttons') ); add_action( 'edit_form_advanced', array(&$this, 'AddQuicktagsAndFunctions') ); // 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 ); // 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 { width: 100%; height: 100%; } .vvqbox object { max-width: 100%; }'; } // This function gets called when the minimum WordPress version isn't met function WPVersionTooOld() { echo '

' . sprintf( __( 'This version of Viper\'s Video Quicktags requires WordPress 2.6 or newer. Please upgrade or use the legacy version of this plugin.', 'vipers-video-quicktags' ), 'http://codex.wordpress.org/Upgrading_WordPress', 'http://downloads.wordpress.org/plugin/vipers-video-quicktags.5.4.4.zip' ) . "

\n"; } // Register the settings page that allows plugin configuration function RegisterSettingsPage() { add_options_page( __("Viper's Video Quicktags Configuration", 'vipers-video-quicktags'), __('Video Quicktags', 'vipers-video-quicktags'), 'manage_options', 'vipers-video-quicktags', array(&$this, 'SettingsPage') ); } // Add a link to the settings page to the plugins list function AddPluginActionLink( $links, $file ) { static $this_plugin; if( empty($this_plugin) ) $this_plugin = plugin_basename(__FILE__); if ( $file == $this_plugin ) { $settings_link = '' . __('Settings') . ''; array_unshift( $links, $settings_link ); } return $links; } // Check the posts to be displayed looking for the QuickTime tag. If found, load the JS script. function MaybeEnqueueQuicktimeJavascript() { global $wp_query; // Abort if no posts (obviously) if ( !is_array($wp_query->posts) || empty($wp_query->posts) ) return; // Loop through each post looking for the shortcode foreach ( $wp_query->posts as $post ) { if ( FALSE !== stristr( $post->post_content, '[quicktime') ) { wp_enqueue_script( 'qtobject' ); return; } } } // Load the custom TinyMCE plugin function mce_external_plugins( $plugins ) { $plugins['vipersvideoquicktags'] = plugins_url('/vipers-video-quicktags/resources/tinymce3/editor_plugin.js'); return $plugins; } // Add the custom TinyMCE buttons function mce_buttons( $buttons ) { array_push( $buttons, 'vvqYouTube', 'vvqGoogleVideo', 'vvqDailyMotion', 'vvqVimeo', 'vvqVeoh', 'vvqViddler', 'vvqMetacafe', 'vvqBlipTV', 'vvqFlickrVideo', 'vvqSpike', 'vvqMySpace', 'vvqFLV', 'vvqQuicktime', 'vvqVideoFile' ); return $buttons; } // Hide TinyMCE buttons the user doesn't want to see + some misc editor CSS function EditorCSS() { echo "\n"; } // Add the old style buttons to the non-TinyMCE editor views and output all of the JS for the button function + dialog box function AddQuicktagsAndFunctions() { $types = array( 'youtube' => array( __('YouTube', 'vipers-video-quicktags'), __('Embed a video from YouTube', 'vipers-video-quicktags'), __('Please enter the URL at which the video can be viewed.', 'vipers-video-quicktags'), 'http://www.youtube.com/watch?v=stdJd598Dtg', ), 'googlevideo' => array( __('Google Video', 'vipers-video-quicktags'), __('Embed a video from Google Video', 'vipers-video-quicktags'), __('Please enter the URL at which the video can be viewed.', 'vipers-video-quicktags'), 'http://video.google.com/videoplay?docid=-6006084025483872237', ), 'dailymotion' => array( __('DailyMotion', 'vipers-video-quicktags'), __('Embed a video from DailyMotion', 'vipers-video-quicktags'), __('Please enter the URL at which the video can be viewed.', 'vipers-video-quicktags'), 'http://www.dailymotion.com/video/x347lz_bugatti-veyron-407-kmh-la-plus-rapi_shortfilms', ), 'vimeo' => array( __('Vimeo', 'vipers-video-quicktags'), __('Embed a video from Vimeo', 'vipers-video-quicktags'), __('Please enter the URL at which the video can be viewed.', 'vipers-video-quicktags'), 'http://www.vimeo.com/240975', ), 'veoh' => array( __('Veoh', 'vipers-video-quicktags'), __('Embed a video from Veoh', 'vipers-video-quicktags'), __('Please enter the URL at which the video can be viewed.', 'vipers-video-quicktags'), 'http://www.veoh.com/videos/v14185855NK3BNfQa', ), 'viddler' => array( __('Viddler', 'vipers-video-quicktags'), __('Embed a video from Viddler', 'vipers-video-quicktags'), sprintf( __("Please enter the WordPress.com-style embed tag for the Viddler video. See Help for details. In the future, you don't need to actually open this window — you can just paste directly into the editor.", 'vipers-video-quicktags'), admin_url('options-general.php?page=vipers-video-quicktags&tab=help#vvq-viddlerhelp') ), '[viddler id=fad7437b&w=437&h=370]', ), 'metacafe' => array( __('Metacafe', 'vipers-video-quicktags'), __('Embed a video from Metacafe', 'vipers-video-quicktags'), __('Please enter the URL at which the video can be viewed.', 'vipers-video-quicktags'), 'http://www.metacafe.com/watch/1609225/truck_tries_to_outrun_train/', ), 'bliptv' => array( __('Blip.tv', 'vipers-video-quicktags'), __('Embed a video from Blip.tv', 'vipers-video-quicktags'), sprintf( __("Please enter the WordPress.com-style embed tag for the Blip.tv video. See Help for details. In the future, you don't need to actually open this window — you can just paste directly into the editor.", 'vipers-video-quicktags'), admin_url('options-general.php?page=vipers-video-quicktags&tab=help#vvq-bliptvhelp') ), '[blip.tv ?posts_id=1213119&dest=-1]', ), 'flickrvideo' => array( __('Flickr Video', 'vipers-video-quicktags'), __('Embed a video from Flickr Video', 'vipers-video-quicktags'), __('Please enter the URL at which the video can be viewed.', 'vipers-video-quicktags'), 'http://www.flickr.com/photos/michales/2418623193', ), 'spike' => array( __('IFILM/Spike', 'vipers-video-quicktags'), __('Embed a video from IFILM/Spike.com', 'vipers-video-quicktags'), __('Please enter the URL at which the video can be viewed.', 'vipers-video-quicktags'), 'http://www.spike.com/video/psychic-cop-shows/2710582', ), 'myspace' => array( __('MySpace', 'vipers-video-quicktags'), __('Embed a video from MySpace', 'vipers-video-quicktags'), __('Please enter the URL at which the video can be viewed.', 'vipers-video-quicktags'), 'http://vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid=1387215221', ), 'flv' => array( __('FLV', 'vipers-video-quicktags'), __('Embed a Flash Video (FLV) file', 'vipers-video-quicktags'), sprintf( __('Please enter the URL to the %1$s file.', 'vipers-video-quicktags'), __('Flash Video (FLV)', 'vipers-video-quicktags') ), 'http://yoursite.com/videos/cool-video.flv', ), 'quicktime' => array( __('Quicktime', 'vipers-video-quicktags'), __('Embed a Quicktime video file', 'vipers-video-quicktags'), sprintf( __('Please enter the URL to the %1$s file.', 'vipers-video-quicktags'), __('Quicktime', 'vipers-video-quicktags') ), 'http://yoursite.com/videos/cool-video.mov', ), 'videofile' => array( __('Video File', 'vipers-video-quicktags'), __('Embed a generic video file', 'vipers-video-quicktags'), sprintf( __('Please enter the URL to the %1$s file.', 'vipers-video-quicktags'), __('generic video', 'vipers-video-quicktags') ), 'http://yoursite.com/videos/cool-video.avi', ), ); $buttonhtml = $datajs = ''; foreach ( $types as $type => $strings ) { // HTML for quicktag button if ( 1 == $this->settings[$type]['button'] ) $buttonshtml .= ''; // Create the data array $datajs .= " VVQData['$type'] = {\n"; $datajs .= ' title: "' . $this->js_escape( ucwords( $strings[1] ) ) . '",' . "\n"; $datajs .= ' instructions: "' . $this->js_escape( $strings[2] ) . '",' . "\n"; $datajs .= ' example: "' . js_escape( $strings[3] ) . '"'; if ( !empty($this->settings[$type]['width']) && !empty($this->settings[$type]['height']) ) { $datajs .= ",\n width: " . $this->settings[$type]['width'] . ",\n"; $datajs .= ' height: ' . $this->settings[$type]['height']; } $datajs .= "\n };\n"; } ?> used to display the dialog box function OutputjQueryDialogDiv() { ?>
defaultsettings as $type => $settings ) { if ( !is_array($this->defaultsettings[$type]) ) continue; foreach ( $fields as $setting ) { if ( isset($usersettings[$type][$setting]) ) unset( $usersettings[$type][$setting] ); } } $defaults = TRUE; break; } // Copy in the results of the form foreach ( $this->defaultsettings as $type => $settings ) { if ( !is_array($this->defaultsettings[$type]) ) continue; foreach ( $fields as $setting ) { if ( isset($_POST['vvq'][$type][$setting]) ) $usersettings[$type][$setting] = (int) $_POST['vvq'][$type][$setting]; else $usersettings[$type][$setting] = 0; // Width and height are required, clear if 0 if ( 0 === $usersettings[$type][$setting] && in_array( $setting, array( 'width', 'height' ) ) ) unset( $usersettings[$type][$setting] ); } } break; case 'additional': // Check for the defaults button if ( !empty($_POST['vvq-defaults']) ) { unset( $usersettings['alignment'], $usersettings['videofile']['usewmp'], $usersettings['quicktime']['dynamicload'] ); // Custom CSS is skipped $defaults = TRUE; break; } $usersettings['alignment'] = $_POST['vvq-alignment']; $usersettings['videofile']['usewmp'] = (int) $_POST['vvq-videofile-usewmp']; $usersettings['quicktime']['dynamicload'] = (int) $_POST['vvq-quicktime-dynamicload']; if ( empty($wpmu_version) ) $usersettings['customcss'] = trim( strip_tags( $_POST['vvq-customcss'] ) ); break; case 'youtube': // Check for the defaults button if ( !empty($_POST['vvq-defaults']) ) { $usersettings['youtube'] = array(); $defaults = TRUE; break; } // Copy in the results of the form $usersettings['youtube']['previewurl'] = trim( $_POST['vvq-youtube-previewurl'] ); $usersettings['youtube']['width'] = (int) $_POST['vvq-youtube-width']; $usersettings['youtube']['height'] = (int) $_POST['vvq-youtube-height']; $usersettings['youtube']['color1'] = strtoupper( trim( $_POST['vvq-youtube-color1'] ) ); $usersettings['youtube']['color2'] = strtoupper( trim( $_POST['vvq-youtube-color2'] ) ); $usersettings['youtube']['border'] = (int) $_POST['vvq-youtube-border']; $usersettings['youtube']['rel'] = (int) $_POST['vvq-youtube-rel']; $usersettings['youtube']['fs'] = (int) $_POST['vvq-youtube-fs']; $usersettings['youtube']['autoplay'] = (int) $_POST['vvq-youtube-autoplay']; $usersettings['youtube']['loop'] = (int) $_POST['vvq-youtube-loop']; $usersettings['youtube']['highqual'] = (int) $_POST['vvq-youtube-highqual']; $usersettings['youtube']['aspectratio'] = (int) $_POST['vvq-youtube-aspectratio']; // Fill in an missing items with the defaults if ( empty($usersettings['youtube']['previewurl']) ) $usersettings['youtube']['previewurl'] = $this->defaultsettings['youtube']['previewurl']; if ( empty($usersettings['youtube']['width']) ) $usersettings['youtube']['width'] = $this->defaultsettings['youtube']['width']; if ( empty($usersettings['youtube']['height']) ) $usersettings['youtube']['height'] = $this->defaultsettings['youtube']['height']; if ( empty($usersettings['youtube']['color1']) ) $usersettings['youtube']['color1'] = $this->defaultsettings['youtube']['color1']; if ( empty($usersettings['youtube']['color2']) ) $usersettings['youtube']['color2'] = $this->defaultsettings['youtube']['color2']; // Check data validity if ( '#' != substr( $usersettings['youtube']['color1'], 0, 1 ) ) $usersettings['youtube']['color1'] = '#' . $usersettings['youtube']['color1']; if ( '#' != substr( $usersettings['youtube']['color2'], 0, 1 ) ) $usersettings['youtube']['color2'] = '#' . $usersettings['youtube']['color2']; break; case 'googlevideo': // Check for the defaults button if ( !empty($_POST['vvq-defaults']) ) { $usersettings['googlevideo'] = array(); $defaults = TRUE; break; } // Copy in the results of the form $usersettings['googlevideo']['previewurl'] = (int) $_POST['vvq-googlevideo-previewurl']; $usersettings['googlevideo']['width'] = (int) $_POST['vvq-googlevideo-width']; $usersettings['googlevideo']['height'] = (int) $_POST['vvq-googlevideo-height']; $usersettings['googlevideo']['autoplay'] = (int) $_POST['vvq-googlevideo-autoplay']; $usersettings['googlevideo']['aspectratio'] = (int) $_POST['vvq-googlevideo-aspectratio']; // Fill in an missing items with the defaults if ( empty($usersettings['googlevideo']['previewurl']) ) $usersettings['googlevideo']['previewurl'] = $this->defaultsettings['googlevideo']['previewurl']; if ( empty($usersettings['googlevideo']['width']) ) $usersettings['googlevideo']['width'] = $this->defaultsettings['googlevideo']['width']; if ( empty($usersettings['googlevideo']['height']) ) $usersettings['googlevideo']['height'] = $this->defaultsettings['googlevideo']['height']; break; case 'dailymotion': // Check for the defaults button if ( !empty($_POST['vvq-defaults']) ) { $usersettings['dailymotion'] = array(); $defaults = TRUE; break; } // Copy in the results of the form $usersettings['dailymotion']['previewurl'] = trim( $_POST['vvq-dailymotion-previewurl'] ); $usersettings['dailymotion']['width'] = (int) $_POST['vvq-dailymotion-width']; $usersettings['dailymotion']['height'] = (int) $_POST['vvq-dailymotion-height']; $usersettings['dailymotion']['backgroundcolor'] = strtoupper( trim( $_POST['vvq-dailymotion-backgroundcolor'] ) ); $usersettings['dailymotion']['glowcolor'] = strtoupper( trim( $_POST['vvq-dailymotion-glowcolor'] ) ); $usersettings['dailymotion']['foregroundcolor'] = strtoupper( trim( $_POST['vvq-dailymotion-foregroundcolor'] ) ); $usersettings['dailymotion']['seekbarcolor'] = strtoupper( trim( $_POST['vvq-dailymotion-seekbarcolor'] ) ); $usersettings['dailymotion']['autoplay'] = (int) $_POST['vvq-dailymotion-autoplay']; $usersettings['dailymotion']['related'] = (int) $_POST['vvq-dailymotion-related']; // Fill in an missing items with the defaults if ( empty($usersettings['dailymotion']['previewurl']) ) $usersettings['dailymotion']['previewurl'] = $this->defaultsettings['dailymotion']['previewurl']; if ( empty($usersettings['dailymotion']['width']) ) $usersettings['dailymotion']['width'] = $this->defaultsettings['dailymotion']['width']; if ( empty($usersettings['dailymotion']['height']) ) $usersettings['dailymotion']['height'] = $this->defaultsettings['dailymotion']['height']; if ( empty($usersettings['dailymotion']['backgroundcolor']) ) $usersettings['dailymotion']['backgroundcolor'] = $this->defaultsettings['dailymotion']['backgroundcolor']; if ( empty($usersettings['dailymotion']['glowcolor']) ) $usersettings['dailymotion']['glowcolor'] = $this->defaultsettings['dailymotion']['glowcolor']; if ( empty($usersettings['dailymotion']['foregroundcolor']) ) $usersettings['dailymotion']['foregroundcolor'] = $this->defaultsettings['dailymotion']['foregroundcolor']; if ( empty($usersettings['dailymotion']['seekbarcolor']) ) $usersettings['dailymotion']['seekbarcolor'] = $this->defaultsettings['dailymotion']['seekbarcolor']; // Check data validity if ( '#' != substr( $usersettings['dailymotion']['backgroundcolor'], 0, 1 ) ) $usersettings['dailymotion']['backgroundcolor'] = '#' . $usersettings['dailymotion']['backgroundcolor']; if ( '#' != substr( $usersettings['dailymotion']['glowcolor'], 0, 1 ) ) $usersettings['dailymotion']['glowcolor'] = '#' . $usersettings['dailymotion']['glowcolor']; if ( '#' != substr( $usersettings['dailymotion']['foregroundcolor'], 0, 1 ) ) $usersettings['dailymotion']['foregroundcolor'] = '#' . $usersettings['dailymotion']['foregroundcolor']; if ( '#' != substr( $usersettings['dailymotion']['seekbarcolor'], 0, 1 ) ) $usersettings['dailymotion']['seekbarcolor'] = '#' . $usersettings['dailymotion']['seekbarcolor']; break; case 'vimeo': // Check for the defaults button if ( !empty($_POST['vvq-defaults']) ) { $usersettings['vimeo'] = array(); $defaults = TRUE; break; } // Copy in the results of the form $usersettings['vimeo']['previewurl'] = (int) $_POST['vvq-vimeo-previewurl']; $usersettings['vimeo']['width'] = (int) $_POST['vvq-vimeo-width']; $usersettings['vimeo']['height'] = (int) $_POST['vvq-vimeo-height']; $usersettings['vimeo']['color'] = strtoupper( trim( $_POST['vvq-vimeo-color'] ) ); $usersettings['vimeo']['portrait'] = (int) $_POST['vvq-vimeo-portrait']; $usersettings['vimeo']['title'] = (int) $_POST['vvq-vimeo-title']; $usersettings['vimeo']['byline'] = (int) $_POST['vvq-vimeo-byline']; $usersettings['vimeo']['fullscreen'] = (int) $_POST['vvq-vimeo-fullscreen']; $usersettings['vimeo']['aspectratio'] = (int) $_POST['vvq-vimeo-aspectratio']; // Fill in an missing items with the defaults if ( empty($usersettings['vimeo']['previewurl']) ) $usersettings['vimeo']['previewurl'] = $this->defaultsettings['vimeo']['previewurl']; if ( empty($usersettings['vimeo']['width']) ) $usersettings['vimeo']['width'] = $this->defaultsettings['vimeo']['width']; if ( empty($usersettings['vimeo']['height']) ) $usersettings['vimeo']['height'] = $this->defaultsettings['vimeo']['height']; if ( empty($usersettings['vimeo']['color']) ) $usersettings['vimeo']['color'] = $this->defaultsettings['vimeo']['color']; // Check data validity if ( '#' != substr( $usersettings['vimeo']['color'], 0, 1 ) ) $usersettings['vimeo']['color'] = '#' . $usersettings['vimeo']['color']; break; case 'flv': // Check for the defaults button if ( !empty($_POST['vvq-defaults']) ) { $usersettings['flv'] = array(); $defaults = TRUE; break; } // Copy in the results of the form $usersettings['flv']['previewurl'] = trim( $_POST['vvq-flv-previewurl'] ); $usersettings['flv']['width'] = (int) $_POST['vvq-flv-width']; $usersettings['flv']['height'] = (int) $_POST['vvq-flv-height']; $usersettings['flv']['backcolor'] = strtoupper( trim( $_POST['vvq-flv-backcolor'] ) ); $usersettings['flv']['frontcolor'] = strtoupper( trim( $_POST['vvq-flv-frontcolor'] ) ); $usersettings['flv']['lightcolor'] = strtoupper( trim( $_POST['vvq-flv-lightcolor'] ) ); $usersettings['flv']['screencolor'] = strtoupper( trim( $_POST['vvq-flv-screencolor'] ) ); $usersettings['flv']['flashvars'] = trim( $_POST['vvq-flv-flashvars'] ); // Fill in an missing items with the defaults if ( empty($usersettings['flv']['previewurl']) ) $usersettings['flv']['previewurl'] = $this->defaultsettings['flv']['previewurl']; if ( empty($usersettings['flv']['width']) ) $usersettings['flv']['width'] = $this->defaultsettings['flv']['width']; if ( empty($usersettings['flv']['height']) ) $usersettings['flv']['height'] = $this->defaultsettings['flv']['height']; if ( empty($usersettings['flv']['backcolor']) ) $usersettings['flv']['backcolor'] = $this->defaultsettings['flv']['backcolor']; if ( empty($usersettings['flv']['frontcolor']) ) $usersettings['flv']['frontcolor'] = $this->defaultsettings['flv']['frontcolor']; if ( empty($usersettings['flv']['lightcolor']) ) $usersettings['flv']['lightcolor'] = $this->defaultsettings['flv']['lightcolor']; if ( empty($usersettings['flv']['screencolor']) ) $usersettings['flv']['screencolor'] = $this->defaultsettings['flv']['screencolor']; // Check data validity if ( '#' != substr( $usersettings['flv']['backcolor'], 0, 1 ) ) $usersettings['flv']['backcolor'] = '#' . $usersettings['flv']['backcolor']; if ( '#' != substr( $usersettings['flv']['frontcolor'], 0, 1 ) ) $usersettings['flv']['frontcolor'] = '#' . $usersettings['flv']['frontcolor']; if ( '#' != substr( $usersettings['flv']['lightcolor'], 0, 1 ) ) $usersettings['flv']['lightcolor'] = '#' . $usersettings['flv']['lightcolor']; if ( '#' != substr( $usersettings['flv']['screencolor'], 0, 1 ) ) $usersettings['flv']['screencolor'] = '#' . $usersettings['flv']['screencolor']; break; } update_option( 'vvq_options', $usersettings ); // Redirect back to the place we came from $url = admin_url( 'options-general.php?page=vipers-video-quicktags&tab=' . urlencode($_POST['vvq-tab']) ); if ( TRUE == $defaults ) $redirectto = add_query_arg( 'defaults', 'true', $url ); else $redirectto = add_query_arg( 'updated', 'true', $url ); wp_redirect( $redirectto ); } // Some style tweaks for the settings page function StyleTweaks() { ?>

" />

' . "\n"; _e("Viper's Video Quicktags", 'vipers-video-quicktags'); ?>

Help section for details.', 'vipers-video-quicktags'), admin_url( 'options-general.php?page=vipers-video-quicktags&tab=help#vvq-parameters' ) ); ?>

Firefox or Opera. If you switch, you\'ll be able to see the video preview update live as you change any option (rather than just a very limited number options) and more.', 'vipers-video-quicktags'), 'http://www.mozilla.com/firefox/', 'http://www.opera.com/' ); ?>

×      
  
  
 





jQuery("#vvqvideopreview-container").css( "min-height", jQuery("#vvq-height").val() + "px" ); // Parse the URL var PreviewID = jQuery("#vvq-previewurl").val().match(/http:\/\/video\.google\.([A-Za-z.]{2,5})\/videoplay\?docid=([\d-]+)(.*?)/); if ( !PreviewID ) { jQuery("#vvqvideopreview-container").html('
js_escape( __("Unable to parse preview URL. Please make sure it's the full URL and a valid one at that.", 'vipers-video-quicktags') ); ?>
'); return; } var PreviewID = PreviewID[2]; // Generate the URL and do the preview var Autoplay = ""; if ( true == jQuery("#vvq-googlevideo-autoplay").attr("checked") ) { var Autoplay = "&autoplay=1"; } swfobject.embedSWF( "http://video.google.com/googleplayer.swf?docid=" + PreviewID + Autoplay, "vvqvideopreview", jQuery("#vvq-width").val(), jQuery("#vvq-height").val(), "9", vvqexpressinstall, vvqflashvars, vvqparams, vvqattributes ); } }); // ]]>
×      
jQuery("#vvqvideopreview-container").css( "min-height", jQuery("#vvq-height").val() + "px" ); // Get the colors, transform to uppercase, and then set the inputs with the uppercase value var BackgroundColorVal = jQuery("#vvq-dailymotion-backgroundcolor").val().toUpperCase(); var GlowColorVal = jQuery("#vvq-dailymotion-glowcolor").val().toUpperCase(); var ForegroundColorVal = jQuery("#vvq-dailymotion-foregroundcolor").val().toUpperCase(); var SeekbarColorVal = jQuery("#vvq-dailymotion-seekbarcolor").val().toUpperCase(); jQuery("#vvq-dailymotion-backgroundcolor").val(BackgroundColorVal); jQuery("#vvq-dailymotion-glowcolor").val(GlowColorVal); jQuery("#vvq-dailymotion-foregroundcolor").val(ForegroundColorVal); jQuery("#vvq-dailymotion-seekbarcolor").val(SeekbarColorVal); // Parse the URL var PreviewID = jQuery("#vvq-previewurl").val().match(/http:\/\/(www.dailymotion|dailymotion)\.com\/(.+)\/([0-9a-zA-Z]+)\_(.*?)/); if ( !PreviewID ) { jQuery("#vvqvideopreview-container").html('
js_escape( __("Unable to parse preview URL. Please make sure it's the full URL and a valid one at that.", 'vipers-video-quicktags') ); ?>
'); return; } var PreviewID = PreviewID[3]; // Generate the URL and do the preview var BackgroundColor = ""; var GlowColor = ""; var ForegroundColor = ""; var SeekbarColor = ""; if ( "" != BackgroundColorVal && "defaultsettings['dailymotion']['backgroundcolor']; ?>" != BackgroundColorVal ) var BackgroundColor = "background:" + BackgroundColorVal.replace(/#/, "") + ";"; if ( "" != GlowColorVal && "defaultsettings['dailymotion']['glowcolor']; ?>" != GlowColorVal ) var GlowColor = "glow:" + GlowColorVal.replace(/#/, "") + ";"; if ( "" != ForegroundColorVal && "defaultsettings['dailymotion']['foregroundcolor']; ?>" != ForegroundColorVal ) var ForegroundColor = "foreground:" + ForegroundColorVal.replace(/#/, "") + ";"; if ( "" != SeekbarColorVal && "defaultsettings['dailymotion']['seekbarcolor']; ?>" != SeekbarColorVal ) var SeekbarColor = "special:" + SeekbarColorVal.replace(/#/, "") + ";"; if ( true == jQuery("#vvq-dailymotion-autoplay").attr("checked") ) { var Autoplay = "1"; } else { var Autoplay = "0"; } if ( true == jQuery("#vvq-dailymotion-related").attr("checked") ) { var Related = "1"; } else { var Related = "0"; } swfobject.embedSWF( "http://www.dailymotion.com/swf/" + PreviewID + "&colors=" + BackgroundColor + GlowColor + ForegroundColor + SeekbarColor + "&autoPlay=" + Autoplay + "&related=" + Related, "vvqvideopreview", jQuery("#vvq-width").val(), jQuery("#vvq-height").val(), "9", vvqexpressinstall, vvqflashvars, vvqparams, vvqattributes ); } }); // ]]>
×
  
  
  
  

jQuery("#vvqvideopreview-container").css( "min-height", jQuery("#vvq-height").val() + "px" ); // Get the color, transform to uppercase, and then set the input with the uppercase value var ColorVal = jQuery("#vvq-vimeo-color").val().toUpperCase(); jQuery("#vvq-vimeo-color").val(ColorVal); // Parse the URL var PreviewID = jQuery("#vvq-previewurl").val().match(/http:\/\/(www.vimeo|vimeo)\.com(\/|\/clip:)(\d+)(.*?)/); if ( !PreviewID ) { jQuery("#vvqvideopreview-container").html('
js_escape( __("Unable to parse preview URL. Please make sure it's the full URL and a valid one at that.", 'vipers-video-quicktags') ); ?>
'); return; } var PreviewID = PreviewID[3]; // Generate the URL and do the preview var Color = ""; if ( "" != ColorVal && "defaultsettings['vimeo']['color']; ?>" != ColorVal ) var Color = "&color=" + ColorVal.replace(/#/, ""); if ( true == jQuery("#vvq-vimeo-portrait").attr("checked") ) { var Portrait = "1"; } else { var Portrait = "0"; } if ( true == jQuery("#vvq-vimeo-title").attr("checked") ) { var Title = "1"; } else { var Title = "0"; } if ( true == jQuery("#vvq-vimeo-byline").attr("checked") ) { var Byline = "1"; } else { var Byline = "0"; } if ( true == jQuery("#vvq-vimeo-fullscreen").attr("checked") ) { var Fullscreen = "1"; } else { var Fullscreen = "0"; } swfobject.embedSWF( "http://www.vimeo.com/moogaloop.swf?server=www.vimeo.com&clip_id=" + PreviewID + Color + "&show_portrait=" + Portrait + "&show_title=" + Title + "&show_byline=" + Byline + "&fullscreen=" + Fullscreen, "vvqvideopreview", jQuery("#vvq-width").val(), jQuery("#vvq-height").val(), "9", vvqexpressinstall, vvqflashvars, vvqparams, vvqattributes ); } /* Color presets which is also based on code stolen from Ozh's "Liz Comment Counter" */ // Make the presets VVQMakeVimeoPresets(); function VVQMakeVimeoPresets() { var presets = { "": "defaultsettings['vimeo']['color']; ?>", "": "#FF9933", "": "#C9FF23", "": "#FF0179", "": "#FFFFFF" }; jQuery("#vvq-vimeo-presets").html(""); for (var i in presets) { var color = presets[i]; jQuery("#vvq-vimeo-presets").append('
'); } } // Update the color inputs when a preset is clicked jQuery(".vvq-preset").click(function(){ var color = jQuery(this).css('backgroundColor'); // Opera and IE return hex already, but we need to convert RGB to hex for Firefox, Safari, etc. if ( -1 == color.search(/#/) ) { var color = VVQRGBtoHex( color ); } if (color != undefined) { jQuery('#vvq-vimeo-color').val(color).keyup(); } VVQUpdatePreview(); }).tTips(); }); // ]]>
×      
  
 




jQuery("#vvqvideopreview-container").css( "min-height", jQuery("#vvq-height").val() + "px" ); // Get the colors, transform to uppercase, and then set the inputs with the uppercase value var BackColorVal = jQuery("#vvq-flv-backcolor").val().toUpperCase(); var FrontColorVal = jQuery("#vvq-flv-frontcolor").val().toUpperCase(); var LightColorVal = jQuery("#vvq-flv-lightcolor").val().toUpperCase(); var ScreenColorVal = jQuery("#vvq-flv-screencolor").val().toUpperCase(); jQuery("#vvq-flv-backcolor").val(BackColorVal); jQuery("#vvq-flv-frontcolor").val(FrontColorVal); jQuery("#vvq-flv-lightcolor").val(LightColorVal); jQuery("#vvq-flv-screencolor").val(ScreenColorVal); // Generate the URL and do the preview var vvqflvparams = { file: jQuery("#vvq-previewurl").val(), image: jQuery("#vvq-previewurl").val().replace(/\.flv/, ".jpg"), backcolor: BackColorVal.replace(/#/, ""), frontcolor: FrontColorVal.replace(/#/, ""), lightcolor: LightColorVal.replace(/#/, ""), screencolor: ScreenColorVal.replace(/#/, ""), volume: "100", settings['flv']['flashvars']) ) { parse_str( $this->settings['flv']['flashvars'], $flashvars ); foreach ( $flashvars as $key => $value ) echo ' ' . $key . ': "' . $value . '",' . "\n"; } ?> wmode: "opaque", allowfullscreen: "true" }; swfobject.embedSWF( "", "vvqvideopreview", jQuery("#vvq-width").val(), jQuery("#vvq-height").val(), "9", vvqexpressinstall, vvqflvparams, vvqparams, vvqattributes ); } }); // ]]>

×
  
  
  
  

query-string style list of additional parameters to pass to the player. Example: %3$s', 'vipers-video-quicktags'), 'http://codex.wordpress.org/Template_Tags/How_to_Pass_Tag_Parameters#Tags_with_query-string-style_parameters', 'http://code.jeroenwijering.com/trac/wiki/FlashVars', 'autostart=true&repeat=always&playlist=bottom' ); ?>

Help tab.', 'vipers-video-quicktags'), '!important', admin_url('options-general.php?page=vipers-video-quicktags&tab=help#vvq-customcss') ); ?>
cssalignments[$this->settings['alignment']] );
						echo str_replace( '/* alignment CSS placeholder */', "$aligncss", $this->standardcss );
					?>

settings['youtube']['button'], 1); ?> /> settings['youtube']['aspectratio'], 1); ?> />
settings['googlevideo']['button'], 1); ?> /> settings['googlevideo']['aspectratio'], 1); ?> />
settings['dailymotion']['button'], 1); ?> /> settings['dailymotion']['aspectratio'], 1); ?> />
settings['vimeo']['button'], 1); ?> /> settings['vimeo']['aspectratio'], 1); ?> />
settings['veoh']['button'], 1); ?> /> settings['veoh']['aspectratio'], 1); ?> />
settings['viddler']['button'], 1); ?> />      
settings['metacafe']['button'], 1); ?> /> settings['metacafe']['aspectratio'], 1); ?> />
settings['bliptv']['button'], 1); ?> /> settings['bliptv']['aspectratio'], 1); ?> />
settings['flickrvideo']['button'], 1); ?> /> settings['flickrvideo']['aspectratio'], 1); ?> />
settings['spike']['button'], 1); ?> /> settings['spike']['aspectratio'], 1); ?> />
settings['myspace']['button'], 1); ?> /> settings['myspace']['aspectratio'], 1); ?> />
' . sprintf( __('JW\'s FLV Media Player is covered by the Creative Commons Noncommercial
license
which means you cannot use it on a commerical website.', 'vipers-video-quicktags'), 'http://www.jeroenwijering.com/?item=JW_FLV_Media_Player', 'http://creativecommons.org/licenses/by-nc-sa/3.0/', 'http://www.jeroenwijering.com/?page=order' ); ?>
settings['flv']['button'], 1); ?> />  
settings['quicktime']['button'], 1); ?> />  
' . __("This part of the plugin is very buggy as embedding video files can be hard.
Consider trying TinyMCE's native video embedder instead.", 'vipers-video-quicktags') . '
'; ?>
settings['videofile']['button'], 1); ?> />  

'; print_r( get_option('vvq_options') ); echo ''; */ } // Output the video-releated styling for the main site function Styles() { echo "\n\n"; } // Replaces tabs, new lines, etc. to decrease the characters function StringShrink( $string ) { if ( empty($string) ) return $string; return preg_replace( "/\r?\n/", ' ', str_replace( "\t", '', $string ) ); } // Conditionally output debug error text function error( $error ) { global $post; // If the user can't edit this post, then just silently fail if ( empty($post->ID) || ( 'post' == $post->post_type && !current_user_can( 'edit_post', $post->ID ) ) || ( 'page' == $post->post_type && !current_user_can( 'edit_page', $post->ID ) ) ) return ''; // But if this user is an admin, then display some helpful text return '[' . sprintf( __('ERROR: %s', 'vipers-video-quicktags'), $error ) . ']'; } // Return a link to the post for use in the feed function postlink() { global $post; if ( empty($post->ID) ) return ''; // This should never happen (I hope) return apply_filters( 'vvq_feedoutput', '' . __( 'Click here to view the embedded video.', 'vipers-video-quicktags' ) . '' ); } // No-name attribute fixing function attributefix( $atts = array() ) { // Quoted value if ( 0 !== preg_match( '#=("|\')(.*?)\1#', $atts[0], $match ) ) $atts[0] = $match[2]; // Unquoted value elseif ( '=' == substr( $atts[0], 0, 1 ) ) $atts[0] = substr( $atts[0], 1 ); return $atts; } // Show an error for Stage6 function shortcode_stage6() { return '[' . __('Stage6 is no more, so this Stage6-hosted video cannot be displayed.', 'vipers-video-quicktags') . ']'; } // Handle YouTube shortcodes function shortcode_youtube( $atts, $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'), __('YouTube') ) ); if ( is_feed() ) return $this->postlink(); // Set any missing $atts items to the defaults $atts = shortcode_atts(array( 'width' => $this->settings['youtube']['width'], 'height' => $this->settings['youtube']['height'], 'color1' => $this->settings['youtube']['color1'], 'color2' => $this->settings['youtube']['color2'], 'border' => $this->settings['youtube']['border'], 'rel' => $this->settings['youtube']['rel'], 'fs' => $this->settings['youtube']['fs'], 'autoplay' => $this->settings['youtube']['autoplay'], 'loop' => $this->settings['youtube']['loop'], 'highqual' => $this->settings['youtube']['highqual'], ), $atts); // If a URL was passed if ( 'http://' == substr( $content, 0, 7 ) ) { // Playlist URL if ( FALSE !== stristr( $content, 'view_play_list' ) ) { preg_match( '#http://(www.youtube|youtube|[A-Za-z]{2}.youtube)\.com/view_play_list\?p=([\w-]+)(.*?)#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'), __('YouTube') ) ); $embedpath = 'p/' . $matches[2]; $fallbacklink = $fallbackcontent = 'http://www.youtube.com/view_play_list?p=' . $matches[2]; } // Normal video URL else { preg_match( '#http://(www.youtube|youtube|[A-Za-z]{2}.youtube)\.com/(watch\?v=|w/\?v=)([\w-]+)(.*?)#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'), __('YouTube') ) ); $embedpath = 'v/' . $matches[3]; $fallbacklink = 'http://www.youtube.com/watch?v=' . $matches[3]; $fallbackcontent = '' . __('YouTube Preview Image', 'vipers-video-quicktags') . ''; } } // 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 = '' . __('YouTube Preview Image', 'vipers-video-quicktags') . ''; } // Setup the parameters $color1 = $color2 = $border = $highqual = $autoplay = $loop = ''; 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'; $rel = ( 1 == $atts['rel'] ) ? '1' : '0'; $fs = ( 1 == $atts['fs'] ) ? '1' : '0'; if ( $atts['highqual'] ) $highqual = '&ap=%2526fmt%3D18'; if ( $atts['autoplay'] ) $autoplay = '&autoplay=1'; if ( $atts['loop'] ) $loop = '&loop=1'; $objectid = uniqid('vvq'); $this->swfobjects[$objectid] = array( 'width' => $atts['width'], 'height' => $atts['height'], 'url' => 'http://www.youtube.com/' . $embedpath . $color1 . $color2 . $border . '&rel=' . $rel . '&fs=' . $fs . $autoplay . $loop . $highqual ); return '' . $fallbackcontent . ''; } // Handle Google Video shortcodes function shortcode_googlevideo( $atts, $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') ) ); 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'], ), $atts); // 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') ) ); $videoid = $matches[2]; } // If a URL wasn't passed, assume a video ID was passed instead else { $videoid = $content; } // Setup the parameters $autoplay = ''; if ( 1 == $atts['autoplay'] ) $autoplay = '&autoplay=1'; $objectid = uniqid('vvq'); $this->swfobjects[$objectid] = array( 'width' => $atts['width'], 'height' => $atts['height'], 'url' => 'http://video.google.com/googleplayer.swf?docid=' . $videoid . $autoplay ); return 'http://video.google.com/videoplay?docid=' . $videoid . ''; } // Handle DailyMotion shortcodes function shortcode_dailymotion( $atts, $content = '' ) { if ( empty($content) ) return $this->error( sprintf( __('No URL or video ID was passed to the %s BBCode', 'vipers-video-quicktags'), __('YouTube') ) ); 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); // 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') ) ); $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 = uniqid('vvq'); $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 = '' ) { // 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') ) ); 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); // 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') ) ); $videoid = $matches[3]; } // If a URL wasn't passed, assume a video ID was passed instead else { $videoid = $content; } // Setup the parameters $color = ''; if ( '' != $atts['color'] && $this->defaultsettings['vimeo']['color'] != $atts['color'] ) $color = '&color=' . str_replace( '#', '', $atts['color'] ); $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 = uniqid('vvq'); $this->swfobjects[$objectid] = array( 'width' => $atts['width'], 'height' => $atts['height'], 'url' => 'http://www.vimeo.com/moogaloop.swf?server=www.vimeo.com&clip_id=' . $videoid . $color . '&show_portrait=' . $portrait . '&show_title=' . $title . '&show_byline=' . $byline . '&fullscreen=' . $fullscreen ); return 'http://www.vimeo.com/' . $videoid . ''; } // Handle Veoh shortcodes function shortcode_veoh( $atts, $content = '' ) { if ( empty($content) ) return $this->error( sprintf( __('No URL or video ID was passed to the %s BBCode', 'vipers-video-quicktags'), __('Veoh') ) ); 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); // If a URL was passed if ( 'http://' == substr( $content, 0, 7 ) ) { preg_match( '#http://(www.veoh|veoh)\.com/videos/([0-9a-zA-Z]+)(.*?)#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'), __('Veoh') ) ); $videoid = $matches[2]; } // If a URL wasn't passed, assume a video ID was passed instead else { $videoid = $content; } $objectid = uniqid('vvq'); $this->swfobjects[$objectid] = array( 'width' => $atts['width'], 'height' => $atts['height'], 'url' => 'http://www.veoh.com/veohplayer.swf?permalinkId=' . $videoid . '&id=anonymous&player=videodetailsembedded&affiliateId=&videoAutoPlay=' . $atts['autoplay'] ); return 'http://www.veoh.com/videos/' . $videoid . ''; } // Handle Viddler shortcodes function shortcode_viddler( $atts, $content = '' ) { 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); // 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 = uniqid('vvq'); $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') ) . ''; } // Handle Metacafe shortcodes function shortcode_metacafe( $atts, $content = '' ) { if ( empty($content) ) return $this->error( sprintf( __('No URL or video ID was passed to the %s BBCode', 'vipers-video-quicktags'), __('Metacafe') ) ); 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); // If a URL was passed if ( 'http://' == substr( $content, 0, 7 ) ) { preg_match( '#http://(www.metacafe|metacafe)\.com/watch/(\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'), __('Metacafe') ) ); $videoid = $matches[2]; } // If a URL wasn't passed, assume a video ID was passed instead else { $videoid = $content; } $objectid = uniqid('vvq'); $this->swfobjects[$objectid] = array( 'width' => $atts['width'], 'height' => $atts['height'], 'url' => 'http://www.metacafe.com/fplayer/' . $videoid . '/vipers_video_quicktags.swf' ); return 'http://www.metacafe.com/watch/' . $videoid . '/'; } // Handle Blip.tv shortcodes function shortcode_bliptv( $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); // Parse WordPress.com shortcode format parse_str( $atts[0], $params ); 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 = uniqid('vvq'); $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') ) . ''; } // Handle Flickr videos function shortcode_flickrvideo( $atts, $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') ) ); 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); // 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') ) ); $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 = uniqid('vvq'); $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 = '' ) { if ( empty($content) ) return $this->error( sprintf( __('No URL or video ID was passed to the %s BBCode', 'vipers-video-quicktags'), __('IFILM/Spike') ) ); 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); // 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') ) ); $videoid = $matches[3]; } // If a URL wasn't passed, assume a video ID was passed instead else { $videoid = $content; } $objectid = uniqid('vvq'); $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 = '' ) { if ( empty($content) ) return $this->error( sprintf( __('No URL or video ID was passed to the %s BBCode', 'vipers-video-quicktags'), __('MySpace') ) ); 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); // 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') ) ); $videoid = $matches[3]; } // If a URL wasn't passed, assume a video ID was passed instead else { $videoid = $content; } $objectid = uniqid('vvq'); $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 = '' ) { if ( empty($content) ) return $this->error( sprintf( __('No URL was passed to the %s BBCode', 'vipers-video-quicktags'), __('FLV') ) ); 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' => str_replace( '.flv', '.jpg', $content ), 'backcolor' => $this->settings['flv']['backcolor'], 'frontcolor' => $this->settings['flv']['frontcolor'], 'lightcolor' => $this->settings['flv']['lightcolor'], 'screencolor' => $this->settings['flv']['screencolor'], 'volume' => 100, 'flashvars' => '', ), $atts); // Setup the flashvars using the parameters as well as the "flashvars" value $flashvars = array( 'file' => $content, 'image' => $atts['image'], 'backcolor' => str_replace( '#', '', $atts['backcolor'] ), 'frontcolor' => str_replace( '#', '', $atts['frontcolor'] ), 'lightcolor' => str_replace( '#', '', $atts['lightcolor'] ), 'screencolor' => str_replace( '#', '', $atts['screencolor'] ), 'volume' => 100, ); if ( !empty($atts['flashvars']) ) { $atts['flashvars'] = str_replace( '#038;', '&', $atts['flashvars'] ); // Fix formatting applied by WordPress parse_str( $atts['flashvars'], $params ); foreach ( $params as $key => $value ) $flashvars[$key] = $value; } $objectid = uniqid('vvq'); $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 '' . $content . ''; } // Handle major pain in the ass Quicktime video files function shortcode_quicktime( $atts, $content = '' ) { if ( empty($content) ) return $this->error( sprintf( __('No URL was passed to the %s BBCode', 'vipers-video-quicktags'), __('Quicktime') ) ); 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, 'useplaceholder' => 0, 'placeholder' => str_replace( '.mov', '.jpg', $content ), 'controller' => 1, ), $atts); if ( 1 == $atts['useplaceholder'] && !empty($atts['placeholder']) ) { $mov = $atts['placeholder']; $href = ' myQTObject.addParam("href", "' . $content . '"); myQTObject.addParam("target", "myself");'; } else { $mov = $content; $href = ''; } $autostart = ( 1 == $atts['autostart'] ) ? 'true' : 'false'; $controller = ( 1 == $atts['controller'] ) ? 'true' : 'false'; return ''; } // Handle super-duper pain in the ass regular video files function shortcode_videofile( $atts, $content = '' ) { if ( empty($content) ) return $this->error( sprintf( __('No URL was passed to the %s BBCode', 'vipers-video-quicktags'), __('generic video') ) ); 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); // 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 = '' ) { if ( empty($content) ) return $this->error( sprintf( __('No URL was passed to the %s BBCode', 'vipers-video-quicktags'), __('generic Flash embed') ) ); 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); // Create Flashvars $flashvars = array(); if ( !empty($atts['flashvars']) ) { $atts['flashvars'] = str_replace( '#038;', '&', $atts['flashvars'] ); // Fix formatting applied by WordPress parse_str( $atts['flashvars'], $params ); foreach ( $params as $key => $value ) $flashvars[$key] = $value; } $objectid = uniqid('vvq'); $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') ) . ''; } // Output the SWFObject calls that replace all of the placeholders created by the shortcode handlers with the Flash videos function SWFObjectCalls() { if ( empty($this->swfobjects) ) return; ?> , 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( 'plugins_loaded', create_function( '', 'global $VipersVideoQuicktags; $VipersVideoQuicktags = new VipersVideoQuicktags();' ) ); ?>