agencenous/wp-reporting
Composer 安装命令:
composer require agencenous/wp-reporting
包简介
Utility for sending log reports in Wordpress themes & plugins
README 文档
README
Utility for sending log reports in Wordpress themes & plugins
Include it in your own plugin or theme:
composer require agencenous/wp-reporting
Usage
Report PHP errors
<?php add_action ('plugins_loaded', function(){ require 'vendor/autoload.php'; // Register each project \WPReporting()->register('project-name', [ 'label' => 'Project name', // translate it with __('Project name', 'project-textdomain') 'description' => 'Send logs by emails', // translate it with __('Description', 'project-textdomain') 'category' => 'plugin', // plugin, theme, main 'to' => 'bm91c0BhdmVjbm91cy5ldQ==', // email addresse, plain or BASE64 encoded (to prevent spam when source is open) 'only_in_dir' => __DIR__, // Limit error reporting to this directory for this project 'javascript' => true, // Enable javascript error reporting ]); }); // Add it in any function or class try{ // Your code goes here } catch(\Throwable $e){ // For PHP 7 \WPReporting()->send($e, 'project-name'); } catch(\Exception $e){ // For PHP 5 \WPReporting()->send($e, 'project-name'); } ?>
If you need to catch warnings or notices
<?php // Add it in any function or class \WPReporting()->listen('project-name', E_WARNING); // Your code goes here \WPReporting()->stop(); ?>
Report Javascript errors
<script type="text/javascript"> try{ // Your code goes here } catch(err){ wp_reporting.log_error('project-name', err); } </script>
In a normal context, you can use the wp_reporting global variable.
In case of the script is not loaded automatically, you can use the wp_reporting function.
\WPReporting()->load_scripts();
Privacy
Email addresses can be base64 encoded. So you do not expose theme directly in source-code.
Emails are sent using the wp_mail() function.
Calling WPReporting() will automatically add a setting page in the Wordpress dashboard to let admin enable/disable error reporting for each registered project.
Reports will only be sent if the admin has enabled it.
after installing wp-reporting, you can use the bin command to encode an email address:
vendor/bin/wp-reporting-encode-email xxxxx@xx.xx
Moreover
Enable settings on network in a multisite context.
Just add this line in your wp-config.php file.
defined('WP_REPORTING_NETWORK', true);
agencenous/wp-reporting 适用场景与选型建议
agencenous/wp-reporting 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.65k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 04 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 agencenous/wp-reporting 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 agencenous/wp-reporting 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2.65k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2023-04-25