For php 7.2 compatibility, I need to refactor the following create_function() to an anonymous function:
function bbpp_thankmelater_shortcode_h($atts, $content = NULL) {
extract(Bbpp_ThankMeLater_Shortcoder::atts(array(
"email_type" => NULL,
"comment" => NULL,
"level" => 1
), $atts));
if ($email_type == "text") {
return str_repeat("*", $level) . " " . $content;
}
return "<h{$level}>" . $content . "</h{$level}>";
}
for ($i = 1; $i <= 6; $i++) {
Bbpp_ThankMeLater_Shortcoder::add("h{$i}", create_function("\$atts,\$content", "\$atts[\"level\"]={$i};return bbpp_thankmelater_shortcode_h(\$atts, \$content);"));
}
When using Rector to do it automatically I get this error:
[ERROR] Could not process "shortcodes/h.php" file, due to:
"Syntax error, unexpected T_NS_SEPARATOR, expecting ']':1".
Any Idea? Thx in advance for your help