2ndkauboy / textdomain-overwrite

A simple plugin which enables a user to overwrite localization string from the WordPress core, plugins and themes, using it's own language files
GNU General Public License v3.0
28 stars 5 forks source link

Shouldn't the hook be handled separately for Plugins and Themes? #1

Closed Zodiac1978 closed 11 years ago

Zodiac1978 commented 11 years ago

Any calls to load_plugin_textdomain should be in a function attached to the “plugins_loaded” action hook. Any calls to load_theme_textdomain should be in a function attached to the “after_setup_theme” action hook. Quoted from: http://ottopress.com/2013/language-packs-101-prepwork/

Is this maybe a problem if you are using plugins_loaded for themes too?

2ndkauboy commented 11 years ago

I don't think that it's a problem. I tried to keep the plugin as simple and as readable as possible. There is an inconsistence in the params and the paths to the files in the load__textdomain() functions. As all functions internally call the load_textdomain() function, I decided not to use all special versions of those function (actually my first version of the plugin was trying to use the special load__textdomain() functions). It was also necessary to avoid function like load_theme_textdomain() as otherwise you would have to place you own language files within the theme folders. But than updating the theme would delete those files.

Regarding the filter: I wanted to make sure, that the files are loaded, before all other language files, as newer files are merged for the same textdomain, but they don't overwrite existing strings. As the plugins_loaded filter is trigged before all load*_textdomain calls, I thought this would be the perfect one to hook into. Sure I could have split up the loading into three three functions and call them just before each individual action hook, but as I said, I wanted to keep the plugin as simple and readable as possible, without messing it up too much.

But if you are not happy with my solution, please feel free to send me a push request (or some improved version via gist or mail). I want this plugin to be nice and stable before submitting it to the WordPress plugin repo (I might also turn it into a class, and with a less conflicting function/class name).

Zodiac1978 commented 11 years ago

I am not in plugin programming like you. I just saw your source code and I remembered the quote from Otto. It makes perfectly sense what you have written. I just wanted to help and I were curious why you did it. Now I know. :) So feel free to close this issue.