PHP Fatal error: Cannot redeclare jr_mt_query_chars()

[ad_1]

PHP Fatal error: Cannot redeclare jr_mt_query_chars() (previously declared in \wp-content\plugins\jonradio-multiple-themes\includes\admin-validate.php:268)

This happens when switching and submitting another theme in the dropdown next to Select Theme for Site Home.

jr_mt_query_chars() is declared inside jr_mt_validate_settings() which isn’t a good practice in general as the code could become finicky. jr_mt_validate_settings() seems gets called twice somewhere, so the declaration happens twice, hence the fatal error.

A way to workaround this is by making jr_mt_query_chars() as a variable to an anonymous function:$jr_mt_query_chars = function() {}

Another thing noticed were many php warnings from input elements that had not been set. For example:
PHP Warning: Undefined array key "add_path_id" in \includes\admin-validate.php on line 114

So said code in line 114:
$url = jr_mt_sanitize_url( $input['add_path_id'] ); .
It could be tweaked like this instead:
$url = jr_mt_sanitize_url( $input['add_path_id'] ?? '' );

 

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