Created
April 27, 2019 20:22
-
-
Save JulioPotier/0d1e4a011213b0d34f7e25ee3adbc552 to your computer and use it in GitHub Desktop.
Compatibilité de la fonction wp_open_body() pour tous les thèmes
This file contains 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
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