Wordpress Themes - WP Forum at BFA
Click Here To DONATE! Support the theme development, get more attention and additional benefits based on your donation level. Your forum name will be highlighted.

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Plugins & Atahualpa »

Incomapitibility of RotateHeaderImages with other plugins


Build custom WP THEMES, without
coding.
Click here for THEMEFRAME

From the author of Atahualpa, the #1 most
downloaded (700,000+) theme @ wordpress.org
  #1  
Old May 9, 2012, 05:53 PM
Jonny007-MKD
 
1 posts · Dec 2011
Hello,
since RotateHeaderImages uses the global variable j as index, this variable can be changed by other plugins which are written as bad as this piece of code of yours. When writing modules/plugins/themes you should keep you plugin independent so that no other plugin can interfere (unexpectedly) with it.
It happend to me, that j was set to 120 after page load (due to email-decrypt--for()-loops or whatever which also shouldn't use global variables (imagine image rotation would reset the variable while decrypting is in process (which could be possible in future))) and the image was replaced by image[120] which is 'undefined' which of course was no valid/existing file.

So i changed your code (in JS you can use structures which are like a light version of C-objects) and I would be very glad if you integrated it into atahualpa for all the other users and also accepted the idea and principle for your next and current projects.


Thanks!
Jonny007-MKD


themes/atahualpa/js.php
Code:
[...]
<?php if (strpos($bfa_ata['configure_header'],'%image')!== FALSE AND 
$bfa_ata['header_image_javascript'] != "0" AND $bfa_ata['crossslide_fade'] == "0") { ?>
bfa_ata = {
	HeaderImages: [<?php echo implode(", ", bfa_rotating_header_images()); $init = ''; ?>], t:0, i:0, j:0, p:<? echo count(bfa_rotating_header_images())-1; ?>,
	<?php if ($bfa_ata['header_image_javascript_preload'] == "Yes") { 
		$init = 'bfa_ata.init(); '; ?>
	PreLoadImages: [],
	init: function() {
		for (var i = 0; i < bfa_ata.p; i++) {
			bfa_ata.PreLoadImages[i] = new Image();
			bfa_ata.PreLoadImages[i].src = HeaderImages[i];
		}
	},	
	<?php } ?>
	RotateHeaderImages: function() {
		if (document.body) {
			if (!bfa_ata.HeaderImageContainer) bfa_ata.HeaderImageContainer = document.getElementById('imagecontainer');
			bfa_ata.HeaderImageContainer.style.background = 'url(' + bfa_ata.HeaderImages[bfa_ata.j] + ') <?php echo $bfa_ata['headerimage_alignment']; ?> no-repeat';
			if (++bfa_ata.j > (bfa_ata.p)) {bfa_ata.j = 0;}
			bfa_ata.t = setTimeout(bfa_ata.RotateHeaderImages, <?php echo $bfa_ata['header_image_javascript']; ?>000);
		}
	}
};
window.onload = function(){<? echo $init; ?>bfa_ata.RotateHeaderImages()};
<?php } ?>

Last edited by Jonny007-MKD; May 9, 2012 at 05:57 PM.

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
3.6.1 doesn't work with plugins taisia Plugins & Atahualpa 4 Jan 23, 2011 05:23 PM
SEO Plugins -- How Many are Too Many? Cheers Header configuration & styling 7 Dec 21, 2010 03:35 PM
Plugins for IDX Broker mcglastonbury9 Plugins & Atahualpa 1 Oct 16, 2010 01:53 PM
Plugins Esperanza Plugins & Atahualpa 6 Aug 25, 2009 03:33 PM


All times are GMT -6. The time now is 02:36 PM.


Powered by vBulletin® Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.