定制 wpdesk/hook-parser 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

wpdesk/hook-parser

Composer 安装命令:

composer require wpdesk/hook-parser

包简介

WordPress hook documentation parser

README 文档

README

A library to parse the plugin code to create hook documentation.

How to document

Use PHP Doc tags when commenting apply_filter or do_action function.

Supported tags

  • @param
  • @return
  • @see
  • @ignore
  • @internal
  • @since
  • @deprecated

Worth to know

  • Parser can parse PHP code so the hooks commented out will be ignored.
  • Parse errors in code will prevent from successful scanning.
  • When a hook appears more than once then it will be shown in the documentation more than once. To prevent this use @ignore tag.

Documented hook example

<?php
/**
 * Do actions when shipment is created via checkout.
 *
 * @param \WPDesk_Flexible_Shipping_Shipment $shipment Created shipment.
 * @see https://flexibleshipping.com/
 * @deprecated
 */
do_action( 'flexible_shipping_checkout_shipment_created', $shipment );
<?php

$some_bool =
    /**
     * Long text.
     * 
     * @param bool $some_bool Some bool value passed to filter.
     * @param string $some_string Some string passed to filter.
     * @return bool Returns true when in a mood. 
     * 
     * @since 1.2.3 
     * @internal Can be changed anytime. 
     */ 
    apply_filters( sprintf( 'some_filter_%s', $var), true, $someothervar );

Usage

<?php
$parser       = new \HookParser\CodeParser();
$renderer     = new \HookParser\HtmlRenderer();
$fileIterator = new \HookParser\PHPFileFinder();

$output = '<ul>';
foreach ( $fileIterator->getIterator( 'path/to/plugin/src' ) as $filePath ) {
    foreach ( $parser->parse( file_get_contents( current( $filePath ) ) ) as $hook ) {
        $output .= $renderer->render( $hook );
    }
}

return $output . '</ul>';

统计信息

  • 总下载量: 26
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2020-12-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固