WPtouch Mobile Switch Fix

The Problem

I recently installed version 1.9.21 of WPtouch and noticed some strange behaviour. When switching from the Mobile version of a page to the Desktop version, the URL is reset to the root, even though the current page’s URL is passed into the “switch_delayer()” function.

The Reason

When on the Desktop version, the link generated contains a non-escaped ampersand:

http://megasad.com/?theme_view=mobile
&wptouch_redirect=megasad.com/2009/12/platypus

Though not valid XHTML, this works as you’d expect, switching to the Mobile view and staying on the same page.

When on the Mobile version, the ampersand appears as a proper HTML entity:

http://megasad.com/?theme_view=normal
&wptouch_redirect=megasad.com/2009/12/platypus

But whilst this is valid XHTML, the wptouch_redirect functionality is then broken.

The Fix

Remove “amp;” from line 162 of “core-functions.php“, so that it goes from this:

... '/?theme_view=normal&wptouch_redirect=' ...

To this:

... '/?theme_view=normal&wptouch_redirect=' ...

The Conclusion

This may already be fixed in version 2.0 of WPtouch Pro. However, as I’ve not yet used that, I don’t know for sure. I also assume this will be of help to those users of 1.9.21 who aren’t yet ready to upgrade to 2.0.