?? GreyFile — Mystic File Browser

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



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

?? Viewing: Public_Enqueue.php

<?php

namespace KS_PAC_DCFH\Base;

use KS_PAC_DCFH\Admin\Controllers\Strings;

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

class Public_Enqueue
{
    private $version;

    private $min = '';

    public function init(): void
    {
        $this->version = KS_PAC_DCFH_PLUGIN_VERSION;
        $this->min = KS_PAC_DCFH_PLUGIN_DEV_MOD ? '' : '.min';
        add_action('wp_enqueue_scripts', [$this, 'maybe_enqueue_scripts']);
        add_filter('script_loader_tag', [$this, 'maybe_filter_script_tag'], 10, 3);
        add_action('wp_print_scripts', [$this, 'maybe_remove_third_party_localized_script']);
    }

    public function maybe_enqueue_scripts(): void
    {
        $wp_max_upload_size = wp_max_upload_size();
        // Localizations
        $localizations = [
            'ajaxURL' => esc_js(admin_url('admin-ajax.php')),
            'ajaxNonce' => wp_create_nonce('dcfh-nonce-ajax'),
            'pluginURL' => esc_js($this->get_plugin_url()),
            'blogURL' => get_bloginfo('url'),
            'wpLocale' => ks_pac_dcfh_wp_helper()::get_wp_locale(),
            'wpMaxUploadSize' => $wp_max_upload_size,
            'wpMaxUploadSizeFormatted' => size_format($wp_max_upload_size),
            'imageMimeTypes' => ks_pac_dcfh_wp_helper()::get_image_mimes(),
            'isSuperAdmin' => is_super_admin(),
            'userIPAddress' => md5(ks_pac_dcfh_general_helper()::get_ip_address()),
            'isPopupsforDivi' => is_plugin_active('popups-for-divi/plugin.php'),
            'i10n' => Strings::instance()->strings('frontend_i10'),
        ];
        /*---------------- App ----------------*/
        wp_enqueue_style('divi-contact-form-helper', $this->get_plugin_url("/assets/public/app$this->min.css"), [], $this->version);
        wp_enqueue_script('divi-contact-form-helper', $this->get_plugin_url("/assets/public/app$this->min.js"), ['jquery', 'wp-i18n'], $this->version, true);
        wp_localize_script('divi-contact-form-helper', 'DiviContactFormHelperPublicData', apply_filters('dcfh_f_public_localizations', $localizations));
        //wp_set_script_translations('divi-contact-form-helper', 'pwh-dcfh');
        if (ks_pac_dcfh_db()::is_setting_enabled('pwh_dcfh_load_resources_from_cdn')) {
            /*---------------- DateTime Picker ----------------*/
            wp_register_style('divi-contact-form-helper-datetimepicker', 'https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.min.css', [], '2.5.20');
            wp_register_script('divi-contact-form-helper-datetimepicker', 'https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.full.min.js', ['jquery'], '2.5.20', true);
            /*---------------- Select2 ----------------*/
            wp_register_style('divi-contact-form-helper-select2', 'https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css', [], '4.1.0');
            wp_register_script('divi-contact-form-helper-select2', 'https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js', ['jquery'], '4.1.0', true);
            /*---------------- Digital Signature Pad ----------------*/
            wp_register_script('divi-contact-form-helper-signature-pad', 'https://cdn.jsdelivr.net/npm/signature_pad@5.0.1/dist/signature_pad.umd.min.js', ['jquery'], '5.0.1', true);
            /*---------------- Input Mask ----------------*/
            wp_register_script('divi-contact-form-helper-inputmask', 'https://cdnjs.cloudflare.com/ajax/libs/jquery.inputmask/5.0.6/jquery.inputmask.min.js', null, '5.0.6', true);
        } else {
            /*---------------- DateTime Picker ----------------*/
            wp_register_style('divi-contact-form-helper-datetimepicker', $this->get_plugin_url("/assets/vendor/jquery.datetimepicker.min.css"), [], '2.5.20');
            wp_register_script('divi-contact-form-helper-datetimepicker', $this->get_plugin_url("/assets/vendor/jquery.datetimepicker.full.min.js"), ['jquery'], '2.5.20', true);
            /*---------------- Select2 ----------------*/
            wp_register_style('divi-contact-form-helper-select2', $this->get_plugin_url("/assets/vendor/select2.min.css"), [], '4.1.0');
            wp_register_script('divi-contact-form-helper-select2', $this->get_plugin_url("/assets/vendor/select2.min.js"), ['jquery'], '4.1.0', true);
            /*---------------- Digital Signature Pad ----------------*/
            wp_register_script('divi-contact-form-helper-signature-pad', $this->get_plugin_url("/assets/vendor/signature_pad.umd.min.js"), ['jquery'], '5.0.1', true);
            /*---------------- Input Mask ----------------*/
            wp_register_script('divi-contact-form-helper-inputmask', $this->get_plugin_url("/assets/vendor/jquery.inputmask.min.js"), null, '5.0.6', true);
        }
        /*---------------- Google reCAPTCHA V2 ----------------*/
        wp_register_script('divi-contact-form-helper-google-recaptcha-v2', 'https://www.google.com/recaptcha/api.js?onload=onloadGoogleRecaptchaCallback&render=explicit', ['jquery'], null, true);
        /*---------------- Cloudflare Turnstile ----------------*/
        wp_register_script('divi-contact-form-helper-cloudflare-turnstile', 'https://challenges.cloudflare.com/turnstile/v0/api.js?onload=onloadTurnstileCallback', ['jquery'], null, true);
    }

    public function maybe_filter_script_tag($tag, $handle, $src)
    {
        if ('divi-contact-form-helper-google-recaptcha-v2' === $handle) {
            return str_replace(' src', ' async defer src', $tag);
        }

        return $tag;
    }

    public function maybe_remove_third_party_localized_script(): void
    {
        if (ks_pac_dcfh_db()::is_setting_enabled('pwh_dcfh_disable_google_recaptcha')) {
            global $wp_scripts;
            if (isset($wp_scripts->registered['et-recaptcha-v3'])) {
                $wp_scripts->registered['et-recaptcha-v3']->src = '';
            }
            if (isset($wp_scripts->registered['et-core-api-spam-recaptcha'])) {
                $wp_scripts->registered['et-core-api-spam-recaptcha']->src = '';
                $wp_scripts->registered['et-core-api-spam-recaptcha']->extra['data'] = '';
            }
        }
    }

    private function get_plugin_url($path = ''): string
    {
        return KS_PAC_DCFH_PLUGIN_URL.$path;
    }
}


??

??