PHP code example of 10quality / wpmvc-addon-status

1. Go to this page and download the library: Download 10quality/wpmvc-addon-status library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

10quality / wpmvc-addon-status example snippets


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

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

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

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

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