add_action('admin_init', 'my_custom_settings'); function my_custom_settings() { // Add a new section to the WordPress dashboard settings add_settings_section('my_custom_section', 'My Custom Section', 'my_section_callback', 'general'); // Add a new field to the above section add_settings_field('my_custom_field', 'My Custom Field', 'my_field_callback', 'general', 'my_custom_section'); // Register the new setting register_setting('general', 'my_custom_setting'); } function my_section_callback() { echo 'Here you can add your custom settings for the site
'; } function my_field_callback() { echo ''; }
function my_plugin_custom_settings() { add_settings_section('my_plugin_section', 'My Plugin Settings', 'my_plugin_callback', 'my_plugin_menu'); add_settings_field('my_plugin_field', 'My Plugin Field', 'my_plugin_field_callback', 'my_plugin_menu', 'my_plugin_section'); register_setting('my_plugin_menu', 'my_plugin_setting'); } function my_plugin_callback() { echo 'In this example, we are adding a new setting to a custom plugin using the add_settings_section, add_settings_field, and register_setting functions, and then calling the functions using the admin_init action hook. We are also creating a new menu item for the plugin using the add_menu_page function, and then displaying the plugin settings using the my_plugin_settings function. Package library: This code is part of the WordPress core, and no external package or library is required to use it.Here are the settings for my custom plugin
'; } function my_plugin_field_callback() { echo ''; } add_action('admin_init', 'my_plugin_custom_settings'); add_action('admin_menu', 'my_plugin_menu'); function my_plugin_menu() { add_menu_page('My Plugin', 'My Plugin', 'manage_options', 'my_plugin_menu', 'my_plugin_settings', 'dashicons-admin-plugins', 100); } function my_plugin_settings() { echo ''; echo ''; }My Plugin Settings
'; echo ''; echo '