• Resolved LaserDiscMovies

    (@laserdiscmovies)


    Hello !

    Wonderful plugin !

    RE: Version 1.40

    Just noticed when validating my website that ID’s are being reused. Confirmed that if I disable your plugin the issue goes away. Your review and thoughts would be appreciated.

    https://michelle.astengox.com/

    See W3 error details below:

    Error: Duplicate ID s.
    From line 773, column 65; to line 773, column 110
    <input type="text" value="" name="s" id="s" />?					
    
    Warning: The first occurrence of ID s was here.
    From line 211, column 65; to line 211, column 110
    <input type="text" value="" name="s" id="s" />?					
    
    Error: Duplicate ID searchsubmit.
    From line 774, column 10; to line 774, column 59
    <input type="submit" id="searchsubmit" value="" />?					
    
    Warning: The first occurrence of ID searchsubmit was here.
    From line 212, column 10; to line 212, column 59
    <input type="submit" id="searchsubmit" value=""

    https://www.ads-software.com/plugins/bop-search-box-item-type-for-nav-menus/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author joe_bopper

    (@joe_bopper)

    Hi LaserDiscMovies,

    Thanks for getting in touch. Yes, I’m aware of this problem. It arises when the site’s theme does not support html5 and the search form is used more than once.

    The issue is that WordPress’s default search form suffers from this lack of foresight (that a search form might be used more than once) and I decided it was probably better to be consistent with WP than to change it for this plugin. This is because many themes will use the ids mentioned for css and js and so removing them would cause users to find their search form poorly styled. I would then have received loads of support questions and been unable to provide a satisfactory solution as styling is each site’s theme’s responsibility and therefore outside the scope of this plugin.

    Here is a link to the WP default search form code. Note repeating lines 237 and 238 is what causes the invalidation.

    You could solve this issue by having your theme support html5 (link), by removing one of your search forms, by changing the html output of the search forms (read the FAQ for the appropriate hooks), or by accepting a minor invalidation of your site’s html.

    I’m marking this support question as resolved as this is a backwards compatibility issue in WordPress itself.

    Cheers,
    Joe

    Thread Starter LaserDiscMovies

    (@laserdiscmovies)

    Joe,

    Thank you for your detailed reply. Your plugin and support are greatly appreciated! Could use a bit more of your insights.

    Configuration:
    WordPress 4.24
    Theme: twenty eleven v2.1
    Using Child theme

    So, I tried html5 and it broke your search box. Also, I thought I had removed all other search code from the child theme. I can modify the child theme as needed. I am just not sure what to modify. Any further thoughts or ideas would be appreciated.

    Plugin Author joe_bopper

    (@joe_bopper)

    Hi,

    How do you mean “it broke?” If you mean it looked a bit rubbish after, that’s to be expected as the elements, ids and classes are different for the html5 output (once again, a WP default) and so a theme designed for less than html5 may not have the style rules (and, perhaps, javascript) included for the html5 output. Your code in functions.php (or other appropriate file) should be

    add_action( 'after_setup_theme', function(){
        add_theme_support( 'html5', array( 'search-form' ) );
    }, 10, 0 );

    Note: anonymous functions like above require PHP 5.3 or greater, however, while WP is supposed to work with versions >5.2, 5.3 has reached its official end of life and so all servers should have updated to at least 5.4 by now.

    The conflicting ids could be coming from a use of get_search_form (could be a widget using it) as well as using this plugin, having more than one search box in a menu, by having more than one menu with a search box in (whether that be the same menu twice or two different menus), or simply by the ids being used again directly in a template file.

    The only advice I can give for diagnosing the duplicates is to check the source code of your web page against the line numbers given by the w3 validator and using that to figure out which template is outputting the html.

    Hope this helps.

    Cheers,
    Joe

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘W3 Code Validation Issue…’ is closed to new replies.