<?php defined('ABSPATH') || exit; class WC_Meta_Data implements JsonSerializable { protected $current_data; protected $data; public function __construct($meta = array()) { $this->current_data = $meta; $this->apply_changes(); } public function jsonSerialize() { return $this->get_data(); } public function apply_changes() { $this->data = $this->current_data; } public function __set($key, $value) { $this->current_data[$key] = $value; } public function __isset($key) { return array_key_exists($key, $this->current_data); } public function __get($key) { if (array_key_exists($key, $this->current_data)) { return $this->current_data[$key]; } return null; } public function get_changes() { $changes = array(); foreach ($this->current_data as $id => $value) { if (!array_key_exists($id, $this->data) || $value !== $this->data[$id]) { $changes[$id] = $value; } } return $changes; } public function get_data() { return $this->data; } }