承接 wp-hooks/generator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wp-hooks/generator

最新稳定版本:1.0.1

Composer 安装命令:

composer require wp-hooks/generator

包简介

Generates a JSON representation of the WordPress actions and filters in your code

README 文档

README

Generates a JSON representation of the WordPress actions and filters in your code. Can be used with WordPress plugins, themes, and core.

Note: If you just want the hook files without generating them yourself, use the following packages instead:

Requirements

PHP 8.3 or higher.

Installation

composer require wp-hooks/generator

Generating the Hook Files

./bin/wp-hooks-generator --input=src --output=hooks

Usage of the Generated Hook Files in PHP

// Get hooks as JSON: $actions_json = file_get_contents( 'hooks/actions.json' ); $filters_json = file_get_contents( 'hooks/filters.json' ); // Convert hooks to PHP: $actions = json_decode( $actions_json, true )['hooks']; $filters = json_decode( $filters_json, true )['hooks']; // Search for filters matching a string: $search = 'permalink'; $results = array_filter( $filters, function( array $hook ) use ( $search ) { return ( strpos( $hook['name'], $search ) !== false ); } ); var_dump( $results );

Usage of the Generated Hook Files in JavaScript

// Get hooks as array of objects: const actions = require('hooks/actions.json').hooks; const filters = require('hooks/filters.json').hooks; // Search for actions matching a string: const search = 'menu'; const results = actions.filter( hook => ( hook.name.match( search ) !== null ) ); console.log(results);

Ignoring Files or Directories

You can ignore files or directories in two ways:

On the Command Line

./vendor/bin/wp-hooks-generator --input=src --output=hooks --ignore-files="ignore/this,ignore/that" 

In composer.json

"extra": { "wp-hooks": { "ignore-files": [ "ignore/this", "ignore/that" ] } }

Ignoring Hooks

You can ignore hooks in two ways:

On the Command Line

./vendor/bin/wp-hooks-generator --input=src --output=hooks --ignore-hooks="this_hook,that_hook" 

In composer.json

"extra": { "wp-hooks": { "ignore-hooks": [ "this_hook", "that_hook" ] } }

TypeScript Interfaces for the Hook Files

The TypeScript interfaces for the hook files can be found in interface/index.d.ts. Usage:

import { Hooks, Hook, Doc, Tags, Tag } from 'hooks/index.d.ts';

JSON Schema for the Hook Files

The JSON schema for the hook files can be found in schema.json.

统计信息

  • 总下载量: 174.91k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 86
  • 点击次数: 0
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 86
  • Watchers: 1
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固