If else for main menu
Not sure where/when this function is called, but here's your code with some fixes:

function bartik_links__system_main_menu($variables) {
    $output = '';
    $prefix = drupal_is_front_page() ? '' : '&lt;h2&gt;';
    $suffix = drupal_is_front_page() ? '' : '&lt;/h2&gt;';

    foreach ($variables['links'] as $link) {
        $output .= l($prefix.check_plain($link['title']).$suffix, $link['href'], $link);
    }
    return $output;
}