alleyinteractive/wp-filter-side-effects
Composer 安装命令:
composer require alleyinteractive/wp-filter-side-effects
包简介
Use a WordPress filter like an action.
README 文档
README
add_filter_side_effect() allows attaching a callback function to a WordPress filter without requiring that the callback function return the filtered value or even return any value. It wraps add_filter() and accepts the same arguments with the same defaults.
The callback function can return void or return a value. If the callback function returns a value, that value will be ignored, not passed back to the filter. Filter side effects thus behave like add_action() callbacks and can be used in situations where a call to apply_filters() signals that some behavior needs to occur, but no convenient action exists to run it.
Installation
Install the latest version with:
$ composer require alleyinteractive/wp-filter-side-effects
Basic usage
<?php use function Alley\WP\add_filter_side_effect; add_filter_side_effect( 'rest_pre_insert_post', function ( $prepared_post, $request ): void { // Do something before the post is saved, like... $language_slug = $request['lang']; $default_category = $this->get_custom_default_language_category( $language_slug ); if ( $default_category ) { add_filter( 'pre_option_default_category', fn() => $default_category ); } }, 10, 2, );
About
License
Maintainers
alleyinteractive/wp-filter-side-effects 适用场景与选型建议
alleyinteractive/wp-filter-side-effects 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 526.29k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2022 年 06 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 alleyinteractive/wp-filter-side-effects 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 alleyinteractive/wp-filter-side-effects 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 526.29k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 35
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2022-06-03