Plugin Directory

Changeset 3318377


Ignore:
Timestamp:
06/26/2025 04:42:20 PM (9 months ago)
Author:
engagebay
Message:

fixed landing page preview issue

Location:
engagebay-landing-page-builder
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • engagebay-landing-page-builder/tags/2.0/includes/class-engagebay-lp-tinymce-utils.php

    r3318298 r3318377  
    4343        if ( isset( $atts['id'] ) ) {
    4444            $id     = $atts['id'];
    45             $js_api = ( sanitize_text_field( get_option( 'engagebay_lp_builder_js_api' ) ) );
    46             $domain = ( sanitize_text_field( get_option( 'engagebay_lp_builder_domain' ) ) );
    47             $email  = ( sanitize_email( get_option( 'engagebay_lp_builder_email' ) ) );
    48             if ( $domain != '' && $email != '' && $js_api != '' ) {
     45            $js_api = sanitize_text_field( get_option( 'engagebay_lp_builder_js_api' ) );
     46            $domain = sanitize_text_field( get_option( 'engagebay_lp_builder_domain' ) );
     47            $email  = sanitize_email( get_option( 'engagebay_lp_builder_email' ) );
     48
     49            if ( $domain !== '' && $email !== '' && $js_api !== '' ) {
    4950                return "
    50             <script>
    51                 var EhAPI = EhAPI || {};
    52                 EhAPI.after_load = function() {
    53                     EhAPI.set_account('$js_api', '$domain');
    54                     EhAPI.execute('rules');
    55                 };
    56                 (function(d, s, f) {
    57                     var sc = document.createElement(s);
    58                     sc.type = 'text/javascript';
    59                     sc.async = true;
    60                     sc.src = f;
    61                     var m = document.getElementsByTagName(s)[0];
    62                     m.parentNode.insertBefore(sc, m);   
    63                 })(document, 'script', '//d2p078bqz5urf7.cloudfront.net/jsapi/ehform.js');
    64             </script>
    65             <script>
    66                 function waitForEhForms() {
    67                     const interval = 100; // Check every 100ms
    68                     const checkAndLoad = () => {
    69                         const params = new URLSearchParams(window.location.search);
    70                         const elementorPreviewParam = params.get('elementor-preview');
    71                         if (elementorPreviewParam && typeof EhForms !== 'undefined' && typeof EhForms.loadForms === 'function') {
    72                             EhForms.loadForms();
    73                             console.log('EhForms.loadForms() called successfully.');
    74                         } else {
    75                             setTimeout(checkAndLoad, interval);
    76                         }
    77                     };
    78                     checkAndLoad();
    79                 }
    80                 // Call the function
    81                 waitForEhForms();
    82             </script>
    83         <div class='engage-hub-form-embed' id='eh_form_$id' data-id='$id'></div>";
     51                <script>
     52                    if (!window._ehform_script_loaded) {
     53                        var EhAPI = EhAPI || {};
     54                        EhAPI.after_load = function() {
     55                            EhAPI.set_account('$js_api', '$domain');
     56                            EhAPI.execute('rules');
     57                        };
     58                        (function(d, s, f) {
     59                            var sc = document.createElement(s);
     60                            sc.type = 'text/javascript';
     61                            sc.async = true;
     62                            sc.src = f;
     63                            sc.onload = function() { window._ehform_script_loaded = true; };
     64                            var m = document.getElementsByTagName(s)[0];
     65                            m.parentNode.insertBefore(sc, m);   
     66                        })(document, 'script', '//d2p078bqz5urf7.cloudfront.net/jsapi/ehform.js');
     67                    }
     68                </script>
     69                <script>
     70                    function waitForEhForms() {
     71                        const interval = 100;
     72                        const checkAndLoad = () => {
     73                            const params = new URLSearchParams(window.location.search);
     74                            const elementorPreviewParam = params.get('elementor-preview');
     75                            if (elementorPreviewParam && typeof EhForms !== 'undefined' && typeof EhForms.loadForms === 'function') {
     76                                EhForms.loadForms();
     77                                console.log('EhForms.loadForms() called successfully.');
     78                            } else {
     79                                setTimeout(checkAndLoad, interval);
     80                            }
     81                        };
     82                        checkAndLoad();
     83                    }
     84                    waitForEhForms();
     85                </script>
     86                <div class='engage-hub-form-embed' id='eh_form_$id' data-id='$id'></div>";
    8487            }
    8588        }
    86 
    87         return;
    8889    }
    8990
  • engagebay-landing-page-builder/trunk/includes/class-engagebay-lp-tinymce-utils.php

    r3318298 r3318377  
    4343        if ( isset( $atts['id'] ) ) {
    4444            $id     = $atts['id'];
    45             $js_api = ( sanitize_text_field( get_option( 'engagebay_lp_builder_js_api' ) ) );
    46             $domain = ( sanitize_text_field( get_option( 'engagebay_lp_builder_domain' ) ) );
    47             $email  = ( sanitize_email( get_option( 'engagebay_lp_builder_email' ) ) );
    48             if ( $domain != '' && $email != '' && $js_api != '' ) {
     45            $js_api = sanitize_text_field( get_option( 'engagebay_lp_builder_js_api' ) );
     46            $domain = sanitize_text_field( get_option( 'engagebay_lp_builder_domain' ) );
     47            $email  = sanitize_email( get_option( 'engagebay_lp_builder_email' ) );
     48
     49            if ( $domain !== '' && $email !== '' && $js_api !== '' ) {
    4950                return "
    50             <script>
    51                 var EhAPI = EhAPI || {};
    52                 EhAPI.after_load = function() {
    53                     EhAPI.set_account('$js_api', '$domain');
    54                     EhAPI.execute('rules');
    55                 };
    56                 (function(d, s, f) {
    57                     var sc = document.createElement(s);
    58                     sc.type = 'text/javascript';
    59                     sc.async = true;
    60                     sc.src = f;
    61                     var m = document.getElementsByTagName(s)[0];
    62                     m.parentNode.insertBefore(sc, m);   
    63                 })(document, 'script', '//d2p078bqz5urf7.cloudfront.net/jsapi/ehform.js');
    64             </script>
    65             <script>
    66                 function waitForEhForms() {
    67                     const interval = 100; // Check every 100ms
    68                     const checkAndLoad = () => {
    69                         const params = new URLSearchParams(window.location.search);
    70                         const elementorPreviewParam = params.get('elementor-preview');
    71                         if (elementorPreviewParam && typeof EhForms !== 'undefined' && typeof EhForms.loadForms === 'function') {
    72                             EhForms.loadForms();
    73                             console.log('EhForms.loadForms() called successfully.');
    74                         } else {
    75                             setTimeout(checkAndLoad, interval);
    76                         }
    77                     };
    78                     checkAndLoad();
    79                 }
    80                 // Call the function
    81                 waitForEhForms();
    82             </script>
    83         <div class='engage-hub-form-embed' id='eh_form_$id' data-id='$id'></div>";
     51                <script>
     52                    if (!window._ehform_script_loaded) {
     53                        var EhAPI = EhAPI || {};
     54                        EhAPI.after_load = function() {
     55                            EhAPI.set_account('$js_api', '$domain');
     56                            EhAPI.execute('rules');
     57                        };
     58                        (function(d, s, f) {
     59                            var sc = document.createElement(s);
     60                            sc.type = 'text/javascript';
     61                            sc.async = true;
     62                            sc.src = f;
     63                            sc.onload = function() { window._ehform_script_loaded = true; };
     64                            var m = document.getElementsByTagName(s)[0];
     65                            m.parentNode.insertBefore(sc, m);   
     66                        })(document, 'script', '//d2p078bqz5urf7.cloudfront.net/jsapi/ehform.js');
     67                    }
     68                </script>
     69                <script>
     70                    function waitForEhForms() {
     71                        const interval = 100;
     72                        const checkAndLoad = () => {
     73                            const params = new URLSearchParams(window.location.search);
     74                            const elementorPreviewParam = params.get('elementor-preview');
     75                            if (elementorPreviewParam && typeof EhForms !== 'undefined' && typeof EhForms.loadForms === 'function') {
     76                                EhForms.loadForms();
     77                                console.log('EhForms.loadForms() called successfully.');
     78                            } else {
     79                                setTimeout(checkAndLoad, interval);
     80                            }
     81                        };
     82                        checkAndLoad();
     83                    }
     84                    waitForEhForms();
     85                </script>
     86                <div class='engage-hub-form-embed' id='eh_form_$id' data-id='$id'></div>";
    8487            }
    8588        }
    86 
    87         return;
    8889    }
    8990
Note: See TracChangeset for help on using the changeset viewer.