WordPress.org

Ready to get started?Download WordPress

Forums

WordPress SEO by Yoast
Please put the 'load_plugin_textdomain' on 'init&amp (4 posts)

  1. Yakir Sitbon
    Member
    Posted 1 year ago #

    Hey guys.

    I just want ask, Why do not put load_plugin_textdomain() in 'init' action?

    We are using with polylang plugin for I18n, and we can't use with your plugin..

    In polylang, the lang changed on 'init' action (priority 5 if i remember right), and all setup lang before this, just not work.

    Please fix this for our ppl :)

    Thanks you
    Yakir.

    Polylang url: http://wordpress.org/extend/plugins/polylang/

    http://wordpress.org/extend/plugins/wordpress-seo/

  2. Chouby
    Member
    Posted 1 year ago #

    I already made the same request some months ago
    http://wordpress.org/support/topic/plugin-wordpress-seo-by-yoast-wordpress-seo-and-multilingual-plugins?replies=1

    As far as I know, the way WordPress SEO is written should break *all* multilingual plugins, not only Polylang. I tested with WP Native Dashboard and qtranslate too. And although WPML and WordPress SEO claim to be 100% compatible, I am quite sure that WPML does not load the right text domain, except of course if it reloads it as proposed below.

    So currently, the only solution I can propose waiting for @joostdevalk to modify his plugin is to reload the wordpress-seo texdomain in a function hooked (for example) to 'init':

    add_action ('init', 'reload_wp_seo_text_domain');
    function reload_wp_seo_text_domain {
      unload_textdomain('wordpress-seo'); // mandatory !
      load_plugin_textdomain( 'wordpress-seo', false, '/wordpress-seo/languages' );
    }

    Not very good for performance as it is loaded two times, but this seems to work with Polylang. I did not check with other multilingual plugins.

  3. entr
    Member
    Posted 1 year ago #

    Same problem here. Thanks Chouby for pointing me into that direction. Here is a fix that doesn't load locale file twice. We override the Wp-Seo's call when it's called before 'plugins_loaded' action.

    function reload_wp_seo_text_domain() {
      load_plugin_textdomain( 'wordpress-seo', false, '/wordpress-seo/languages' );
    }
    add_action ('plugins_loaded', 'reload_wp_seo_text_domain');
    
    function override_wp_seo_load_textdomain( $return, $domain ) {
    	if ( $domain == 'wordpress-seo' && ! did_action( 'plugins_loaded' ) ) {
    		return true;
    	}
    	return $return;
    }
    add_filter( 'override_load_textdomain', 'override_wp_seo_load_textdomain', 10, 2 );

    For that to work with theme's function.php you should probably use the 'init' action but for mu-plugins this works best.

  4. entr
    Member
    Posted 1 year ago #

    Is it possible that get put to the good standard and loaded at 'init' or 'plugins_loaded' at least. Thanks.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic