Current path: home/webdevt/www/demo2/wp-content/plugins/divi-contact-form-helper/d5/server/Frontend/Controllers/
?? Go up: /home/webdevt/www/demo2/wp-content/plugins/divi-contact-form-helper/d5/server/Frontend
<?php
namespace KS_PAC_DCFH\Frontend\Controllers;
if (!defined('ABSPATH')) {
exit;
}
class ContactFormEmailTemplates
{
public function load(): void
{
add_filter('divi_module_dynamic_content_options', [$this, 'maybe_dynamic_content_options'], 10, 3);
add_filter('divi_module_dynamic_content_resolved_value', [$this, 'maybe_dynamic_content_resolved_value'], 10, 2);
}
public function maybe_dynamic_content_options($options, $post_id, $context)
{
// Return If Not Logged In
if (!is_user_logged_in()) {
return $options;
}
$templates = ks_pac_dcfh_app()->email_template_manager()::get_templates_list();
if (empty($templates)) {
return $options;
}
foreach ($templates as $key => $value) {
$options[$key] = [
'id' => $key,
'label' => $value['tpl_name'],
'type' => 'text',
'custom' => false,
'group' => __('Email Templates - Divi Contact Form Helper', 'divi-contact-form-helper'),
];
}
return $options;
}
public function maybe_dynamic_content_resolved_value($value, $data_args)
{
$name = $data_args['name'] ?? '';
if (!str_contains($name, '_pwh_dcfh_email_tpl')) {
return $value;
}
return $name;
}
}