Custom Order Beaver Builder Admin Bar Dropdown

This will let you customize the order of the BB Admin Bar dropdown. I wanted a order that makes more sense to me as that’s how it’s laid out on the page. Of course Parts can go anywhere, so I stuck them after the main content (singular/archive). But other than that, it goes in DOM order

add_filter( 'fl_theme_builder_current_page_layouts', function( $layouts ) {
    // Custom order
    $custom_order = ['header', 'singular', 'archive', '404', 'part' , 'footer'];

    $sorted_layouts = [];
    // Populate sorted_layouts based on custom_order
    foreach ($custom_order as $type) {
        if (isset($layouts[$type])) {
            $sorted_layouts[$type] = $layouts[$type];
        }
    }

    // Add any layout types not added to your custom order that are in $layouts
    foreach ($layouts as $type => $layout_array) {
        if (!isset($sorted_layouts[$type])) {
            $sorted_layouts[$type] = $layout_array;
        }
    }

    return $sorted_layouts;
});