Trouble with ADA

Hello, I am new to php and am trying to figure out how I can add ADA compliant attributes to the code below.

The goal is to add ADA compliance attributes like aria-labeled and aria-labeledby to the output. It seems like I have an Empty Link on the output that need to be addressed.

Thanks in advance for your patience and help.

CODE:

if(!empty($sub_cat))
    {
        $sub_cat = "<li><a class=\"subclass-filter current\" href=\"#\" data-type='all' data-id='0'>{$attr['header_filter_text']}</a></li>" . $sub_cat;
        $sub_cat =
            "<div class=\"jeg_subcat\">
                <ul class=\"jeg_subcat_list\">
                    {$sub_cat}
                </ul>
            </div>";
    }

    // Now Render Output
    if(empty($heading_title) && empty($sub_cat)) {
        $output = '';
    } else {
        $output =
            "<div class=\"jeg_block_heading {$header_class} jeg_subcat_right\">
                {$heading_title}
                {$sub_cat}
            </div>";
    }

That is just an html attribute. Use it the same way you do things like this,

<label for="name"><input type="text" id="name" name="name"></label>
1 Like

Thanks! I am going to try this on the dev server. I was able to “cheat” and comment out the code below and it also worked.


   if(!empty($sub_cat))
        {
            //$sub_cat = "<li><a class=\"subclass-filter current\" href=\"#\" data-type='all' data-id='0'>{$attr['header_filter_text']}</a></li>" . $sub_cat;
            //$sub_cat =
            //    "<div class=\"jeg_subcat\">
            //        <ul class=\"jeg_subcat_list\">
            //            {$sub_cat}
            //        </ul>
            //    </div>";
        }

        // Now Render Output
        if(empty($heading_title) && empty($sub_cat)) {
            $output = '';
        } else {
            $output =
                "<div class=\"jeg_block_heading {$header_class} jeg_subcat_right\">
                    <ul class=\"jeg_subcat_list\">
						{$heading_title}
						{$sub_cat}
					</ul>
                </div>";
        }

        return $output;
Sponsor our Newsletter | Privacy Policy | Terms of Service