I am using LiveReload to refresh my browser and compile my SASS. The browser extensions are not working so well for me, so I am adding the script to my footer. I'm trying to think of a way to prevent the function that adds it from running if it is on a live web server opposed to my local production environment XAMPP (in OSX 10.6.8).

This is what I have now:

if (! function_exists('_sf_live_reload') && ! is_admin() ) :
function _sf_live_reload() { ?>
<script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script>
add_action('tha_body_bottom', '_sf_live_reload');

Yes, I know I could just remember to manually delete it before uploading, but lets assume I forge things from time to time. Plus deleting and recreating this over and over again isn't the best solution anyway.

1 Answer 1

$whitelist = array('');

if(!in_array($_SERVER['REMOTE_ADDR'], $whitelist)){
// not valid

For more info on how it works. https://stackoverflow.com/questions/1634782/what-is-the-most-accurate-way-to-retrieve-a-users-correct-ip-address-in-php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.