What is the grammar of "please," please?

Yes. Or when you’re talking to your boss, you say:

I was wondering if I could have tomorrow off.

instead of

I’m wondering if I can have tomorrow off.

In general, form, function and meaning are part of one package, and they determine each other. But with the particular case of please, it really doesn’t modify anything propositionally, so labeling it as an “adverb” is kind of pointless. Yes, it behaves kind of like an adverb syntactically, but to identify it as such is really only useful for satisfying a high school English teacher.

A much more helpful way to describe it is as an affective discourse marker, such as in this paper.

It’s also useful when teaching English as a Foreign Language (to help students understand where in the sentence to use the word) or when teaching how to use punctuation. I honestly don’t see how please is a special case.