Methods

addCurrentToMenuItem(item)

Add the current class and attributes to a menu item.

Parameters:
NameTypeDescription
itemHTMLElement

The menu item to add the current class and attributes to.

Since
  • 4.0.2

buildCacheKey(prefix, paramKeys, params) → {string}

Build a cache key.

Parameters:
NameTypeDescription
prefixstring

The prefix for the cache key.

paramKeysArray

The keys of the parameters to build the cache key.

paramsobject

The parameters to build the cache key.

Since
  • 4.0.2
Returns:

The cache key.

Type: 
string

getSearchParamsObjFromKeys(keys, searchParams) → {object}

Get a search params object from an array of keys and search params provided.

Parameters:
NameTypeDescription
keysArray | string

The keys to get from the search params.

searchParamsURLSearchParams

The search params to get the keys from.

Since
  • 4.0.2
Returns:

The search params object.

Type: 
object

hijackMenuClick(event)

Hijacks the click event on the menu.

Parameters:
NameTypeDescription
eventEvent

The click event.

Since
  • 4.0.2

removeCurrentFromMenuItem(item)

Remove the current class and attributes from a menu item.

Parameters:
NameTypeDescription
itemHTMLElement

The menu item to remove the current class and attributes from.

Since
  • 4.0.2

useCache(initialState) → {object}

A hook to manage a cache.

Parameters:
NameTypeDescription
initialStateobject

The initial state of the cache.

Since
  • 4.0.2
Returns:

The cache state and actions.

Type: 
object

useHijackWpMenu(menuId, paramKeys, setSearchParams)

Hijacks the click event on the menu.

Parameters:
NameTypeDescription
menuIdstring

The ID of the menu to hijack.

paramKeysArray | string

The keys to get from the search params.

setSearchParamsfunction

The function to set the search params.

Since
  • 4.0.2

useId(defaultId) → {string}

Generates a unique ID if default ID is not provided.

Parameters:
NameTypeDescription
defaultIdstring

The default ID.

Since
  • 3.2.2
Returns:

The ID.

Type: 
string