WPIntell

Source evidence

WordPress 6.4 – The plugin no longer works.

Any Mobile Theme Switcher · support · 2023-11-09T10:16:00+00:00

mixedsentiment
highseverity
0.95relevance
18replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

8 / 21 rows with source links

38.1% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

13 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
olimate resolved
After updating WordPress to the new version 6.4, the plugin has stopped working. Can someone please help? Hi, I just checked our plugin with WordPress 6.4.1. and couldn’t find any fatal error at all. And the theme switching is working fine here. Tested with default wordpress theme. Can you send me the error messaging you are getting ? Thanks Thanks for your reply! The thing is, I rolled back to version 6.3, and now everything is working smoothly. I’ll keep you posted when I decide to update WordPress again 🙂 Hey, I got a related Problem: If a child theme is selected for the Mobile Theme, the whole child theme stops working under WordPress 6.4 and above. Most likely, this is related to the changes for the template locating system introduced in https://core.trac.wordpress.org/ticket/59279 and https://core.trac.wordpress.org/ticket/58576 . I don’t really know how the “correct” fix would be, however i found that the following change to the any-mobile-theme-switcher.php fixes the issue appearently: Change lines 54 to 68 from: if (!empty($forceLayout)){ //IF USER FORCE FOR THE THEME if ($forceLayout == 'mobile'){ // IF FORCED THEME IS MOBILE $amts_mobile_browser = get_option('iphone_theme'); add_filter('stylesheet', 'loadMobileStyle'); add_filter('template', 'loadMobileTheme'); $amts_shown_theme = 'mobile'; } } else { // NORMAL THEME [PLUGIN DEFAULT] if (!empty($amts_mobile_browser)){ add_filter('stylesheet', 'loadMobileStyle'); add_filter('template', 'loadMobileTheme'); $amts_shown_theme = 'mobile'; } } to: global $wp_stylesheet_path; if (!empty($forceLayout)){ //IF USER FORCE FOR THE THEME if ($forceLayout == 'mobile'){ // IF FORCED THEME IS MOBILE $amts_mobile_browser = get_option('iphone_theme'); add_filter('stylesheet', 'loadMobileStyle'); add_filter('template', 'loadMobileTheme'); $wp_stylesheet_path = null; $amts_shown_theme = 'mobile'; } } else { // NORMAL THEME [PLUGIN DEFAULT] if (!empty($amts_mobile_browser)){ $wp_stylesheet_path = null; add_filter('stylesheet', 'loadMobileStyle'); add_filter('template', 'loadMobileTheme'); $amts_shown_theme = 'mobile'; } } (add the global $wp_stylesheet_path and set it to null if we are on mobile). Please release a fix as soon as possible because otherwise all our pretty mobile themes won’t work anymore 🙁 Happy Coding! My issue with 6.4 was quite similar. The right theme on mobile was loaded, but with broken styles, etc @olimate Please try my fix and see if it fixes your problem too? Happy Coding I tried but I get same result. The defualt WP theme is loaded but with any styles, etc… So the mobile site looks broken. Probably the global template path has to be set to null too… Please try again with this code: global $wp_stylesheet_path, $wp_template_path; if (!empty($forceLayout)){ //IF USER FORCE FOR THE THEME if ($forceLayout == 'mobile'){ // IF FORCED THEME IS MOBILE $amts_mobile_browser = get_option('iphone_theme'); $wp_stylesheet_path = null; $wp_template_path = null; add_filter('stylesheet', 'loadMobileStyle'); add_filter('template', 'loadMobileTheme'); $amts_shown_theme = 'mobile'; } } else { // NORMAL THEME [PLUGIN DEFAULT] if (!empty($amts_mobile_browser)){ $wp_stylesheet_path = null; $wp_template_path = null; add_filter('stylesheet', 'loadMobileStyle'); add_filter('template', 'loadMobileTheme'); $amts_shown_theme = 'mobile'; } } Happy coding! Hi, I am trying to replicate this issue but has been able to do it. This is scenario i am working with. My active default theme is Twenty Twenty Three. and then i have created a child theme from Twenty Twenty Four. Same child theme is set as mobile theme. And there is no error and theme switching is working fine. Can you please share me your scenario about your child theme so that i can replicate it here. Thanks doesn’t work with wp 6.4 – 6.4.1 my any resource – js – css and others not loading After lots of testing, i found the / a culprit in the Plugin “Meta Box”. The Problem (as i understand it) is the following: WordPress introduced a global variable into the functions get_template_directory() and get_stylesheet_directory(). These global variables are used to speed up these functions (if the function was executed before the variables are not null, and if they are not null, the function is not executed but the global variables are returned without using the filters or anything). You can look at the new functions here and here . Meta Box (probably other plugins as well, but in my case, Meta Box was the culprit) saves the template and stylesheet directory in own Constants and does so BEFORE the plugins_loaded action (which it shouldn’t do, but “wordpress coders do be codin’ bad” sometimes) When the mobile theme SHOULD be loaded, the stylesheets get all kinds of messed up because while the global variables are still set to the “desktop” theme, some functions still load mobile stuff. The fix i wrote in my post above should solve the problem by setting the global variables to null, thus forcing the get_template_directory and get_stylesheet_directory functions next time they are run to apply the filters added by any mobile theme switcher and setting the global variables to the “correct” values from there on. I paste the complete fix in here again, just for convenience: Change the code in the any-mobile-theme-switcher.php Lines 55 to 68 from this: if (!empty($forceLayout)){ //IF USER FORCE FOR THE THEME if ($forceLayout == 'mobile'){ // IF FORCED THEME IS MOBILE $amts_mobile_browser = get_option('iphone_theme'); add_filter('stylesheet', 'loadMobileStyle'); add_filter('template', 'loadMobileTheme'); $amts_shown_theme = 'mobile'; } } else { // NORMAL THEME [PLUGIN DEFAULT] if (!empty($amts_mobile_browser)){ add_filter('stylesheet', 'loadMobileStyle'); add_filter('template', 'loadMobileTheme'); $amts_shown_theme = 'mobile'; } } to this: global $wp_stylesheet_path, $wp_template_path; if (!empty($forceLayout)){ //IF USER FORCE FOR THE THEME if ($forceLayout == 'mobile'){ // IF FORCED THEME IS MOBILE $wp_stylesheet_path = null; $wp_template_path = null; $amts_mobile_browser = get_option('iphone_theme'); add_filter('stylesheet', 'loadMobileStyle'); add_filter('template', 'loadMobileTheme'); $amts_shown_theme = 'mobile'; } } else { // NORMAL THEME [PLUGIN DEFAULT] if (!empty($amts_mobile_browser)){ $wp_stylesheet_path = null; $wp_template_path = null; add_filter('stylesheet', 'loadMobileStyle'); add_filter('template', 'loadMobileTheme'); $amts_shown_theme = 'mobile'; } } Happy Coding! Well, I’m nout using meta box plugin. And as @anasite said, I have exactly the same issue (my any resource – js – css and others not loading). Hey @olimate , As i wrote, this isn’t necessarily a problem with meta box, but with any plugin that uses the functions get_template_directory() and/or get_stylesheet_directory() BEFORE the plugins_loaded Hook. You can deactivate your plugins one by one (best to do that on a staging copy of your website) and load the website on mobile to find the culprit on your site. Thanks again for your quick reply. My themes uses this: bloginfo(‘stylesheet_url’); echo ‘?ver=’ . filemtime( get_stylesheet_directory() . ‘/style.css’ in order to get a fresh css files all the time. So, where I need to paste this solution? In my function.php file in the “mobile” theme? In both themes? Is this a temp solution? I mean, this will be solved in the next plugin release? Thanks again! @olimate : The Problem shouldn’t (and probably couldn’t) be triggered by a theme. The fix i wrote is for the any-mobile-theme-switcher.php, and you should only apply it if you know what you are doing. I hope @dcsupport will adopt my fix for a quick update of the plugin so that after an update everything will be gucci as the hip kids say 😉 Happy Coding! @olimate Apparently, this problem isn’t only with Any Mobile Theme Switcher, but with a lot of themes and other plugins too. A different fix for the problem is this Plugin: https://gist.github.com/joemcgill/dd569c287013ad545f41495f93d7a27e Click “Download Zip” on the upper right Go to your WordPress “Plugins” page and click the button “Install Plugin” Click the Button “Upload Plugin” and choose the Zip you just downloaded. Install and activate the Plugin. Check if everything works again as it should 😉 More Background information can be found here: https://core.trac.wordpress.org/ticket/59847 Happy Coding! This reply was modified 2 years, 6 months ago by HU ist Sebastian . @kuchenundkakao Thank you! Your code helped me to fix the same issue with Device Theme Switcher plugin. Hi @kuchenundkakao ! Your plugin fix, worked like a charm, you rocks buddy! Thanks a bunch for your support 🙂 So, now what we need to expect, a new Any Mobile Theme Switcher plugin update to fix it or a new WordPress 6.4.X update to resolve the issue? We have updated plugin to 3.2 with fixes from @kuchenundkakao Thank you so much 🙂

Comments

18 shown
Dinesh Karki 2023-11-09T12:28:00+00:00

Hi, I just checked our plugin with WordPress 6.4.1. and couldn’t find any fatal error at all. And the theme switching is working fine here. Tested with default wordpress theme. Can you send me the error messaging you are getting ? Thanks

olimate 2023-11-09T15:03:00+00:00

Thanks for your reply! The thing is, I rolled back to version 6.3, and now everything is working smoothly. I’ll keep you posted when I decide to update WordPress again 🙂

HU ist Sebastian 2023-11-09T15:55:00+00:00

Hey, I got a related Problem: If a child theme is selected for the Mobile Theme, the whole child theme stops working under WordPress 6.4 and above. Most likely, this is related to the changes for the template locating system introduced in https://core.trac.wordpress.org/ticket/59279 and https://core.trac.wordpress.org/ticket/58576 . I don’t really know how the “correct” fix would be, however i found that the following change to the any-mobile-theme-switcher.php fixes the issue appearently: Change lines 54 to 68 from: if (!empty($forceLayout)){ //IF USER FORCE FOR THE THEME if ($forceLayout == 'mobile'){ // IF FORCED THEME IS MOBILE $amts_mobile_browser = get_option('iphone_theme'); add_filter('stylesheet', 'loadMobileStyle'); add_filter('template', 'loadMobileTheme'); $amts_shown_theme = 'mobile'; } } else { // NORMAL THEME [PLUGIN DEFAULT] if (!empty($amts_mobile_browser)){ add_filter('stylesheet', 'loadMobileStyle'); add_filter('template', 'loadMobileTheme'); $amts_shown_theme = 'mobile'; } } to: global $wp_stylesheet_path; if (!empty($forceLayout)){ //IF USER FORCE FOR THE THEME if ($forceLayout == 'mobile'){ // IF FORCED THEME IS MOBILE $amts_mobile_browser = get_option('iphone_theme'); add_filter('stylesheet', 'loadMobileStyle'); add_filter('template', 'loadMobileTheme'); $wp_stylesheet_path = null; $amts_shown_theme = 'mobile'; } } else { // NORMAL THEME [PLUGIN DEFAULT] if (!empty($amts_mobile_browser)){ $wp_stylesheet_path = null; add_filter('stylesheet', 'loadMobileStyle'); add_filter('template', 'loadMobileTheme'); $amts_shown_theme = 'mobile'; } } (add the global $wp_stylesheet_path and set it to null if we are on mobile). Please release a fix as soon as possible because otherwise all our pretty mobile themes won’t work anymore 🙁 Happy Coding!

olimate 2023-11-09T16:00:00+00:00

My issue with 6.4 was quite similar. The right theme on mobile was loaded, but with broken styles, etc

HU ist Sebastian 2023-11-09T16:26:00+00:00

@olimate Please try my fix and see if it fixes your problem too? Happy Coding

olimate 2023-11-09T16:32:00+00:00

I tried but I get same result. The defualt WP theme is loaded but with any styles, etc… So the mobile site looks broken.

HU ist Sebastian 2023-11-09T17:01:00+00:00

Probably the global template path has to be set to null too… Please try again with this code: global $wp_stylesheet_path, $wp_template_path; if (!empty($forceLayout)){ //IF USER FORCE FOR THE THEME if ($forceLayout == 'mobile'){ // IF FORCED THEME IS MOBILE $amts_mobile_browser = get_option('iphone_theme'); $wp_stylesheet_path = null; $wp_template_path = null; add_filter('stylesheet', 'loadMobileStyle'); add_filter('template', 'loadMobileTheme'); $amts_shown_theme = 'mobile'; } } else { // NORMAL THEME [PLUGIN DEFAULT] if (!empty($amts_mobile_browser)){ $wp_stylesheet_path = null; $wp_template_path = null; add_filter('stylesheet', 'loadMobileStyle'); add_filter('template', 'loadMobileTheme'); $amts_shown_theme = 'mobile'; } } Happy coding!

Dinesh Karki 2023-11-10T05:32:00+00:00

Hi, I am trying to replicate this issue but has been able to do it. This is scenario i am working with. My active default theme is Twenty Twenty Three. and then i have created a child theme from Twenty Twenty Four. Same child theme is set as mobile theme. And there is no error and theme switching is working fine. Can you please share me your scenario about your child theme so that i can replicate it here. Thanks

Anasite 2023-11-10T08:20:00+00:00

doesn’t work with wp 6.4 – 6.4.1 my any resource – js – css and others not loading

HU ist Sebastian 2023-11-10T08:25:00+00:00

After lots of testing, i found the / a culprit in the Plugin “Meta Box”. The Problem (as i understand it) is the following: WordPress introduced a global variable into the functions get_template_directory() and get_stylesheet_directory(). These global variables are used to speed up these functions (if the function was executed before the variables are not null, and if they are not null, the function is not executed but the global variables are returned without using the filters or anything). You can look at the new functions here and here . Meta Box (probably other plugins as well, but in my case, Meta Box was the culprit) saves the template and stylesheet directory in own Constants and does so BEFORE the plugins_loaded action (which it shouldn’t do, but “wordpress coders do be codin’ bad” sometimes) When the mobile theme SHOULD be loaded, the stylesheets get all kinds of messed up because while the global variables are still set to the “desktop” theme, some functions still load mobile stuff. The fix i wrote in my post above should solve the problem by setting the global variables to null, thus forcing the get_template_directory and get_stylesheet_directory functions next time they are run to apply the filters added by any mobile theme switcher and setting the global variables to the “correct” values from there on. I paste the complete fix in here again, just for convenience: Change the code in the any-mobile-theme-switcher.php Lines 55 to 68 from this: if (!empty($forceLayout)){ //IF USER FORCE FOR THE THEME if ($forceLayout == 'mobile'){ // IF FORCED THEME IS MOBILE $amts_mobile_browser = get_option('iphone_theme'); add_filter('stylesheet', 'loadMobileStyle'); add_filter('template', 'loadMobileTheme'); $amts_shown_theme = 'mobile'; } } else { // NORMAL THEME [PLUGIN DEFAULT] if (!empty($amts_mobile_browser)){ add_filter('stylesheet', 'loadMobileStyle'); add_filter('template', 'loadMobileTheme'); $amts_shown_theme = 'mobile'; } } to this: global $wp_stylesheet_path, $wp_template_path; if (!empty($forceLayout)){ //IF USER FORCE FOR THE THEME if ($forceLayout == 'mobile'){ // IF FORCED THEME IS MOBILE $wp_stylesheet_path = null; $wp_template_path = null; $amts_mobile_browser = get_option('iphone_theme'); add_filter('stylesheet', 'loadMobileStyle'); add_filter('template', 'loadMobileTheme'); $amts_shown_theme = 'mobile'; } } else { // NORMAL THEME [PLUGIN DEFAULT] if (!empty($amts_mobile_browser)){ $wp_stylesheet_path = null; $wp_template_path = null; add_filter('stylesheet', 'loadMobileStyle'); add_filter('template', 'loadMobileTheme'); $amts_shown_theme = 'mobile'; } } Happy Coding!

olimate 2023-11-10T08:46:00+00:00

Well, I’m nout using meta box plugin. And as @anasite said, I have exactly the same issue (my any resource – js – css and others not loading).

HU ist Sebastian 2023-11-10T08:52:00+00:00

Hey @olimate , As i wrote, this isn’t necessarily a problem with meta box, but with any plugin that uses the functions get_template_directory() and/or get_stylesheet_directory() BEFORE the plugins_loaded Hook. You can deactivate your plugins one by one (best to do that on a staging copy of your website) and load the website on mobile to find the culprit on your site.

olimate 2023-11-10T09:20:00+00:00

Thanks again for your quick reply. My themes uses this: bloginfo(‘stylesheet_url’); echo ‘?ver=’ . filemtime( get_stylesheet_directory() . ‘/style.css’ in order to get a fresh css files all the time. So, where I need to paste this solution? In my function.php file in the “mobile” theme? In both themes? Is this a temp solution? I mean, this will be solved in the next plugin release? Thanks again!

HU ist Sebastian 2023-11-10T09:45:00+00:00

@olimate : The Problem shouldn’t (and probably couldn’t) be triggered by a theme. The fix i wrote is for the any-mobile-theme-switcher.php, and you should only apply it if you know what you are doing. I hope @dcsupport will adopt my fix for a quick update of the plugin so that after an update everything will be gucci as the hip kids say 😉 Happy Coding!

HU ist Sebastian 2023-11-10T11:27:00+00:00

@olimate Apparently, this problem isn’t only with Any Mobile Theme Switcher, but with a lot of themes and other plugins too. A different fix for the problem is this Plugin: https://gist.github.com/joemcgill/dd569c287013ad545f41495f93d7a27e Click “Download Zip” on the upper right Go to your WordPress “Plugins” page and click the button “Install Plugin” Click the Button “Upload Plugin” and choose the Zip you just downloaded. Install and activate the Plugin. Check if everything works again as it should 😉 More Background information can be found here: https://core.trac.wordpress.org/ticket/59847 Happy Coding! This reply was modified 2 years, 6 months ago by HU ist Sebastian .

Slams 2023-11-10T19:05:00+00:00

@kuchenundkakao Thank you! Your code helped me to fix the same issue with Device Theme Switcher plugin.

olimate 2023-11-11T06:29:00+00:00

Hi @kuchenundkakao ! Your plugin fix, worked like a charm, you rocks buddy! Thanks a bunch for your support 🙂 So, now what we need to expect, a new Any Mobile Theme Switcher plugin update to fix it or a new WordPress 6.4.X update to resolve the issue?

Dnesscarkey 2023-11-20T12:09:00+00:00

We have updated plugin to 3.2 with fixes from @kuchenundkakao Thank you so much 🙂