HEX
Server: Apache/2
System: Linux bq-e705.pointdnshere.com 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User: wellmix (1103)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/wellmix/public_html/wp-content/plugins/weglot/src/third/wprocket/class-wprocket-cache.php
<?php

namespace WeglotWP\Third\Wprocket;

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

use Exception;
use WeglotWP\Models\Hooks_Interface_Weglot;
use WeglotWP\Services\Option_Service_Weglot;



/**
 * Wp_Optimize_Cache
 *
 * @since 3.1.4
 */
class Wprocket_Cache implements Hooks_Interface_Weglot {
	/**
	 * @var Wprocket_Active
	 */
	private $wprocket_active_services;
	/**
	 * @var Option_Service_Weglot
	 */
	private $option_services;

	/**
	 * @return void
	 * @throws Exception
	 * @since 3.1.4
	 */
	public function __construct() {
		$this->wprocket_active_services = weglot_get_service( 'Wprocket_Active' );
		$this->option_services          = weglot_get_service( 'Option_Service_Weglot' );
	}

	/**
	 * @return void
	 * @throws Exception
	 * @since 3.1.4
	 * @see Hooks_Interface_Weglot
	 */
	public function hooks() {
		if ( ! $this->wprocket_active_services->is_active() ) {
			return;
		}

		if ( ! isset( $_COOKIE['weglot_wp_rocket_cache'] ) && $this->option_services->get_option( 'auto_redirect' ) ) {
			add_action( 'send_headers', array( $this, 'set_weglot_wp_rocket_cache' ), 10, 1 );
		}
	}

	public function set_weglot_wp_rocket_cache(){
		setcookie( 'weglot_wp_rocket_cache', 'true' ); //phpcs:ignore
	}
}