Use PHP 7.4 featers and PHP 8 polyfills
This commit is contained in:
@ -49,7 +49,7 @@ abstract class Base_Host_Provider {
|
||||
* @var array
|
||||
* @since 2.0.0
|
||||
*/
|
||||
protected $supports = array();
|
||||
protected $supports = [];
|
||||
|
||||
/**
|
||||
* Constants that need to be present on wp-config.php for this integration to work.
|
||||
@ -58,7 +58,7 @@ abstract class Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $constants = array();
|
||||
protected $constants = [];
|
||||
|
||||
/**
|
||||
* Constants that are optional on wp-config.php.
|
||||
@ -66,7 +66,7 @@ abstract class Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $optional_constants = array();
|
||||
protected $optional_constants = [];
|
||||
|
||||
/**
|
||||
* Runs on singleton instantiation.
|
||||
@ -74,11 +74,11 @@ abstract class Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
add_filter('wu_domain_manager_get_integrations', array($this, 'self_register'));
|
||||
add_filter('wu_domain_manager_get_integrations', [$this, 'self_register']);
|
||||
|
||||
add_action('init', array($this, 'add_to_integration_list'));
|
||||
add_action('init', [$this, 'add_to_integration_list']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -131,7 +131,7 @@ abstract class Base_Host_Provider {
|
||||
*/
|
||||
final public function self_register($integrations) {
|
||||
|
||||
$integrations[ $this->get_id() ] = get_called_class();
|
||||
$integrations[ $this->get_id() ] = static::class;
|
||||
|
||||
return $integrations;
|
||||
}
|
||||
@ -144,7 +144,7 @@ abstract class Base_Host_Provider {
|
||||
*/
|
||||
protected function get_enabled_list() {
|
||||
|
||||
return get_network_option(null, 'wu_host_integrations_enabled', array());
|
||||
return get_network_option(null, 'wu_host_integrations_enabled', []);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -196,7 +196,7 @@ abstract class Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function add_to_integration_list() {
|
||||
public function add_to_integration_list(): void {
|
||||
|
||||
$slug = $this->get_id();
|
||||
|
||||
@ -204,9 +204,9 @@ abstract class Base_Host_Provider {
|
||||
|
||||
$url = wu_network_admin_url(
|
||||
'wp-ultimo-hosting-integration-wizard',
|
||||
array(
|
||||
[
|
||||
'integration' => $slug,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$html .= sprintf('<a href="%s" class="button-primary">%s</a>', $url, __('Configuration', 'wp-ultimo'));
|
||||
@ -222,11 +222,11 @@ abstract class Base_Host_Provider {
|
||||
wu_register_settings_field(
|
||||
'integrations',
|
||||
"integration_{$slug}",
|
||||
array(
|
||||
[
|
||||
'type' => 'note',
|
||||
'title' => $title,
|
||||
'desc' => $html,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -236,7 +236,7 @@ abstract class Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function alert_provider_detected() {
|
||||
public function alert_provider_detected(): void {
|
||||
|
||||
if (WP_Ultimo()->is_loaded() === false) {
|
||||
return;
|
||||
@ -247,18 +247,18 @@ abstract class Base_Host_Provider {
|
||||
|
||||
$slug = $this->get_id();
|
||||
|
||||
$actions = array(
|
||||
'activate' => array(
|
||||
$actions = [
|
||||
'activate' => [
|
||||
// translators: %s is the integration name.
|
||||
'title' => sprintf(__('Activate %s', 'wp-ultimo'), $this->get_title()),
|
||||
'url' => wu_network_admin_url(
|
||||
'wp-ultimo-hosting-integration-wizard',
|
||||
array(
|
||||
[
|
||||
'integration' => $slug,
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
WP_Ultimo()->notices->add($message, 'info', 'network-admin', "should-enable-{$slug}-integration", $actions);
|
||||
}
|
||||
@ -269,7 +269,7 @@ abstract class Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function alert_provider_not_setup() {
|
||||
public function alert_provider_not_setup(): void {
|
||||
|
||||
if (WP_Ultimo()->is_loaded() === false) {
|
||||
return;
|
||||
@ -280,19 +280,19 @@ abstract class Base_Host_Provider {
|
||||
|
||||
$slug = $this->get_id();
|
||||
|
||||
$actions = array(
|
||||
'activate' => array(
|
||||
$actions = [
|
||||
'activate' => [
|
||||
// translators: %s is the integration name
|
||||
'title' => sprintf(__('Setup %s', 'wp-ultimo'), $this->get_title()),
|
||||
'url' => wu_network_admin_url(
|
||||
'wp-ultimo-hosting-integration-wizard',
|
||||
array(
|
||||
[
|
||||
'integration' => $slug,
|
||||
'tab' => 'config',
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
WP_Ultimo()->notices->add($message, 'warning', 'network-admin', "should-setup-{$slug}-integration", $actions);
|
||||
}
|
||||
@ -305,7 +305,7 @@ abstract class Base_Host_Provider {
|
||||
*/
|
||||
public function get_fields() {
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -348,26 +348,26 @@ abstract class Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_hooks() {
|
||||
public function register_hooks(): void {
|
||||
/*
|
||||
* Hooks the event that is triggered when a new domain is added.
|
||||
*/
|
||||
add_action('wu_add_domain', array($this, 'on_add_domain'), 10, 2);
|
||||
add_action('wu_add_domain', [$this, 'on_add_domain'], 10, 2);
|
||||
|
||||
/*
|
||||
* Hooks the event that is triggered when a domain is deleted.
|
||||
*/
|
||||
add_action('wu_remove_domain', array($this, 'on_remove_domain'), 10, 2);
|
||||
add_action('wu_remove_domain', [$this, 'on_remove_domain'], 10, 2);
|
||||
|
||||
/*
|
||||
* Hooks the event that is triggered when a sub-domain is added.
|
||||
*/
|
||||
add_action('wu_add_subdomain', array($this, 'on_add_subdomain'), 10, 2);
|
||||
add_action('wu_add_subdomain', [$this, 'on_add_subdomain'], 10, 2);
|
||||
|
||||
/*
|
||||
* Hooks the event that is triggered when a sub-domain is added.
|
||||
*/
|
||||
add_action('wu_remove_subdomain', array($this, 'on_remove_subdomain'), 10, 2);
|
||||
add_action('wu_remove_subdomain', [$this, 'on_remove_subdomain'], 10, 2);
|
||||
|
||||
/*
|
||||
* Add additional hooks.
|
||||
@ -412,7 +412,7 @@ abstract class Base_Host_Provider {
|
||||
$all_set = true;
|
||||
|
||||
foreach ($this->constants as $constant) {
|
||||
$constants = is_array($constant) ? $constant : array($constant);
|
||||
$constants = is_array($constant) ? $constant : [$constant];
|
||||
|
||||
$current = false;
|
||||
|
||||
@ -445,10 +445,10 @@ abstract class Base_Host_Provider {
|
||||
*/
|
||||
public function get_missing_constants() {
|
||||
|
||||
$missing_constants = array();
|
||||
$missing_constants = [];
|
||||
|
||||
foreach ($this->constants as $constant) {
|
||||
$constants = is_array($constant) ? $constant : array($constant);
|
||||
$constants = is_array($constant) ? $constant : [$constant];
|
||||
|
||||
$current = false;
|
||||
|
||||
@ -474,10 +474,10 @@ abstract class Base_Host_Provider {
|
||||
*/
|
||||
public function get_all_constants() {
|
||||
|
||||
$constants = array();
|
||||
$constants = [];
|
||||
|
||||
foreach ($this->constants as $constant) {
|
||||
$current = is_array($constant) ? $constant : array($constant);
|
||||
$current = is_array($constant) ? $constant : [$constant];
|
||||
|
||||
$constants = array_merge($constants, $current);
|
||||
}
|
||||
@ -493,7 +493,7 @@ abstract class Base_Host_Provider {
|
||||
* @param array $constant_values Key => Value of the necessary constants.
|
||||
* @return void
|
||||
*/
|
||||
public function setup_constants($constant_values) {
|
||||
public function setup_constants($constant_values): void {
|
||||
/*
|
||||
* Important: This step is crucial, as it makes sure we clean up undesired constants.
|
||||
* Removing this can allow insertion of arbitrary constants onto the wp-config.pp file
|
||||
@ -523,9 +523,9 @@ abstract class Base_Host_Provider {
|
||||
/*
|
||||
* Initializes the array with an opening comment.
|
||||
*/
|
||||
$content = array(
|
||||
$content = [
|
||||
sprintf('// WP Multisite WaaS - Domain Mapping - %s', $this->get_title()),
|
||||
);
|
||||
];
|
||||
|
||||
/*
|
||||
* Important: This step is crucial, as it makes sure we clean up undesired constants.
|
||||
@ -557,13 +557,13 @@ abstract class Base_Host_Provider {
|
||||
*/
|
||||
public function get_explainer_lines() {
|
||||
|
||||
$explainer_lines = array(
|
||||
'will' => array(
|
||||
$explainer_lines = [
|
||||
'will' => [
|
||||
// translators: %s is the name of the integration e.g. RunCloud
|
||||
'send_domains' => sprintf(__('Send API calls to %s servers with domain names added to this network', 'wp-ultimo'), $this->get_title()),
|
||||
),
|
||||
'will_not' => array(),
|
||||
);
|
||||
],
|
||||
'will_not' => [],
|
||||
];
|
||||
|
||||
if ($this->supports('autossl')) {
|
||||
|
||||
@ -630,9 +630,9 @@ abstract class Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function test_connection() {
|
||||
public function test_connection(): void {
|
||||
|
||||
wp_send_json_success(array());
|
||||
wp_send_json_success([]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -51,11 +51,11 @@ class Closte_Host_Provider extends Base_Host_Provider {
|
||||
* @var array
|
||||
* @since 2.0.0
|
||||
*/
|
||||
protected $supports = array(
|
||||
protected $supports = [
|
||||
'autossl',
|
||||
'no-instructions',
|
||||
'no-config',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Constants that need to be present on wp-config.php for this integration to work.
|
||||
@ -63,9 +63,9 @@ class Closte_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $constants = array(
|
||||
protected $constants = [
|
||||
'CLOSTE_CLIENT_API_KEY',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Picks up on tips that a given host provider is being used.
|
||||
@ -88,14 +88,14 @@ class Closte_Host_Provider extends Base_Host_Provider {
|
||||
* @param int $site_id ID of the site that is receiving that mapping.
|
||||
* @return void
|
||||
*/
|
||||
public function on_add_domain($domain, $site_id) {
|
||||
public function on_add_domain($domain, $site_id): void {
|
||||
|
||||
$this->send_closte_api_request(
|
||||
'/adddomainalias',
|
||||
array(
|
||||
[
|
||||
'domain' => $domain,
|
||||
'wildcard' => strncmp($domain, '*.', strlen('*.')) === 0,
|
||||
)
|
||||
'wildcard' => str_starts_with($domain, '*.'),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -107,14 +107,14 @@ class Closte_Host_Provider extends Base_Host_Provider {
|
||||
* @param int $site_id ID of the site that is receiving that mapping.
|
||||
* @return void
|
||||
*/
|
||||
public function on_remove_domain($domain, $site_id) {
|
||||
public function on_remove_domain($domain, $site_id): void {
|
||||
|
||||
$this->send_closte_api_request(
|
||||
'/deletedomainalias',
|
||||
array(
|
||||
[
|
||||
'domain' => $domain,
|
||||
'wildcard' => strncmp($domain, '*.', strlen('*.')) === 0,
|
||||
)
|
||||
'wildcard' => str_starts_with($domain, '*.'),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -150,15 +150,15 @@ class Closte_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function test_connection() {
|
||||
public function test_connection(): void {
|
||||
|
||||
$response = $this->send_closte_api_request('/adddomainalias', array());
|
||||
$response = $this->send_closte_api_request('/adddomainalias', []);
|
||||
|
||||
if (wu_get_isset($response, 'error') === 'Invalid or empty domain: ') {
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'message' => __('Access Authorized'),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -178,23 +178,23 @@ class Closte_Host_Provider extends Base_Host_Provider {
|
||||
public function send_closte_api_request($endpoint, $data) {
|
||||
|
||||
if (defined('CLOSTE_CLIENT_API_KEY') === false) {
|
||||
return (object) array(
|
||||
return (object) [
|
||||
'success' => false,
|
||||
'error' => 'Closte API Key not found.',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$post_fields = array(
|
||||
$post_fields = [
|
||||
'blocking' => true,
|
||||
'timeout' => 45,
|
||||
'method' => 'POST',
|
||||
'body' => array_merge(
|
||||
array(
|
||||
[
|
||||
'apikey' => CLOSTE_CLIENT_API_KEY,
|
||||
),
|
||||
],
|
||||
$data
|
||||
),
|
||||
);
|
||||
];
|
||||
|
||||
$response = wp_remote_post('https://app.closte.com/api/client' . $endpoint, $post_fields);
|
||||
|
||||
@ -207,10 +207,10 @@ class Closte_Host_Provider extends Base_Host_Provider {
|
||||
return $body;
|
||||
}
|
||||
|
||||
return (object) array(
|
||||
return (object) [
|
||||
'success' => false,
|
||||
'error' => 'unknown',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
@ -52,9 +52,9 @@ class Cloudflare_Host_Provider extends Base_Host_Provider {
|
||||
* @var array
|
||||
* @since 2.0.0
|
||||
*/
|
||||
protected $supports = array(
|
||||
protected $supports = [
|
||||
'autossl',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Constants that need to be present on wp-config.php for this integration to work.
|
||||
@ -62,10 +62,10 @@ class Cloudflare_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $constants = array(
|
||||
protected $constants = [
|
||||
'WU_CLOUDFLARE_API_KEY',
|
||||
'WU_CLOUDFLARE_ZONE_ID',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Add Cloudflare own DNS entries to the comparison table.
|
||||
@ -78,7 +78,7 @@ class Cloudflare_Host_Provider extends Base_Host_Provider {
|
||||
*/
|
||||
public function add_cloudflare_dns_entries($dns_records, $domain) {
|
||||
|
||||
$zone_ids = array();
|
||||
$zone_ids = [];
|
||||
|
||||
$default_zone_id = defined('WU_CLOUDFLARE_ZONE_ID') && WU_CLOUDFLARE_ZONE_ID ? WU_CLOUDFLARE_ZONE_ID : false;
|
||||
|
||||
@ -89,10 +89,10 @@ class Cloudflare_Host_Provider extends Base_Host_Provider {
|
||||
$cloudflare_zones = $this->cloudflare_api_call(
|
||||
'client/v4/zones',
|
||||
'GET',
|
||||
array(
|
||||
[
|
||||
'name' => $domain,
|
||||
'status' => 'active',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
foreach ($cloudflare_zones->result as $zone) {
|
||||
@ -108,11 +108,11 @@ class Cloudflare_Host_Provider extends Base_Host_Provider {
|
||||
$dns_entries = $this->cloudflare_api_call(
|
||||
"client/v4/zones/$zone_id/dns_records/",
|
||||
'GET',
|
||||
array(
|
||||
[
|
||||
'name' => $domain,
|
||||
'match' => 'any',
|
||||
'type' => 'A,AAAA,CNAME',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if ( ! empty($dns_entries->result)) {
|
||||
@ -121,13 +121,13 @@ class Cloudflare_Host_Provider extends Base_Host_Provider {
|
||||
$not_proxied_tag = sprintf('<span class="wu-bg-gray-700 wu-text-white wu-p-1 wu-rounded wu-text-3xs wu-uppercase wu-ml-2 wu-font-bold" %s>%s</span>', wu_tooltip_text(__('Not Proxied', 'wp-ultimo')), __('Cloudflare', 'wp-ultimo'));
|
||||
|
||||
foreach ($dns_entries->result as $entry) {
|
||||
$dns_records[] = array(
|
||||
$dns_records[] = [
|
||||
'ttl' => $entry->ttl,
|
||||
'data' => $entry->content,
|
||||
'type' => $entry->type,
|
||||
'host' => $entry->name,
|
||||
'tag' => $entry->proxied ? $proxied_tag : $not_proxied_tag,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -160,16 +160,16 @@ class Cloudflare_Host_Provider extends Base_Host_Provider {
|
||||
*/
|
||||
public function get_fields() {
|
||||
|
||||
return array(
|
||||
'WU_CLOUDFLARE_ZONE_ID' => array(
|
||||
return [
|
||||
'WU_CLOUDFLARE_ZONE_ID' => [
|
||||
'title' => __('Zone ID', 'wp-ultimo'),
|
||||
'placeholder' => __('e.g. 644c7705723d62e31f700bb798219c75', 'wp-ultimo'),
|
||||
),
|
||||
'WU_CLOUDFLARE_API_KEY' => array(
|
||||
],
|
||||
'WU_CLOUDFLARE_API_KEY' => [
|
||||
'title' => __('API Key', 'wp-ultimo'),
|
||||
'placeholder' => __('e.g. xKGbxxVDpdcUv9dUzRf4i4ngv0QNf1wCtbehiec_o', 'wp-ultimo'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -178,7 +178,7 @@ class Cloudflare_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function test_connection() {
|
||||
public function test_connection(): void {
|
||||
|
||||
$results = $this->cloudflare_api_call('client/v4/user/tokens/verify');
|
||||
|
||||
@ -195,9 +195,9 @@ class Cloudflare_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.7
|
||||
* @return void
|
||||
*/
|
||||
public function additional_hooks() {
|
||||
public function additional_hooks(): void {
|
||||
|
||||
add_filter('wu_domain_dns_get_record', array($this, 'add_cloudflare_dns_entries'), 10, 2);
|
||||
add_filter('wu_domain_dns_get_record', [$this, 'add_cloudflare_dns_entries'], 10, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -230,7 +230,7 @@ class Cloudflare_Host_Provider extends Base_Host_Provider {
|
||||
* @param int $site_id ID of the site that is receiving that mapping.
|
||||
* @return void
|
||||
*/
|
||||
public function on_add_subdomain($subdomain, $site_id) {
|
||||
public function on_add_subdomain($subdomain, $site_id): void {
|
||||
|
||||
global $current_site;
|
||||
|
||||
@ -240,7 +240,7 @@ class Cloudflare_Host_Provider extends Base_Host_Provider {
|
||||
return;
|
||||
}
|
||||
|
||||
if (strpos($subdomain, (string) $current_site->domain) === false) {
|
||||
if (! str_contains($subdomain, (string) $current_site->domain)) {
|
||||
return; // Not a sub-domain of the main domain.
|
||||
|
||||
}
|
||||
@ -253,12 +253,12 @@ class Cloudflare_Host_Provider extends Base_Host_Provider {
|
||||
|
||||
$should_add_www = apply_filters('wu_cloudflare_should_add_www', true, $subdomain, $site_id);
|
||||
|
||||
$domains_to_send = array($subdomain);
|
||||
$domains_to_send = [$subdomain];
|
||||
|
||||
/**
|
||||
* Adds the www version, if necessary.
|
||||
*/
|
||||
if (strncmp($subdomain, 'www.', strlen('www.')) !== 0 && $should_add_www) {
|
||||
if (! str_starts_with($subdomain, 'www.') && $should_add_www) {
|
||||
$domains_to_send[] = 'www.' . $subdomain;
|
||||
}
|
||||
|
||||
@ -267,13 +267,13 @@ class Cloudflare_Host_Provider extends Base_Host_Provider {
|
||||
|
||||
$data = apply_filters(
|
||||
'wu_cloudflare_on_add_domain_data',
|
||||
array(
|
||||
[
|
||||
'type' => 'CNAME',
|
||||
'name' => $subdomain,
|
||||
'content' => '@',
|
||||
'proxied' => $should_proxy,
|
||||
'ttl' => 1,
|
||||
),
|
||||
],
|
||||
$subdomain,
|
||||
$site_id
|
||||
);
|
||||
@ -300,7 +300,7 @@ class Cloudflare_Host_Provider extends Base_Host_Provider {
|
||||
* @param int $site_id ID of the site that is receiving that mapping.
|
||||
* @return void
|
||||
*/
|
||||
public function on_remove_subdomain($subdomain, $site_id) {
|
||||
public function on_remove_subdomain($subdomain, $site_id): void {
|
||||
|
||||
global $current_site;
|
||||
|
||||
@ -310,7 +310,7 @@ class Cloudflare_Host_Provider extends Base_Host_Provider {
|
||||
return;
|
||||
}
|
||||
|
||||
if (strpos($subdomain, (string) $current_site->domain) === false) {
|
||||
if (! str_contains($subdomain, (string) $current_site->domain)) {
|
||||
return; // Not a sub-domain of the main domain.
|
||||
|
||||
}
|
||||
@ -326,19 +326,19 @@ class Cloudflare_Host_Provider extends Base_Host_Provider {
|
||||
/**
|
||||
* Created the list that we should remove.
|
||||
*/
|
||||
$domains_to_remove = array(
|
||||
$domains_to_remove = [
|
||||
$original_subdomain,
|
||||
'www.' . $original_subdomain,
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($domains_to_remove as $original_subdomain) {
|
||||
$dns_entries = $this->cloudflare_api_call(
|
||||
"client/v4/zones/$zone_id/dns_records/",
|
||||
'GET',
|
||||
array(
|
||||
[
|
||||
'name' => $original_subdomain,
|
||||
'type' => 'CNAME',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if ( ! $dns_entries->result) {
|
||||
@ -368,7 +368,7 @@ class Cloudflare_Host_Provider extends Base_Host_Provider {
|
||||
* @param array $data The date to send.
|
||||
* @return object|\WP_Error
|
||||
*/
|
||||
protected function cloudflare_api_call($endpoint = 'client/v4/user/tokens/verify', $method = 'GET', $data = array()): object {
|
||||
protected function cloudflare_api_call($endpoint = 'client/v4/user/tokens/verify', $method = 'GET', $data = []): object {
|
||||
|
||||
$api_url = 'https://api.cloudflare.com/';
|
||||
|
||||
@ -376,15 +376,15 @@ class Cloudflare_Host_Provider extends Base_Host_Provider {
|
||||
|
||||
$response = wp_remote_request(
|
||||
$endpoint_url,
|
||||
array(
|
||||
[
|
||||
'method' => $method,
|
||||
'body' => $method === 'GET' ? $data : wp_json_encode($data),
|
||||
'data_format' => 'body',
|
||||
'headers' => array(
|
||||
'headers' => [
|
||||
'Authorization' => sprintf('Bearer %s', defined('WU_CLOUDFLARE_API_KEY') ? WU_CLOUDFLARE_API_KEY : ''),
|
||||
'Content-Type' => 'application/json',
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
if ( ! is_wp_error($response)) {
|
||||
@ -408,7 +408,7 @@ class Cloudflare_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function get_instructions() {
|
||||
public function get_instructions(): void {
|
||||
|
||||
wu_get_template('wizards/host-integrations/cloudflare-instructions');
|
||||
}
|
||||
@ -443,10 +443,10 @@ class Cloudflare_Host_Provider extends Base_Host_Provider {
|
||||
*/
|
||||
public function get_explainer_lines() {
|
||||
|
||||
$explainer_lines = array(
|
||||
'will' => array(),
|
||||
'will_not' => array(),
|
||||
);
|
||||
$explainer_lines = [
|
||||
'will' => [],
|
||||
'will_not' => [],
|
||||
];
|
||||
|
||||
if (is_subdomain_install()) {
|
||||
$explainer_lines['will']['send_sub_domains'] = __('Add a new proxied subdomain to the configured CloudFlare zone whenever a new site gets created', 'wp-ultimo');
|
||||
|
@ -53,9 +53,9 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
* @var array
|
||||
* @since 2.0.0
|
||||
*/
|
||||
protected $supports = array(
|
||||
protected $supports = [
|
||||
'autossl',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Constants that need to be present on wp-config.php for this integration to work.
|
||||
@ -63,12 +63,12 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $constants = array(
|
||||
protected $constants = [
|
||||
'WU_CLOUDWAYS_EMAIL',
|
||||
'WU_CLOUDWAYS_API_KEY',
|
||||
'WU_CLOUDWAYS_SERVER_ID',
|
||||
'WU_CLOUDWAYS_APP_ID',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Constants that maybe present on wp-config.php for this integration to work.
|
||||
@ -76,9 +76,9 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $optional_constants = array(
|
||||
protected $optional_constants = [
|
||||
'WU_CLOUDWAYS_EXTRA_DOMAINS',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Runs on singleton instantiation.
|
||||
@ -86,12 +86,12 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.1.1
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
parent::init();
|
||||
|
||||
// Add the action to sync domains SSL.
|
||||
add_action('wu_domain_manager_dns_propagation_finished', array($this, 'request_ssl'), 10, 0);
|
||||
add_action('wu_domain_manager_dns_propagation_finished', [$this, 'request_ssl'], 10, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -100,7 +100,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.1.1
|
||||
* @return void
|
||||
*/
|
||||
public function request_ssl() {
|
||||
public function request_ssl(): void {
|
||||
/**
|
||||
* If the integration is not active, bail.
|
||||
*/
|
||||
@ -112,9 +112,9 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
|
||||
$ssl_response = $this->send_cloudways_request(
|
||||
'/security/lets_encrypt_install',
|
||||
array(
|
||||
[
|
||||
'ssl_domains' => $this->get_valid_ssl_domains($all_domains),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if (is_wp_error($ssl_response)) {
|
||||
@ -132,7 +132,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
*/
|
||||
public function detect(): bool {
|
||||
|
||||
return strpos(ABSPATH, 'cloudways') !== false;
|
||||
return str_contains(ABSPATH, 'cloudways');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -143,34 +143,34 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
*/
|
||||
public function get_fields() {
|
||||
|
||||
return array(
|
||||
'WU_CLOUDWAYS_EMAIL' => array(
|
||||
return [
|
||||
'WU_CLOUDWAYS_EMAIL' => [
|
||||
'title' => __('Cloudways Account Email', 'wp-ultimo'),
|
||||
'desc' => __('Your Cloudways account email address.', 'wp-ultimo'),
|
||||
'placeholder' => __('e.g. me@gmail.com', 'wp-ultimo'),
|
||||
),
|
||||
'WU_CLOUDWAYS_API_KEY' => array(
|
||||
],
|
||||
'WU_CLOUDWAYS_API_KEY' => [
|
||||
'title' => __('Cloudways API Key', 'wp-ultimo'),
|
||||
'desc' => __('The API Key retrieved in the previous step.', 'wp-ultimo'),
|
||||
'placeholder' => __('e.g. eYP0Jo3Fzzm5SOZCi5nLR0Mki2lbYZ', 'wp-ultimo'),
|
||||
),
|
||||
'WU_CLOUDWAYS_SERVER_ID' => array(
|
||||
],
|
||||
'WU_CLOUDWAYS_SERVER_ID' => [
|
||||
'title' => __('Cloudways Server ID', 'wp-ultimo'),
|
||||
'desc' => __('The Server ID retrieved in the previous step.', 'wp-ultimo'),
|
||||
'placeholder' => __('e.g. 11667', 'wp-ultimo'),
|
||||
),
|
||||
'WU_CLOUDWAYS_APP_ID' => array(
|
||||
],
|
||||
'WU_CLOUDWAYS_APP_ID' => [
|
||||
'title' => __('Cloudways App ID', 'wp-ultimo'),
|
||||
'desc' => __('The App ID retrieved in the previous step.', 'wp-ultimo'),
|
||||
'placeholder' => __('e.g. 940288', 'wp-ultimo'),
|
||||
),
|
||||
'WU_CLOUDWAYS_EXTRA_DOMAINS' => array(
|
||||
],
|
||||
'WU_CLOUDWAYS_EXTRA_DOMAINS' => [
|
||||
'title' => __('Cloudways Extra Domains', 'wp-ultimo'),
|
||||
'tooltip' => __('The Cloudways API is a bit strange in that it doesn’t offer a way to add or remove just one domain, only a way to update the whole domain list. That means that WP Multisite WaaS will replace all domains you might have there with the list of mapped domains of the network every time a new domain is added.', 'wp-ultimo'),
|
||||
'desc' => __('Comma-separated list of additional domains to add to Cloudways.', 'wp-ultimo'),
|
||||
'placeholder' => __('e.g. *.test.com, test.com', 'wp-ultimo'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -181,7 +181,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
* @param int $site_id ID of the site that is receiving that mapping.
|
||||
* @return void
|
||||
*/
|
||||
public function on_add_domain($domain, $site_id) {
|
||||
public function on_add_domain($domain, $site_id): void {
|
||||
|
||||
$this->sync_domains();
|
||||
}
|
||||
@ -194,7 +194,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
* @param int $site_id ID of the site that is receiving that mapping.
|
||||
* @return void
|
||||
*/
|
||||
public function on_remove_domain($domain, $site_id) {
|
||||
public function on_remove_domain($domain, $site_id): void {
|
||||
|
||||
$this->sync_domains();
|
||||
}
|
||||
@ -231,15 +231,15 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
private function sync_domains() {
|
||||
private function sync_domains(): void {
|
||||
|
||||
$all_domains = $this->get_domains();
|
||||
|
||||
$alias_response = $this->send_cloudways_request(
|
||||
'/app/manage/aliases',
|
||||
array(
|
||||
[
|
||||
'aliases' => $all_domains,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if (is_wp_error($alias_response)) {
|
||||
@ -260,7 +260,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
array_map(
|
||||
function ($domain) {
|
||||
|
||||
if (strncmp($domain, '*.', strlen('*.')) === 0) {
|
||||
if (str_starts_with($domain, '*.')) {
|
||||
$domain = str_replace('*.', '', $domain);
|
||||
}
|
||||
|
||||
@ -290,7 +290,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
$domain_list = $this->get_domain_list();
|
||||
|
||||
foreach ($domain_list as $naked_domain) {
|
||||
if (strncmp((string) $naked_domain, 'www.', strlen('www.')) !== 0 && strncmp((string) $naked_domain, '*.', strlen('*.')) !== 0) {
|
||||
if (! str_starts_with((string) $naked_domain, 'www.') && ! str_starts_with((string) $naked_domain, '*.')) {
|
||||
$domain_list[] = 'www.' . $naked_domain;
|
||||
}
|
||||
}
|
||||
@ -311,7 +311,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
*/
|
||||
private function check_domain_dns($domain_names, $network_ip) {
|
||||
|
||||
$valid_domains = array();
|
||||
$valid_domains = [];
|
||||
|
||||
foreach ($domain_names as $domain_name) {
|
||||
$response = wp_remote_get('https://dns.google/resolve?name=' . $domain_name);
|
||||
@ -343,9 +343,9 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function test_connection() {
|
||||
public function test_connection(): void {
|
||||
|
||||
$response = $this->send_cloudways_request('/app/manage/fpm_setting', array(), 'GET');
|
||||
$response = $this->send_cloudways_request('/app/manage/fpm_setting', [], 'GET');
|
||||
|
||||
if (is_wp_error($response) || wu_get_isset($response, 'error')) {
|
||||
wp_send_json_error($response);
|
||||
@ -364,7 +364,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$final_domain_list = array();
|
||||
$final_domain_list = [];
|
||||
|
||||
// Prepare the query
|
||||
$query = "SELECT domain FROM {$wpdb->base_prefix}wu_domain_mappings";
|
||||
@ -377,7 +377,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
foreach ($mappings as $domain) {
|
||||
$final_domain_list[] = $domain;
|
||||
|
||||
if (strncmp((string) $domain, 'www.', strlen('www.')) !== 0) {
|
||||
if (! str_starts_with((string) $domain, 'www.')) {
|
||||
$final_domain_list[] = "www.$domain";
|
||||
}
|
||||
}
|
||||
@ -421,25 +421,25 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
if ( ! $token) {
|
||||
$response = wp_remote_post(
|
||||
'https://api.cloudways.com/api/v1/oauth/access_token',
|
||||
array(
|
||||
[
|
||||
'blocking' => true,
|
||||
'method' => 'POST',
|
||||
'headers' => array(
|
||||
'headers' => [
|
||||
'cache-control' => 'no-cache',
|
||||
'content-type' => 'application/x-www-form-urlencoded',
|
||||
),
|
||||
'body' => array(
|
||||
],
|
||||
'body' => [
|
||||
'email' => defined('WU_CLOUDWAYS_EMAIL') ? WU_CLOUDWAYS_EMAIL : '',
|
||||
'api_key' => defined('WU_CLOUDWAYS_API_KEY') ? WU_CLOUDWAYS_API_KEY : '',
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
if ( ! is_wp_error($response)) {
|
||||
$body = json_decode(wp_remote_retrieve_body($response), true);
|
||||
|
||||
if (isset($body['access_token'])) {
|
||||
$expires_in = isset($body['expires_in']) ? $body['expires_in'] : 50 * MINUTE_IN_SECONDS;
|
||||
$expires_in = $body['expires_in'] ?? 50 * MINUTE_IN_SECONDS;
|
||||
|
||||
set_site_transient('wu_cloudways_token', $body['access_token'], $expires_in);
|
||||
|
||||
@ -461,7 +461,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
* @param string $method The HTTP verb.
|
||||
* @return object|\WP_Error
|
||||
*/
|
||||
protected function send_cloudways_request($endpoint, $data = array(), $method = 'POST'): object {
|
||||
protected function send_cloudways_request($endpoint, $data = [], $method = 'POST'): object {
|
||||
|
||||
$token = $this->get_cloudways_access_token();
|
||||
|
||||
@ -471,10 +471,10 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
|
||||
if ($method === 'GET') {
|
||||
$endpoint_url = add_query_arg(
|
||||
array(
|
||||
[
|
||||
'server_id' => defined('WU_CLOUDWAYS_SERVER_ID') ? WU_CLOUDWAYS_SERVER_ID : '',
|
||||
'app_id' => defined('WU_CLOUDWAYS_APP_ID') ? WU_CLOUDWAYS_APP_ID : '',
|
||||
),
|
||||
],
|
||||
$endpoint_url
|
||||
);
|
||||
} else {
|
||||
@ -486,17 +486,17 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
|
||||
$response = wp_remote_post(
|
||||
$endpoint_url,
|
||||
array(
|
||||
[
|
||||
'blocking' => true,
|
||||
'method' => $method,
|
||||
'timeout' => 45,
|
||||
'body' => $data,
|
||||
'headers' => array(
|
||||
'headers' => [
|
||||
'cache-control' => 'no-cache',
|
||||
'content-type' => 'application/x-www-form-urlencoded',
|
||||
'authorization' => "Bearer $token",
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
if (is_wp_error($response)) {
|
||||
@ -514,7 +514,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function get_instructions() {
|
||||
public function get_instructions(): void {
|
||||
|
||||
wu_get_template('wizards/host-integrations/cloudways-instructions');
|
||||
}
|
||||
@ -538,6 +538,6 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
*/
|
||||
public function get_logo() {
|
||||
|
||||
return wu_get_asset('cloudways.png', 'img/hosts');
|
||||
return wu_get_asset('cloudways.webp', 'img/hosts');
|
||||
}
|
||||
}
|
||||
|
@ -53,10 +53,10 @@ class CPanel_Host_Provider extends Base_Host_Provider {
|
||||
* @var array
|
||||
* @since 2.0.0
|
||||
*/
|
||||
protected $supports = array(
|
||||
protected $supports = [
|
||||
'autossl',
|
||||
'no-instructions',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Constants that need to be present on wp-config.php for this integration to work.
|
||||
@ -64,11 +64,11 @@ class CPanel_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $constants = array(
|
||||
protected $constants = [
|
||||
'WU_CPANEL_USERNAME',
|
||||
'WU_CPANEL_PASSWORD',
|
||||
'WU_CPANEL_HOST',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Constants that are optional on wp-config.php.
|
||||
@ -76,10 +76,10 @@ class CPanel_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $optional_constants = array(
|
||||
protected $optional_constants = [
|
||||
'WU_CPANEL_PORT',
|
||||
'WU_CPANEL_ROOT_DIR',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Holds the API object.
|
||||
@ -110,31 +110,31 @@ class CPanel_Host_Provider extends Base_Host_Provider {
|
||||
*/
|
||||
public function get_fields() {
|
||||
|
||||
return array(
|
||||
'WU_CPANEL_USERNAME' => array(
|
||||
return [
|
||||
'WU_CPANEL_USERNAME' => [
|
||||
'title' => __('cPanel Username', 'wp-ultimo'),
|
||||
'placeholder' => __('e.g. username', 'wp-ultimo'),
|
||||
),
|
||||
'WU_CPANEL_PASSWORD' => array(
|
||||
],
|
||||
'WU_CPANEL_PASSWORD' => [
|
||||
'type' => 'password',
|
||||
'title' => __('cPanel Password', 'wp-ultimo'),
|
||||
'placeholder' => __('password', 'wp-ultimo'),
|
||||
),
|
||||
'WU_CPANEL_HOST' => array(
|
||||
],
|
||||
'WU_CPANEL_HOST' => [
|
||||
'title' => __('cPanel Host', 'wp-ultimo'),
|
||||
'placeholder' => __('e.g. yourdomain.com', 'wp-ultimo'),
|
||||
),
|
||||
'WU_CPANEL_PORT' => array(
|
||||
],
|
||||
'WU_CPANEL_PORT' => [
|
||||
'title' => __('cPanel Port', 'wp-ultimo'),
|
||||
'placeholder' => __('Defaults to 2083', 'wp-ultimo'),
|
||||
'value' => 2083,
|
||||
),
|
||||
'WU_CPANEL_ROOT_DIR' => array(
|
||||
],
|
||||
'WU_CPANEL_ROOT_DIR' => [
|
||||
'title' => __('Root Directory', 'wp-ultimo'),
|
||||
'placeholder' => __('Defaults to /public_html', 'wp-ultimo'),
|
||||
'value' => '/public_html',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -145,7 +145,7 @@ class CPanel_Host_Provider extends Base_Host_Provider {
|
||||
* @param int $site_id ID of the site that is receiving that mapping.
|
||||
* @return void
|
||||
*/
|
||||
public function on_add_domain($domain, $site_id) {
|
||||
public function on_add_domain($domain, $site_id): void {
|
||||
|
||||
// Root Directory
|
||||
$root_dir = defined('WU_CPANEL_ROOT_DIR') && WU_CPANEL_ROOT_DIR ? WU_CPANEL_ROOT_DIR : '/public_html';
|
||||
@ -154,11 +154,11 @@ class CPanel_Host_Provider extends Base_Host_Provider {
|
||||
$results = $this->load_api()->api2(
|
||||
'AddonDomain',
|
||||
'addaddondomain',
|
||||
array(
|
||||
[
|
||||
'dir' => $root_dir,
|
||||
'newdomain' => $domain,
|
||||
'subdomain' => $this->get_subdomain($domain),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$this->log_calls($results);
|
||||
@ -172,16 +172,16 @@ class CPanel_Host_Provider extends Base_Host_Provider {
|
||||
* @param int $site_id ID of the site that is receiving that mapping.
|
||||
* @return void
|
||||
*/
|
||||
public function on_remove_domain($domain, $site_id) {
|
||||
public function on_remove_domain($domain, $site_id): void {
|
||||
|
||||
// Send Request
|
||||
$results = $this->load_api()->api2(
|
||||
'AddonDomain',
|
||||
'deladdondomain',
|
||||
array(
|
||||
[
|
||||
'domain' => $domain,
|
||||
'subdomain' => $this->get_subdomain($domain) . '_' . $this->get_site_url(),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$this->log_calls($results);
|
||||
@ -197,7 +197,7 @@ class CPanel_Host_Provider extends Base_Host_Provider {
|
||||
* @param int $site_id ID of the site that is receiving that mapping.
|
||||
* @return void
|
||||
*/
|
||||
public function on_add_subdomain($subdomain, $site_id) {
|
||||
public function on_add_subdomain($subdomain, $site_id): void {
|
||||
|
||||
// Root Directory
|
||||
$root_dir = defined('WU_CPANEL_ROOT_DIR') && WU_CPANEL_ROOT_DIR ? WU_CPANEL_ROOT_DIR : '/public_html';
|
||||
@ -210,11 +210,11 @@ class CPanel_Host_Provider extends Base_Host_Provider {
|
||||
$results = $this->load_api()->api2(
|
||||
'SubDomain',
|
||||
'addsubdomain',
|
||||
array(
|
||||
[
|
||||
'dir' => $root_dir,
|
||||
'domain' => $subdomain,
|
||||
'rootdomain' => $rootdomain,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
// Check the results
|
||||
@ -282,7 +282,7 @@ class CPanel_Host_Provider extends Base_Host_Provider {
|
||||
return array_shift($domain_parts);
|
||||
}
|
||||
|
||||
$subdomain = str_replace(array('.', '/'), '', $domain);
|
||||
$subdomain = str_replace(['.', '/'], '', $domain);
|
||||
|
||||
return $subdomain;
|
||||
}
|
||||
@ -333,9 +333,9 @@ class CPanel_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function test_connection() {
|
||||
public function test_connection(): void {
|
||||
|
||||
$results = $this->load_api()->api2('Cron', 'fetchcron', array());
|
||||
$results = $this->load_api()->api2('Cron', 'fetchcron', []);
|
||||
|
||||
$this->log_calls($results);
|
||||
|
||||
@ -356,12 +356,12 @@ class CPanel_Host_Provider extends Base_Host_Provider {
|
||||
*/
|
||||
public function get_explainer_lines() {
|
||||
|
||||
$explainer_lines = array(
|
||||
'will' => array(
|
||||
$explainer_lines = [
|
||||
'will' => [
|
||||
'send_domains' => __('Add a new Addon Domain on cPanel whenever a new domain mapping gets created on your network', 'wp-ultimo'),
|
||||
),
|
||||
'will_not' => array(),
|
||||
);
|
||||
],
|
||||
'will_not' => [],
|
||||
];
|
||||
|
||||
if (is_subdomain_install()) {
|
||||
$explainer_lines['will']['send_sub_domains'] = __('Add a new SubDomain on cPanel whenever a new site gets created on your network', 'wp-ultimo');
|
||||
|
@ -51,10 +51,10 @@ class Gridpane_Host_Provider extends Base_Host_Provider {
|
||||
* @var array
|
||||
* @since 2.0.0
|
||||
*/
|
||||
protected $supports = array(
|
||||
protected $supports = [
|
||||
'autossl',
|
||||
'no-config',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Constants that need to be present on wp-config.php for this integration to work.
|
||||
@ -62,9 +62,9 @@ class Gridpane_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $constants = array(
|
||||
protected $constants = [
|
||||
'WU_GRIDPANE',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Picks up on tips that a given host provider is being used.
|
||||
@ -85,7 +85,7 @@ class Gridpane_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function enable() {
|
||||
public function enable(): void {
|
||||
/*
|
||||
* Prevent issues with Gridpane
|
||||
*/
|
||||
@ -104,19 +104,19 @@ class Gridpane_Host_Provider extends Base_Host_Provider {
|
||||
* @param string $method The HTTP method.
|
||||
* @return mixed
|
||||
*/
|
||||
public function send_gridpane_api_request($endpoint, $data = array(), $method = 'POST') {
|
||||
public function send_gridpane_api_request($endpoint, $data = [], $method = 'POST') {
|
||||
|
||||
$post_fields = array(
|
||||
$post_fields = [
|
||||
'timeout' => 45,
|
||||
'blocking' => true,
|
||||
'method' => $method,
|
||||
'body' => array_merge(
|
||||
array(
|
||||
[
|
||||
'api_token' => WU_GRIDPANE_API_KEY,
|
||||
),
|
||||
],
|
||||
$data
|
||||
),
|
||||
);
|
||||
];
|
||||
|
||||
$response = wp_remote_request("https://my.gridpane.com/api/{$endpoint}", $post_fields);
|
||||
|
||||
@ -143,11 +143,11 @@ class Gridpane_Host_Provider extends Base_Host_Provider {
|
||||
|
||||
return $this->send_gridpane_api_request(
|
||||
'application/add-domain',
|
||||
array(
|
||||
[
|
||||
'server_ip' => WU_GRIDPANE_SERVER_ID,
|
||||
'site_url' => WU_GRIDPANE_APP_ID,
|
||||
'domain_url' => $domain,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -163,11 +163,11 @@ class Gridpane_Host_Provider extends Base_Host_Provider {
|
||||
|
||||
return $this->send_gridpane_api_request(
|
||||
'application/delete-domain',
|
||||
array(
|
||||
[
|
||||
'server_ip' => WU_GRIDPANE_SERVER_ID,
|
||||
'site_url' => WU_GRIDPANE_APP_ID,
|
||||
'domain_url' => $domain,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -201,30 +201,30 @@ class Gridpane_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function test_connection() {
|
||||
public function test_connection(): void {
|
||||
|
||||
$results = $this->on_remove_domain('test.com', false);
|
||||
|
||||
if (wu_get_isset($results, 'message') === 'This action is unauthorized.') {
|
||||
wp_send_json_error(
|
||||
array(
|
||||
[
|
||||
'error' => __('We were not able to successfully establish a connection.', 'wp-ultimo'),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if (is_wp_error($results)) {
|
||||
wp_send_json_error(
|
||||
array(
|
||||
[
|
||||
'error' => __('We were not able to successfully establish a connection.', 'wp-ultimo'),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'success' => __('Connection successfully established.', 'wp-ultimo'),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -234,7 +234,7 @@ class Gridpane_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function get_instructions() {
|
||||
public function get_instructions(): void {
|
||||
|
||||
wu_get_template('wizards/host-integrations/gridpane-instructions');
|
||||
}
|
||||
@ -258,6 +258,6 @@ class Gridpane_Host_Provider extends Base_Host_Provider {
|
||||
*/
|
||||
public function get_logo() {
|
||||
|
||||
return wu_get_asset('gridpane.png', 'img/hosts');
|
||||
return wu_get_asset('gridpane.webp', 'img/hosts');
|
||||
}
|
||||
}
|
||||
|
@ -52,9 +52,9 @@ class Runcloud_Host_Provider extends Base_Host_Provider {
|
||||
* @var array
|
||||
* @since 2.0.0
|
||||
*/
|
||||
protected $supports = array(
|
||||
protected $supports = [
|
||||
'autossl',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Constants that need to be present on wp-config.php for this integration to work.
|
||||
@ -62,12 +62,12 @@ class Runcloud_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $constants = array(
|
||||
protected $constants = [
|
||||
'WU_RUNCLOUD_API_KEY',
|
||||
'WU_RUNCLOUD_API_SECRET',
|
||||
'WU_RUNCLOUD_SERVER_ID',
|
||||
'WU_RUNCLOUD_APP_ID',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Picks up on tips that a given host provider is being used.
|
||||
@ -78,7 +78,7 @@ class Runcloud_Host_Provider extends Base_Host_Provider {
|
||||
*/
|
||||
public function detect(): bool {
|
||||
|
||||
return strpos(ABSPATH, 'runcloud') !== false;
|
||||
return str_contains(ABSPATH, 'runcloud');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,28 +89,28 @@ class Runcloud_Host_Provider extends Base_Host_Provider {
|
||||
*/
|
||||
public function get_fields() {
|
||||
|
||||
return array(
|
||||
'WU_RUNCLOUD_API_KEY' => array(
|
||||
return [
|
||||
'WU_RUNCLOUD_API_KEY' => [
|
||||
'title' => __('RunCloud API Key', 'wp-ultimo'),
|
||||
'desc' => __('The API Key retrieved in the previous step.', 'wp-ultimo'),
|
||||
'placeholder' => __('e.g. Sx9tHAn5XMrkeyZKS1a7uj8dGTLgKnlEOaJEFRt1m95L', 'wp-ultimo'),
|
||||
),
|
||||
'WU_RUNCLOUD_API_SECRET' => array(
|
||||
],
|
||||
'WU_RUNCLOUD_API_SECRET' => [
|
||||
'title' => __('RunCloud API Secret', 'wp-ultimo'),
|
||||
'desc' => __('The API secret retrieved in the previous step.', 'wp-ultimo'),
|
||||
'placeholder' => __('e.g. ZlAebXp2sa6J5xsrPoiPcMXZRIVsHJ2rEkNCNGknZnF0UK5cSNSePS8GBW9FXIQd', 'wp-ultimo'),
|
||||
),
|
||||
'WU_RUNCLOUD_SERVER_ID' => array(
|
||||
],
|
||||
'WU_RUNCLOUD_SERVER_ID' => [
|
||||
'title' => __('RunCloud Server ID', 'wp-ultimo'),
|
||||
'desc' => __('The Server ID retrieved in the previous step.', 'wp-ultimo'),
|
||||
'placeholder' => __('e.g. 11667', 'wp-ultimo'),
|
||||
),
|
||||
'WU_RUNCLOUD_APP_ID' => array(
|
||||
],
|
||||
'WU_RUNCLOUD_APP_ID' => [
|
||||
'title' => __('RunCloud App ID', 'wp-ultimo'),
|
||||
'desc' => __('The App ID retrieved in the previous step.', 'wp-ultimo'),
|
||||
'placeholder' => __('e.g. 940288', 'wp-ultimo'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -121,17 +121,17 @@ class Runcloud_Host_Provider extends Base_Host_Provider {
|
||||
* @param int $site_id ID of the site that is receiving that mapping.
|
||||
* @return void
|
||||
*/
|
||||
public function on_add_domain($domain, $site_id) {
|
||||
public function on_add_domain($domain, $site_id): void {
|
||||
|
||||
$success = false;
|
||||
|
||||
$response = $this->send_runcloud_request(
|
||||
$this->get_runcloud_base_url('domains'),
|
||||
array(
|
||||
[
|
||||
'name' => $domain,
|
||||
'www' => true,
|
||||
'redirection' => 'non-www',
|
||||
),
|
||||
],
|
||||
'POST'
|
||||
);
|
||||
|
||||
@ -163,7 +163,7 @@ class Runcloud_Host_Provider extends Base_Host_Provider {
|
||||
* @param int $site_id ID of the site that is receiving that mapping.
|
||||
* @return void
|
||||
*/
|
||||
public function on_remove_domain($domain, $site_id) {
|
||||
public function on_remove_domain($domain, $site_id): void {
|
||||
|
||||
$domain_id = $this->get_runcloud_domain_id($domain);
|
||||
|
||||
@ -171,7 +171,7 @@ class Runcloud_Host_Provider extends Base_Host_Provider {
|
||||
wu_log_add('integration-runcloud', __('Domain name not found on runcloud', 'wp-ultimo'));
|
||||
}
|
||||
|
||||
$response = $this->send_runcloud_request($this->get_runcloud_base_url("domains/$domain_id"), array(), 'DELETE');
|
||||
$response = $this->send_runcloud_request($this->get_runcloud_base_url("domains/$domain_id"), [], 'DELETE');
|
||||
|
||||
if (is_wp_error($response)) {
|
||||
wu_log_add('integration-runcloud', $response->get_error_message(), LogLevel::ERROR);
|
||||
@ -210,9 +210,9 @@ class Runcloud_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function test_connection() {
|
||||
public function test_connection(): void {
|
||||
|
||||
$response = $this->send_runcloud_request($this->get_runcloud_base_url('domains'), array(), 'GET');
|
||||
$response = $this->send_runcloud_request($this->get_runcloud_base_url('domains'), [], 'GET');
|
||||
|
||||
if (is_wp_error($response) || wp_remote_retrieve_response_code($response) !== 200) {
|
||||
wp_send_json_error($response);
|
||||
@ -246,7 +246,7 @@ class Runcloud_Host_Provider extends Base_Host_Provider {
|
||||
* @param string $method HTTP Method to send. Defaults to POST.
|
||||
* @return array
|
||||
*/
|
||||
public function send_runcloud_request($url, $data = array(), $method = 'POST') {
|
||||
public function send_runcloud_request($url, $data = [], $method = 'POST') {
|
||||
|
||||
$username = defined('WU_RUNCLOUD_API_KEY') ? WU_RUNCLOUD_API_KEY : '';
|
||||
|
||||
@ -254,15 +254,15 @@ class Runcloud_Host_Provider extends Base_Host_Provider {
|
||||
|
||||
$response = wp_remote_request(
|
||||
$url,
|
||||
array(
|
||||
[
|
||||
'timeout' => 100,
|
||||
'redirection' => 5,
|
||||
'body' => $data,
|
||||
'method' => $method,
|
||||
'headers' => array(
|
||||
'headers' => [
|
||||
'Authorization' => 'Basic ' . base64_encode($username . ':' . $password),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
return $response;
|
||||
@ -293,7 +293,7 @@ class Runcloud_Host_Provider extends Base_Host_Provider {
|
||||
*/
|
||||
public function get_runcloud_domain_id($domain) {
|
||||
|
||||
$domains_list = $this->send_runcloud_request($this->get_runcloud_base_url('domains'), array(), 'GET');
|
||||
$domains_list = $this->send_runcloud_request($this->get_runcloud_base_url('domains'), [], 'GET');
|
||||
|
||||
$list = $this->maybe_return_runcloud_body($domains_list);
|
||||
|
||||
@ -317,7 +317,7 @@ class Runcloud_Host_Provider extends Base_Host_Provider {
|
||||
|
||||
$ssl_id = false;
|
||||
|
||||
$response = $this->send_runcloud_request($this->get_runcloud_base_url('ssl'), array(), 'GET');
|
||||
$response = $this->send_runcloud_request($this->get_runcloud_base_url('ssl'), [], 'GET');
|
||||
|
||||
if (is_wp_error($response)) {
|
||||
wu_log_add('integration-runcloud', $response->get_error_message(), LogLevel::ERROR);
|
||||
@ -341,9 +341,9 @@ class Runcloud_Host_Provider extends Base_Host_Provider {
|
||||
* @param int $ssl_id The SSL id on RunCloud.
|
||||
* @return void
|
||||
*/
|
||||
public function redeploy_runcloud_ssl($ssl_id) {
|
||||
public function redeploy_runcloud_ssl($ssl_id): void {
|
||||
|
||||
$response = $this->send_runcloud_request($this->get_runcloud_base_url("ssl/$ssl_id"), array(), 'PUT');
|
||||
$response = $this->send_runcloud_request($this->get_runcloud_base_url("ssl/$ssl_id"), [], 'PUT');
|
||||
|
||||
if (is_wp_error($response)) {
|
||||
wu_log_add('integration-runcloud', $response->get_error_message(), LogLevel::ERROR);
|
||||
@ -358,7 +358,7 @@ class Runcloud_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function get_instructions() {
|
||||
public function get_instructions(): void {
|
||||
|
||||
wu_get_template('wizards/host-integrations/runcloud-instructions');
|
||||
}
|
||||
|
@ -52,9 +52,9 @@ class ServerPilot_Host_Provider extends Base_Host_Provider {
|
||||
* @var array
|
||||
* @since 2.0.0
|
||||
*/
|
||||
protected $supports = array(
|
||||
protected $supports = [
|
||||
'autossl',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Constants that need to be present on wp-config.php for this integration to work.
|
||||
@ -62,11 +62,11 @@ class ServerPilot_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $constants = array(
|
||||
protected $constants = [
|
||||
'WU_SERVER_PILOT_CLIENT_ID',
|
||||
'WU_SERVER_PILOT_API_KEY',
|
||||
'WU_SERVER_PILOT_APP_ID',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Picks up on tips that a given host provider is being used.
|
||||
@ -89,23 +89,23 @@ class ServerPilot_Host_Provider extends Base_Host_Provider {
|
||||
*/
|
||||
public function get_fields() {
|
||||
|
||||
return array(
|
||||
'WU_SERVER_PILOT_CLIENT_ID' => array(
|
||||
return [
|
||||
'WU_SERVER_PILOT_CLIENT_ID' => [
|
||||
'title' => __('ServerPilot Client ID', 'wp-ultimo'),
|
||||
'desc' => __('Your ServerPilot Client ID.', 'wp-ultimo'),
|
||||
'placeholder' => __('e.g. cid_lSmjevkdoSOpasYVqm', 'wp-ultimo'),
|
||||
),
|
||||
'WU_SERVER_PILOT_API_KEY' => array(
|
||||
],
|
||||
'WU_SERVER_PILOT_API_KEY' => [
|
||||
'title' => __('ServerPilot API Key', 'wp-ultimo'),
|
||||
'desc' => __('The API Key retrieved in the previous step.', 'wp-ultimo'),
|
||||
'placeholder' => __('e.g. eYP0Jo3Fzzm5SOZCi5nLR0Mki2lbYZ', 'wp-ultimo'),
|
||||
),
|
||||
'WU_SERVER_PILOT_APP_ID' => array(
|
||||
],
|
||||
'WU_SERVER_PILOT_APP_ID' => [
|
||||
'title' => __('ServerPilot App ID', 'wp-ultimo'),
|
||||
'desc' => __('The App ID retrieved in the previous step.', 'wp-ultimo'),
|
||||
'placeholder' => __('e.g. 940288', 'wp-ultimo'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,16 +116,16 @@ class ServerPilot_Host_Provider extends Base_Host_Provider {
|
||||
* @param int $site_id ID of the site that is receiving that mapping.
|
||||
* @return void
|
||||
*/
|
||||
public function on_add_domain($domain, $site_id) {
|
||||
public function on_add_domain($domain, $site_id): void {
|
||||
|
||||
$current_domain_list = $this->get_server_pilot_domains();
|
||||
|
||||
if ($current_domain_list && is_array($current_domain_list)) {
|
||||
$this->send_server_pilot_api_request(
|
||||
'',
|
||||
array(
|
||||
'domains' => array_merge($current_domain_list, array($domain, 'www.' . $domain)),
|
||||
)
|
||||
[
|
||||
'domains' => array_merge($current_domain_list, [$domain, 'www.' . $domain]),
|
||||
]
|
||||
);
|
||||
|
||||
/**
|
||||
@ -143,7 +143,7 @@ class ServerPilot_Host_Provider extends Base_Host_Provider {
|
||||
* @param int $site_id ID of the site that is receiving that mapping.
|
||||
* @return void
|
||||
*/
|
||||
public function on_remove_domain($domain, $site_id) {
|
||||
public function on_remove_domain($domain, $site_id): void {
|
||||
|
||||
$current_domain_list = $this->get_server_pilot_domains();
|
||||
|
||||
@ -156,9 +156,9 @@ class ServerPilot_Host_Provider extends Base_Host_Provider {
|
||||
|
||||
$this->send_server_pilot_api_request(
|
||||
'',
|
||||
array(
|
||||
[
|
||||
'domains' => $current_domain_list,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -173,16 +173,16 @@ class ServerPilot_Host_Provider extends Base_Host_Provider {
|
||||
* @param int $site_id ID of the site that is receiving that mapping.
|
||||
* @return void
|
||||
*/
|
||||
public function on_add_subdomain($subdomain, $site_id) {
|
||||
public function on_add_subdomain($subdomain, $site_id): void {
|
||||
|
||||
$current_domain_list = $this->get_server_pilot_domains();
|
||||
|
||||
if ($current_domain_list && is_array($current_domain_list)) {
|
||||
$this->send_server_pilot_api_request(
|
||||
'',
|
||||
array(
|
||||
'domains' => array_merge($current_domain_list, array($subdomain)),
|
||||
)
|
||||
[
|
||||
'domains' => array_merge($current_domain_list, [$subdomain]),
|
||||
]
|
||||
);
|
||||
|
||||
/**
|
||||
@ -213,18 +213,18 @@ class ServerPilot_Host_Provider extends Base_Host_Provider {
|
||||
* @param string $method HTTP Method: POST, GET, PUT, etc.
|
||||
* @return object
|
||||
*/
|
||||
public function send_server_pilot_api_request($endpoint, $data = array(), $method = 'POST') {
|
||||
public function send_server_pilot_api_request($endpoint, $data = [], $method = 'POST') {
|
||||
|
||||
$post_fields = array(
|
||||
$post_fields = [
|
||||
'timeout' => 45,
|
||||
'blocking' => true,
|
||||
'method' => $method,
|
||||
'body' => $data ? json_encode($data) : array(),
|
||||
'headers' => array(
|
||||
'body' => $data ? json_encode($data) : [],
|
||||
'headers' => [
|
||||
'Authorization' => 'Basic ' . base64_encode(WU_SERVER_PILOT_CLIENT_ID . ':' . WU_SERVER_PILOT_API_KEY),
|
||||
'Content-Type' => 'application/json',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$response = wp_remote_request('https://api.serverpilot.io/v1/apps/' . WU_SERVER_PILOT_APP_ID . $endpoint, $post_fields);
|
||||
|
||||
@ -249,9 +249,9 @@ class ServerPilot_Host_Provider extends Base_Host_Provider {
|
||||
|
||||
return $this->send_server_pilot_api_request(
|
||||
'/ssl',
|
||||
array(
|
||||
[
|
||||
'auto' => true,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -263,7 +263,7 @@ class ServerPilot_Host_Provider extends Base_Host_Provider {
|
||||
*/
|
||||
public function get_server_pilot_domains() {
|
||||
|
||||
$app_info = $this->send_server_pilot_api_request('', array(), 'GET');
|
||||
$app_info = $this->send_server_pilot_api_request('', [], 'GET');
|
||||
|
||||
if (isset($app_info['data']['domains'])) {
|
||||
return $app_info['data']['domains'];
|
||||
@ -285,9 +285,9 @@ class ServerPilot_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function test_connection() {
|
||||
public function test_connection(): void {
|
||||
|
||||
$response = $this->send_server_pilot_api_request('', array(), 'GET');
|
||||
$response = $this->send_server_pilot_api_request('', [], 'GET');
|
||||
|
||||
if (is_wp_error($response) || wu_get_isset($response, 'error')) {
|
||||
wp_send_json_error($response);
|
||||
@ -302,7 +302,7 @@ class ServerPilot_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.1.2
|
||||
* @return void
|
||||
*/
|
||||
public function get_instructions() {
|
||||
public function get_instructions(): void {
|
||||
|
||||
wu_get_template('wizards/host-integrations/serverpilot-instructions');
|
||||
}
|
||||
|
@ -52,10 +52,10 @@ class WPEngine_Host_Provider extends Base_Host_Provider {
|
||||
* @var array
|
||||
* @since 2.0.0
|
||||
*/
|
||||
protected $supports = array(
|
||||
protected $supports = [
|
||||
'no-instructions',
|
||||
'no-config',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Constants that need to be present on wp-config.php for this integration to work.
|
||||
@ -63,9 +63,9 @@ class WPEngine_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $constants = array(
|
||||
array('WPE_API', 'WPE_APIKEY'),
|
||||
);
|
||||
protected $constants = [
|
||||
['WPE_API', 'WPE_APIKEY'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Picks up on tips that a given host provider is being used.
|
||||
@ -86,7 +86,7 @@ class WPEngine_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function load_dependencies() {
|
||||
public function load_dependencies(): void {
|
||||
|
||||
// if WP Engine is not defined, then return
|
||||
if ( ! defined('WPE_PLUGIN_DIR') || ! is_readable(WPE_PLUGIN_DIR . '/class-wpeapi.php')) {
|
||||
@ -104,7 +104,7 @@ class WPEngine_Host_Provider extends Base_Host_Provider {
|
||||
* @param int $site_id ID of the site that is receiving that mapping.
|
||||
* @return void
|
||||
*/
|
||||
public function on_add_domain($domain, $site_id) {
|
||||
public function on_add_domain($domain, $site_id): void {
|
||||
|
||||
$api = new \WPE_API();
|
||||
|
||||
@ -123,7 +123,7 @@ class WPEngine_Host_Provider extends Base_Host_Provider {
|
||||
* @param int $site_id ID of the site that is receiving that mapping.
|
||||
* @return void
|
||||
*/
|
||||
public function on_remove_domain($domain, $site_id) {
|
||||
public function on_remove_domain($domain, $site_id): void {
|
||||
|
||||
$api = new \WPE_API();
|
||||
|
||||
@ -144,7 +144,7 @@ class WPEngine_Host_Provider extends Base_Host_Provider {
|
||||
* @param int $site_id ID of the site that is receiving that mapping.
|
||||
* @return void
|
||||
*/
|
||||
public function on_add_subdomain($subdomain, $site_id) {
|
||||
public function on_add_subdomain($subdomain, $site_id): void {
|
||||
|
||||
$this->on_add_domain($subdomain, $site_id);
|
||||
}
|
||||
@ -159,7 +159,7 @@ class WPEngine_Host_Provider extends Base_Host_Provider {
|
||||
* @param int $site_id ID of the site that is receiving that mapping.
|
||||
* @return void
|
||||
*/
|
||||
public function on_remove_subdomain($subdomain, $site_id) {
|
||||
public function on_remove_subdomain($subdomain, $site_id): void {
|
||||
|
||||
$this->on_remove_domain($subdomain, $site_id);
|
||||
}
|
||||
@ -196,7 +196,7 @@ class WPEngine_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function test_connection() {
|
||||
public function test_connection(): void {
|
||||
|
||||
$api = new \WPE_API();
|
||||
|
||||
|
@ -52,11 +52,11 @@ class WPMUDEV_Host_Provider extends Base_Host_Provider {
|
||||
* @var array
|
||||
* @since 2.0.0
|
||||
*/
|
||||
protected $supports = array(
|
||||
protected $supports = [
|
||||
'autossl',
|
||||
'no-instructions',
|
||||
'no-config',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Constants that need to be present on wp-config.php for this integration to work.
|
||||
@ -64,9 +64,9 @@ class WPMUDEV_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $constants = array(
|
||||
protected $constants = [
|
||||
'WPMUDEV_HOSTING_SITE_ID',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Runs on singleton instantiation.
|
||||
@ -74,7 +74,7 @@ class WPMUDEV_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.1.1
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
parent::init();
|
||||
|
||||
@ -82,7 +82,7 @@ class WPMUDEV_Host_Provider extends Base_Host_Provider {
|
||||
* Add filter to increase the number of tries to get the SSL certificate.
|
||||
* This is needed because, from our tests, WPMU DEV hosting takes a while to get the SSL certificate.
|
||||
*/
|
||||
add_filter('wu_async_process_domain_stage_max_tries', array($this, 'ssl_tries'), 10, 2);
|
||||
add_filter('wu_async_process_domain_stage_max_tries', [$this, 'ssl_tries'], 10, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -127,31 +127,31 @@ class WPMUDEV_Host_Provider extends Base_Host_Provider {
|
||||
* @param int $site_id ID of the site that is receiving that mapping.
|
||||
* @return void
|
||||
*/
|
||||
public function on_add_domain($domain, $site_id) {
|
||||
public function on_add_domain($domain, $site_id): void {
|
||||
|
||||
$site_id = WPMUDEV_HOSTING_SITE_ID;
|
||||
|
||||
$api_key = get_site_option('wpmudev_apikey');
|
||||
|
||||
$domains = array($domain);
|
||||
$domains = [$domain];
|
||||
|
||||
if (strncmp($domain, 'www.', strlen('www.')) !== 0) {
|
||||
if (! str_starts_with($domain, 'www.')) {
|
||||
$domains[] = "www.$domain";
|
||||
}
|
||||
|
||||
foreach ($domains as $_domain) {
|
||||
$response = wp_remote_post(
|
||||
"https://premium.wpmudev.org/api/hosting/v1/$site_id/domains",
|
||||
array(
|
||||
[
|
||||
'timeout' => 50,
|
||||
'body' => array(
|
||||
'body' => [
|
||||
'domain' => $_domain,
|
||||
'site_id' => $site_id,
|
||||
),
|
||||
'headers' => array(
|
||||
],
|
||||
'headers' => [
|
||||
'Authorization' => $api_key,
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
if (is_wp_error($response)) {
|
||||
@ -182,7 +182,7 @@ class WPMUDEV_Host_Provider extends Base_Host_Provider {
|
||||
* @param int $site_id ID of the site that is receiving that mapping.
|
||||
* @return void
|
||||
*/
|
||||
public function on_remove_domain($domain, $site_id) {
|
||||
public function on_remove_domain($domain, $site_id): void {
|
||||
|
||||
/**
|
||||
* The WPMU DEV Hosting REST API does not offer an endpoint to remove domains yet.
|
||||
@ -222,7 +222,7 @@ class WPMUDEV_Host_Provider extends Base_Host_Provider {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function test_connection() {
|
||||
public function test_connection(): void {
|
||||
|
||||
$site_id = WPMUDEV_HOSTING_SITE_ID;
|
||||
|
||||
@ -230,12 +230,12 @@ class WPMUDEV_Host_Provider extends Base_Host_Provider {
|
||||
|
||||
$response = wp_remote_get(
|
||||
"https://premium.wpmudev.org/api/hosting/v1/{$site_id}/domains",
|
||||
array(
|
||||
[
|
||||
'timeout' => 50,
|
||||
'headers' => array(
|
||||
'headers' => [
|
||||
'Authorization' => $api_key,
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
if (is_wp_error($response) || wp_remote_retrieve_response_code($response) !== 200) {
|
||||
@ -264,6 +264,6 @@ class WPMUDEV_Host_Provider extends Base_Host_Provider {
|
||||
*/
|
||||
public function get_logo() {
|
||||
|
||||
return wu_get_asset('wpmudev.jpg', 'img/hosts');
|
||||
return wu_get_asset('wpmudev.webp', 'img/hosts');
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ class CPanel_API {
|
||||
* @since 1.6.2
|
||||
* @return void
|
||||
*/
|
||||
public function generate_cookie() {
|
||||
public function generate_cookie(): void {
|
||||
|
||||
wu_log_add('integration-cpanel-cookie', '');
|
||||
}
|
||||
@ -138,7 +138,7 @@ class CPanel_API {
|
||||
* @param array $params Request parameters to send.
|
||||
* @return mixed
|
||||
*/
|
||||
private function request($url, $params = array()) {
|
||||
private function request($url, $params = []) {
|
||||
|
||||
if ($this->log) {
|
||||
$curl_log = fopen($this->curlfile, 'a+');
|
||||
@ -162,7 +162,7 @@ class CPanel_API {
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
$curl_opts = array(
|
||||
$curl_opts = [
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_SSL_VERIFYHOST => false,
|
||||
@ -170,7 +170,7 @@ class CPanel_API {
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_COOKIEJAR => realpath($this->cookie_file),
|
||||
CURLOPT_COOKIEFILE => realpath($this->cookie_file),
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
CURLOPT_HTTPHEADER => [
|
||||
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0',
|
||||
'Host: ' . $this->host,
|
||||
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||
@ -178,8 +178,8 @@ class CPanel_API {
|
||||
'Accept-Encoding: gzip, deflate',
|
||||
'Connection: keep-alive',
|
||||
'Content-Type: application/x-www-form-urlencoded',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
if ( ! empty($params)) {
|
||||
$curl_opts[ CURLOPT_POST ] = true;
|
||||
@ -258,7 +258,7 @@ class CPanel_API {
|
||||
* @param array $parameters Parameters to the API endpoint.
|
||||
* @return boolean
|
||||
*/
|
||||
public function execute($api, $module, $function, array $parameters = array()) {
|
||||
public function execute($api, $module, $function, array $parameters = []) {
|
||||
|
||||
switch ($api) {
|
||||
case 'api2':
|
||||
@ -279,7 +279,7 @@ class CPanel_API {
|
||||
* @param array $parameters Parameters to the API endpoint.
|
||||
* @return mixed
|
||||
*/
|
||||
public function uapi($module, $function, array $parameters = array()) {
|
||||
public function uapi($module, $function, array $parameters = []) {
|
||||
|
||||
if (count($parameters) < 1) {
|
||||
$parameters = '';
|
||||
@ -299,7 +299,7 @@ class CPanel_API {
|
||||
* @param array $parameters Parameters to the API endpoint.
|
||||
* @return mixed
|
||||
*/
|
||||
public function api2($module, $function, array $parameters = array()) {
|
||||
public function api2($module, $function, array $parameters = []) {
|
||||
|
||||
if (count($parameters) < 1) {
|
||||
$parameters = '';
|
||||
|
Reference in New Issue
Block a user