settings api sub menu and data not populating

I don’t know anything about the WeDevs thing, but I do kinda know the Settings API itself.

That being said I have a shot in the dark answer. In your wedevs_plugin_page() function, do the methods on the $settings_api object need a parameter for which settings section to display? Like $settings_api->show_navigation('wedevs_basic');?

Or maybe the object instantiation itself takes a parameter? Like $settings_api = new WeDevs_Settings_API('wedevs_basic');?

Again, I don’t know the WeDevs framework, but it seems odd that the WeDevs_Settings_API object you create during the admin_init function would be able to later communicate with another WeDevs_Settings_API object created in the options page function. Unless $settings_api->admin_init(); does something really cool to facilitate that communication, it just seems like something is missing here.

EDIT:

OK I think you’re not really supposed to use that Settings API plugin (as in don’t activate it), but rather use it as an example for your own code in your own theme. I guess that’s what the author means by “THIS PLUGIN IS FOR DEVELOPERS, NOT GENERAL USERS.”

Anyway, take the class.settings-api.php file from the plugin and include that in your theme (which I think is what you’re doing already). Don’t change anything in this file.

Then in your o-functions.php file, just get rid of all that procedural stuff and use the oop-example.php file instead. Like copy the code from that file and paste it in your o-functions.php file.

Now edit that o-functions.php file to suit your needs. First thing you should do is change the name of the class from ‘WeDevs_Settings_API_Test’ to something more descriptive for your theme. Don’t forget to change the class name in the conditional as well – if ( !class_exists('WeDevs_Settings_API_Test' ) ):

Then change the parameters for add_options_page( 'Settings API', 'Settings API', 'delete_posts', 'settings_api_test', array($this, 'plugin_page') );

You will want to change the first, second, and fourth parameters which are the page title, menu title, and menu slug respectively. The slug especially has to be unique.

Then you can change the sections and the fields to whatever you need.

So a quick recap – once you copy the code from oop-example.php, you will need to change the name of the class, change the parameters for add_options_page(), change the section names in function get_settings_sections(), and change the field data in function get_settings_fields(). Don’t touch anything else in this code.

Now to finish it off instantiate an object using your new class after where you’re using locate_template(), like this:

locate_template( 'class.settings-api.php', true );
locate_template( 'o-functions.php', true );
new My_Settings_API();

Note that when I renamed the class in o-functions.php, I called it “My_Settings_API”. So you need to use whatever name you gave it.