Is your forum working in a genuine RTL environment (i.e. as shown for Hebrew or Arabic) or in an LTR environment with a few RTL writings?
My forum is working in LTR environment. I've only added a 'Category' for Hebrew readers, and for this specific category I really need the RTL BBcode feature; as well as for adding some Hebrew text inside English posts.
In the first case you can alter the main template and set
<html dir="rtl">for the whole document. For the second case your proposal is comprehensible but not complete. The script also has to be aware of RTL main language of the forum page and LTR writings within it.
To be honest, <div dir="rtl"> & <span dir="rtl"> is more then enough. It works perfectly inside LTR documents as we can see in the example:
I do not need RTL environment such as:
<!DOCTYPE html> <html lang="he"> <body dir="rtl"> etc.
since the main forum language is English.
The main reason for using dir="rtl" is to be able to add Latin letters inside RTL text - without scrambling the entire sentence (which is currently the obvious case).
There is no need for "perfect" support for RTL languages, as far as I concerned.
I don't know what it means from the PHP and CSS perspective of the forum, but it worth doing a little test I guess.
Please let me know if I can help somehow.
this is an example for a Hebrew post, where I really need a BBcode for RTL: