Simple Machines Community Forum

SMF Development => Feature Requests => Topic started by: dougiefresh on October 03, 2015, 01:22:51 PM

Title: Hook to help deal with auto-embed URLs for tags....
Post by: dougiefresh on October 03, 2015, 01:22:51 PM
I would love to see a hook that would enable auto-embed functions to change the message so that the auto-embedding takes place after bbcode tag definition and before bbcode tag parsing.

In SMF 2.0.x, my suggested placement would be like this:

$message = strtr($message, array("\n" => '<br />'));

At Line 1705:
// Call integration function to auto-embed stuff:
call_integration_hook('integrate_auto_embed', array(&$message));

// The non-breaking-space looks a bit different each time.
$non_breaking_space = $context['utf8'] ? ($context['server']['complex_preg_chars'] ? '\x{A0}' : "\xC2\xA0") : '\xA0';
Title: Re: Hook to help deal with auto-embed URLs for tags....
Post by: Oldiesmann on October 04, 2015, 06:25:26 PM
SMF 2.1 has an "integrate_pre_parsebbc" hook, which is called before the bbcode tags are defined, which should be sufficient for this purpose.

// Allow mods access before entering the main parse_bbc loop
call_integration_hook('integrate_pre_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags));
Title: Re: Hook to help deal with auto-embed URLs for tags....
Post by: dougiefresh on October 04, 2015, 07:52:37 PM
Damn, I didn't even see that one....  How embarrassing....  Thanks!
Title: Re: Hook to help deal with auto-embed URLs for tags....
Post by: dougiefresh on October 04, 2015, 07:57:25 PM
Here's a stupid question (hopefully not!): Can the callback function only have one parameter, even though 4 are sent by the call_integration_hook function?  For example:

function Blah_Blah_Blah(&$message)
{
}
Title: Re: Hook to help deal with auto-embed URLs for tags....
Post by: Oldiesmann on October 04, 2015, 09:09:11 PM
No, it will need all the parameters, even if you don't use them all.
Title: Re: Hook to help deal with auto-embed URLs for tags....
Post by: dougiefresh on October 05, 2015, 03:57:52 AM
Okay, thanks!