Tagged: 

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1359752

    Today I have updated 5 Enfold sites from PHP 7.4 to PHP 8.0 without any problems. However, 1 website caused a problem (www.nataliewalters.nl) after updating to PHP 8.0 and I was not able to login at WordPress anymore. I got these errors:

    WordPress versie 6.0.1
    Actief thema: Enfold Child (versie 1.0)
    Huidige plugin: (versie )
    PHP versie 8.0.20

    Foutdetails
    ===========
    Een fout van het type E_ERROR werd veroorzaakt op regelnummer 34 van het bestand /home/nataliefoto/domains/nataliewalters.nl/public_html/wp-content/themes/enfold-child/functions.php. Foutmelding: Uncaught Error: Undefined constant “‘after_setup_theme’” in /home/nataliefoto/domains/nataliewalters.nl/public_html/wp-content/themes/enfold-child/functions.php:34
    Stack trace:
    #0 /home/nataliefoto/domains/nataliewalters.nl/public_html/wp-settings.php(566): include()
    #1 /home/nataliefoto/domains/nataliewalters.nl/public_html/wp-config.php(95): require_once(‘/home/nataliefo…’)
    #2 /home/nataliefoto/domains/nataliewalters.nl/public_html/wp-load.php(50): require_once(‘/home/nataliefo…’)
    #3 /home/nataliefoto/domains/nataliewalters.nl/public_html/wp-login.php(12): require(‘/home/nataliefo…’)
    #4 {main}
    thrown

    I use Enfold Child themes on all my Enfold sites. I have set the PHP version back to 7.4 now and that solved the issue, however I would like to upgrade to 8.0 of course. So what can be the problem here?

    This is my functions.php file:

    <?php
    
    /*
    * Add your own functions here. You can also copy some of the theme functions into this file. 
    * WordPress will use those functions instead of the original functions then.
    */
    
    function wpcodex_hide_email_shortcode( $atts , $content = null ) {
    	if ( ! is_email( $content ) ) {
    		return;
    	}
    
    	$content = antispambot( $content );
    
    	$email_link = sprintf( 'mailto:%s', $content );
    
    	return sprintf( '<a href="%s">%s</a>', esc_url( $email_link, array( 'mailto' ) ), esc_html( $content ) );
    }
    add_shortcode( 'email', 'wpcodex_hide_email_shortcode' );
    
    function ava_image_sizes() {
    remove_image_size(‘masonry’);
    remove_image_size(‘magazine’);
    remove_image_size(‘widget’);
    remove_image_size(‘featured’);
    remove_image_size(‘featured_large’);
    remove_image_size(‘extra_large’);
    remove_image_size(‘portfolio_small’);
    remove_image_size(‘gallery’);
    remove_image_size(‘entry_with_sidebar’);
    remove_image_size(‘entry_without_sidebar’);
    }
    add_action( ‘after_setup_theme’, ‘ava_image_sizes’, 11 );

    Thank you for your help!

    Best Wishes,
    Alwin

    • This topic was modified 1 year, 8 months ago by Alwin.
    • This topic was modified 1 year, 8 months ago by Rikard.
    #1359785

    Hi Alwin,

    Can you try to replace all single quotes (just replace it manually).
    If that does not help, try to replace after_setup_theme with init

    Best regards,
    Nikko

    #1359795

    Hello Niko,

    I replaced all single quotes, that didn’t help.

    What do you mean with “try to replace after_setup_theme with init”? Change this line:

    add_action( ‘after_setup_theme’, ‘ava_image_sizes’, 11 );

    into this:
    add_action( ‘init’, ‘ava_image_sizes’, 11 );
    ?

    By the way, I use the exact some code in functions.php on 2 other Enfold sites which are running fine with PHP 8.0.

    Thanks,
    Alwin

    #1360004

    Hi Alwin,

    I apologize for the delayed response.
    Yes, that’s correct when I said replace after_setup_theme with init.

    Best regards,
    Nikko

    #1360367

    Hello Niko,

    Oke, I replaced the code like you said, but it does not solve the issue.

    Best Wishes,
    Alwin

    #1360393

    Hi Alwin,

    I tried the same thing on my end using WP 6.0.1 and the following PHP versions 8.0.7, 8.1.0, 7.4 and didn’t have any issue whether it’s after_setup_theme or init.
    Can you try to switch your PHP version to 7.4 or 8.1? let us know if this helps.

    Best regards,
    Nikko

    #1360450

    PHP 7.4 is working fine, but that was not the issue (the website is running 7.4 by default).

    The issue is that I like to upgrade this site to PHP 8.0. I have tried PHP 8.1 also now (like you asked me to try) but that is causing the same issue: the frontend is running fine, but I am not able to login at WordPress anymore.

    B
    Kind regards,
    Alwin

    #1360454

    Hi Alwin,

    I apologize for the inconvenience.
    Can we request for cPanel access? so we can check further on the issue as I can’t seem to replicate the issue you mentioned.

    Best regards,
    Nikko

    #1360457

    Hello Nikko,

    The issue is solved! I misunderstood your very first suggestion to replace all single quotes…

    I replaced the single quotes again, but now I did it the correct way and everything is working fine now :)

    That leaves me with the question: how is it possible that there was no issue at PHP 7.4 with the wrong single quotes in the code?

    Thanks,
    Alwin

    #1360459

    Hi Alwin,

    That is also something I have not figured out :D
    There are some people who are running PHP 7 who have that issue as well but get fixed with just manually replacing those wrong single quotes, so I just assumed that it does not work on certain servers but now I know it is true on certain PHP versions.
    Anyway, I’m really glad that the issue is fixed on your end.

    Best regards,
    Nikko

    #1360476

    Yes, thank you for your help Nikko!

    best Wishes,
    Alwin

    #1360491

    Hi,

    Great, I’m glad that Nikko could help you out. Please let us know if you should need any further help on the topic, or if we can close it.

    Best regards,
    Rikard

    #1360509

    You can close the topic Rikard, thanks :)

    #1360517

    Hi,

    Thanks for letting us know, I’ll close this thread for now then. Please open a new thread if you should have any further questions or problems.

    Best regards,
    Rikard

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Problem with PHP 8.0’ is closed to new replies.