2019-09-26 02:10:52 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* WooCommerce.com Product Installation Requirements Check.
|
|
|
|
*
|
2020-08-05 20:49:10 +00:00
|
|
|
* @package WooCommerce\WCCom
|
2019-09-26 02:10:52 +00:00
|
|
|
* @since 3.8.0
|
|
|
|
*/
|
|
|
|
|
2020-01-29 05:21:29 +00:00
|
|
|
use Automattic\Jetpack\Constants;
|
|
|
|
|
2019-09-26 02:10:52 +00:00
|
|
|
defined( 'ABSPATH' ) || exit;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WC_WCCOM_Site_Installer_Requirements_Check Class
|
|
|
|
* Contains functionality to check the necessary requirements for the installer.
|
|
|
|
*/
|
|
|
|
class WC_WCCOM_Site_Installer_Requirements_Check {
|
|
|
|
/**
|
|
|
|
* Check if the site met the requirements
|
|
|
|
*
|
|
|
|
* @version 3.8.0
|
|
|
|
* @return bool|WP_Error Does the site met the requirements?
|
|
|
|
*/
|
|
|
|
public static function met_requirements() {
|
2019-12-20 17:18:04 +00:00
|
|
|
$errs = array();
|
2019-09-26 02:10:52 +00:00
|
|
|
|
|
|
|
if ( ! self::met_wp_cron_requirement() ) {
|
|
|
|
$errs[] = 'wp-cron';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! self::met_filesystem_requirement() ) {
|
|
|
|
$errs[] = 'filesystem';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! empty( $errs ) ) {
|
|
|
|
// translators: %s: Requirements unmet.
|
2019-10-01 00:31:23 +00:00
|
|
|
return new WP_Error( 'requirements_not_met', sprintf( __( 'Server requirements not met, missing requirement(s): %s.', 'woocommerce' ), implode( ', ', $errs ) ), array( 'status' => 400 ) );
|
2019-09-26 02:10:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Validates if WP CRON is enabled.
|
|
|
|
*
|
|
|
|
* @since 3.8.0
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
private static function met_wp_cron_requirement() {
|
2020-01-29 05:21:29 +00:00
|
|
|
return ! Constants::is_true( 'DISABLE_WP_CRON' );
|
2019-09-26 02:10:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Validates if `WP_CONTENT_DIR` is writable.
|
|
|
|
*
|
|
|
|
* @since 3.8.0
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
private static function met_filesystem_requirement() {
|
|
|
|
return is_writable( WP_CONTENT_DIR );
|
|
|
|
}
|
|
|
|
}
|