Plugin Directory

Changeset 3403732


Ignore:
Timestamp:
11/27/2025 02:20:05 AM (3 months ago)
Author:
awcode
Message:

smush

Location:
awcode-toolkit/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • awcode-toolkit/trunk/aw-toolkit.php

    r3291514 r3403732  
    22/*
    33 * Plugin Name: AWcode Toolkit
    4  * Version: 1.0.19
     4 * Version: 1.0.20
    55 * Description: A collection of useful tools and functions for Wordpress site owners
    66 * Author: AWcode
    77 * Author URI: https://awcode.com/
    88 * Requires at least: 5.0
    9  * Tested up to: 6.8.1
     9 * Tested up to: 6.8.3
    1010 * License: GPLv2
    1111 *
     
    7272}
    7373
     74
     75//Increase smush limits
     76if ( ! defined( 'WP_SMUSH_MAX_BYTES' ) ) {
     77        define( 'WP_SMUSH_MAX_BYTES', 52428800 ); // 500MB
     78}
     79
     80
     81if ( ! class_exists( 'AW_WP_Nonstop_Smushit' ) ) {
     82    class AW_WP_Nonstop_Smushit {
     83
     84        protected static $instance = null;
     85
     86        public static function get_instance() {
     87            if ( is_null( self::$instance ) ) {
     88                self::$instance = new self();
     89            }
     90            return self::$instance;
     91        }
     92
     93        protected function __construct() {
     94            if ( ! $this->has_wp_smushit() ) {
     95                //skip silently
     96            } else {
     97                add_action( 'admin_footer', [ $this, 'enqueue_scripts' ] );
     98                add_action( 'admin_head', function() {
     99                    ?>
     100                    <script>
     101                        !function(){const t=EventTarget.prototype.addEventListener;EventTarget.prototype.addEventListener=function(e,n,r){if("click"===e&&this.matches&&this.matches(".wp-smush-resume-bulk-smush")){const i=function(t){const e=new Proxy(t,{get(t,e){if("isTrusted"===e)return!0;if("clientX"===e)return t.clientX||100;if("clientY"===e)return t.clientY||100;const n=t[e];return"function"==typeof n?n.bind(t):n}});return n.call(this,e)};return t.call(this,e,i,r)}return t.call(this,e,n,r)}}();
     102                    </script>
     103                    <?php
     104                }, 0 );
     105            }
     106        }
     107
     108        /**
     109         * Check the existence of WP Smushit plugin
     110         * @return bool
     111         */
     112        protected function has_wp_smushit() {
     113            return defined( 'WP_SMUSH_VERSION' ) || class_exists( '\Smush\WP_Smush' ) || class_exists( 'WP_Smush' );
     114        }
     115
     116
     117        public function enqueue_scripts() {
     118            ?>
     119            <script>
     120                jQuery(document).ready(function($) {
     121                    ;(function(window) {
     122                        'use strict';
     123                        if (!window.MutationObserver) {
     124                            return;
     125                        }
     126
     127                        var observer = new MutationObserver(function(mutations) {
     128                            mutations.forEach(function(mutation) {
     129                                if (mutation.type !== 'attributes' || mutation.attributeName !== 'class') {
     130                                    return;
     131                                }
     132
     133                                var exceeded = mutation.target.classList.contains('wp-smush-exceed-limit');
     134                                if (exceeded) {
     135                                    const button = mutation.target.querySelector('.wp-smush-resume-bulk-smush');
     136                                    if (button) {
     137                                        button.click();
     138                                    }
     139                                }
     140                            });
     141                        });
     142
     143                        const container = document.querySelector('.wp-smush-bulk-progress-bar-wrapper');
     144                        if (container) {
     145                            observer.observe(container, {attributes: true});
     146                        }
     147                    })(window);
     148                });
     149            </script>
     150        <?php
     151        }
     152    }
     153}
     154
     155add_action( 'plugins_loaded', [ 'AW_WP_Nonstop_Smushit', 'get_instance' ], 20 );
     156
     157
    74158?>
  • awcode-toolkit/trunk/readme.txt

    r3291514 r3403732  
    44Tags: woocommerce, cloudflare, awcode, web developer, web design
    55Requires at least: 5.0
    6 Tested up to: 6.8.1
    7 Stable tag: 1.0.19
     6Tested up to: 6.8.3
     7Stable tag: 1.0.20
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5050== Upgrade Notice ==
    5151
    52 = 1.0.19 =
    53 Security Enhancements
     52= 1.0.20 =
     53Increase plugin limits
    5454
    5555== Changelog ==
     56
     57= 1.0.20 =
     58Increase plugin limits
    5659
    5760= 1.0.19 =
Note: See TracChangeset for help on using the changeset viewer.