← All changes
|
inc/3rd-party/amazon-s3-and-cloudfront/classes/Main.php
+34
-26
1.10
→
trunk
View file →
| @@ -1,12 +1,11 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Imagify\ThirdParty\AS3CF; |
| 3 | 3 | |
| 4 | -use \Imagify\Optimization\File; | |
| 5 | -use \Imagify\ThirdParty\AS3CF\CDN\WP\AS3 as CDN; | |
| 4 | +use Imagify\Optimization\File; | |
| 5 | +use Imagify\ThirdParty\AS3CF\CDN\WP\AS3 as CDN; | |
| 6 | +use Imagify\Traits\InstanceGetterTrait; | |
| 6 | 7 | |
| 7 | -defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' ); | |
| 8 | - | |
| 9 | 8 | /** |
| 10 | 9 | * Imagify WP Offload S3 class. |
| 11 | 10 | * |
| 12 | 11 | * @since 1.9 |
| @@ -12,9 +11,9 @@ | ||
| 12 | 11 | * @since 1.9 |
| 13 | 12 | * @author Grégory Viguier |
| 14 | 13 | */ |
| 15 | 14 | class Main extends \Imagify_AS3CF_Deprecated { |
| 16 | - use \Imagify\Traits\InstanceGetterTrait; | |
| 15 | + use InstanceGetterTrait; | |
| 17 | 16 | |
| 18 | 17 | /** |
| 19 | 18 | * AS3CF settings. |
| 20 | 19 | * |
| @@ -61,9 +60,9 @@ | ||
| 61 | 60 | |
| 62 | 61 | /** |
| 63 | 62 | * WebP images to display with a <picture> tag. |
| 64 | 63 | */ |
| 65 | - add_action( 'as3cf_init', [ $this, 'store_s3_settings' ] ); | |
| 64 | + add_action( 'as3cf_init', [ $this, 'store_s3_settings' ] ); | |
| 66 | 65 | add_filter( 'imagify_webp_picture_process_image', [ $this, 'picture_tag_webp_image' ] ); |
| 67 | 66 | |
| 68 | 67 | /** |
| 69 | 68 | * Register CDN. |
| @@ -73,20 +72,20 @@ | ||
| 73 | 72 | /** |
| 74 | 73 | * Optimization process. |
| 75 | 74 | */ |
| 76 | 75 | add_filter( 'imagify_before_optimize_size', [ $this, 'maybe_copy_file_from_cdn_before_optimization' ], 8, 6 ); |
| 77 | - add_action( 'imagify_after_optimize', [ $this, 'maybe_send_media_to_cdn_after_optimization' ], 8, 2 ); | |
| 76 | + add_action( 'imagify_after_optimize', [ $this, 'maybe_send_media_to_cdn_after_optimization' ], 8, 2 ); | |
| 78 | 77 | |
| 79 | 78 | /** |
| 80 | 79 | * Restoration process. |
| 81 | 80 | */ |
| 82 | - add_action( 'imagify_after_restore_media', [ $this, 'maybe_send_media_to_cdn_after_restore' ], 8, 4 ); | |
| 81 | + add_action( 'imagify_after_restore_media', [ $this, 'maybe_send_media_to_cdn_after_restore' ], 8, 4 ); | |
| 83 | 82 | |
| 84 | 83 | /** |
| 85 | 84 | * WebP support. |
| 86 | 85 | */ |
| 87 | - add_filter( 'as3cf_attachment_file_paths', [ $this, 'add_webp_images_to_attachment' ], 8, 3 ); | |
| 88 | - add_filter( 'mime_types', [ $this, 'add_webp_support' ] ); | |
| 86 | + add_filter( 'as3cf_attachment_file_paths', [ $this, 'add_webp_images_to_attachment' ], 8, 3 ); | |
| 87 | + add_filter( 'mime_types', [ $this, 'add_webp_support' ] ); | |
| 89 | 88 | |
| 90 | 89 | /** |
| 91 | 90 | * Redirections. |
| 92 | 91 | */ |
| @@ -121,9 +120,9 @@ | ||
| 121 | 120 | /** |
| 122 | 121 | * WebP images to display with a <picture> tag. |
| 123 | 122 | * |
| 124 | 123 | * @since 1.9 |
| 125 | - * @see \Imagify\Webp\Picture\Display->process_image() | |
| 124 | + * @see \Imagify\Picture\Display->process_image() | |
| 126 | 125 | * @author Grégory Viguier |
| 127 | 126 | * |
| 128 | 127 | * @param array $data An array of data for this image. |
| 129 | 128 | * @return array |
| @@ -442,9 +441,9 @@ | ||
| 442 | 441 | return $paths; |
| 443 | 442 | } |
| 444 | 443 | |
| 445 | 444 | foreach ( $paths as $size_name => $file_path ) { |
| 446 | - if ( 'thumb' === $size_name || 'backup' === $size_name || $process->is_size_webp( $size_name ) ) { | |
| 445 | + if ( 'thumb' === $size_name || 'backup' === $size_name || $process->is_size_next_gen( $size_name ) ) { | |
| 447 | 446 | continue; |
| 448 | 447 | } |
| 449 | 448 | |
| 450 | 449 | if ( 'file' === $size_name ) { |
| @@ -527,12 +526,15 @@ | ||
| 527 | 526 | return $size_and_count; |
| 528 | 527 | } |
| 529 | 528 | |
| 530 | 529 | if ( ! isset( $data ) ) { |
| 531 | - $data = \Imagify_DB::get_metas( [ | |
| 532 | - // Get the filesizes. | |
| 533 | - 's3_filesize' => 'wpos3_filesize_total', | |
| 534 | - ], $image_ids ); | |
| 530 | + $data = \Imagify_DB::get_metas( | |
| 531 | + [ | |
| 532 | + // Get the filesizes. | |
| 533 | + 's3_filesize' => 'wpos3_filesize_total', | |
| 534 | + ], | |
| 535 | + $image_ids | |
| 536 | + ); | |
| 535 | 537 | |
| 536 | 538 | $data = array_map( 'absint', $data['s3_filesize'] ); |
| 537 | 539 | } |
| 538 | 540 | |
| @@ -591,14 +593,17 @@ | ||
| 591 | 593 | return false; |
| 592 | 594 | } |
| 593 | 595 | |
| 594 | 596 | if ( is_array( $is ) ) { |
| 595 | - return imagify_merge_intersect( $is, [ | |
| 596 | - 'key' => '', | |
| 597 | - 'year_month' => '', | |
| 598 | - 'subdirs' => '', | |
| 599 | - 'filename' => '', | |
| 600 | - ] ); | |
| 597 | + return imagify_merge_intersect( | |
| 598 | + $is, | |
| 599 | + [ | |
| 600 | + 'key' => '', | |
| 601 | + 'year_month' => '', | |
| 602 | + 'subdirs' => '', | |
| 603 | + 'filename' => '', | |
| 604 | + ] | |
| 605 | + ); | |
| 601 | 606 | } |
| 602 | 607 | |
| 603 | 608 | if ( ! isset( $uploads_dir ) ) { |
| 604 | 609 | $uploads_dir = wp_parse_url( $this->filesystem->get_upload_baseurl() ); |
| @@ -622,10 +627,13 @@ | ||
| 622 | 627 | } |
| 623 | 628 | |
| 624 | 629 | unset( $match[0] ); |
| 625 | 630 | |
| 626 | - return array_merge( [ | |
| 627 | - 'year_month' => '', | |
| 628 | - 'subdirs' => '', | |
| 629 | - ], $match ); | |
| 631 | + return array_merge( | |
| 632 | + [ | |
| 633 | + 'year_month' => '', | |
| 634 | + 'subdirs' => '', | |
| 635 | + ], | |
| 636 | + $match | |
| 637 | + ); | |
| 630 | 638 | } |
| 631 | 639 | } |