-
Notifications
You must be signed in to change notification settings - Fork 21
/
WCAdminValidator.php
42 lines (36 loc) · 1.04 KB
/
WCAdminValidator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?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' );
}
}
}