?? GreyFile — Mystic File Browser

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



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

?? Viewing: DashboardScripts.php

<?php

namespace KS_PAC_DCFH\Admin\Dashboard;

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

class DashboardScripts
{
    private string $plugin_url;

    private string $plugin_version;

    public function load(): void
    {
        $this->plugin_url = KS_PAC_DCFH_PLUGIN_URL;
        $this->plugin_version = KS_PAC_DCFH_PLUGIN_VERSION;
        add_action('admin_enqueue_scripts', [$this, 'maybe_enqueue_scripts']);
    }

    public function maybe_enqueue_scripts($hook): void
    {
        if ('pee-aye-creative_page_divi-contact-form-helper' !== $hook) {
            return;
        }
        $this->render_css();
        $this->render_js();

    }

    private function render_css()
    {
        $custom_css_array = [
            '.pac-divi-contact-form-helper-loader' => [
                'position' => 'relative',
                'width' => '100%',
                'height' => '100%',
                'background' => 'var(--pac-upui-white)',
                'border-radius' => '8px',
            ],
            '#ks-pac-dcfh-app-inner > .pac-divi-contact-form-helper-loader' => [
                'height' => 'calc(100vh - 92px)',
                'width' => 'calc(100% - 40px)',
                'margin' => '30px 30px 30px 10px',
            ],
            '.pee-aye-creative_page_divi-contact-form-helper #wpbody-content > div:not(#ks-pac-dcfh-app, .pac-misc-message)' => [
                'display' => 'none',
            ],
            '.pee-aye-creative_page_divi-contact-form-helper #wpfooter' => [
                'display' => 'none',
            ],
            '.pee-aye-creative_page_divi-contact-form-helper #wpbody-content' => [
                'padding-bottom' => '0 !important',
            ],
        ];
        $custom_css = '';
        foreach ($custom_css_array as $selector => $properties) {
            $custom_css .= $selector." {\n";
            foreach ($properties as $prop => $val) {
                $custom_css .= "    {$prop}: {$val};\n";
            }
            $custom_css .= "}\n\n";
        }
        wp_add_inline_style('wp-admin', $custom_css);
    }

    private function render_js()
    {
        wp_enqueue_script(
            'divi-contact-form-helper-dashboard',
            $this->plugin_url."/dashboard/build/bundle.js",
            ['jquery', 'wp-element', 'wp-i18n'],
            $this->plugin_version.'.'.uniqid(),
            true
        );
        $current_user_data = ks_pac_dcfh_get_current_user_data();
        $current_plugin_data = ks_pac_dcfh_get_plugin_data();
        $roles = get_editable_roles();
        $role_slugs = array_keys($roles);
        $filtered_roles = array_diff($role_slugs, ['administrator', 'subscriber']);
        wp_localize_script(
            'divi-contact-form-helper-dashboard',
            'DiviContactFormHelperDashboardData',
            [
                'restURL' => untrailingslashit(rest_url('dcfh/v1')),
                'nonce' => wp_create_nonce('wp_rest'),
                'assetsURL' => $this->plugin_url."/dashboard/assets",
                'currentUserInfo' => $current_user_data,
                'generalSettingsEmail' => get_bloginfo('admin_email'),
                'editableRoles' => $filtered_roles,
                'pluginInfo' => [
                    'pluginName' => $current_plugin_data['Name'] ?? '',
                    'pluginTextDomain' => $current_plugin_data['TextDomain'] ?? '',
                    'pluginCurrentVersion' => $current_plugin_data['Version'] ?? '',
                    'pluginDescription' => $current_plugin_data['Description'] ?? '',
                    'pluginSlug' => $current_plugin_data['pluginExtras']['PluginSlug'],
                    'PluginIsETMarketplace' => $current_plugin_data['pluginExtras']['PluginIsETMarketplace'],
                    'pluginDOCLink' => $current_plugin_data['pluginExtras']['PluginDocLink'],
                    'pluginSupportLink' => $current_plugin_data['pluginExtras']['PluginSupportLink'],
                    'pluginTroubleshootLink' => $current_plugin_data['pluginExtras']['PluginTroubleshootLink'],
                    'pluginCommunityLink' => $current_plugin_data['pluginExtras']['PluginCommunityLink'],
                    'pluginBetaNoticeLink' => $current_plugin_data['pluginExtras']['PluginBetaNoticeLink'],
                    'pluginETReviewsLink' => $current_plugin_data['pluginExtras']['PluginETReviewsLink'],
                    'pluginPAReviewsLink' => $current_plugin_data['pluginExtras']['PluginPAReviewsLink'],
                    'pluginFindLicenseKeyLink' => $current_plugin_data['pluginExtras']['PluginFindLicenseKeyLink'],
                ]
            ]
        );
    }
}


??

??