#34809 closed enhancement (invalid)
how to do file_get_contents in WordPress
Reported by: | rinkuyadav999 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Filesystem API | Keywords: | |
Focuses: | Cc: |
Description
Hi
I am developing a free WordPress theme.
Theme check plugin display:
WARNING: file_get_contents was found in the file customizer.php File operations should use the WP_Filesystem methods instead of direct PHP filesystem calls.
Line 10: $fonts = file_get_contents( get_template_directory() . '/json/google-fonts.json' );
I can't found, how to use file_get_contents in WordPress.
Thank you
Regards
Rinku Y
Change History (2)
#1
follow-up:
↓ 2
@
9 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
- Version 4.3.1 deleted
#2
in reply to:
↑ 1
@
9 years ago
Replying to dd32:
The Theme Check plugin / warning is incorrect in this case.
However, this isn't the correct avenue for support requests, Please use the WordPress Support Forums or contact the Theme Review team directly for theme issues.
Maybe it would be helpful to throw exception if someone is using wp-filesystem outside admin area? It seems like some developers try to avoid Theme Checker plugin / warnings by wrong implementation of wp-filesystem in frontend for just get_contents. BTW warnings can be easily bypassed by something like this: $func = 'file_ge' . 't_contents'; $data = $func($file);
The Theme Check plugin / warning is incorrect in this case.
However, this isn't the correct avenue for support requests, Please use the WordPress Support Forums or contact the Theme Review team directly for theme issues.