Use ACF options page with Carbon Fields options page

So yeah, this is a bit confusing, but it is a special case, because ACF’s repeater & flexible was too visually complex to use, so I decided to use Carbon Fields’s options page instead (I wrote about CF here – in Romanian – a while back).

Anyhow, using them separately? All fine. But putting all in the same menu and have ACF pages first? Well, that’s a totally different story! And apparently I’m the only one that’s crazy enough to use both plugins at once – or the only one that had this probel? – hence this article.

This is all good (assuming you’re using PHP 5.6+, btw). But how do we reorder the menu items and having ACF pages first?

Let’s shuffle some arrays a bit!

add_action('admin_menu', function () {
global $submenu;
// We first remove the dummy container.
unset($submenu['my-top-page-tmp'][0]);
// Then we move the first menu item - Carbon's Page - to the end of the array.
$submenu['my-top-page-tmp'][] = array_shift($submenu['my-top-page-tmp']);
}, 99);

And that’s about all.

Sure enough, you can change and put them in any order, but that’s what I needed. Do you have a better method to achieve this? If so, please leave a comment and let me know!