[theme-reviewers] what are the rules for file access in themes?

Otto otto at ottodestruct.com
Thu Jan 10 21:14:58 UTC 2013


On Thu, Jan 10, 2013 at 1:06 PM, Simon Prosser <pross at pross.org.uk> wrote:
> A lot of shared hosting companies block file_get_contents and file_put_contents.
>
> file() reads a file line by line and puts it in an array.
>
> Heres what we use:
> function pl_file_get_contents( $filename ) {
>
>         if ( is_file( $filename ) ) {
>
>                 $file = file( $filename, FILE_SKIP_EMPTY_LINES );
>                 $out = '';
>                 if( is_array( $file ) )
>                         foreach( $file as $contents )
>                                 $out .= $contents;
>
>                 if( $out )
>                         return $out;
>                 else
>                         return false;
>         }
> }


Seems overcomplicated. This is a bit quicker:

$contents = implode( file( $file ) );

-Otto


More information about the theme-reviewers mailing list