Last active
December 31, 2015 04:29
-
-
Save mannieschumpert/7934810 to your computer and use it in GitHub Desktop.
Optionally enqueue LiveReload for local development.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Enqueue LiveReload if local install | |
* | |
* Assumes livereload.js is in the root folder of your local site | |
* | |
* This should be fairly reliable, | |
* but may need to be changed for some environments | |
*/ | |
if ( $_SERVER['REMOTE_ADDR'] === '127.0.0.1' ){ | |
add_action( 'wp_enqueue_scripts', 'enqueue_livereload' ); | |
} | |
function enqueue_livereload(){ | |
wp_enqueue_script( 'livereload', site_url().'/livereload.js', '', NULL ); | |
} |
I was able to fix my issue by changing site_url()
to home_url()
Cool. Sorry I missed this.
Yeah, what site_url
and home_url
reference does indeed depend on individual installation configurations.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm having a slight issue with this. I have livereload.js in the root folder, however when I view source, it's looking for it at /wordpress.
I am thinking that it might be the semi-non-standard way I have wordpress installed:
root
...
I'm not exactly sure if that's the problem or not. Any ideas?