public function __construct($scripts = '') { $this->old_scripts = empty($scripts) || !$scripts instanceof WP_Scripts ? new WP_Scripts() : $scripts; // Unset all the object properties except our private copy of the // scripts object. We have to unset everything so that the overload // methods talk to $this->old_scripts->whatever instead of $this->whatever. foreach (array_keys(get_object_vars($this)) as $key) { if ('old_scripts' === $key) { continue; } unset($this->{$key}); } parent::__construct(); }