Changeset 3436746
- Timestamp:
- 01/10/2026 05:39:05 PM (3 months ago)
- Location:
- 365i-queue-optimizer/trunk
- Files:
-
- 8 edited
-
365i-queue-optimizer.php (modified) (2 diffs)
-
admin/class-settings-page.php (modified) (3 diffs)
-
assets/css/admin.css (modified) (3 diffs)
-
assets/js/admin.js (modified) (2 diffs)
-
readme.txt (modified) (3 diffs)
-
src/class-queue-optimizer-main.php (modified) (4 diffs)
-
templates/partials/header.php (modified) (1 diff)
-
uninstall.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
365i-queue-optimizer/trunk/365i-queue-optimizer.php
r3436728 r3436746 4 4 * Plugin URI: https://www.365i.co.uk/blog/2025/04/20/fix-wordpress-6-8-slow-image-uploads-with-365i-queue-optimizer/ 5 5 * Description: A lightweight WordPress plugin to optimize ActionScheduler queue processing for faster image optimization and background tasks. 6 * Version: 1. 4.26 * Version: 1.5.0 7 7 * Author: 365i 8 8 * Author URI: https://www.mcneece.com/author/mark-mcneece/ … … 22 22 23 23 // Define plugin constants. 24 define( 'QUEUE_OPTIMIZER_VERSION', '1. 4.2' );24 define( 'QUEUE_OPTIMIZER_VERSION', '1.5.0' ); 25 25 define( 'QUEUE_OPTIMIZER_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); 26 26 define( 'QUEUE_OPTIMIZER_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); -
365i-queue-optimizer/trunk/admin/class-settings-page.php
r3436597 r3436746 107 107 ) ); 108 108 109 register_setting( 'queue_optimizer_settings', 'queue_optimizer_server_type_override', array( 110 'type' => 'string', 111 'sanitize_callback' => array( $this, 'sanitize_server_type_override' ), 112 'default' => '', 113 ) ); 114 109 115 add_settings_section( 110 116 'queue_optimizer_main', … … 150 156 __( 'Image Processing Engine', '365i-queue-optimizer' ), 151 157 array( $this, 'render_image_engine_field' ), 158 'queue_optimizer_settings', 159 'queue_optimizer_main' 160 ); 161 162 add_settings_field( 163 'queue_optimizer_server_type_override', 164 __( 'Server Type', '365i-queue-optimizer' ), 165 array( $this, 'render_server_type_field' ), 152 166 'queue_optimizer_settings', 153 167 'queue_optimizer_main' … … 525 539 return in_array( $value, $allowed, true ) ? $value : 'WP_Image_Editor_Imagick'; 526 540 } 541 542 /** 543 * Render server type override field. 544 * 545 * @since 1.5.0 546 */ 547 public function render_server_type_field() { 548 $value = get_option( 'queue_optimizer_server_type_override', '' ); 549 $detected_type = Queue_Optimizer_Main::get_server_environment()['server_type']; 550 551 $types = array( 552 '' => sprintf( 553 /* translators: %s: auto-detected server type */ 554 __( 'Auto-detect (%s)', '365i-queue-optimizer' ), 555 ucfirst( $detected_type ) 556 ), 557 'shared' => __( 'Shared Hosting', '365i-queue-optimizer' ), 558 'vps' => __( 'VPS / Managed', '365i-queue-optimizer' ), 559 'dedicated' => __( 'Dedicated / High Performance', '365i-queue-optimizer' ), 560 ); 561 ?> 562 <select id="queue_optimizer_server_type_override" name="queue_optimizer_server_type_override"> 563 <?php foreach ( $types as $type_value => $type_label ) : ?> 564 <option value="<?php echo esc_attr( $type_value ); ?>" <?php selected( $value, $type_value ); ?>> 565 <?php echo esc_html( $type_label ); ?> 566 </option> 567 <?php endforeach; ?> 568 </select> 569 <span class="description"> 570 <?php esc_html_e( 'Override auto-detection if recommendations don\'t match your server.', '365i-queue-optimizer' ); ?> 571 </span> 572 <?php 573 } 574 575 /** 576 * Sanitize server type override setting. 577 * 578 * @since 1.5.0 579 * @param mixed $value The value to sanitize. 580 * @return string Sanitized value. 581 */ 582 public function sanitize_server_type_override( $value ) { 583 $allowed = array( '', 'shared', 'vps', 'dedicated' ); 584 return in_array( $value, $allowed, true ) ? $value : ''; 585 } 527 586 } -
365i-queue-optimizer/trunk/assets/css/admin.css
r3436728 r3436746 366 366 .qo-save-notice { 367 367 position: fixed; 368 top: 50px;369 right: 2 0px;368 top: 45px; 369 right: 25px; 370 370 z-index: 99999; 371 371 background: #00a32a; 372 372 color: #fff; 373 padding: 1 2px 20px;373 padding: 14px 22px; 374 374 border-radius: 4px; 375 375 font-size: 14px; 376 376 font-weight: 500; 377 box-shadow: 0 4px 12px rgba(0, 0, 0, 0. 15);377 box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); 378 378 opacity: 0; 379 transform: translate X(100px);379 transform: translateY(-20px); 380 380 transition: all 0.3s ease; 381 381 } … … 383 383 .qo-save-notice.qo-notice-visible { 384 384 opacity: 1; 385 transform: translate X(0);385 transform: translateY(0); 386 386 } 387 387 … … 393 393 margin-right: 6px; 394 394 } 395 396 /* Ensure notice is visible below admin bar */ 397 @media screen and (min-width: 783px) { 398 .qo-save-notice { 399 top: 45px; 400 } 401 } 402 403 @media screen and (max-width: 782px) { 404 .qo-save-notice { 405 top: 56px; 406 right: 10px; 407 left: 10px; 408 text-align: center; 409 } 410 } -
365i-queue-optimizer/trunk/assets/js/admin.js
r3436728 r3436746 164 164 */ 165 165 function initSaveNotification() { 166 // Check if settings were just saved 166 // Check if settings were just saved (check both possible parameter names) 167 167 var urlParams = new URLSearchParams(window.location.search); 168 if (urlParams.get('settings-updated') === 'true') { 169 // Create and show the notification 168 var settingsUpdated = urlParams.get('settings-updated') === 'true'; 169 170 // Also check for the settings saved notice as a fallback 171 var hasWpNotice = $('.qo-settings-saved, .notice-success, .updated').length > 0; 172 173 if (settingsUpdated || hasWpNotice) { 174 // Hide the native WordPress notice 175 $('.qo-settings-saved, .notice-success, .updated').hide(); 176 177 // Create and show our custom notification 170 178 var $notice = $('<div class="qo-save-notice">' + 171 179 '<span class="dashicons dashicons-yes-alt"></span> ' + 172 180 'Settings saved successfully!</div>'); 173 181 174 $(' body').append($notice);175 176 // Trigger animation 182 $('#wpbody').append($notice); 183 184 // Trigger animation after a brief delay 177 185 setTimeout(function() { 178 186 $notice.addClass('qo-notice-visible'); … … 188 196 189 197 // Remove the query parameter from URL without reload 190 var newUrl = window.location.pathname + '?page=queue-optimizer'; 191 window.history.replaceState({}, '', newUrl); 198 if (settingsUpdated) { 199 var newUrl = window.location.pathname + '?page=queue-optimizer'; 200 window.history.replaceState({}, '', newUrl); 201 } 192 202 } 193 203 } -
365i-queue-optimizer/trunk/readme.txt
r3436728 r3436746 4 4 Requires at least: 5.8 5 5 Tested up to: 6.9 6 Stable tag: 1. 4.26 Stable tag: 1.5.0 7 7 Requires PHP: 8.0 8 8 License: GPLv2 or later … … 193 193 194 194 == Changelog == 195 196 = 1.5.0 - 2025-01-10 = 197 198 **Server Detection Improvements** 199 200 * Fixed server detection being too optimistic (shared hosting incorrectly detected as dedicated) 201 * Added manual server type override setting - choose Shared, VPS, or Dedicated manually 202 * More conservative auto-detection thresholds (requires 1GB+ for dedicated, 512MB+ for VPS) 203 * Lowered recommended settings to safer defaults that work better on shared resources 204 * Default fallback changed from VPS to Shared for unknown environments 205 206 **Changed Recommended Settings:** 207 * Shared: 30s time limit, 1 batch, 25 actions, 3 days retention 208 * VPS: 45s time limit, 2 batches, 35 actions, 5 days retention 209 * Dedicated: 60s time limit, 4 batches, 50 actions, 7 days retention 195 210 196 211 = 1.4.2 - 2025-01-10 = … … 336 351 == Upgrade Notice == 337 352 353 = 1.5.0 = 354 Important fix: Server detection now more conservative to prevent failures on shared hosting. Adds manual server type override. Recommended settings lowered to safer defaults. 355 338 356 = 1.4.2 = 339 357 UX improvement: Save notification now appears when settings are saved. -
365i-queue-optimizer/trunk/src/class-queue-optimizer-main.php
r3436597 r3436746 277 277 * 278 278 * @since 1.4.0 279 * @since 1.5.0 Added manual override and more conservative auto-detection. 279 280 * @return string Server type: 'shared', 'vps', or 'dedicated'. 280 281 */ 281 282 private static function detect_server_type() { 282 $memory_bytes = wp_convert_hr_to_bytes( ini_get( 'memory_limit' ) ); 283 $execution_time = (int) ini_get( 'max_execution_time' ); 284 285 // High resources suggest dedicated/VPS. 286 if ( $memory_bytes >= 512 * MB_IN_BYTES && ( $execution_time >= 120 || 0 === $execution_time ) ) { 283 // First check for manual override. 284 $manual = get_option( 'queue_optimizer_server_type_override', '' ); 285 if ( in_array( $manual, array( 'shared', 'vps', 'dedicated' ), true ) ) { 286 return $manual; 287 } 288 289 $memory_bytes = wp_convert_hr_to_bytes( ini_get( 'memory_limit' ) ); 290 $execution_time = (int) ini_get( 'max_execution_time' ); 291 292 // Very high thresholds for "dedicated" - be conservative. 293 // Many shared hosts now offer high PHP limits but share CPU/DB resources. 294 if ( $memory_bytes >= 1024 * MB_IN_BYTES && ( $execution_time >= 300 || 0 === $execution_time ) ) { 287 295 return 'dedicated'; 288 296 } 289 297 290 // Medium resources suggest VPS/managed.291 if ( $memory_bytes >= 256 * MB_IN_BYTES && $execution_time >= 60 ) {298 // Higher thresholds for "vps". 299 if ( $memory_bytes >= 512 * MB_IN_BYTES && $execution_time >= 120 ) { 292 300 return 'vps'; 293 301 } 294 302 295 // Lower resources suggest shared hosting.303 // Default: assume shared hosting (safest). 296 304 return 'shared'; 297 305 } … … 301 309 * 302 310 * @since 1.4.0 311 * @since 1.5.0 More conservative default values. 303 312 * @return array Recommended settings. 304 313 */ … … 306 315 $server_type = self::detect_server_type(); 307 316 317 // Conservative recommendations to prevent failures on shared resources. 308 318 $recommendations = array( 309 319 'shared' => array( 310 320 'time_limit' => 30, 311 'concurrent_batches' => 2,321 'concurrent_batches' => 1, 312 322 'batch_size' => 25, 313 323 'retention_days' => 3, 314 324 ), 315 325 'vps' => array( 326 'time_limit' => 45, 327 'concurrent_batches' => 2, 328 'batch_size' => 35, 329 'retention_days' => 5, 330 ), 331 'dedicated' => array( 316 332 'time_limit' => 60, 317 333 'concurrent_batches' => 4, … … 319 335 'retention_days' => 7, 320 336 ), 321 'dedicated' => array(322 'time_limit' => 120,323 'concurrent_batches' => 8,324 'batch_size' => 100,325 'retention_days' => 14,326 ),327 337 ); 328 338 329 339 return isset( $recommendations[ $server_type ] ) 330 340 ? $recommendations[ $server_type ] 331 : $recommendations[' vps'];341 : $recommendations['shared']; 332 342 } 333 343 -
365i-queue-optimizer/trunk/templates/partials/header.php
r3421676 r3436746 13 13 <div class="wrap"> 14 14 <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> 15 15 16 <?php if ( isset( $_GET['settings-updated'] ) && 'true' === $_GET['settings-updated'] ) : // phpcs:ignore WordPress.Security.NonceVerification.Recommended ?> 17 <div class="notice notice-success is-dismissible qo-settings-saved"> 18 <p><?php esc_html_e( 'Settings saved.', '365i-queue-optimizer' ); ?></p> 19 </div> 20 <?php endif; ?> 21 16 22 <div class="notice notice-info"> 17 23 <p><strong><?php esc_html_e( 'Simple & Fast', '365i-queue-optimizer' ); ?></strong></p> -
365i-queue-optimizer/trunk/uninstall.php
r3436597 r3436746 17 17 delete_option( 'queue_optimizer_retention_days' ); 18 18 delete_option( 'queue_optimizer_image_engine' ); 19 delete_option( 'queue_optimizer_server_type_override' ); 19 20 delete_option( 'queue_optimizer_activated' ); 20 21
Note: See TracChangeset
for help on using the changeset viewer.