ILA (Spuds) preg_replace_callback

Aperto da Flavio93Zena, Venerdì - 24 Agosto 2018 - 06:19

0 Utenti e 1 Visitatore stanno visualizzando questa discussione.

Flavio93Zena

8192: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead
File: /public_html/Sources/ILA-Subs.php
Line: 346

Blah blah rimpiazzare preg_replace col preg_replace_callback nella mod in-line attachments di Spuds (lo scrivo più che altro per la ricerca), ema quando non hai un accidente da fare che proprio ti giri i pollici sai cosa fare ;D

Grazie in anticipo ::)

emanuele

Nella versione github non vedo callback con /e, l'hai provata?
https://github.com/Spuds/SMF-ILA

Flavio93Zena

O_o deve aver fatto qualche casino perchè ho la stessa identica versione ma il codice è diverso... L'ho provata e pare funzionare, grazie! :D

Per i posteri, ho cambiato tutta la funzione (giusto per tagliare la testa al toro):
function ila_hide_bbc(&$message, $hide_tags = '')
{
global $modSettings;
if (empty($modSettings['enableBBC']))
return;
if (stripos($message, '[attach') === false)
return;
// if our ila attach tags are nested inside of these tags we need to hide them so they don't fire
if ($hide_tags == '')
$hide_tags = array('code', 'html', 'php', 'noembed', 'nobbc');
// look for each tag, if attach is found inside then replace its[ with a hex so we don't try to render them later
foreach ($hide_tags as $tag)
{
if (stripos($message, '[' . $tag . ']') !== false)
{
$message = preg_replace_callback('~\[' . $tag . ']((?>[^[]|\[(?!/?' . $tag . ']))+?)\[/' . $tag . ']~i',
function($matches) use($tag)
{
return "[" . $tag . "]" . str_ireplace("[attach", "[attach", $matches[1]) . "[/" . $tag . "]";
},
$message);
}
}
}

Discussioni simili (2)