Forum Replies Created

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter v4ssi

    (@v4ssi)

    Perfect, thank you for your answer, i will wait. 🙂

    I want share my problem and solution.
    Today i’ve discovered that my meta description and all other SEO string were not changing with the language of the page.
    They were set correctly, polylang was able to get them with a manually test (ex: pll__(__(‘test var’)).
    So wpml-compat.php line 362 was doing all correctly.

    I’m gone to check if the problem was SEO by Yoast and apparently i was a bit confused because testing class-frontend.php and checking get_wpseo_options() and metadesc() the array was in the default language and for no reason was the right language.. anyway…to make a long story short i’ve set in polylangs->settings->url modifications->”The language code, for example /en/, is added to all urls when using pretty permalinks.” than i’ve re-saved in settings->permalinks and all was working good.

    While i was finishing this post i’ve checked for the 1000 times the documentation of polylang and i’ve found this sentence “For example, it is recommended to use the second option when running Polylang together with WordPress SEO by Yoast.”

    In my humble opinion it’s better add this thing to the FAQ:
    I’ve installed SEO by Yoast but the custom strings are not working properly
    Answer with the solution above.

    I hope this will save someone. ^^
    As usual sorry for my English.

    p.s.
    I’ve added here this post because is similar to this thread and this other old thread

    I’ve found the solution of the second problem.
    Just add in functions.php this line:

    add_filter('widget_text', 'pll__', 1);

    That i’ve taken from core.php line 117.

    Thank you again Chouby.

    I was not far when i tried alone but not enough near. 😀
    I tried to debug the code for 3 hours, like a dumb, because the server gave to me “internal server error 500 “.
    Also if loggin was active, wordpress and server too weren’t new log.

    Anyway i found the problem and fixed it. Thanks you so much Chouby. ^^

    add_filter('pll_get_strings', 'add_widget_text');
    function add_widget_text($strings) {
    	global $wp_registered_widgets;
    	$sidebars = wp_get_sidebars_widgets();
    
    	foreach ($sidebars as $sidebar => $widgets) {
    		if ($sidebar == 'wp_inactive_widgets' || !isset($widgets))
    			continue;
    
    		foreach ($widgets as $widget) {
    			if (!isset($wp_registered_widgets[$widget]['callback'][0]) || !is_object($wp_registered_widgets[$widget]['callback'][0]) || !method_exists($wp_registered_widgets[$widget]['callback'][0], 'get_settings'))
    				continue;
    
    			$widget_settings = $wp_registered_widgets[$widget]['callback'][0]->get_settings();
    			$number = $wp_registered_widgets[$widget]['params'][0]['number'];
    
    			if (isset($widget_settings[$number]['text']) && $text = $widget_settings[$number]['text'])
    				$strings[] = array('name' => 'Widget text', 'string' => $text, 'context' => 'Widget', 'multiline' => true);
    		}
    	}
    	return $strings;
    }

    add_filter instead of add_filters
    And i added the names to the array keys.

    They are added at the end of the pages but whocares. ^^

    Update:
    If i edit the text the query works but in the frontend the widget remain with the “default” language.
    I think that the problem is the widget option “The widget is displayed for: All languages” that if turned ON override the visualization of the translation and if it’s turned OFF hide the widget for the other language.

    10 month old … the fix work..

    Hello Chouby, thank you for you attention.

    I need to have the possibility to modify the “widget-text content” from strings-translations of your awesome plugin.
    And the code that jussi.r wrote it’s good but force me to change the function directly into the plugin files, that i don’t want do.

    I tried to achieve this result using hooks/override but today i’m really stunned and i don’t arrive to my objective.

    And i don’t want use forking/svn too.

    Thank you.

    p.s.
    Sry for my english.

    Sorry for necroposting.
    How is possible get the last solution without change the admin.php ?
    I tried to understand how do it with hooks/override on functions.php but i’m not getting any point.

    No news about the bug with the Yoast Sitemap?
    Ty anyway.

Viewing 8 replies - 1 through 8 (of 8 total)