• Ester Dammers

    (@rebelstar)


    I’m using a theme on my website that hasn’t been updated for a while and needed some fixing here and there, especially after upgrading to PHP 7.4. Everything works fine now, expect for one thing. I have this tab/button in the right top part of my website which you can click for user login. The normal behaviour is that it folds out once it’s clicked and then there’s a login link. The button doesn’t work anymore and reverting back to PHP 7.0 makes it work again, but I don’t want to go back to that old PHP version.

    So now there’s this code snippet which actually makes this thing work. I think some elements of it are not any longer supported by this PHP version but my knowledge is not good enough to be able to see what the problem is and to rewrite it. So I was hoping someone here could help me out with rewriting this code to have it work properly on PHP 7.4.

    This is the code that’s being used and that became pretty useless since the PHP 7.4 update. The theme I’m using is DFblog by Daniel Fajardo. Unfortunately it’s impossible to reach him. There’s a website but the e-mail form doesn’t work.

    function df_get_usermenu() {
    
    	global $current_user;
    
    	echo( '<div id="usermenu">' );
    
    	echo( '<div class="caption"><ul>' );
    	if( is_user_logged_in() ) {
    		get_currentuserinfo();
    		echo( '<li>'.sprintf(__('Howdy, <a href="%1$s" title="Edit your profile">%2$s</a>', 'dfBlog' ), get_template_directory_uri()."/../../../wp-admin/profile.php", $current_user->user_login ).'</li>' );
    	}
    	wp_register();
    	echo( '<li class="last">' );
    	wp_loginout();
    	echo( '</li></ul></div>' );
    
    	echo( '<div class="clear tab">' );
    	echo( '<a href="#" title="'.__( 'Users', 'dfBlog' ).'">' );
    	echo( '<img src="'.get_template_directory_uri().'/images/icons/arrow-dn.png" alt="btn" />' );
    	echo( '<img src="'.get_template_directory_uri().'/images/icons/arrow-up.png" alt="btn" style="display: none" />' );
    	echo( '</a></div>' );
    
    	echo( '</div>' );
    
    	return( true );
    }

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator bcworkz

    (@bcworkz)

    I don’t see anything wrong with your code, and the appropriate HTML is still output. It’s more likely the change in versions is affecting what JavaScript is being loaded somehow. Your page has a console error “ReferenceError: BrowserDetect is not defined” which is probably preventing your fold out script from running on a click event. Perhaps you should be looking at whatever PHP is causing the BrowserDetect script to be loaded.

    Thread Starter Ester Dammers

    (@rebelstar)

    Hi, thanks for answering. Well I’m not familiar with javascript and don’t know anything about that. The Reference Error you point at doesn’t sound as something I’ve ever heard before as well so I really don’t know where to look to solve this problem.

    Thread Starter Ester Dammers

    (@rebelstar)

    There are a few javascript files in the folder as well but as i don’t know anything about javascript, I haven’t got a clue if one of them actually has something to do with the fold out thing.

    Moderator bcworkz

    (@bcworkz)

    The erroneous BrowserDetect appears to be related to the fade in effect of content when the page loads. I’m guessing this is part of your theme. Try temporarily switching to the twentytwenty theme. If the error in browser console goes away, then it is confirmed that it’s your theme. It it’s not your theme, selectively deactivate plugins to zero in on the offending module. I’d then recommend you seek assistance through the dedicated support channel of the responsible module.

    Thread Starter Ester Dammers

    (@rebelstar)

    Thanks again but are you sure you’re looking at the right page because as far as I know (and see) there’s never been any fade-in effect for content. It just loads and then it’s there. I’m really getting a bit confused now although I really appreciate your approach for help.

    Thread Starter Ester Dammers

    (@rebelstar)

    The TwentyTwenty theme doesn’t have a collapsible button like this one does so I can’t test if that works or not. It must be theme related and I already tried deactivating all plug-ins and even reverting the theme back to the original files (I did some customisations) but unfortunately the button-issue stays where it is. The only difference is when I roll back to PHP 7.0 so that’s how I know it’s something that has to do with the PHP upgrade.

    Moderator bcworkz

    (@bcworkz)

    Whether the fade in effect manifests itself or not isn’t the issue. There’s code on the page that tries to apply a fade in effect which is causing an error. While twentytwenty doesn’t have your fold out eelement, the goal is to see if the Reference error: BrowserDetect is not defined message goes away in the console. We don’t need the fold out element to do so.

    I think what has happened is the change in PHP version has caused scripts to load in a different order. The script defining BrowserDetect is probably still there, but is now executed after the BrowserDetect variable is first referenced. This can happen when scripts are not properly enqueued with appropriate dependency parameters.

    This may not actually resolve the broken fold out, but we cannot properly evaluate its functioning when there is a console error on the page. All the same, resolving this error will probably allow the fold out to work correctly.

    If you’re not interested in the fade in effect, the best course of action is to remove any related script. We need to identify the module responsible to do so. Unless there is a related setting somewhere in the admin area, you’ll likely need the assistance of the responsible module’s developer.

    Thread Starter Ester Dammers

    (@rebelstar)

    Sorry for my extremely late reply and thanks so much for your help. I did find the fade in effect which is actually in the same line as the browserdetect, I think. My knowledge of advanced scripting doesn’t go that far.

    If I actually remove the line and upload the file without it, the fold-out item works again! But I’m not sure if it’s safe to really remove it. It’s something related to IE6 and I don’t use that browser. I just commented it out now, but maybe you have a clue if it’s better to alter this line or that it’s safe to have it removed.

    This is the line where the fade script goes including something ‘browserdetect’.

    echo( '<script type="text/javascript">jQuery(document).ready(function(){ if( BrowserDetect.browser == "Explorer" && BrowserDetect.version <= 6){jQuery("#wrapper").fadeOut(2000);jQuery("#absolute").hide();jQuery("#absolute").load("'.$Modules->url.'ie6/template.html");jQuery("#absolute").fadeIn(2000);}});</script>' );
    
    • This reply was modified 3 years, 7 months ago by Ester Dammers.
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘‘Fold out’ tab not working after PHP 7.4’ is closed to new replies.