Put this in the main plugin file (myplugin.php
):
defined( 'MY_PLUGIN_URL' ) || define( 'MY_PLUGIN_URL', plugin_dir_url(__FILE__) );
defined( 'MY_PLUGIN_PATH' ) || define( 'MY_PLUGIN_PATH', plugin_dir_path(__FILE__) );
right before any other code, and use MY_PLUGIN_PATH
to include files, or MY_PLUGIN_URL
to load your assets.
E.G:
require_once MY_PLUGIN_PATH . 'templates/se.php';
wp_enqueue_style( 'my-css', MY_PLUGIN_URL . 'assets/css/style.css' );
Those constants can be accessible from any other file including the main plugin loader file and the files within the sub-directories. As long as the plugin is loaded correctly.
Hope that helps.