Support » Plugins and Hacks » Category Posts in Custom Menu » [Resolved] unexpected T_FUNCTION

[Resolved] unexpected T_FUNCTION

  • 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!


Viewing 15 replies - 1 through 15 (of 18 total)
  • 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.

    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?

    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.

    Theme: Descartes 1.2 (modified)

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

    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

    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,

    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?

    im willing and able.

    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,

    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

    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

    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,

    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,

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

    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,

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘[Resolved] unexpected T_FUNCTION’ is closed to new replies.
Skip to toolbar