Skip to content
This repository has been archived by the owner on Sep 4, 2018. It is now read-only.

ericmann/WP-JS-Hooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#WP-JS-Hooks

A lightweight & efficient EventManager for JS in WP.

Introduction

See ticket #21170 for more information. We also did a general overview of the project at WordSesh that you can find here.

Dependencies

WP-JS-Hooks does not require any third-party applications or software. The library is completely self-maintained. However, the repository itself uses Grunt to perform tasks such as JSHint, Uglify, and QUnit. For more information on how to install Grunt, please visit http://gruntjs.com

API Usage

API functions can be called via the global wp.hooks like this wp.hooks.addAction(), etc.

  • addAction( 'namespace.identifier', callback, priority )
  • addFilter( 'namespace.identifier', callback, priority )
  • removeAction( 'namespace.identifier' )
  • removeFilter( 'namespace.identifier' )
  • doAction( 'namespace.identifier', arg1, arg2, moreArgs, finalArg )
  • applyFilter( 'namespace.identifier', content )

Features

  • Fast and lightweight, only 1.3kb
  • Priorities system ensures hooks with lower integer priority are fired first.
  • Uses native object hash lookup for finding hook callbacks.
  • Utilizes insertion sort for keeping priorities correct. Best Case: O(n), worst case: O(n^2)

Changelog

  • 4/24/13
    • Reduced repository size by removing an old node_modules folder from repo history.

About

A lightweight & efficient EventManager for JS in WP.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published