agencenous/wp-reporting 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

agencenous/wp-reporting

最新稳定版本:1.8.1

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);

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固