PHP Fatal error: Cannot redeclare jr_mt_query_chars()
-
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 insidejr_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'] ?? '' );
- You must be logged in to reply to this topic.