WC_Data::__clone
When the object is cloned, make sure meta is cloned correctly.
Meta ID handling depends on the clone mode:
- CLONE_MODE_DUPLICATE (default): Forces reading of Meta and clears meta IDs for duplication (backward compatible).
- CLONE_MODE_CACHE: Preserves meta IDs for caching purposes.
Метод класса: WC_Data{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$WC_Data = new WC_Data(); $WC_Data->__clone();
Список изменений
| С версии 3.0.2 | Введена. |
Код WC_Data::__clone() WC Data:: clone WC 10.5.0
public function __clone() {
if ( self::CLONE_MODE_DUPLICATE === $this->clone_mode ) {
$this->maybe_read_meta_data();
}
if ( ! empty( $this->meta_data ) ) {
foreach ( $this->meta_data as $array_key => $meta ) {
$this->meta_data[ $array_key ] = clone $meta;
// Only clear meta IDs in duplicate mode (maintains backward compatibility).
if ( self::CLONE_MODE_DUPLICATE === $this->clone_mode && ! empty( $meta->id ) ) {
$this->meta_data[ $array_key ]->id = null;
}
}
}
}