- This topic has 13 replies, 2 voices, and was last updated 6 years, 8 months ago by
Tom.
-
AuthorPosts
-
July 19, 2019 at 1:24 pm #962229
Jim
Hi. So I looked up my site on Opera Mini for Android and it looks broken. Never test before with this browser but saw 17% of my traffic is through this browser. Tried deactivating all plugins but I couldn’t figure out what the issue was. Used the default install of the browser.
Update: Site seems to show a bit proper when blog module is disabled.July 19, 2019 at 8:00 pm #962360Tom
Lead DeveloperLead DeveloperHi there,
I just checked it out on my Pixel and everything looks great. What about it is broken for you?
July 20, 2019 at 3:45 am #962500Jim
Hi Tom. It seems the data saving feature is the one breaking the site (for automatic and extreme options) and it comes enabled by default. It breaks my SVG icons in single posts, makes menu bar and archive excerpt only show halfway inside the browser and a few other issues. I am not sure how to tell users who use opera to disable or choose alternative options. Could you check with your browser with extreme and automatic data-savings mode (with ad blocker on) enabled respectively?
July 20, 2019 at 7:33 am #962611Tom
Lead DeveloperLead DeveloperIt looks like setting the data savings to extreme disables javascript on the site, which is likely why this is happening.
However, it shouldn’t be set to “Extreme” by default – mine was set to “Automatic” and worked nicely.
I’m not sure how we’d detect Extreme mode and change how the javascript works just for Opera. I’ll do some research.
July 20, 2019 at 10:59 am #962863Jim
It is also broken in automatic mode (on my phone maybe). But yeah, extreme feature and JS don’t play well. I am looking at an alternative way involving a dismissible message that appears in the header on mobile devices telling opera users to choose the high mode.
July 20, 2019 at 7:47 pm #963073Tom
Lead DeveloperLead DeveloperIt looks like you can use javascript to do that: https://gist.github.com/ireade/10fe4b3c1e1caa9751a3
July 20, 2019 at 10:54 pm #963122Jim
I tried to hook it but it shows the raw code on the front end. How Should I use it?
July 21, 2019 at 8:58 am #963487Tom
Lead DeveloperLead DeveloperYou could:
1. Create a Hook Element: https://docs.generatepress.com/article/hooks-element-overview/
2. Set the hook to wherever you want your message to appear.
3. Add your content:<div class="opera-message" style="display: none;"> Your message in here </div>4. Set the Display Rules and publish.
Then:
1. Create another Hook Element.
2. Set the hook towp_footer
3. Add this as the content:<script> // Check if current browser is Opera var isOpera = window.opera | window.opr | ( navigator.userAgent.indexOf(' OPR/') > -1 ) | ( navigator.userAgent.indexOf(' Coast/') > -1 ) | ( navigator.userAgent.indexOf(' OPiOS/') > -1 ); // Check if the Opera browser is Opera Mini or Opera Mobile in regular mode (called High Savings Mode) var isOperaHigh = (navigator.userAgent.indexOf('OPR/') > -1) && (navigator.userAgent.indexOf('Mobile') > -1) && (navigator.userAgent.indexOf('Presto/') < 0); // Check if the Opera browser is Opera Mini in Extreme Savings Mode var isOperaExtreme = (navigator.userAgent.indexOf('Opera Mini/') > -1) && (navigator.userAgent.indexOf('Presto/') > -1); if ( isOperaHigh || isOperaExtreme ) { document.querySelector( '.opera-message' ).setAttribute( 'style', 'display: block' ); } </script>4. Set the Display Rules and publish.
July 21, 2019 at 1:44 pm #963644Jim
I got it to display on opera and for a while, the message would disappear if ‘high’ or ‘off’ mode was selected in data savings but now it shows when all these modes are selected. Should the js above limit it to extreme and automatic modes? Or is there a way to modify it to just show on Extreme and Automatic modes?
July 21, 2019 at 3:59 pm #963690Tom
Lead DeveloperLead DeveloperAccording to the code, it should only display if it’s set to High or Extreme.
Does your site have any caching that could be conflicting?
July 21, 2019 at 4:10 pm #963696Jim
I did a test with cache disabled but it still did not work. But I have shortened the message so that it shows in the header above the menu for opera users in a non-intrusive way. Opera Mini is popular in emerging markets and drives much traffic to sites but often is aggressive with data savings which break sites. Or could you have a suggestion on how to make the message have a close button?
July 22, 2019 at 9:50 am #964327Tom
Lead DeveloperLead DeveloperA close button would require javascript and cookies (to remember that it’s been closed). This might help?: https://www.gmitropapas.com/generatepress-theme-tutorial-convert-the-top-widget-bar-into-a-notification-window/
July 22, 2019 at 2:42 pm #964520Jim
Hi Tom. I found a workaround by modifying the initial code you provided and now I am able to display the message in Automatic and Extreme modes. Thanks for the help.
July 22, 2019 at 6:08 pm #964608Tom
Lead DeveloperLead DeveloperAwesome, you’re welcome! 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.