Does "$wp_filesystem->append_contents" or something exist?
-
I need to use the function
file_put_contents
to overwrite a file with whole new content or append contents several times in some cases. But I guess that the function is not allowed to use in WordPress themes.So I would like to use
$wp_filesystem->put_contents
instead, but it seems the WP function does not have theflags
argument(FILE_USE_INCLUDE_PATH | FILE_APPEND | LOCK_EX) to choose whether to append content several times into a file or to overwrite a file with new one.I need some CSS, which is created lately and dynamically in a widget function(add class names to some elements & calculate CSS according to them) after all the other styles are already loaded. So I cannot use
wp_add_inline_style
, which is loaded before that. So, I absolutely need an alternative function forfile_put_contents
which has an argument to choose appending or replacing.ThemeCheck does not show any warning about
file_put_contents
. So can I just usefile_put_contents
in my theme?Please help!
- The topic ‘Does "$wp_filesystem->append_contents" or something exist?’ is closed to new replies.