{"id":19419254,"url":"https://github.com/wp-hooks/generator","last_synced_at":"2025-05-16T18:06:17.413Z","repository":{"id":36234685,"uuid":"222433287","full_name":"wp-hooks/generator","owner":"wp-hooks","description":"Generates a JSON representation of the WordPress actions and filters in your code","archived":false,"fork":false,"pushed_at":"2025-02-02T17:36:01.000Z","size":567,"stargazers_count":80,"open_issues_count":5,"forks_count":8,"subscribers_count":1,"default_branch":"trunk","last_synced_at":"2025-04-03T18:15:24.656Z","etag":null,"topics":["wordpress"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/wp-hooks/generator","language":"PHP","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/wp-hooks.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"johnbillion"}},"created_at":"2019-11-18T11:28:49.000Z","updated_at":"2025-03-31T16:50:35.000Z","dependencies_parsed_at":"2024-11-17T14:02:34.892Z","dependency_job_id":"238e5b1d-38ad-44de-a240-43a0e8899d78","html_url":"https://github.com/wp-hooks/generator","commit_stats":{"total_commits":142,"total_committers":3,"mean_commits":"47.333333333333336","dds":"0.21830985915492962","last_synced_commit":"6c7f173d85452db52a59a3a6bb943cbe7d845cde"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-hooks%2Fgenerator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-hooks%2Fgenerator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-hooks%2Fgenerator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-hooks%2Fgenerator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wp-hooks","download_url":"https://codeload.github.com/wp-hooks/generator/tar.gz/refs/heads/trunk","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248606861,"owners_count":21132428,"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","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":["wordpress"],"created_at":"2024-11-10T13:16:58.833Z","updated_at":"2025-04-12T17:38:28.147Z","avatar_url":"https://github.com/wp-hooks.png","language":"PHP","funding_links":["https://github.com/sponsors/johnbillion"],"categories":[],"sub_categories":[],"readme":"# WP Hooks Generator\n\nGenerates a JSON representation of the WordPress actions and filters in your code. Can be used with WordPress plugins, themes, and core.\n\nNote: If you just want the hook files without generating them yourself, use the following packages instead:\n\n* [wp-hooks/wordpress-core](https://github.com/wp-hooks/wordpress-core) for WordPress core\n\n## Requirements\n\nPHP 8.3 or higher.\n\n## Installation\n\n```shell\ncomposer require wp-hooks/generator\n```\n\n## Generating the Hook Files\n\n```shell\n./bin/wp-hooks-generator --input=src --output=hooks\n```\n\n## Usage of the Generated Hook Files in PHP\n\n```php\n// Get hooks as JSON:\n$actions_json = file_get_contents( 'hooks/actions.json' );\n$filters_json = file_get_contents( 'hooks/filters.json' );\n\n// Convert hooks to PHP:\n$actions = json_decode( $actions_json, true )['hooks'];\n$filters = json_decode( $filters_json, true )['hooks'];\n\n// Search for filters matching a string:\n$search = 'permalink';\n$results = array_filter( $filters, function( array $hook ) use ( $search ) {\n    return ( strpos( $hook['name'], $search ) !== false );\n} );\n\nvar_dump( $results );\n```\n\n## Usage of the Generated Hook Files in JavaScript\n\n```js\n// Get hooks as array of objects:\nconst actions = require('hooks/actions.json').hooks;\nconst filters = require('hooks/filters.json').hooks;\n\n// Search for actions matching a string:\nconst search = 'menu';\nconst results = actions.filter( hook =\u003e ( hook.name.match( search ) !== null ) );\n\nconsole.log(results);\n```\n\n## Ignoring Files or Directories\n\nYou can ignore files or directories in two ways:\n\n### On the Command Line\n\n    ./vendor/bin/wp-hooks-generator --input=src --output=hooks --ignore-files=\"ignore/this,ignore/that\"\n\n### In composer.json\n\n```json\n\"extra\": {\n    \"wp-hooks\": {\n        \"ignore-files\": [\n            \"ignore/this\",\n            \"ignore/that\"\n        ]\n    }\n}\n```\n\n## Ignoring Hooks\n\nYou can ignore hooks in two ways:\n\n### On the Command Line\n\n    ./vendor/bin/wp-hooks-generator --input=src --output=hooks --ignore-hooks=\"this_hook,that_hook\"\n\n### In composer.json\n\n```json\n\"extra\": {\n    \"wp-hooks\": {\n        \"ignore-hooks\": [\n            \"this_hook\",\n            \"that_hook\"\n        ]\n    }\n}\n```\n\n## TypeScript Interfaces for the Hook Files\n\nThe TypeScript interfaces for the hook files can be found in [`interface/index.d.ts`](interface/index.d.ts). Usage:\n\n```typescript\nimport { Hooks, Hook, Doc, Tags, Tag } from 'hooks/index.d.ts';\n```\n\n## JSON Schema for the Hook Files\n\nThe JSON schema for the hook files can be found in [`schema.json`](schema.json).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwp-hooks%2Fgenerator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwp-hooks%2Fgenerator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwp-hooks%2Fgenerator/lists"}