Skip to content

Commit

Permalink
PHP 5.6 :: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanHerman committed Feb 18, 2018
1 parent 375dad9 commit c92bea2
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/classes/class-webp-images-handle-uploads.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ public function generate_webp_images() {

$this->upload_paths = new WebP_Images_Upload_Paths( $this->attachment_meta['file'] );

// PHP 5.6 fix
$upload_path = $this->upload_paths;

// Make webp directory
if ( wp_mkdir_p( $this->upload_paths::$webp_file_path ) ) {
if ( wp_mkdir_p( $upload_path::$webp_file_path ) ) {

// Flush rewrite rules so the webp dir is accessible
flush_rewrite_rules();
Expand Down Expand Up @@ -120,8 +123,10 @@ public function generate_webp_image( $file ) {

}

$input = untrailingslashit( $this->upload_paths::$base_dir ) . $this->upload_paths::$sub_dir . $file;
$output = untrailingslashit( $this->upload_paths::$webp_dir_path ) . $this->upload_paths::$sub_dir . str_replace( pathinfo( $file, PATHINFO_EXTENSION ), 'webp', $file );
$upload_paths = $this->upload_paths;

$input = untrailingslashit( $upload_paths::$base_dir ) . $upload_paths::$sub_dir . $file;
$output = untrailingslashit( $upload_paths::$webp_dir_path ) . $upload_paths::$sub_dir . str_replace( pathinfo( $file, PATHINFO_EXTENSION ), 'webp', $file );

shell_exec( "cwebp -q {$this->webp_options['quality']} {$input} -o {$output}" );

Expand All @@ -144,7 +149,9 @@ private function delete_webp_image( $file ) {

}

$webp_file_path = $this->upload_paths::$webp_dir_path . $this->upload_paths::$webp_file_sub_dir . str_replace( pathinfo( $file, PATHINFO_EXTENSION ), 'webp', $file );
$upload_paths = $this->upload_paths;

$webp_file_path = $upload_paths::$webp_dir_path . $upload_paths::$webp_file_sub_dir . str_replace( pathinfo( $file, PATHINFO_EXTENSION ), 'webp', $file );

if ( ! file_exists( $webp_file_path ) ) {

Expand Down

0 comments on commit c92bea2

Please sign in to comment.