Get Current Plugin URL
wp_enqueue_style('stylsheet', 'http://www.example.com/stylesheet.css' );
wp_enqueue_style('stylsheet', 'http://www.example.com/wp-content/plugins/example-plugin/css/stylesheet.css' );
This will work fine but it's not best practice, for example you can only use this on the one domain, you can't move this plugin inside the mu-plugins folder and you can't change the name of the plugin folder.
So to get around these problems WordPress comes with a very useful function called plugins_url(), you give this function the filepath and it will return with the URL to this plugin. It is very useful to use when you need to include Savascript or CSS files in your plugin.
$url = plugins_url( $path, $plugin );
If you want to include a stylesheet from within a plugin the best way to do this is to use the global variable __FILE__ as the second parameter, this will always return the URL root of the plugin.
So if your stylesheet is in a css folder on the root of your plugin you will enqueue it by using the following code.
wp_enqueue_style('stylsheet', plugins_url( 'css/stylesheet.css', __FILE__ ) );
Subscribe To Newsletter
Get weekly updates to your email