?? GreyFile — Mystic File Browser

Current path: home/webdevt/www/demo2/wp-content/plugins/divi-contact-form-helper/d4/app/Admin/Controllers/



?? Go up: /home/webdevt/www/demo2/wp-content/plugins/divi-contact-form-helper/d4/app/Admin

?? Viewing: Dashboard_Stats.php

<?php

namespace KS_PAC_DCFH\Admin\Controllers;

if (!defined('ABSPATH')) {
    exit;
}

class Dashboard_Stats
{
    public function init(): void
    {
        global $pagenow;
        if ('index.php' === $pagenow && ks_pac_dcfh_db()::is_setting_enabled('pwh_dcfh_stats_enabled')) {
            add_action('wp_dashboard_setup', [$this, 'add_dashboard_widget']);
        }
    }

    public function add_dashboard_widget(): void
    {
        wp_add_dashboard_widget('pwh-dcfh-contact-form-stats', __('Divi Contact Form Statistics', 'divi-contact-form-helper'), [$this, 'display']);
    }

    public function display(): void
    { ?>
        <table>
            <thead>
            <tr>
                <th><?php esc_html_e('Yesterday', 'divi-contact-form-helper'); ?></th>
                <th><?php esc_html_e('Today', 'divi-contact-form-helper'); ?></th>
                <th><?php esc_html_e('Last Week', 'divi-contact-form-helper'); ?></th>
                <th><?php esc_html_e('Last Month', 'divi-contact-form-helper'); ?></th>
            </tr>
            </thead>
            <tbody>
            <?php
            $stats = ks_pac_dcfh_post_meta()::get_contact_forms_dashboard_stats();
            if (!empty($stats)) {
                foreach ($stats as $key => $stat) {
                    $yesterday = isset($stat['yesterday']) ? esc_html($stat['yesterday']) : 0;
                    $today = isset($stat['today']) ? esc_html($stat['today']) : 0;
                    $last_week = isset($stat['last_week']) ? esc_html($stat['last_week']) : 0;
                    $last_month = isset($stat['last_month']) ? esc_html($stat['last_month']) : 0;
                    $total = esc_html($yesterday + $today + $last_week + $last_month);
                    ?>
                    <tr>
                        <td colspan="4" class="text-left font-weight-600"><?php echo esc_html($key); ?></td>
                    </tr>
                    <tr>
                        <td><?php echo esc_html(number_format_i18n($yesterday)); ?></td>
                        <td><?php echo esc_html(number_format_i18n($today)); ?></td>
                        <td><?php echo esc_html(number_format_i18n($last_week)); ?></td>
                        <td><?php echo esc_html(number_format_i18n($last_month)); ?></td>
                    </tr>
                    <tr>
                        <td colspan="4" class="text-right font-weight-600 font-italic">
                            <?php echo sprintf('Total Entries: %s', esc_html(number_format_i18n($total))); ?></td>
                    </tr>
                    <?php
                }
            } else { ?>
                <tr>
                    <td colspan="4" class="text-center"><?php esc_html_e('No entries found.', 'divi-contact-form-helper'); ?></td>
                </tr>
            <?php } ?>
            </tbody>
        </table>
        <?php
    }
}


??

??