DiviArea.Utils.sanitizeHookName()

DiviArea.Utils.sanitizeHookName(name)

Sanitizes the given name before it is injected into a hook-name.

This function will convert the name to lower-case, replace dashes with underscores and remove any other special character.

Params

name string, required
The value to sanitize.

Returns

A string that is safe to use in the name of an action or filter. It contains only lower-case characters, digits and underscores.

Examples

// Sanitize a Popup ID to for a hook name.
var key = DiviArea.Utils.sanitizeHookName( area.attr( 'id' ) );

// Use the sanitized key in an action hook.
DiviArea.doAction( 'init_area_' + key, area );

Notes

No notes

Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Get in touch with us