• Resolved skylarkcob

    (@skylarkcob)


    Hi author, your plugin is good but it makes error on AMP page. Can you help me to fix it.

    public function force_ssl_with_javascript()
            {
                ?>
                <script>
                    if (document.location.protocol != "https:") {
                        document.location = document.URL.replace(/^http:/i, "https:");
                    }
                </script>
                <?php
            }

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Mark

    (@markwolters)

    Hi,

    what kind of issues are you experiencing? The page seems to be loading fine. Do you only experience issues with the Javascript redirect or also with another redirect option?

    Mark

    Thread Starter skylarkcob

    (@skylarkcob)

    Google Search Console show error on my AMP page:

    https://validator.ampproject.org/#url=https%3A%2F%2Fhocwp.net%2Fblog%2Flam-da-ngon-ngu-voi-polylang%2Famp%2F

    User-authored JavaScript found on page (Critical issue).

    Can you add a filter for theme author can turn off javascript redirect?

    Plugin Author Mark

    (@markwolters)

    Hi,

    we will have a look at adding a filter for the Javascript redirect. I will have to discuss this with Rogier first. In the meantime, you could also enable another redirect option like the WordPress 301 or .htaccess redirect. Those don’t add inline scripts so it should pass the AMP test. We recommend to enable the .htaccess redirect option when possible since it’s the fastest redirect.

    Mark

    Plugin Contributor Rogier Lankhorst

    (@rogierlankhorst)

    You can disable the JavaScript redirect in settings/ssl. Doesn’t that resolve your issue?

    Thread Starter skylarkcob

    (@skylarkcob)

    Thank you very much for your supports Mark and Rogier. I only want to disable javascript redirect on AMP page. On normal page I still use this utils.

    Now I use filter option_{$option_name} to check and disable it. But I can’t make it works on theme. It only works on plugin.

    Plugin Contributor Rogier Lankhorst

    (@rogierlankhorst)

    I have added a filter, which will be published on the next update.

    Usage:

    add_filter('rsssl_javascript_redirect', 'rsssl_remove_javascript');
    function rsssl_remove_javascript($script){
      return '';
    }
    Thread Starter skylarkcob

    (@skylarkcob)

    Thank you very much. Vote 5 stars for your plugin 🙂

    bbrian1988

    (@bbrian1988)

    Thank you very much and I’m also looking for the next update. I’m also getting the same critical errors on my AMP pages due to this.

    Here is the report if it helps: https://validator.ampproject.org/#url=https%3A%2F%2Fquotebold.com%2Fpowerful-quotes%2Famp%2F

    Love the plugin so far,
    Brian

    bbrian1988

    (@bbrian1988)

    *Was able to fix it by disabling the javascript redirect – thanks again though 🙂

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Error on AMP page’ is closed to new replies.