Plugin Directory

Changeset 3436746


Ignore:
Timestamp:
01/10/2026 05:39:05 PM (3 months ago)
Author:
bsolveit
Message:

Version 1.5.0 - Fix server detection, add manual override

  • Fixed server detection being too optimistic (shared hosting incorrectly detected as dedicated)
  • Added manual server type override setting (Shared/VPS/Dedicated dropdown)
  • More conservative auto-detection thresholds (1GB+ for dedicated, 512MB+ for VPS)
  • Lowered recommended settings to safer defaults
  • Default fallback changed from VPS to Shared for unknown environments
Location:
365i-queue-optimizer/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • 365i-queue-optimizer/trunk/365i-queue-optimizer.php

    r3436728 r3436746  
    44 * Plugin URI: https://www.365i.co.uk/blog/2025/04/20/fix-wordpress-6-8-slow-image-uploads-with-365i-queue-optimizer/
    55 * Description: A lightweight WordPress plugin to optimize ActionScheduler queue processing for faster image optimization and background tasks.
    6  * Version: 1.4.2
     6 * Version: 1.5.0
    77 * Author: 365i
    88 * Author URI: https://www.mcneece.com/author/mark-mcneece/
     
    2222
    2323// Define plugin constants.
    24 define( 'QUEUE_OPTIMIZER_VERSION', '1.4.2' );
     24define( 'QUEUE_OPTIMIZER_VERSION', '1.5.0' );
    2525define( 'QUEUE_OPTIMIZER_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
    2626define( 'QUEUE_OPTIMIZER_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
  • 365i-queue-optimizer/trunk/admin/class-settings-page.php

    r3436597 r3436746  
    107107        ) );
    108108
     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
    109115        add_settings_section(
    110116            'queue_optimizer_main',
     
    150156            __( 'Image Processing Engine', '365i-queue-optimizer' ),
    151157            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' ),
    152166            'queue_optimizer_settings',
    153167            'queue_optimizer_main'
     
    525539        return in_array( $value, $allowed, true ) ? $value : 'WP_Image_Editor_Imagick';
    526540    }
     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    }
    527586}
  • 365i-queue-optimizer/trunk/assets/css/admin.css

    r3436728 r3436746  
    366366.qo-save-notice {
    367367    position: fixed;
    368     top: 50px;
    369     right: 20px;
     368    top: 45px;
     369    right: 25px;
    370370    z-index: 99999;
    371371    background: #00a32a;
    372372    color: #fff;
    373     padding: 12px 20px;
     373    padding: 14px 22px;
    374374    border-radius: 4px;
    375375    font-size: 14px;
    376376    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);
    378378    opacity: 0;
    379     transform: translateX(100px);
     379    transform: translateY(-20px);
    380380    transition: all 0.3s ease;
    381381}
     
    383383.qo-save-notice.qo-notice-visible {
    384384    opacity: 1;
    385     transform: translateX(0);
     385    transform: translateY(0);
    386386}
    387387
     
    393393    margin-right: 6px;
    394394}
     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  
    164164     */
    165165    function initSaveNotification() {
    166         // Check if settings were just saved
     166        // Check if settings were just saved (check both possible parameter names)
    167167        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
    170178            var $notice = $('<div class="qo-save-notice">' +
    171179                '<span class="dashicons dashicons-yes-alt"></span> ' +
    172180                'Settings saved successfully!</div>');
    173181
    174             $('body').append($notice);
    175 
    176             // Trigger animation
     182            $('#wpbody').append($notice);
     183
     184            // Trigger animation after a brief delay
    177185            setTimeout(function() {
    178186                $notice.addClass('qo-notice-visible');
     
    188196
    189197            // 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            }
    192202        }
    193203    }
  • 365i-queue-optimizer/trunk/readme.txt

    r3436728 r3436746  
    44Requires at least: 5.8
    55Tested up to: 6.9
    6 Stable tag: 1.4.2
     6Stable tag: 1.5.0
    77Requires PHP: 8.0
    88License: GPLv2 or later
     
    193193
    194194== 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
    195210
    196211= 1.4.2 - 2025-01-10 =
     
    336351== Upgrade Notice ==
    337352
     353= 1.5.0 =
     354Important fix: Server detection now more conservative to prevent failures on shared hosting. Adds manual server type override. Recommended settings lowered to safer defaults.
     355
    338356= 1.4.2 =
    339357UX improvement: Save notification now appears when settings are saved.
  • 365i-queue-optimizer/trunk/src/class-queue-optimizer-main.php

    r3436597 r3436746  
    277277     *
    278278     * @since 1.4.0
     279     * @since 1.5.0 Added manual override and more conservative auto-detection.
    279280     * @return string Server type: 'shared', 'vps', or 'dedicated'.
    280281     */
    281282    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 ) ) {
    287295            return 'dedicated';
    288296        }
    289297
    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 ) {
    292300            return 'vps';
    293301        }
    294302
    295         // Lower resources suggest shared hosting.
     303        // Default: assume shared hosting (safest).
    296304        return 'shared';
    297305    }
     
    301309     *
    302310     * @since 1.4.0
     311     * @since 1.5.0 More conservative default values.
    303312     * @return array Recommended settings.
    304313     */
     
    306315        $server_type = self::detect_server_type();
    307316
     317        // Conservative recommendations to prevent failures on shared resources.
    308318        $recommendations = array(
    309319            'shared' => array(
    310320                'time_limit'         => 30,
    311                 'concurrent_batches' => 2,
     321                'concurrent_batches' => 1,
    312322                'batch_size'         => 25,
    313323                'retention_days'     => 3,
    314324            ),
    315325            'vps' => array(
     326                'time_limit'         => 45,
     327                'concurrent_batches' => 2,
     328                'batch_size'         => 35,
     329                'retention_days'     => 5,
     330            ),
     331            'dedicated' => array(
    316332                'time_limit'         => 60,
    317333                'concurrent_batches' => 4,
     
    319335                'retention_days'     => 7,
    320336            ),
    321             'dedicated' => array(
    322                 'time_limit'         => 120,
    323                 'concurrent_batches' => 8,
    324                 'batch_size'         => 100,
    325                 'retention_days'     => 14,
    326             ),
    327337        );
    328338
    329339        return isset( $recommendations[ $server_type ] )
    330340            ? $recommendations[ $server_type ]
    331             : $recommendations['vps'];
     341            : $recommendations['shared'];
    332342    }
    333343
  • 365i-queue-optimizer/trunk/templates/partials/header.php

    r3421676 r3436746  
    1313<div class="wrap">
    1414    <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
    1622    <div class="notice notice-info">
    1723        <p><strong><?php esc_html_e( 'Simple & Fast', '365i-queue-optimizer' ); ?></strong></p>
  • 365i-queue-optimizer/trunk/uninstall.php

    r3436597 r3436746  
    1717delete_option( 'queue_optimizer_retention_days' );
    1818delete_option( 'queue_optimizer_image_engine' );
     19delete_option( 'queue_optimizer_server_type_override' );
    1920delete_option( 'queue_optimizer_activated' );
    2021
Note: See TracChangeset for help on using the changeset viewer.