diff --git a/digg-digg/digg-digg.php b/digg-digg/digg-digg.php index 0072960..326b5be 100755 --- a/digg-digg/digg-digg.php +++ b/digg-digg/digg-digg.php @@ -26,7 +26,7 @@ //function to be run when the plugin is activated register_activation_hook( __FILE__, 'dd_run_when_plugin_activated' ); -add_action('init', 'dd_enable_required_js_in_wordpress' ); +add_action( 'wp_enqueue_scripts', 'dd_enable_required_js_in_wordpress' ); add_action( 'wp_enqueue_scripts', 'dd_wp_enqueue_styles' ); add_action( 'wp_head', 'dd_get_thumbnails_for_fb' ); add_filter( 'the_excerpt', 'dd_hook_wp_content' ); @@ -344,16 +344,14 @@ function integrateFloatingButtonsIntoWpContent($dd_floating_button_for_display,$ $dd_override_top_offset = 0; } - // $floatingCSS = ''; $floatingJSOptions = ''; - $floatingJS = ''; - $dd_floating_bar = "
" . $floatButtonsContainer . "
" . $floatingJSOptions . $floatingJS . $dd_lazyLoad_scheduler_script . $dd_lazyLoad_jQuery_script; + $dd_floating_bar = "
" . $floatButtonsContainer . "
" . $floatingJSOptions . $dd_lazyLoad_scheduler_script . $dd_lazyLoad_jQuery_script; $dd_start_anchor = ''; if(!$ddFloatDisplay[DD_COMMENT_ANCHOR_OPTION][DD_COMMENT_ANCHOR_OPTION_STATUS]){ @@ -407,11 +405,9 @@ function integrateFloatingButtonsIntoWpContent_footerload($dd_floating_button_fo $dd_lazyLoad_scheduler_script = ""; } - // $floatingCSS = ''; $floatingJSOptions = ''; - $floatingJS = ''; - $dd_floating_bar = "
" . $floatButtonsContainer . "
" . $floatingCSS . $floatingJSOptions . $floatingJS . $dd_lazyLoad_scheduler_script . $dd_lazyLoad_jQuery_script; + $dd_floating_bar = "
" . $floatButtonsContainer . "
" . $floatingJSOptions . $dd_lazyLoad_scheduler_script . $dd_lazyLoad_jQuery_script; $dd_start_anchor = ''; diff --git a/digg-digg/include/dd-helper.php b/digg-digg/include/dd-helper.php old mode 100644 new mode 100755 index 5933419..9226bc4 --- a/digg-digg/include/dd-helper.php +++ b/digg-digg/include/dd-helper.php @@ -144,6 +144,8 @@ function dd_enable_required_js_in_wordpress() { //jQuery need to put on head wp_enqueue_script('jquery'); } + + wp_enqueue_script( 'diggdigg', DD_PLUGIN_URL . 'js/diggdigg-floating-bar.js', array(), DD_VERSION ); } //filter for ajax floating javascript diff --git a/digg-digg/js/diggdigg-floating-bar.js b/digg-digg/js/diggdigg-floating-bar.js index ff951f5..03c0c17 100755 --- a/digg-digg/js/diggdigg-floating-bar.js +++ b/digg-digg/js/diggdigg-floating-bar.js @@ -11,6 +11,10 @@ jQuery(document).ready(function(){ } var $dd_start = jQuery( '#' + dd_anchorId ); + // if anchor element is not found then the rest is moot. Bail out to avoid errors. + if ( $dd_start.length === 0 ) { + return; + } var $dd_end = jQuery('#dd_end'); var $dd_outer = jQuery('.dd_outer');