• Resolved kg69design

    (@kg69design)


    The script that puts lang value in search form is the reason of validation errors as XHTML 1.0 Transitional. To fix it just add <![CDATA[” … “//]]> around it in wp-content\plugins\polylang\include\core.php on line 453. Instead of:

    echo "<script type='text/javascript'>" .$js. "</script>";

    replace with:

    echo "<script type='text/javascript'>//<![CDATA[" .$js. "//]]></script>";

    And, of course, it will be good if we have an option to switch this option off if we do not use search form.

    Thanks for cool plugin.

    https://www.ads-software.com/extend/plugins/polylang/

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter kg69design

    (@kg69design)

    Sorry, had a mistake in my previous fix code. To fix validation issue you have to change in wp-content\plugins\polylang\include\core.php on line 434-453. Instead of:

    $js = "
    e = document.getElementsByName('s');
    for (i = 0; i < e.length; i++) {
    	if (e[i].tagName.toUpperCase() == 'INPUT') {
    		s = e[i].parentNode.parentNode.children;
    		l = 0;
    		for (j = 0; j < s.length; j++) {
    			if (s[j].name == 'lang') {
    				l = 1;
    			}
    		}
    		if ( l == 0) {
    			var ih = document.createElement('input');
    			ih.type = 'hidden';
    			ih.name = 'lang';
    			ih.value = '$lang';
    			e[i].parentNode.appendChild(ih);
    		}
    	}
    }";

    replace with:

    $js = "//<![CDATA[
    e = document.getElementsByName('s');
    for (i = 0; i < e.length; i++) {
    	if (e[i].tagName.toUpperCase() == 'INPUT') {
    		s = e[i].parentNode.parentNode.children;
    		l = 0;
    		for (j = 0; j < s.length; j++) {
    			if (s[j].name == 'lang') {
    				l = 1;
    			}
    		}
    		if ( l == 0) {
    			var ih = document.createElement('input');
    			ih.type = 'hidden';
    			ih.name = 'lang';
    			ih.value = '$lang';
    			e[i].parentNode.appendChild(ih);
    		}
    	}
    }
    //]]>";

    Idea is the same, but I placed it in wrong place.

    Thread Starter kg69design

    (@kg69design)

    Is anybody here?

    Yes but what is your question ? ^^

    Thread Starter kg69design

    (@kg69design)

    I just was hoping on some sort of feedback from the author, because it is unclear whether he saw this or not.

    Chouby is active but he develop PolyLang for free. May be we can accept to have ours requests in waiting for few days ??

    Thread Starter kg69design

    (@kg69design)

    Yes, you are right.

    Plugin Author Chouby

    (@chouby)

    I cannot connect often these days. Thank you for sharing the correction. I do not see the difference between the wrong and the good one though.

    Thread Starter kg69design

    (@kg69design)

    1. Thanks for the reply. The difference between the wrong and the good one:.

    If you add CDATA like these, the whole script will be comment and it will not work.

    echo "<script type='text/javascript'>//<![CDATA[" .$js. "//]]></script>";

    So, you need to add “//<![CDATA[” and “//]]>” from new lines.

    2. I also found a strange behavior (may be this is in my particular case), but if add to my template’s file something like this:

    <?php echo (category_description()) ? '<div>'.category_description().'</div>' : '' ?>

    I’ll get an output of current locale (e.g. “en_EN”) if category description is empty.

    And in rss feed instead of category name I have current language name.

    3. And one more thing. I have no opportunity to donate but if i can help to your project in any way I will be glad (testing, graphic design, translation (Russian and Ukrainian)).

    Thread Starter kg69design

    (@kg69design)

    And one more thing that I found. I’m trying to install some plugin for mailing (with subscription). I tried 4 or 5 of them (Mailz, MailPress, Wysija Newsletters and so on) and everytime I have one problem – confirmation page. The link to this page generated by all these plugins with parameters like these:

    https://gplants.kg69design.com/wysijap/subscriptions/?wysija-page=1&controller=confirm&wysija-key=7a76b337ea6e6436849935dd883b1959&action=subscribe&wysijap=subscriptions

    But this page is always 404 Not found. In all these plugins. So, I suggested that in that case lang parameter is missing and I add it manually in one of these plugins core code, so now everything seems to be fine and I have link like this:

    https://gplants.kg69design.com/wysijap/subscriptions/?wysija-page=1&controller=confirm&wysija-key=7a76b337ea6e6436849935dd883b1959&action=subscribe&wysijap=subscriptions&lang=ru

    But I wonder, is it possible to prevent such cases and set default lang parameter to a query?

    Plugin Author Chouby

    (@chouby)

    1. Thank you for the precision. I did not see the difference. I guess I have to do the same for the js code in widget.php.

    2. I did not succeed to reproduce the bug until now (with latest version), although I have some pieces of the puzzle:
    * ‘language’ is a taxonomy. The locale is stored in the description field.
    * category_description calls term_description which in fact does not check if the taxonomy is a category. So, if you call this function on a page with the url ‘/?cat=22&lang=en’, you may display the language locale instead of the category description (I successfully did this).
    * Due to this kind of issue, Polylang should never create urls such as ‘/?cat=22&lang=en’ or ‘/?cat=22&lang=en&feed=rss2’ (and it fact there is no need since it can take the language from the category itself).

    Could you precise what is your permalink structure and what are your Polylang settings? Did you check if it could come from any plugin or theme conflict (all my tests are done with twentyten)? It may help catching this bug.

    3. Any help is appreciated. If you want to send translations, you can use my contact form https://www.flabellina.com/polylang-contact/

    4. I do something like this in pre_get_posts filter (although it is not to set the lang parameter but page_id). Maybe you can try something like this:

    $qvars = $query->query_vars;
    $qvars['lang'] = whatever you want... // add the lang parameter
    $query->parse_query($qvars); // reparse query

    Plugin Author Chouby

    (@chouby)

    For the category_description issue, can you try the current development version ? It may solve it.

    Thread Starter kg69design

    (@kg69design)

    1. For the category_description issue:
    This is likely my mistake, because I did not pay attention to that fact, that the current locale outputted on archive page (and there is no need for category description there, of course)

    Current development version has a warning if you are in a single post page (I deactivated all other plugins and use twentyten theme):

    Invalid argument supplied for foreach() in ...\wp-content\plugins\polylang\include\core.php on line 373

    Seems like the primary WP_Query Object has empty tax_query in a single post page.

    Plugin Author Chouby

    (@chouby)

    Thank you. the warning should be removed now.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘[Plugin: Polylang] Validation improvement’ is closed to new replies.