Prep Plugin for release on WordPress.org (#23)

* Update translation text domain
* 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.
* Add Proper Build script
* Use emojii flags
* Fix i18n deprecation  notice for translating too early
* Put all scripts in footer and load async
This commit is contained in:
David Stone
2025-04-14 11:36:46 -06:00
committed by GitHub
parent a31cfcb565
commit d88e50df38
1087 changed files with 12586 additions and 18535 deletions

View File

@ -502,7 +502,7 @@ class Cart implements \JsonSerializable {
return $this->cart_descriptor;
}
$desc = wu_get_setting('company_name', __('Subscription', 'wp-ultimo'));
$desc = wu_get_setting('company_name', get_network_option(null, 'site_name'));
$products = [];
@ -556,7 +556,7 @@ class Cart implements \JsonSerializable {
$payment = wu_get_payment($payment_id);
if ( ! $payment) {
$this->errors->add('payment_not_found', __('The payment in question was not found.', 'wp-ultimo'));
$this->errors->add('payment_not_found', __('The payment in question was not found.', 'wp-multisite-waas'));
return true;
}
@ -583,7 +583,7 @@ class Cart implements \JsonSerializable {
* a payment can pay it. Let's check for that.
*/
if (empty($this->customer) || $this->customer->get_id() !== $payment->get_customer_id()) {
$this->errors->add('lacks_permission', __('You are not allowed to modify this payment.', 'wp-ultimo'));
$this->errors->add('lacks_permission', __('You are not allowed to modify this payment.', 'wp-multisite-waas'));
return true;
}
@ -594,7 +594,7 @@ class Cart implements \JsonSerializable {
$membership = $payment->get_membership();
if ( ! $membership) {
$this->errors->add('membership_not_found', __('The membership in question was not found.', 'wp-ultimo'));
$this->errors->add('membership_not_found', __('The membership in question was not found.', 'wp-multisite-waas'));
return true;
}
@ -683,7 +683,7 @@ class Cart implements \JsonSerializable {
);
if ( ! in_array($payment->get_status(), $allowed_status, true)) {
$this->errors->add('invalid_status', __('The payment in question has an invalid status.', 'wp-ultimo'));
$this->errors->add('invalid_status', __('The payment in question has an invalid status.', 'wp-multisite-waas'));
return true;
}
@ -742,7 +742,7 @@ class Cart implements \JsonSerializable {
$membership = wu_get_membership($membership_id);
if ( ! $membership) {
$this->errors->add('membership_not_found', __('The membership in question was not found.', 'wp-ultimo'));
$this->errors->add('membership_not_found', __('The membership in question was not found.', 'wp-multisite-waas'));
return true;
}
@ -762,7 +762,7 @@ class Cart implements \JsonSerializable {
* Only the customer that owns a membership can change it.
*/
if (empty($this->customer) || $this->customer->get_id() !== $membership->get_customer_id()) {
$this->errors->add('lacks_permission', __('You are not allowed to modify this membership.', 'wp-ultimo'));
$this->errors->add('lacks_permission', __('You are not allowed to modify this membership.', 'wp-multisite-waas'));
return true;
}
@ -794,7 +794,7 @@ class Cart implements \JsonSerializable {
return false;
}
$this->errors->add('no_changes', __('This cart proposes no changes to the current membership.', 'wp-ultimo'));
$this->errors->add('no_changes', __('This cart proposes no changes to the current membership.', 'wp-multisite-waas'));
return true;
}
@ -816,7 +816,7 @@ class Cart implements \JsonSerializable {
*/
if (empty($this->plan_id)) {
if (count($this->products) === 0) {
$this->errors->add('no_changes', __('This cart proposes no changes to the current membership.', 'wp-ultimo'));
$this->errors->add('no_changes', __('This cart proposes no changes to the current membership.', 'wp-multisite-waas'));
return true;
}
@ -938,7 +938,7 @@ class Cart implements \JsonSerializable {
$this->products = [];
$this->line_items = [];
$this->errors->add('no_changes', __('This cart proposes no changes to the current membership.', 'wp-ultimo'));
$this->errors->add('no_changes', __('This cart proposes no changes to the current membership.', 'wp-multisite-waas'));
return true;
}
@ -1000,13 +1000,13 @@ class Cart implements \JsonSerializable {
$description = sprintf(
// translators: %1$s the duration, and %2$s the duration unit (day, week, month, etc)
_n('%2$s', '%1$s %2$s', $membership->get_duration(), 'wp-ultimo'), // phpcs:ignore
_n('%2$s', '%1$s %2$s', $membership->get_duration(), 'wp-multisite-waas'), // phpcs:ignore
$membership->get_duration(),
wu_get_translatable_string(($membership->get_duration() <= 1 ? $membership->get_duration_unit() : $membership->get_duration_unit() . 's'))
);
// Translators: Placeholder receives the recurring period description
$message = sprintf(__('You already have an active %s agreement.', 'wp-ultimo'), $description);
$message = sprintf(__('You already have an active %s agreement.', 'wp-multisite-waas'), $description);
$this->errors->add('no_changes', $message);
@ -1027,8 +1027,8 @@ class Cart implements \JsonSerializable {
'wu_checkout_credit_line_item_params',
[
'type' => 'credit',
'title' => __('Scheduled Swap Credit', 'wp-ultimo'),
'description' => __('Swap scheduled to next billing cycle.', 'wp-ultimo'),
'title' => __('Scheduled Swap Credit', 'wp-multisite-waas'),
'description' => __('Swap scheduled to next billing cycle.', 'wp-multisite-waas'),
'discountable' => false,
'taxable' => false,
'quantity' => 1,
@ -1222,8 +1222,8 @@ class Cart implements \JsonSerializable {
'wu_checkout_credit_line_item_params',
[
'type' => 'credit',
'title' => __('Credit', 'wp-ultimo'),
'description' => __('Prorated amount based on the previous membership.', 'wp-ultimo'),
'title' => __('Credit', 'wp-multisite-waas'),
'description' => __('Prorated amount based on the previous membership.', 'wp-multisite-waas'),
'discountable' => false,
'taxable' => false,
'quantity' => 1,
@ -1259,7 +1259,7 @@ class Cart implements \JsonSerializable {
if (empty($discount_code)) {
// translators: %s is the coupon code being used, all-caps. e.g. PROMO10OFF
$this->errors->add('discount_code', sprintf(__('The code %s do not exist or is no longer valid.', 'wp-ultimo'), $code));
$this->errors->add('discount_code', sprintf(__('The code %s do not exist or is no longer valid.', 'wp-multisite-waas'), $code));
return false;
}
@ -1340,7 +1340,7 @@ class Cart implements \JsonSerializable {
if ($line_item_interval !== $interval) {
// translators: two intervals
$this->errors->add('wrong', sprintf(__('Interval %1$s and %2$s do not match.', 'wp-ultimo'), $line_item_interval, $interval));
$this->errors->add('wrong', sprintf(__('Interval %1$s and %2$s do not match.', 'wp-multisite-waas'), $line_item_interval, $interval));
return false;
}
@ -1503,7 +1503,7 @@ class Cart implements \JsonSerializable {
$product = is_numeric($product_id_or_slug) ? wu_get_product($product_id_or_slug) : wu_get_product_by_slug($product_id_or_slug);
if ( ! $product) {
$message = __('The product you are trying to add does not exist.', 'wp-ultimo');
$message = __('The product you are trying to add does not exist.', 'wp-multisite-waas');
$this->errors->add('missing-product', $message);
@ -1515,7 +1515,7 @@ class Cart implements \JsonSerializable {
$product = $product->get_as_variation($this->duration, $this->duration_unit);
if ( ! $product) {
$message = __('The product you are trying to add does not exist for the selected duration.', 'wp-ultimo');
$message = __('The product you are trying to add does not exist for the selected duration.', 'wp-multisite-waas');
$this->errors->add('missing-price-variations', $message);
@ -1529,7 +1529,7 @@ class Cart implements \JsonSerializable {
* another one. Bail.
*/
if ( ! empty($this->plan_id)) {
$message = __('Theres already a plan in this membership.', 'wp-ultimo');
$message = __('Theres already a plan in this membership.', 'wp-multisite-waas');
$this->errors->add('plan-already-added', $message);
@ -1591,7 +1591,7 @@ class Cart implements \JsonSerializable {
* price variation. We need to add an error.
*/
// translators: respectively, product name, duration, and duration unit.
$message = sprintf(__('%1$s does not have a valid price variation for that billing period (every %2$s %3$s(s)) and was not added to the cart.', 'wp-ultimo'), $product->get_name(), $this->duration, $this->duration_unit);
$message = sprintf(__('%1$s does not have a valid price variation for that billing period (every %2$s %3$s(s)) and was not added to the cart.', 'wp-multisite-waas'), $product->get_name(), $this->duration, $this->duration_unit);
$this->errors->add('missing-price-variations', $message);
@ -1655,7 +1655,7 @@ class Cart implements \JsonSerializable {
}
// translators: placeholder is the product name.
$description = ($product->get_setup_fee() > 0) ? __('Signup Fee for %s', 'wp-ultimo') : __('Signup Credit for %s', 'wp-ultimo');
$description = ($product->get_setup_fee() > 0) ? __('Signup Fee for %s', 'wp-multisite-waas') : __('Signup Credit for %s', 'wp-multisite-waas');
$description = sprintf($description, $product->get_name());
@ -1830,7 +1830,7 @@ class Cart implements \JsonSerializable {
$where_clauses[] = ['type', $type];
// Cast to array recursively
$line_items = json_decode(json_encode($this->line_items), true);
$line_items = json_decode(wp_json_encode($this->line_items), true);
$line_items = Array_Search::find(
$line_items,
@ -2353,7 +2353,7 @@ class Cart implements \JsonSerializable {
*/
public function jsonSerialize(): string {
return json_encode($this->done());
return wp_json_encode($this->done());
}
/**