It is invalid to add suffix to page .html in wp subtheme.

I put the following code in the fuction.php file in the xxx- child theme folder. It doesn"t work, but it works in the parent theme.
I want to put it in a child theme, so as not to add this code to upgrade the parent theme. Excuse me, where does it need to be changed?

<?php
// html
add_action("init", "html_page_permalink", -1);
function html_page_permalink() {
    global $wp_rewrite;
    if ( !strpos($wp_rewrite->get_page_permastruct(), ".html")){
        $wp_rewrite->page_structure = $wp_rewrite->page_structure . ".html";
    }
}
//
function nice_trailingslashit($string, $type_of_url) {
    if ( $type_of_url != "single" && $type_of_url != "page"&& $type_of_url != "paged"&& $type_of_url != "single_paged" )
      $string = trailingslashit($string);
    return $string;
}
add_filter("user_trailingslashit", "nice_trailingslashit", 10, 2);

?>
Jan.21,2022
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b366e9-343c2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b366e9-343c2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?