Writing a Custom WordPress Plugin

We just need to tell WordPress which hook we want the function called, as well as the function name.In order to implement this in the plugin we will need to call the menu functions at the right time..To do that we will put these function calls into their own function which will be called via a WordPress action..So in the constructor we will add a `add_action` call.When WordPress gets to the admin_menu hook, it will call the add_admin_menu function within the plugin..This will then render out the menu items.WP Admin Dashboard Settings Page for PluginOnce we have the admin menu items in place..We can link these to some actual pages within the plugin..Within the add_menu_page() and add_submenu_page() functions is a spot for a callback function..This tells WordPress which function to call when each menu item is clicked..When we added the main menu item with the add_menu_page function, we told it to call the display_custom_plugin_admin_page function..This in turn will display a template we have made already.With the menu items now linking to actual pages, we can add some forms on the settings page so we can let users configure our plugin..Within the custom plugin source code there are examples of different input types and one of using images and WordPress’s built in media library.Setting up form fields is pretty straight forward..Within the template file admin/partials/wordpress-custom-plugin-admin-display.php, we can echo out the forms and fields we want.Within the form tags there are a couple functions we need to call..First is settings_fields().. More details

Leave a Reply