Settings API – Order of Sections

Plugin A and Plugin B are related but can be used without each other.
Plugin A is far more likely to be used than Plugin B.

Both have some settings in common that do not make sense to be configured differently.

So when one is installed without the other, they each have their own settings page.

When both are installed, for the options in common, Plugin B uses the settings for Plugin A. For the options unique to B there are just two. Rather than waste Settings Menu space, when both are installed, B will add it’s section to the settings page for A (using same settings group obviously but different section)

That is working beautifully except for one thing –

The section for Plugin B always ends up *before* the section for Plugin A even though it is A’s option page.

I can not figure out how WordPress determines the order for more than one section on the same options page.

I could potentially add a bit of JS to move the section for B so that it comes after A but that is really hackish, is there no way to get WordPress to spit out the sections in a specified order? How does it sort them?

Link is code for Plugin B just in case anyone wants to see what I’m doing (settings API stuff near bottom)

The page I need help with: [log in to see the link]

Source link