Both sentences are grammatically correct so you have to decide on the meaning.
For the first question, if someone told you that he would come, but he didn’t, then you probably say “I wish he would be here”. On the other hand if you think it is impossible for him to be here now, you say " Iwish he were here."
The other questions can be explained by this way, too. The difference is in the meaning.
Love,
Aydın
Hi again, Lost soul,
For the second question; both are unreal situation for now and future;
Someone will be leaving in a short time and you say “I wish he wouldn’t be leaving.”
Someone is leaving now and you say “I wish he weren’t leaving.”
For the third question;both are unreal situations for past;
Someone would have known it if he had been taught, but he hadn’t been taught so he couldn’t know it and you say “I wish he would have known it.”
Someone didn’t know something you asked to him and you say “I wish he had known it.”
I hope this helps you get the idea of WISH.
Love,
Aydın