WordPress.org

Ready to get started?Download WordPress

Forums

Cool Video Gallery
[resolved] fancybox.js conflict with other plugins in the admin panel (1 post)

  1. vloo
    Member
    Posted 1 year ago #

    Activating the plugin broke some scripts which lead to problems when working with metaboxes while editing or creating new posts or pages.

    Solution is to enque scripts and styles only when needed, which is - on the plugin admin pages. Following is the new code that I wrote in the function addPlayerHeader() in cool-video-gallery.php on line 850:

    $screen = get_current_screen(); // see get_current_screen in WP codex
    			//var_dump($screen->id); //useful to find your own id
    
    			if ((is_object($screen) && $screen->id == 'video-gallery_page_cvg-gallery-manage') || !is_admin()) {
    
    				$options_settings = get_option('cvg_settings');	
    
    				echo "<!-- Cool Video Gallery Script starts here -->";
    
    				wp_enqueue_script('jwplayer', $this->video_player_url . 'jwplayer.js', '');
    				wp_enqueue_script('jquery.fancybox', $this->plugin_url . 'third_party_lib/fancybox/jquery.fancybox-1.3.4.pack.js', 'jquery');
    				wp_enqueue_style('jquery.fancybox', $this->plugin_url . 'third_party_lib/fancybox/jquery.fancybox-1.3.4.css', 'jquery');
    
    				if(isset($options_settings['cvg_navigation_controls']) && $options_settings['cvg_navigation_controls'] == 0) {
    					?>
    					<style type="text/css" media="screen">
    						#fancybox-left-ico {
    						 left: 20px;
    						} 
    
    						#fancybox-right-ico {
    						 right: 20px;
    						 left: auto;
    						}
    					</style>
    				<?php } ?>
    				<script type="text/javascript">
    					jQuery(document).ready(function(){
    						if(jQuery('.slideContent').length != 0) {
    							jQuery('.slideContent').each(function() {
    								jQuery(this.id).s3Slider({
    								  timeOut: <?php echo $options_settings['cvg_slideshow']; ?>,
    								  item_id: this.id
    							   });
    							});
    						}
    					});
    
    				</script>
    				<!-- Cool Video Gallery Script ends here -->
    			<?php
    			} else {
    				//It is another admin page and it doesn't need to load anything
    			}

    I suggest the author applies the change in order to prevent such a conflict for more complex WordPress configurations. Adding scripts where needed is always a better solution than adding them everywhere.

    http://wordpress.org/extend/plugins/cool-video-gallery/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.