Skip to content

Latest commit

 

History

History
32 lines (23 loc) · 1.49 KB

README.md

File metadata and controls

32 lines (23 loc) · 1.49 KB

#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 )
  • applyFilters( '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.