WordPress.org

Ready to get started?Download WordPress

Forums

Polylang
[resolved] Validation improvement (14 posts)

  1. kg69design
    Member
    Posted 2 years ago #

    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.

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

  2. kg69design
    Member
    Posted 2 years ago #

    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.

  3. kg69design
    Member
    Posted 2 years ago #

    Is anybody here?

  4. fmarie
    Member
    Posted 2 years ago #

    Yes but what is your question ? ^^

  5. kg69design
    Member
    Posted 2 years ago #

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

  6. fmarie
    Member
    Posted 2 years ago #

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

  7. kg69design
    Member
    Posted 2 years ago #

    Yes, you are right.

  8. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    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.

  9. kg69design
    Member
    Posted 2 years ago #

    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)).

  10. kg69design
    Member
    Posted 2 years ago #

    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:

    http://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:

    http://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?

  11. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    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 http://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
  12. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

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

  13. kg69design
    Member
    Posted 2 years ago #

    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.

  14. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    Thank you. the warning should be removed now.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.