Changeset 3441908
- Timestamp:
- 01/18/2026 12:49:51 PM (4 weeks ago)
- Location:
- squeeze
- Files:
-
- 90 added
- 4 edited
-
tags/1.7.6 (added)
-
tags/1.7.6/assets (added)
-
tags/1.7.6/assets/css (added)
-
tags/1.7.6/assets/css/admin.css (added)
-
tags/1.7.6/assets/css/admin.css.map (added)
-
tags/1.7.6/assets/css/admin.less (added)
-
tags/1.7.6/assets/images (added)
-
tags/1.7.6/assets/images/computer-folder-close-icon.svg (added)
-
tags/1.7.6/assets/images/computer-folder-open-icon.svg (added)
-
tags/1.7.6/assets/images/icon-bulk-page.svg (added)
-
tags/1.7.6/assets/images/icon-compare.svg (added)
-
tags/1.7.6/assets/images/icon-exclude.svg (added)
-
tags/1.7.6/assets/images/icon-resize.svg (added)
-
tags/1.7.6/assets/images/icon.svg (added)
-
tags/1.7.6/assets/images/replace_urls.jpg (added)
-
tags/1.7.6/assets/images/sprite.svg (added)
-
tags/1.7.6/assets/js (added)
-
tags/1.7.6/assets/js/1dbcc374dc53cb692541.wasm (added)
-
tags/1.7.6/assets/js/4240e511ac61ecfff2d8.js (added)
-
tags/1.7.6/assets/js/4afb21e314317a97602a.wasm (added)
-
tags/1.7.6/assets/js/6ac3239376efce53600f.wasm (added)
-
tags/1.7.6/assets/js/8206b9ffe333bdb791d8.wasm (added)
-
tags/1.7.6/assets/js/admin.bundle.js (added)
-
tags/1.7.6/assets/js/assets_js_squeeze_js-assets_js_worker_js.script.bundle.js (added)
-
tags/1.7.6/assets/js/assets_js_worker_js.bundle.js (added)
-
tags/1.7.6/assets/js/assets_js_worker_js.script.bundle.js (added)
-
tags/1.7.6/assets/js/c96242667dc8e630897a.wasm (added)
-
tags/1.7.6/assets/js/editor.bundle.js (added)
-
tags/1.7.6/assets/js/node_modules_jsquash_avif_codec_enc_avif_enc_mt_worker_js.bundle.js (added)
-
tags/1.7.6/assets/js/node_modules_jsquash_avif_codec_enc_avif_enc_mt_worker_js.script.bundle.js (added)
-
tags/1.7.6/assets/js/node_modules_jsquash_oxipng_codec_pkg-parallel_index_js.script.bundle.js (added)
-
tags/1.7.6/assets/js/node_modules_jsquash_oxipng_codec_pkg-parallel_snippets_wasm-bindgen-rayon-3d2df09ebec17a22_s-312b0a0.js (added)
-
tags/1.7.6/assets/js/node_modules_jsquash_oxipng_codec_pkg-parallel_snippets_wasm-bindgen-rayon-3d2df09ebec17a22_s-312b0a0.script.bundle.js (added)
-
tags/1.7.6/assets/js/node_modules_jsquash_oxipng_codec_pkg-parallel_snippets_wasm-bindgen-rayon-3d2df09ebec17a22_s-312b0a1.js (added)
-
tags/1.7.6/assets/js/node_modules_jsquash_oxipng_codec_pkg-parallel_snippets_wasm-bindgen-rayon-3d2df09ebec17a22_s-312b0a1.script.bundle.js (added)
-
tags/1.7.6/assets/js/node_modules_jsquash_oxipng_codec_pkg-parallel_snippets_wasm-bindgen-rayon-3d2df09ebec17a22_s-3a2b7f.script.bundle.js (added)
-
tags/1.7.6/assets/js/node_modules_jsquash_oxipng_codec_pkg-parallel_squoosh_oxipng_js.script.bundle.js (added)
-
tags/1.7.6/assets/js/node_modules_jsquash_oxipng_codec_pkg_squoosh_oxipng_js.script.bundle.js (added)
-
tags/1.7.6/assets/js/script.bundle.js (added)
-
tags/1.7.6/assets/js/vendors-node_modules_jsquash_avif_codec_enc_avif_enc_js.bundle.js (added)
-
tags/1.7.6/assets/js/vendors-node_modules_jsquash_avif_codec_enc_avif_enc_js.script.bundle.js (added)
-
tags/1.7.6/assets/js/vendors-node_modules_jsquash_avif_codec_enc_avif_enc_mt_js.bundle.js (added)
-
tags/1.7.6/assets/js/vendors-node_modules_jsquash_avif_codec_enc_avif_enc_mt_js.script.bundle.js (added)
-
tags/1.7.6/assets/js/vendors-node_modules_jsquash_avif_decode_js-node_modules_jsquash_avif_encode_js-node_modules_-29c710.script.bundle.js (added)
-
tags/1.7.6/assets/js/vendors-node_modules_jsquash_avif_decode_js-node_modules_jsquash_avif_encode_js-node_modules_-515c76.bundle.js (added)
-
tags/1.7.6/assets/js/vendors-node_modules_jsquash_avif_decode_js-node_modules_jsquash_avif_encode_js-node_modules_-515c76.script.bundle.js (added)
-
tags/1.7.6/assets/js/vendors-node_modules_jsquash_avif_decode_js-node_modules_jsquash_avif_encode_js-node_modules_-55a88c.script.bundle.js (added)
-
tags/1.7.6/assets/js/vendors-node_modules_jsquash_avif_decode_js-node_modules_jsquash_avif_encode_js-node_modules_-88b2ac.bundle.js (added)
-
tags/1.7.6/assets/js/vendors-node_modules_jsquash_jpeg_decode_js-node_modules_jsquash_jpeg_encode_js-node_modules_-72a791.js (added)
-
tags/1.7.6/assets/js/vendors-node_modules_jsquash_jpeg_decode_js-node_modules_jsquash_jpeg_encode_js-node_modules_-9c2145.js (added)
-
tags/1.7.6/assets/js/vendors-node_modules_jsquash_oxipng_codec_pkg-parallel_squoosh_oxipng_js.js (added)
-
tags/1.7.6/assets/js/vendors-node_modules_jsquash_oxipng_codec_pkg-parallel_squoosh_oxipng_js.script.bundle.js (added)
-
tags/1.7.6/assets/js/vendors-node_modules_jsquash_oxipng_codec_pkg_squoosh_oxipng_js.js (added)
-
tags/1.7.6/assets/js/vendors-node_modules_jsquash_oxipng_codec_pkg_squoosh_oxipng_js.script.bundle.js (added)
-
tags/1.7.6/assets/js/vendors-node_modules_jsquash_webp_codec_enc_webp_enc_js.bundle.js (added)
-
tags/1.7.6/assets/js/vendors-node_modules_jsquash_webp_codec_enc_webp_enc_js.script.bundle.js (added)
-
tags/1.7.6/assets/js/vendors-node_modules_jsquash_webp_codec_enc_webp_enc_simd_js.bundle.js (added)
-
tags/1.7.6/assets/js/vendors-node_modules_jsquash_webp_codec_enc_webp_enc_simd_js.script.bundle.js (added)
-
tags/1.7.6/assets/js/vendors-node_modules_piexifjs_piexif_js-node_modules_jsquash_avif_decode_js-node_modules_jsqu-2d8528.bundle.js (added)
-
tags/1.7.6/assets/templates (added)
-
tags/1.7.6/assets/templates/directory-item-empty.html (added)
-
tags/1.7.6/assets/templates/directory-item.html (added)
-
tags/1.7.6/assets/templates/log-details-button.html (added)
-
tags/1.7.6/assets/templates/log-step.html (added)
-
tags/1.7.6/assets/templates/log-wrapper.html (added)
-
tags/1.7.6/assets/templates/path-list-item.html (added)
-
tags/1.7.6/inc (added)
-
tags/1.7.6/inc/handlers.php (added)
-
tags/1.7.6/inc/helpers.php (added)
-
tags/1.7.6/inc/settings.php (added)
-
tags/1.7.6/languages (added)
-
tags/1.7.6/languages/squeeze-uk-0282bc9bb3139ae7f3090194c10090b4.json (added)
-
tags/1.7.6/languages/squeeze-uk-08ec2477f322448a2db534074ac234a4.json (added)
-
tags/1.7.6/languages/squeeze-uk-1c72eced88847462c7e0967d0b7e5a17.json (added)
-
tags/1.7.6/languages/squeeze-uk-24b88c172a2803f6ee0c4956b1a8afb1.json (added)
-
tags/1.7.6/languages/squeeze-uk-6ae642d7d2342ed41f24938c32a6f536.json (added)
-
tags/1.7.6/languages/squeeze-uk-81ea56f743cbb228777c5cd8e3e8aac3.json (added)
-
tags/1.7.6/languages/squeeze-uk-8a8cc8d6792f201000247ed42d4140e8.json (added)
-
tags/1.7.6/languages/squeeze-uk-ac76f1d75eb777f747e6708b19d31b78.json (added)
-
tags/1.7.6/languages/squeeze-uk-b1f8d5e52cbbc262494fff20eec962fd.json (added)
-
tags/1.7.6/languages/squeeze-uk-e28a2098475e8c88fb444548eea784e3.json (added)
-
tags/1.7.6/languages/squeeze-uk-e9cc8298549e98be96351e6176bc85d5.json (added)
-
tags/1.7.6/languages/squeeze-uk-ebfe0cea630778e3fc5018cec6e46aac.json (added)
-
tags/1.7.6/languages/squeeze-uk-f98be19bec7bc848ce3ed383c60037c1.json (added)
-
tags/1.7.6/languages/squeeze-uk-ff025606f2061c02a097c943a471265d.json (added)
-
tags/1.7.6/languages/squeeze-uk.mo (added)
-
tags/1.7.6/languages/squeeze-uk.po (added)
-
tags/1.7.6/languages/squeeze.pot (added)
-
tags/1.7.6/readme.txt (added)
-
tags/1.7.6/squeeze.php (added)
-
trunk/inc/handlers.php (modified) (6 diffs)
-
trunk/inc/helpers.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/squeeze.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
squeeze/trunk/inc/handlers.php
r3436111 r3441908 231 231 } 232 232 $attach_id = (int) $_POST["attachmentID"]; 233 $sizes = wp_get_attachment_metadata( $attach_id ); 234 $sizes = $sizes['sizes']; 233 // Load excluded images once per request (Premium only) - cached in get_excluded_images() 234 $excluded_images = array(); 235 // Get attachment metadata once (contains sizes data) 236 $metadata = wp_get_attachment_metadata( $attach_id ); 237 $sizes = ( isset( $metadata['sizes'] ) ? $metadata['sizes'] : array() ); 235 238 $full_image = wp_get_attachment_image_src( $attach_id, 'full' ); 239 // Check exclusion early (Premium only) - before expensive operations if possible 240 if ( squeeze_freemius()->is__premium_only() && !empty( $excluded_images ) && !empty( $full_image[0] ) ) { 241 if ( $is_excluded = self::$SqueezePremium->is_excluded_image( $full_image[0], $excluded_images ) ) { 242 wp_send_json_error( '❌ ' . esc_html__( 'Attachment is excluded from compression', 'squeeze' ) . ' (' . esc_html__( 'found substring: ', 'squeeze' ) . $is_excluded['exclude_reason'] . ')' ); 243 } 244 } 245 // Cache file paths to avoid repeated function calls 246 $attached_file = get_attached_file( $attach_id ); 247 $original_image_path = wp_get_original_image_path( $attach_id ); 236 248 $is_squeezed = get_post_meta( $attach_id, 'squeeze_is_compressed', true ); 237 249 // -scaled image … … 240 252 'width' => $full_image[1], 241 253 'height' => $full_image[2], 242 'filesize' => wp_filesize( get_attached_file( $attach_id )),254 'filesize' => wp_filesize( $attached_file ), 243 255 ); 256 // Build size URLs (WordPress caches these internally) 244 257 foreach ( $sizes as $size_name => $size_data ) { 245 258 $sizes[$size_name]['url'] = wp_get_attachment_image_url( $attach_id, $size_name ); … … 250 263 'mime' => get_post_mime_type( $attach_id ), 251 264 'name' => get_the_title( $attach_id ), 252 'filename' => basename( wp_get_original_image_path( $attach_id )),265 'filename' => basename( $original_image_path ), 253 266 'sizes' => $sizes, 254 267 'is_squeezed' => $is_squeezed, … … 271 284 $image_formats = self::$SqueezeHelpers->get_image_formats(); 272 285 $image_formats = implode( ',', $image_formats ); 286 // MIME type mapping based on file extension (much faster than exif_imagetype) 287 $mime_type_map = array( 288 'jpg' => 'image/jpeg', 289 'jpeg' => 'image/jpeg', 290 'png' => 'image/png', 291 'webp' => 'image/webp', 292 'avif' => 'image/avif', 293 'gif' => 'image/gif', 294 ); 295 // Load excluded images once per request (Premium only) - cached in get_excluded_images() 296 $excluded_images = array(); 297 // Cache home URL and normalize ABSPATH to avoid repeated function calls and string operations 298 $home_url = trailingslashit( home_url() ); 299 $abspath_normalized = str_replace( '\\', '/', ABSPATH ); 273 300 foreach ( $pathes as $path ) { 274 301 // Remove dangerous patterns related to directory traversal … … 293 320 } 294 321 foreach ( $images as $image ) { 295 $attach_id = attachment_url_to_postid( $image ); 296 $attach_mime = image_type_to_mime_type( exif_imagetype( $image ) ); 297 $attach_url = str_replace( ABSPATH, home_url(), $image ); 322 // Get file extension for MIME type detection (much faster than exif_imagetype) 323 $extension = strtolower( pathinfo( $image, PATHINFO_EXTENSION ) ); 324 // Skip if extension not in our map (safety check) 325 if ( !isset( $mime_type_map[$extension] ) ) { 326 continue; 327 } 328 $attach_mime = $mime_type_map[$extension]; 329 $filename = basename( $image ); 330 // Convert file path to URL efficiently 331 // Normalize path separators and replace ABSPATH with home URL 332 $image_normalized = str_replace( '\\', '/', $image ); 333 $attach_url = str_replace( $abspath_normalized, $home_url, $image_normalized ); 334 // Check exclusion early (Premium only) - before any expensive operations 335 if ( squeeze_freemius()->is__premium_only() && !empty( $excluded_images ) ) { 336 if ( $is_excluded = self::$SqueezePremium->is_excluded_image( $attach_url, $excluded_images ) ) { 337 $attachment_data[] = array( 338 'excluded' => true, 339 'exclude_reason' => $is_excluded['exclude_reason'], 340 'filename' => $filename, 341 ); 342 continue; 343 } 344 } 345 // Skip attachment_url_to_postid() to avoid expensive database queries 346 // Path-based compression works with ID = 0 (files not in media library) 347 $attach_id = 0; 298 348 $attach_name = pathinfo( $image, PATHINFO_FILENAME ); 299 349 $attachment_data[] = array( … … 302 352 'mime' => $attach_mime, 303 353 'name' => $attach_name, 304 'filename' => basename( $image ),354 'filename' => $filename, 305 355 ); 306 356 } -
squeeze/trunk/inc/helpers.php
r3436111 r3441908 8 8 9 9 class SqueezeHelpers extends SqueezeInit { 10 // Cache squeeze_options array per request to avoid repeated database queries 11 private static $cached_squeeze_options = null; 12 10 13 public function __construct() { 11 14 //parent::__construct(); // will cause infinite loop in SquuezeInit … … 327 330 328 331 public function get_option($option) { 329 $options = get_option('squeeze_options'); 332 // Cache squeeze_options array per request to avoid repeated database queries 333 // This prevents hundreds of get_option('squeeze_options') calls during bulk operations 334 if (self::$cached_squeeze_options === null) { 335 self::$cached_squeeze_options = get_option('squeeze_options'); 336 } 337 338 $options = self::$cached_squeeze_options; 330 339 $option_value = isset($options[$option]) ? $options[$option] : $this->get_default_value($option); 331 340 … … 336 345 $default_options = $this->get_default_value('all', true); 337 346 $options = wp_parse_args($options, $default_options); 338 return update_option('squeeze_options', $options); 347 $result = update_option('squeeze_options', $options); 348 349 // Clear the cache when options are updated 350 if ($result) { 351 self::$cached_squeeze_options = $options; 352 } 353 354 return $result; 339 355 } 340 356 -
squeeze/trunk/readme.txt
r3436111 r3441908 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.3 7 Stable tag: 1.7. 57 Stable tag: 1.7.6 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 185 185 186 186 == Changelog == 187 = 1.7.6 = 188 * Cached heavy PHP and SQL requests 187 189 = 1.7.5 = 188 190 * Updated notifications texts and icons -
squeeze/trunk/squeeze.php
r3436111 r3441908 6 6 * Author URI: https://pluginarium.com 7 7 * Author: Bogdan Bendziukov 8 * Version: 1.7. 58 * Version: 1.7.6 9 9 * 10 10 * Text Domain: squeeze … … 26 26 * Plugin version 27 27 */ 28 const VERSION = '1.7. 5';28 const VERSION = '1.7.6'; 29 29 30 30 const CHECKOUT_URL = 'https://checkout.freemius.com/plugin/17217/plan/28703/';
Note: See TracChangeset
for help on using the changeset viewer.