I’m building a small plugin into a WordPress theme like wp-content/themes/my-theme/inc/my-plugin.
I’m wondering how to include files inside this folder that are relative to the main plugin file wp-content/themes/my-theme/inc/my-plugin/my-plugin.php.
For example, in my-plugin.php, I need to include wp-content/themes/my-theme/inc/my-plugin/css/style.css.
I’m looking for something like wp_enqueue_style( ‘my-plugin-style’, plugins_url( ‘/css/style.css’, __FILE__ ) ); but I want it to be only relative to the my-plugin.php directory and NOT relative to the WordPress plugin directory OR theme directory. This way I can make it a separate plugin too if I want, without changing any code.
Please do not ask why I’m building this into the theme or that it should be a separate plugin. Just looking for possible solutions.
Read more here:: How to include files relative to a file’s directory