{"id":15505615,"url":"https://github.com/dimitribouteille/wp-hooks","last_synced_at":"2025-04-23T01:51:51.052Z","repository":{"id":43570520,"uuid":"251437379","full_name":"dimitriBouteille/wp-hooks","owner":"dimitriBouteille","description":"Wordpress library to manage actions and filters.","archived":false,"fork":false,"pushed_at":"2022-02-26T16:03:10.000Z","size":17,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-23T01:51:46.453Z","etag":null,"topics":["composer","hooks","wordpress","wp"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dimitriBouteille.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-30T21:55:51.000Z","updated_at":"2024-05-11T07:48:23.000Z","dependencies_parsed_at":"2022-08-23T08:01:05.239Z","dependency_job_id":null,"html_url":"https://github.com/dimitriBouteille/wp-hooks","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimitriBouteille%2Fwp-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimitriBouteille%2Fwp-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimitriBouteille%2Fwp-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimitriBouteille%2Fwp-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dimitriBouteille","download_url":"https://codeload.github.com/dimitriBouteille/wp-hooks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250354298,"owners_count":21416751,"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":["composer","hooks","wordpress","wp"],"created_at":"2024-10-02T09:24:01.965Z","updated_at":"2025-04-23T01:51:51.034Z","avatar_url":"https://github.com/dimitriBouteille.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wordpress hooks\n\nWordpress library that makes it easier to manage actions and filters.\n\n[![Latest Stable Version](https://img.shields.io/packagist/v/dbout/wp-hooks?style=flat-square)](https://packagist.org/packages/dbout/wp-hooks) ![PHP Version](https://img.shields.io/packagist/php-v/dbout/wp-hooks)\n\n## Requirements\n\nThe server requirements are basically the same as for WordPress with the addition of a few ones :\n\n- PHP \u003e= 7.4\n- [Composer](https://getcomposer.org/) ❤️\n\n\u003e To simplify the integration of this library, we recommend using Wordpress with one of the following tools: [Bedrock](https://roots.io/bedrock/), [Themosis](https://framework.themosis.com/) or [Wordplate](https://github.com/wordplate/wordplate#readme).\n\n## Installation\n\nInstall with composer, in the root of the Wordpress project run:\n\n```bash\ncomposer require dbout/wp-hooks\n```\n\n## Usage\n\n### Via classes\n\nThe default use is via classes, the idea of creating a class per hook:\n\n```php\nclass InitHook extends \\Dbout\\WpHooks\\Hookable\\Hookable {\n\n    protected string $hook = 'init';\n\n    public function execute(): void \n    {\n        // Do something\n    }\n}\n```\n\nIn the `function.php` file of your theme, you must now load the hook: \n\n```php\n$loader = new \\Dbout\\WpHooks\\HooksLoader();\n$loader-\u003eadd(InitHook::class);\n\n$loader-\u003eregister();\n```\n\nIf you want, you can record several hooks with the loader:\n\n```php\n$loader = new \\Dbout\\WpHooks\\HooksLoader();\n$loader\n    -\u003eadd(InitHook::class)\n    -\u003eadd(RegisterMenus::class)\n    -\u003eadd(RegisterAssets::class);\n\n$loader-\u003eregister();\n```\n\n### Second methods\n\nWithout instance :\n```php\n\\Dbout\\WpHooks\\Facade\\Action::add('init', 'InitHooks@callback');\n```\n\nWith custom instance :\n```php\n\\Dbout\\WpHooks\\Facade\\Action::add('init', [new InitHooks(), 'callback']);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimitribouteille%2Fwp-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdimitribouteille%2Fwp-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimitribouteille%2Fwp-hooks/lists"}