• Resolved Mad Max

    (@mad_max)


    I’ve got a multilanguage site with WPML and when I choose to “Show on checked pages” a widget, and check the front page and a language only, I would expect this widget to be visible on the front page AND in the selected language, and hidden on all pages of every other language.

    It shows instead on every languages, even if on front page only.

    So I double checked the logic in the function show_widget an found a glitch on line 147: the function checks for WPML language stuff ONLY if $show is false (i.e. if you chose “Show on checked pages” and then select only one or more languages), but in the case above, $show is always TRUE on front page, regardless of the current language.

    I’ve patched the code between lines 159 and 169 from:

    if ( ( $instance['dw_include'] && false == $show ) || ( 0 == $instance['dw_include'] && $show ) ) {
    		return false;
    	} else {
    		$user_ID = is_user_logged_in();
    		if ( ( 'out' == $instance['dw_logged'] && $user_ID ) || ( 'in' == $instance['dw_logged'] && !$user_ID ) ) {
    		return false;
    		}
    	}

    to

    if ( ( $instance['dw_include'] && false == $show ) || ( 0 == $instance['dw_include'] && $show ) ) {
    		return false;
    	}elseif($instance['dw_include'] && $show && !isset($instance['lang-'. ICL_LANGUAGE_CODE])){
    		//if the widget has to be visible here, but the current language has not been checked, return false
    		return false;
    	} else {
    		$user_ID = is_user_logged_in();
    	if ( ( 'out' == $instance['dw_logged'] && $user_ID ) || ( 'in' == $instance['dw_logged'] && !$user_ID ) ) {
    		return false;
    	}

    I’m using Wp 3.9.1 with WPML 3.1.5 and Display widgets 2.0.3

    https://wordpress.org/plugins/display-widgets/

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show on one language, doesn't hide widget for the others languages’ is closed to new replies.