Same here! I’ve used this plugin exactly the same way for years, and suddenly all errors.
Here some thoughts to correct the error.
The error is with PHP version < 5.3.
The get_called_class function is not working because methods of the RWMB_Field classes are used statically so $t[‘object’] (line 53) is never set.
So we want to do some late static binding.
It’s in the file /wp-content\plugins\meta-box\inc\common.php.
I’m working on it, stay tuned 🙂
I’ve come to a fix which requires a small refactoring.
Here is the steps to apply the fix:
1- insert the following method at the end of the RWMB_Field class in the file
/wp-content\plugins\meta-box\inc\field.php
static function get_method_callback($field, $method)
{
if (version_compare(PHP_VERSION, '5.3') >= 0)
return array(get_called_class(), $method);
return array(RW_Meta_Box::get_class_name($field), $method);
}
2- Replace all call_user_func
calls in this RWMB_Field class.
call_user_func( array( get_called_class()
with
call_user_func( self::get_method_callback($field
3- Test!
If you still have “Warning: call_user_func(Array)”, it’s maybe because the type chosen for the field doesn’t exists.
The bug is also occurring when a type contains the dash (-) character.
To fix the bug edit the following file :
/wp-content\plugins\meta-box\inc\meta-box.php:398
Replace
$_type = str_replace( '_', ' ', $field['type'] );
with
$_type = str_replace( array('_', '-'), ' ', $field['type'] );
Thread Starter
MissHD
(@misshd)
Thank you a lot ! It’s perfect. 🙂
@esoterick You are just awesome. Thanks for the fix.
The bug has been fixed in version 4.3.8.
Careful however, the RW_Meta_Box::get_class_name method is still buggy if you use a type that contains dashes (like select-advanced or checkbox-list).
To fix this bug:
/wp-content\plugins\meta-box\inc\meta-box.php:396
Replace
$_type = str_replace( '_', ' ', $field['type'] );
with
$_type = str_replace( array('_', '-'), ' ', $field['type'] );
Dear Esoterick , I want to use RWMB_Field in php version 5.2.pls help me
Dear Thanchay,
If you download the latest version of Meta Box you will only have to replace
Replace
$_type = str_replace( ‘_’, ‘ ‘, $field[‘type’] );
with
$_type = str_replace( array(‘_’, ‘-‘), ‘ ‘, $field[‘type’] );
in the following file
/wp-content\plugins\meta-box\inc\meta-box.php:396
rilwis has fixed the PHP 5.2 version in the 4.3.8 version.
Basically, he gets the class name in the following file
wp-content\plugins\meta-box\inc\field.php:32
and use it for every call_user_func.
Regards