add_filter in functions.php of child theme is suggested on the internet but breaks my site on php 8 specifically. What is the issue here?

[ad_1]

In the functions.php of my Child Theme I have the following lines:

//Elementor - disable Google Fonts
 add_filter( 'elementor/frontend/print_google_fonts', '__return_false' );
 add_filter( 'elementor/fonts/additional_fonts', '__return_false' );

I've found this solution on various posts on the Internet.

Now the thing is: This works only on php7.

On PHP 8 it breaks my site.

Why is this and what can I do to resolve this?

Thanks in advance.

edit: The error is thrown: /root/wp-content/plugins/elementor-pro/modules/assets-manager/asset-types/fonts-manager.php on line 342 and the according snippet is:

return array_replace( $custom_fonts, $fonts );

in the block:

    public function register_fonts_in_control( $fonts ) {
        $custom_fonts = $this->get_font_types();
        if ( empty( $custom_fonts ) ) {
            $this->generate_fonts_list();
            $custom_fonts = $this->get_font_types();
        }

        return array_replace( $custom_fonts, $fonts );
    }

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer