Toggle option in sidebar widgets

The after_title does not go through any transformations. In fact only the before_widget does:

http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/widgets.php#L876

However, a little lower you can see that $params = apply_filters( 'dynamic_sidebar_params', $params ); there’s a filter you can hook to do your own filtering.

add_filter( 'dynamic_sidebar_params', 'wpse_45418_change_after_title' );
function wpse_45418_change_after_title( $params ) {

    $id = $params[0]['widget_id'];

    if ( $id != 'mywidget' ) return $params;

    global $wp_registered_widgets;
    foreach ( (array) $wp_registered_widgets[$id]['classname'] as $cn ) {
        if ( is_string($cn) )
            $classname_ .= '_' . $cn;
        elseif ( is_object($cn) )
            $classname_ .= '_' . get_class($cn);
    }

    $params[0]['after_title'] = sprintf($params[0]['after_title'], $id, $classname );

    return $params;
}

This is the general answer to why your IDs are not getting rendered. From this example, to generate your own unique IDs in the after_title key, you would need to do something similar, but provide unique IDs, like so:

add_filter( 'dynamic_sidebar_params', 'wpse_45418_change_after_title' );
function wpse_45418_change_after_title( $params ) {

    $id = $params[0]['widget_id'];
    if ( $id != 'mywidget' ) return $params;

    $url = esc_url( 'http://some-url-you-need.com' );
    $uidcollapse = $id.'-unique-id';
    $uidboxdiv = $id.'-another-unique-id';

    // <a class="dropdown" style="float: right;" href="https://wordpress.stackexchange.com/questions/45418/%1$s" data-toggle="collapse"><b class="toggleicon"></b></a></div><div id="#%2$s" class="collapse in"><div id="#%3$s" class="boxdiv">

    $params[0]['after_title'] = sprintf($params[0]['after_title'], $url, $classname, $uidcollapes, $uidboxdiv );

    return $params;
}

techhipbettruvabetnorabahisbahis forumutaraftarium24eduedusedueduseduseduseduseduedusedus