MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //home/cafsindia/www/wp-content/plugins/imageseo/src/Actions/Admin/UpdateCounterImages.php
<?php

namespace ImageSeoWP\Actions\Admin;

if (!defined('ABSPATH')) {
    exit;
}

use ImageSeoWP\Async\QueryImagesNoAltBackgroundProcess;
use ImageSeoWP\Async\QueryTotalImagesBackgroundProcess;

class UpdateCounterImages
{
    public function __construct()
    {
        $this->processQueryImagesNoAlt = new QueryImagesNoAltBackgroundProcess();
        $this->processQueryTotalImages = new QueryTotalImagesBackgroundProcess();
    }

    public function hooks()
    {
        add_action('admin_post_imageseo_recount_images', [$this, 'recountImages']);
    }

    public function recountImages()
    {
        $redirectUrl = admin_url('admin.php?page=imageseo-settings');

        if (!wp_verify_nonce($_GET['_wpnonce'], 'imageseo_recount_images')) {
            wp_redirect($redirectUrl);
            exit;
        }

        if (!current_user_can('manage_options')) {
            wp_redirect($redirectUrl);
            exit;
        }

        set_transient('imageseo_process_query_count_images', true, 20);

        $this->processQueryImagesNoAlt->push_to_queue([
            'query_images_no_alt' => true,
        ]);
        $this->processQueryImagesNoAlt->save()->dispatch();

        $this->processQueryTotalImages->push_to_queue([
            'query_total_images' => true,
        ]);
        $this->processQueryTotalImages->save()->dispatch();

        wp_redirect($redirectUrl);
    }
}