If a user doesn’t pass a $sectionName that doesn’t match any in the switch, it goes to default and no $rowID is created. So how about if there are no $sectionName matches, and the switch makes it to default, see if $tagID arg is set. If set make that the $rowID. But ONLY do that if $sectionName doesn’t match a preset.
Forgive me… I’m not a explainer how about a example… Note tagID is added as a new arg.
function sp_SectionStart($args='', $sectionName='') {
$defs = array('tagClass' => 'spPlainSection',
'echo' => 1,
'tagID' => '',
);
$a = wp_parse_args($args, $defs);
$a = apply_filters('sph_SectionStart_args', $a);
extract($a, EXTR_SKIP);
# sanitize before use
$tagClass = esc_attr($tagClass);
$tagID = esc_attr($tagID);
$echo = (int) $echo;
# notifiy custom code before we start the section code
do_action('sph_BeforeSectionStart', $sectionName, $a);
do_action('sph_BeforeSectionStart_'.$sectionName, $a);
# specific formatting based on 'defined' names
$rowClass = '';
$rowId = '';
switch ($sectionName) {
case 'group':
global $spGroupView, $spThisGroup;
$rowClass = ($spGroupView->currentGroup % 2) ? ' spOdd' : ' spEven';
$rowId = "group$spThisGroup->group_id";
break;
case 'subforum':
case 'forum':
global $spGroupView, $spThisForum;
$rowClass = ($spGroupView->currentForum % 2) ? ' spOdd' : ' spEven';
if ($spThisForum->forum_status) $rowClass.= ' spLockedForum';
$rowId = "forum$spThisForum->forum_id";
break;
case 'topic':
global $spForumView, $spThisTopic;
$rowClass = ($spForumView->currentTopic % 2) ? ' spOdd' : ' spEven';
if ($spThisTopic->topic_status) $rowClass.= ' spLockedTopic';
if ($spThisTopic->topic_pinned) $rowClass.= ' spPinnedTopic';
$rowId = "topic$spThisTopic->topic_id";
break;
case 'post':
global $spTopicView, $spThisPost;
$rowClass = ($spTopicView->currentPost % 2) ? ' spOdd' : ' spEven';
if ($spThisPost->post_pinned) $rowClass.= ' spPinnedPost';
$rowClass.= ' spType-'.$spThisPost->user->usertype;
if (!empty($spThisPost->user->rank)) $rowClass.= ' spRank-'.sp_create_slug($spThisPost->user->rank[0]['name'], 'rank', false);
if (!empty($spThisPost->user->special_rank)) {
foreach ($spThisPost->user->special_rank as $rank) {
$rowClass.= ' spSpecialRank-'.sp_create_slug($rank['name'], 'rank', false);
}
}
if (!empty($spThisPost->user->memberships)) {
foreach ($spThisPost->user->memberships as $membership) {
$rowClass.= ' spUsergroup-'.sp_create_slug($membership['usergroup_name'], 'usergroup', false);
}
}
$rowId = "post$spThisPost->post_id";
break;
case 'list':
global $spListView, $spThisListTopic;
$rowClass = ($spListView->currentTopic % 2) ? ' spOdd' : ' spEven';
$rowId = "topic$spThisListTopic->topic_id";
break;
case 'usergroup':
global $spMembersList;
$rowClass = ($spMembersList->currentMemberGroup % 2) ? ' spOdd' : ' spEven';
break;
case 'member':
global $spMembersList;
$rowClass = ($spMembersList->currentMember % 2) ? ' spOdd' : ' spEven';
break;
case 'default':
if(!empty($tagID)) $rowID = $tagID;
break;
}
# allow filtering of the row class
$rowClass = apply_filters('sph_SectionStartRowClass', $rowClass, $sectionName, $a);
# output section starting div
if(!empty($rowId)) $rowId=" id='$rowId'";
$out = "<div class='$tagClass$rowClass'$rowId>n";
if ($echo) {
echo $out;
# notifiy custom code that section has started
# only valid if content is echoed out ($display=1)
do_action('sph_AfterSectionStart', $sectionName, $a);
do_action('sph_AfterSectionStart_'.$sectionName, $a);
} else {
return $out;
}
}