intraxia / jaxion

A WordPress plugin framework for modern WordPress development.
http://intraxia.github.io/jaxion/
MIT License
15 stars 3 forks source link

load_i18n() in Application.php is firing too early #8

Closed AramZS closed 7 years ago

AramZS commented 8 years ago

load_plugin_textdomain is dependent on function wp_get_current_user. That function is no longer in place early enough for when Jaxion is called at (theoretically) plugins_loaded action hook. Instead it likely best lives in the related action hook load_textdomain.

Fix in place at https://github.com/PressForward/pressforward/issues/864 is to wrap it in an add_action step, though this may not be optimal.

    /**
     * Load's the plugin's translation files.
     */
    private function load_i18n() {
        add_action( 'load_textdomain', function(){
            load_plugin_textdomain(
                $this->fetch( 'basename' ),
                false,
                basename( $this->fetch( 'path' ) ) . '/languages/'
            );
        });
    }
mAAdhaTTah commented 8 years ago

I'll probably move this into a separate class, to make sure all the hooks are registered through the Loader. Also note that $this in the closure context is invalid in PHP5.3. You've used that a couple times in PF, so if you're trying to ensure 5.3 compat, you need to avoid that usage.