?? GreyFile — Mystic File Browser

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



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

?? Viewing: FormStats.php

<?php

namespace KS_PAC_DCFH\Admin\Controllers;

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

class FormStats
{
    public function load(): void
    {
        global $pagenow;
        if ('index.php' === $pagenow && ks_pac_dcfh_app()->settings_rep()->is_setting_enabled('is_contact_form_stats_enabled')) {
            add_action('wp_dashboard_setup', [$this, 'load_widget']);
        }
    }

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

    public function render_widget_html(): void
    { ?>
        <table>
            <thead>
            <tr>
                <th class="text-center"><?php esc_html_e('Yesterday', 'divi-contact-form-helper'); ?></th>
                <th class="text-center"><?php esc_html_e('Today', 'divi-contact-form-helper'); ?></th>
                <th class="text-center"><?php esc_html_e('Last Week', 'divi-contact-form-helper'); ?></th>
                <th class="text-center"><?php esc_html_e('Last Month', 'divi-contact-form-helper'); ?></th>
            </tr>
            </thead>
            <tbody>
            <?php
            $dashboard_stats = ks_pac_dcfh_app()->general_db_manager()::get_dashboard_stats();
            if (!empty($dashboard_stats)) {
                foreach ($dashboard_stats as $contact_form_id => $dashboard_stat) {
                    $yesterday = isset($dashboard_stat['yesterday']) ? esc_html($dashboard_stat['yesterday']) : 0;
                    $today = isset($dashboard_stat['today']) ? esc_html($dashboard_stat['today']) : 0;
                    $last_week = isset($dashboard_stat['last_week']) ? esc_html($dashboard_stat['last_week']) : 0;
                    $last_month = isset($dashboard_stat['last_month']) ? esc_html($dashboard_stat['last_month']) : 0;
                    $total = $yesterday + $today + $last_week + $last_month;
                    ?>
                    <tr>
                        <td colspan="4" class="text-center font-weight-600">
                            <a href="<?php echo esc_url(add_query_arg([
                                'post_type' => 'pwh_dcfh',
                                'contact_form_id' => $contact_form_id
                            ], admin_url('edit.php'))); ?>"><?php echo esc_html(ks_pac_dcfh_app()->form_settings_manager()::get_contact_form_title($contact_form_id)); ?></a>
                        </td>
                    </tr>
                    <tr>
                        <td class="text-center"><?php echo esc_html(number_format_i18n($yesterday)); ?></td>
                        <td class="text-center"><?php echo esc_html(number_format_i18n($today)); ?></td>
                        <td class="text-center"><?php echo esc_html(number_format_i18n($last_week)); ?></td>
                        <td class="text-center"><?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
    }
}


??

??