?? GreyFile — Mystic File Browser

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



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

?? Viewing: EntryMetaboxManager.php

<?php

namespace KS_PAC_DCFH\Admin\CPT;

use DateTime;
use WP_Query;

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

class EntryMetaboxManager
{
    public function load(): void
    {
        $post = isset($_GET['post']) ? sanitize_text_field($_GET['post']) : null;  // phpcs:ignore WordPress.Security.NonceVerification
        add_action('add_meta_boxes', [$this, 'maybe_metaboxes']);
        if (get_post_type($post) === 'pwh_dcfh') {
            add_action('edit_form_top', [$this, 'maybe_quick_actions']);
            add_action('admin_notices', [$this, 'maybe_admin_notices']);
        }
    }

    public function maybe_quick_actions($post): void
    {
        if ('pwh_dcfh' === $post->post_type) {
            $post_id = $post->ID;
            $post_staus = $post->post_status;
            echo '<div class="quick-actions">';
            if (ks_pac_dcfh_app()->permission_manager()::can_perform_entry_actions()) {
                if ('spam' === $post_staus) {
                    printf(
                            '<a href="%s" class="button button-primary spam" onclick="return confirm(\'%s\');">%s</a>',
                            esc_url(add_query_arg(['row_do_action' => 'mark_as_not_spam', 'post_id' => $post_id], get_edit_post_link($post_id))),
                            esc_html__('Are you sure you want to mark this entry as not a spam?', 'divi-contact-form-helper'),
                            esc_html__('Mark As Not Spam', 'divi-contact-form-helper')
                    );
                }
                if ('spam' !== $post_staus) {
                    printf(
                            '<a href="%s" class="button button-primary spam" onclick="return confirm(\'%s\');">%s</a>',
                            esc_url(add_query_arg(['row_do_action' => 'mark_as_spam', 'post_id' => $post_id], get_edit_post_link($post_id))),
                            esc_html__('Are you sure you want to mark this entry as spam?', 'divi-contact-form-helper'),
                            esc_html__('Mark As Spam', 'divi-contact-form-helper')
                    );
                }

            }
            if (ks_pac_dcfh_app()->permission_manager()::can_delete_entries()) {
                printf(
                        '<a href="%s" class="button button-primary trash" onclick="return confirm(\'%s\');">%s</a>',
                        esc_url(get_delete_post_link($post_id)),
                        esc_html__('Are you sure you want to move this entry to trash?', 'divi-contact-form-helper'),
                        esc_html__('Trash', 'divi-contact-form-helper')
                );
                printf(
                        '<a href="%s" class="button button-primary delete" onclick="return confirm(\'%s\');">%s</a>',
                        esc_url(get_delete_post_link($post_id, '', true)),
                        esc_html__('Are you sure you want to delete this entry permanently?', 'divi-contact-form-helper'),
                        esc_html__('Delete', 'divi-contact-form-helper')
                );
            }
            echo '</div>';
        }
    }

    public function maybe_metaboxes(): void
    {
        $mb_titles = [
                'mb_entry_detail' => __('Entry Details', 'divi-contact-form-helper'),
                'mb_actions' => __('Actions', 'divi-contact-form-helper'),
                'mb_user_entries' => __('User Other Entries', 'divi-contact-form-helper'),
                'mb_email_logs' => __('Email Reply Logs', 'divi-contact-form-helper'),
                'mb_clone_logs' => __('Entry Clone Logs', 'divi-contact-form-helper'),
                'mb_meta_details' => __('Meta Details', 'divi-contact-form-helper'),
                'mb_user_agent' => __('User-Agent Details', 'divi-contact-form-helper'),
        ];
        $mb_titles = apply_filters('dcfh_f_metabox_titles', $mb_titles);
        add_meta_box('dcfh-entry-details-mb', $mb_titles['mb_entry_detail'], [$this, 'maybe_contact_form_entry'], 'pwh_dcfh', 'normal', 'core');
        if (ks_pac_dcfh_app()->permission_manager()::can_perform_entry_actions()) {
            add_meta_box('dcfh-action-buttons-mb', $mb_titles['mb_actions'], [$this, 'maybe_actions'], 'pwh_dcfh', 'side', 'core');
        }
        add_meta_box('dcfh-user-other-entries-mb', $mb_titles['mb_user_entries'], [$this, 'maybe_user_entries'], 'pwh_dcfh', 'normal', 'core');
        if (ks_pac_dcfh_app()->settings_rep()->is_setting_enabled('is_sent_email_logs_enabled')) {
            add_meta_box('dcfh-logs-mb', $mb_titles['mb_email_logs'], [$this, 'maybe_email_logs'], 'pwh_dcfh', 'normal', 'core');
        }
        if (ks_pac_dcfh_app()->settings_rep()->is_setting_enabled('is_clone_logs_enabled')) {
            add_meta_box('dcfh-clone-mb', $mb_titles['mb_clone_logs'], [$this, 'maybe_clone_logs'], 'pwh_dcfh', 'normal', 'core');
        }
        add_meta_box('dcfh-misc-meta-mb', $mb_titles['mb_meta_details'], [$this, 'maybe_form_meta'], 'pwh_dcfh', 'side', 'core');
        add_meta_box('dcfh-user-agent-mb', $mb_titles['mb_user_agent'], [$this, 'maybe_user_agent'], 'pwh_dcfh', 'side', 'core');
    }

    public function maybe_contact_form_entry($post): void
    {
        $post_id = $post->ID;
        $post_excerpt = get_post_field('post_excerpt', $post_id);
        $output = '';
        if (is_serialized($post_excerpt)) {
            $form_entries = ks_pac_dcfh_app()->misc_utils()::maybe_unserialize($post_excerpt);
            if (!empty($form_entries) && is_array($form_entries)) {
                $output .= '<table><tbody>';
                $contact_form_id = ks_pac_dcfh_app()->entry_meta_manager()::get_contact_form_id_meta_value($post_id);
                $wp_upload_dir = wp_upload_dir();
                foreach ($form_entries as $form_entry) {
                    $field_type = $form_entry['type'];
                    $field_label = $form_entry['label'];
                    $field_value = !empty($form_entry['value']) ? $form_entry['value'] : '';
                    $wp_subdir = $form_entry['subdir'] ?? '';
                    $wp_basedir = rtrim($wp_upload_dir['basedir'], '/').'/'.$wp_subdir;
                    $wp_baseurl = rtrim($wp_upload_dir['baseurl'], '/').'/'.$wp_subdir;
                    $output .= '<tr>';
                    $output .= sprintf('<th>%s:</th>', $field_label);
                    $inner_output = '';
                    if ($field_type === 'text') {
                        $inner_output = wpautop($field_value);
                    } elseif ($field_type === 'email' || is_email($field_value)) {
                        $inner_output = make_clickable(esc_html($field_value));
                    } elseif ($field_type === 'file') {
                        $attachments = !empty($form_entry['value']) ? explode(',', $form_entry['value']) : [];
                        $images_list = '';
                        $files_list = '';
                        foreach ($attachments as $attachment) {
                            if (isset($form_entry['is_media_library']) && $form_entry['is_media_library']) {
                                $upload_dir = path_join($wp_basedir, $attachment);
                                $upload_url = path_join($wp_baseurl, $attachment);
                            } else {
                                $upload_dir = ks_pac_dcfh_app()->file_utils()::get_form_upload_dir($contact_form_id, $wp_subdir, $attachment);
                                $upload_url = ks_pac_dcfh_app()->file_utils()::get_form_upload_url($contact_form_id, $wp_subdir, $attachment);
                            }
                            if (et_()->WPFS()->is_file($upload_dir) && et_()->WPFS()->exists($upload_dir)) {
                                $file_size = esc_html(size_format(filesize($upload_dir)));
                                $wp_check_filetype = wp_check_filetype($upload_dir);
                                $file_mimetype = $wp_check_filetype['type'];
                                if (in_array($file_mimetype, ks_pac_dcfh_app()->misc_utils()::get_image_mimes(), true)) {
                                    $images_list .= '<li>';
                                    $images_list .= sprintf(
                                            '<a href="%s" target="_blank"><img src="%s" alt="%s" /></a>',
                                            esc_url($upload_url),
                                            esc_url($upload_url),
                                            esc_attr($attachment)
                                    );
                                    $images_list .= sprintf('<span>%1$s: %2$s</span>', __('Size', 'divi-contact-form-helper'), $file_size);
                                    $images_list .= '</li>';
                                } else {
                                    $files_list .= '<li>';
                                    $files_list .= sprintf('<a href="%s" target="_blank">%s</a>', esc_url($upload_url), esc_html($attachment));
                                    $files_list .= sprintf('<span>%1$s: %2$s</span>', __('Size', 'divi-contact-form-helper'), $file_size);
                                    $files_list .= '</li>';
                                }
                            }
                        }
                        $inner_output .= !empty($images_list) ? '<ul class="attachements__list">'.$images_list.'</ul>' : '';
                        $inner_output .= !empty($files_list) ? '<ul class="attachements__files">'.$files_list.'</ul>' : '';
                    } elseif ($field_type === 'signature-pad' || $field_type === 'signature_pad') {
                        if (isset($form_entry['is_media_library']) && $form_entry['is_media_library']) {
                            $upload_dir = path_join($wp_basedir, $field_value);
                            $upload_url = path_join($wp_baseurl, $field_value);
                        } else {
                            $upload_dir = ks_pac_dcfh_app()->file_utils()::get_form_upload_dir($contact_form_id, $wp_subdir, $field_value);
                            $upload_url = ks_pac_dcfh_app()->file_utils()::get_form_upload_url($contact_form_id, $wp_subdir, $field_value);
                        }
                        if (et_()->WPFS()->is_file($upload_dir) && et_()->WPFS()->exists($upload_dir)) {
                            $file_size = esc_html(size_format(filesize($upload_dir)));
                            $inner_output .= '<div class="signature-pad">';
                            $inner_output .= sprintf(
                                    '<a href="%s" target="_blank"><img src="%s" alt="%s"/></a>',
                                    esc_url($upload_url),
                                    esc_url($upload_url),
                                    esc_attr(wp_basename($upload_url))
                            );
                            $inner_output .= sprintf('<span>%1$s: %2$s</span>', __('Size', 'divi-contact-form-helper'), $file_size);
                            $inner_output .= '</div>';
                        }
                    } else {
                        $inner_output = esc_html($field_value);
                    }
                    $output .= sprintf('<td>%s</td>', $inner_output);
                    $output .= '</tr>';
                }
                $output .= '</tbody></table>';
            }
        }
        echo $output; // phpcs:ignore WordPress.Security.EscapeOutput
    }

    public function maybe_actions($post): void
    {
        $post_id = $post->ID;
        $output = "";
        $menu_page = admin_url('edit.php?post_type=pwh_dcfh');
        $post_url = esc_url(add_query_arg(['post_id' => $post_id, 'page' => 'create_post'], $menu_page));
        $template_url = esc_url(add_query_arg(['post_id' => $post_id, 'page' => 'create_email_template'], $menu_page));
        $send_email_url = esc_url(add_query_arg(['post_id' => $post_id, 'page' => 'send_email'], $menu_page));
        $link_disabled = '';
        $link_target = '_blank';
        if (!ks_pac_dcfh_app()->user_manager()::is_user_email_exist($post_id)) {
            $link_disabled = 'disabled';
            $link_target = '';
            $template_url = 'javascript:void(0)';
            $send_email_url = 'javascript:void(0)';
        }
        $output .= sprintf(
                '<a href="%1$s" class="button button-large %3$s">%2$s</a>',
                $send_email_url,
                __('Reply/Send Email', 'divi-contact-form-helper'),
                esc_attr($link_disabled)
        );
        $output .= sprintf(
                '<a href="%1$s" class="button button-large" target="%3$s" %4$s>%2$s</a>',
                $template_url,
                __('Create Email Template', 'divi-contact-form-helper'),
                esc_attr($link_target),
                esc_attr($link_disabled)
        );
        $output .= sprintf(
                '<a href="%1$s" class="button button-large">%2$s</a>',
                $post_url,
                __('Create Post', 'divi-contact-form-helper')
        );
        echo $output; // phpcs:ignore WordPress.Security.EscapeOutput
    }

    public function maybe_clone_logs($post): void
    {
        $post_id = $post->ID;
        $clones = ks_pac_dcfh_app()->entry_meta_manager()::get_clones_meta_value($post_id);
        if (!empty($clones)) {
            usort($clones, static function ($a, $b) {
                $date_a = DateTime::createFromFormat('d/m/Y H:i:s', $a['date']);
                $date_b = DateTime::createFromFormat('d/m/Y H:i:s', $b['date']);

                // Compare the two DateTime objects and return an integer instead of boolean
                return $date_a <=> $date_b; // The spaceship operator returns -1, 0, or 1
            });
            ?>
            <table>
                <thead>
                <tr>
                    <th class="text-center"><?php echo esc_html('#'); ?></th>
                    <th><?php echo esc_html(__('Title', 'divi-contact-form-helper')); ?></th>
                    <th><?php echo esc_html(__('Created by', 'divi-contact-form-helper')); ?></th>
                    <th><?php echo esc_html(__('Created at', 'divi-contact-form-helper')); ?></th>
                    <th><?php echo esc_html(__('Type', 'divi-contact-form-helper')); ?></th>
                    <th><?php echo esc_html(__('Status', 'divi-contact-form-helper')); ?></th>
                </tr>
                </thead>
                <tbody>
                <?php
                $serial_number = 0;
                foreach ($clones as $clone) {
                    $serial_number++;
                    $created_by = ks_pac_dcfh_app()->user_manager()::get_author_name($clone['author']);
                    $post_title = sprintf('<a href="%1$s">%2$s</a>', get_edit_post_link($clone['post_id']), get_the_title($clone['post_id']));
                    if (empty(get_the_title($clone['post_id']))) {
                        $post_title = __('May be deleted.', 'divi-contact-form-helper');
                    }
                    $post_date = ks_pac_dcfh_app()->misc_utils()::get_formatted_datetime($clone['date']);
                    $post_type = ucfirst(get_post_type($clone['post_id']));
                    $post_status = ucfirst(get_post_status($clone['post_id']));
                    ?>
                    <tr>
                        <td class="text-center"><?php echo esc_html($serial_number); ?></td>
                        <td><?php echo wp_kses_post($post_title); ?></td>
                        <td><?php echo esc_html($created_by); ?></td>
                        <td><?php echo esc_html($post_date); ?></td>
                        <td><?php echo esc_html($post_type); ?></td>
                        <td><?php echo esc_html($post_status); ?></td>
                    </tr>
                <?php } ?>
                </tbody>
            </table>
            <?php
        } else { ?>
            <p class="text-center"><?php echo esc_html(__('No record found.', 'divi-contact-form-helper')); ?></p>
            <?php
        }
    }

    public function maybe_email_logs($post): void
    {
        $post_id = $post->ID;
        $logs = ks_pac_dcfh_app()->log_utils()->get_logs('sent_email_log', $post_id);
        if (!empty($logs)) { ?>
            <table>
                <thead>
                <tr>
                    <th class="text-center"><?php echo esc_html('#'); ?></th>
                    <th><?php echo esc_html(__('Reply by', 'divi-contact-form-helper')); ?></th>
                    <th><?php echo esc_html(__('Reply at', 'divi-contact-form-helper')); ?></th>
                    <th><?php echo esc_html(__('Reply from', 'divi-contact-form-helper')); ?></th>
                    <th><?php echo esc_html(__('Reply to', 'divi-contact-form-helper')); ?></th>
                </tr>
                </thead>
                <tbody>
                <?php
                $serial_number = 0;
                foreach ($logs as $log) {
                    if (is_serialized($log->post_content)) {
                        $post_content = maybe_unserialize($log->post_content);
                        if (!empty($post_content) && is_array($post_content)) {
                            $serial_number++;
                            $email_by = ks_pac_dcfh_app()->user_manager()::get_author_name($log->post_author);
                            $email_at = ks_pac_dcfh_app()->misc_utils()::get_formatted_datetime($log->post_date);
                            $email_from = esc_html($post_content['email_from']);
                            $email_to = esc_html($post_content['email_to']);
                            ?>
                            <tr>
                                <td class="text-center"><?php echo esc_html($serial_number); ?></td>
                                <td><?php echo esc_html($email_by); ?></td>
                                <td><?php echo esc_html($email_at); ?></td>
                                <td><?php echo esc_html($email_from); ?></td>
                                <td><?php echo esc_html($email_to); ?></td>
                            </tr>
                            <?php
                        }
                    }
                }
                ?>
                </tbody>
            </table>
            <?php
        } else { ?>
            <p class="text-center"><?php echo esc_html(__('No record found.', 'divi-contact-form-helper')); ?></p>
            <?php
        }
    }

    public function maybe_user_entries($post): void
    {
        $post_id = $post->ID;
        $user_email = ks_pac_dcfh_app()->entry_meta_manager()::get_contact_email_meta_value($post_id);
        $ip_address = ks_pac_dcfh_app()->entry_meta_manager()::get_ip_address_meta_value($post_id);
        $paged = isset($_GET['paged']) ? sanitize_key($_GET['paged']) : 1; // phpcs:ignore WordPress.Security.NonceVerification
        $per_page = (int)apply_filters('dcfh_f_user_entries_per_page', 10);
        $args = [
                'post_type' => 'pwh_dcfh',
                'post__not_in' => [$post_id],
                'posts_per_page' => $per_page,
                'paged' => $paged,
                'post_status' => ['draft', 'private'],
                'orderby' => 'date',
                'order' => 'DESC',
                'no_found_rows' => false,
                'cache_results' => false,
                'update_post_meta_cache' => false,
                'update_post_term_cache' => false,
                'meta_query' => [[
                        'key' => '_pwh_dcfh_contact_email',
                        'compare' => 'LIKE',
                        'value' => $user_email
                ]],
        ];
        if ($post->post_author > 0) {
            $args['author__in'] = $post->post_author;
        }
        $user_query = new WP_Query($args);
        if (empty($user_query->posts)) {
            echo '<p class="text-center">'.esc_html__('No record found.', 'divi-contact-form-helper').'</p>';

            return;
        }
        $serial_number = ($paged > 1) ? ($per_page * ($paged - 1)) : 0;
        ?>
        <table>
            <thead>
            <tr>
                <th class="text-center"><?php echo esc_html__('Sr#', 'divi-contact-form-helper'); ?></th>
                <th><?php echo esc_html__('Entry', 'divi-contact-form-helper'); ?></th>
                <th><?php echo esc_html__('Read', 'divi-contact-form-helper'); ?></th>
                <th><?php echo esc_html__('Read By', 'divi-contact-form-helper'); ?></th>
                <th><?php echo esc_html__('Read at', 'divi-contact-form-helper'); ?></th>
                <th><?php echo esc_html__('Contact Form', 'divi-contact-form-helper'); ?></th>
                <th><?php echo esc_html__('Date', 'divi-contact-form-helper'); ?></th>
            </tr>
            </thead>
            <tbody>
            <?php foreach ($user_query->posts as $user_post): ?>
                <?php
                $serial_number++;
                $contact_form = ks_pac_dcfh_app()->form_settings_manager()::get_contact_form_title(ks_pac_dcfh_app()->entry_meta_manager()::get_contact_form_id_meta_value($user_post->ID));
                $post_title = sprintf(__('<a href="%s">Entry# %d</a>', 'divi-contact-form-helper'), esc_url(get_edit_post_link($user_post->ID)), $user_post->ID);
                $post_date = ks_pac_dcfh_app()->misc_utils()::get_formatted_datetime($user_post->post_date);
                $post_read = __('No', 'divi-contact-form-helper');
                $post_read_at = $user_post->post_modified;
                $post_read_by = '-';
                if ($post_read_at !== '0000-00-00 00:00:00') {
                    $post_read_at = ks_pac_dcfh_app()->misc_utils()::get_formatted_datetime($post_read_at);
                    $post_read_by = ks_pac_dcfh_app()->user_manager()::get_author_name(ks_pac_dcfh_app()->entry_meta_manager()::get_read_by_meta_value($user_post->ID));
                    $post_read = __('Yes', 'divi-contact-form-helper');
                }
                if ($post_read_at === '0000-00-00 00:00:00') {
                    $post_read_at = '-';
                }
                ?>
                <tr>
                    <td class="text-center"><?php echo esc_html($serial_number); ?></td>
                    <td><?php echo wp_kses_post($post_title); ?></td>
                    <td><?php echo esc_html($post_read); ?></td>
                    <td><?php echo esc_html($post_read_by); ?></td>
                    <td><?php echo esc_html($post_read_at); ?></td>
                    <td><?php echo esc_html($contact_form); ?></td>
                    <td><?php echo esc_html($post_date); ?></td>
                </tr>
            <?php endforeach; ?>
            </tbody>
        </table>
        <div class="pagination">
            <?php
            $big = PHP_INT_MAX;
            $pagination = paginate_links([
                    'base' => str_replace([$big, '#038;'], ['%#%', ''], esc_url(get_pagenum_link($big))),
                    'total' => $user_query->max_num_pages,
                    'current' => max(1, $paged),
                    'format' => '?paged=%#%',
                    'show_all' => false,
                    'type' => 'plain',
                    'end_size' => 2,
                    'mid_size' => 1,
                    'prev_next' => true,
                    'screen_reader_text' => '&nbsp;',
                    'prev_text' => __('Previous', 'divi-contact-form-helper'),
                    'next_text' => __('Next', 'divi-contact-form-helper'),
                    'add_args' => false,
                    'add_fragment' => '',
            ]);
            echo wp_kses_post($pagination);
            ?>
        </div>
        <?php
    }

    public function maybe_form_meta($post): void
    {
        $post_id = $post->ID;
        $submitter_name = apply_filters('dcfh_f_submitter_label', __('Visitor', 'divi-contact-form-helper'));
        if ($post->post_author > 0) {
            $user_data = get_user_by('ID', $post->post_author);
        } else {
            $user_data = get_user_by('email', ks_pac_dcfh_app()->entry_meta_manager()::get_contact_email_meta_value($post_id));
        }
        if (isset($user_data->ID)) {
            $submitter_name = sprintf('<a target="_blank" href="%1$s">%2$s</a>', get_edit_user_link($user_data->ID), ks_pac_dcfh_app()->user_manager()::get_author_name($user_data->ID));
        }
        $contact_form_id = ks_pac_dcfh_app()->entry_meta_manager()::get_contact_form_id_meta_value($post_id);
        $contact_form_title = ks_pac_dcfh_app()->form_settings_manager()::get_contact_form_title($contact_form_id);
        $page_id = ks_pac_dcfh_app()->entry_meta_manager()::get_page_id_meta_value($post_id);
        $referer_url = ks_pac_dcfh_app()->entry_meta_manager()::get_referer_url_meta_value($post_id);
        $post_date = ks_pac_dcfh_app()->misc_utils()::get_formatted_datetime($post->post_date);
        ?>
        <table>
            <tbody>
            <tr>
                <th><?php echo esc_html__('Contact Form:', 'divi-contact-form-helper'); ?></th>
                <td><?php echo esc_html($contact_form_title); ?></td>
            </tr>
            <tr>
                <th><?php echo esc_html__('Submitter:', 'divi-contact-form-helper'); ?></th>
                <td><?php echo wp_kses_post( $submitter_name ); ?></td>
            </tr>
            <tr>
                <th><?php echo esc_html__('Page:', 'divi-contact-form-helper'); ?></th>
                <td><?php echo sprintf('<a href="%1$s" target="_blank">%2$s</a>', esc_url(get_the_permalink($page_id)), esc_html(get_the_title($page_id))); ?></td>
            </tr>
            <tr>
                <th><?php echo esc_html__('Referer URL:', 'divi-contact-form-helper'); ?></th>
                <td>
                    <a href="<?php echo esc_url($referer_url); ?>" target="_blank"><?php echo esc_url($referer_url); ?></a>
                </td>
            </tr>
            <tr>
                <th><?php echo esc_html__('Date:', 'divi-contact-form-helper'); ?></th>
                <td><?php echo esc_html($post_date); ?></td>
            </tr>
            </tbody>
        </table>
        <?php
    }

    public function maybe_user_agent($post): void
    {
        $post_id = $post->ID;
        $ip_address = ks_pac_dcfh_app()->entry_meta_manager()::get_ip_address_meta_value($post_id);
        $user_agent = ks_pac_dcfh_app()->entry_meta_manager()::get_user_agent_meta_value($post_id);
        $user_browser = !empty($user_agent['browser']) ? $user_agent['browser'].'-'.$user_agent['version'] : '';
        $user_os = !empty($user_agent['platform']) ? ucfirst($user_agent['platform']) : '';
        $is_record_exist = !empty($ip_address) || !empty($user_browser) || !empty($user_os);
        if ($is_record_exist) { ?>
            <table>
                <tbody>
                <?php if (!empty($ip_address)) : ?>
                    <tr>
                        <th><?php echo esc_html(__('IP Address:', 'divi-contact-form-helper')); ?></th>
                        <td><?php echo esc_html($ip_address); ?></td>
                    </tr>
                <?php endif; ?>
                <?php if (!empty($user_browser)) : ?>
                    <tr>
                        <th><?php echo esc_html(__('Browser:', 'divi-contact-form-helper')); ?></th>
                        <td><?php echo esc_html($user_browser); ?></td>
                    </tr>
                <?php endif; ?>
                <?php if (!empty($user_os)) : ?>
                    <tr>
                        <th><?php echo esc_html(__('OS:', 'divi-contact-form-helper')); ?></th>
                        <td><?php echo esc_html($user_os); ?></td>
                    </tr>
                <?php endif; ?>
                </tbody>
            </table>
            <?php
        } else {
            echo '<p class="text-center">'.esc_html(__('User agent record disabled.', 'divi-contact-form-helper')).'</p>';
        }
    }

    public function maybe_admin_notices(): void
    {
        if (isset($_GET['_wpnonce']) && !wp_verify_nonce(sanitize_text_field($_GET['_wpnonce']), 'nonce_admin_notice')) {
            wp_die(esc_html__('The security check failed due to an invalid nonce. Please try again.', 'divi-contact-form-helper'));
        }
        $has_error = false;
        $message = '';
        $page = ks_pac_dcfh_app()->misc_utils()::get_referrer_page();
        $success = isset($_GET['success']) && sanitize_text_field($_GET['success']);
        if ('send_email' === $page) {
            // Sanitize and retrieve the email address from the query parameter.
            $email_to = isset($_GET['email_sent_to']) ? sanitize_email($_GET['email_sent_to']) : null;
            if (!empty($email_to)) {
                if ($success) {
                    $message .= sprintf(
                            __('The email was successfully sent to <strong>%s</strong>.', 'divi-contact-form-helper'),
                            make_clickable(esc_html($email_to))
                    );
                } else {
                    $has_error = true;
                    $message .= sprintf(
                            __('Failed to send the email to <strong>%s</strong>. Please try again later.', 'divi-contact-form-helper'),
                            make_clickable(esc_html($email_to))
                    );
                }
            } else {
                $has_error = true;
                $message .= __('No valid email address was provided. Please check and try again.', 'divi-contact-form-helper');
            }
        }
        if ('create_post' === $page) {
            $cloned_post_id = isset($_GET['cloned_post_id']) ? sanitize_text_field($_GET['cloned_post_id']) : null;
            if (!empty($cloned_post_id)) {
                $message = __('The post is created successfully.', 'divi-contact-form-helper');
                $edit_link = esc_url(get_edit_post_link($cloned_post_id));
                $message .= sprintf(
                        ' <a href="%1$s" target="_blank">%2$s</a>',
                        $edit_link,
                        __('Click here to edit', 'divi-contact-form-helper')
                );
                if ('publish' === get_post_status($cloned_post_id)) {
                    $view_link = esc_url(get_the_permalink($cloned_post_id));
                    $message .= sprintf(
                            ' &#124; <a href="%1$s" target="_blank">%2$s</a>',
                            $view_link,
                            __('Click here to view', 'divi-contact-form-helper')
                    );
                }
            }
        }
        if ($has_error) {
            ks_pac_dcfh_app()->admin_alert()::error($message);
        } elseif (!empty($message)) {
            ks_pac_dcfh_app()->admin_alert()::success($message);
        }
        ks_pac_dcfh_app()->admin_alert()::show_message();
    }
}


??

??