Skip to content

Commit

Permalink
Adjusted .min. checks for better accuracy. Added is_writable director…
Browse files Browse the repository at this point in the history
…y checks
  • Loading branch information
Bennett Stone authored and Bennett Stone committed Jul 16, 2013
1 parent 30da672 commit effe217
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion class.magic-min.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ private function minify_contents( $src_file, $run_minification = true )
* If the filename indicates that the contents are already minified, we'll just return the contents
* If the switch is flipped (useful for loading things such as jquery via google cdn)
*/
if( preg_match( '/.min./i', $src_file ) || $run_minification === false )
if( preg_match( '/\.min\./i', $src_file ) || $run_minification === false )
{
return $this->source;
}
Expand Down Expand Up @@ -419,6 +419,15 @@ private function make_min( $src_file, $new_file, $do_minify = true )
{
global $messages;

$this->messages[]['Minifier note'] = 'Writing new file to '. dirname( $new_file );

//Make sure the directory is writable
if( !is_writeable( dirname( $new_file ) ) )
{
$this->messages[]['Minifier ERROR'] = dirname( $new_file ) . ' is not writable. Cannot create minified file.';
return false;
}

//Output gzip data as needed, but default to none
//Lengthy line usage is intentional to provide cleanly formatted fwrite contents
$this->prequel = '';
Expand Down

0 comments on commit effe217

Please sign in to comment.