Prep Plugin for release on WordPress.org ()

* 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
.phpcs.xml.dist
assets
css
img
flags
1x1
ad.svgae.svgaf.svgag.svgai.svgal.svgam.svgao.svgaq.svgar.svgas.svgat.svgau.svgaw.svgax.svgaz.svgba.svgbb.svgbd.svgbe.svgbf.svgbg.svgbh.svgbi.svgbj.svgbl.svgbm.svgbn.svgbo.svgbq.svgbr.svgbs.svgbt.svgbv.svgbw.svgby.svgbz.svgca.svgcc.svgcd.svgcf.svgcg.svgch.svgci.svgck.svgcl.svgcm.svgcn.svgco.svgcr.svgcu.svgcv.svgcw.svgcx.svgcy.svgcz.svgde.svgdj.svgdk.svgdm.svgdo.svgdz.svgec.svgee.svgeg.svgeh.svger.svges-ca.svges-ga.svges.svget.svgeu.svgfi.svgfj.svgfk.svgfm.svgfo.svgfr.svgga.svggb-eng.svggb-nir.svggb-sct.svggb-wls.svggb.svggd.svgge.svggf.svggg.svggh.svggi.svggl.svggm.svggn.svggp.svggq.svggr.svggs.svggt.svggu.svggw.svggy.svghk.svghm.svghn.svghr.svght.svghu.svgid.svgie.svgil.svgim.svgin.svgio.svgiq.svgir.svgis.svgit.svgje.svgjm.svgjo.svgjp.svgke.svgkg.svgkh.svgki.svgkm.svgkn.svgkp.svgkr.svgkw.svgky.svgkz.svgla.svglb.svglc.svgli.svglk.svglr.svgls.svglt.svglu.svglv.svgly.svgma.svgmc.svgmd.svgme.svgmf.svgmg.svgmh.svgmk.svgml.svgmm.svgmn.svgmo.svgmp.svgmq.svgmr.svgms.svgmt.svgmu.svgmv.svgmw.svgmx.svgmy.svgmz.svgna.svgnc.svgne.svgnf.svgng.svgni.svgnl.svgno.svgnp.svgnr.svgnu.svgnz.svgom.svgpa.svgpe.svgpf.svgpg.svgph.svgpk.svgpl.svgpm.svgpn.svgpr.svgps.svgpt.svgpw.svgpy.svgqa.svgre.svgro.svgrs.svgru.svgrw.svgsa.svgsb.svgsc.svgsd.svgse.svgsg.svgsh.svgsi.svgsj.svgsk.svgsl.svgsm.svgsn.svgso.svgsr.svgss.svgst.svgsv.svgsx.svgsy.svgsz.svgtc.svgtd.svgtf.svgtg.svgth.svgtj.svgtk.svgtl.svgtm.svgtn.svgto.svgtr.svgtt.svgtv.svgtw.svgtz.svgua.svgug.svgum.svgun.svgus.svguy.svguz.svgva.svgvc.svgve.svgvg.svgvi.svgvn.svgvu.svgwf.svgws.svgxk.svgye.svgyt.svgza.svgzm.svgzw.svg
4x3
ad.svgae.svgaf.svgag.svgai.svgal.svgam.svgao.svgaq.svgar.svgas.svgat.svgau.svgaw.svgax.svgaz.svgba.svgbb.svgbd.svgbe.svgbf.svgbg.svgbh.svgbi.svgbj.svgbl.svgbm.svgbn.svgbo.svgbq.svgbr.svgbs.svgbt.svgbv.svgbw.svgby.svgbz.svgca.svgcc.svgcd.svgcf.svgcg.svgch.svgci.svgck.svgcl.svgcm.svgcn.svgco.svgcr.svgcu.svgcv.svgcw.svgcx.svgcy.svgcz.svgde.svgdj.svgdk.svgdm.svgdo.svgdz.svgec.svgee.svgeg.svgeh.svger.svges-ca.svges-ga.svges.svget.svgeu.svgfi.svgfj.svgfk.svgfm.svgfo.svgfr.svgga.svggb-eng.svggb-nir.svggb-sct.svggb-wls.svggb.svggd.svgge.svggf.svggg.svggh.svggi.svggl.svggm.svggn.svggp.svggq.svggr.svggs.svggt.svggu.svggw.svggy.svghk.svghm.svghn.svghr.svght.svghu.svgid.svgie.svgil.svgim.svgin.svgio.svgiq.svgir.svgis.svgit.svgje.svgjm.svgjo.svgjp.svgke.svgkg.svgkh.svgki.svgkm.svgkn.svgkp.svgkr.svgkw.svgky.svgkz.svgla.svglb.svglc.svgli.svglk.svglr.svgls.svglt.svglu.svglv.svgly.svgma.svgmc.svgmd.svgme.svgmf.svgmg.svgmh.svgmk.svgml.svgmm.svgmn.svgmo.svgmp.svgmq.svgmr.svgms.svgmt.svgmu.svgmv.svgmw.svgmx.svgmy.svgmz.svgna.svgnc.svgne.svgnf.svgng.svgni.svgnl.svgno.svgnp.svgnr.svgnu.svgnz.svgom.svgpa.svgpe.svgpf.svgpg.svgph.svgpk.svgpl.svgpm.svgpn.svgpr.svgps.svgpt.svgpw.svgpy.svgqa.svgre.svgro.svgrs.svgru.svgrw.svgsa.svgsb.svgsc.svgsd.svgse.svgsg.svgsh.svgsi.svgsj.svgsk.svgsl.svgsm.svgsn.svgso.svgsr.svgss.svgst.svgsv.svgsx.svgsy.svgsz.svgtc.svgtd.svgtf.svgtg.svgth.svgtj.svgtk.svgtl.svgtm.svgtn.svgto.svgtr.svgtt.svgtv.svgtw.svgtz.svgua.svgug.svgum.svgun.svgus.svguy.svguz.svgva.svgvc.svgve.svgvg.svgvi.svgvn.svgvu.svgwf.svgws.svgxk.svgye.svgyt.svgza.svgzm.svgzw.svg
logo.pnglogo.webp
js
composer.jsoncomposer.lock
data
inc
admin-pages
class-about-admin-page.phpclass-base-admin-page.phpclass-base-customer-facing-admin-page.phpclass-broadcast-edit-admin-page.phpclass-broadcast-list-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-discount-code-list-admin-page.phpclass-domain-edit-admin-page.phpclass-domain-list-admin-page.phpclass-edit-admin-page.phpclass-email-edit-admin-page.phpclass-email-list-admin-page.phpclass-email-template-customize-admin-page.phpclass-event-list-admin-page.phpclass-event-view-admin-page.phpclass-hosting-integration-wizard-admin-page.phpclass-invoice-template-customize-admin-page.phpclass-jobs-list-admin-page.phpclass-list-admin-page.phpclass-membership-edit-admin-page.phpclass-membership-list-admin-page.phpclass-migration-alert-admin-page.phpclass-payment-edit-admin-page.phpclass-payment-list-admin-page.phpclass-placeholders-admin-page.phpclass-product-edit-admin-page.phpclass-product-list-admin-page.phpclass-settings-admin-page.phpclass-setup-wizard-admin-page.phpclass-shortcodes-admin-page.phpclass-site-edit-admin-page.phpclass-site-list-admin-page.phpclass-system-info-admin-page.phpclass-tax-rates-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
customer-panel
debug
api
builders
checkout
class-cart.phpclass-checkout-pages.phpclass-checkout.phpclass-legacy-checkout.phpclass-line-item.php
signup-fields
class-admin-notices.phpclass-ajax.phpclass-api.phpclass-async-calls.phpclass-dashboard-widgets.phpclass-domain-mapping.phpclass-faker.phpclass-helper.phpclass-hooks.phpclass-light-ajax.phpclass-logger.phpclass-maintenance-mode.phpclass-newsletter.phpclass-requirements.phpclass-scripts.phpclass-session-cookie.phpclass-settings.phpclass-sunrise.phpclass-user-switching.phpclass-views.phpclass-whitelabel.phpclass-wp-ultimo.php
compat
country
database
debug
deprecated
development
domain-mapping
duplication
functions
gateways
helpers
installers
integrations
internal
invoices
limitations
limits
list-tables
managers
models
objects
site-templates
sso
tax
traits
ui
lang
loco.xmlpackage-lock.jsonpackage.jsonphpstan.neon.distsetuptest.shsunrise.php
tests/Admin_Pages
utils/rector
views
about.phpadmin-notices.php
admin-pages
base
broadcast
checkout
customers
dashboard-statistics
dashboard-widgets
domain
email
emails
events
invoice
legacy
limitations
memberships
payments
settings
shortcodes
sites
system-info
taxes
ui
wizards
wp-multisite-waas.php

@@ -9,6 +9,8 @@
namespace WP_Ultimo\Models;
use stdClass;
use WP_Ultimo\Database\Engine\Schema;
use WP_Ultimo\Helpers\Hash;
// Exit if accessed directly
@@ -132,22 +134,21 @@ abstract class Base_Model implements \JsonSerializable {
* Constructs the object via the constructor arguments
*
* @since 2.0.0
*
* @param mixed $object Std object with model parameters.
* @param mixed $object_model Std object with model parameters.
*/
public function __construct($object = null) {
public function __construct($object_model = null) {
$this->model = sanitize_key((new \ReflectionClass($this))->getShortName());
if (is_array($object)) {
$object = (object) $object;
if (is_array($object_model)) {
$object_model = (object) $object_model;
}
if ( ! is_object($object)) {
if ( ! is_object($object_model)) {
return;
}
$this->setup_model($object);
$this->setup_model($object_model);
}
/**
@@ -182,7 +183,7 @@ abstract class Base_Model implements \JsonSerializable {
$value = call_user_func([$this, "get_{$field}"]);
if ( ! is_numeric($value)) {
_doing_it_wrong(__METHOD__, __('You can only use numeric fields to generate hashes.', 'wp-ultimo'), '2.0.0');
_doing_it_wrong(__METHOD__, esc_html__('You can only use numeric fields to generate hashes.', 'wp-multisite-waas'), '2.0.0');
return false;
}
@@ -193,22 +194,21 @@ abstract class Base_Model implements \JsonSerializable {
/**
* Setup properties.
*
* @param object $object Row from the database.
* @param object $object_model Row from the database.
*
* @access private
* @since 2.0.0
* @return bool
*/
private function setup_model($object) {
private function setup_model($object_model) {
if ( ! is_object($object)) {
if ( ! is_object($object_model)) {
return false;
}
$vars = get_object_vars($object);
$vars = get_object_vars($object_model);
$this->attributes($vars);
return !empty($this->id);
return ! empty($this->id);
}
/**
@@ -256,6 +256,7 @@ abstract class Base_Model implements \JsonSerializable {
*
* @since 2.0.0
* @return Schema
* @throws \ReflectionException
*/
public static function get_schema() {
@@ -607,7 +608,7 @@ abstract class Base_Model implements \JsonSerializable {
public function delete() {
if ( ! $this->get_id()) {
return new \WP_Error("wu_{$this->model}_delete_unsaved_item", __('Item not found.', 'wp-ultimo'));
return new \WP_Error("wu_{$this->model}_delete_unsaved_item", __('Item not found.', 'wp-multisite-waas'));
}
/**
@@ -681,13 +682,13 @@ abstract class Base_Model implements \JsonSerializable {
if ( ! $this->get_meta_table_name()) {
// _doing_it_wrong(__METHOD__, __('This model does not support metadata.', 'wp-ultimo'), '2.0.0');
// _doing_it_wrong(__METHOD__, __('This model does not support metadata.', 'wp-multisite-waas'), '2.0.0');
return false;
}
// _doing_it_wrong(__METHOD__, __('Model metadata only works for already saved models.', 'wp-ultimo'), '2.0.0');
return !(! $this->get_id() && ! $this->_mocked);
// _doing_it_wrong(__METHOD__, __('Model metadata only works for already saved models.', 'wp-multisite-waas'), '2.0.0');
return ! (! $this->get_id() && ! $this->_mocked);
}
/**
@@ -696,14 +697,14 @@ abstract class Base_Model implements \JsonSerializable {
* @since 2.0.0
*
* @param string $key The meta key.
* @param mixed $default The default value to be passed.
* @param mixed $default_value The default value to be passed.
* @param bool $single To return single values or not.
* @return mixed
*/
public function get_meta($key, $default = false, $single = true) {
public function get_meta($key, $default_value = false, $single = true) {
if ( ! $this->is_meta_available()) {
return $default;
return $default_value;
}
$meta_type = $this->get_meta_type_name();
@@ -712,7 +713,7 @@ abstract class Base_Model implements \JsonSerializable {
return get_metadata($meta_type, $this->get_id(), $key, $single);
}
return $default;
return $default_value;
}
/**
@@ -730,7 +731,7 @@ abstract class Base_Model implements \JsonSerializable {
}
if ( ! is_array($meta)) {
_doing_it_wrong(__METHOD__, __('This method expects an array as argument.', 'wp-ultimo'), '2.0.0');
_doing_it_wrong(__METHOD__, esc_html__('This method expects an array as argument.', 'wp-multisite-waas'), '2.0.0');
return false;
}
@@ -838,7 +839,7 @@ abstract class Base_Model implements \JsonSerializable {
* Allows use as a callback, such as in `array_map`
*
* @param stdClass $data Raw mapping data.
* @return Mapping
* @return Base_model
*/
protected static function to_instance($data) {
@@ -1038,7 +1039,7 @@ abstract class Base_Model implements \JsonSerializable {
* Creates a copy of the given model adn resets it's id to a 'new' state.
*
* @since 2.0.0
* @return \WP_Ultimo\Model\Base_Model
* @return Base_Model
*/
public function duplicate() {

@@ -82,17 +82,17 @@ class Broadcast extends Post_Base_Model {
*
* @since 2.0.7
*
* @param mixed $object Std object with model parameters.
* @param mixed $object_model Std object with model parameters.
*/
public function __construct($object = null) {
public function __construct($object_model = null) {
$object = (array) $object;
$object_model = (array) $object_model;
if ( ! wu_get_isset($object, 'migrated_from_id')) {
unset($object['migrated_from_id']);
if ( ! wu_get_isset($object_model, 'migrated_from_id')) {
unset($object_model['migrated_from_id']);
}
parent::__construct($object);
parent::__construct($object_model);
}
/**

@@ -537,12 +537,12 @@ class Checkout_Form extends Base_Model {
$steps = [
[
'id' => 'checkout',
'name' => __('Checkout', 'wp-ultimo'),
'name' => __('Checkout', 'wp-multisite-waas'),
'desc' => '',
'fields' => [
[
'step' => 'checkout',
'name' => __('Plans', 'wp-ultimo'),
'name' => __('Plans', 'wp-multisite-waas'),
'type' => 'pricing_table',
'id' => 'pricing_table',
'required' => true,
@@ -551,7 +551,7 @@ class Checkout_Form extends Base_Model {
],
[
'step' => 'checkout',
'name' => __('Email', 'wp-ultimo'),
'name' => __('Email', 'wp-multisite-waas'),
'type' => 'email',
'id' => 'email_address',
'required' => true,
@@ -560,7 +560,7 @@ class Checkout_Form extends Base_Model {
],
[
'step' => 'checkout',
'name' => __('Username', 'wp-ultimo'),
'name' => __('Username', 'wp-multisite-waas'),
'type' => 'username',
'id' => 'username',
'required' => true,
@@ -570,7 +570,7 @@ class Checkout_Form extends Base_Model {
],
[
'step' => 'checkout',
'name' => __('Password', 'wp-ultimo'),
'name' => __('Password', 'wp-multisite-waas'),
'type' => 'password',
'id' => 'password',
'required' => true,
@@ -581,7 +581,7 @@ class Checkout_Form extends Base_Model {
],
[
'step' => 'checkout',
'name' => __('Site Title', 'wp-ultimo'),
'name' => __('Site Title', 'wp-multisite-waas'),
'type' => 'site_title',
'id' => 'site_title',
'required' => true,
@@ -591,7 +591,7 @@ class Checkout_Form extends Base_Model {
],
[
'step' => 'checkout',
'name' => __('Site URL', 'wp-ultimo'),
'name' => __('Site URL', 'wp-multisite-waas'),
'type' => 'site_url',
'id' => 'site_url',
'placeholder' => '',
@@ -602,7 +602,7 @@ class Checkout_Form extends Base_Model {
],
[
'step' => 'checkout',
'name' => __('Your Order', 'wp-ultimo'),
'name' => __('Your Order', 'wp-multisite-waas'),
'type' => 'order_summary',
'id' => 'order_summary',
'order_summary_template' => 'clean',
@@ -610,13 +610,13 @@ class Checkout_Form extends Base_Model {
],
[
'step' => 'checkout',
'name' => __('Payment Method', 'wp-ultimo'),
'name' => __('Payment Method', 'wp-multisite-waas'),
'type' => 'payment',
'id' => 'payment',
],
[
'step' => 'checkout',
'name' => __('Billing Address', 'wp-ultimo'),
'name' => __('Billing Address', 'wp-multisite-waas'),
'type' => 'billing_address',
'id' => 'billing_address',
'required' => true,
@@ -624,7 +624,7 @@ class Checkout_Form extends Base_Model {
],
[
'step' => 'checkout',
'name' => __('Checkout', 'wp-ultimo'),
'name' => __('Checkout', 'wp-multisite-waas'),
'type' => 'submit_button',
'id' => 'checkout',
],
@@ -646,7 +646,7 @@ class Checkout_Form extends Base_Model {
$steps = [
[
'id' => 'checkout',
'name' => __('Checkout', 'wp-ultimo'),
'name' => __('Checkout', 'wp-multisite-waas'),
'desc' => '',
'fields' => [
[
@@ -660,7 +660,7 @@ class Checkout_Form extends Base_Model {
],
[
'step' => 'checkout',
'name' => __('Next Step', 'wp-ultimo'),
'name' => __('Next Step', 'wp-multisite-waas'),
'type' => 'submit_button',
'id' => 'next_step',
],
@@ -668,12 +668,12 @@ class Checkout_Form extends Base_Model {
],
[
'id' => 'site',
'name' => __('Site Info', 'wp-ultimo'),
'name' => __('Site Info', 'wp-multisite-waas'),
'desc' => '',
'fields' => [
[
'step' => 'checkout',
'name' => __('Site Title', 'wp-ultimo'),
'name' => __('Site Title', 'wp-multisite-waas'),
'type' => 'site_title',
'id' => 'site_title',
'required' => true,
@@ -683,7 +683,7 @@ class Checkout_Form extends Base_Model {
],
[
'step' => 'checkout',
'name' => __('Site URL', 'wp-ultimo'),
'name' => __('Site URL', 'wp-multisite-waas'),
'type' => 'site_url',
'id' => 'site_url',
'required' => true,
@@ -694,7 +694,7 @@ class Checkout_Form extends Base_Model {
],
[
'step' => 'site',
'name' => __('Next Step', 'wp-ultimo'),
'name' => __('Next Step', 'wp-multisite-waas'),
'type' => 'submit_button',
'id' => 'next_step_site',
],
@@ -702,13 +702,13 @@ class Checkout_Form extends Base_Model {
],
[
'id' => 'user',
'name' => __('User Info', 'wp-ultimo'),
'name' => __('User Info', 'wp-multisite-waas'),
'logged' => 'guests_only',
'desc' => '',
'fields' => [
[
'step' => 'checkout',
'name' => __('Email', 'wp-ultimo'),
'name' => __('Email', 'wp-multisite-waas'),
'type' => 'email',
'id' => 'email_address',
'required' => true,
@@ -717,7 +717,7 @@ class Checkout_Form extends Base_Model {
],
[
'step' => 'checkout',
'name' => __('Username', 'wp-ultimo'),
'name' => __('Username', 'wp-multisite-waas'),
'type' => 'username',
'id' => 'username',
'required' => true,
@@ -727,7 +727,7 @@ class Checkout_Form extends Base_Model {
],
[
'step' => 'checkout',
'name' => __('Password', 'wp-ultimo'),
'name' => __('Password', 'wp-multisite-waas'),
'type' => 'password',
'id' => 'password',
'required' => true,
@@ -738,7 +738,7 @@ class Checkout_Form extends Base_Model {
],
[
'step' => 'user',
'name' => __('Next Step', 'wp-ultimo'),
'name' => __('Next Step', 'wp-multisite-waas'),
'type' => 'submit_button',
'id' => 'next_step_user',
],
@@ -746,12 +746,12 @@ class Checkout_Form extends Base_Model {
],
[
'id' => 'payment',
'name' => __('Payment', 'wp-ultimo'),
'name' => __('Payment', 'wp-multisite-waas'),
'desc' => '',
'fields' => [
[
'step' => 'checkout',
'name' => __('Your Order', 'wp-ultimo'),
'name' => __('Your Order', 'wp-multisite-waas'),
'type' => 'order_summary',
'id' => 'order_summary',
'order_summary_template' => 'clean',
@@ -759,13 +759,13 @@ class Checkout_Form extends Base_Model {
],
[
'step' => 'checkout',
'name' => __('Payment Method', 'wp-ultimo'),
'name' => __('Payment Method', 'wp-multisite-waas'),
'type' => 'payment',
'id' => 'payment',
],
[
'step' => 'checkout',
'name' => __('Billing Address', 'wp-ultimo'),
'name' => __('Billing Address', 'wp-multisite-waas'),
'type' => 'billing_address',
'id' => 'billing_address',
'required' => true,
@@ -773,7 +773,7 @@ class Checkout_Form extends Base_Model {
],
[
'step' => 'checkout',
'name' => __('Checkout', 'wp-ultimo'),
'name' => __('Checkout', 'wp-multisite-waas'),
'type' => 'submit_button',
'id' => 'checkout',
],
@@ -832,17 +832,17 @@ class Checkout_Form extends Base_Model {
'enable_price_1' => [
'duration' => '1',
'duration_unit' => 'month',
'label' => __('Monthly', 'wp-ultimo'),
'label' => __('Monthly', 'wp-multisite-waas'),
],
'enable_price_3' => [
'duration' => '3',
'duration_unit' => 'month',
'label' => __('Quarterly', 'wp-ultimo'),
'label' => __('Quarterly', 'wp-multisite-waas'),
],
'enable_price_12' => [
'duration' => '1',
'duration_unit' => 'year',
'label' => __('Yearly', 'wp-ultimo'),
'label' => __('Yearly', 'wp-multisite-waas'),
],
];
@@ -867,7 +867,7 @@ class Checkout_Form extends Base_Model {
}
$step['fields']['pricing_table'] = [
'name' => __('Pricing Tables', 'wp-ultimo'),
'name' => __('Pricing Tables', 'wp-multisite-waas'),
'id' => 'pricing_table',
'type' => 'pricing_table',
'pricing_table_template' => 'legacy',
@@ -893,7 +893,7 @@ class Checkout_Form extends Base_Model {
$step['fields'] = [
'template_selection' => [
'name' => __('Template Selection', 'wp-ultimo'),
'name' => __('Template Selection', 'wp-multisite-waas'),
'id' => 'template_selection',
'type' => 'template_selection',
'template_selection_template' => 'legacy',
@@ -940,7 +940,7 @@ class Checkout_Form extends Base_Model {
$field['id'] = 'password';
$field['password_strength_meter'] = false;
$field['password_confirm_field'] = true;
$field['password_confirm_label'] = wu_get_isset($step['fields']['user_pass_conf'], 'name', __('Confirm Password', 'wp-ultimo'));
$field['password_confirm_label'] = wu_get_isset($step['fields']['user_pass_conf'], 'name', __('Confirm Password', 'wp-multisite-waas'));
break;
case 'user_email':
@@ -971,7 +971,7 @@ class Checkout_Form extends Base_Model {
$field['id'] = 'submit_button';
if ('account' === $step_id) {
$field['name'] = __('Continue to the Next Step', 'wp-ultimo');
$field['name'] = __('Continue to the Next Step', 'wp-multisite-waas');
}
break;
@@ -992,17 +992,17 @@ class Checkout_Form extends Base_Model {
*/
$new_format[] = [
'id' => 'payment',
'name' => __('Checkout', 'wp-ultimo'),
'name' => __('Checkout', 'wp-multisite-waas'),
'fields' => [
[
'name' => __('Order Summary', 'wp-ultimo'),
'name' => __('Order Summary', 'wp-multisite-waas'),
'type' => 'order_summary',
'id' => 'order_summary',
'order_summary_template' => 'clean',
'table_columns' => 'simple',
],
[
'name' => __('Billing Address', 'wp-ultimo'),
'name' => __('Billing Address', 'wp-multisite-waas'),
'type' => 'billing_address',
'id' => 'billing_address',
'zip_and_country' => true,
@@ -1010,19 +1010,19 @@ class Checkout_Form extends Base_Model {
[
'type' => 'discount_code',
'id' => 'discount_code',
'name' => __('Coupon Code', 'wp-ultimo'),
'tooltip' => __('Coupon Code', 'wp-ultimo'),
'name' => __('Coupon Code', 'wp-multisite-waas'),
'tooltip' => __('Coupon Code', 'wp-multisite-waas'),
'display_checkbox' => true,
],
[
'name' => __('Payment Methods', 'wp-ultimo'),
'name' => __('Payment Methods', 'wp-multisite-waas'),
'type' => 'payment',
'id' => 'payment',
],
[
'type' => 'submit_button',
'id' => 'submit_button',
'name' => __('Pay & Create Account', 'wp-ultimo'),
'name' => __('Pay & Create Account', 'wp-multisite-waas'),
],
],
];
@@ -1212,7 +1212,7 @@ class Checkout_Form extends Base_Model {
$fields = [
[
'step' => 'checkout',
'name' => __('Your Order', 'wp-ultimo'),
'name' => __('Your Order', 'wp-multisite-waas'),
'type' => 'order_summary',
'id' => 'order_summary',
'order_summary_template' => 'clean',
@@ -1220,13 +1220,13 @@ class Checkout_Form extends Base_Model {
],
[
'step' => 'checkout',
'name' => __('Payment Method', 'wp-ultimo'),
'name' => __('Payment Method', 'wp-multisite-waas'),
'type' => 'payment',
'id' => 'payment',
],
[
'step' => 'checkout',
'name' => __('Finish Payment', 'wp-ultimo'),
'name' => __('Finish Payment', 'wp-multisite-waas'),
'type' => 'submit_button',
'id' => 'checkout',
'order' => 0,
@@ -1236,7 +1236,7 @@ class Checkout_Form extends Base_Model {
$steps = [
[
'id' => 'checkout',
'name' => __('Checkout', 'wp-ultimo'),
'name' => __('Checkout', 'wp-multisite-waas'),
'desc' => '',
'fields' => $fields,
],
@@ -1312,7 +1312,7 @@ class Checkout_Form extends Base_Model {
$label = sprintf(
// translators: %1$s the duration, and %2$s the duration unit (day, week, month, etc)
_n('%2$s', '%1$s %2$s', $product->get_duration(), 'wp-ultimo'), // phpcs:ignore
_n('%2$s', '%1$s %2$s', $product->get_duration(), 'wp-multisite-waas'), // phpcs:ignore
$product->get_duration(),
wu_get_translatable_string($product->get_duration() <= 1 ? $product->get_duration_unit() : $product->get_duration_unit() . 's')
);
@@ -1343,7 +1343,7 @@ class Checkout_Form extends Base_Model {
$label = sprintf(
// translators: %1$s the duration, and %2$s the duration unit (day, week, month, etc)
_n('%2$s', '%1$s %2$s', $variation['duration'], 'wp-ultimo'), // phpcs:ignore
_n('%2$s', '%1$s %2$s', $variation['duration'], 'wp-multisite-waas'), // phpcs:ignore
$variation['duration'],
wu_get_translatable_string($variation['duration'] <= 1 ? $variation['duration_unit'] : $variation['duration_unit'] . 's')
);
@@ -1371,7 +1371,7 @@ class Checkout_Form extends Base_Model {
$fields[] = [
'step' => 'checkout',
'name' => __('Plans', 'wp-ultimo'),
'name' => __('Plans', 'wp-multisite-waas'),
'type' => 'pricing_table',
'id' => 'pricing_table',
'required' => true,
@@ -1406,7 +1406,7 @@ class Checkout_Form extends Base_Model {
$end_fields = [
[
'step' => 'checkout',
'name' => __('Your Order', 'wp-ultimo'),
'name' => __('Your Order', 'wp-multisite-waas'),
'type' => 'order_summary',
'id' => 'order_summary',
'order_summary_template' => 'clean',
@@ -1414,13 +1414,13 @@ class Checkout_Form extends Base_Model {
],
[
'step' => 'checkout',
'name' => __('Payment Method', 'wp-ultimo'),
'name' => __('Payment Method', 'wp-multisite-waas'),
'type' => 'payment',
'id' => 'payment',
],
[
'step' => 'checkout',
'name' => __('Complete Checkout', 'wp-ultimo'),
'name' => __('Complete Checkout', 'wp-multisite-waas'),
'type' => 'submit_button',
'id' => 'checkout',
'order' => 0,
@@ -1432,7 +1432,7 @@ class Checkout_Form extends Base_Model {
$steps = [
[
'id' => 'checkout',
'name' => __('Checkout', 'wp-ultimo'),
'name' => __('Checkout', 'wp-multisite-waas'),
'desc' => '',
'fields' => $fields,
],
@@ -1468,7 +1468,7 @@ class Checkout_Form extends Base_Model {
$template_selection_fields = [
[
'step' => 'template',
'name' => __('Template Selection', 'wp-ultimo'),
'name' => __('Template Selection', 'wp-multisite-waas'),
'type' => 'template_selection',
'id' => 'template_selection',
'cols' => 4,
@@ -1485,7 +1485,7 @@ class Checkout_Form extends Base_Model {
$steps[] = [
'id' => 'template',
'name' => __('Template Selection', 'wp-ultimo'),
'name' => __('Template Selection', 'wp-multisite-waas'),
'desc' => '',
'fields' => $template_selection_fields,
];
@@ -1521,7 +1521,7 @@ class Checkout_Form extends Base_Model {
$final_fields[] = [
'step' => 'create',
'id' => 'site_title',
'name' => __('Site Title', 'wp-ultimo'),
'name' => __('Site Title', 'wp-multisite-waas'),
'tooltip' => '',
'placeholder' => '',
'type' => 'site_title',
@@ -1532,7 +1532,7 @@ class Checkout_Form extends Base_Model {
$final_fields[] = [
'step' => 'create',
'id' => 'site_url',
'name' => __('Site URL', 'wp-ultimo'),
'name' => __('Site URL', 'wp-multisite-waas'),
'tooltip' => '',
'placeholder' => '',
'display_field_attachments' => false,
@@ -1543,7 +1543,7 @@ class Checkout_Form extends Base_Model {
$final_fields[] = [
'step' => 'create',
'name' => __('Create Site', 'wp-ultimo'),
'name' => __('Create Site', 'wp-multisite-waas'),
'type' => 'submit_button',
'id' => 'checkout',
'order' => 0,
@@ -1551,7 +1551,7 @@ class Checkout_Form extends Base_Model {
$steps[] = [
'id' => 'create',
'name' => __('Create Site', 'wp-ultimo'),
'name' => __('Create Site', 'wp-multisite-waas'),
'desc' => '',
'classes' => 'wu-max-w-sm',
'fields' => $final_fields,

@@ -211,7 +211,7 @@ class Customer extends Base_Model {
$user = $this->get_user();
if (empty($user)) {
return __('User Deleted', 'wp-ultimo');
return __('User Deleted', 'wp-multisite-waas');
}
return $user->display_name;
@@ -267,7 +267,7 @@ class Customer extends Base_Model {
$user = $this->get_user();
if (empty($user)) {
return __('none', 'wp-ultimo');
return __('none', 'wp-multisite-waas');
}
return $user->user_login;
@@ -284,7 +284,7 @@ class Customer extends Base_Model {
$user = $this->get_user();
if (empty($user)) {
return __('none', 'wp-ultimo');
return __('none', 'wp-multisite-waas');
}
return $user->user_email;
@@ -730,7 +730,7 @@ class Customer extends Base_Model {
* @options customer
* @return void
*/
public function set_type($type): void {
public function set_type($type) {
$this->type = $type;
}

@@ -465,14 +465,14 @@ class Discount_Code extends Base_Model {
public function is_valid($product = false) {
if ($this->is_active() === false) {
return new \WP_Error('discount_code', __('This coupon code is not valid.', 'wp-ultimo'));
return new \WP_Error('discount_code', __('This coupon code is not valid.', 'wp-multisite-waas'));
}
/*
* Check for uses
*/
if ($this->has_max_uses() && $this->get_uses() >= $this->get_max_uses()) {
return new \WP_Error('discount_code', __('This discount code was already redeemed the maximum amount of times allowed.', 'wp-ultimo'));
return new \WP_Error('discount_code', __('This discount code was already redeemed the maximum amount of times allowed.', 'wp-multisite-waas'));
}
/*
@@ -487,9 +487,9 @@ class Discount_Code extends Base_Model {
$start_date_instance = wu_date($start_date);
if ($now < $start_date_instance) {
return new \WP_Error('discount_code', __('This coupon code is not valid.', 'wp-ultimo'));
return new \WP_Error('discount_code', __('This coupon code is not valid.', 'wp-multisite-waas'));
return new \WP_Error('discount_code', __('The coupon code is not valid yet.', 'wp-ultimo'));
return new \WP_Error('discount_code', __('The coupon code is not valid yet.', 'wp-multisite-waas'));
}
}
@@ -497,7 +497,7 @@ class Discount_Code extends Base_Model {
$expiration_date_instance = wu_date($expiration_date);
if ($now > $expiration_date_instance) {
return new \WP_Error('discount_code', __('This coupon code is not valid.', 'wp-ultimo'));
return new \WP_Error('discount_code', __('This coupon code is not valid.', 'wp-multisite-waas'));
}
}
@@ -515,7 +515,7 @@ class Discount_Code extends Base_Model {
$allowed = $this->get_limit_products() && in_array($product_id, $this->get_allowed_products()); // phpcs:ignore
if (false === $allowed) {
return new \WP_Error('discount_code', __('This coupon code is not valid.', 'wp-ultimo'));
return new \WP_Error('discount_code', __('This coupon code is not valid.', 'wp-multisite-waas'));
}
}
@@ -640,7 +640,7 @@ class Discount_Code extends Base_Model {
$description[] = sprintf(
// translators: placeholder is the value off. Can be wither $X.XX or X%
__('%1$s OFF on Subscriptions', 'wp-ultimo'),
__('%1$s OFF on Subscriptions', 'wp-multisite-waas'),
$value
);
}
@@ -654,12 +654,12 @@ class Discount_Code extends Base_Model {
$description[] = sprintf(
// translators: placeholder is the value off. Can be wither $X.XX or X%
__('%1$s OFF on Setup Fees', 'wp-ultimo'),
__('%1$s OFF on Setup Fees', 'wp-multisite-waas'),
$setup_fee_value
);
}
return implode(' ' . __('and', 'wp-ultimo') . ' ', $description);
return implode(' ' . __('and', 'wp-multisite-waas') . ' ', $description);
}
/**

@@ -532,7 +532,7 @@ class Domain extends Base_Model {
*/
wu_log_clear("domain-{$this->get_domain()}");
wu_log_add("domain-{$this->get_domain()}", __('Domain deleted and logs cleared...', 'wp-ultimo'));
wu_log_add("domain-{$this->get_domain()}", __('Domain deleted and logs cleared...', 'wp-multisite-waas'));
return $results;
}

@@ -25,11 +25,11 @@ class Event extends Base_Model {
const SEVERITY_NEUTRAL = 2;
const SEVERITY_INFO = 3;
const SEVERITY_INFO = 3;
const SEVERITY_WARNING = 4;
const SEVERITY_FATAL = 5;
const SEVERITY_FATAL = 5;
/**
* Severity of the problem.
@@ -156,14 +156,14 @@ class Event extends Base_Model {
public function get_severity_label() {
$labels = [
self::SEVERITY_SUCCESS => __('Success', 'wp-ultimo'),
self::SEVERITY_NEUTRAL => __('Neutral', 'wp-ultimo'),
self::SEVERITY_INFO => __('Info', 'wp-ultimo'),
self::SEVERITY_WARNING => __('Warning', 'wp-ultimo'),
self::SEVERITY_FATAL => __('Fatal', 'wp-ultimo'),
self::SEVERITY_SUCCESS => __('Success', 'wp-multisite-waas'),
self::SEVERITY_NEUTRAL => __('Neutral', 'wp-multisite-waas'),
self::SEVERITY_INFO => __('Info', 'wp-multisite-waas'),
self::SEVERITY_WARNING => __('Warning', 'wp-multisite-waas'),
self::SEVERITY_FATAL => __('Fatal', 'wp-multisite-waas'),
];
return $labels[ $this->get_severity() ] ?? __('Note', 'wp-ultimo');
return $labels[ $this->get_severity() ] ?? __('Note', 'wp-multisite-waas');
}
/**
@@ -303,12 +303,12 @@ class Event extends Base_Model {
$default_messages = [];
$default_messages['changed'] = __('The <strong>{{model}}</strong> #{{object_id}} was changed: {{payload}}', 'wp-ultimo');
$default_messages['created'] = __('The <strong>{{model}}</strong> #{{object_id}} was created.', 'wp-ultimo');
$default_messages['changed'] = __('The <strong>{{model}}</strong> #{{object_id}} was changed: {{payload}}', 'wp-multisite-waas');
$default_messages['created'] = __('The <strong>{{model}}</strong> #{{object_id}} was created.', 'wp-multisite-waas');
$default_messages = apply_filters('wu_get_default_system_messages', $default_messages);
return wu_get_isset($default_messages, $slug, __('No Message', 'wp-ultimo'));
return wu_get_isset($default_messages, $slug, __('No Message', 'wp-multisite-waas'));
}

@@ -317,11 +317,11 @@ class Membership extends Base_Model {
*
* @since 2.0.0
*
* @param object $object Std object with model parameters.
* @param object $object_model Std object with model parameters.
*/
public function __construct($object = null) {
public function __construct($object_model = null) {
parent::__construct($object);
parent::__construct($object_model);
$this->_gateway_info = [
'gateway' => $this->get_gateway(),
@@ -670,7 +670,7 @@ class Membership extends Base_Model {
public function swap($order) {
if ( ! is_a($order, Cart::class)) {
return new \WP_Error('invalid-date', __('Swap Cart is invalid.', 'wp-ultimo'));
return new \WP_Error('invalid-date', __('Swap Cart is invalid.', 'wp-multisite-waas'));
}
// clear the current addons.
@@ -743,11 +743,11 @@ class Membership extends Base_Model {
}
if ( ! wu_validate_date($schedule_date)) {
return new \WP_Error('invalid-date', __('Schedule date is invalid.', 'wp-ultimo'));
return new \WP_Error('invalid-date', __('Schedule date is invalid.', 'wp-multisite-waas'));
}
if ( ! is_a($order, Cart::class)) {
return new \WP_Error('invalid-date', __('Swap Cart is invalid.', 'wp-ultimo'));
return new \WP_Error('invalid-date', __('Swap Cart is invalid.', 'wp-multisite-waas'));
}
$date_instance = wu_date($schedule_date);
@@ -831,7 +831,7 @@ class Membership extends Base_Model {
$description = sprintf(
// translators: %1$s the duration, and %2$s the duration unit (day, week, month, etc)
_n('every %2$s', 'every %1$s %2$s', $this->get_duration(), 'wp-ultimo'), // phpcs:ignore
_n('every %2$s', 'every %1$s %2$s', $this->get_duration(), 'wp-multisite-waas'), // phpcs:ignore
$this->get_duration(),
wu_get_translatable_string(($this->get_duration() <= 1 ? $this->get_duration_unit() : $this->get_duration_unit() . 's'))
);
@@ -847,12 +847,12 @@ class Membership extends Base_Model {
public function get_times_billed_description(): string {
// translators: times billed / subscription duration in cycles. e.g. 1/12 cycles
$description = __('%1$s / %2$s cycles', 'wp-ultimo');
$description = __('%1$s / %2$s cycles', 'wp-multisite-waas');
if ($this->is_forever_recurring()) {
// translators: the place holder is the number of times the membership was billed.
$description = __('%1$s / until cancelled', 'wp-ultimo');
$description = __('%1$s / until cancelled', 'wp-multisite-waas');
}
return sprintf($description, $this->get_times_billed(), $this->get_billing_cycles());
@@ -872,7 +872,7 @@ class Membership extends Base_Model {
$message = sprintf(
// translators: %1$s is the formatted price, %2$s the duration, and %3$s the duration unit (day, week, month, etc)
_n('%1$s every %3$s', '%1$s every %2$s %3$s', $duration, 'wp-ultimo'), // phpcs:ignore
_n('%1$s every %3$s', '%1$s every %2$s %3$s', $duration, 'wp-multisite-waas'), // phpcs:ignore
wu_format_currency($this->get_amount(), $this->get_currency()),
$duration,
wu_get_translatable_string($duration <= 1 ? $this->get_duration_unit() : $this->get_duration_unit() . 's')
@@ -883,7 +883,7 @@ class Membership extends Base_Model {
if ( ! $this->is_forever_recurring()) {
$billing_cycles_message = sprintf(
// translators: %s is the number of billing cycles.
_n('for %s cycle', 'for %s cycles', $this->get_billing_cycles(), 'wp-ultimo'),
_n('for %s cycle', 'for %s cycles', $this->get_billing_cycles(), 'wp-multisite-waas'),
$this->get_billing_cycles()
);
@@ -892,13 +892,13 @@ class Membership extends Base_Model {
} else {
$pricing['subscription'] = sprintf(
// translators: %1$s is the formatted price of the product
__('%1$s one time payment', 'wp-ultimo'),
__('%1$s one time payment', 'wp-multisite-waas'),
wu_format_currency($this->get_initial_amount(), $this->get_currency())
);
}
if ($this->is_free()) {
$pricing['subscription'] = __('Free!', 'wp-ultimo');
$pricing['subscription'] = __('Free!', 'wp-multisite-waas');
}
return implode(' + ', $pricing);

@@ -12,9 +12,9 @@ namespace WP_Ultimo\Models;
use WP_Ultimo\Models\Base_Model;
use WP_Ultimo\Database\Payments\Payment_Status;
use WP_Ultimo\Checkout\Line_Item;
use WP_Ultimo\Models\Product;
use WP_Ultimo\Models\Customer;
use WP_Ultimo\Models\Membership;
use WP_Ultimo\Models\Product;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -192,7 +192,7 @@ class Payment extends Base_Model {
return wu_format_currency($this->{"$method_key"}(), $this->get_currency());
}
throw new \BadMethodCallException($name);
throw new \BadMethodCallException(esc_html($name));
}
/**
@@ -548,13 +548,13 @@ class Payment extends Base_Model {
$gateway = $this->get_gateway();
if ( ! $gateway) {
return __('None', 'wp-ultimo');
return __('None', 'wp-multisite-waas');
}
$gateway_class = wu_get_gateway($gateway);
if ( ! $gateway_class) {
return __('None', 'wp-ultimo');
return __('None', 'wp-multisite-waas');
}
$title = $gateway_class->get_public_title();
@@ -905,7 +905,7 @@ class Payment extends Base_Model {
if (false === $this->invoice_number) {
$provisional = true;
$this->invoice_number = wu_get_setting('next_invoice_number');
$this->invoice_number = wu_get_setting('next_invoice_number', 1);
}
$prefix = wu_get_setting('invoice_prefix', '');
@@ -930,7 +930,7 @@ class Payment extends Base_Model {
$prefix = str_replace($search, $replace, (string) $prefix);
return sprintf('%s%s %s', $prefix, $this->invoice_number, $provisional ? __('(provisional)', 'wp-ultimo') : '');
return sprintf('%s%s %s', $prefix, $this->invoice_number, $provisional ? __('(provisional)', 'wp-multisite-waas') : '');
}
/**
@@ -1050,11 +1050,11 @@ class Payment extends Base_Model {
* it is a partial refund.
*/
if ($amount >= $this->get_total()) {
$title = __('Full Refund', 'wp-ultimo');
$title = __('Full Refund', 'wp-multisite-waas');
$new_status = Payment_Status::REFUND;
} else {
$title = __('Partial Refund', 'wp-ultimo');
$title = __('Partial Refund', 'wp-multisite-waas');
$new_status = Payment_Status::PARTIAL_REFUND;
}
@@ -1064,7 +1064,7 @@ class Payment extends Base_Model {
$formatted_value = date_i18n(get_option('date_format'), $time);
// translators: %s is the date of processing.
$description = sprintf(__('Processed on %s', 'wp-ultimo'), $formatted_value);
$description = sprintf(__('Processed on %s', 'wp-multisite-waas'), $formatted_value);
$line_item_data = [
'type' => 'refund',
@@ -1110,7 +1110,7 @@ class Payment extends Base_Model {
* Creates a copy of the given model adn resets it's id to a 'new' state.
*
* @since 2.0.0
* @return \WP_Ultimo\Model\Base_Model
* @return Base_Model
*/
public function duplicate() {

@@ -620,11 +620,11 @@ class Product extends Base_Model {
public function get_formatted_amount($key = 'amount') {
if ($this->is_free()) {
return __('Free!', 'wp-ultimo');
return __('Free!', 'wp-multisite-waas');
}
if ($this->get_pricing_type() === 'contact_us') {
return $this->get_contact_us_label() ?: __('Contact Us', 'wp-ultimo');
return $this->get_contact_us_label() ?: __('Contact Us', 'wp-multisite-waas');
}
return wu_format_currency($this->get_amount(), $this->get_currency());
@@ -697,11 +697,11 @@ class Product extends Base_Model {
$pricing = [];
if ($this->get_pricing_type() === 'contact_us') {
return __('Contact us', 'wp-ultimo');
return __('Contact us', 'wp-multisite-waas');
}
if ($this->is_free()) {
return __('Free!', 'wp-ultimo');
return __('Free!', 'wp-multisite-waas');
}
if ($this->is_recurring()) {
@@ -709,7 +709,7 @@ class Product extends Base_Model {
$message = sprintf(
// translators: %1$s is the formatted price, %2$s the duration, and %3$s the duration unit (day, week, month, etc)
_n('%1$s every %3$s', '%1$s every %2$s %3$s', $duration, 'wp-ultimo'), // phpcs:ignore
_n('%1$s every %3$s', '%1$s every %2$s %3$s', $duration, 'wp-multisite-waas'), // phpcs:ignore
wu_format_currency($this->get_amount(), $this->get_currency()),
$duration,
wu_get_translatable_string($duration <= 1 ? $this->get_duration_unit() : $this->get_duration_unit() . 's')
@@ -720,7 +720,7 @@ class Product extends Base_Model {
if ( ! $this->is_forever_recurring()) {
$billing_cycles_message = sprintf(
// translators: %s is the number of billing cycles.
_n('for %s cycle', 'for %s cycles', $this->get_billing_cycles(), 'wp-ultimo'),
_n('for %s cycle', 'for %s cycles', $this->get_billing_cycles(), 'wp-multisite-waas'),
$this->get_billing_cycles()
);
@@ -729,7 +729,7 @@ class Product extends Base_Model {
} else {
$pricing['subscription'] = sprintf(
// translators: %1$s is the formatted price of the product
__('%1$s one time payment', 'wp-ultimo'),
__('%1$s one time payment', 'wp-multisite-waas'),
wu_format_currency($this->get_amount(), $this->get_currency())
);
}
@@ -737,7 +737,7 @@ class Product extends Base_Model {
if ($this->has_setup_fee() && $include_fees) {
$pricing['fee'] = sprintf(
// translators: %1$s is the formatted price of the setup fee
__('Setup Fee of %1$s', 'wp-ultimo'),
__('Setup Fee of %1$s', 'wp-multisite-waas'),
wu_format_currency($this->get_setup_fee(), $this->get_currency())
);
}
@@ -758,12 +758,12 @@ class Product extends Base_Model {
}
if ( ! $this->is_recurring()) {
return __('one-time payment', 'wp-ultimo');
return __('one-time payment', 'wp-multisite-waas');
}
$description = sprintf(
// translators: %1$s the duration, and %2$s the duration unit (day, week, month, etc)
_n('every %2$s', 'every %1$s %2$s', $this->get_duration(), 'wp-ultimo'), // phpcs:ignore
_n('every %2$s', 'every %1$s %2$s', $this->get_duration(), 'wp-multisite-waas'), // phpcs:ignore
$this->get_duration(),
wu_get_translatable_string($this->get_duration() <= 1 ? $this->get_duration_unit() : $this->get_duration_unit() . 's')
);

@@ -23,7 +23,7 @@ defined('ABSPATH') || exit;
*
* @since 2.0.0
*/
class Site extends Base_Model {
class Site extends Base_Model implements Limitable {
use Traits\Limitable;
use \WP_Ultimo\Traits\WP_Ultimo_Site_Deprecated;
@@ -1255,14 +1255,14 @@ class Site extends Base_Model {
*
* @since 2.0.0
*
* @param mixed $object Object containing the parameters.
* @param mixed $object_model Object containing the parameters.
*/
public function __construct($object = null) {
public function __construct($object_model = null) {
parent::__construct($object);
parent::__construct($object_model);
if (is_array($object)) {
$object = (object) $object;
if (is_array($object_model)) {
$object_model = (object) $object_model;
}
$details = get_blog_details($this->get_blog_id());
@@ -1274,11 +1274,11 @@ class Site extends Base_Model {
/*
* Quick fix for WP CLI, since it uses the --path arg to do other things.
*/
if ( ! $this->path && is_object($object) && isset($object->site_path)) {
$this->path = $object->site_path;
if ( ! $this->path && is_object($object_model) && isset($object_model->site_path)) {
$this->path = $object_model->site_path;
}
$object = (object) $object;
$object_model = (object) $object_model;
}
/**
@@ -1437,7 +1437,7 @@ class Site extends Base_Model {
public function delete() {
if ( ! $this->get_id()) {
return new \WP_Error("wu_{$this->model}_delete_unsaved_item", __('Item not found.', 'wp-ultimo'));
return new \WP_Error("wu_{$this->model}_delete_unsaved_item", __('Item not found.', 'wp-multisite-waas'));
}
/**

@@ -0,0 +1,99 @@
<?php
/**
* Limitable interface.
*
* @package WP_Ultimo
* @subpackage Models
*/
namespace WP_Ultimo\Models;
interface Limitable {
/**
* List of limitations that need to be merged.
*
* Every model that is limitable (imports this trait)
* needs to declare explicitly the limitations that need to be
* merged. This allows us to chain the merges, and gives us
* a final list of limitations at the end of the process.
*
* @since 2.0.0
* @return array
*/
public function limitations_to_merge();
/**
* Returns the limitations of this particular blog.
*
* @since 2.0.0
*
* @param bool $waterfall If we should construct the limitations object recursively.
* @param bool $skip_self If we should skip the current limitations.
* @return \WP_Ultimo\Objects\Limitations
*/
public function get_limitations($waterfall = true, $skip_self = false);
/**
* Checks if this site has limitations or not.
*
* @since 2.0.0
* @return boolean
*/
public function has_limitations();
/**
* Checks if a particular module is being limited.
*
* @since 2.0.0
*
* @param string $module Module to check.
* @return boolean
*/
public function has_module_limitation($module);
/**
* Returns all user role quotas.
*
* @since 2.0.0
* @return array
*/
public function get_user_role_quotas();
/**
* Proxy method to retrieve the allowed user roles.
*
* @since 2.0.0
* @return array
*/
public function get_allowed_user_roles();
/**
* Schedules plugins to be activated or deactivated based on the current limitations;
*
* @since 2.0.5
* @return void
*/
public function sync_plugins(): void;
/**
* Makes sure we save limitations when we are supposed to.
*
* This is called on the handle_save method of the inc/admin-pages/class-edit-admin-page.php
* for all models that have the trait Limitable.
*
* @see inc/admin-pages/class-edit-admin-page.php
*
* @since 2.0.0
* @return void
*/
public function handle_limitations(): void;
/**
* Returns the list of product slugs associated with this model.
*
* @since 2.0.0
* @return array
*/
public function get_applicable_product_slugs();
}

@@ -26,26 +26,12 @@ trait Limitable {
protected $_limitations = [];
/**
* List of limitations that need to be merged.
*
* Every model that is limitable (imports this trait)
* needs to declare explicitly the limitations that need to be
* merged. This allows us to chain the merges, and gives us
* a final list of limitations at the end of the process.
*
* @since 2.0.0
* @return array
* @inheritDoc
*/
abstract public function limitations_to_merge();
/**
* Returns the limitations of this particular blog.
*
* @since 2.0.0
*
* @param bool $waterfall If we should construct the limitations object recursively.
* @param bool $skip_self If we should skip the current limitations.
* @return \WP_Ultimo\Objects\Limitations
* @inheritdoc
*/
public function get_limitations($waterfall = true, $skip_self = false) {
@@ -104,10 +90,7 @@ trait Limitable {
}
/**
* Checks if this site has limitations or not.
*
* @since 2.0.0
* @return boolean
* @inheritdoc
*/
public function has_limitations() {
@@ -191,15 +174,7 @@ trait Limitable {
}
/**
* Makes sure we save limitations when we are supposed to.
*
* This is called on the handle_save method of the inc/admin-pages/class-edit-admin-page.php
* for all models that have the trait Limitable.
*
* @see inc/admin-pages/class-edit-admin-page.php
*
* @since 2.0.0
* @return void
* @inheritdoc
*/
public function handle_limitations(): void {
/*
@@ -247,7 +222,7 @@ trait Limitable {
* Set the new permissions, based on the diff.
*/
$limitations = wu_array_recursive_diff($modules_to_save, $current_limitations->to_array());
} elseif ('product' === $this->model && $this->get_type() !== 'plan') {
} elseif ($this->get_type() !== 'plan') {
$limitations = wu_array_recursive_diff($modules_to_save, Limitations::get_empty()->to_array());
} else {
$limitations = $modules_to_save;
@@ -257,10 +232,7 @@ trait Limitable {
}
/**
* Returns the list of product slugs associated with this model.
*
* @since 2.0.0
* @return array
* @inheritdoc
*/
public function get_applicable_product_slugs() {