[wp-hackers] Where to insert mobile redirect code?
Aaron Campbell
aaron at bluedogwebservices.com
Mon Apr 16 14:22:46 UTC 2012
Here's a high-level view of how WP Super Cache works:
* When a page is loaded the first time it's cached and stored as a static
html file.
* When a person visits the site, there are rules in the .htaccess that
check if a cached (static) file is available.
* If there is, it simply serves that file and ends.
So basically none of your code is going to run on a cached page load
because it serves the static file. Quite a while ago Donncha made it
mobile-friendly <http://ocaoimh.ie/2009/06/19/go-mobile-with-supercache/> (when
that post was made is was still in beta, but the code is in the released
version now). You'll need to turn on "Mobile device support" and work from
there. Basically it caches mobile versions of page on a per-device basis
and it sounds like your code is going to keep it from ever creating that
cache, so mobile devices should always end up running your code.
On Tue, Mar 27, 2012 at 5:03 PM, Mike Schleif <wordpress at helices.org> wrote:
> Hi, Otto!
>
> Perhaps, we misunderstand each other?
>
> My code sends mobile devices to a NON-Wordpress site. When I research WP
> Super Cache and mobile devices, all I've found is how to send WP pages to
> mobile devices, which requires other software/plugins.
>
> Don suggested using WP_DEBUG to find "headers already sent" messages -
> which I did find and resulted from WP Super Cache. Disabling WPSC results
> in the behavior I want - at the expense of NO cache.
>
>
> What am I missing? Thank you.
>
> If ever I can be of service to you; contact me at once.
>
> I wish for you a truly extraordinary day ...
>
> --
> Best Regards,
>
> Mike Schleif
> 612-235-6060
> http://mdsresource.net
> http://tofree.me/GooglePlus
> http://www.linkedin.com/in/**schleif <http://www.linkedin.com/in/schleif>
> http://facebook.com/**MDSResource <http://facebook.com/MDSResource>
> http://twitter.com/mikeschleif
>
>
> On 3/27/2012 6:28 PM, Otto wrote:
>
>> WP Super Cache has special cases for mobile devices that you'll need
>> to use to disable the super-caching for those devices. Basically it
>> adds some checking to the .htaccess rules for things like iPhone and
>> Android and such.
>>
>> -Otto
>>
>>
>>
>> On Tue, Mar 27, 2012 at 6:25 PM, Mike Schleif<wordpress at helices.org>
>> wrote:
>>
>>> Hi!
>>>
>>> OK, that points to WP Super Cache
>>>
>>> When I turn OFF WP Super Cache, then it redirects properly.
>>>
>>> Is this a problem with ALL wp caching plugins?
>>>
>>> Please, advise. Thank you.
>>>
>>>
>>> If ever I can be of service to you; contact me at once.
>>>
>>> I wish for you a truly extraordinary day ...
>>>
>>> --
>>> Best Regards,
>>>
>>> Mike Schleif
>>> 612-235-6060
>>> http://mdsresource.net
>>> http://tofree.me/GooglePlus
>>> http://www.linkedin.com/in/**schleif<http://www.linkedin.com/in/schleif>
>>> http://facebook.com/**MDSResource <http://facebook.com/MDSResource>
>>> http://twitter.com/mikeschleif
>>>
>>>
>>> On 3/27/2012 6:03 PM, Dion Hulse (dd32) wrote:
>>>
>>>> If it doesn't work even there, this means you've got something
>>>> outputting data before they're loaded, which is bad.
>>>> Look at the source of a rendered page, and see if there's anything
>>>> output before the theme is output.
>>>>
>>>> Also define WP_DEBUG to true, and see if any "headers already sent"
>>>> messages pop up, they'll tell you the line of code where the output is
>>>> starting.
>>>>
>>>> Chances are, you've got 2 line breaks after a closing ?> somewhere.
>>>>
>>>> On 28 March 2012 09:57, Mike Schleif<wordpress at helices.org> wrote:
>>>>
>>>>> Hi!
>>>>>
>>>>> I created a file: aaa-mobile-redirect.php
>>>>>
>>>>> I added the exact code snippet (below) with no whitespace before nor
>>>>> after.
>>>>>
>>>>> I uploaded to here: /wp-content/mu-plugins/aaa-**mobile-redirect.php
>>>>>
>>>>> I removed that exact code from the 1st lines of /index.php
>>>>>
>>>>> It does NOT work.
>>>>>
>>>>> What am I missing? Thank you.
>>>>>
>>>>> If ever I can be of service to you; contact me at once.
>>>>>
>>>>> I wish for you a truly extraordinary day ...
>>>>>
>>>>> --
>>>>> Best Regards,
>>>>>
>>>>> Mike Schleif
>>>>> 612-235-6060
>>>>> http://mdsresource.net
>>>>> http://tofree.me/GooglePlus
>>>>> http://www.linkedin.com/in/**schleif<http://www.linkedin.com/in/schleif>
>>>>> http://facebook.com/**MDSResource <http://facebook.com/MDSResource>
>>>>> http://twitter.com/mikeschleif
>>>>>
>>>>>
>>>>>
>>>>> On 3/27/2012 5:03 PM, Aaron Jorbin wrote:
>>>>>
>>>>>> I would look at doing it as a MU plugin -
>>>>>> http://codex.wordpress.org/**Must_Use_Plugins<http://codex.wordpress.org/Must_Use_Plugins>
>>>>>>
>>>>>> http://aaron.jorb.in
>>>>>> twitter: twitter.com/aaronjorbin
>>>>>>
>>>>>>
>>>>>> On Tue, Mar 27, 2012 at 6:01 PM, Mike Schleif<wordpress at helices.org>
>>>>>> wrote:
>>>>>>
>>>>>> Hi!
>>>>>>>
>>>>>>> I have this simple PHP code:|
>>>>>>> |
>>>>>>>
>>>>>>> |<?php
>>>>>>> require_once "/_PATH_/_DOMAIN_/class.****mobile.php";
>>>>>>> $mobile = new MobileWebarto("http://m._****DOMAIN_");
>>>>>>> ?>|
>>>>>>>
>>>>>>>
>>>>>>> Obviously, _PATH_ and _DOMAIN_ are placeholders.
>>>>>>>
>>>>>>> class.mobile.php identifies whether or not the visitor is a mobile
>>>>>>> device.
>>>>>>>
>>>>>>> On most sites, inserting this code at line #1 of header.php behaves
>>>>>>> exactly as I want and expect.
>>>>>>>
>>>>>>> However, some sites do NOT behave as desired.
>>>>>>>
>>>>>>> In reality, I want this code to execute PRIOR to any theme code.
>>>>>>>
>>>>>>> Furthermore, I don't want WordPress updates to remove the call to
>>>>>>> this
>>>>>>> code.
>>>>>>>
>>>>>>> It seems that this code could be inserted into index.php - BUT ...
>>>>>>>
>>>>>>> HOW can this be done WITHOUT future WP updates removing my code?
>>>>>>>
>>>>>>> Please, advise. Thank you.
>>>>>>>
>>>>>>> ______________________________****_________________
>>>>>>> wp-hackers mailing list
>>>>>>> wp-hackers at lists.automattic.****com<wp-hackers at lists.**
>>>>>>> automattic.com <wp-hackers at lists.automattic.com>>
>>>>>>>
>>>>>>>
>>>>>>> http://lists.automattic.com/****mailman/listinfo/wp-hackers<http://lists.automattic.com/**mailman/listinfo/wp-hackers>
>>>>>>> <ht**tp://lists.automattic.com/**mailman/listinfo/wp-hackers<http://lists.automattic.com/mailman/listinfo/wp-hackers>
>>>>>>> >
>>>>>>>
>>>>>>> ______________________________**_________________
>>>>>> wp-hackers mailing list
>>>>>> wp-hackers at lists.automattic.**com <wp-hackers at lists.automattic.com>
>>>>>> http://lists.automattic.com/**mailman/listinfo/wp-hackers<http://lists.automattic.com/mailman/listinfo/wp-hackers>
>>>>>>
>>>>>>
>>>>>> ______________________________**_________________
>>>>> wp-hackers mailing list
>>>>> wp-hackers at lists.automattic.**com <wp-hackers at lists.automattic.com>
>>>>> http://lists.automattic.com/**mailman/listinfo/wp-hackers<http://lists.automattic.com/mailman/listinfo/wp-hackers>
>>>>>
>>>> ______________________________**_________________
>>>> wp-hackers mailing list
>>>> wp-hackers at lists.automattic.**com <wp-hackers at lists.automattic.com>
>>>> http://lists.automattic.com/**mailman/listinfo/wp-hackers<http://lists.automattic.com/mailman/listinfo/wp-hackers>
>>>>
>>>>
>>>> ______________________________**_________________
>>> wp-hackers mailing list
>>> wp-hackers at lists.automattic.**com <wp-hackers at lists.automattic.com>
>>> http://lists.automattic.com/**mailman/listinfo/wp-hackers<http://lists.automattic.com/mailman/listinfo/wp-hackers>
>>>
>> ______________________________**_________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.**com <wp-hackers at lists.automattic.com>
>> http://lists.automattic.com/**mailman/listinfo/wp-hackers<http://lists.automattic.com/mailman/listinfo/wp-hackers>
>>
>>
>> ______________________________**_________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.**com <wp-hackers at lists.automattic.com>
> http://lists.automattic.com/**mailman/listinfo/wp-hackers<http://lists.automattic.com/mailman/listinfo/wp-hackers>
>
--
Aaron D. Campbell
BlueDog Web Services <http://bluedogwebservices.com>
@BlueDogWeb <http://twitter.com/BlueDogWeb>
More information about the wp-hackers
mailing list