Custom TinyMCE Editor Formats in Dropdown

You can group styles using the items key – you can nest multiple times too!

/* TINY MCE FORMATE */
function my_mce_before_init_insert_formats( $init_array ) {  
    $style_formats = array(  
        array(  
            'title' => 'Buttons',
            'items' => array(
                array(
                    'title' => 'Green',
                    'selector' => 'a',
                    'classes' => 'btn--green'
                )
                array(
                    'title' => 'Blue Button',
                    'selector' => 'a',
                    'classes' => 'btn--blue'
                )
            ),
        ),          
        array(  
            'title' => 'Download',
            'items' => array(
                array(
                    'title' => 'Style 1',
                    'selector' => 'a',  
                    'classes' => 'download-style-1'
                ),
                array(
                    'title' => 'Style 2',
                    'selector' => 'a',  
                    'classes' => 'download-style-2'
                )
            )
        )
    ); 

    $init_array['style_formats'] = json_encode( $style_formats );  

    return $init_array;  
} 

add_filter( 'tiny_mce_before_init', 'my_mce_before_init_insert_formats' );