Use a PHP 5.2 compatible approach for creating new instances of

shipping methods which were registered using an instance
This commit is contained in:
Allen Snook 2016-02-25 11:56:05 -08:00
parent 1ea53460f2
commit bdb816f83b
2 changed files with 5 additions and 1 deletions

View File

@ -231,7 +231,8 @@ class WC_Shipping_Zone implements WC_Data {
// as classes. If the "class" is an instance, just use it. If not,
// create an instance.
if ( is_object( $class_name ) ) {
$methods[ $raw_method->instance_id ] = new $class_name( $raw_method->instance_id );
$class_name_of_instance = get_class( $class_name );
$methods[ $raw_method->instance_id ] = new $class_name_of_instance( $raw_method->instance_id );
} else {
// If the class is not an object, it should be a string. It's better
// to double check, to be sure (a class must be a string, anything)

View File

@ -93,6 +93,9 @@ class WC_Shipping_Zones {
if ( in_array( $raw_shipping_method->method_id, array_keys( $allowed_classes ) ) ) {
$class_name = $allowed_classes[ $raw_shipping_method->method_id ];
if ( is_object( $class_name ) ) {
$class_name = get_class( $class_name );
}
return new $class_name( $raw_shipping_method->instance_id );
}
return false;