Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

Add Browsersync Refresh on WordPress save #25

Open
renestalder opened this issue Apr 28, 2015 · 3 comments
Open

Add Browsersync Refresh on WordPress save #25

renestalder opened this issue Apr 28, 2015 · 3 comments

Comments

@renestalder
Copy link
Contributor

Browsersync have got a new API since v2.6.0. It enables to inject custom reloading which makes it possible to reload on database changes.

/* PHP pseudo codez */
add_action( 'save_post', function() {
    http_get("http://localhost:3000/__browser_sync__?method=reload");
});
@xarem
Copy link
Member

xarem commented Apr 28, 2015

good idea!

Attention:

  • must only trigger again if the first query to localhost:3000 was successful
  • must only trigger if WP Debug is enabled

@renestalder
Copy link
Contributor Author

Also attention on the fact, that the port of localhost could differ. It can change whenever a second browsersync instance is running.

@xarem
Copy link
Member

xarem commented Apr 28, 2015

On the initialisation callback of BrowserSync we could get urls + port and write them to a custom json file in the wordpress root directory which is in the gitignore: http://www.browsersync.io/docs/api/#api-cb

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants