Styger Posted July 12, 2018 Share Posted July 12, 2018 My web host recommend an upgrade to PHP 7 but my Wordpress theme is using a deprecated ereg expression that is breaking the comments section. Here's the offending code: function the_commenter_link() { $commenter = get_comment_author_link(); if ( ereg( ']* class=[^>]+>', $commenter ) ) {$commenter = ereg_replace( '(]* class=[\'"]?)', '\\1url ' , $commenter ); } else { $commenter = ereg_replace( '(<a )/', '\\1class="url "' , $commenter );} echo $commenter ; } Reading posts online it seems that ereg needs to be replaced with preg_match and preg_replace. Is it a straight swap like written below or is there more to it than that? function the_commenter_link() { $commenter = get_comment_author_link(); if ( preg_match( ']* class=[^>]+>', $commenter ) ) {$commenter = preg_replace( '(]* class=[\'"]?)', '\\1url ' , $commenter ); } else { $commenter = preg_replace( '(<a )/', '\\1class="url "' , $commenter );} echo $commenter ; } Thanks for your help! Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted July 12, 2018 Share Posted July 12, 2018 What theme is it. Is there an update to the theme? If that's broken, more likely than not there will be other parts broken as well. If not here's a guide on how to make the switch. https://docstore.mik.ua/orelly/webprog/pcook/ch13_02.htm Quote Link to comment Share on other sites More sharing options...
Styger Posted July 12, 2018 Author Share Posted July 12, 2018 (edited) It's a woo theme that was retired in 2015 so there are no more updates. Everything seemed to work okay with PHP 7 except the comments section. I ran a search through the theme's PHP files and this was the only reference to ereg. Thanks for the link but I still don't understand the proper syntax because I don't work with code. Edited July 12, 2018 by Styger Quote Link to comment Share on other sites More sharing options...
requinix Posted July 13, 2018 Share Posted July 13, 2018 If you want to make changes to code then you'll have to "work with code". That link covers half of the changes you'll need to make. What's your code with them in place? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.