I need to create custom header for my WordPress theme. But I need to do it via plugin. Something like I have prebuild header in my plugin. I need to set it to header and I need to remove theme default header.
I research everywhere but I couldn't find any resource for this.
Please use the below code to load the header from plugin.
add_action('get_header', function(){
require PLUGIN_DIR.'includes/templates/header.php';
$templates = [];
$templates[] = 'header.php';
remove_all_actions( 'wp_head' );
ob_start();
locate_template( $templates, true );
ob_get_clean();
});