DiviArea.Utils.sanitizeHookName()

  1. Home
  2. Knowledge Base
  3. Codex
  4. JS API
  5. JS Functions
  6. 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