Is file_get_contents() the only way for plugins reading local files OR does WP_Filesystem_Direct::get_contents() even work?

$wp_filesystem->get_contents() $wp_filesystem->get_contents() replaced file_get_contents() perfectly as a drop-in replacement. Of course, it must be initiated with WP_Filesystem(); first. Here is a before and after example… Before: if ( (strpos ( file_get_contents ( $check_this_file ), $check_this_string ) === false) ) {…} After: WP_Filesystem(); if ( (strpos ( $wp_filesystem->get_contents ( $check_this_file ), $check_this_string ) === false) ) … Read more