Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Only load SWFObject when it's actually needed

Previously it was being loaded literally everywhere
  • Loading branch information...
commit 2ab69cff12a1a09916e360dda348bae356c93eb5 1 parent b4a45e6
Alex Mills authored
Showing with 12 additions and 1 deletion.
  1. +12 −1 vipers-video-quicktags.php
13 vipers-video-quicktags.php
View
@@ -306,6 +306,7 @@ function VipersVideoQuicktags() {
add_action( 'admin_post_vvqsettings', array(&$this, 'POSTHandler') );
add_action( 'wp_head', array(&$this, 'Head') );
add_action( 'admin_head', array(&$this, 'Head') );
+ add_action( 'wp_print_footer_scripts', array(&$this, 'maybe_enqueue_swfobject'), 5 );
add_action( 'wp_footer', array(&$this, 'SWFObjectCalls'), 50 );
add_filter( 'widget_text', 'do_shortcode', 11 ); // Videos in the text widget
@@ -347,13 +348,14 @@ function VipersVideoQuicktags() {
add_shortcode( 'wpvideo', array(&$this, 'shortcode_videopress') );
// Register other scripts and styles
- wp_enqueue_script( 'swfobject' );
wp_register_script( 'qtobject', plugins_url('/vipers-video-quicktags/resources/qtobject.js'), array(), '1.0.2' );
if ( is_admin() ) {
// Settings page only
if ( isset($_GET['page']) && 'vipers-video-quicktags' == $_GET['page'] ) {
add_action( 'admin_head', array(&$this, 'StyleTweaks' ) );
+ wp_enqueue_script( 'swfobject' );
+
wp_enqueue_script( 'farbtastic' );
wp_enqueue_style( 'farbtastic' );
}
@@ -3771,6 +3773,15 @@ function shortcode_flash( $atts, $content = '' ) {
}
+ // This function tells WordPress to load the SWFObject JS file if SWFObjectCalls() is going to run
+ function maybe_enqueue_swfobject() {
+ if ( is_feed() || empty($this->swfobjects) )
+ return;
+
+ wp_enqueue_script( 'swfobject' );
+ }
+
+
// Output the SWFObject calls that replace all of the placeholders created by the shortcode handlers with the Flash videos
function SWFObjectCalls() {
if ( is_feed() || empty($this->swfobjects) )
Please sign in to comment.
Something went wrong with that request. Please try again.