Changeset 3410763
- Timestamp:
- 12/04/2025 11:06:44 AM (10 days ago)
- Location:
- sg-cachepress/trunk
- Files:
-
- 9 edited
-
core/Combinator/Abstract_Combinator.php (modified) (1 diff)
-
core/Combinator/Css_Combinator.php (modified) (3 diffs)
-
core/Combinator/Js_Combinator.php (modified) (1 diff)
-
core/Images_Optimizer/Images_Optimizer_Webp.php (modified) (6 diffs)
-
core/Loader/Loader.php (modified) (1 diff)
-
core/Supercacher/Supercacher_Helper.php (modified) (3 diffs)
-
core/Supercacher/Supercacher_Posts.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
sg-cachepress.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sg-cachepress/trunk/core/Combinator/Abstract_Combinator.php
r3090872 r3410763 204 204 return $file_content; 205 205 } 206 207 /** 208 * Removes the host and query stings from an URL to get the source. 209 * 210 * @param $url The URL to prepare. 211 * 212 * @return string The URL src. 213 */ 214 public function prepare_url_src( $url ) { 215 // Strips the URL from its host and query strings. 216 return trim( str_replace( Helper_Service::get_site_url(), '', strtok( $url, '?' ) ), "/\\" ); 217 } 206 218 } -
sg-cachepress/trunk/core/Combinator/Css_Combinator.php
r3174268 r3410763 182 182 } 183 183 184 // Re place the site URL and get the src.185 $excluded[] = trim( str_replace( Helper_Service::get_site_url(), '', strtok( $wp_styles->registered[ $handle ]->src, '?' ) ), '/\\');184 // Remove the query stings and the host to get the source. 185 $excluded[] = $this->prepare_url_src( $wp_styles->registered[ $handle ]->src ); 186 186 } 187 187 … … 208 208 } 209 209 210 // Get the host from src. .210 // Get the host from src. 211 211 $host = wp_parse_url( $style[2], PHP_URL_HOST ); 212 212 … … 219 219 } 220 220 221 // Remove query strings from the URL.222 $src = Front_End_Optimization::remove_query_strings( $style[2] );223 224 // Bail if the urlis excluded.225 if ( in_array( str_replace( trailingslashit( Helper_Service::get_site_url() ), '', $src ), $this->excluded_urls ) ) {221 // Remove the query stings and the host to get the source. 222 $src = $this->prepare_url_src( $style[2] ); 223 224 // Bail if the URL is excluded. 225 if ( in_array( $src, $this->excluded_urls ) ) { 226 226 return true; 227 227 } -
sg-cachepress/trunk/core/Combinator/Js_Combinator.php
r3204886 r3410763 519 519 public $excluded_ids = array( 520 520 '@wordpress/block-library/navigation-js-module', 521 '@wordpress/block-library/navigation/view-js-module', 521 522 ); 522 523 -
sg-cachepress/trunk/core/Images_Optimizer/Images_Optimizer_Webp.php
r2698959 r3410763 119 119 120 120 /** 121 * Check if image exists and perform optimi ation.121 * Check if image exists and perform optimization. 122 122 * 123 123 * @since 5.0.0 … … 128 128 */ 129 129 public static function generate_webp_file( $filepath ) { 130 // Bail if the file doe ns't exists or if the webp copy already exists.130 // Bail if the file doesn't exists or if the webp copy already exists. 131 131 if ( ! file_exists( $filepath ) ) { 132 132 return true; … … 189 189 190 190 /** 191 * Delete all Webp files.191 * Delete the webp images generated by us, and reset the optimization status. 192 192 * 193 193 * @since 5.4.0 … … 196 196 */ 197 197 public function delete_webp_files() { 198 $basedir = Helper_Service::get_uploads_dir(); 199 exec( "find $basedir -name '*.webp' -type f -print0 | xargs -L 500 -0 rm", $output, $result);198 199 $this->delete_generated_webp_copies(); 200 200 201 201 $this->reset_image_optimization_status(); … … 220 220 221 221 if ( ! empty( $metadata['sizes'] ) ) { 222 // Loop through all image sizes and optimize them as well.222 // Loop through all image sizes and delete them as well. 223 223 foreach ( $metadata['sizes'] as $size ) { 224 224 $wp_filesystem->delete( str_replace( $basename, $size['file'], $main_image ) . '.webp' ); 225 225 } 226 226 } 227 228 227 } 229 228 … … 241 240 $this->optimize( $id, $metadata ); 242 241 } 242 243 244 /** 245 * Deletes only the webp images generated by us. 246 */ 247 public function delete_generated_webp_copies() { 248 249 $images_ids = $this->get_all_image_attachments_with_webp_meta(); 250 251 $batch_size = 200; 252 253 $batches = array_chunk( $images_ids, $batch_size ); 254 255 foreach ( $batches as $chunk ) { 256 foreach ( $chunk as $image_id ) { 257 $this->delete_webp_copy( $image_id ); 258 } 259 } 260 } 261 262 /** 263 * Gets all attachments with webp meta key. 264 * 265 * @return Array with IDs of images. 266 */ 267 public function get_all_image_attachments_with_webp_meta() { 268 // Query for attachments with the meta key and MIME type 'image'. 269 $image_ids = get_posts( 270 array( 271 'post_type' => 'attachment', 272 'post_mime_type' => 'image', 273 'meta_query' => array( 274 array( 275 'key' => 'siteground_optimizer_is_converted_to_webp', 276 'compare' => 'EXISTS', 277 ), 278 ), 279 'fields' => 'ids', 280 'posts_per_page' => -1, 281 ) 282 ); 283 284 return $image_ids; 285 } 243 286 } -
sg-cachepress/trunk/core/Loader/Loader.php
r3150542 r3410763 510 510 // Minify the js files. 511 511 add_action( 'wp_print_scripts', array( $this->minifier, 'minify_scripts' ), 20 ); 512 add_action( 'wp_print_footer_scripts', array( $this->minifier, 'minify_scripts' ) ); 512 513 if ( ! function_exists( 'is_plugin_active' ) ) { 514 require_once ABSPATH . 'wp-admin/includes/plugin.php'; 515 } 516 517 if ( is_plugin_active( 'akismet/akismet.php' ) ) { 518 add_action( 'wp_print_footer_scripts', array( $this->minifier, 'minify_scripts' ), 9 ); 519 } else { 520 add_action( 'wp_print_footer_scripts', array( $this->minifier, 'minify_scripts' ) ); 521 } 513 522 } 514 523 -
sg-cachepress/trunk/core/Supercacher/Supercacher_Helper.php
r2944007 r3410763 28 28 if ( 29 29 0 === $is_cache_enabled || 30 self::is_url_excluded( trailingslashit( $url ) ) 30 self::is_url_excluded( trailingslashit( $url ) ) || 31 self::is_query_param_excluded( $url ) 31 32 ) { 32 33 $result->header( 'X-Cache-Enabled', 'False' ); … … 60 61 ( 0 === $is_cache_enabled && 0 === $file_cache_enabled ) || 61 62 self::is_url_excluded( $url ) || 62 self::is_post_type_excluded( $url ) 63 self::is_post_type_excluded( $url ) || 64 self::is_query_param_excluded( $url ) 63 65 ) { 64 66 $headers['X-Cache-Enabled'] = 'False'; … … 163 165 } 164 166 167 /** 168 * Checks if the URL contains excluded query parameters. 169 * 170 * @param $url The URL to check. 171 * 172 * @return boolean True if the URL contains excluded parameters, false otherwise. 173 */ 174 public static function is_query_param_excluded( $url ) { 175 // Get the excluded parameters, if there are such. 176 $excluded_params = apply_filters( 'sgo_bypass_query_params', array() ); 177 178 if ( empty( $excluded_params ) ) { 179 return false; 180 } 181 182 // Get the query parameters. 183 $parsed_params = wp_parse_url( $url, PHP_URL_QUERY ); 184 185 if ( empty( $parsed_params ) ) { 186 return false; 187 } 188 189 // Convert the parameters into array. 190 $query_params = array(); 191 parse_str( $parsed_params, $query_params ); 192 193 // Check if excluded parameters, exist in the query string. 194 foreach ( $excluded_params as $param ) { 195 if ( array_key_exists( $param, $query_params ) ) { 196 return true; 197 } 198 } 199 200 return false; 201 } 202 165 203 } -
sg-cachepress/trunk/core/Supercacher/Supercacher_Posts.php
r3393532 r3410763 137 137 public function purge_all_post_cache( $post_id ) { 138 138 139 // Get the post. 140 $post = get_post( $post_id ); 141 142 // Bail if the current hook is save_post and the post is scheduled. 143 if ( 'save_post' === current_action() && 'future' === get_post_status( $post_id ) ) { 144 return; 145 } 146 147 // Bail if the current hook is publish_post and the post isn't scheduled. 148 if ( 'publish_post' === current_action() && 'future' !== get_post_status( $post_id ) ) { 149 return; 150 } 151 152 // Bail if post type is excluded from cache purge. 153 if ( true === $this->is_post_excluded_from_cache_purge( $post ) ) { 154 return; 155 } 156 139 157 // Check if the cache for that $post_id is already flushed. 140 158 if ( true === $this->is_post_cache_already_flushed( $post_id ) ) { 141 return;142 }143 144 // Get the post.145 $post = get_post( $post_id );146 147 // Bail if the current hook is save_post and the post is scheduled.148 if ( 'save_post' === current_action() && 'future' === get_post_status( $post_id ) ) {149 return;150 }151 152 // Bail if the current hook is publish_post and the post isn't scheduled.153 if ( 'publish_post' === current_action() && 'future' !== get_post_status( $post_id ) ) {154 return;155 }156 157 // Bail if post type is excluded from cache purge.158 if ( true === $this->is_post_excluded_from_cache_purge( $post ) ) {159 159 return; 160 160 } -
sg-cachepress/trunk/readme.txt
r3393532 r3410763 4 4 Requires at least: 4.7 5 5 Requires PHP: 7.0 6 Tested up to: 6. 87 Stable tag: 7.7. 46 Tested up to: 6.9 7 Stable tag: 7.7.5 8 8 License: GPLv3 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 119 119 == Changelog == 120 120 121 = Version 7.7.5 = 122 Release Date: Dec 4th, 2025 123 124 * JS Combinator improvements 125 * Dynamic cache purge improvements 126 * CSS combination improvements 127 * WebP deletion improvements 128 * Query string exclude support for Dynamic Cache 129 130 121 131 = Version 7.7.4 = 122 132 Release Date: Nov 11th, 2025 -
sg-cachepress/trunk/sg-cachepress.php
r3393532 r3410763 11 11 * Plugin URI: https://siteground.com 12 12 * Description: This plugin will link your WordPress application with all the performance optimizations provided by SiteGround 13 * Version: 7.7. 413 * Version: 7.7.5 14 14 * Author: SiteGround 15 15 * Author URI: https://www.siteground.com … … 34 34 // Define version constant. 35 35 if ( ! defined( __NAMESPACE__ . '\VERSION' ) ) { 36 define( __NAMESPACE__ . '\VERSION', '7.7. 4' );36 define( __NAMESPACE__ . '\VERSION', '7.7.5' ); 37 37 } 38 38
Note: See TracChangeset
for help on using the changeset viewer.