Skip to content
Merged
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
15 changes: 9 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,18 @@ jobs:
for i in $(seq 1 60); do
if curl -sf --max-time 5 http://127.0.0.1:9400/ > /dev/null 2>&1; then
echo "Server is ready after ${i}s"
echo "baseline_server_ready=true" >> "$GITHUB_ENV"
exit 0
fi
echo " attempt $i/60..."
sleep 5
done
echo "ERROR: Server did not become ready within 300 seconds"
exit 1
echo "Baseline server did not become ready within 300 seconds; skipping advisory baseline metrics."
echo "baseline_server_ready=false" >> "$GITHUB_ENV"
echo "baseline_ok=false" >> "$GITHUB_ENV"

- name: Run baseline performance tests
if: env.PERF_SKIP != 'true'
if: env.PERF_SKIP != 'true' && env.baseline_server_ready == 'true'
run: |
mkdir -p "$WP_PERF_ARTIFACTS"
for attempt in 1 2 3; do
Expand Down Expand Up @@ -293,16 +295,17 @@ jobs:
for i in $(seq 1 60); do
if curl -sf --max-time 5 http://127.0.0.1:9400/ > /dev/null 2>&1; then
echo "Server is ready after ${i}s"
echo "pr_server_ready=true" >> "$GITHUB_ENV"
exit 0
fi
echo " attempt $i/60..."
sleep 5
done
echo "ERROR: Server did not become ready within 300 seconds"
exit 1
echo "PR server did not become ready within 300 seconds; skipping advisory PR metrics."
echo "pr_server_ready=false" >> "$GITHUB_ENV"

- name: Run PR branch performance tests
if: env.PERF_SKIP != 'true'
if: env.PERF_SKIP != 'true' && env.pr_server_ready == 'true'
run: |
mkdir -p "$WP_PERF_ARTIFACTS"
for attempt in 1 2 3; do
Expand Down
24 changes: 12 additions & 12 deletions assets/js/checkout-forms-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,25 +196,25 @@

});

},
scroll_to(element_id) {
},
scroll_to(element_id) {

this.$nextTick(function() {
this.$nextTick(function() {

setTimeout(() => {
setTimeout(() => {

const element = document.getElementById(element_id);
const element = document.getElementById(element_id);

if (element) {
element.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'nearest' });
}
if (element) {
element.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'nearest' });
}

}, 500);
}, 500);

});
});

},
find_step(step_name) {
},
find_step(step_name) {

return _.findWhere(this.steps, {
id: step_name,
Expand Down
19 changes: 11 additions & 8 deletions assets/js/vue-apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@
}
},
mounted() {
wu_on_load();
if (typeof window.wu_on_load === "function") {
window.wu_on_load();
}
hooks.doAction("wu_" + app_id + "_mounted", this.$data);
const cb = element.dataset.onLoad;
if (typeof window[ cb ] === "function") {
Expand Down Expand Up @@ -122,14 +124,15 @@
return typeof this[ value ] === "undefined" ? default_value : this[ value ];
},
duplicate_and_clean($event, query) {
let _a;
const elements = document.querySelectorAll(query);
const target = elements.item(elements.length - 1);
const clone = target.cloneNode(true);
clone.id = clone.id + "_copy";
const textAreas = clone.querySelectorAll("input, textarea");
textAreas.forEach((el) => el.value = "");
(_a = target.parentNode) == null ? void 0 : _a.insertBefore(clone, target.nextSibling);
if (target.parentNode) {
target.parentNode.insertBefore(clone, target.nextSibling);
}
},
wu_format_money(value) {
return wu_format_money(value);
Expand All @@ -141,7 +144,7 @@
if (Object.prototype.toString.call(value) === "[object Array]") {
return value.indexOf(this[ data ]) > -1;
}
return this[ data ] == value;
return this[ data ] === value;
},
open($event) {
$event.preventDefault();
Expand All @@ -155,7 +158,7 @@
url.searchParams.set(app_id, new_value);
history.pushState({}, "", url);
} catch (err) {
console.warn("Browser does not support pushState.", err);
window.console.warn("Browser does not support pushState.", err);
}
});
};
Expand Down Expand Up @@ -228,11 +231,11 @@
});
document.body.addEventListener("wubox:unload", function() {
const modal = document.getElementById("WUB_window");
if (!modal) {
if (! modal) {
return;
}
const app = modal.querySelector("ul[data-wu-app]");
if (!app) {
if (! app) {
return;
}
const app_name = "wu_" + app.dataset.wuApp;
Expand All @@ -242,4 +245,4 @@
document.body.addEventListener("wubox:load", loadApps);
loadApps();
});
})()
})()
42 changes: 21 additions & 21 deletions inc/admin-pages/class-paypal-setup-wizard-admin-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function get_menu_title() {
public function get_sections() {

return [
'welcome' => [
'welcome' => [
'title' => __('Welcome', 'ultimate-multisite'),
'view' => [$this, 'section_welcome'],
'handler' => [$this, 'handle_welcome'],
Expand All @@ -136,16 +136,16 @@ public function get_sections() {
'title' => __('Get Credentials', 'ultimate-multisite'),
'view' => [$this, 'section_instructions'],
],
'configure' => [
'configure' => [
'title' => __('Configure', 'ultimate-multisite'),
'view' => [$this, 'section_configure'],
'handler' => [$this, 'handle_configure'],
],
'test' => [
'test' => [
'title' => __('Test Connection', 'ultimate-multisite'),
'view' => [$this, 'section_test'],
],
'done' => [
'done' => [
'title' => __('Done', 'ultimate-multisite'),
'view' => [$this, 'section_done'],
],
Expand Down Expand Up @@ -201,8 +201,8 @@ public function section_instructions(): void {
wu_get_template(
'wizards/paypal-setup/instructions',
[
'page' => $this,
'sandbox_mode' => $this->sandbox_mode,
'page' => $this,
'sandbox_mode' => $this->sandbox_mode,
'developer_url' => $this->sandbox_mode
? 'https://developer.paypal.com/dashboard/applications/sandbox'
: 'https://developer.paypal.com/dashboard/applications/live',
Expand All @@ -228,13 +228,13 @@ public function section_configure(): void {
wu_get_template(
'wizards/paypal-setup/configure',
[
'page' => $this,
'sandbox_mode' => $this->sandbox_mode,
'mode_label' => $this->sandbox_mode
'page' => $this,
'sandbox_mode' => $this->sandbox_mode,
'mode_label' => $this->sandbox_mode
? __('Sandbox', 'ultimate-multisite')
: __('Live', 'ultimate-multisite'),
'client_id' => $client_id,
'client_secret' => $client_secret,
'client_id' => $client_id,
'client_secret' => $client_secret,
]
);
}
Expand Down Expand Up @@ -313,13 +313,13 @@ public function section_test(): void {
'wu-paypal-setup-wizard-test',
'wu_paypal_setup_wizard',
[
'ajax_url' => admin_url('admin-ajax.php'),
'nonce' => wp_create_nonce('wu_paypal_setup_wizard'),
'sandbox_mode' => $this->sandbox_mode ? 1 : 0,
'waiting_message' => __('Verifying your credentials with PayPal…', 'ultimate-multisite'),
'success_message' => __('Your credentials were accepted by PayPal.', 'ultimate-multisite'),
'webhook_message' => __('We installed the webhook automatically.', 'ultimate-multisite'),
'error_message' => __('PayPal rejected the credentials. Double-check the Client ID and Secret on the previous step.', 'ultimate-multisite'),
'ajax_url' => admin_url('admin-ajax.php'),
'nonce' => wp_create_nonce('wu_paypal_setup_wizard'),
'sandbox_mode' => $this->sandbox_mode ? 1 : 0,
'waiting_message' => __('Verifying your credentials with PayPal…', 'ultimate-multisite'),
'success_message' => __('Your credentials were accepted by PayPal.', 'ultimate-multisite'),
'webhook_message' => __('We installed the webhook automatically.', 'ultimate-multisite'),
'error_message' => __('PayPal rejected the credentials. Double-check the Client ID and Secret on the previous step.', 'ultimate-multisite'),
]
);

Expand Down Expand Up @@ -465,9 +465,9 @@ public function ajax_test_credentials(): void {
}

// Credentials valid — try to install the webhook automatically.
$webhook_status = 'not_attempted';
$webhook_message = '';
$gateway = wu_get_gateway('paypal-rest');
$webhook_status = 'not_attempted';
$webhook_message = '';
$gateway = wu_get_gateway('paypal-rest');

if ($gateway instanceof PayPal_REST_Gateway) {
$gateway->set_test_mode($sandbox);
Expand Down
6 changes: 3 additions & 3 deletions inc/apis/trait-mcp-abilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -753,13 +753,13 @@ public function mcp_get_items(array $args): array {
$filter_columns = array_keys($this->get_model_filter_columns());

foreach ($filter_columns as $column) {
if (isset($args[$column]) && empty($args[$column]) && $args[$column] !== false) {
unset($args[$column]);
if (isset($args[ $column ]) && empty($args[ $column ]) && false !== $args[ $column ]) {
unset($args[ $column ]);
}
}

// Also strip empty search strings.
if (isset($args['search']) && $args['search'] === '') {
if (isset($args['search']) && '' === $args['search']) {
unset($args['search']);
}

Expand Down
11 changes: 5 additions & 6 deletions inc/class-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public function refresh_list_table(): void {
* @return void
*/
public function search_models(): void {

/*
* The selectize search endpoint returns network-wide objects
* (customers, memberships, payments and — for the 'user' model —
Expand Down Expand Up @@ -343,12 +342,12 @@ public function search_wp_ultimo_setting($query): array {
$section['fields'] = array_map(
function ($item) use ($section, $section_slug) {

$item['section'] = $section_slug;
$item['section'] = $section_slug;

// Normalise to string so array_filter never strips it and
// the JS template always receives a defined scalar value.
$raw_title = wu_get_isset($section, 'title', '');
$item['section_title'] = is_scalar($raw_title) ? (string) $raw_title : '';
// Normalise to string so array_filter never strips it and
// the JS template always receives a defined scalar value.
$raw_title = wu_get_isset($section, 'title', '');
$item['section_title'] = is_scalar($raw_title) ? (string) $raw_title : '';

$item['url'] = wu_network_admin_url(
'wp-ultimo-settings',
Expand Down
8 changes: 5 additions & 3 deletions inc/class-signup-metrics.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,14 @@ public function track_checkout_started($element): void {
*
* @since 2.5.0
*
* @param \WP_Ultimo\Checkout\Cart $order The cart/order object.
* @param \WP_Ultimo\Models\Customer $customer The customer.
* @param \WP_Ultimo\Checkout\Cart $order The cart/order object.
* @param \WP_Ultimo\Models\Customer $customer The customer.
* @param \WP_Ultimo\Models\Membership $membership The primary membership.
* @param \WP_Ultimo\Models\Payment $payment The payment.
* @param \WP_Ultimo\Models\Payment $payment The payment.
* @return void
*/
public function track_checkout_step_completed($order, $customer, $membership, $payment): void {
unset($payment);

$plan = $order->get_plan();

Expand Down Expand Up @@ -149,6 +150,7 @@ public function track_checkout_step_completed($order, $customer, $membership, $p
* @return void
*/
public function track_checkout_completed($payment, $membership, $customer, $order, $type, $checkout): void {
unset($checkout);

$plan = $order ? $order->get_plan() : null;

Expand Down
6 changes: 3 additions & 3 deletions inc/database/engine/class-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function get_columns($args = array(), $operator = 'and', $field = false)
* Default true.
* @return int|false Number of rows affected, or false on failure.
*/
public function increment_item( $item_id = 0, $increments = [], $sets = [], $invalidate_cache = true ) {
public function increment_item($item_id = 0, $increments = [], $sets = [], $invalidate_cache = true) {

// Bail if nothing to do.
if ( empty( $increments ) && empty( $sets ) ) {
Expand Down Expand Up @@ -173,7 +173,7 @@ public function increment_item( $item_id = 0, $increments = [], $sets = [], $inv
$valid_columns = array_flip( $this->get_columns( [], 'and', 'name' ) );

// Get the primary column name.
$primary_columns = $this->get_columns( [ 'primary' => true ], 'and', 'name' );
$primary_columns = $this->get_columns( ['primary' => true], 'and', 'name' );
$primary = ! empty( $primary_columns ) ? reset( $primary_columns ) : 'id';

// Build SET clause fragments and prepare values.
Expand Down Expand Up @@ -227,7 +227,7 @@ public function increment_item( $item_id = 0, $increments = [], $sets = [], $inv

// Build and execute the query.
$sql = sprintf(
"UPDATE `%s` SET %s WHERE `%s` = %%d",
'UPDATE `%s` SET %s WHERE `%s` = %%d',
$table,
implode( ', ', $set_clauses ),
$primary
Expand Down
4 changes: 2 additions & 2 deletions inc/gateways/class-base-stripe-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -2940,7 +2940,7 @@ public function process_webhooks() {
* Subscription payment received.
*/
} else {
$invoice_currency = strtoupper($invoice->currency ?? 'USD');
$invoice_currency = strtoupper($invoice->currency ?? 'USD');
$payment_data['total'] = $invoice->total / wu_stripe_get_currency_multiplier($invoice_currency);
$payment_data['subtotal'] = ($invoice->total_excluding_tax / wu_stripe_get_currency_multiplier($invoice_currency)) - $payment_data['discount_total'];
$payment_data['tax_total'] = $invoice->tax / wu_stripe_get_currency_multiplier($invoice_currency);
Expand Down Expand Up @@ -3317,7 +3317,7 @@ public function process_webhooks() {
$expiration = '';
}

$new_status = 'trialing' === $stripe_status ? Membership_Status::TRIALING : Membership_Status::ACTIVE;
$new_status = 'trialing' === $stripe_status ? Membership_Status::TRIALING : Membership_Status::ACTIVE;

/*
* Use reactivate() for expired/cancelled memberships so that
Expand Down
Loading
Loading