Shortcode arguments to another shortcode

You could pass the variable via a global but it would be neater to trap it in a static variable:

function track_acc_id($new_id = false) {
  static $id;
  if (!empty($new_id)) {
    $id = $new_id;
  }
  return $id;
}

//This is the accordion container
function accordionGroup( $atts, $content = null )
{
    extract(shortcode_atts(array(
    'id_container' => '',
), $atts));

    track_acc_id($id_container);

    return "<div class="panel-group" id=".$id_container." role="tablist" aria-multiselectable="true">".do_shortcode($content)."</div>";
}
add_shortcode( 'accordion-group', 'accordionGroup');

//This is the accordion item. It's need a reference from the accordion ID
function accordionItem( $atts, $content = null)
{
    extract(shortcode_atts(array(
    'titulo' => '',
    'id' => '',
), $atts));

    $id = track_acc_id();

    return "
        <div class="panel panel-default">
            <div class="panel-heading" role="tab" id=".$id.">
                <h4 class="panel-title">
                    <a class="collapsed" role="button" data-toggle="collapse" data-parent="#the-reference-goes-here" href="#".$id."-collapse" aria-expanded='false' aria-controls=".$id."-collapse'>".$titulo."</a>
                </h4>
            </div>
            <div id='".$id."-collapse' class="panel-collapse collapse" role="tabpanel" aria-labelledby=".$id.">
                <div class="panel-body">".$content."</div>
            </div>
        </div>";
}
add_shortcode( 'accordion-item', 'accordionItem');

echo do_shortcode('[accordion-group id_container="d00d"]');
echo do_shortcode('[accordion-item]');

Or the whole thing into a class.

error code: 523