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/Requirements.tar
GoogleProductFeedValidator.php000064400000005633151547535340012507 0ustar00<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Internal\Requirements;

use Automattic\WooCommerce\GoogleListingsAndAds\Exception\ExtensionRequirementException;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\MerchantStatuses;
use Automattic\WooCommerce\GoogleListingsAndAds\PluginHelper;
use DateTime;

defined( 'ABSPATH' ) || exit;

/**
 * Class GoogleProductFeedValidator
 *
 * @since 1.2.0
 *
 * @package AutomatticWooCommerceGoogleListingsAndAdsInternalRequirements
 */
class GoogleProductFeedValidator extends RequirementValidator {

	use PluginHelper;

	/**
	 * Validate all requirements for the plugin to function properly.
	 *
	 * @return bool
	 */
	public function validate(): bool {
		try {
			$this->validate_google_product_feed_inactive();
		} catch ( ExtensionRequirementException $e ) {

			add_filter(
				'woocommerce_gla_custom_merchant_issues',
				function ( $issues, $current_time ) {
					return $this->add_conflict_issue( $issues, $current_time );
				},
				10,
				2
			);

			add_action(
				'deactivated_plugin',
				function ( $plugin ) {
					if ( 'woocommerce-product-feeds/woocommerce-gpf.php' === $plugin ) {
						/** @var MerchantStatuses $merchant_statuses */
						$merchant_statuses = woogle_get_container()->get( MerchantStatuses::class );
						if ( $merchant_statuses instanceof MerchantStatuses ) {
							$merchant_statuses->clear_cache();
						}
					}
				}
			);
		}
		return true;
	}

	/**
	 * Validate that Google Product Feed isn't enabled.
	 *
	 * @throws ExtensionRequirementException When Google Product Feed is active.
	 */
	protected function validate_google_product_feed_inactive() {
		if ( defined( 'WOOCOMMERCE_GPF_VERSION' ) ) {
			throw ExtensionRequirementException::incompatible_plugin( 'Google Product Feed' );
		}
	}

	/**
	 * Add an account-level issue regarding the plugin conflict
	 * to the array of issues to be saved in the database.
	 *
	 * @param array    $issues The current array of account-level issues
	 * @param DateTime $cache_created_time The time of the cache/issues generation.
	 *
	 * @return array The issues with the new conflict issue included
	 */
	protected function add_conflict_issue( array $issues, DateTime $cache_created_time ): array {
		$issues[] = [
			'product_id' => 0,
			'product'    => 'All products',
			'code'       => 'incompatible_google_product_feed',
			'issue'      => __( 'The Google Product Feed plugin may cause conflicts or unexpected results.', 'google-listings-and-ads' ),
			'action'     => __( 'Deactivate the Google Product Feed plugin from your store', 'google-listings-and-ads' ),
			'action_url' => 'https://developers.google.com/shopping-content/guides/best-practices#do-not-use-api-and-feeds',
			'created_at' => $cache_created_time->format( 'Y-m-d H:i:s' ),
			'type'       => MerchantStatuses::TYPE_ACCOUNT,
			'severity'   => 'error',
			'source'     => 'filter',
		];

		return $issues;
	}
}
PluginValidator.php000064400000002261151547535340010376 0ustar00<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Internal\Requirements;

use Automattic\WooCommerce\GoogleListingsAndAds\Internal\Requirements\WCAdminValidator;
use Automattic\WooCommerce\GoogleListingsAndAds\Internal\Requirements\WCValidator;

defined( 'ABSPATH' ) || exit;

/**
 * Class PluginValidator
 *
 * Display admin notices for required and incompatible plugins.
 *
 * @package AutomatticWooCommerceGoogleListingsAndAdsInternalRequirements
 */
class PluginValidator {

	private const PLUGINS = [
		WCAdminValidator::class,
		WCValidator::class,
		GoogleProductFeedValidator::class,
	];

	/**
	 * @var bool $is_validated
	 * Holds the validation status of the plugin.
	 */
	protected static $is_validated = null;

	/**
	 * Validate all required and incompatible plugins.
	 *
	 * @return bool
	 */
	public static function validate(): bool {
		if ( null !== self::$is_validated ) {
			return self::$is_validated;
		}

		self::$is_validated = true;

		/** @var RequirementValidator $plugin */
		foreach ( self::PLUGINS as $plugin ) {
			if ( ! $plugin::instance()->validate() ) {
				self::$is_validated = false;
			}
		}
		return self::$is_validated;
	}
}
RequirementValidator.php000064400000002451151547535340011441 0ustar00<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Internal\Requirements;

use Automattic\WooCommerce\GoogleListingsAndAds\Exception\RuntimeExceptionWithMessageFunction;

defined( 'ABSPATH' ) || exit;

/**
 * Class RequirementValidator
 *
 * @package AutomatticWooCommerceGoogleListingsAndAdsInternalRequirements
 */
abstract class RequirementValidator implements RequirementValidatorInterface {

	/**
	 * @var RequirementValidator[]
	 */
	private static $instances = [];

	/**
	 * Get the instance of the RequirementValidator object.
	 *
	 * @return RequirementValidator
	 */
	public static function instance(): RequirementValidator {
		$class = get_called_class();
		if ( ! isset( self::$instances[ $class ] ) ) {
			self::$instances[ $class ] = new $class();
		}
		return self::$instances[ $class ];
	}


	/**
	 * Add a standard requirement validation error notice.
	 *
	 * @param RuntimeExceptionWithMessageFunction $e
	 */
	protected function add_admin_notice( RuntimeExceptionWithMessageFunction $e ) {
		// Display notice error message.
		add_action(
			'admin_notices',
			function () use ( $e ) {
				echo '<div class="notice notice-error">' . PHP_EOL;
				echo '	<p>' . esc_html( $e->get_formatted_message() ) . '</p>' . PHP_EOL;
				echo '</div>' . PHP_EOL;
			}
		);
	}
}
RequirementValidatorInterface.php000064400000000732151547535340013262 0ustar00<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Internal\Requirements;

defined( 'ABSPATH' ) || exit;

/**
 * Interface RequirementValidatorInterface
 *
 * @package AutomatticWooCommerceGoogleListingsAndAdsInternalRequirements
 */
interface RequirementValidatorInterface {
	/**
	 * Validate requirements for plugin to function properly.
	 *
	 * @return bool True if the requirements are met.
	 */
	public function validate(): bool;
}
VersionValidator.php000064400000003062151547535340010565 0ustar00<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Internal\Requirements;

use Automattic\WooCommerce\GoogleListingsAndAds\Exception\InvalidVersion;

defined( 'ABSPATH' ) || exit;

/**
 * Class VersionValidator. Validates PHP Requirements like the version and the architecture.
 *
 * @package AutomatticWooCommerceGoogleListingsAndAdsInternalRequirements
 */
class VersionValidator extends RequirementValidator {

	/**
	 * Validate all requirements for the plugin to function properly.
	 *
	 * @return bool
	 */
	public function validate(): bool {
		try {
			$this->validate_php_version();
			$this->validate_php_architecture();
			return true;
		} catch ( InvalidVersion $e ) {
			$this->add_admin_notice( $e );
			return false;
		}
	}

	/**
	 * Validate the PHP version being used.
	 *
	 * @throws InvalidVersion When the PHP version does not meet the minimum version.
	 */
	protected function validate_php_version() {
		if ( ! version_compare( PHP_VERSION, WC_GLA_MIN_PHP_VER, '>=' ) ) {
			throw InvalidVersion::from_requirement( 'PHP', PHP_VERSION, WC_GLA_MIN_PHP_VER );
		}
	}

	/**
	 * Validate the PHP Architecture being 64 Bits.
	 * This is done by checking PHP_INT_SIZE. In 32 bits this will be 4 Bytes. In 64 Bits this will be 8 Bytes
	 *
	 * @see https://www.php.net/manual/en/language.types.integer.php
	 * @since 2.3.9
	 *
	 * @throws InvalidVersion When the PHP Architecture is not 64 Bits.
	 */
	protected function validate_php_architecture() {
		if ( PHP_INT_SIZE !== 8 ) {
			throw InvalidVersion::invalid_architecture();
		}
	}
}
WCAdminValidator.php000064400000002051151547535340010417 0ustar00<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Internal\Requirements;

use Automattic\WooCommerce\GoogleListingsAndAds\Exception\ExtensionRequirementException;

defined( 'ABSPATH' ) || exit;

/**
 * Class WCAdminValidator
 *
 * @package AutomatticWooCommerceGoogleListingsAndAdsInternalRequirements
 */
class WCAdminValidator extends RequirementValidator {

	/**
	 * Validate all requirements for the plugin to function properly.
	 *
	 * @return bool
	 */
	public function validate(): bool {
		try {
			$this->validate_wc_admin_active();
			return true;
		} catch ( ExtensionRequirementException $e ) {
			$this->add_admin_notice( $e );
			return false;
		}
	}

	/**
	 * Validate that WooCommerce Admin is enabled.
	 *
	 * @throws ExtensionRequirementException When the WooCommerce Admin is disabled by hook.
	 */
	protected function validate_wc_admin_active() {
		if ( apply_filters( 'woocommerce_admin_disabled', false ) ) {
			throw ExtensionRequirementException::missing_required_plugin( 'WooCommerce Admin' );
		}
	}
}
WCValidator.php000064400000002243151547535340007451 0ustar00<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Internal\Requirements;

use Automattic\WooCommerce\GoogleListingsAndAds\Exception\InvalidVersion;

defined( 'ABSPATH' ) || exit;

/**
 * Class WCValidator
 *
 * @package AutomatticWooCommerceGoogleListingsAndAdsInternalRequirements
 */
class WCValidator extends RequirementValidator {

	/**
	 * Validate all requirements for the plugin to function properly.
	 *
	 * @return bool
	 */
	public function validate(): bool {
		try {
			$this->validate_wc_version();
			return true;
		} catch ( InvalidVersion $e ) {
			$this->add_admin_notice( $e );
			return false;
		}
	}

	/**
	 * Validate the minimum required WooCommerce version (after plugins are fully loaded).
	 *
	 * @throws InvalidVersion When the WooCommerce version does not meet the minimum version.
	 */
	protected function validate_wc_version() {
		if ( ! defined( 'WC_VERSION' ) ) {
			throw InvalidVersion::requirement_missing( 'WooCommerce', WC_GLA_MIN_WC_VER );
		}

		if ( ! version_compare( WC_VERSION, WC_GLA_MIN_WC_VER, '>=' ) ) {
			throw InvalidVersion::from_requirement( 'WooCommerce', WC_VERSION, WC_GLA_MIN_WC_VER );
		}
	}
}