I have a custom tag and I want to adapt it (as done here (https://www.smfhacks.com/index.php?action=downloads;sa=view;down=215)). Is the way I do it correct?
Find
array(
'tag' => 'google',
'type' => 'unparsed_content',
'content' => '<a href="https://www.google.com/search?q=$1" target="_blank">$1</a>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
'disabled_content' => '<span style="color: red;">Google Search: $1</span>',
),
array(
'tag' => 'google',
'type' => 'unparsed_equals',
'before' => '<a href="https://www.google.com/search?q=$1" target="_blank">',
'after' => '</a>',
'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
'disabled_before' => '<span style="color: red;">',
'disabled_after' => ' ($1)</span>',
),
Replace
array(
'tag' => 'google',
'type' => 'unparsed_content',
'content' => '<a href="https://www.google.com/search?q=$1" target="_blank">$1</a>',
'validate' => function (&$tag, &$data, $disabled)
{
$data = strtr($data, array('<br>' => ''));
},
'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
'disabled_content' => '<span style="color: red;">Google Search: $1</span>',
),
array(
'tag' => 'google',
'type' => 'unparsed_equals',
'before' => '<a href="https://www.google.com/search?q=$1" target="_blank">',
'after' => '</a>',
'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
'disabled_before' => '<span style="color: red;">',
'disabled_after' => ' ($1)</span>',
),
That is the correct way to update your code from using
create_function( <args-text>, <source-code-text>)
to using anonymous function
function(args) { source code }
special attention should be made if the original source code text contained text escapes such as \' or \". You can get pretty dizzy if the original source code text also contained regex patterns
Generally that looks sound though the change of br format may bite you if not careful.