{"id":31642196,"url":"https://github.com/mamedul/wp-hook","last_synced_at":"2026-04-19T14:34:06.675Z","repository":{"id":314757913,"uuid":"1056667778","full_name":"mamedul/wp-hook","owner":"mamedul","description":"WP Hook - Powerful WordPress-Like Hook System for Node.js","archived":false,"fork":false,"pushed_at":"2025-09-14T15:56:37.000Z","size":1448,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-14T16:35:49.533Z","etag":null,"topics":["actions","architecture","events","extensible","filters","hooks","node-hook","nodejs-hook","plugin","wordpress","wp-hook"],"latest_commit_sha":null,"homepage":"https://mamedul.github.io/wp-hook/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mamedul.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-14T15:09:33.000Z","updated_at":"2025-09-14T15:56:40.000Z","dependencies_parsed_at":"2025-09-14T16:35:53.786Z","dependency_job_id":"8e496bfe-a352-40f6-b764-d9ca5dd16747","html_url":"https://github.com/mamedul/wp-hook","commit_stats":null,"previous_names":["mamedul/wp-hook"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/mamedul/wp-hook","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mamedul%2Fwp-hook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mamedul%2Fwp-hook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mamedul%2Fwp-hook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mamedul%2Fwp-hook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mamedul","download_url":"https://codeload.github.com/mamedul/wp-hook/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mamedul%2Fwp-hook/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278717450,"owners_count":26033542,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","architecture","events","extensible","filters","hooks","node-hook","nodejs-hook","plugin","wordpress","wp-hook"],"created_at":"2025-10-07T03:57:07.997Z","updated_at":"2025-10-07T03:57:19.782Z","avatar_url":"https://github.com/mamedul.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WP-HOOK\n\nA powerful and flexible **hook system** for **Node.js**, inspired by the WordPress **actions** and **filters** API. This package provides a simple yet effective way to create extensible and decoupled architectures in your JavaScript applications.\n\n![wp-hook](wp-hook-og-image.png)\n\n[![Version](https://img.shields.io/badge/Version-2025.9.15-blue.svg)](https://github.com/mamedul/wp-hook/)\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/mamedul/wp-hook/blob/main/LICENSE) \u0026nbsp;\u0026nbsp; [![GitHub stars](https://img.shields.io/github/stars/mamedul/wp-hook?style=social)](https://github.com/mamedul/wp-hook/stargazers) \u0026nbsp;\u0026nbsp; [![GitHub forks](https://img.shields.io/github/forks/mamedul/wp-hook?style=social)](https://github.com/mamedul/wp-hook/network/members) \u0026nbsp;\u0026nbsp; [![GitHub watchers](https://img.shields.io/github/watchers/mamedul/wp-hook?style=social)](https://github.com/mamedul/wp-hook/watchers) \u0026nbsp;\u0026nbsp; [![GitHub followers](https://img.shields.io/github/followers/mamedul?style=social)](https://github.com/mamedul?tab=followers)\n[![Hire Me](https://img.shields.io/badge/Hire%20Me-Available-brightgreen.svg)](http://mamedul.github.io/)\n\n\n_\\[ It is designed to be cross-platform, supporting modern ES2015+ environments as well as vanilla JavaScript setups. \\]_\n\n## Features\n\n*   **Full WordPress Hook API compatibility:** Implements the vast majority of WP hook functions.\n    \n*   **Actions (`do_action`):** Create points in your code where other functions can be executed.\n    \n*   **Filters (`apply_filters`):** Create points in your code where data can be modified.\n    \n*   **Priority-based execution:** Control the order in which callbacks are executed.\n    \n*   **Hook Inspection:** Check if hooks exist, how many times they've run, and what's currently running.\n    \n*   **Easy to use:** A simple and intuitive API.\n    \n*   **Zero dependencies:** Lightweight and self-contained.\n    \n\n## Installation\n\nYou can install package via-\n\n### ✅ **npm install**\n\nThis is the **standard** way to install any Node.js package-\n\n```bash\nnpm install wp-hook\n```\n\nOr-\n\n\n### ✅ **Yarn install**\n\nYes — Yarn can install npm packages because it uses the same npm registry under the hood (equivalent to `npm install wp-hook`)-\n\n```bash\nyarn add wp-hook\n```\n\n---\n\n### ✅ **Test**\n\nAfter installation, you can run tests from the terminal using-\n\n```bash\nnpm run test\n```\n\n## Quick Start\n\n### ✅ NodeJS\n\n```js\nconst {add_action, do_action, did_action,  add_filter, apply_filters, current_action} = require('wp-hook');\n\n// --- ACTIONS ---\n// 1. Register a function for an action hook\nfunction myActionCallback(arg1, arg2) {\n    console.log(`Action running! Args: ${arg1}, ${arg2}`);\n    console.log(`Currently doing action: ${current_action()}`);\n}\nadd_action('app_init', myActionCallback, 10, 2);\n\n// 2. Trigger the action hook\nconsole.log('Doing action...');\ndo_action('app_init', 'user_id_123', { setting: 'on' });\nconsole.log(`'app_init' has run ${did_action('app_init')} time(s).`);\n\n\n// --- FILTERS ---\n// 1. Register a function for a filter hook\nfunction myFilterCallback(text) {\n    return text.toUpperCase();\n}\nadd_filter('format_title', myFilterCallback);\n\n// 2. Trigger the filter hook and use the modified value\nlet title = 'Hello World';\ntitle = apply_filters('format_title', title);\nconsole.log(title); // Output: HELLO WORLD\n```\n\n***OR***\n\n\n### ✅ Browser Usage (UMD)\n\nThis library can be used directly in the browser. A UMD (Universal Module Definition) bundle is provided in the `dist` folder, which is also available via CDN.\n\n#### 1\\. Include via CDN\n\nYou can add `wp-hook` to your project by including the following script tag. It's recommended to use the minified version for production.\n\n```html\n\u003c!-- Regular --\u003e\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/wp-hook/dist/wp-hook.umd.js\"\u003e\u003c/script\u003e\n\n\u003c!-- Minified --\u003e\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/wp-hook/dist/wp-hook.umd.min.js\"\u003e\u003c/script\u003e\n```\n\n#### 2\\. Example Usage\n\nOnce included, the library will be available under the global variable `Wp_Hook`.\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n    \u003ctitle\u003ewp-hook Browser Example\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003ch1\u003eCheck the console for output!\u003c/h1\u003e\n\n    \u003cscript src=\"https://cdn.jsdelivr.net/npm/wp-hook/dist/wp-hook.umd.min.js\"\u003e\u003c/script\u003e\n\n    \u003cscript\u003e\n        // The library is now available on the window.Wp_Hook object\n        console.log(Wp_Hook);\n\n        // Add an action\n        Wp_Hook.add_action('app_loaded', function() {\n            console.log('The application has loaded!');\n        });\n\n        // Trigger the action\n        Wp_Hook.do_action('app_loaded');\n        // Console Output: The application has loaded!\n\n        // Use a filter\n        const originalText = \"hello browser\";\n        const filteredText = Wp_Hook.apply_filters('format_text', originalText, (text) =\u003e text.toUpperCase());\n        \n        console.log(filteredText); \n        // Note: Filters require a callback to be added first to have an effect.\n        // Let's add one now.\n        Wp_Hook.add_filter('format_text', (text) =\u003e text.toUpperCase());\n        const trulyFilteredText = Wp_Hook.apply_filters('format_text', originalText);\n        console.log(trulyFilteredText);\n        // Console Output: HELLO BROWSER\n    \u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n---\n\n## Preview\n\n\n### ✅ NodeJS\n\n```bash\nnode run test\n```\n\n**OR**\n\n### ✅ Browser  (UMD)\n\n[▶ Open Live Preview](https://mamedul.ddns.net/wp-hook/browser-test.html)\n\n\n---\n\n## API Reference\n\n### 1\\. Registering Hooks\n\n| Function | Purpose |\n| --- | --- |\n| `add_action(hook, callback, priority, args)` | Attach a function to an action hook. |\n| `add_filter(hook, callback, priority, args)` | Attach a function to a filter hook. |\n\n### 2\\. Triggering Hooks\n\n| Function | Purpose |\n| --- | --- |\n| `do_action(hook, ...args)` | Trigger an action hook (run all attached callbacks). |\n| `do_action_ref_array(hook, args_array)` | Same as `do_action()`, but pass arguments as an array. |\n| `apply_filters(hook, value, ...args)` | Trigger a filter hook, passing `$value` through each callback. |\n| `apply_filters_ref_array(hook, args_array)` | Same as `apply_filters()`, but arguments are passed as an array. |\n\n### 3\\. Removing Hooks\n\n| Function | Purpose |\n| --- | --- |\n| `remove_action(hook, callback, priority)` | Remove a previously added action callback. |\n| `remove_filter(hook, callback, priority)` | Remove a previously added filter callback. |\n| `remove_all_actions(hook, priority)` | Remove all callbacks for a specific action hook (or priority). |\n| `remove_all_filters(hook, priority)` | Remove all callbacks for a specific filter hook (or priority). |\n\n### 4\\. Inspecting Hooks\n\n| Function | Purpose |\n| --- | --- |\n| `has_action(hook, callback = false)` | Check if a function is hooked to an action (or if any callbacks exist). |\n| `has_filter(hook, callback = false)` | Check if a function is hooked to a filter (or if any callbacks exist). |\n| `did_action(hook)` | Returns how many times an action has run. |\n| `current_action()` | Get the name of the currently running action hook. |\n| `current_filter()` | Get the name of the currently running filter hook. |\n| `doing_action(hook = null)` | Check if a specific action (or any action) is currently running. |\n| `doing_filter(hook = null)` | Check if a specific filter (or any filter) is currently running. |\n\n## Advanced Usage\n\n### ✅ Custom Instances\n\nWhile the singleton is convenient, you can create isolated instances of the `Wp_Hook` class for separate event buses.\n\n```js\nconst myInstance = new Wp_Hook();\n\nmyInstance.add_action('my_hook', () =\u003e console.log('Hello from my instance!'));\n\nmyInstance.do_action('my_hook');\n```\n\n\n## Files\n\nFiles structures/ tree\n\n```bash\nwp-hook/\n├── lib/\n│   └── Wp-Hook.js\n│   └── Hook.js\n├── dist/\n│   └── wp-hook.umd.js\n│   └── wp-hook.umd.min.js\n├── test.js\n├── browser-test.html\n├── package.json\n├── README.md\n└── CHANGELOG.md\n```\n\n## License\n\nThis extensible codes is licensed under the [**MIT License**](LICENSES.md). Copyright (c) 2025 by [**Mamedul Islam**](https://mamedul.github.io/).\n\nSee the [LICENSE](https://opensource.org/licenses/MIT) file for more details.\n\n---\n\n## Show Your Support\n\nIf you find this extension useful, please consider giving it a star on GitHub! Your support helps motivate further development and improvements.\n\n[![GitHub stars](https://img.shields.io/github/stars/mamedul/wp-hook?style=for-the-badge)](https://github.com/mamedul/wp-hook/stargazers) \u0026nbsp;\n\nIf you found this project helpful, give it a ⭐ on GitHub!\n\n## Author \u0026 Hire\n\nThis extensible codes was created by [**Mamedul Islam**](https://mamedul.github.io/) and opened for [contribute](CONTRIBUTE.md) by anyone.\n\n_As a passionate **web developer** with experience in creating interactive and user-friendly web components. Currently *available for freelance projects* or full-time opportunities._\n\n_Helping businesses grow their online presence with custom web solutions. Specializing in **WordPress**, **WooCommerce**, and **Shopify**. Building modern, responsive, and high-performance scalable websites with custom made plugins, codes, customizations._\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://mamedul.github.io\" title=\"Portfolio\"\u003e\u003cimg src=\"https://img.shields.io/badge/Portfolio-38BDF8?style=for-the-badge\u0026logo=google-chrome\u0026logoColor=white\" alt=\"Portfolio\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://wa.me/8801847406830?text=Hi%2C%20do%20you%20have%20time%20to%20develop%20or%20update%20my%20website%3F\" title=\"WhatsApp\"\u003e\u003cimg src=\"https://img.shields.io/badge/WhatsApp-25D366?style=for-the-badge\u0026logo=whatsapp\u0026logoColor=white\" alt=\"WhatsApp\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.fiverr.com/mamedul\" title=\"Fiverr\"\u003e\u003cimg src=\"https://img.shields.io/badge/Fiverr-4DBF43?style=for-the-badge\u0026logo=fiverr\u0026logoColor=white\" alt=\"Fiverr\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.linkedin.com/in/mamedul/\" title=\"LinkedIn\"\u003e\u003cimg src=\"https://img.shields.io/badge/LinkedIn-0A66C2?style=for-the-badge\u0026logo=linkedin\u0026logoColor=white\" alt=\"LinkedIn\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.x.com/mamedul\" title=\"X (Twitter)\"\u003e\u003cimg src=\"https://img.shields.io/badge/X-4020F0?style=for-the-badge\u0026logo=x\u0026logoColor=white\" alt=\"X (Twitter)\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/mamedul\" title=\"GitHub\"\u003e\u003cimg src=\"https://img.shields.io/badge/GitHub-238636?style=for-the-badge\u0026logo=github\u0026logoColor=white\" alt=\"GitHub\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmamedul%2Fwp-hook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmamedul%2Fwp-hook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmamedul%2Fwp-hook/lists"}