. ************************************************************************** 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.0'; 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 $wp_db_version, $wpmu_version, $shortcode_tags; // 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() && 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' => 1, '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' => 1, ), 'metacafe' => array( 'button' => 1, 'width' => 400, 'height' => 345, 'aspectratio' => 1, ), 'bliptv' => array( 'button' => 1, 'width' => 400, 'height' => 330, 'aspectratio' => 1, ), 'wpvideo' => array( 'button' => 1, 'width' => 400, 'height' => 224, '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' => 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' => 3, 'customcss' => '', 'customfeedtext' => '', ) ); // Default customfeedtext. Change it via the settings page. $this->customfeedtext = '

' . __( 'Click here to view the embedded video.', 'vipers-video-quicktags' ) . '

'; // 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; } } } // Upgrade settings $upgrade = false; if ( empty($this->settings['version']) || -1 == version_compare($this->settings['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($this->settings['version'], '6.1.0') ) { // Custom FLV colors $colors = array( 'backcolor', 'frontcolor', 'lightcolor', 'screencolor' ); foreach ( $colors as $color ) { if ( $usersettings['flv'][$color] != $this->defaultsettings['flv'][$color] ) $usersettings['flv']['customcolors'] = 1; } $upgrade = true; } if ( -1 == version_compare($this->settings['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 ( $upgrade ) { $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, '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 ); if ( $wp_db_version < 8989 && 'update.php' == basename( $_SERVER['PHP_SELF'] ) && 'upgrade-plugin' == $_GET['action'] && FALSE !== strstr( $_GET['plugin'], 'vipers-video-quicktags' ) ) add_action( 'admin_notices', array(&$this, 'AutomaticUpgradeNotice') ); // 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') ); // 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( 'wpvideo', array(&$this, 'shortcode_wpvideo') ); // WordPress.tv 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') ); // 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 ( 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' ); } } 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( __( '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"; } // Tell the user that WordPress won't properly upload SWF files via FTP function AutomaticUpgradeNotice() { if ( 'ftpext' != get_filesystem_method() ) return; echo '

' . sprintf( __( "WARNING: If you use the FLV embed feature of Viper's Video Quicktags, there is a bug in WordPress with the FTP method of upgrading plugins. It will not upload the .swf files properly. If you do embed FLV files, please manually download the plugin and upload the files to your server. If you don't embed FLV files (and only embed YouTube, etc. videos), you can safely ignore this message and upgrade automatically.", 'vipers-video-quicktags' ), 'http://downloads.wordpress.org/plugin/vipers-video-quicktags.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', 'vipers-video-quicktags') . ''; 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; } } } // Break the browser cache of TinyMCE function tiny_mce_version( $version ) { return $version . '-vvq' . $this->version . 'line' . $this->settings['tinymceline']; } // 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() { global $user_id; 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', ), ); $buttonshtml = $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['tinymceline'], $usersettings['customfeedtext'], $usersettings['videofile']['usewmp'], $usersettings['quicktime']['dynamicload'] ); // Custom CSS is skipped $defaults = TRUE; break; } $usersettings['alignment'] = $_POST['vvq-alignment']; $usersettings['tinymceline'] = (int) $_POST['vvq-tinymceline']; $usersettings['customfeedtext'] = trim( $_POST['vvq-customfeedtext'] ); $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'] ) ); // Check data validity if ( 0 == $usersettings['tinymceline'] ) $usersettings['tinymceline'] = $this->defaultsettings['tinymceline']; 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']['hd'] = (int) $_POST['vvq-youtube-hd']; $usersettings['youtube']['autoplay'] = (int) $_POST['vvq-youtube-autoplay']; $usersettings['youtube']['loop'] = (int) $_POST['vvq-youtube-loop']; $usersettings['youtube']['showsearch'] = (int) $_POST['vvq-youtube-showsearch']; $usersettings['youtube']['showinfo'] = (int) $_POST['vvq-youtube-showinfo']; $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']['fs'] = (int) $_POST['vvq-googlevideo-fs']; $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']['skin'] = $_POST['vvq-flv-skin']; $usersettings['flv']['customcolors'] = (int) $_POST['vvq-flv-customcolors']; $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']['skin']) ) $usersettings['flv']['skin'] = $this->defaultsettings['flv']['skin']; 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 ( empty($this->flvskins[$usersettings['flv']['skin']]) ) $usersettings['flv']['skin'] = ''; 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; } $usersettings['version'] = $this->version; update_option( 'vvq_options', $usersettings ); // Redirect back to where we came from $redirectto = remove_query_arg( 'defaults', remove_query_arg( 'updated', wp_get_referer() ) ); $redirectto = ( TRUE == $defaults ) ? add_query_arg( 'defaults', 'true', $redirectto ) : add_query_arg( 'updated', 'true', $redirectto ); wp_safe_redirect( $redirectto ); } // Some style tweaks for the settings page function StyleTweaks() { ?>

" />

' . "\n"; ?>

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 = ""; var FS = ""; if ( true == jQuery("#vvq-googlevideo-autoplay").attr("checked") ) { var Autoplay = "&autoplay=1"; } if ( true == jQuery("#vvq-googlevideo-fs").attr("checked") ) { var FS = "&fs=true"; } swfobject.embedSWF( "http://video.google.com/googleplayer.swf?docid=" + PreviewID + Autoplay + FS, "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 = new Array(); vvqflvparams["file"] = jQuery("#vvq-previewurl").val(); vvqflvparams["image"] = jQuery("#vvq-previewurl").val().replace(/\.flv/, ".jpg"); if ( true == jQuery("#vvq-flv-customcolors").attr("checked") ) { vvqflvparams["backcolor"] = BackColorVal.replace(/#/, ""); vvqflvparams["frontcolor"] = FrontColorVal.replace(/#/, ""); vvqflvparams["lightcolor"] = LightColorVal.replace(/#/, ""); vvqflvparams["screencolor"] = ScreenColorVal.replace(/#/, ""); } vvqflvparams["volume"] = "100"; vvqflvparams["bufferlength"] = "15"; vvqflvparams["skin"] = "" + jQuery("#vvq-flv-skin").val() + ".swf"; vvqflvparams["wmode"] = "opaque"; vvqflvparams["allowfullscreen"] = "true"; settings['flv']['flashvars']) ) { parse_str( $this->settings['flv']['flashvars'], $flashvars ); foreach ( (array) $flashvars as $key => $value ) echo ' vvqflvparams["' . $key . '"] = "' . $value . '";' . "\n"; } ?> swfobject.embedSWF( "", "vvqvideopreview", jQuery("#vvq-width").val(), jQuery("#vvq-height").val(), "9", vvqexpressinstall, vvqflvparams, vvqparams, vvqattributes ); } jQuery("#vvq-flv-customcolors").change(function(){ if ( true != jQuery(this).attr("checked") ) { jQuery(".vvq-flv-customcolor").hide(); } else { jQuery(".vvq-flv-customcolor").show(); } }); if ( true != jQuery("#vvq-flv-customcolors").attr("checked") ) { jQuery(".vvq-flv-customcolor").hide(); } }); // ]]>

×
  
  
  
  

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&playlist=bottom&bufferlength=15' ); ?>

%s", 'vipers-video-quicktags'), '' . htmlspecialchars($this->customfeedtext) . '' ); ?>

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 );
					?>

template file located in this plugin\'s "localization" folder and then send it to me. For help, see the WordPress Codex.', 'vipers-video-quicktags'), plugins_url('/vipers-video-quicktags/localization/_vipers-video-quicktags-template.po'), 'http://www.viper007bond.com/contact/', 'http://codex.wordpress.org/Translating_WordPress' ); ?>

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 commercial 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); ?> />  
' . sprintf( __("This part of the plugin is fairly buggy as embedding video files is complex.
Consider trying TinyMCE's native video embedder instead. Why?", 'vipers-video-quicktags'), admin_url('options-general.php?page=vipers-video-quicktags&tab=help#vvq-videofilepoor') ) . '
'; ?>
settings['videofile']['button'], 1); ?> />  

'; print_r( get_option('vvq_options') ); echo ''; */ } // Output the head stuff function Head() { $this->wpheadrun = TRUE; echo "\n\n"; ?> 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) $text = ( !empty($this->settings['customfeedtext']) ) ? $this->settings['customfeedtext'] : $this->customfeedtext; return apply_filters( 'vvq_feedoutput', '' . $text . '' ); } // 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; } // Generate a placeholder ID function videoid( $type ) { global $post; if ( empty($post) || empty($post->ID) ) { $objectid = uniqid("vvq-$type-"); } else { $count = 1; $objectid = 'vvq-' . $post->ID . '-' . $type . '-' . $count; while ( !empty($this->usedids[$objectid]) ) { $count++; $objectid = 'vvq-' . $post->ID . '-' . $type . '-' . $count; } $this->usedids[$objectid] = true; } return $objectid; } // Reverse the parts we care about (and probably some we don't) of wptexturize() which gets applied before shortcodes function wpuntexturize( $text ) { $find = array( '–', '—', '×', '…', '“', '’s', '”', '&' ); $replace = array( '--', '---', 'x', '...', '``', '\'s', '\'\'', '&' ); return str_replace( $find, $replace, $text ); } // 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 = '' ) { $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'), __('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'], 'showsearch' => $this->settings['youtube']['showsearch'], 'showinfo' => $this->settings['youtube']['showinfo'], 'hd' => $this->settings['youtube']['hd'], ), $atts); // Allow other plugins to modify these values (for example based on conditionals) $atts = apply_filters( 'vvq_shortcodeatts', $atts, 'youtube', $origatts ); // 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=|\?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 = $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 'http://www.metacafe.com/watch/' . $videoid . '/'; } // 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 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 = $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 WordPress.com/WordPress.tv shortcodes function shortcode_wpvideo( $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' => $this->settings['wpvideo']['width'], 'height' => $this->settings['wpvideo']['height'], ), $atts); // Allow other plugins to modify these values (for example based on conditionals) $atts = apply_filters( 'vvq_shortcodeatts', $atts, 'wpvideo', $origatts ); if ( empty($atts[0]) ) return $this->error( sprintf( __('An invalid %s shortcode format was used. Please check your code.', 'vipers-video-quicktags'), __('WordPress.com', 'vipers-video-quicktags') ) ); if ( false !== $atts['w'] ) { $atts['width'] = $atts['w']; $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://v.wordpress.com/' . $atts[0] ); 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', __('WordPress.com', '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( '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']) ) { parse_str( $this->settings['flv']['flashvars'], $params ); $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'] ) ); parse_str( $atts['flashvars'], $params ); $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 .flv/.mp4 if ( empty($flashvars['image']) ) $flashvars['image'] = str_replace( array('.flv', '.mp4'), '.jpg', $content ); // 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 parse_str( $atts['flashvars'], $params ); 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(); } ?>