How to unify admin menu of the WooCommerce Email Template Customizer and 9MAIL

If you have both WooCommerce Email Template Customizer and 9MAIL, you can have admin menu of these 2 plugins shown in the same list, and with the same admin menu item. Simply add this code below regarding this instruction:

 

add_action( 'admin_menu', function () {
global $submenu;

$list_submenu = $submenu['edit.php?post_type=viwec_template'];
$ninemail = [];
$ref = [ 'edit.php?post_type=emtmpl', 'edit.php?post_type=emtmpl_block', 'emtmpl_settings', 'woocommerce-email-template-customizer-extensions' ];

foreach ( $list_submenu as $k => $data ) {
if ( isset( $data[2] ) && in_array( $data[2], $ref ) ) {
$ninemail[] = $data;
unset( $list_submenu[ $k ] );
}
}

$list_submenu = array_merge( $list_submenu, $ninemail );

$submenu['edit.php?post_type=viwec_template'] = $list_submenu;

}, PHP_INT_MAX );

add_filter( 'emtmpl_register_post_type', function ( $args ) {
$args['show_in_menu'] = 'edit.php?post_type=viwec_template';
$args['labels']['all_items'] = esc_html__( '9Mail - All Emails', '9mail-wordpress-email-templates-designer' );

return $args;
} );

add_filter( 'emtmpl_block_register_post_type', function ( $args ) {
$args['show_in_menu'] = 'edit.php?post_type=viwec_template';
$args['labels']['all_items'] = esc_html__( '9Mail - Blocks', '9mail-wordpress-email-templates-designer' );

return $args;
} );

add_filter( 'emtmpl_setting_page_parent_slug', function ( $slug ) {
return 'edit.php?post_type=viwec_template';
} );