HEX
Server: LiteSpeed
System: Linux eko108.isimtescil.net 4.18.0-477.21.1.lve.1.el8.x86_64 #1 SMP Tue Sep 5 23:08:35 UTC 2023 x86_64
User: uyarreklamcomtr (11202)
PHP: 7.4.33
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/Event.tar
ClearProductStatsCache.php000064400000002654151542174340011624 0ustar00<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Event;

use Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\Registerable;
use Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\Service;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\MerchantStatuses;
use Exception;

defined( 'ABSPATH' ) || exit;

/**
 * Class ClearProductStatsCache
 *
 * @since 1.1.0
 *
 * @package Automattic\WooCommerce\GoogleListingsAndAds\Product
 */
class ClearProductStatsCache implements Registerable, Service {
	/**
	 * @var MerchantStatuses
	 */
	protected $merchant_statuses;

	/**
	 * ClearProductStatsCache constructor.
	 *
	 * @param MerchantStatuses $merchant_statuses
	 */
	public function __construct( MerchantStatuses $merchant_statuses ) {
		$this->merchant_statuses = $merchant_statuses;
	}

	/**
	 * Register a service.
	 */
	public function register(): void {
		add_action(
			'woocommerce_gla_batch_updated_products',
			function () {
				$this->clear_stats_cache();
			}
		);
		add_action(
			'woocommerce_gla_batch_deleted_products',
			function () {
				$this->clear_stats_cache();
			}
		);
	}

	/**
	 * Clears the product statistics cache
	 */
	protected function clear_stats_cache() {
		try {
			$this->merchant_statuses->clear_cache();
		} catch ( Exception $exception ) {
			// log and fail silently
			do_action( 'woocommerce_gla_exception', $exception, __METHOD__ );
		}
	}
}
StartProductSync.php000064400000003316151542174340010561 0ustar00<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Event;

use Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\Registerable;
use Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\Service;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\CleanupProductsJob;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\JobRepository;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\UpdateAllProducts;

defined( 'ABSPATH' ) || exit;

/**
 * Class StartProductSync
 *
 * @package Automattic\WooCommerce\GoogleListingsAndAds\Product
 */
class StartProductSync implements Registerable, Service {
	/**
	 * @var JobRepository
	 */
	protected $job_repository;

	/**
	 * StartProductSync constructor.
	 *
	 * @param JobRepository $job_repository
	 */
	public function __construct( JobRepository $job_repository ) {
		$this->job_repository = $job_repository;
	}

	/**
	 * Register a service.
	 */
	public function register(): void {
		add_action(
			'woocommerce_gla_mc_settings_sync',
			function () {
				$this->on_settings_sync();
			}
		);

		add_action(
			'woocommerce_gla_mapping_rules_change',
			function () {
				$this->on_rules_change();
			}
		);
	}

	/**
	 * Start the cleanup and update all products.
	 */
	protected function on_settings_sync() {
		$cleanup = $this->job_repository->get( CleanupProductsJob::class );
		$cleanup->schedule();

		$update = $this->job_repository->get( UpdateAllProducts::class );
		$update->schedule();
	}

	/**
	 * Creates a Job for updating all products with a 30 minutes delay.
	 */
	protected function on_rules_change() {
		$update = $this->job_repository->get( UpdateAllProducts::class );
		$update->schedule_delayed( 1800 ); // 30 minutes
	}
}