Created
May 14, 2015 02:18
-
-
Save fastmover/72878a1303d8c5b61c12 to your computer and use it in GitHub Desktop.
Live Reload Theme functions for Wordpress and Grunt-contrib-watch
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 | |
| function removePortFromURL ( $url = false ) | |
| { | |
| if ( ! $url ) { | |
| return false; | |
| } | |
| $url = rtrim ( $url, '/' ); | |
| $url = rtrim ( $url, ':' ); | |
| $urlNoHTTP = substr ( $url, 0, -strpos ( $url, ':' ) ); | |
| if ( false !== strpos ( $urlNoHTTP, ':') ) { | |
| $url = substr ( $url, 0, strrpos ( $url, ':' ) ); | |
| } | |
| return $url; | |
| } | |
| function liveReload( $dev ) { | |
| if ( true === $dev ) { | |
| $url = removePortFromURL (); | |
| ?> | |
| <script src="<?= $url; ?>:35729/livereload.js"></script> | |
| <?php | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment