diff --git a/classes/Traits/InstanceGetterTrait.php b/classes/Traits/InstanceGetterTrait.php index 239147373..e847ca45c 100644 --- a/classes/Traits/InstanceGetterTrait.php +++ b/classes/Traits/InstanceGetterTrait.php @@ -9,7 +9,7 @@ * This is temporary, until we get a DI container. * * @since 1.9 - * @since 1.9.4 Renamed FakeSingletonTrait into InstanceGetterTrait. + * @since 1.9.4 Renamed into InstanceGetterTrait. * @author Grégory Viguier */ trait InstanceGetterTrait { diff --git a/imagify.php b/imagify.php index 0d50a0fa4..fb78d43ef 100644 --- a/imagify.php +++ b/imagify.php @@ -3,7 +3,7 @@ * Plugin Name: Imagify * Plugin URI: https://wordpress.org/plugins/imagify/ * Description: Dramaticaly reduce image file sizes without losing quality, make your website load faster, boost your SEO and save money on your bandwidth using Imagify, the new most advanced image optimization tool. - * Version: 1.9.6 + * Version: 1.9.7 * Requires PHP: 5.4 * Author: WP Media * Author URI: https://wp-media.me/ @@ -20,7 +20,7 @@ defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' ); // Imagify defines. -define( 'IMAGIFY_VERSION', '1.9.6' ); +define( 'IMAGIFY_VERSION', '1.9.7' ); define( 'IMAGIFY_SLUG', 'imagify' ); define( 'IMAGIFY_FILE', __FILE__ ); define( 'IMAGIFY_PATH', realpath( plugin_dir_path( IMAGIFY_FILE ) ) . '/' ); diff --git a/inc/3rd-party/wp-rocket/classes/Main.php b/inc/3rd-party/wp-rocket/classes/Main.php index 453d3948f..3b7d092c4 100755 --- a/inc/3rd-party/wp-rocket/classes/Main.php +++ b/inc/3rd-party/wp-rocket/classes/Main.php @@ -20,8 +20,8 @@ class Main { * @author Grégory Viguier */ public function init() { - add_action( 'imagify_assets_enqueued', [ $this, 'dequeue_sweetalert' ] ); - add_filter( 'imagify_cdn_source', [ $this, 'set_cdn_source' ] ); + add_action( 'admin_init', [ $this, 'dequeue_sweetalert' ] ); + add_filter( 'imagify_cdn_source', [ $this, 'set_cdn_source' ] ); } @@ -30,14 +30,18 @@ public function init() { /** ----------------------------------------------------------------------------------------- */ /** - * Don't load Imagify CSS & JS files on WP Rocket options screen to avoid conflict with older version of SweetAlert. + * Remove all Imagify admin notices + CSS & JS files on WP Rocket (< 3.0) options screen to avoid conflict with older version of SweetAlert. * * @since 1.9.3 * @access public * @author Grégory Viguier */ public function dequeue_sweetalert() { - if ( ! defined( 'WP_ROCKET_PLUGIN_SLUG' ) ) { + if ( ! defined( 'WP_ROCKET_VERSION' ) || ! defined( 'WP_ROCKET_PLUGIN_SLUG' ) ) { + return; + } + + if ( version_compare( WP_ROCKET_VERSION, '3.0' ) >= 0 ) { return; } @@ -45,7 +49,8 @@ public function dequeue_sweetalert() { return; } - \Imagify_Assets::get_instance()->dequeue_script( array( 'sweetalert-core', 'sweetalert', 'notices' ) ); + remove_action( 'all_admin_notices', [ \Imagify_Notices::get_instance(), 'render_notices' ] ); + remove_action( 'admin_enqueue_scripts', [ \Imagify_Assets::get_instance(), 'enqueue_styles_and_scripts' ], IMAGIFY_INT_MAX ); } /** diff --git a/inc/classes/class-imagify-plugin.php b/inc/classes/class-imagify-plugin.php index 070ae2b9f..a04a2d4b5 100644 --- a/inc/classes/class-imagify-plugin.php +++ b/inc/classes/class-imagify-plugin.php @@ -99,6 +99,13 @@ public function include_files() { require_once $this->plugin_path . 'vendor/autoload.php'; } + $instance_getter_path = $this->plugin_path . 'classes/Traits/InstanceGetterTrait.php'; + + if ( file_exists( $instance_getter_path . '.suspected' ) && ! file_exists( $instance_getter_path ) ) { + // Trolling greedy antiviruses. + require_once $instance_getter_path . '.suspected'; + } + $inc_path = $this->plugin_path . 'inc/'; require_once $inc_path . 'deprecated/deprecated.php'; diff --git a/package.json b/package.json index bd0802ac6..56d0c74bd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "imagify", "description": "Imagify Image Optimizer. Dramatically reduce image file sizes without losing quality, make your website load faster, boost your SEO and save money on your bandwidth.", - "version": "1.9.6", + "version": "1.9.7", "homepage": "https://wordpress.org/plugins/imagify/", "license": "GPL-2.0", "private": true, diff --git a/readme.txt b/readme.txt index 53a0e8d88..32f7eb542 100755 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: wp_media, GregLone Tags: optimize images, images, optimize, performance, webp Requires at least: 4.0.0 Tested up to: 5.2.2 -Stable tag: 1.9.6 +Stable tag: 1.9.7 Optimize images in one click: reduce image file sizes, convert WebP, keep your images beautiful… and boost your loading time and your SEO! @@ -153,6 +153,11 @@ When the plugin is disabled, your existing images remain optimized. Backups of t 4. Other Media Page == Changelog == += 1.9.7 - 2019/10/08 = +* Improvement: prevent greedy antiviruses from crashing the website by renaming our highly dangerous php file with a ".suspected" suffix. +* Improvement: on the settings page, display the "Save & Go to Bulk Optimizer" button only if the user has the ability to bulk optimize. +* Fix: display the "Welcome" banner correctly when it is shown on the WP Rocket’s settings page. + = 1.9.6 - 2019/07/22 = * Improvement: now images that are "already optimized" can also get webp versions. * Fix: progress bar height in the admin bar for Chrome and Safari. diff --git a/views/part-settings-footer.php b/views/part-settings-footer.php index 93a414ab4..ae1e45cbc 100755 --- a/views/part-settings-footer.php +++ b/views/part-settings-footer.php @@ -9,14 +9,18 @@ submit_button(); if ( Imagify_Requirements::is_api_key_valid() ) { - // Submit and go to bulk page. - submit_button( - esc_html__( 'Save & Go to Bulk Optimizer', 'imagify' ), - 'secondary imagify-button-secondary', // Type/classes. - 'submit-goto-bulk', // Name (id). - true, // Wrap. - array() // Other attributes. - ); + $user_can = imagify_get_context( 'wp' )->current_user_can( 'bulk-optimize' ) || imagify_get_context( 'custom-folders' )->current_user_can( 'bulk-optimize' ); + + if ( $user_can ) { + // Submit and go to bulk page. + submit_button( + esc_html__( 'Save & Go to Bulk Optimizer', 'imagify' ), + 'secondary imagify-button-secondary', // Type/classes. + 'submit-goto-bulk', // Name (id). + true, // Wrap. + array() // Other attributes. + ); + } } ?>