Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions inc/functions/currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ function wu_get_currency_symbol($currency = '') {
break;
case 'BYN':
$currency_symbol = 'Br';
break;
case 'CHF':
$currency_symbol = 'CHF';
break;
Expand Down
4 changes: 4 additions & 0 deletions inc/functions/discount-code.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ function wu_get_discount_codes($query = []) {
*/
function wu_get_discounted_price($base_price, $amount, $type, $format = true) {

// Default to the base price so an unknown discount type fails safe to
// "no discount applied" instead of an undefined variable.
$discounted_price = $base_price;

if ('percentage' === $type) {
$discounted_price = $base_price - ($base_price * ($amount / 100));
} elseif ('absolute' === $type) {
Expand Down
2 changes: 1 addition & 1 deletion inc/installers/class-migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@
/*
* Registers a shutdown handler.
*/
// register_shutdown_function(array($this, 'on_shutdown'), $session, $this->dry_run, $installer);

Check warning on line 523 in inc/installers/class-migrator.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

This comment is 73% valid code; is this commented out code?

try {
wp_cache_flush();
Expand Down Expand Up @@ -656,7 +656,7 @@
* @throws Exception Halts the process on error.
* @return mixed
*/
public function _install_dry_run_check(): void {

Check warning on line 659 in inc/installers/class-migrator.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Method name "_install_dry_run_check" should not be prefixed with an underscore to indicate visibility

global $wpdb, $wu_migrator_current_installer;

Expand All @@ -678,7 +678,7 @@
* @throws Exception Halts the process on error.
* @return mixed
*/
public function _install_backup(): void {

Check warning on line 681 in inc/installers/class-migrator.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Method name "_install_backup" should not be prefixed with an underscore to indicate visibility

global $wpdb;

Expand Down Expand Up @@ -754,7 +754,7 @@
* @throws Exception Halts the process on error.
* @return void
*/
protected function _install_settings() {

Check warning on line 757 in inc/installers/class-migrator.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Method name "_install_settings" should not be prefixed with an underscore to indicate visibility

$settings = $this->get_old_settings();

Expand Down Expand Up @@ -977,7 +977,7 @@
* @throws Exception Halts the process on error.
* @return void
*/
protected function _install_products() {

Check warning on line 980 in inc/installers/class-migrator.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Method name "_install_products" should not be prefixed with an underscore to indicate visibility

global $wpdb;

Expand Down Expand Up @@ -1418,7 +1418,7 @@
* @throws Exception Halts the process on error.
* @return void
*/
protected function _install_customers() {

Check warning on line 1421 in inc/installers/class-migrator.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Method name "_install_customers" should not be prefixed with an underscore to indicate visibility

global $wpdb;

Expand Down Expand Up @@ -1488,7 +1488,7 @@
* @throws Exception Halts the process on error.
* @return void
*/
protected function _install_memberships() {

Check warning on line 1491 in inc/installers/class-migrator.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Method name "_install_memberships" should not be prefixed with an underscore to indicate visibility

global $wpdb;

Expand Down Expand Up @@ -1766,7 +1766,7 @@
* @throws Exception Halts the process on error.
* @return void
*/
protected function _install_transactions() {

Check warning on line 1769 in inc/installers/class-migrator.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Method name "_install_transactions" should not be prefixed with an underscore to indicate visibility

global $wpdb;

Expand Down Expand Up @@ -1871,7 +1871,7 @@
'parent' => 0,
'line_items' => $line_items,
'status' => wu_get_isset($map_status, $transaction->type, Payment_Status::COMPLETED),
'customer_id' => $membership ? $customer->get_id() : false,
'customer_id' => ($membership && $customer) ? $customer->get_id() : false,
'membership_id' => $membership ? $membership->get_id() : false,
'product_id' => $membership ? $membership->get_plan_id() : false,
'currency' => $membership ? $membership->get_currency() : false,
Expand Down Expand Up @@ -1914,7 +1914,7 @@
* @throws Exception Halts the process on error.
* @return void
*/
protected function _install_discount_codes() {

Check warning on line 1917 in inc/installers/class-migrator.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Method name "_install_discount_codes" should not be prefixed with an underscore to indicate visibility

global $wpdb;

Expand Down Expand Up @@ -2018,7 +2018,7 @@
* @throws Exception Halts the process on error.
* @return void
*/
protected function _install_sites() {

Check warning on line 2021 in inc/installers/class-migrator.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Method name "_install_sites" should not be prefixed with an underscore to indicate visibility

global $wpdb;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ public function add_cloudflare_dns_entries($dns_records, $domain) {
]
);

foreach ($cloudflare_zones->result as $zone) {
$zone_ids[] = $zone->id;
if ( ! is_wp_error($cloudflare_zones) && ! empty($cloudflare_zones->result) && is_iterable($cloudflare_zones->result) ) {
foreach ($cloudflare_zones->result as $zone) {
$zone_ids[] = $zone->id;
}
}

foreach ($zone_ids as $zone_id) {
Expand Down
2 changes: 1 addition & 1 deletion inc/integrations/host-providers/class-dns-record.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ public static function from_provider(array $data, string $provider): self {
'id' => $data['id'] ?? ($data['type'] . '-' . ($data['name'] ?? '@')),
'type' => $data['type'] ?? 'A',
'name' => $data['name'] ?? '@',
'content' => $data['value'] ?? '',
'content' => $data['content'] ?? $data['value'] ?? '',
'ttl' => (int) ($data['ttl'] ?? 3600),
'priority' => isset($data['priority']) ? (int) $data['priority'] : null,
'proxied' => false,
Expand Down
4 changes: 4 additions & 0 deletions inc/models/class-membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,10 @@ public function get_normalized_amount() {

$duration = $this->get_duration();

if ( ! $duration ) {
return $amount;
}

$normalized_duration_unit = wu_convert_duration_unit_to_month($this->get_duration_unit());

return $amount / $duration * $normalized_duration_unit;
Expand Down
6 changes: 5 additions & 1 deletion inc/models/class-site.php
Original file line number Diff line number Diff line change
Expand Up @@ -2258,7 +2258,7 @@
* @param bool $is_new If this object is a new one.
*/
$profile_stage = microtime(true);
do_action('wu_model_post_save', $this->model, $data, $data_unserialized, $this, $new); // @phpstan-ignore-line

Check warning on line 2261 in inc/models/class-site.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

No error to ignore is reported on line 2261.

/**
* Fires after an object is stored into the database.
Expand Down Expand Up @@ -2378,14 +2378,18 @@

$pending_site = maybe_unserialize($item);

if ( ! $pending_site instanceof self ) {
return null;
}

$pending_site->set_type('pending');

return $pending_site;
},
$results
);

return $results;
return array_values(array_filter($results));
}

$query = $query_args;
Expand Down
4 changes: 4 additions & 0 deletions inc/sso/class-magic-link.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ public function generate_magic_link($user_id, $site_id, $redirect_to = '') {

$site = wu_get_site($site_id);

if ( ! $site ) {
return false;
}

// Build the magic link URL.
$site_url = $site->get_active_site_url();

Expand Down
Loading