Current path: home/webdevt/www/demo2/wp-content/plugins/divi-contact-form-helper/d5/server/Admin/Setup/
?? Go up: /home/webdevt/www/demo2/wp-content/plugins/divi-contact-form-helper/d5/server/Admin
<?php
namespace KS_PAC_DCFH\Admin\Setup;
use ET\Builder\VisualBuilder\Assets\PackageBuildManager;
if (!defined('ABSPATH')) {
exit;
}
class VisualBuilderScripts
{
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('divi_visual_builder_assets_before_enqueue_scripts', [$this, 'maybe_enqueue_vb_script']);
add_action('divi_visual_builder_assets_after_enqueue_scripts', [$this, 'maybe_set_translations']);
}
public function maybe_enqueue_vb_script(): void
{
// Bail early if either Divi 5 or Visual Builder is not enabled.
if (!et_builder_d5_enabled() || !et_core_is_fb_enabled()) {
return;
}
$attributes = [
'ajaxURL' => admin_url('admin-ajax.php'),
'baseRestRoute' => get_bloginfo('url'),
'pagesOptions' => ks_pac_dcfh_app()->vb_utils()::get_all_pages(),
'languagesOptions' => ks_pac_dcfh_app()->vb_utils()::get_lanuages(),
'mimeTypeOptions' => ks_pac_dcfh_app()->vb_utils()::get_allowed_mimes_types(),
'wpAllowedMimeTypes' => ks_pac_dcfh_app()->file_utils()::get_wp_allowed_mime_types(),
'dateTimeFormatOptions' => ks_pac_dcfh_app()->vb_utils()::get_datetime_formats(),
'dateFormatOptions' => ks_pac_dcfh_app()->vb_utils()::get_date_formats(),
'timeFormatOptions' => ks_pac_dcfh_app()->vb_utils()::get_time_formats(),
'weekDaysSelectOptions' => ks_pac_dcfh_app()->vb_utils()::get_week_days(),
'weekDaysCheckboxesOptions' => ks_pac_dcfh_app()->vb_utils()::get_week_days('checkbox'),
'defaultLocale' => ks_pac_dcfh_app()->misc_utils()::get_wp_locale(),
'uploadSizeInfoMessage' => sprintf(
__('Default WordPress Max Upload File Size: %1$s KB (i.e., %2$s). Convert your MB to KB (in binary) using <a href="%3$s" target="_blank">%3$s</a>', 'divi-contact-form-helper'),
round(wp_max_upload_size() / 1024),
size_format(wp_max_upload_size()),
esc_url('https://www.gbmb.org/mb-to-kb')
),
'homeURL' => home_url(),
'defaultStrings' => ks_pac_dcfh_app()->default_strings()->get(),
];
PackageBuildManager::register_package_build(
[
'name' => 'divi-contact-form-helper-vb',
'version' => $this->plugin_version,
'script' => [
'src' => $this->plugin_url."/visual-builder/visual-builder.min.js",
'deps' => [
'wp-i18n',
'react',
'jquery-core',
'lodash',
'divi-vendor-wp-hooks'
],
'enqueue_top_window' => false,
'enqueue_app_window' => true,
//'data_top_window' => $attributes,
'data_app_window' => $attributes,
'args' => [
'in_footer' => false,
],
],
]
);
}
public function maybe_set_translations()
{
if (!et_builder_d5_enabled() || !et_core_is_fb_enabled()) {
return;
}
wp_set_script_translations(
'divi-contact-form-helper-vb',
'divi-contact-form-helper',
KS_PAC_DCFH_PLUGIN_DIR.'/languages/'
);
}
}