: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Smush directory smush scanner: DScanner class
* @package Smush\Core\Modules\Helpers
* @author Anton Vanyukov <anton@incsub.com>
* @copyright (c) 2018, Incsub (http://incsub.com)
namespace Smush\Core\Modules\Helpers;
if ( ! defined( 'ABSPATH' ) ) {
* Indicates if a scan is in process
private $is_scanning = false;
* Indicates the current step being scanned
private $current_step = 0;
const IS_SCANNING_SLUG = 'wp-smush-files-scanning';
const CURRENT_STEP = 'wp-smush-scan-step';
* Refresh status variables.
private function refresh_status() {
$this->is_scanning = get_transient( self::IS_SCANNING_SLUG );
$this->current_step = (int) get_option( self::CURRENT_STEP );
public function init_scan() {
set_transient( self::IS_SCANNING_SLUG, true, 60 * 5 ); // 5 minutes max
update_option( self::CURRENT_STEP, 0 );
* Reset the scan as if it weren't being executed (on finish and cancel).
public function reset_scan() {
delete_transient( self::IS_SCANNING_SLUG );
delete_option( self::CURRENT_STEP );
* Update the current step being scanned.
* @param int $step Current scan step.
public function update_current_step( $step ) {
update_option( self::CURRENT_STEP, absint( $step ) );
* Get the current scan step being scanned.
public function get_current_scan_step() {
return $this->current_step;
* Return the number of total steps to finish the scan.
public function get_scan_steps() {
return count( WP_Smush::get_instance()->core()->mod->dir->get_scanned_images() );
* Check if a scanning is in process
public function is_scanning() {
return $this->is_scanning;