diff --git a/src/class-tiny-image.php b/src/class-tiny-image.php index 5ee627f6..826395c7 100644 --- a/src/class-tiny-image.php +++ b/src/class-tiny-image.php @@ -102,7 +102,7 @@ public function get_mime_type() { public function compress( $settings ) { - if ( $settings->get_compressor() === null || ! $this->can_be_compressed() ) { + if ( ! $settings->running() || $settings->get_compressor() === null || ! $this->can_be_compressed() ) { return; } diff --git a/src/class-tiny-plugin.php b/src/class-tiny-plugin.php index 65ce3421..01def4d7 100644 --- a/src/class-tiny-plugin.php +++ b/src/class-tiny-plugin.php @@ -50,6 +50,14 @@ public function set_compressor($compressor) { $this->settings->set_compressor( $compressor ); } + public function start () { + $this->settings->start(); + } + + public function pause () { + $this->settings->pause(); + } + public function init() { add_filter( 'jpeg_quality', $this->get_static_method( 'jpeg_quality' ) diff --git a/src/class-tiny-settings.php b/src/class-tiny-settings.php index 63cde311..999c1b6d 100644 --- a/src/class-tiny-settings.php +++ b/src/class-tiny-settings.php @@ -24,6 +24,7 @@ class Tiny_Settings extends Tiny_WP_Base { private $tinify_sizes; private $compressor; private $notices; + private $_running = true; public function __construct() { parent::__construct(); @@ -37,6 +38,18 @@ private function init_compressor() { ); } + public function pause () { + $this->_running = FALSE; + } + + public function start () { + $this->_running = TRUE; + } + + public function running () { + return $this->_running; + } + public function get_absolute_url() { return get_admin_url( null, 'options-media.php#' . self::NAME ); }