HEX
Server: nginx/1.18.0
System: Linux vcwordpress 5.15.0-174-generic #184-Ubuntu SMP Fri Mar 13 18:41:50 UTC 2026 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/e-tdr.com/e-tdr/wp-content/themes/e-tdr/inc/theme-customisations.php
<?php
// This will call the SMTP(config-file) to submit the form
function mailtrap($phpmailer)
{
    $phpmailer->isSMTP();
    $phpmailer->Host = SMTP_HOST;
    $phpmailer->SMTPAuth = true;
    $phpmailer->Port = SMTP_PORT;
    $phpmailer->Username = SMTP_USER;
    $phpmailer->Password = SMTP_PASS;
    $phpmailer->SMTPSecure = SMTP_SECURE;
    $phpmailer->From       = SMTP_FROM;
    $phpmailer->FromName = SMTP_FROM_NAME;
}

add_action('phpmailer_init', 'mailtrap');

// Action Hook to redirect to thank you page after form submission
add_action('wp_footer', 'redirect_cf7');
function redirect_cf7()
{
    // Get dynamic URL of the thank you page
    $thank_you_url = home_url('/thank-you/');
?>
    <script type="text/javascript">
        document.addEventListener('wpcf7mailsent', function(event) {
            location = '<?php echo esc_url($thank_you_url); ?>';
        }, false);
    </script>
<?php
}

// Allow SVG uploads
function enable_svg_upload($mimes)
{
    $mimes['svg'] = 'image/svg+xml';
    return $mimes;
}
add_filter('upload_mimes', 'enable_svg_upload');

// Disable block editor for all post types except 'post'
function disable_gutenberg_editor_except_posts($use_block_editor, $post_type)
{
    // Disable block editor for all post types except 'post'
    if ($post_type !== 'post') {
        return false;
    }
    return true;
}
add_filter('use_block_editor_for_post_type', 'disable_gutenberg_editor_except_posts', 10, 2);

// Stop Plugin Auto Updates
add_filter('auto_update_plugin', '__return_false');

// Stop Theme Auto Updates
add_filter('auto_update_theme', '__return_false');

if (function_exists('acf_add_options_page')) {

    acf_add_options_page(array(
        'page_title'    => 'Theme Settings',
        'menu_title'    => 'Theme Settings',
        'menu_slug'     => 'theme-settings',
        'capability'    => 'edit_posts',
        'redirect'      => false
    ));

    // Optional: Sub-pages for better organization
    acf_add_options_sub_page(array(
        'page_title'  => 'Header Settings',
        'menu_title'  => 'Header',
        'parent_slug' => 'theme-settings',
    ));

    acf_add_options_sub_page(array(
        'page_title'  => 'Footer Settings',
        'menu_title'  => 'Footer',
        'parent_slug' => 'theme-settings',
    ));

    acf_add_options_sub_page(array(
        'page_title'  => 'Contact Us Modal Settings',
        'menu_title'  => 'Contact Us Modal',
        'parent_slug' => 'theme-settings',
    ));
}

function etdr_enqueue_custom_style()
{
    wp_enqueue_style('etdr-custom-style', get_template_directory_uri() . '/css/custom-style.css', array(), filemtime(get_template_directory() . '/css/custom-style.css'), 'all');

    wp_enqueue_script('bootstrap-js', 'https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js', array(), '5.3.3', true);
}
add_action('wp_enqueue_scripts', 'etdr_enqueue_custom_style');

function add_bootstrap_nav_classes($classes, $item, $args)
{
    if ($args->theme_location == 'menu-1') {
        $classes[] = 'nav-item';
    }
    return $classes;
}
add_filter('nav_menu_css_class', 'add_bootstrap_nav_classes', 10, 3);

function add_bootstrap_link_class($atts, $item, $args)
{
    if ($args->theme_location == 'menu-1') {
        $atts['class'] = 'nav-link';
    }
    return $atts;
}
add_filter('nav_menu_link_attributes', 'add_bootstrap_link_class', 10, 3);

// Disable Gutenberg for posts
add_filter('use_block_editor_for_post', '__return_false', 10);

// Disable Gutenberg for widgets
add_filter('use_widgets_block_editor', '__return_false');

// Add GTM live only — balanced defer (3.5s or first interaction, whichever is sooner)
function vc_add_gtm_live_only()
{
    // Run ONLY on live domain
    if (parse_url(home_url(), PHP_URL_HOST) !== 'e-tdr.com') {
        return;
    }
?>
    <!-- Google Tag Manager (Deferred) -->
    <script>
        // Initialize dataLayer immediately so any pre-GTM events are queued
        window.dataLayer = window.dataLayer || [];

        function initGTM() {
            if (window.gtmDidInit) return false;
            window.gtmDidInit = true;

            var script = document.createElement('script');
            script.type = 'text/javascript';
            script.async = true;
            // script.onload ensures PageView is properly tracked on deferred load
            // Source: https://stackoverflow.com/a/62142237 (CC BY-SA 4.0)
            script.onload = function() {
                dataLayer.push({
                    event: 'gtm.js',
                    'gtm.start': new Date().getTime(),
                    'gtm.uniqueEventId': 0
                });
            };
            script.src = 'https://www.googletagmanager.com/gtm.js?id=GTM-TMZN4ZHD';
            document.head.appendChild(script);
        }

        function initGTMOnEvent(event) {
            initGTM();
            event.currentTarget.removeEventListener(event.type, initGTMOnEvent);
        }

        // Load after 3.5s post-DOMContentLoaded — balanced for analytics vs performance
        // Source: https://constantsolutions.dk/2020/06/delay-loading-of-google-analytics-google-tag-manager-script-for-better-pagespeed-score-and-initial-load/
        document.addEventListener('DOMContentLoaded', function() {
            setTimeout(initGTM, 3500);
        });

        // Or load immediately on first user interaction (whichever comes first)
        document.addEventListener('scroll', initGTMOnEvent);
        document.addEventListener('mousemove', initGTMOnEvent);
        document.addEventListener('touchstart', initGTMOnEvent);
    </script>
    <!-- End Google Tag Manager -->
<?php
}
add_action('wp_head', 'vc_add_gtm_live_only', 99);


// GTM Noscript (Body)
function vc_add_gtm_noscript_live_only()
{
    // Run ONLY on live domain
    if (parse_url(home_url(), PHP_URL_HOST) !== 'e-tdr.com') {
        return;
    }
?>
    <!-- Google Tag Manager (noscript) -->
    <noscript>
        <iframe src="https://www.googletagmanager.com/ns.html?id=GTM-TMZN4ZHD"
            height="0" width="0" style="display:none;visibility:hidden"></iframe>
    </noscript>
    <!-- End Google Tag Manager (noscript) -->
<?php
}
add_action('wp_body_open', 'vc_add_gtm_noscript_live_only');