Use new code style
This commit is contained in:
@ -65,7 +65,7 @@ class Requirements {
|
||||
/**
|
||||
* Static-only class.
|
||||
*/
|
||||
private function __construct() {} // end __construct;
|
||||
private function __construct() {}
|
||||
|
||||
/**
|
||||
* Check if the minimum pre-requisites to run WP Multisite WaaS are present.
|
||||
@ -80,20 +80,17 @@ class Requirements {
|
||||
*/
|
||||
public static function met() {
|
||||
|
||||
if (self::$met === null) {
|
||||
|
||||
if (null === self::$met) {
|
||||
self::$met = (
|
||||
self::check_php_version()
|
||||
&& self::check_wp_version()
|
||||
&& self::is_multisite()
|
||||
&& self::is_network_active()
|
||||
);
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return self::$met;
|
||||
|
||||
} // end met;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if we have ran through the setup already.
|
||||
@ -106,26 +103,21 @@ class Requirements {
|
||||
global $wpdb;
|
||||
|
||||
if (self::is_unit_test()) {
|
||||
|
||||
// phpcs:disable
|
||||
|
||||
$tables = wu_array_flatten($wpdb->get_results(sprintf('SHOW TABLES FROM %s;', DB_NAME), ARRAY_N));
|
||||
|
||||
// phpcs:enable
|
||||
|
||||
if (!in_array("{$wpdb->prefix}wu_domain_mappings", $tables, true)) {
|
||||
|
||||
if (! in_array("{$wpdb->prefix}wu_domain_mappings", $tables, true)) {
|
||||
Core_Installer::get_instance()->_install_database_tables();
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return get_network_option(null, 'wu_setup_finished', false);
|
||||
|
||||
} // end run_setup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for a test environment.
|
||||
@ -134,10 +126,8 @@ class Requirements {
|
||||
* @return boolean
|
||||
*/
|
||||
public static function is_unit_test() {
|
||||
|
||||
return defined('WP_TESTS_MULTISITE') && WP_TESTS_MULTISITE;
|
||||
|
||||
} // end is_unit_test;
|
||||
}
|
||||
/**
|
||||
* Check if the PHP version requirements are met
|
||||
*
|
||||
@ -146,16 +136,13 @@ class Requirements {
|
||||
public static function check_php_version(): bool {
|
||||
|
||||
if (version_compare(phpversion(), self::$php_version, '<')) {
|
||||
|
||||
add_action('network_admin_notices', array('WP_Ultimo\Requirements', 'notice_unsupported_php_version'));
|
||||
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} // end check_php_version;
|
||||
}
|
||||
/**
|
||||
* Check if the WordPress version requirements are met
|
||||
*
|
||||
@ -166,16 +153,13 @@ class Requirements {
|
||||
global $wp_version;
|
||||
|
||||
if (version_compare($wp_version, self::$wp_version, '<')) {
|
||||
|
||||
add_action('network_admin_notices', array('WP_Ultimo\Requirements', 'notice_unsupported_wp_version'));
|
||||
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} // end check_wp_version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Cron Status
|
||||
@ -195,50 +179,44 @@ class Requirements {
|
||||
global $wp_version;
|
||||
|
||||
if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON) {
|
||||
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
if (defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON) {
|
||||
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$cached_status = get_site_transient('wp-ultimo-cron-test-ok');
|
||||
|
||||
if ($cached_status) {
|
||||
|
||||
return true;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$sslverify = version_compare($wp_version, 4.0, '<');
|
||||
$doing_wp_cron = sprintf('%.22F', microtime(true));
|
||||
|
||||
$cron_request = apply_filters('cron_request', array( // phpcs:ignore
|
||||
'url' => site_url('wp-cron.php?doing_wp_cron=' . $doing_wp_cron),
|
||||
'args' => array(
|
||||
'timeout' => 3,
|
||||
'blocking' => true,
|
||||
'sslverify' => apply_filters('https_local_ssl_verify', $sslverify), // phpcs:ignore
|
||||
),
|
||||
));
|
||||
$cron_request = apply_filters(
|
||||
'cron_request', // phpcs:ignore
|
||||
array(
|
||||
'url' => site_url('wp-cron.php?doing_wp_cron=' . $doing_wp_cron),
|
||||
'args' => array(
|
||||
'timeout' => 3,
|
||||
'blocking' => true,
|
||||
'sslverify' => apply_filters('https_local_ssl_verify', $sslverify), // phpcs:ignore
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$result = wp_remote_post($cron_request['url'], $cron_request['args']);
|
||||
|
||||
if (wp_remote_retrieve_response_code($result) >= 300) {
|
||||
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
set_transient('wp-ultimo-cron-test-ok', 1, HOUR_IN_SECONDS);
|
||||
|
||||
return true;
|
||||
|
||||
} // end check_wp_cron;
|
||||
}
|
||||
/**
|
||||
* Check if the install is a Multisite install
|
||||
*
|
||||
@ -246,17 +224,14 @@ class Requirements {
|
||||
*/
|
||||
public static function is_multisite(): bool {
|
||||
|
||||
if (!is_multisite()) {
|
||||
|
||||
if (! is_multisite()) {
|
||||
add_action('admin_notices', array('WP_Ultimo\Requirements', 'notice_not_multisite'));
|
||||
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} // end is_multisite;
|
||||
}
|
||||
/**
|
||||
* Check if WP Multisite WaaS is network active.
|
||||
*
|
||||
@ -277,28 +252,21 @@ class Requirements {
|
||||
$skip_network_activation_check = apply_filters('wp_ultimo_skip_network_active_check', wu_is_must_use());
|
||||
|
||||
if ($skip_network_activation_check) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // end if;
|
||||
|
||||
if (!function_exists('is_plugin_active_for_network')) {
|
||||
|
||||
if (! function_exists('is_plugin_active_for_network')) {
|
||||
require_once ABSPATH . '/wp-admin/includes/plugin.php';
|
||||
}
|
||||
|
||||
} // end if;
|
||||
|
||||
if (!is_plugin_active_for_network(WP_ULTIMO_PLUGIN_BASENAME) && !self::is_unit_test()) {
|
||||
|
||||
if (! is_plugin_active_for_network(WP_ULTIMO_PLUGIN_BASENAME) && ! self::is_unit_test()) {
|
||||
add_action('admin_notices', array('WP_Ultimo\Requirements', 'notice_not_network_active'));
|
||||
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} // end is_network_active;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a network admin notice about the PHP requirements not being met
|
||||
@ -312,8 +280,7 @@ class Requirements {
|
||||
$message = sprintf(__('WP Multisite WaaS requires at least PHP version %1$s to run. Your current PHP version is <strong>%2$s</strong>. Please, contact your hosting company support to upgrade your PHP version. If you want maximum performance consider upgrading your PHP to version 7.0 or later.', 'wp-ultimo'), self::$php_version, phpversion());
|
||||
|
||||
printf('<div class="notice notice-error"><p>%s</p></div>', $message);
|
||||
|
||||
} // end notice_unsupported_php_version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a network admin notice about the WordPress requirements not being met
|
||||
@ -329,8 +296,7 @@ class Requirements {
|
||||
$message = sprintf(__('WP Multisite WaaS requires at least WordPress version %1$s to run. Your current WordPress version is <strong>%2$s</strong>.', 'wp-ultimo'), self::$wp_version, $wp_version);
|
||||
|
||||
printf('<div class="notice notice-error"><p>%s</p></div>', $message);
|
||||
|
||||
} // end notice_unsupported_wp_version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a network admin notice about the install not being a multisite install
|
||||
@ -343,8 +309,7 @@ class Requirements {
|
||||
$message = __('WP Multisite WaaS requires a multisite install to run properly. To know more about WordPress Networks, visit this link: <a href="https://wordpress.org/support/article/create-a-network/">Create a Network →</a>', 'wp-ultimo');
|
||||
|
||||
printf('<div class="notice notice-error"><p>%s</p></div>', $message);
|
||||
|
||||
} // end notice_not_multisite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a network admin notice about the WP Multisite WaaS not being network-active
|
||||
@ -358,7 +323,5 @@ class Requirements {
|
||||
$message = sprintf(__('WP Multisite WaaS needs to be network active to run properly. You can "Network Activate" it <a href="%s">here</a>', 'wp-ultimo'), network_admin_url('plugins.php'));
|
||||
|
||||
printf('<div class="notice notice-error"><p>%s</p></div>', $message);
|
||||
|
||||
} // end notice_not_network_active;
|
||||
|
||||
} // end class Requirements;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user