I'm receiving the following filemtime() warning:
Warning: filemtime(): stat failed for https://testing.local/wp-content/plugins/test-social-icons/css/style.css in /app/public/wp-content/plugins/zoo-social-icons/zoo-social-icons.php on line 29
Here's how I'm enqueuing the stylesheet within my plugin:
function test_styles_scripts() {
$dir = plugin_dir_url(__FILE__);
wp_enqueue_style( 'test-style', $dir . 'css/style.css', array(), filemtime( $dir . 'css/style.css' ) );
}
add_action( 'wp_enqueue_scripts', 'test_styles_scripts' );
The stylesheet is correctly enqueuing. Why am I getting this warning?
plugin_dir_path()
needed to beplugin_dir_url()
. The second one, forfilemtime()
, still needs to beplugin_dir_path()
, becausefilemtime()
requires a path, not a URL, but the browser requires a URL, which is what the first one is for.