Hello CF7 Team and @takayukister,
I was testing a WordPress site on PHP 8.2.
I noticed that there is a PHP ERROR caused by CF7 Form.
Reason –
Call to undefined function create_function() in formatting.php
(includes/formatting.php)
PHP Documentation –
https://www.php.net/manual/en/function.create-function.php
(This function has been DEPRECATED as of PHP 7.2.0, and REMOVED as of PHP 8.0.0. Relying on this function is highly discouraged.)
The Code with issue –
(includes/formatting.php)
$pee = preg_replace_callback( '/<(script|style|textarea).*?<\/\\1>/s', create_function( '$matches', 'return str_replace("\n", "<WPPreserveNewline />", $matches[0]);' ), $pee );
The updated code that I suggest –
$pee = preg_replace_callback(
'/<(script|style|textarea).*?<\/\\1>/s',
function($matches) {
return str_replace("\n", "<WPPreserveNewline />", $matches[0]);
},
$pee
);
This code is compatible with PHP 7/8.
I request you to pls include this small bug fix in future updates of CF7.
Regards
The page I need help with: [log in to see the link]