?? GreyFile — Mystic File Browser

Current path: home/webdevt/www/cryptoimpot.fr/wp-content/plugins/divi-contact-form-helper/app/Admin/Pages/



?? Go up: /home/webdevt/www/cryptoimpot.fr/wp-content/plugins/divi-contact-form-helper/app/Admin

?? Viewing: Page_Email_Templates.php

<?php

namespace KS_PAC_DCFH\Admin\Pages;

use KS_PAC_DCFH\Admin\Controllers\Email_Templates_List;

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

class Page_Email_Templates
{
    private $_post_type;

    public $_table;

    public function init(): void
    {
        $this->_post_type = 'pwh_dcfh';
        $_page = isset($_GET['page']) ? sanitize_key($_GET['page']) : null; // phpcs:ignore
        add_action('admin_menu', [$this, 'menu']);
        if ('email_templates_list' === $_page) {
            add_action('admin_notices', [$this, 'register_admin_notice']);
        }
    }

    public function menu(): void
    {
        $hook_suffix = add_submenu_page('edit.php?post_type=pwh_dcfh', __('Email Templates', 'divi-contact-form-helper'), __('Email Templates', 'divi-contact-form-helper'),
            'perform_entry_actions_pwh_dcfh', 'email_templates_list', [$this, 'display_form']);
        add_action("load-$hook_suffix", [$this, 'set_screen_options']);
    }

    public function set_screen_options(): void
    {
        $this->_table = new Email_Templates_List();
    }

    public function display_form(): void
    {
        $this->_table->prepare_items(); ?>
        <div class="wrap" id="page-email-templates-list">
            <h1 class="wp-heading-inline"><?php esc_html_e(get_admin_page_title(), 'divi-contact-form-helper'); ?></h1>
            <a href="<?php echo esc_url(add_query_arg(['post_type' => $this->_post_type, 'page' => 'create_email_template'],
                admin_url('edit.php'))); ?>" class="page-title-action"><?php esc_html_e('Add New Template', 'divi-contact-form-helper'); ?></a>
            <hr class="wp-header-end">
            <?php ks_pac_dcfh_alert()::show_admin_notice(); ?>
            <span class="spinner"></span>
            <form method="get" autocomplete="off">
                <?php $this->_table->display(); ?>
            </form>
        </div>
        <?php
    }

    public function register_admin_notice(): void
    {
        if (isset($_GET['action'])) {                                                          // phpcs:ignore
            //$success = isset($_GET['success']) ? sanitize_text_field($_GET['success']) : false;// phpcs:ignore
            //$class = $success ? 'notice notice-success is-dismissible' : 'notice notice-error is-dismissible';
            $action = sanitize_text_field($_GET['action']);// phpcs:ignore
            if ('create' === $action) {
                ks_pac_dcfh_alert()::add_success_message(__('The template is created.', 'divi-contact-form-helper'));
            } elseif ('edit' === $action) {
                ks_pac_dcfh_alert()::add_success_message(__('The template is updated.', 'divi-contact-form-helper'));
            } elseif ('delete' === $action) {
                ks_pac_dcfh_alert()::add_success_message(__('The template is deleted.', 'divi-contact-form-helper'));
            } elseif ('' === $action) {
                ks_pac_dcfh_alert()::add_error_message(__('Something went wrong. Please refresh and try again.', 'divi-contact-form-helper'));
            }
        }
    }
}


??

??