Created
February 19, 2024 14:28
-
-
Save zackpyle/3479d4bfeca86cd62e34305fe066e3cd to your computer and use it in GitHub Desktop.
Create a custom order for the Beaver Builder admin bar dropdown #beaverbuilder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
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; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment