old_lang = $sitepress->get_admin_language(); $sitepress->set_admin_language( $target_lang ); } public function __destruct() { $this->restore_lang(); } public function restore_lang () { if ( $this->old_lang ) { $this->sitepress->set_admin_language( $this->old_lang ); $this->old_lang = false; } } }