Forum Replies Created
-
AuthorPosts
-
William Gregorio
ParticipantHere is the private function within the backticks format
private function change_input_file( &$field ) { $field['type'] = ( $field['type'] === 'file' || $field['type'] === 'image' ) ? $field['type'] . '_advanced' : $field['type']; if ( 'group' === $field['type'] && isset($field['fields']) && is_array($field['fields']) && count($field['fields']) > 0 ) { array_walk( $field['fields'], [ $this, 'change_input_file' ] ); } }William Gregorio
ParticipantWhen using the Meta Box settings page plugin with WordPress, a critical error may occur due to saving fields without specifying values. This can lead to a fatal error when the count() function is called on a null value within the Manager.php file of the plugin. The problem I believe occurs because the code is trying to count something that isn't there, leading to a crash.
Error frontend: There has been a critical error on this website.
Learn more about troubleshooting WordPress.Error backend: Warning: Undefined array key "fields" in /home/directory/public_html/wp-content/plugins/mb-core/vendor/meta-box/mb-settings-page/src/Customizer/Manager.php on line 36
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /home/directory/public_html/wp-content/plugins/mb-core/vendor/meta-box/mb-settings-page/src/Customizer/Manager.php:36For temporary purposes, I switched the function to:
private function change_input_file( &$field ) {
$field['type'] = ( $field['type'] === 'file' || $field['type'] === 'image' ) ? $field['type'] . '_advanced' : $field['type'];if ( 'group' === $field['type'] && isset($field['fields']) && is_array($field['fields']) && count($field['fields']) > 0 ) {
array_walk( $field['fields'], [ $this, 'change_input_file' ] );
}
}You will need shell access and wp-cli, this was only because I could not get in at all, nor could I deactivate the plugin within the shell with wp-cli, after you are back in, then just delete the issue within the GUI, insert the original private function back, and your back, hopefully, this can help someone in the future.
-
AuthorPosts