PHP Warning: filemtime(): stat failed
-
Hello there,
This plugin keeps logging a “PHP Warning: filemtime(): stat failed” warning for me and it seems I’m not alone: https://ww.wp.xz.cn/support/topic/warning-filemtime-stat-failed-for-4/ (I can’t post in this Topic).
I’ve done some debugging and found that
filemtime()expects a filesystem path, butplugin_dir_url()returns a URL. This triggers the PHP warnings. Usingplugin_dir_path()fixes it. To fix it I updated https://plugins.svn.ww.wp.xz.cn/woo-related-products-refresh-on-reload/trunk/public/class-woo-related-products-public.php lines 103-105 from:wp_register_script( 'owl-carousel', plugin_dir_url( FILE ) . 'owl-carousel/owl.carousel.min.js', '', gmdate( 'ymd-Gis', filemtime( plugin_dir_url( FILE ) . 'owl-carousel/owl.carousel.min.js' ) ), true );
wp_enqueue_script( 'owl-carousel' );
wp_enqueue_style( 'owl-carousel-stylesheet', plugin_dir_url( FILE ) . 'owl-carousel/owl.carousel.css', '', gmdate( 'ymd-Gis', filemtime( plugin_dir_url( FILE ) . 'owl-carousel/owl.carousel.css' ) ) );To
wp_register_script( 'owl-carousel', plugin_dir_url( __FILE__ ) . 'owl-carousel/owl.carousel.min.js', '', gmdate( 'ymd-Gis', filemtime( plugin_dir_path( __FILE__ ) . 'owl-carousel/owl.carousel.min.js' ) ), true );
wp_enqueue_script( 'owl-carousel' );
wp_enqueue_style( 'owl-carousel-stylesheet', plugin_dir_url( __FILE__ ) . 'owl-carousel/owl.carousel.css', '', gmdate( 'ymd-Gis', filemtime( plugin_dir_path( __FILE__ ) . 'owl-carousel/owl.carousel.css' ) ) );Could you please fix the plugin?
The topic ‘PHP Warning: filemtime(): stat failed’ is closed to new replies.