Prep Plugin for release on WordPress.org
Escape everything that should be escaped. Add nonce checks where needed. Sanitize all inputs. Apply Code style changes across the codebase. Correct many deprecation notices. Optimize load order of many filters.
This commit is contained in:
.phpcs.xml.distsetuptest.shsunrise.php
assets
inc
admin-pages
class-broadcast-edit-admin-page.phpclass-checkout-form-edit-admin-page.phpclass-checkout-form-list-admin-page.phpclass-customer-edit-admin-page.phpclass-customer-list-admin-page.phpclass-customizer-admin-page.phpclass-dashboard-admin-page.phpclass-discount-code-edit-admin-page.phpclass-domain-edit-admin-page.phpclass-domain-list-admin-page.phpclass-edit-admin-page.phpclass-email-edit-admin-page.phpclass-email-template-customize-admin-page.phpclass-event-view-admin-page.phpclass-hosting-integration-wizard-admin-page.phpclass-invoice-template-customize-admin-page.phpclass-membership-edit-admin-page.phpclass-migration-alert-admin-page.phpclass-payment-edit-admin-page.phpclass-product-edit-admin-page.phpclass-settings-admin-page.phpclass-setup-wizard-admin-page.phpclass-site-edit-admin-page.phpclass-site-list-admin-page.phpclass-template-previewer-customize-admin-page.phpclass-top-admin-nav-menu.phpclass-view-logs-admin-page.phpclass-webhook-edit-admin-page.phpclass-webhook-list-admin-page.phpclass-wizard-admin-page.php
api
checkout
class-cart.phpclass-checkout-pages.phpclass-checkout.phpclass-legacy-checkout.phpclass-line-item.php
class-admin-notices.phpclass-ajax.phpclass-api.phpclass-async-calls.phpclass-dashboard-widgets.phpclass-domain-mapping.phpclass-faker.phpclass-helper.phpclass-light-ajax.phpclass-logger.phpclass-maintenance-mode.phpclass-newsletter.phpclass-requirements.phpclass-session-cookie.phpclass-settings.phpclass-sunrise.phpclass-views.phpclass-whitelabel.phpsignup-fields
debug
development
functions
compatiblity.phpdate.phpfinancial.phplegacy.phpmarkup-helpers.phpoptions.phpsort.phpstring-helpers.phpsunrise.phpurl.php
gateways
helpers
integrations
host-providers
limitations
limits
list-tables
class-base-list-table.phpclass-checkout-form-list-table.phpclass-customer-list-table.phpclass-customers-payment-list-table.phpclass-email-list-table.phpclass-membership-line-item-list-table.phpclass-membership-list-table-widget.phpclass-membership-list-table.phpclass-memberships-site-list-table.phpclass-payment-line-item-list-table.phpclass-payment-list-table-widget.phpclass-payment-list-table.phpclass-product-list-table.phpclass-site-list-table.php
managers
class-customer-manager.phpclass-domain-manager.phpclass-email-manager.phpclass-event-manager.phpclass-gateway-manager.phpclass-limitation-manager.phpclass-notes-manager.phpclass-site-manager.phpclass-webhook-manager.php
models
tax
ui
views
about.phpadmin-notices.php
admin-pages
fields
field-actions.phpfield-code-editor.phpfield-color-picker.phpfield-dashicon.phpfield-group.phpfield-header.phpfield-hidden.phpfield-html.phpfield-image.phpfield-link.phpfield-multiselect.phpfield-note.phpfield-repeater.phpfield-select-icon.phpfield-select.phpfield-small-header.phpfield-submit.phpfield-tab-select.phpfield-text-display.phpfield-text-edit.phpfield-text.phpfield-textarea.phpfield-toggle.phpfield-wp-editor.phpform.php
partials
base
centered.php
checkout-forms
customers
dash.phpedit.phpedit
empty-state.phpfilter.phpgrid.phplist.phpproducts
responsive-table-row.phpsettings.phpwizard.phpwizard
broadcast
checkout
fields
field-checkbox-multi.phpfield-checkbox.phpfield-group.phpfield-hidden.phpfield-html.phpfield-note.phpfield-password.phpfield-payment-methods.phpfield-products.phpfield-radio.phpfield-select.phpfield-submit.phpfield-text.phpfield-toggle.phpform.php
partials
paypal
templates
order-bump
order-summary
period-selection
pricing-table
steps
template-selection
customers
dashboard-statistics
filter.phpwidget-countries.phpwidget-forms.phpwidget-most-visited-sites.phpwidget-mrr-growth.phpwidget-new-accounts.phpwidget-revenue.phpwidget-tax-by-code.phpwidget-tax-by-day.phpwidget-tax-graph.phpwidget-taxes.php
dashboard-widgets
account-summary.phpactivity-stream.phpbilling-info.phpcurrent-membership-product-details.phpcurrent-membership.phpcurrent-site.phpdomain-mapping.phpfirst-steps.phpinvoices.phplimits-and-quotas.phplogin-form.phpmy-sites.phpsite-actions.phpsummary.phpthank-you.php
domain
email
emails
admin
customer
events
invoice
legacy
signup
limitations
memberships
payments
settings
shortcodes
sites
system-info
taxes
ui
wizards
@@ -92,7 +92,8 @@ abstract class Base_Host_Provider {
|
||||
/*
|
||||
* Adds an admin notice telling the admin that they should probably enable this integration.
|
||||
*/
|
||||
return $this->alert_provider_detected();
|
||||
$this->alert_provider_detected();
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -106,7 +107,8 @@ abstract class Base_Host_Provider {
|
||||
/*
|
||||
* Adds an admin notice telling the admin that the provider is not correctly setup.
|
||||
*/
|
||||
return $this->alert_provider_not_setup();
|
||||
$this->alert_provider_not_setup();
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -301,7 +303,7 @@ abstract class Base_Host_Provider {
|
||||
* Get Fields for the integration.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return string
|
||||
* @return array
|
||||
*/
|
||||
public function get_fields() {
|
||||
|
||||
|
@@ -11,10 +11,6 @@ namespace WP_Ultimo\Integrations\Host_Providers;
|
||||
|
||||
use Psr\Log\LogLevel;
|
||||
use WP_Ultimo\Domain_Mapping\Helper;
|
||||
use WP_Ultimo\Integrations\Host_Providers\Base_Host_Provider;
|
||||
|
||||
// Exit if accessed directly
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
/**
|
||||
* This base class should be extended to implement new host integrations for SSL and domains.
|
||||
@@ -120,7 +116,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
if (is_wp_error($ssl_response)) {
|
||||
wu_log_add('integration-cloudways', '[SSL]' . $ssl_response->get_error_message(), LogLevel::ERROR);
|
||||
} else {
|
||||
wu_log_add('integration-cloudways', '[SSL]' . print_r($ssl_response, true));
|
||||
wu_log_add('integration-cloudways', '[SSL]' . print_r($ssl_response, true)); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,7 +242,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider {
|
||||
if (is_wp_error($alias_response)) {
|
||||
wu_log_add('integration-cloudways', '[Alias]' . $alias_response->get_error_message(), LogLevel::ERROR);
|
||||
} else {
|
||||
wu_log_add('integration-cloudways', '[Alias]' . print_r($alias_response, true));
|
||||
wu_log_add('integration-cloudways', '[Alias]' . print_r($alias_response, true)); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -10,7 +10,6 @@
|
||||
namespace WP_Ultimo\Integrations\Host_Providers;
|
||||
|
||||
use Psr\Log\LogLevel;
|
||||
use WP_Ultimo\Integrations\Host_Providers\Base_Host_Provider;
|
||||
|
||||
// Exit if accessed directly
|
||||
defined('ABSPATH') || exit;
|
||||
@@ -260,7 +259,7 @@ class Runcloud_Host_Provider extends Base_Host_Provider {
|
||||
'body' => $data,
|
||||
'method' => $method,
|
||||
'headers' => [
|
||||
'Authorization' => 'Basic ' . base64_encode($username . ':' . $password),
|
||||
'Authorization' => 'Basic ' . base64_encode($username . ':' . $password), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
|
||||
],
|
||||
]
|
||||
);
|
||||
@@ -325,7 +324,7 @@ class Runcloud_Host_Provider extends Base_Host_Provider {
|
||||
} else {
|
||||
$data = $this->maybe_return_runcloud_body($response);
|
||||
|
||||
wu_log_add('integration-runcloud', json_encode($data));
|
||||
wu_log_add('integration-runcloud', wp_json_encode($data));
|
||||
|
||||
if (property_exists($data, 'id')) {
|
||||
$ssl_id = $data->id;
|
||||
|
@@ -10,10 +10,6 @@
|
||||
namespace WP_Ultimo\Integrations\Host_Providers;
|
||||
|
||||
use Psr\Log\LogLevel;
|
||||
use WP_Ultimo\Integrations\Host_Providers\Base_Host_Provider;
|
||||
|
||||
// Exit if accessed directly
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
/**
|
||||
* This base class should be extended to implement new host integrations for SSL and domains.
|
||||
@@ -219,9 +215,9 @@ class ServerPilot_Host_Provider extends Base_Host_Provider {
|
||||
'timeout' => 45,
|
||||
'blocking' => true,
|
||||
'method' => $method,
|
||||
'body' => $data ? json_encode($data) : [],
|
||||
'body' => $data ? wp_json_encode($data) : [],
|
||||
'headers' => [
|
||||
'Authorization' => 'Basic ' . base64_encode(WU_SERVER_PILOT_CLIENT_ID . ':' . WU_SERVER_PILOT_API_KEY),
|
||||
'Authorization' => 'Basic ' . base64_encode(WU_SERVER_PILOT_CLIENT_ID . ':' . WU_SERVER_PILOT_API_KEY), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
|
||||
'Content-Type' => 'application/json',
|
||||
],
|
||||
];
|
||||
@@ -243,7 +239,7 @@ class ServerPilot_Host_Provider extends Base_Host_Provider {
|
||||
* Makes sure ServerPilot autoSSL is always on, when possible.
|
||||
*
|
||||
* @since 1.7.4
|
||||
* @return bool
|
||||
* @return object
|
||||
*/
|
||||
public function turn_server_pilot_auto_ssl_on() {
|
||||
|
||||
@@ -273,8 +269,8 @@ class ServerPilot_Host_Provider extends Base_Host_Provider {
|
||||
* Log response so we can see what went wrong
|
||||
*/
|
||||
|
||||
// translators: %s is the json_encode of the error.
|
||||
wu_log_add('integration-serverpilot', sprintf(__('An error occurred while trying to get the current list of domains: %s', 'wp-multisite-waas'), json_encode($app_info)), LogLevel::ERROR);
|
||||
// translators: %s is the wp_json_encode of the error.
|
||||
wu_log_add('integration-serverpilot', sprintf(__('An error occurred while trying to get the current list of domains: %s', 'wp-multisite-waas'), wp_json_encode($app_info)), LogLevel::ERROR);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@@ -128,11 +128,10 @@ class CPanel_API {
|
||||
*
|
||||
* @since 1.6.2
|
||||
* @param string $message Message to be logged.
|
||||
* @return boolean
|
||||
*/
|
||||
public function log($message) {
|
||||
|
||||
return wu_log_add('integration-cpanel', $message);
|
||||
wu_log_add('integration-cpanel', $message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,7 +151,7 @@ class CPanel_API {
|
||||
if ( ! file_exists($this->cookie_file)) {
|
||||
try {
|
||||
fopen($this->cookie_file, 'w');
|
||||
} catch (Exception $ex) {
|
||||
} catch (\Exception $ex) {
|
||||
if ( ! file_exists($this->cookie_file)) {
|
||||
$this->log($ex . __('Cookie file missing.', 'wp-multisite-waas'));
|
||||
|
||||
@@ -232,12 +231,11 @@ class CPanel_API {
|
||||
* Signs in on the cPanel.
|
||||
*
|
||||
* @since 1.6.2
|
||||
* @return boolean
|
||||
*/
|
||||
private function sign_in() {
|
||||
|
||||
$url = $this->get_base_url() . '/login/?login_only=1';
|
||||
$url .= '&user=' . $this->username . '&pass=' . urlencode($this->password);
|
||||
$url .= '&user=' . $this->username . '&pass=' . rawurlencode($this->password);
|
||||
|
||||
$reply = $this->request($url);
|
||||
|
||||
@@ -249,7 +247,7 @@ class CPanel_API {
|
||||
$this->homepage = $this->get_base_url() . $reply['redirect'];
|
||||
$this->ex_page = $this->get_base_url() . "/{$this->cpsess}/execute/";
|
||||
} else {
|
||||
return $this->log(__('Cannot connect to your cPanel server : Invalid Credentials', 'wp-multisite-waas'));
|
||||
$this->log(__('Cannot connect to your cPanel server : Invalid Credentials', 'wp-multisite-waas'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,22 +255,22 @@ class CPanel_API {
|
||||
* Executes API calls, taking the request to the right API version
|
||||
*
|
||||
* @since 1.6.2
|
||||
* @throws Exception Throwns exception when the api is invalid.
|
||||
* @throws \Exception Throwns exception when the api is invalid.
|
||||
* @param string $api API version.
|
||||
* @param string $module Module name, to build the endpoint.
|
||||
* @param string $function Endpoint function to call.
|
||||
* @param string $function_name Endpoint function to call.
|
||||
* @param array $parameters Parameters to the API endpoint.
|
||||
* @return boolean
|
||||
*/
|
||||
public function execute($api, $module, $function, array $parameters = []) {
|
||||
public function execute($api, $module, $function_name, array $parameters = []) {
|
||||
|
||||
switch ($api) {
|
||||
case 'api2':
|
||||
return $this->api2($module, $function, $parameters);
|
||||
return $this->api2($module, $function_name, $parameters);
|
||||
case 'uapi':
|
||||
return $this->uapi($module, $function, $parameters);
|
||||
return $this->uapi($module, $function_name, $parameters);
|
||||
default:
|
||||
throw new Exception('Invalid API type : api2 and uapi are accepted', 1);
|
||||
throw new \Exception('Invalid API type : api2 and uapi are accepted', 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,11 +279,11 @@ class CPanel_API {
|
||||
*
|
||||
* @since 1.6.2
|
||||
* @param string $module Module name, to build the endpoint.
|
||||
* @param string $function Endpoint function to call.
|
||||
* @param string $function_name Endpoint function to call.
|
||||
* @param array $parameters Parameters to the API endpoint.
|
||||
* @return mixed
|
||||
*/
|
||||
public function uapi($module, $function, array $parameters = []) {
|
||||
public function uapi($module, $function_name, array $parameters = []) {
|
||||
|
||||
if (count($parameters) < 1) {
|
||||
$parameters = '';
|
||||
@@ -293,7 +291,7 @@ class CPanel_API {
|
||||
$parameters = (http_build_query($parameters));
|
||||
}
|
||||
|
||||
return json_decode((string) $this->request($this->ex_page . $module . '/' . $function . '?' . $parameters));
|
||||
return json_decode((string) $this->request($this->ex_page . $module . '/' . $function_name . '?' . $parameters));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,11 +299,11 @@ class CPanel_API {
|
||||
*
|
||||
* @since 1.6.2
|
||||
* @param string $module Module name, to build the endpoint.
|
||||
* @param string $function Endpoint function to call.
|
||||
* @param string $function_name Endpoint function to call.
|
||||
* @param array $parameters Parameters to the API endpoint.
|
||||
* @return mixed
|
||||
*/
|
||||
public function api2($module, $function, array $parameters = []) {
|
||||
public function api2($module, $function_name, array $parameters = []) {
|
||||
|
||||
if (count($parameters) < 1) {
|
||||
$parameters = '';
|
||||
@@ -314,9 +312,9 @@ class CPanel_API {
|
||||
}
|
||||
|
||||
$url = $this->get_base_url() . $this->cpsess . '/json-api/cpanel' .
|
||||
'?cpanel_jsonapi_version=2' .
|
||||
"&cpanel_jsonapi_func={$function}" .
|
||||
"&cpanel_jsonapi_module={$module}&" . $parameters;
|
||||
'?cpanel_jsonapi_version=2' .
|
||||
"&cpanel_jsonapi_func={$function_name}" .
|
||||
"&cpanel_jsonapi_module={$module}&" . $parameters;
|
||||
|
||||
return json_decode((string) $this->request($url, $parameters));
|
||||
}
|
||||
|
Reference in New Issue
Block a user