Skip to content

Add Start and Pause Functions for backend development. Pause compress… #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/class-tiny-image.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 8 additions & 0 deletions src/class-tiny-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' )
Expand Down
13 changes: 13 additions & 0 deletions src/class-tiny-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 );
}
Expand Down