woothemes/woocommerce — pull request #856 by GeertDD (2012-03-20 13:41:17+00:00)
Title: Fixed the initialisation of the language files

Discussion started in #766. As far as I tested this is working fine.

Some notes: `load_plugin_textdomain()` is now the very first call in `init`.

Only a few hooks that are executed before `init` were used. The `plugins_loaded` hook was used for initializing `WC_Shipping` and `WC_Countries`. The initialisation process for both those classes is not much more than loading all the available methods via the `woocommerce_shipping_methods` and `woocommerce_payment_gateways` filters. Moving this initialisation process to `init` should be no problem. Anything that is attached to the loading hooks will still be attached then.

The `after_setup_theme` which is execute before `init` is used for checking theme compatibility features. I think this could be moved to `init` but it doesn't have to since no translation calls are made in the `compatibility()` method.

No other pre `init` hooks are used as far as I see.

Then we have a few other classes that were constructed immediately when the plugin loaded, which is, of course, pre `init`. Those classes are `WC_Cart`, `WC_Customer` and `WC_Query`.

The `WC_Cart` constructor just loads `WC_Tax` and then binds it `init()` method to the `init` hook. Apparently it is possible to bind new stuff to the `init` while in the `init` method. This is what happens now in my update. We could as well directly call `init()` in the constructor of `WC_Cart` now. It works nevertheless.

The `WC_Customer` constructor sets up default SESSION data if needed. This can be moved to `init` without problems.

The `WC_Query` constructor only registers two filters: one for `pre_get_posts` and one for `wp`. Both are executed after `init`. So, no problem at all to move the initialisation of `WC_Query` to `init`.

That all being said, and while my change seems to work fine, I think even more stuff (if not all) can and should be moved to `init`, for example the file includes, etc.

Let me know if you have any questions. Thanks for reading! :)