|
@@ -188,15 +188,24 @@ function dw_ask_widget() {
|
|
|
}
|
|
}
|
|
|
add_action( 'wp_footer', 'dw_ask_widget' );
|
|
add_action( 'wp_footer', 'dw_ask_widget' );
|
|
|
|
|
|
|
|
-// Dev only: on a real post/page save (Gutenberg "Update"), touch a sentinel file that
|
|
|
|
|
-// BrowserSync watches, so the front-end preview reloads — DB content changes aren't
|
|
|
|
|
-// visible to a filesystem watcher otherwise. Gated to WP_DEBUG → no-op in production.
|
|
|
|
|
-function dw_bs_reload_on_save( $post_id ) {
|
|
|
|
|
- if ( ! ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ) return;
|
|
|
|
|
- if ( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) ) return;
|
|
|
|
|
- @touch( get_template_directory() . '/.bs-reload' );
|
|
|
|
|
|
|
+// Dev only: on a real content save, ping BrowserSync's reload endpoint so the front-end
|
|
|
|
|
+// preview refreshes — DB content changes aren't visible to a filesystem watcher otherwise.
|
|
|
|
|
+// Hooks the REST save events the block editor actually fires (+ customizer + nav menus).
|
|
|
|
|
+// Gated to WP_DEBUG → no-op in production.
|
|
|
|
|
+if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
|
|
|
|
|
+ function dw_bs_reload_on_save( $post = null ) {
|
|
|
|
|
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
|
|
|
|
|
+ if ( $post && is_object( $post ) && $post->post_status === 'auto-draft' ) return;
|
|
|
|
|
+ wp_remote_get( 'https://daw.stu:81/__browser_sync__?method=reload', array(
|
|
|
|
|
+ 'blocking' => false,
|
|
|
|
|
+ 'sslverify' => false,
|
|
|
|
|
+ ) );
|
|
|
|
|
+ }
|
|
|
|
|
+ add_action( 'rest_after_insert_page', 'dw_bs_reload_on_save', 10, 3 );
|
|
|
|
|
+ add_action( 'rest_after_insert_post', 'dw_bs_reload_on_save', 10, 3 );
|
|
|
|
|
+ add_action( 'customize_save_after', 'dw_bs_reload_on_save', 10, 3 );
|
|
|
|
|
+ add_action( 'wp_update_nav_menu', 'dw_bs_reload_on_save', 10, 3 );
|
|
|
}
|
|
}
|
|
|
-add_action( 'save_post', 'dw_bs_reload_on_save' );
|
|
|
|
|
|
|
|
|
|
add_action('wp_footer', 'dw_analytics', 22);
|
|
add_action('wp_footer', 'dw_analytics', 22);
|
|
|
function dw_analytics() { ?>
|
|
function dw_analytics() { ?>
|