WordPress.org

Forums

Category Posts in Custom Menu
[resolved] unexpected T_FUNCTION (19 posts)

  1. marcelbrown
    Member
    Posted 1 year ago #

    Updated to version 0.9.1. Now can't activate plugin because of the following error:

    Parse error: syntax error, unexpected T_FUNCTION in /home/simplysm/public_html/wp-content/plugins/category-posts-in-custom-menu/category-posts-in-custom-menu.php on line 125

    WordPress 3.8 with Genesis 2.02 and Serenity 1.02 child theme.

    Any help would be appreciated. Thanks!

    http://wordpress.org/plugins/category-posts-in-custom-menu/

  2. Jeremie.fr
    Member
    Posted 1 year ago #

    Same problem here.
    I think this is because the module is now using closures which can cause issues with php version prior to 5.3.

    I modified my .htaccess to have a
    SetEnv PHP_VER 5_4
    instead of
    SetEnv PHP_VER 5

    But the method can be different depend on your web server.

  3. justbase
    Member
    Posted 1 year ago #

    same here. and to modify my htaccess, without the setenv statement being in there in the first place, is not an option for me... Misschien weet je een oplossing hiervoor Diana?

  4. Joseph Kesisoglou
    Member
    Posted 1 year ago #

    I have got the same issue.

    Parse error: syntax error, unexpected T_FUNCTION in /www/blog/wp-content/plugins/category-posts-in-custom-menu/category-posts-in-custom-menu.php on line 125

    I tried removing lines 123-127, which I assume are only comments, but still no change. Also tried clean install through the wordpress environment - didn't work - and finally I tried another clean installation by downloading the plugin to my client and then uploading to server via FTP - didn't work either. In my situation it might be clashing with changes I made on the functions.php
    I hope one with greater php knowledge can debug this.

    After all this experimentation wordpress deactivated the plugin automatically and upon manual activation it generates this:

    Plugin could not be activated because it triggered a fatal error.

    followed by the parse error.

    http://josephkesisoglou.co.uk/blog
    Theme: Descartes 1.2 (modified)

  5. justbase
    Member
    Posted 1 year ago #

    my suggestion is to download the previous version 0.9 and install that one. it worked for me and im a happy camper again...

  6. marcelbrown
    Member
    Posted 1 year ago #

    I checked and the hosting for this site was using PHP 5.2. I had to edit the .htaccess file to use a newer PHP version and the problem is resolved. However, I would think that the plugin author would probably want to code a fallback for PHP 5.2 regardless.

    Since I use HostGator, the following is all I had to add to my .htaccess file, which was easy to do with the WordPress SEO Plugin by Yoast.

    # Use PHP 5.4
    AddType application/x-httpd-php54 .php

  7. Diana Koenraadt
    Member
    Plugin Author

    Posted 1 year ago #

    Hi all,

    thank you for your reports. My apologies that the new version is causing problems. I will investigate how to introduce a fallback for earlier PHP versions.

    Kind regards,
    Diana

  8. Diana Koenraadt
    Member
    Plugin Author

    Posted 1 year ago #

    Is someone willing and able to test code changes for me with an old version of PHP, before I commit a new version of the plugin?

  9. justbase
    Member
    Posted 1 year ago #

    im willing and able.

  10. Diana Koenraadt
    Member
    Plugin Author

    Posted 1 year ago #

    justbase, thank you kindly!

    I've added an if-else statement to switch between old and newer versions of PHP and have checked this in to the Development Version.

    For anyone who is willing and able to test drive it: On the plugin homepage, click 'Developers' and then under 'Other Versions', download the plugin .zip by clicking 'Developers Version'.

    I'd love to hear your feedback. Again, my apologies for my inattentiveness with regards to PHP versions.

    Kind regards,
    Diana

  11. justbase
    Member
    Posted 1 year ago #

    Parse error: syntax error, unexpected T_FUNCTION in /home2/pageinsb/public_html/wp-content/plugins/category-posts-in-custom-menu/category-posts-in-custom-menu.php on line 156

  12. justbase
    Member
    Posted 1 year ago #

    geen probleem om je te helpen met testen, i think the updated code works, but there seems to be a basic syntax error. no biggie

  13. Diana Koenraadt
    Member
    Plugin Author

    Posted 1 year ago #

    I'm glad you offered to test. It seems that this way of switching versions doesn't work, the offending code is still interpreted and causes the original error.

    Thank you very much for your help. I've found some new reference material on how to switch depending on the PHP version, will try to fix it before I go to work.

    Kind regards,
    Diana

  14. Diana Koenraadt
    Member
    Plugin Author

    Posted 1 year ago #

    I've applied the different way of switching versions.
    I've now added a cpcm-functions.php file and cpcm-functions52.php file, each defining the function replace_dates in a different manner. The PHP require() function is called depending on the PHP version, thereby avoiding the aforementioned syntax error.

    If someone could please re-test this with PHP 5.2 or below, I'd be very grateful. Please reinstall the complete plugin, not just the main .php file, because of the two newly added files.

    Kind regards,
    Diana

  15. themightyant
    Member
    Posted 1 year ago #

    Hi Diana,
    the new dev version works fine on my server PHP 5.2.9.
    Thanks for the plugin and update
    Regards
    Antony

  16. Diana Koenraadt
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Antony,

    thank you kindly for testing the new development version.
    Is there someone who can verify this please? Not out of doubt about Antony's test, but just to be sure.

    Kind regards,
    Diana

  17. r.glenn.nall
    Member
    Posted 1 year ago #

    worked GREAT this way for me, too. thanks. (i've noticed this same error with another plugin, recently, too...)

  18. Diana Koenraadt
    Member
    Plugin Author

    Posted 1 year ago #

    Hi r.glenn.nall,

    thank you kindly for testing the development version as well.
    I will mark version 0.9.2 tonight when I get home.

    Kind regards,
    Diana

  19. Diana Koenraadt
    Member
    Plugin Author

    Posted 1 year ago #

    Version 0.9.2 has been committed and tagged.

    Kind regards,
    Diana

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic