Check if logo, sitename, slogan, and secondary links exist
$secondary_links = theme_get_setting('toggle_secondary_links'); is working fine.

It doesn't work if secondary menu is disabled form admin/appearance/settings

It works when secondary menu is disabled form admin/appearance/settings/theme-name

OR

It works when secondary menu is disabled form admin/structure/menu/settings source of Source for the Secondary links is set to 'No Secondary links'