I'm a newby developing plugins for Wordpress.

When I try to enqueue a style, Wordpress shows the following error: Insecure Content.

The code I use to 'attach' the css files is the following one:

add_action('wp_enqueue_scripts', 'callback_for_setting_up_scripts');

function callback_for_setting_up_scripts(){
  wp_register_style('estilo', __DIR__ . '/assets/css/estilo.css');
  wp_enqueue_style( 'estilo' );

This code is located in the /modules folder of the main plugin because it's the style for a specific module.

I use Query Monitor Plugin as a debugger.

Any idea?

Thanks in advance


1 Answer 1


__DIR__ returns the current file system path, not a URL. So the resulting stylesheet will not be a valid URL, and will not have https://, causing the insecure content warning.

To get the URL for a stylesheet in your plugin, you need to use plugins_url():

wp_register_style( 'estilo', plugins_url( 'assets/css/estilo.css', __FILE__ ) );

The use of __FILE__ here is described in the documentation for the function:

A full path to a file inside a plugin or mu-plugin. The URL will be relative to its directory. Typically this is done by passing __FILE__ as the argument.

  • Thanks a lot! That was my problem. Thanks!
    – VicentGN
    Apr 24, 2020 at 6:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.