Aucune description

class-wc-wccom-site-installer-requirements-check.php 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * WooCommerce.com Product Installation Requirements Check.
  4. *
  5. * @package WooCommerce\WCCom
  6. * @since 3.8.0
  7. */
  8. use Automattic\Jetpack\Constants;
  9. defined( 'ABSPATH' ) || exit;
  10. /**
  11. * WC_WCCOM_Site_Installer_Requirements_Check Class
  12. * Contains functionality to check the necessary requirements for the installer.
  13. */
  14. class WC_WCCOM_Site_Installer_Requirements_Check {
  15. /**
  16. * Check if the site met the requirements
  17. *
  18. * @version 3.8.0
  19. * @return bool|WP_Error Does the site met the requirements?
  20. */
  21. public static function met_requirements() {
  22. $errs = array();
  23. if ( ! self::met_wp_cron_requirement() ) {
  24. $errs[] = 'wp-cron';
  25. }
  26. if ( ! self::met_filesystem_requirement() ) {
  27. $errs[] = 'filesystem';
  28. }
  29. if ( ! empty( $errs ) ) {
  30. // translators: %s: Requirements unmet.
  31. return new WP_Error( 'requirements_not_met', sprintf( __( 'Server requirements not met, missing requirement(s): %s.', 'woocommerce' ), implode( ', ', $errs ) ), array( 'status' => 400 ) );
  32. }
  33. return true;
  34. }
  35. /**
  36. * Validates if WP CRON is enabled.
  37. *
  38. * @since 3.8.0
  39. * @return bool
  40. */
  41. private static function met_wp_cron_requirement() {
  42. return ! Constants::is_true( 'DISABLE_WP_CRON' );
  43. }
  44. /**
  45. * Validates if `WP_CONTENT_DIR` is writable.
  46. *
  47. * @since 3.8.0
  48. * @return bool
  49. */
  50. private static function met_filesystem_requirement() {
  51. return is_writable( WP_CONTENT_DIR );
  52. }
  53. }