If someone still needs to add the frontend header and footer to the backend, maybe this can help:
add_action( 'in_admin_header',function(){
remove_all_actions( 'admin_notices' );
?>
<style id="admin-in-header-css">
html{
margin:0 !important
}
#wpadminbar,
#adminmenumain,
#wpfooter,
#footer-upgrade+div,
#footer-left,
#footer-upgrade{
display: none !important;
}
#wpcontent, #wpfooter {
margin-left: 0;
margin-right: 0;
padding-left: 0;
padding-right: 0;
}
</style>
<?php
ob_start();
get_header();
if( class_exists( 'WPBMap' ) ){
WPBMap::addAllMappedShortcodes(); //Just in case you hvve WPBakery page builder
}
$frontend_header = ob_get_clean();
echo do_shortcode( str_replace( '<html','<div',str_replace( '<body','<div',$frontend_header ) ) );
?>
<style id="admin-after-head-css">
html{
margin:0 !important
}
</style>
<?php
} );
add_action( 'in_admin_footer',function(){
add_filter( 'admin_footer_text','__return_empty_string' );
add_filter( 'update_footer','__return_empty_string' );
ob_start();
get_footer();
if( class_exists( 'WPBMap' ) ){
WPBMap::addAllMappedShortcodes(); //Just in case you have WPBakery pagebuilder
}
$frontend_footer = ob_get_clean();
echo do_shortcode( str_replace( '</html>','',str_replace( '</body>','</div>',$frontend_footer ) ) );
} );
It's not possible to do it in a clean way because we are trying to do something a little dirty here, but I think this is a good compromise between dirtiness and the goal we want to reach.
All that we can remove via PHP we remove it via PHP, the rest will be hidden with some dirty CSS.
I've assigned two times a zero top margin to the HTML element because the first time it has to be parsed just before the first rendering, and the second time it has to override the margin added by the core that arrives later during the rendering. If you add it only one time you will see a layout shift during the rendering.
I replaced <body,<html,, and to prevent double opening and closing tags (added by the core and the theme).
As said, this is a dirty solution, but it should work with most themes.