dimanche 30 décembre 2018

How to mitigate server-dependent behavior for REQUEST_URI to use it to suppress a specific shortcode

I noticed something quirky regarding when I put the following line in my PHP code:

echo strpos($_SERVER['REQUEST_URI'], "/?s=");

If the following URL is entered: https://s1.temporary-access.com/~allacros/devel/?s=tahiti the echo statement returns '16'. That's expected behavior.

However, if the following URL is entered: http://stage.world-of-waterfalls.com/?s=tahiti the echo statement returns '0'.

That's unexpected behavior, and it has consequences in that I cannot seem to use the following code to suppress the shortcode that causes an erroneous button artifact caused by that shortcode for search results pages (the only case I've seen where I'm trying to rely on this)...

if( !( empty( strpos($_SERVER['REQUEST_URI'], "/?s=") ) ) )
    remove_shortcode('uwr-button');

Anyone know why this is happening? And how to fix the code so it's agnostic to the server it's on (assuming that's the issue)?

Aucun commentaire:

Enregistrer un commentaire