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
Menu