Creating Custom Setting Page with Submenu

Before we move to submenus, we will add some additional features to the plugin.

Prevent direct access of plugin file

It’s important to prevent the direct access of the plugin file, which could lead to unexpected behavior or execution of the file if accessed directly from the plugin folder. To avoid this, we can add a safeguard in the form of the following line of code that prevents the execution of the file when the URL of the PHP file is viewed in the browser.

Get hands-on with 1400+ tech skills courses.