PHP 7 and WordPress: How to FIX unexpected ‘new’ (T_NEW) error

Hey,

after I’ve upgraded my PHP to version 7 I found the following error being displayed for one plugin I was using:

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

Parse error: syntax error, unexpected ‘new’ (T_NEW) in /var/www/vhosts/wp-content/plugins/smilies-themer/smilies-themer.php on line 80

The solution was pretty easy. Just open an editor on the file and line PHP tells you. Now you should see something like

$this->smilies =& new smilies_package($this->current_smilies);

Here they made some changes in PHP 7. You can’t assign classes with a & symbol anymore. So just remove that & symbol and the plugin will work fine again (search for multiple occurences).

Here you go, have fun with very fast working new PHP 7 and your (old) WordPress !

  1. thanks. works for me (so far)

  2. Thanks that was a great help about removing the & from &new when using php 7.0.

    Regards: Graeme

  3. Thanks, i’m examining some old plugins and this really helped me!

Leave a Comment