10quality/wpmvc-addon-status

System status report pages for WordPress MVC framework.

v1.0.3 2023-02-10 23:02 UTC

This package is auto-updated.

Last update: 2024-04-11 01:32:01 UTC


README

Latest Stable Version GitHub Workflow Status Total Downloads License

Add-on for WordPress MVC.

The add-on will add a "System Status" option inside WordPress admin dashboard, allowing for administrator to see the system status and log files.

Features:

  • System status (WP, PHP and DB versions).
  • Easy JSON export.
  • WordPress MVC log file viewer.
  • Flush WordPress MVC cache.

Install and Configuration

To install, use the following composer command:

composer require 10quality/wpmvc-addon-status

To configure the add-on, simply add it to your projects add-ons list at [project]/app/Config/app.php:

    'addons' => [
        'WPMVC\Addons\Status\StatusAddon',
    ],

Hooks

You can add custom status information and sections.

wpmvc_addon_status_sections

Filter wpmvc_addon_status_sections allows to add new sections to the system status report, example:

add_filter( 'wpmvc_addon_status_sections', function( $sections ) {
    $sections['my-plugin'] = __( 'My Plugin', 'my-domain' );
    return $sections;
} );

wpmvc_addon_status_data

Filter wpmvc_addon_status_data allows to add new date to the system status report, data can be added as:

  • Array
  • Class instance of StatusData.

Using array

Example:

add_filter( 'wpmvc_addon_status_data', function( $data ) {
    $data[] = [
        'section' => 'my-plugin',
        'title' => __( 'API Connection', 'my-domain' );
        'message' => __( 'Yes', 'my-domain' );
        'status' => 1,
    ];
    return $data;
} );
Status Description
0 Normal status. Displays with black text.
1 Success status. Displays with green text.
2 Important status. Displays with blue text.
3 Danger status. Displays with red text.

Class instance

Example:

namespace MyNamespace\SystemStatus;

use WPMVC\Addons\Status\Abstracts\StatusData;
/**
 * Custom system status data.
 */
class ConnectionData extends StatusData
{
    /**
     * Checks connection.
     * This method is always called by the addon to init data.
     */
    public function check()
    {
        // Do custom code
        $has_connection = true;

        $this->section = 'my-plugin';
        $this->title = __( 'API Connection', 'my-domain' );
        $this->message = $has_connection ? 'Yes' : 'No';
        $this->status = $has_connection ? 1 : 3;
    }
}

Then add class to filter:

add_filter( 'wpmvc_addon_status_data', function( $data ) {
    $data[] = new ConnectionData();
    return $data;
} );

Data status

Status Description
0 Normal status. Displays with black text.
1 Success status. Displays with green text.
2 Important status. Displays with blue text.
3 Danger status. Displays with red text.

Coding Guidelines

PSR-2 coding guidelines.

License

MIT License. (c) 2020 10 Quality.