Skip to content

Instantly share code, notes, and snippets.

@JulioPotier
Created April 27, 2019 20:22
Show Gist options
  • Save JulioPotier/0d1e4a011213b0d34f7e25ee3adbc552 to your computer and use it in GitHub Desktop.
Save JulioPotier/0d1e4a011213b0d34f7e25ee3adbc552 to your computer and use it in GitHub Desktop.
Compatibilité de la fonction wp_open_body() pour tous les thèmes
add_action( 'get_header', 'baw_wp_body_open_buffer' );
function baw_wp_body_open_buffer() {
ob_start();
do_action( 'wp_body_open' );
$wp_body_open_content = ob_get_clean();
ob_start( function( $buffer ) use( $wp_body_open_content ) {
return preg_replace( '(<body.*>)', "$0\n$wp_body_open_content", $buffer );
} );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment