Use PHP 7.4 featers and PHP 8 polyfills

This commit is contained in:
David Stone
2025-02-08 13:57:32 -07:00
parent 8bea6067cd
commit b41dc2b2eb
550 changed files with 15270 additions and 14627 deletions

View File

@ -62,7 +62,7 @@ abstract class Base_Model implements \JsonSerializable {
* @since 2.0.0
* @var array
*/
protected $meta_fields = array();
protected $meta_fields = [];
/**
* Model creation date.
@ -86,7 +86,7 @@ abstract class Base_Model implements \JsonSerializable {
* @since 2.0.0
* @var array
*/
public $meta = array();
public $meta = [];
/**
* The ID of the original 1.X model that was used to generate this item on migration.
@ -118,7 +118,7 @@ abstract class Base_Model implements \JsonSerializable {
* @since 2.0.0
* @var array
*/
protected $_mappings = array();
protected $_mappings = [];
/**
* Mocked status. Used to suppress errors.
@ -165,7 +165,7 @@ abstract class Base_Model implements \JsonSerializable {
*
* @param mixed $slug The slug.
*/
public function set_slug($slug) {
public function set_slug($slug): void {
$this->slug = $slug;
}
@ -179,7 +179,7 @@ abstract class Base_Model implements \JsonSerializable {
*/
public function get_hash($field = 'id') {
$value = call_user_func(array($this, "get_{$field}"));
$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');
@ -232,13 +232,13 @@ abstract class Base_Model implements \JsonSerializable {
}
if (method_exists($this, "set_$key")) {
call_user_func(array($this, "set_$key"), $value);
call_user_func([$this, "set_$key"], $value);
}
$mapping = wu_get_isset($this->_mappings, $key);
if ($mapping && method_exists($this, "set_$mapping")) {
call_user_func(array($this, "set_$mapping"), $value);
call_user_func([$this, "set_$mapping"], $value);
}
}
@ -376,7 +376,7 @@ abstract class Base_Model implements \JsonSerializable {
* @param array $query Arguments for the query.
* @return array|int List of items, or number of items when 'count' is passed as a query var.
*/
public static function get_items_as_array($query = array()) {
public static function get_items_as_array($query = []) {
$instance = new static();
@ -406,12 +406,12 @@ abstract class Base_Model implements \JsonSerializable {
public function has_running_jobs() {
$jobs = wu_get_scheduled_actions(
array(
[
'status' => \ActionScheduler_Store::STATUS_RUNNING,
'args' => array(
'args' => [
"{$this->model}_id" => $this->get_id(),
),
)
],
]
);
return $jobs;
@ -424,7 +424,7 @@ abstract class Base_Model implements \JsonSerializable {
* @param integer $id ID of the object.
* @return void
*/
private function set_id($id) {
private function set_id($id): void {
$this->id = $id;
}
@ -441,7 +441,7 @@ abstract class Base_Model implements \JsonSerializable {
*/
public function validation_rules() {
return array();
return [];
}
/**
@ -492,7 +492,7 @@ abstract class Base_Model implements \JsonSerializable {
$data_unserialized = $data;
$meta = wu_get_isset($data, 'meta', array());
$meta = wu_get_isset($data, 'meta', []);
$new = ! $this->exists();
@ -507,10 +507,10 @@ abstract class Base_Model implements \JsonSerializable {
*/
$meta = apply_filters("wu_{$this->model}_meta_pre_save", $meta, $data_unserialized, $this);
$blocked_attributes = array(
$blocked_attributes = [
'query_class',
'meta',
);
];
foreach ($blocked_attributes as $attribute) {
unset($data[ $attribute ]);
@ -805,7 +805,7 @@ abstract class Base_Model implements \JsonSerializable {
* @param array $args Query arguments.
* @return array|int List of items, or number of items when 'count' is passed as a query var.
*/
public static function query($args = array()) {
public static function query($args = []) {
$instance = new static();
@ -835,7 +835,7 @@ abstract class Base_Model implements \JsonSerializable {
unset($array['_mocked']);
foreach ($array as $key => $value) {
if (strncmp('_', $key, strlen($key)) === 0) {
if (str_starts_with('_', $key)) {
unset($array[ $key ]);
}
}
@ -864,7 +864,7 @@ abstract class Base_Model implements \JsonSerializable {
*/
protected static function to_instances($data) {
return array_map(array(get_called_class(), 'to_instance'), $data);
return array_map([static::class, 'to_instance'], $data);
}
/**
@ -931,7 +931,7 @@ abstract class Base_Model implements \JsonSerializable {
* @param string $date_created Model creation date.
* @return void
*/
public function set_date_created($date_created) {
public function set_date_created($date_created): void {
$this->date_created = $date_created;
}
@ -943,7 +943,7 @@ abstract class Base_Model implements \JsonSerializable {
* @param string $date_modified Model last modification date.
* @return void
*/
public function set_date_modified($date_modified) {
public function set_date_modified($date_modified): void {
$this->date_modified = $date_modified;
}
@ -966,7 +966,7 @@ abstract class Base_Model implements \JsonSerializable {
* @param int $migrated_from_id The ID of the original 1.X model that was used to generate this item on migration.
* @return void
*/
public function set_migrated_from_id($migrated_from_id) {
public function set_migrated_from_id($migrated_from_id): void {
$this->migrated_from_id = absint($migrated_from_id);
}
@ -1034,7 +1034,7 @@ abstract class Base_Model implements \JsonSerializable {
* @param array $query_args If you need to select a type to get all.
* @return array With all items requested.
*/
public static function get_all($query_args = array()) {
public static function get_all($query_args = []) {
$instance = new static();
@ -1072,7 +1072,7 @@ abstract class Base_Model implements \JsonSerializable {
* @since 2.0.0
* @return void
*/
public function hydrate() {
public function hydrate(): void {
$attributes = get_object_vars($this);
$attributes = array_filter($attributes, fn ($value) => $value === null);
@ -1080,10 +1080,10 @@ abstract class Base_Model implements \JsonSerializable {
unset($attributes['meta']);
foreach ($attributes as $attribute => $maybe_null) {
$possible_setters = array(
$possible_setters = [
"get_{$attribute}",
"is_{$attribute}",
);
];
foreach ($possible_setters as $setter) {
$setter = method_exists($this, $setter) ? $setter : '';
@ -1106,7 +1106,7 @@ abstract class Base_Model implements \JsonSerializable {
* @param boolean $skip_validation Set true to have field information validation bypassed when saving this event.
* @return void
*/
public function set_skip_validation($skip_validation = false) {
public function set_skip_validation($skip_validation = false): void {
$this->skip_validation = $skip_validation;
}

View File

@ -35,7 +35,7 @@ class Broadcast extends Post_Base_Model {
* @access public
* @var mixed
*/
protected $query_class = '\\WP_Ultimo\\Database\\Broadcasts\\Broadcast_Query';
protected $query_class = \WP_Ultimo\Database\Broadcasts\Broadcast_Query::class;
/**
* Post type.
@ -51,7 +51,7 @@ class Broadcast extends Post_Base_Model {
* @since 2.0.0
* @var array
*/
protected $allowed_types = array('broadcast_email', 'broadcast_notice');
protected $allowed_types = ['broadcast_email', 'broadcast_notice'];
/**
* Set the allowed status to prevent saving wrong status.
@ -59,7 +59,7 @@ class Broadcast extends Post_Base_Model {
* @since 2.0.0
* @var array
*/
protected $allowed_status = array('publish', 'draft');
protected $allowed_status = ['publish', 'draft'];
/**
* Broadcast status.
@ -107,14 +107,14 @@ class Broadcast extends Post_Base_Model {
*/
public function validation_rules() {
return array(
return [
'notice_type' => 'in:info,success,warning,error',
'status' => 'default:publish',
'name' => 'default:title',
'title' => 'required|min:2',
'content' => 'required|min:3',
'type' => 'required|in:broadcast_email,broadcast_notice|default:broadcast_notice',
);
];
}
/**
@ -139,7 +139,7 @@ class Broadcast extends Post_Base_Model {
* @param int $migrated_from_id The ID of the original 1.X model that was used to generate this item on migration.
* @return void
*/
public function set_migrated_from_id($migrated_from_id) {
public function set_migrated_from_id($migrated_from_id): void {
$this->meta['migrated_from_id'] = $migrated_from_id;
@ -202,7 +202,7 @@ class Broadcast extends Post_Base_Model {
* @param string $message_targets The targets for this broadcast.
* @return void
*/
public function set_message_targets($message_targets) {
public function set_message_targets($message_targets): void {
$this->meta['message_targets'] = $message_targets;
}
@ -216,7 +216,7 @@ class Broadcast extends Post_Base_Model {
* @options info,success,warning,error
* @return void
*/
public function set_notice_type($notice_type) {
public function set_notice_type($notice_type): void {
$this->meta['notice_type'] = $notice_type;
@ -231,7 +231,7 @@ class Broadcast extends Post_Base_Model {
* @param string $name This broadcast name, which is used as broadcast title as well.
* @return void
*/
public function set_name($name) {
public function set_name($name): void {
$this->set_title($name);
}

File diff suppressed because it is too large Load Diff

View File

@ -119,7 +119,7 @@ class Customer extends Base_Model {
* @since 2.0.0
* @var string
*/
protected $query_class = '\\WP_Ultimo\\Database\\Customers\\Customer_Query';
protected $query_class = \WP_Ultimo\Database\Customers\Customer_Query::class;
/**
* Allows injection, which is useful for mocking.
@ -153,7 +153,7 @@ class Customer extends Base_Model {
$id = $this->get_id();
return array(
return [
'user_id' => "required|integer|unique:\WP_Ultimo\Models\Customer,user_id,{$id}",
'email_verification' => 'required|in:none,pending,verified',
'type' => 'required|in:customer',
@ -163,7 +163,7 @@ class Customer extends Base_Model {
'ips' => 'array',
'extra_information' => 'default:',
'signup_form' => 'default:',
);
];
}
/**
@ -184,7 +184,7 @@ class Customer extends Base_Model {
* @param int $user_id The WordPress user ID attached to this customer.
* @return void
*/
public function set_user_id($user_id) {
public function set_user_id($user_id): void {
$this->user_id = $user_id;
}
@ -229,11 +229,11 @@ class Customer extends Base_Model {
public function get_default_billing_address() {
return new \WP_Ultimo\Objects\Billing_Address(
array(
[
'company_name' => $this->get_display_name(),
'billing_email' => $this->get_email_address(),
'billing_country' => $this->get_meta('ip_country'),
)
]
);
}
@ -309,7 +309,7 @@ class Customer extends Base_Model {
* @param string $date_registered Date when the customer was created.
* @return void
*/
public function set_date_registered($date_registered) {
public function set_date_registered($date_registered): void {
$this->date_registered = $date_registered;
}
@ -332,7 +332,7 @@ class Customer extends Base_Model {
* @param string $email_verification Email verification status - either `none`, `pending`, or `verified`.
* @return void
*/
public function set_email_verification($email_verification) {
public function set_email_verification($email_verification): void {
$this->email_verification = $email_verification;
}
@ -356,7 +356,7 @@ class Customer extends Base_Model {
* @param string $last_login Date this customer last logged in.
* @return void
*/
public function set_last_login($last_login) {
public function set_last_login($last_login): void {
$this->last_login = $last_login;
}
@ -377,12 +377,12 @@ class Customer extends Base_Model {
if ( ! $this->has_trialed) {
$trial = wu_get_memberships(
array(
[
'customer_id' => $this->get_id(),
'date_trial_end__not_in' => array(null, '0000-00-00 00:00:00'),
'date_trial_end__not_in' => [null, '0000-00-00 00:00:00'],
'fields' => 'ids',
'number' => 1,
)
]
);
if ( ! empty($trial)) {
@ -402,7 +402,7 @@ class Customer extends Base_Model {
* @param bool $has_trialed Whether or not the customer has trialed before.
* @return void
*/
public function set_has_trialed($has_trialed) {
public function set_has_trialed($has_trialed): void {
$this->meta['wu_has_trialed'] = $has_trialed;
@ -427,7 +427,7 @@ class Customer extends Base_Model {
* @param bool $vip If this customer is a VIP customer or not.
* @return void
*/
public function set_vip($vip) {
public function set_vip($vip): void {
$this->vip = $vip;
}
@ -441,7 +441,7 @@ class Customer extends Base_Model {
public function get_ips() {
if (empty($this->ips)) {
return array();
return [];
}
if (is_string($this->ips)) {
@ -471,7 +471,7 @@ class Customer extends Base_Model {
* @param array $ips List of IP addresses used by this customer.
* @return void
*/
public function set_ips($ips) {
public function set_ips($ips): void {
if (is_string($ips)) {
$ips = maybe_unserialize(wp_unslash($ips));
@ -488,12 +488,12 @@ class Customer extends Base_Model {
* @param string $ip New IP address to add.
* @return void
*/
public function add_ip($ip) {
public function add_ip($ip): void {
$ips = $this->get_ips();
if ( ! is_array($ips)) {
$ips = array();
$ips = [];
}
/*
@ -520,9 +520,9 @@ class Customer extends Base_Model {
public function update_last_login($update_ip = true, $update_country_and_state = false) {
$this->attributes(
array(
[
'last_login' => wu_get_current_time('mysql', true),
)
]
);
$geolocation = $update_ip || $update_country_and_state ? \WP_Ultimo\Geolocation::geolocate_ip('', true) : false;
@ -563,7 +563,7 @@ class Customer extends Base_Model {
* @param array $extra_information Any extra information related to this customer.
* @return void
*/
public function set_extra_information($extra_information) {
public function set_extra_information($extra_information): void {
$extra_information = array_filter((array) $extra_information);
@ -580,9 +580,9 @@ class Customer extends Base_Model {
public function get_memberships() {
return Membership::query(
array(
[
'customer_id' => $this->get_id(),
)
]
);
}
@ -593,18 +593,18 @@ class Customer extends Base_Model {
* @param array $query_args Query arguments.
* @return array
*/
public function get_sites($query_args = array()) {
public function get_sites($query_args = []) {
$query_args = array_merge(
$query_args,
array(
'meta_query' => array(
'customer_id' => array(
[
'meta_query' => [
'customer_id' => [
'key' => 'wu_customer_id',
'value' => $this->get_id(),
),
),
)
],
],
]
);
return Site::query($query_args);
@ -618,7 +618,7 @@ class Customer extends Base_Model {
*/
public function get_pending_sites() {
$pending_sites = array();
$pending_sites = [];
$memberships = $this->get_memberships();
@ -666,9 +666,9 @@ class Customer extends Base_Model {
public function get_payments() {
return Payment::query(
array(
[
'customer_id' => $this->get_id(),
)
]
);
}
@ -696,10 +696,10 @@ class Customer extends Base_Model {
40,
'identicon',
'',
array(
[
'force_display' => true,
'class' => 'wu-rounded-full wu-mr-3',
)
]
);
$search_result = array_merge((array) $user->data, $search_result);
@ -730,7 +730,7 @@ class Customer extends Base_Model {
* @options customer
* @return void
*/
public function set_type($type) {
public function set_type($type): void {
$this->type = $type;
}
@ -832,10 +832,10 @@ class Customer extends Base_Model {
}
return add_query_arg(
array(
[
'email-verification-key' => $key,
'customer' => $this->get_hash(),
),
],
get_site_url(wu_get_main_site_id())
);
}
@ -846,12 +846,12 @@ class Customer extends Base_Model {
* @since 2.0.4
* @return void
*/
public function send_verification_email() {
public function send_verification_email(): void {
$this->generate_verification_key();
$payload = array_merge(
array('verification_link' => $this->get_verification_url()),
['verification_link' => $this->get_verification_url()],
wu_generate_event_payload('customer', $this)
);
@ -876,7 +876,7 @@ class Customer extends Base_Model {
* @param string $signup_form The form used to signup.
* @return void
*/
public function set_signup_form($signup_form) {
public function set_signup_form($signup_form): void {
$this->signup_form = $signup_form;
}

View File

@ -157,7 +157,7 @@ class Discount_Code extends Base_Model {
* @since 2.0.0
* @var string
*/
protected $query_class = '\\WP_Ultimo\\Database\\Discount_Codes\\Discount_Code_Query';
protected $query_class = \WP_Ultimo\Database\Discount_Codes\Discount_Code_Query::class;
/**
* Set the validation rules for this particular model.
@ -171,7 +171,7 @@ class Discount_Code extends Base_Model {
*/
public function validation_rules() {
return array(
return [
'name' => 'required|min:2',
'code' => 'required|min:2|max:20|alpha_dash',
'uses' => 'integer|default:0',
@ -184,7 +184,7 @@ class Discount_Code extends Base_Model {
'setup_fee_value' => 'numeric',
'allowed_products' => 'array',
'limit_products' => 'default:0',
);
];
}
/**
@ -205,7 +205,7 @@ class Discount_Code extends Base_Model {
* @param string $name Your discount code name, which is used as discount code title as well.
* @return void
*/
public function set_name($name) {
public function set_name($name): void {
$this->name = $name;
}
@ -228,7 +228,7 @@ class Discount_Code extends Base_Model {
* @param string $code A unique identification to redeem the discount code. E.g. PROMO10.
* @return void
*/
public function set_code($code) {
public function set_code($code): void {
$this->code = $code;
}
@ -251,7 +251,7 @@ class Discount_Code extends Base_Model {
* @param string $description A description for the discount code, usually a short text.
* @return void
*/
public function set_description($description) {
public function set_description($description): void {
$this->description = $description;
}
@ -274,7 +274,7 @@ class Discount_Code extends Base_Model {
* @param int $uses Number of times this discount was applied.
* @return void
*/
public function set_uses($uses) {
public function set_uses($uses): void {
$this->uses = (int) $uses;
}
@ -286,7 +286,7 @@ class Discount_Code extends Base_Model {
* @param integer $uses Number of uses to add.
* @return void
*/
public function add_use($uses = 1) {
public function add_use($uses = 1): void {
$use_count = (int) $this->get_uses();
@ -311,7 +311,7 @@ class Discount_Code extends Base_Model {
* @param int $max_uses The number of times this discount can be used before becoming inactive.
* @return void
*/
public function set_max_uses($max_uses) {
public function set_max_uses($max_uses): void {
$this->max_uses = (int) $max_uses;
}
@ -345,7 +345,7 @@ class Discount_Code extends Base_Model {
* @param bool $apply_to_renewals Wether or not we should apply the discount to membership renewals.
* @return void
*/
public function set_apply_to_renewals($apply_to_renewals) {
public function set_apply_to_renewals($apply_to_renewals): void {
$this->apply_to_renewals = (bool) $apply_to_renewals;
}
@ -369,7 +369,7 @@ class Discount_Code extends Base_Model {
* @options percentage,absolute
* @return void
*/
public function set_type($type) {
public function set_type($type): void {
$this->type = $type;
}
@ -392,7 +392,7 @@ class Discount_Code extends Base_Model {
* @param int $value Amount discounted in cents.
* @return void
*/
public function set_value($value) {
public function set_value($value): void {
$this->value = $value;
}
@ -416,7 +416,7 @@ class Discount_Code extends Base_Model {
* @options percentage,absolute
* @return void
*/
public function set_setup_fee_type($setup_fee_type) {
public function set_setup_fee_type($setup_fee_type): void {
$this->setup_fee_type = $setup_fee_type;
}
@ -439,7 +439,7 @@ class Discount_Code extends Base_Model {
* @param int $setup_fee_value Amount discounted for setup fees in cents.
* @return void
*/
public function set_setup_fee_value($setup_fee_value) {
public function set_setup_fee_value($setup_fee_value): void {
$this->setup_fee_value = $setup_fee_value;
}
@ -540,7 +540,7 @@ class Discount_Code extends Base_Model {
* @param bool $active Set this discount code as active (true), which means available to be used, or inactive (false).
* @return void
*/
public function set_active($active) {
public function set_active($active): void {
$this->active = (bool) $active;
}
@ -567,7 +567,7 @@ class Discount_Code extends Base_Model {
* @param string $date_start Start date for the coupon code to be considered valid.
* @return void
*/
public function set_date_start($date_start) {
public function set_date_start($date_start): void {
$this->date_start = $date_start;
}
@ -594,7 +594,7 @@ class Discount_Code extends Base_Model {
* @param string $date_expiration Expiration date for the coupon code.
* @return void
*/
public function set_date_expiration($date_expiration) {
public function set_date_expiration($date_expiration): void {
$this->date_expiration = $date_expiration;
}
@ -617,7 +617,7 @@ class Discount_Code extends Base_Model {
* @param string $date_created Date when this discount code was created.
* @return void
*/
public function set_date_created($date_created) {
public function set_date_created($date_created): void {
$this->date_created = $date_created;
}
@ -628,7 +628,7 @@ class Discount_Code extends Base_Model {
*/
public function get_discount_description(): string {
$description = array();
$description = [];
if ($this->get_value() > 0) {
$value = wu_format_currency($this->get_value());
@ -694,7 +694,7 @@ class Discount_Code extends Base_Model {
$compat_coupon = $this;
do_action_deprecated('wp_ultimo_coupon_after_save', array($compat_coupon), '2.0.0', 'wu_discount_code_post_save');
do_action_deprecated('wp_ultimo_coupon_after_save', [$compat_coupon], '2.0.0', 'wu_discount_code_post_save');
}
return $results;
@ -709,7 +709,7 @@ class Discount_Code extends Base_Model {
public function get_allowed_products() {
if ($this->allowed_products === null) {
$this->allowed_products = $this->get_meta('wu_allowed_products', array());
$this->allowed_products = $this->get_meta('wu_allowed_products', []);
}
return (array) $this->allowed_products;
@ -722,7 +722,7 @@ class Discount_Code extends Base_Model {
* @param array $allowed_products The list of products that allows this discount code to be used. If empty, all products will accept this code.
* @return void
*/
public function set_allowed_products($allowed_products) {
public function set_allowed_products($allowed_products): void {
$this->meta['wu_allowed_products'] = (array) $allowed_products;
@ -751,7 +751,7 @@ class Discount_Code extends Base_Model {
* @param bool $limit_products This discount code will be limited to be used in certain products? If set to true, you must define a list of allowed products.
* @return void
*/
public function set_limit_products($limit_products) {
public function set_limit_products($limit_products): void {
$this->meta['wu_limit_products'] = (bool) $limit_products;

View File

@ -90,11 +90,11 @@ class Domain extends Base_Model {
* @since 2.0.0
* @var array
*/
const INACTIVE_STAGES = array(
const INACTIVE_STAGES = [
'checking-dns',
'checking-ssl-cert',
'failed',
);
];
/**
* Query Class to the static query methods.
@ -102,7 +102,7 @@ class Domain extends Base_Model {
* @since 2.0.0
* @var string
*/
protected $query_class = '\\WP_Ultimo\\Database\\Domains\\Domain_Query';
protected $query_class = \WP_Ultimo\Database\Domains\Domain_Query::class;
/**
* Set the validation rules for this particular model.
@ -118,14 +118,14 @@ class Domain extends Base_Model {
$id = $this->get_id();
return array(
return [
'blog_id' => 'required|integer',
'domain' => "required|domain|unique:\WP_Ultimo\Models\Domain,domain,{$id}",
'stage' => 'required|in:checking-dns,checking-ssl-cert,done-without-ssl,done,failed|default:checking-dns',
'active' => 'default:1',
'secure' => 'default:0',
'primary_domain' => 'default:0',
);
];
}
/**
@ -147,7 +147,7 @@ class Domain extends Base_Model {
* @param string $domain Your Domain name. You don't need to put http or https in front of your domain in this field. e.g: example.com.
* @return void
*/
public function set_domain($domain) {
public function set_domain($domain): void {
$this->domain = strtolower($domain);
}
@ -185,7 +185,7 @@ class Domain extends Base_Model {
* @param int $blog_id The blog ID attached to this domain.
* @return void
*/
public function set_blog_id($blog_id) {
public function set_blog_id($blog_id): void {
$this->blog_id = $blog_id;
}
@ -245,7 +245,7 @@ class Domain extends Base_Model {
* @param boolean $active Set this domain as active (true), which means available to be used, or inactive (false).
* @return void
*/
public function set_active($active) {
public function set_active($active): void {
$this->active = $active;
}
@ -269,7 +269,7 @@ class Domain extends Base_Model {
* @param boolean $primary_domain Define true to set this as primary domain of a site, meaning it's the main url, or set false.
* @return void
*/
public function set_primary_domain($primary_domain) {
public function set_primary_domain($primary_domain): void {
$this->primary_domain = $primary_domain;
}
@ -293,7 +293,7 @@ class Domain extends Base_Model {
* @param boolean $secure If this domain has some SSL security or not.
* @return void
*/
public function set_secure($secure) {
public function set_secure($secure): void {
$this->secure = $secure;
}
@ -319,7 +319,7 @@ class Domain extends Base_Model {
* @param string $stage The state of the domain model object. Can be one of this options: checking-dns, checking-ssl-cert, done-without-ssl, done and failed.
* @return void
*/
public function set_stage($stage) {
public function set_stage($stage): void {
$this->stage = $stage;
}
@ -377,7 +377,7 @@ class Domain extends Base_Model {
* @param string $date_created Date when the domain was created. If no date is set, the current date and time will be used.
* @return void
*/
public function set_date_created($date_created) {
public function set_date_created($date_created): void {
$this->date_created = $date_created;
}
@ -456,9 +456,9 @@ class Domain extends Base_Model {
if (is_wp_error($results) === false) {
if ($new_domain) {
if (has_action('mercator.mapping.created')) {
$deprecated_args = array(
$deprecated_args = [
$this,
);
];
/**
* Deprecated: Mercator created domain.
@ -471,10 +471,10 @@ class Domain extends Base_Model {
do_action_deprecated('mercator.mapping.created', $deprecated_args, '2.0.0', 'wu_domain_post_save');
}
} elseif (has_action('mercator.mapping.updated')) {
$deprecated_args = array(
$deprecated_args = [
$this,
$before_changes,
);
];
/**
* Deprecated: Mercator updated domain.
@ -509,9 +509,9 @@ class Domain extends Base_Model {
$results = parent::delete();
if (is_wp_error($results) === false && has_action('mercator.mapping.deleted')) {
$deprecated_args = array(
$deprecated_args = [
$this,
);
];
/**
* Deprecated: Mercator Deleted domain.

View File

@ -36,7 +36,7 @@ class Email extends Post_Base_Model {
* @access public
* @var mixed
*/
protected $query_class = '\\WP_Ultimo\\Database\\Emails\\Email_Query';
protected $query_class = \WP_Ultimo\Database\Emails\Email_Query::class;
/**
* Post type.
@ -52,7 +52,7 @@ class Email extends Post_Base_Model {
* @since 2.0.0
* @var array
*/
protected $allowed_types = array('system_email');
protected $allowed_types = ['system_email'];
/**
* Email slug.
@ -68,7 +68,7 @@ class Email extends Post_Base_Model {
* @since 2.0.0
* @var string
*/
protected $allowed_status = array('publish', 'draft');
protected $allowed_status = ['publish', 'draft'];
/**
* If this email is going to be send later.
@ -142,7 +142,7 @@ class Email extends Post_Base_Model {
*/
public function validation_rules() {
return array(
return [
'schedule' => 'boolean|default:0',
'type' => 'in:system_email|default:system_email',
'event' => 'required|default:',
@ -159,7 +159,7 @@ class Email extends Post_Base_Model {
'send_copy_to_admin' => 'boolean|default:0',
'active' => 'default:1',
'legacy' => 'boolean|default:0',
);
];
}
/**
@ -233,7 +233,7 @@ class Email extends Post_Base_Model {
* @options html,plain-text
* @return void
*/
public function set_style($style) {
public function set_style($style): void {
$this->style = $style;
@ -262,7 +262,7 @@ class Email extends Post_Base_Model {
* @param bool $schedule Whether or not this is a scheduled email.
* @return void
*/
public function set_schedule($schedule) {
public function set_schedule($schedule): void {
$this->schedule = $schedule;
@ -398,7 +398,7 @@ class Email extends Post_Base_Model {
* @param string $event The event that needs to be fired for this email to be sent.
* @return void
*/
public function set_event($event) {
public function set_event($event): void {
$this->event = $event;
@ -413,7 +413,7 @@ class Email extends Post_Base_Model {
* @param string $email_schedule if the send will be schedule.
* @return void
*/
public function set_email_schedule($email_schedule) {
public function set_email_schedule($email_schedule): void {
$this->meta['system_email_schedule'] = $email_schedule;
}
@ -426,7 +426,7 @@ class Email extends Post_Base_Model {
* @param string $send_hours The amount of hours that the email will wait before is sent.
* @return void
*/
public function set_send_hours($send_hours) {
public function set_send_hours($send_hours): void {
$this->meta['system_email_send_hours'] = $send_hours;
}
@ -439,7 +439,7 @@ class Email extends Post_Base_Model {
* @param string $send_days The amount of days that the email will wait before is sent.
* @return void
*/
public function set_send_days($send_days) {
public function set_send_days($send_days): void {
$this->meta['system_email_send_days'] = $send_days;
}
@ -453,7 +453,7 @@ class Email extends Post_Base_Model {
* @options days,hours
* @return void
*/
public function set_schedule_type($schedule_type) {
public function set_schedule_type($schedule_type): void {
$this->meta['system_email_schedule_type'] = $schedule_type;
}
@ -466,7 +466,7 @@ class Email extends Post_Base_Model {
* @param string $name The name being set as title.
* @return void
*/
public function set_name($name) {
public function set_name($name): void {
$this->set_title($name);
}
@ -479,7 +479,7 @@ class Email extends Post_Base_Model {
* @param string $slug The slug being set.
* @return void
*/
public function set_slug($slug) {
public function set_slug($slug): void {
$this->slug = $slug;
}
@ -492,7 +492,7 @@ class Email extends Post_Base_Model {
* @param boolean $custom_sender If has a custom sender.
* @return void
*/
public function set_custom_sender($custom_sender) {
public function set_custom_sender($custom_sender): void {
$this->meta['system_email_custom_sender'] = $custom_sender;
}
@ -505,7 +505,7 @@ class Email extends Post_Base_Model {
* @param string $custom_sender_name The name of the custom sender. E.g. From: John Doe.
* @return void
*/
public function set_custom_sender_name($custom_sender_name) {
public function set_custom_sender_name($custom_sender_name): void {
$this->meta['system_email_custom_sender_name'] = $custom_sender_name;
}
@ -518,7 +518,7 @@ class Email extends Post_Base_Model {
* @param string $custom_sender_email The email of the custom sender. E.g. From: johndoe@gmail.com.
* @return void
*/
public function set_custom_sender_email($custom_sender_email) {
public function set_custom_sender_email($custom_sender_email): void {
$this->meta['system_email_custom_sender_email'] = $custom_sender_email;
}
@ -546,7 +546,7 @@ class Email extends Post_Base_Model {
* @options customer,admin
* @return void
*/
public function set_target($target) {
public function set_target($target): void {
$this->target = $target;
@ -561,9 +561,9 @@ class Email extends Post_Base_Model {
* @param array $payload The payload of the email being sent. Used to get the customer id.
* @return array
*/
public function get_target_list($payload = array()) {
public function get_target_list($payload = []) {
$target_list = array();
$target_list = [];
$target_type = $this->get_target();
@ -571,19 +571,19 @@ class Email extends Post_Base_Model {
$target_list = self::get_super_admin_targets();
} elseif ($target_type === 'customer') {
if ( ! wu_get_isset($payload, 'customer_id')) {
return array();
return [];
}
$customer = wu_get_customer($payload['customer_id']);
if ( ! $customer) {
return array();
return [];
}
$target_list[] = array(
$target_list[] = [
'name' => $customer->get_display_name(),
'email' => $customer->get_email_address(),
);
];
/*
* Maybe ad super admins as well.
@ -606,7 +606,7 @@ class Email extends Post_Base_Model {
*/
public static function get_super_admin_targets() {
$target_list = array();
$target_list = [];
$super_admins = get_super_admins();
@ -614,10 +614,10 @@ class Email extends Post_Base_Model {
$user = get_user_by('login', $super_admin);
if ($user) {
$target_list[] = array(
$target_list[] = [
'name' => $user->display_name,
'email' => $user->user_email,
);
];
}
}
@ -646,7 +646,7 @@ class Email extends Post_Base_Model {
* @param boolean $send_copy_to_admin Checks if we should send a copy of the email to the admin.
* @return void
*/
public function set_send_copy_to_admin($send_copy_to_admin) {
public function set_send_copy_to_admin($send_copy_to_admin): void {
$this->send_copy_to_admin = $send_copy_to_admin;
@ -675,7 +675,7 @@ class Email extends Post_Base_Model {
* @param bool $active Set this email as active (true), which means available will fire when the event occur, or inactive (false).
* @return void
*/
public function set_active($active) {
public function set_active($active): void {
$this->active = $active;
@ -704,7 +704,7 @@ class Email extends Post_Base_Model {
* @param bool $legacy Whether or not this is a legacy email.
* @return void
*/
public function set_legacy($legacy) {
public function set_legacy($legacy): void {
$this->legacy = $legacy;

View File

@ -107,7 +107,7 @@ class Event extends Base_Model {
* @since 2.0.0
* @var string
*/
protected $query_class = '\\WP_Ultimo\\Database\\Events\\Event_Query';
protected $query_class = \WP_Ultimo\Database\Events\Event_Query::class;
/**
* Set the validation rules for this particular model.
@ -121,7 +121,7 @@ class Event extends Base_Model {
*/
public function validation_rules() {
return array(
return [
'severity' => 'required|numeric|between:1,5',
'payload' => 'required',
'object_type' => 'required|alpha_dash|lowercase',
@ -129,7 +129,7 @@ class Event extends Base_Model {
'author_id' => 'integer|default:0',
'slug' => 'required|alpha_dash',
'initiator' => 'required|in:system,manual',
);
];
}
/**
@ -151,15 +151,15 @@ class Event extends Base_Model {
*/
public function get_severity_label() {
$labels = array(
$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'),
);
];
return isset($labels[ $this->get_severity() ]) ? $labels[ $this->get_severity() ] : __('Note', 'wp-ultimo');
return $labels[ $this->get_severity() ] ?? __('Note', 'wp-ultimo');
}
/**
@ -170,15 +170,15 @@ class Event extends Base_Model {
*/
public function get_severity_class() {
$classes = array(
$classes = [
self::SEVERITY_SUCCESS => 'wu-bg-green-200 wu-text-green-700',
self::SEVERITY_NEUTRAL => 'wu-bg-gray-200 wu-text-gray-700',
self::SEVERITY_INFO => 'wu-bg-blue-200 wu-text-blue-700',
self::SEVERITY_WARNING => 'wu-bg-yellow-200 wu-text-yellow-700',
self::SEVERITY_FATAL => 'wu-bg-red-200 wu-text-red-700',
);
];
return isset($classes[ $this->get_severity() ]) ? $classes[ $this->get_severity() ] : '';
return $classes[ $this->get_severity() ] ?? '';
}
/**
@ -188,7 +188,7 @@ class Event extends Base_Model {
* @param int $severity Severity of the problem.
* @return void
*/
public function set_severity($severity) {
public function set_severity($severity): void {
$this->severity = $severity;
}
@ -211,7 +211,7 @@ class Event extends Base_Model {
* @param string $date_created Date when the event was created.
* @return void
*/
public function set_date_created($date_created) {
public function set_date_created($date_created): void {
$this->date_created = $date_created;
}
@ -236,7 +236,7 @@ class Event extends Base_Model {
* @param object $payload Payload of the event.
* @return void
*/
public function set_payload($payload) {
public function set_payload($payload): void {
$this->payload = $payload;
}
@ -265,7 +265,7 @@ class Event extends Base_Model {
$payload = json_decode(json_encode($payload), true);
$interpolation_keys = array();
$interpolation_keys = [];
foreach ($payload as $key => &$value) {
$interpolation_keys[] = "{{{$key}}}";
@ -296,7 +296,7 @@ class Event extends Base_Model {
*/
public static function get_default_system_messages($slug) {
$default_messages = array();
$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');
@ -326,7 +326,7 @@ class Event extends Base_Model {
* @param string $initiator The type of user responsible for initiating the event. There are two options: Manual and System. By default, the event is saved as manual.
* @return void
*/
public function set_initiator($initiator) {
public function set_initiator($initiator): void {
$this->initiator = $initiator;
}
@ -396,7 +396,7 @@ class Event extends Base_Model {
* @param int $author_id The user responsible for creating the event. By default, the event is saved with the current user_id.
* @return void
*/
public function set_author_id($author_id) {
public function set_author_id($author_id): void {
$this->author_id = $author_id;
}
@ -518,7 +518,7 @@ class Event extends Base_Model {
* @param string $object_type The type of object related to this event. It's usually the model name.
* @return void
*/
public function set_object_type($object_type) {
public function set_object_type($object_type): void {
$this->object_type = $object_type;
}
@ -541,7 +541,7 @@ class Event extends Base_Model {
* @param string $slug The event slug. It needs to be unique and preferably make it clear what it is about. Example: account_created is about creating an account.
* @return void
*/
public function set_slug($slug) {
public function set_slug($slug): void {
$this->slug = $slug;
}
@ -564,7 +564,7 @@ class Event extends Base_Model {
* @param int $object_id The ID of the related objects.
* @return void
*/
public function set_object_id($object_id) {
public function set_object_id($object_id): void {
$this->object_id = $object_id;
}
@ -587,7 +587,7 @@ class Event extends Base_Model {
$array['severity_classes'] = $this->get_severity_class();
$array['author'] = array();
$array['author'] = [];
if ($this->get_initiator() === 'manual') {
$user = get_user_by('ID', $this->get_author_id());
@ -600,9 +600,9 @@ class Event extends Base_Model {
$array['author']['avatar'] = get_avatar_url(
$this->get_author_id(),
array(
[
'default' => 'identicon',
)
]
);
}
}

View File

@ -60,7 +60,7 @@ class Membership extends Base_Model {
* @since 2.0.0
* @var array
*/
protected $addon_products = array();
protected $addon_products = [];
/**
* Currency for this membership. 3-letter currency code.
@ -290,7 +290,7 @@ class Membership extends Base_Model {
* @since 2.0.10
* @var array
*/
protected $_compiled_product_list = array();
protected $_compiled_product_list = [];
/**
* Keep original gateway info.
@ -302,7 +302,7 @@ class Membership extends Base_Model {
* @since 2.0.15
* @var array
*/
protected $_gateway_info = array();
protected $_gateway_info = [];
/**
* Query Class to the static query methods.
@ -310,7 +310,7 @@ class Membership extends Base_Model {
* @since 2.0.0
* @var string
*/
protected $query_class = '\\WP_Ultimo\\Database\\Memberships\\Membership_Query';
protected $query_class = \WP_Ultimo\Database\Memberships\Membership_Query::class;
/**
* Constructs the object via the constructor arguments
@ -323,11 +323,11 @@ class Membership extends Base_Model {
parent::__construct($object);
$this->_gateway_info = array(
$this->_gateway_info = [
'gateway' => $this->get_gateway(),
'gateway_customer_id' => $this->get_gateway_customer_id(),
'gateway_subscription_id' => $this->get_gateway_subscription_id(),
);
];
if (did_action('plugins_loaded')) {
$this->_compiled_product_list = $this->get_all_products();
@ -352,7 +352,7 @@ class Membership extends Base_Model {
$membership_status = $membership_status->get_allowed_list(true);
return array(
return [
'customer_id' => 'required|integer|exists:\WP_Ultimo\Models\Customer,id',
'user_id' => 'integer',
'plan_id' => 'required|integer|exists:\WP_Ultimo\Models\Product,id',
@ -371,7 +371,7 @@ class Membership extends Base_Model {
'signup_method' => 'default:',
'disabled' => 'default:0',
'recurring' => 'default:0',
);
];
}
/**
@ -404,7 +404,7 @@ class Membership extends Base_Model {
* @param int $customer_id The ID of the customer attached to this membership.
* @return void
*/
public function set_customer_id($customer_id) {
public function set_customer_id($customer_id): void {
$this->customer_id = absint($customer_id);
}
@ -452,7 +452,7 @@ class Membership extends Base_Model {
* @param int $user_id The user ID attached to this membership.
* @return void
*/
public function set_user_id($user_id) {
public function set_user_id($user_id): void {
$this->user_id = absint($user_id);
}
@ -482,7 +482,7 @@ class Membership extends Base_Model {
if ($plan && ($plan->get_duration() !== $this->get_duration() || $plan->get_duration_unit() !== $this->get_duration_unit())) {
$variation = $plan->get_as_variation($this->get_duration(), $this->get_duration_unit());
$plan = ($variation ? $variation : null) ?? $plan;
$plan = ($variation ?: null) ?? $plan;
}
return $plan;
@ -495,7 +495,7 @@ class Membership extends Base_Model {
* @param int $plan_id The plan ID associated with the membership.
* @return void
*/
public function set_plan_id($plan_id) {
public function set_plan_id($plan_id): void {
$this->plan_id = absint($plan_id);
}
@ -553,7 +553,7 @@ class Membership extends Base_Model {
* @param integer $quantity The quantity.
* @return void
*/
public function add_product($product_id, $quantity = 1) {
public function add_product($product_id, $quantity = 1): void {
$has_product = wu_get_isset($this->addon_products, $product_id);
@ -577,7 +577,7 @@ class Membership extends Base_Model {
* @param integer $quantity The quantity to remove.
* @return void
*/
public function remove_product($product_id, $quantity = 1) {
public function remove_product($product_id, $quantity = 1): void {
$has_product = wu_get_isset($this->addon_products, $product_id);
@ -598,9 +598,9 @@ class Membership extends Base_Model {
*/
public function get_addon_products() {
$products = array();
$products = [];
$this->addon_products = is_array($this->addon_products) ? $this->addon_products : array();
$this->addon_products = is_array($this->addon_products) ? $this->addon_products : [];
foreach ($this->addon_products as $product_id => $quantity) {
$product = wu_get_product($product_id);
@ -609,10 +609,10 @@ class Membership extends Base_Model {
continue;
}
$products[] = array(
$products[] = [
'quantity' => $quantity,
'product' => $product,
);
];
}
return $products;
@ -626,12 +626,12 @@ class Membership extends Base_Model {
*/
public function get_all_products() {
$products = array(
array(
$products = [
[
'quantity' => 1,
'product' => $this->get_plan(),
),
);
],
];
return array_merge($products, $this->get_addon_products());
}
@ -643,7 +643,7 @@ class Membership extends Base_Model {
* @param mixed $addon_products Additional products related to this membership. Services, Packages or other types of products.
* @return void
*/
public function set_addon_products($addon_products) {
public function set_addon_products($addon_products): void {
$this->addon_products = maybe_unserialize($addon_products);
}
@ -673,7 +673,7 @@ class Membership extends Base_Model {
}
// clear the current addons.
$this->addon_products = array();
$this->addon_products = [];
/*
* We'll do that based on the line items,
@ -761,9 +761,9 @@ class Membership extends Base_Model {
*/
wu_unschedule_action(
'wu_async_membership_swap',
array(
[
'membership_id' => $this->get_id(),
),
],
'membership'
);
@ -773,9 +773,9 @@ class Membership extends Base_Model {
return wu_schedule_single_action(
$date_instance->format('U'),
'wu_async_membership_swap',
array(
[
'membership_id' => $this->get_id(),
),
],
'membership'
);
}
@ -798,10 +798,10 @@ class Membership extends Base_Model {
return false;
}
return (object) array(
return (object) [
'order' => $order,
'scheduled_date' => $scheduled_date,
);
];
}
/**
@ -810,7 +810,7 @@ class Membership extends Base_Model {
* @since 2.0.0
* @return void
*/
public function delete_scheduled_swap() {
public function delete_scheduled_swap(): void {
$this->delete_meta('wu_swap_order');
@ -861,7 +861,7 @@ class Membership extends Base_Model {
*/
public function get_price_description(): string {
$pricing = array();
$pricing = [];
if ($this->is_recurring()) {
$duration = $this->get_duration();
@ -919,7 +919,7 @@ class Membership extends Base_Model {
* @param string $currency The currency that this membership. It's a 3-letter code. E.g. 'USD'.
* @return void
*/
public function set_currency($currency) {
public function set_currency($currency): void {
$this->currency = $currency;
}
@ -939,7 +939,7 @@ class Membership extends Base_Model {
*
* @param int $duration The interval period between a charge. Only the interval amount, the unit will be defined in another property.
*/
public function set_duration($duration) {
public function set_duration($duration): void {
$this->duration = absint($duration);
}
@ -959,7 +959,7 @@ class Membership extends Base_Model {
*
* @param string $duration_unit The duration amount type. Can be 'day', 'week', 'month' or 'year'.
*/
public function set_duration_unit($duration_unit) {
public function set_duration_unit($duration_unit): void {
$this->duration_unit = $duration_unit;
}
@ -1000,7 +1000,7 @@ class Membership extends Base_Model {
*
* @param float $amount The product amount.
*/
public function set_amount($amount) {
public function set_amount($amount): void {
$this->amount = wu_to_float($amount);
}
@ -1020,7 +1020,7 @@ class Membership extends Base_Model {
*
* @param float $initial_amount The initial amount charged for this membership, including the setup fee.
*/
public function set_initial_amount($initial_amount) {
public function set_initial_amount($initial_amount): void {
$this->initial_amount = wu_to_float($initial_amount);
}
@ -1043,7 +1043,7 @@ class Membership extends Base_Model {
* @param string $date_created Date of creation of this membership.
* @return void
*/
public function set_date_created($date_created) {
public function set_date_created($date_created): void {
$this->date_created = $date_created;
}
@ -1066,7 +1066,7 @@ class Membership extends Base_Model {
* @param string $date_activated Date when this membership was activated.
* @return void
*/
public function set_date_activated($date_activated) {
public function set_date_activated($date_activated): void {
$this->date_activated = $date_activated;
}
@ -1089,7 +1089,7 @@ class Membership extends Base_Model {
* @param string $date_trial_end Date when the trial period ends, if this membership has or had a trial period.
* @return void
*/
public function set_date_trial_end($date_trial_end) {
public function set_date_trial_end($date_trial_end): void {
$this->date_trial_end = $date_trial_end;
}
@ -1112,7 +1112,7 @@ class Membership extends Base_Model {
* @param string $date_renewed Date when the membership was cancelled.
* @return void
*/
public function set_date_renewed($date_renewed) {
public function set_date_renewed($date_renewed): void {
$this->date_renewed = $date_renewed;
}
@ -1135,7 +1135,7 @@ class Membership extends Base_Model {
* @param string $date_cancellation Date when the membership was cancelled.
* @return void
*/
public function set_date_cancellation($date_cancellation) {
public function set_date_cancellation($date_cancellation): void {
$this->date_cancellation = $date_cancellation;
}
@ -1166,7 +1166,7 @@ class Membership extends Base_Model {
* @param string $reason The reason to cancel the membership.
* @return void
*/
public function set_cancellation_reason($reason) {
public function set_cancellation_reason($reason): void {
$this->meta['cancellation_reason'] = $reason;
$this->cancellation_reason = $reason;
@ -1190,7 +1190,7 @@ class Membership extends Base_Model {
* @param string $date_expiration Date when the membership will expiry.
* @return void
*/
public function set_date_expiration($date_expiration) {
public function set_date_expiration($date_expiration): void {
$this->date_expiration = $date_expiration;
}
@ -1233,7 +1233,7 @@ class Membership extends Base_Model {
$expire_timestamp = strtotime('+' . $this->get_duration() . ' ' . $this->get_duration_unit() . ' 23:59:59', $base_timestamp);
}
$extension_days = array('29', '30', '31');
$extension_days = ['29', '30', '31'];
if (in_array(gmdate('j', $expire_timestamp), $extension_days, true) && 'month' === $this->get_duration_unit()) {
$month = gmdate('n', $expire_timestamp);
@ -1289,7 +1289,7 @@ class Membership extends Base_Model {
* @param string $date_payment_plan_completed Change of the payment completion for the plan value.
* @return void
*/
public function set_date_payment_plan_completed($date_payment_plan_completed) {
public function set_date_payment_plan_completed($date_payment_plan_completed): void {
$this->date_payment_plan_completed = $date_payment_plan_completed;
}
@ -1325,7 +1325,7 @@ class Membership extends Base_Model {
* @param bool $auto_renew If this membership should auto-renewal.
* @return void
*/
public function set_auto_renew($auto_renew) {
public function set_auto_renew($auto_renew): void {
$this->auto_renew = (bool) $auto_renew;
}
@ -1344,12 +1344,12 @@ class Membership extends Base_Model {
// Get discount code from original payment for compatibility
if (empty($this->discount_code) && ! $this->get_meta('verified_payment_discount')) {
$original_payment = wu_get_payments(
array(
[
'number' => 1,
'membership_id' => $this->get_id(),
'orderby' => 'id',
'order' => 'ASC',
)
]
);
if (isset($original_payment[0])) {
@ -1375,7 +1375,7 @@ class Membership extends Base_Model {
* @param string|WP_Ultimo\Models\Discount_Code $discount_code Discount code object.
* @return void
*/
public function set_discount_code($discount_code) {
public function set_discount_code($discount_code): void {
if (is_a($discount_code, '\WP_Ultimo\Models\Discount_Code')) {
$this->meta['discount_code'] = $discount_code;
@ -1412,7 +1412,7 @@ class Membership extends Base_Model {
* @param int $times_billed Amount of times this membership got billed.
* @return void
*/
public function set_times_billed($times_billed) {
public function set_times_billed($times_billed): void {
$this->times_billed = $times_billed;
}
@ -1481,7 +1481,7 @@ class Membership extends Base_Model {
* @param int $billing_cycles Maximum times we should charge this membership.
* @return void
*/
public function set_billing_cycles($billing_cycles) {
public function set_billing_cycles($billing_cycles): void {
$this->billing_cycles = $billing_cycles;
}
@ -1516,10 +1516,10 @@ class Membership extends Base_Model {
*/
public function is_active() {
$active_statuses = array(
$active_statuses = [
Membership_Status::ACTIVE,
Membership_Status::ON_HOLD,
);
];
$active = in_array($this->status, $active_statuses, true);
@ -1545,7 +1545,7 @@ class Membership extends Base_Model {
* @options \WP_Ultimo\Database\Payments\Payment_Status
* @return void
*/
public function set_status($status) {
public function set_status($status): void {
$this->status = $status;
}
@ -1594,7 +1594,7 @@ class Membership extends Base_Model {
* @param string $gateway_customer_id The ID of the customer on the payment gateway database.
* @return void
*/
public function set_gateway_customer_id($gateway_customer_id) {
public function set_gateway_customer_id($gateway_customer_id): void {
$this->gateway_customer_id = $gateway_customer_id;
}
@ -1617,7 +1617,7 @@ class Membership extends Base_Model {
* @param string $gateway_subscription_id The ID of the subscription on the payment gateway database.
* @return void
*/
public function set_gateway_subscription_id($gateway_subscription_id) {
public function set_gateway_subscription_id($gateway_subscription_id): void {
$this->gateway_subscription_id = $gateway_subscription_id;
}
@ -1640,7 +1640,7 @@ class Membership extends Base_Model {
* @param string $gateway ID of the gateway being used on this subscription.
* @return void
*/
public function set_gateway($gateway) {
public function set_gateway($gateway): void {
$this->gateway = $gateway;
}
@ -1663,7 +1663,7 @@ class Membership extends Base_Model {
* @param string $signup_method Signup method used to create this membership.
* @return void
*/
public function set_signup_method($signup_method) {
public function set_signup_method($signup_method): void {
$this->signup_method = $signup_method;
}
@ -1686,7 +1686,7 @@ class Membership extends Base_Model {
* @param int $upgraded_from Plan that this membership upgraded from.
* @return void
*/
public function set_upgraded_from($upgraded_from) {
public function set_upgraded_from($upgraded_from): void {
$this->upgraded_from = $upgraded_from;
}
@ -1709,7 +1709,7 @@ class Membership extends Base_Model {
* @param string $date_modified Date this membership was last modified.
* @return void
*/
public function set_date_modified($date_modified) {
public function set_date_modified($date_modified): void {
$this->date_modified = $date_modified;
}
@ -1732,7 +1732,7 @@ class Membership extends Base_Model {
* @param bool $disabled If this membership is a disabled one.
* @return void
*/
public function set_disabled($disabled) {
public function set_disabled($disabled): void {
$this->disabled = (bool) $disabled;
}
@ -1744,13 +1744,13 @@ class Membership extends Base_Model {
* @param array $query Query arguments.
* @return array
*/
public function get_payments($query = array()) {
public function get_payments($query = []) {
$query = array_merge(
$query,
array(
[
'membership_id' => $this->get_id(),
)
]
);
return wu_get_payments($query);
@ -1764,14 +1764,14 @@ class Membership extends Base_Model {
public function get_last_pending_payment() {
$payments = wu_get_payments(
array(
[
'membership_id' => $this->get_id(),
'status' => 'pending',
'number' => 1,
'orderby' => 'id',
'order' => 'DESC',
'gateway_payment_id' => '',
)
]
);
return ! empty($payments) ? array_pop($payments) : false;
@ -1786,14 +1786,14 @@ class Membership extends Base_Model {
public function get_published_sites() {
$sites = Site::query(
array(
'meta_query' => array(
'customer_id' => array(
[
'meta_query' => [
'customer_id' => [
'key' => 'wu_membership_id',
'value' => $this->get_id(),
),
),
)
],
],
]
);
return $sites;
@ -1809,14 +1809,14 @@ class Membership extends Base_Model {
public function get_sites($include_pending = true) {
$sites = Site::query(
array(
'meta_query' => array(
'customer_id' => array(
[
'meta_query' => [
'customer_id' => [
'key' => 'wu_membership_id',
'value' => $this->get_id(),
),
),
)
],
],
]
);
$pending_site = $include_pending ? $this->get_pending_site() : false;
@ -1844,13 +1844,13 @@ class Membership extends Base_Model {
$site_info = wp_parse_args(
$site_info,
array(
[
'title' => '',
'domain' => $current_site->domain,
'path' => '',
'transient' => array(),
'transient' => [],
'is_publishing' => false,
)
]
);
$site = new \WP_Ultimo\Models\Site($site_info);
@ -1887,7 +1887,7 @@ class Membership extends Base_Model {
* @since 2.0.0
* @return void
*/
public function publish_pending_site_async() {
public function publish_pending_site_async(): void {
/*
* If the force sync setting is on, fallback to the sync version.
*/
@ -1899,11 +1899,11 @@ class Membership extends Base_Model {
// We first try to generate the site through request to start earlier as possible.
$rest_path = add_query_arg(
array(
[
'action' => 'wu_publish_pending_site',
'_ajax_nonce' => wp_create_nonce('wu_publish_pending_site'),
'membership_id' => $this->get_id(),
),
],
admin_url('admin-ajax.php')
);
@ -1912,23 +1912,23 @@ class Membership extends Base_Model {
wp_remote_request(
$rest_path,
array(
[
'sslverify' => false,
)
]
);
} elseif (ignore_user_abort(true) !== ignore_user_abort(false)) {
// We do not have fastcgi but can make the request continue without listening
wp_remote_request(
$rest_path,
array(
[
'sslverify' => false,
'blocking' => false,
)
]
);
}
wu_enqueue_async_action('wu_async_publish_pending_site', array('membership_id' => $this->get_id()), 'membership');
wu_enqueue_async_action('wu_async_publish_pending_site', ['membership_id' => $this->get_id()], 'membership');
}
/**
@ -2039,7 +2039,7 @@ class Membership extends Base_Model {
* @param boolean $recurring If this membership is recurring (true), which means the customer paid a defined amount each period of time, or not recurring (false).
* @return void
*/
public function set_recurring($recurring) {
public function set_recurring($recurring): void {
$this->recurring = (bool) $recurring;
}
@ -2199,7 +2199,7 @@ class Membership extends Base_Model {
* @param string $reason Reason for cancellation.
* @return void
*/
public function cancel($reason = '') {
public function cancel($reason = ''): void {
if ($this->get_status() === Membership_Status::CANCELLED) {
return; // Already cancelled
@ -2298,9 +2298,9 @@ class Membership extends Base_Model {
*/
public function limitations_to_merge() {
$limitations_to_merge = array();
$limitations_to_merge = [];
$product_ids = array($this->get_plan_id());
$product_ids = [$this->get_plan_id()];
$product_ids = array_merge($this->get_addon_ids(), $product_ids);
@ -2357,11 +2357,11 @@ class Membership extends Base_Model {
$has_change = false;
$current_gateway = array(
$current_gateway = [
'gateway' => $this->get_gateway(),
'gateway_customer_id' => $this->get_gateway_customer_id(),
'gateway_subscription_id' => $this->get_gateway_subscription_id(),
);
];
foreach ($this->_gateway_info as $key => $value) {
if ($value !== $current_gateway[ $key ]) {
@ -2433,9 +2433,9 @@ class Membership extends Base_Model {
if ($this->has_product_changes()) {
wu_enqueue_async_action(
'wu_async_after_membership_update_products',
array(
[
'membership_id' => $this->get_id(),
),
],
'membership'
);
}

View File

@ -172,7 +172,7 @@ class Payment extends Base_Model {
* @since 2.0.0
* @var string
*/
protected $query_class = '\\WP_Ultimo\\Database\\Payments\\Payment_Query';
protected $query_class = \WP_Ultimo\Database\Payments\Payment_Query::class;
/**
* Adds magic methods to return formatted values automatically.
@ -188,7 +188,7 @@ class Payment extends Base_Model {
$method_key = str_replace('_formatted', '', $name);
if (strpos($name, '_formatted') !== false && method_exists($this, $method_key)) {
if (str_contains($name, '_formatted') && method_exists($this, $method_key)) {
return wu_format_currency($this->{"$method_key"}(), $this->get_currency());
}
@ -213,7 +213,7 @@ class Payment extends Base_Model {
$payment_types = $payment_types->get_allowed_list(true);
return array(
return [
'customer_id' => 'required|integer|exists:\WP_Ultimo\Models\Customer,id',
'membership_id' => 'required|integer|exists:\WP_Ultimo\Models\Membership,id',
'parent_id' => 'integer|default:',
@ -229,7 +229,7 @@ class Payment extends Base_Model {
'discount_total' => 'integer',
'invoice_number' => 'default:',
'cancel_membership_on_refund' => 'boolean|default:0',
);
];
}
/**
@ -262,7 +262,7 @@ class Payment extends Base_Model {
* @param int $customer_id The ID of the customer attached to this payment.
* @return void
*/
public function set_customer_id($customer_id) {
public function set_customer_id($customer_id): void {
$this->customer_id = absint($customer_id);
}
@ -296,7 +296,7 @@ class Payment extends Base_Model {
* @param int $membership_id The ID of the membership attached to this payment.
* @return void
*/
public function set_membership_id($membership_id) {
public function set_membership_id($membership_id): void {
$this->membership_id = $membership_id;
}
@ -319,7 +319,7 @@ class Payment extends Base_Model {
* @param int $parent_id The ID from another payment that this payment is related to.
* @return void
*/
public function set_parent_id($parent_id) {
public function set_parent_id($parent_id): void {
$this->parent_id = $parent_id;
}
@ -343,7 +343,7 @@ class Payment extends Base_Model {
* @param string $currency The currency of this payment. It's a 3-letter code. E.g. 'USD'.
* @return void
*/
public function set_currency($currency) {
public function set_currency($currency): void {
$this->currency = $currency;
}
@ -366,7 +366,7 @@ class Payment extends Base_Model {
* @param float $subtotal Value before taxes, discounts, fees and other changes.
* @return void
*/
public function set_subtotal($subtotal) {
public function set_subtotal($subtotal): void {
$this->subtotal = $subtotal;
}
@ -435,7 +435,7 @@ class Payment extends Base_Model {
* @param string $discount_code Discount code used.
* @return void
*/
public function set_discount_code($discount_code) {
public function set_discount_code($discount_code): void {
$this->discount_code = $discount_code;
}
@ -458,7 +458,7 @@ class Payment extends Base_Model {
* @param float $total This takes into account fees, discounts and credits.
* @return void
*/
public function set_total($total) {
public function set_total($total): void {
$this->total = $total;
}
@ -508,7 +508,7 @@ class Payment extends Base_Model {
* @options \WP_Ultimo\Database\Payments\Payment_Status
* @return void
*/
public function set_status($status) {
public function set_status($status): void {
$this->status = $status;
}
@ -531,7 +531,7 @@ class Payment extends Base_Model {
* @param string $gateway ID of the gateway being used on this payment.
* @return void
*/
public function set_gateway($gateway) {
public function set_gateway($gateway): void {
$this->gateway = $gateway;
}
@ -613,7 +613,7 @@ class Payment extends Base_Model {
* @param Line_Item[] $line_items THe line items.
* @return void
*/
public function set_line_items(array $line_items) {
public function set_line_items(array $line_items): void {
$line_items = array_filter($line_items);
@ -630,7 +630,7 @@ class Payment extends Base_Model {
* @param Line_Item $line_item The line item.
* @return void
*/
public function add_line_item($line_item) {
public function add_line_item($line_item): void {
$line_items = $this->get_line_items();
@ -655,7 +655,7 @@ class Payment extends Base_Model {
$line_items = $this->get_line_items();
$tax_brackets = array();
$tax_brackets = [];
foreach ($line_items as $line_item) {
$tax_bracket = $line_item->get_tax_rate();
@ -711,12 +711,12 @@ class Payment extends Base_Model {
}
$this->attributes(
array(
[
'tax_total' => $tax_total,
'subtotal' => $sub_total,
'refund_total' => $refund_total,
'total' => $total,
)
]
);
return $this;
@ -732,10 +732,10 @@ class Payment extends Base_Model {
$payable_statuses = apply_filters(
'wu_payment_payable_statuses',
array(
[
Payment_Status::PENDING,
Payment_Status::FAILED,
)
]
);
return $this->get_total() > 0 && in_array($this->get_status(), $payable_statuses, true);
@ -756,9 +756,9 @@ class Payment extends Base_Model {
$slug = $this->get_hash();
return add_query_arg(
array(
[
'payment' => $slug,
),
],
wu_get_registration_url()
);
}
@ -781,7 +781,7 @@ class Payment extends Base_Model {
* @param int $product_id The ID of the product of this payment.
* @return void
*/
public function set_product_id($product_id) {
public function set_product_id($product_id): void {
$this->product_id = $product_id;
}
@ -794,11 +794,11 @@ class Payment extends Base_Model {
*/
public function get_invoice_url() {
$url_atts = array(
$url_atts = [
'action' => 'invoice',
'reference' => $this->get_hash(),
'key' => wp_create_nonce('see_invoice'),
);
];
return add_query_arg($url_atts, get_site_url(wu_get_main_site_id()));
}
@ -821,7 +821,7 @@ class Payment extends Base_Model {
* @param string $gateway_payment_id The ID of the payment on the gateway, if it exists.
* @return void
*/
public function set_gateway_payment_id($gateway_payment_id) {
public function set_gateway_payment_id($gateway_payment_id): void {
$this->gateway_payment_id = $gateway_payment_id;
}
@ -863,7 +863,7 @@ class Payment extends Base_Model {
* @param integer $discount_total The total value of the discounts applied to this payment.
* @return void
*/
public function set_discount_total($discount_total) {
public function set_discount_total($discount_total): void {
$this->discount_total = (float) $discount_total;
}
@ -909,23 +909,23 @@ class Payment extends Base_Model {
$prefix = wu_get_setting('invoice_prefix', '');
$search = array(
$search = [
'%YEAR%',
'%MONTH%',
'%DAY%',
'%%YEAR%%',
'%%MONTH%%',
'%%DAY%%',
);
];
$replace = array(
$replace = [
gmdate('Y'),
gmdate('m'),
gmdate('d'),
gmdate('Y'),
gmdate('m'),
gmdate('d'),
);
];
$prefix = str_replace($search, $replace, (string) $prefix);
@ -939,7 +939,7 @@ class Payment extends Base_Model {
* @param int $invoice_number Sequential invoice number assigned to this payment.
* @return void
*/
public function set_invoice_number($invoice_number) {
public function set_invoice_number($invoice_number): void {
$this->meta['wu_invoice_number'] = $invoice_number;
@ -994,7 +994,7 @@ class Payment extends Base_Model {
* @param bool $cancel_membership_on_refund Holds if we need to cancel the membership on refund.
* @return void
*/
public function set_cancel_membership_on_refund($cancel_membership_on_refund) {
public function set_cancel_membership_on_refund($cancel_membership_on_refund): void {
$this->meta['wu_cancel_membership_on_refund'] = $cancel_membership_on_refund;
@ -1065,7 +1065,7 @@ class Payment extends Base_Model {
// translators: %s is the date of processing.
$description = sprintf(__('Processed on %s', 'wp-ultimo'), $formatted_value);
$line_item_data = array(
$line_item_data = [
'type' => 'refund',
'hash' => uniqid(),
'title' => $title,
@ -1074,7 +1074,7 @@ class Payment extends Base_Model {
'taxable' => false,
'unit_price' => -$amount,
'quantity' => 1,
);
];
$refund_line_item = new Line_Item($line_item_data);

View File

@ -94,7 +94,7 @@ class Post_Base_Model extends Base_Model {
* @since 2.0.0
* @var string
*/
protected $query_class = '\\WP_Ultimo\\Database\\Posts\\Post_Query';
protected $query_class = \WP_Ultimo\Database\Posts\Post_Query::class;
/**
* Get author ID.
@ -111,7 +111,7 @@ class Post_Base_Model extends Base_Model {
*
* @param int $author_id The author ID.
*/
public function set_author_id($author_id) {
public function set_author_id($author_id): void {
$this->author_id = $author_id;
}
@ -131,7 +131,7 @@ class Post_Base_Model extends Base_Model {
*
* @param string $type Post type.
*/
public function set_type($type) {
public function set_type($type): void {
$this->type = $type;
}
@ -151,7 +151,7 @@ class Post_Base_Model extends Base_Model {
*
* @param string $title Post title.
*/
public function set_title($title) {
public function set_title($title): void {
$this->title = $title;
}
@ -174,7 +174,7 @@ class Post_Base_Model extends Base_Model {
*
* @param string $content Post content.
*/
public function set_content($content) {
public function set_content($content): void {
$this->content = $content;
}
@ -194,7 +194,7 @@ class Post_Base_Model extends Base_Model {
*
* @param string $excerpt Post excerpt.
*/
public function set_excerpt($excerpt) {
public function set_excerpt($excerpt): void {
$this->excerpt = $excerpt;
}
@ -214,7 +214,7 @@ class Post_Base_Model extends Base_Model {
*
* @param string $date_created Post creation date.
*/
public function set_date_created($date_created) {
public function set_date_created($date_created): void {
$this->date_created = $date_created;
}
@ -234,7 +234,7 @@ class Post_Base_Model extends Base_Model {
*
* @param string $date_modified Post last modification date.
*/
public function set_date_modified($date_modified) {
public function set_date_modified($date_modified): void {
$this->date_modified = $date_modified;
}
@ -254,7 +254,7 @@ class Post_Base_Model extends Base_Model {
*
* @param int $list_order The post list order.
*/
public function set_list_order($list_order) {
public function set_list_order($list_order): void {
$this->list_order = $list_order;
}
@ -274,7 +274,7 @@ class Post_Base_Model extends Base_Model {
*
* @param string $status The post status.
*/
public function set_status($status) {
public function set_status($status): void {
$this->status = $status;
}

View File

@ -267,7 +267,7 @@ class Product extends Base_Model {
* @since 2.0.0
* @var string
*/
protected $query_class = '\\WP_Ultimo\\Database\\Products\\Product_Query';
protected $query_class = \WP_Ultimo\Database\Products\Product_Query::class;
/**
* Map setters to other parameters.
@ -275,9 +275,9 @@ class Product extends Base_Model {
* @since 2.0.0
* @var array
*/
protected $_mappings = array(
protected $_mappings = [
'product_group' => 'group',
);
];
/**
* Set the validation rules for this particular model.
@ -301,7 +301,7 @@ class Product extends Base_Model {
$currency = wu_get_setting('currency_symbol', 'USD');
return array(
return [
'featured_image_id' => 'integer',
'currency' => "required|default:{$currency}",
'pricing_type' => 'required|in:free,paid,contact_us',
@ -323,7 +323,7 @@ class Product extends Base_Model {
'contact_us_label' => 'default:',
'contact_us_link' => 'url:http,https',
'customer_role' => 'alpha_dash',
);
];
}
/**
@ -366,7 +366,7 @@ class Product extends Base_Model {
* @param int $image_id The ID of the feature image of the product.
* @return void
*/
public function set_featured_image_id($image_id) {
public function set_featured_image_id($image_id): void {
$this->meta['wu_featured_image_id'] = $image_id;
@ -388,7 +388,7 @@ class Product extends Base_Model {
*
* @param string $slug The product slug. It needs to be unique and preferably make it clear what it is about. Example: my_new_product.
*/
public function set_slug($slug) {
public function set_slug($slug): void {
$this->slug = $slug;
}
@ -408,7 +408,7 @@ class Product extends Base_Model {
*
* @param string $name Your product name, which is used as product title as well.
*/
public function set_name($name) {
public function set_name($name): void {
$this->name = $name;
}
@ -428,7 +428,7 @@ class Product extends Base_Model {
*
* @param string $description A description for the product, usually a short text.
*/
public function set_description($description) {
public function set_description($description): void {
$this->description = $description;
}
@ -459,7 +459,7 @@ class Product extends Base_Model {
* @param string $currency The currency that this product accepts. It's a 3-letter code. E.g. 'USD'.
* @return void
*/
public function set_currency($currency) {
public function set_currency($currency): void {
$this->currency = $currency;
}
@ -483,7 +483,7 @@ class Product extends Base_Model {
* @options free,paid,contact_us
* @return void
*/
public function set_pricing_type($pricing_type) {
public function set_pricing_type($pricing_type): void {
$this->pricing_type = $pricing_type;
@ -523,7 +523,7 @@ class Product extends Base_Model {
* @param int $trial_duration The duration of the trial period of this product, if the product has one.
* @return void
*/
public function set_trial_duration($trial_duration) {
public function set_trial_duration($trial_duration): void {
$this->trial_duration = $trial_duration;
}
@ -547,7 +547,7 @@ class Product extends Base_Model {
* @options day,week,month,year
* @return void
*/
public function set_trial_duration_unit($trial_duration_unit) {
public function set_trial_duration_unit($trial_duration_unit): void {
$this->trial_duration_unit = $trial_duration_unit;
}
@ -567,7 +567,7 @@ class Product extends Base_Model {
*
* @param int $duration Time interval between charges.
*/
public function set_duration($duration) {
public function set_duration($duration): void {
$this->duration = $duration;
}
@ -587,7 +587,7 @@ class Product extends Base_Model {
*
* @param string $duration_unit Time interval unit between charges.
*/
public function set_duration_unit($duration_unit) {
public function set_duration_unit($duration_unit): void {
$this->duration_unit = $duration_unit;
}
@ -624,7 +624,7 @@ class Product extends Base_Model {
}
if ($this->get_pricing_type() === 'contact_us') {
return $this->get_contact_us_label() ? $this->get_contact_us_label() : __('Contact Us', 'wp-ultimo');
return $this->get_contact_us_label() ?: __('Contact Us', 'wp-ultimo');
}
return wu_format_currency($this->get_amount(), $this->get_currency());
@ -635,7 +635,7 @@ class Product extends Base_Model {
*
* @param int $amount The value of this product. E.g. 19.99.
*/
public function set_amount($amount) {
public function set_amount($amount): void {
$this->amount = wu_to_float($amount);
}
@ -658,7 +658,7 @@ class Product extends Base_Model {
* @param int $setup_fee The setup fee value, if the product has one. E.g. 159.99.
* @return void
*/
public function set_setup_fee($setup_fee) {
public function set_setup_fee($setup_fee): void {
$this->setup_fee = wu_to_float($setup_fee);
}
@ -694,7 +694,7 @@ class Product extends Base_Model {
*/
public function get_price_description($include_fees = true) {
$pricing = array();
$pricing = [];
if ($this->get_pricing_type() === 'contact_us') {
return __('Contact us', 'wp-ultimo');
@ -786,7 +786,7 @@ class Product extends Base_Model {
*
* @param int $list_order The product list order. Useful when ordering products in a list.
*/
public function set_list_order($list_order) {
public function set_list_order($list_order): void {
$this->list_order = $list_order;
}
@ -809,7 +809,7 @@ class Product extends Base_Model {
* @param boolean $active Set this product as active (true), which means available to be used, or inactive (false).
* @return void
*/
public function set_active($active) {
public function set_active($active): void {
$this->active = (bool) $active;
}
@ -830,7 +830,7 @@ class Product extends Base_Model {
* @param string $type The default product types are 'product', 'service' and 'package'. More types can be add using the product type filter.
* @options plan,service,package
*/
public function set_type($type) {
public function set_type($type): void {
$this->type = $type;
}
@ -879,7 +879,7 @@ class Product extends Base_Model {
* @param int $parent_id The ID from another Product that this product is related to.
* @return void
*/
public function set_parent_id($parent_id) {
public function set_parent_id($parent_id): void {
$this->parent_id = $parent_id;
}
@ -913,7 +913,7 @@ class Product extends Base_Model {
* @param boolean $recurring Set this product as a recurring one (true), which means the customer paid a defined amount each period of time, or not recurring (false).
* @return void
*/
public function set_recurring($recurring) {
public function set_recurring($recurring): void {
$this->recurring = (bool) $recurring;
}
@ -947,7 +947,7 @@ class Product extends Base_Model {
* @param int $billing_cycles The number of times we should charge this product.
* @return void
*/
public function set_billing_cycles($billing_cycles) {
public function set_billing_cycles($billing_cycles): void {
$this->billing_cycles = (int) $billing_cycles;
}
@ -970,7 +970,7 @@ class Product extends Base_Model {
* @param string $date_created Date when this was created.
* @return void
*/
public function set_date_created($date_created) {
public function set_date_created($date_created): void {
$this->date_created = $date_created;
}
@ -993,7 +993,7 @@ class Product extends Base_Model {
* @param string $date_modified Date when this was last modified.
* @return void
*/
public function set_date_modified($date_modified) {
public function set_date_modified($date_modified): void {
$this->date_modified = $date_modified;
}
@ -1040,7 +1040,7 @@ class Product extends Base_Model {
* @param bool $is_taxable Set this product as a taxable one (true), which means tax rules are applied to, or not taxable (false).
* @return void
*/
public function set_taxable($is_taxable) {
public function set_taxable($is_taxable): void {
$this->meta['taxable'] = (bool) $is_taxable;
@ -1070,7 +1070,7 @@ class Product extends Base_Model {
* @param string $tax_category Category of taxes applied to this product. You need to set this if taxable is set to true.
* @return void
*/
public function set_tax_category($tax_category) {
public function set_tax_category($tax_category): void {
$this->meta['tax_category'] = $tax_category;
@ -1099,7 +1099,7 @@ class Product extends Base_Model {
* @param string $contact_us_label If the product is the 'contact_us' type, it will need a label for the contact us button.
* @return void
*/
public function set_contact_us_label($contact_us_label) {
public function set_contact_us_label($contact_us_label): void {
$this->meta['wu_contact_us_label'] = $contact_us_label;
@ -1128,7 +1128,7 @@ class Product extends Base_Model {
* @param string $contact_us_link The url where the contact us button will lead to.
* @return void
*/
public function set_contact_us_link($contact_us_link) {
public function set_contact_us_link($contact_us_link): void {
$this->meta['wu_contact_us_link'] = $contact_us_link;
@ -1157,7 +1157,7 @@ class Product extends Base_Model {
* @param array $feature_list A list (array) of features of the product.
* @return void
*/
public function set_feature_list($feature_list) {
public function set_feature_list($feature_list): void {
$this->meta['feature_list'] = $feature_list;
@ -1203,8 +1203,8 @@ class Product extends Base_Model {
*/
public function get_as_variation($duration, $duration_unit) {
$duration = $duration ? $duration : 1;
$duration_unit = $duration_unit ? $duration_unit : 'month';
$duration = $duration ?: 1;
$duration_unit = $duration_unit ?: 'month';
if ($this->is_free()) {
return $this;
@ -1215,9 +1215,9 @@ class Product extends Base_Model {
}
if (absint($duration) === $this->get_duration() && $duration_unit === $this->get_duration_unit()) {
$price_variation = array(
$price_variation = [
'amount' => $this->get_amount(),
);
];
}
$price_variation = apply_filters('wu_get_as_variation_price_variation', $price_variation, $duration, $duration_unit, $this);
@ -1249,7 +1249,7 @@ class Product extends Base_Model {
return $price_variation;
},
$this->get_meta('price_variations', array())
$this->get_meta('price_variations', [])
);
}
@ -1263,7 +1263,7 @@ class Product extends Base_Model {
* @param ?array $price_variations Price variations array.
* @return void
*/
public function set_price_variations(?array $price_variations) {
public function set_price_variations(?array $price_variations): void {
// Ensure the amount is a float.
$price_variations = array_map(
@ -1273,7 +1273,7 @@ class Product extends Base_Model {
return $price_variation;
},
$price_variations ?? array()
$price_variations ?? []
);
$this->meta['price_variations'] = $price_variations;
@ -1337,13 +1337,13 @@ class Product extends Base_Model {
$results = parent::save();
if ( ! is_wp_error($results) && has_action('save_post_wpultimo_plan')) {
do_action_deprecated('save_post_wpultimo_plan', array($this->get_id()), '2.0.0');
do_action_deprecated('save_post_wpultimo_plan', [$this->get_id()], '2.0.0');
}
if ( ! is_wp_error($results) && has_action('wu_save_plan')) {
$compat_plan = new \WU_Plan($this);
do_action_deprecated('wu_save_plan', array($compat_plan), '2.0.0', 'wu_product_post_save');
do_action_deprecated('wu_save_plan', [$compat_plan], '2.0.0', 'wu_product_post_save');
}
return $results;
@ -1373,7 +1373,7 @@ class Product extends Base_Model {
public function get_available_addons() {
if ($this->available_addons === null) {
$this->available_addons = $this->get_meta('wu_available_addons', array());
$this->available_addons = $this->get_meta('wu_available_addons', []);
if (is_string($this->available_addons)) {
$this->available_addons = explode(',', $this->available_addons);
@ -1390,7 +1390,7 @@ class Product extends Base_Model {
* @param array $available_addons The available addons of this product.
* @return void
*/
public function set_available_addons($available_addons) {
public function set_available_addons($available_addons): void {
$this->meta['wu_available_addons'] = $available_addons;
@ -1427,7 +1427,7 @@ class Product extends Base_Model {
* @param array $group The group of this product, if has any.
* @return void
*/
public function set_group($group) {
public function set_group($group): void {
$this->product_group = $group;
}
@ -1454,7 +1454,7 @@ class Product extends Base_Model {
* @param bool $legacy_options If the legacy options are enabled.
* @return void
*/
public function set_legacy_options($legacy_options) {
public function set_legacy_options($legacy_options): void {
$this->meta['legacy_options'] = $legacy_options;
@ -1477,6 +1477,6 @@ class Product extends Base_Model {
*/
public function limitations_to_merge() {
return array();
return [];
}
}

View File

@ -205,7 +205,7 @@ class Site extends Base_Model {
* @since 2.0.0
* @var array
*/
private $duplication_arguments = array();
private $duplication_arguments = [];
/**
* The site type of this particular site.
@ -237,7 +237,7 @@ class Site extends Base_Model {
* @since 2.0.0
* @var string
*/
protected $query_class = '\\WP_Ultimo\\Database\\Sites\\Site_Query';
protected $query_class = \WP_Ultimo\Database\Sites\Site_Query::class;
/**
* Keeps form date from the signup form.
@ -281,7 +281,7 @@ class Site extends Base_Model {
$site_types = implode(',', array_values($site_types->get_options()));
return array(
return [
'categories' => 'default:',
'featured_image_id' => 'integer|default:',
'site_id' => 'required|integer',
@ -304,7 +304,7 @@ class Site extends Base_Model {
'template_id' => 'integer|default:',
'type' => "required|in:{$site_types}",
'signup_options' => 'default:',
);
];
}
/**
@ -328,7 +328,7 @@ class Site extends Base_Model {
* @param array $categories The categories this site belongs to.
* @return void
*/
public function set_categories($categories) {
public function set_categories($categories): void {
$this->meta['wu_categories'] = $categories;
@ -344,11 +344,11 @@ class Site extends Base_Model {
public function get_categories() {
if ($this->categories === null) {
$this->categories = $this->get_meta('wu_categories', array());
$this->categories = $this->get_meta('wu_categories', []);
}
if ( ! is_array($this->categories)) {
return array();
return [];
}
return array_filter($this->categories);
@ -378,7 +378,7 @@ class Site extends Base_Model {
public function get_featured_image($size = 'wu-thumb-medium') {
if ($this->get_type() === 'external') {
return wu_get_asset('wp-ultimo-screenshot.png');
return wu_get_asset('wp-ultimo-screenshot.webp');
}
is_multisite() && switch_to_blog(wu_get_main_site_id());
@ -393,7 +393,7 @@ class Site extends Base_Model {
return $image_attributes[0];
}
return wu_get_asset('site-placeholder-image.png', 'img');
return wu_get_asset('site-placeholder-image.webp', 'img');
}
/**
@ -403,7 +403,7 @@ class Site extends Base_Model {
* @param int $image_id The ID of the feature image of the site.
* @return void
*/
public function set_featured_image_id($image_id) {
public function set_featured_image_id($image_id): void {
$this->meta['wu_featured_image_id'] = $image_id;
@ -469,7 +469,7 @@ class Site extends Base_Model {
* @param int $blog_id The blog ID. Should be accessed via id.
* @return void
*/
public function set_blog_id($blog_id) {
public function set_blog_id($blog_id): void {
$this->blog_id = $blog_id;
}
@ -492,7 +492,7 @@ class Site extends Base_Model {
* @param int $site_id The network ID for this site.
* @return void
*/
public function set_site_id($site_id) {
public function set_site_id($site_id): void {
$this->site_id = $site_id;
}
@ -514,7 +514,7 @@ class Site extends Base_Model {
* @param string $title The site title.
* @return void
*/
public function set_title($title) {
public function set_title($title): void {
$this->title = sanitize_text_field($title);
}
@ -537,7 +537,7 @@ class Site extends Base_Model {
* @param string $title The site name.
* @return void
*/
public function set_name($title) {
public function set_name($title): void {
$this->set_title($title);
}
@ -566,7 +566,7 @@ class Site extends Base_Model {
* @param string $description A description for the site, usually a short text.
* @return void
*/
public function set_description($description) {
public function set_description($description): void {
$this->description = $description;
}
@ -589,7 +589,7 @@ class Site extends Base_Model {
* @param string $domain The site domain. You don't need to put http or https in front of your domain in this field. e.g: example.com.
* @return void
*/
public function set_domain($domain) {
public function set_domain($domain): void {
$this->domain = $domain;
}
@ -610,7 +610,7 @@ class Site extends Base_Model {
* @param string $path Path of the site. Used when in sub-directory mode.
* @return void
*/
public function set_path($path) {
public function set_path($path): void {
$this->path = $path;
}
@ -644,7 +644,7 @@ class Site extends Base_Model {
* @param string $registered Date when the site was registered.
* @return void
*/
public function set_registered($registered) {
public function set_registered($registered): void {
$this->registered = $registered;
}
@ -678,7 +678,7 @@ class Site extends Base_Model {
* @param string $last_updated Date of the last update on this site.
* @return void
*/
public function set_last_updated($last_updated) {
public function set_last_updated($last_updated): void {
$this->last_updated = $last_updated;
}
@ -701,7 +701,7 @@ class Site extends Base_Model {
* @param int $publishing Holds the ID of the customer that owns this site.
* @return void
*/
public function set_publishing($publishing) {
public function set_publishing($publishing): void {
$this->is_publishing = $publishing;
}
@ -728,7 +728,7 @@ class Site extends Base_Model {
* @param int $active Holds the ID of the customer that owns this site.
* @return void
*/
public function set_active($active) {
public function set_active($active): void {
$this->meta['wu_active'] = $active;
@ -753,7 +753,7 @@ class Site extends Base_Model {
* @param bool $public Set true if this site is a public one, false if not.
* @return void
*/
public function set_public($public) {
public function set_public($public): void {
$this->public = $public;
}
@ -776,7 +776,7 @@ class Site extends Base_Model {
* @param bool $archived Is this an archived site.
* @return void
*/
public function set_archived($archived) {
public function set_archived($archived): void {
$this->archived = $archived;
}
@ -799,7 +799,7 @@ class Site extends Base_Model {
* @param bool $mature Is this a site with mature content.
* @return void
*/
public function set_mature($mature) {
public function set_mature($mature): void {
$this->mature = $mature;
}
@ -822,7 +822,7 @@ class Site extends Base_Model {
* @param bool $spam Is this an spam site.
* @return void
*/
public function set_spam($spam) {
public function set_spam($spam): void {
$this->spam = $spam;
}
@ -845,7 +845,7 @@ class Site extends Base_Model {
* @param bool $deleted Is this site deleted.
* @return void
*/
public function set_deleted($deleted) {
public function set_deleted($deleted): void {
$this->deleted = $deleted;
}
@ -868,7 +868,7 @@ class Site extends Base_Model {
* @param int $lang_id The ID of the language being used on this site.
* @return void
*/
public function set_lang_id($lang_id) {
public function set_lang_id($lang_id): void {
$this->lang_id = $lang_id;
}
@ -895,7 +895,7 @@ class Site extends Base_Model {
* @param int $customer_id The ID of the customer that owns this site.
* @return void
*/
public function set_customer_id($customer_id) {
public function set_customer_id($customer_id): void {
$this->meta['wu_customer_id'] = $customer_id;
@ -960,7 +960,7 @@ class Site extends Base_Model {
* @param int $membership_id The ID of the membership associated with this site, if any.
* @return void
*/
public function set_membership_id($membership_id) {
public function set_membership_id($membership_id): void {
$this->meta['wu_membership_id'] = $membership_id;
@ -1066,7 +1066,7 @@ class Site extends Base_Model {
* @param int $template_id The ID of the templated used to create this site.
* @return void
*/
public function set_template_id($template_id) {
public function set_template_id($template_id): void {
$this->meta['wu_template_id'] = absint($template_id);
@ -1092,11 +1092,11 @@ class Site extends Base_Model {
*/
protected function get_default_duplication_arguments() {
return array(
return [
'keep_users' => true,
'copy_files' => true,
'public' => true,
);
];
}
/**
@ -1130,7 +1130,7 @@ class Site extends Base_Model {
* @param array $duplication_arguments Duplication arguments.
* @return void
*/
public function set_duplication_arguments($duplication_arguments) {
public function set_duplication_arguments($duplication_arguments): void {
$this->duplication_arguments = $duplication_arguments;
}
@ -1150,7 +1150,7 @@ class Site extends Base_Model {
if ($this->type === null) {
$type = $this->get_meta('wu_type');
$this->type = $type ? $type : 'default';
$this->type = $type ?: 'default';
}
return $this->type;
@ -1164,7 +1164,7 @@ class Site extends Base_Model {
* @options \WP_Ultimo\Database\Sites\Site_Type
* @return void
*/
public function set_type($type) {
public function set_type($type): void {
$this->meta = (array) $this->meta;
@ -1185,12 +1185,12 @@ class Site extends Base_Model {
}
$domains = wu_get_domains(
array(
[
'primary_domain' => true,
'blog_id' => $this->get_id(),
'stage__not_in' => \WP_Ultimo\Models\Domain::INACTIVE_STAGES,
'number' => 1,
)
]
);
return empty($domains) ? false : $domains[0];
@ -1297,7 +1297,7 @@ class Site extends Base_Model {
* @param array $transient Form data.
* @return void
*/
public function set_transient($transient) {
public function set_transient($transient): void {
$this->meta['wu_transient'] = $transient;
@ -1312,7 +1312,7 @@ class Site extends Base_Model {
*/
public function get_signup_options() {
return is_array($this->signup_options) ? $this->signup_options : array();
return is_array($this->signup_options) ? $this->signup_options : [];
}
/**
@ -1322,7 +1322,7 @@ class Site extends Base_Model {
* @param array $signup_options Keeps signup options for the site.
* @return void
*/
public function set_signup_options($signup_options) {
public function set_signup_options($signup_options): void {
$this->signup_options = $signup_options;
}
@ -1335,7 +1335,7 @@ class Site extends Base_Model {
*/
public function get_signup_meta() {
return is_array($this->signup_meta) ? $this->signup_meta : array();
return is_array($this->signup_meta) ? $this->signup_meta : [];
}
/**
@ -1345,7 +1345,7 @@ class Site extends Base_Model {
* @param array $signup_meta Keeps signup meta for the site.
* @return void
*/
public function set_signup_meta($signup_meta) {
public function set_signup_meta($signup_meta): void {
$this->signup_meta = $signup_meta;
}
@ -1388,13 +1388,13 @@ class Site extends Base_Model {
*/
public function __call($name, $args) {
if (strpos($name, 'get_option_') !== false) {
if (str_contains($name, 'get_option_')) {
$option = str_replace('get_option_', '', $name);
return get_blog_option($this->get_id(), $option, false);
}
throw new \BadMethodCallException(__CLASS__ . "::$name()");
throw new \BadMethodCallException(self::class . "::$name()");
}
/**
@ -1538,9 +1538,9 @@ class Site extends Base_Model {
if ($new) {
$network = get_network();
$domain = $this->get_domain() ? $this->get_domain() : $network->domain;
$domain = $this->get_domain() ?: $network->domain;
$network_id = $this->get_site_id() ? $this->get_site_id() : get_current_network_id();
$network_id = $this->get_site_id() ?: get_current_network_id();
$user_id = get_current_user_id();
@ -1564,13 +1564,13 @@ class Site extends Base_Model {
$saved = \WP_Ultimo\Helpers\Site_Duplicator::duplicate_site(
$this->get_template_id(),
$this->get_title(),
array(
[
'email' => $email,
'path' => $this->get_path(),
'domain' => $domain,
'meta' => $this->get_signup_options(),
'user_id' => $user_id ? $user_id : 0,
)
'user_id' => $user_id ?: 0,
]
);
if (is_wp_error($saved)) {
@ -1592,9 +1592,9 @@ class Site extends Base_Model {
wp_update_site(
$site_id,
array(
[
'public' => $this->get_public(),
)
]
);
}
@ -1613,9 +1613,9 @@ class Site extends Base_Model {
if ( ! is_wp_error($saved) && wu_get_setting('enable_screenshot_generator', true)) {
wu_enqueue_async_action(
'wu_async_take_screenshot',
array(
[
'site_id' => $saved,
),
],
'site'
);
}
@ -1740,7 +1740,7 @@ class Site extends Base_Model {
* @param array $query_args Additional query args.
* @return array
*/
public static function get_all_by_type($type = 'customer_owned', $query_args = array()) {
public static function get_all_by_type($type = 'customer_owned', $query_args = []) {
global $wpdb;
@ -1753,10 +1753,10 @@ class Site extends Base_Model {
if ($customer_id) {
$memberships = wu_get_memberships(
array(
'fields' => array('id'),
[
'fields' => ['id'],
'customer_id' => $customer_id,
)
]
);
$memberships_str = '';
@ -1789,12 +1789,12 @@ class Site extends Base_Model {
$query = $query_args;
$query['meta_query'] = array(
array(
$query['meta_query'] = [
[
'key' => 'wu_type',
'value' => $type,
),
);
],
];
return static::query($query);
}
@ -1808,19 +1808,19 @@ class Site extends Base_Model {
* @param array $query_args Additional query args.
* @return array
*/
public static function get_all_by_categories($categories = array(), $query_args = array()) {
public static function get_all_by_categories($categories = [], $query_args = []) {
global $wpdb;
$query = $query_args;
$query['meta_query'] = array(
array(
$query['meta_query'] = [
[
'key' => 'wu_categories',
'value' => maybe_serialize($categories),
'compare' => 'LIKE',
),
);
],
];
return static::query($query);
}
@ -1832,7 +1832,7 @@ class Site extends Base_Model {
* @param array $sites An array of selected site ids or site objects.
* @return array
*/
public static function get_all_categories($sites = array()) {
public static function get_all_categories($sites = []) {
global $wpdb;
@ -1842,7 +1842,7 @@ class Site extends Base_Model {
return $cache;
}
$final_array = array();
$final_array = [];
$query = "SELECT DISTINCT meta_value FROM {$wpdb->base_prefix}blogmeta WHERE meta_key = %s";
@ -1867,7 +1867,7 @@ class Site extends Base_Model {
$all_arrays = array_map('maybe_unserialize', $all_arrays);
if ($all_arrays) {
$filtered_array = array();
$filtered_array = [];
foreach ($all_arrays as $array) {
if (is_array($array)) {
@ -1904,7 +1904,7 @@ class Site extends Base_Model {
*/
public function limitations_to_merge() {
$limitations_to_merge = array();
$limitations_to_merge = [];
$membership = $this->get_membership();

View File

@ -99,7 +99,7 @@ class Webhook extends Base_Model {
* @since 2.0.0
* @var string
*/
protected $query_class = '\\WP_Ultimo\\Database\\Webhooks\\Webhook_Query';
protected $query_class = \WP_Ultimo\Database\Webhooks\Webhook_Query::class;
/**
* Set the validation rules for this particular model.
@ -113,7 +113,7 @@ class Webhook extends Base_Model {
*/
public function validation_rules() {
return array(
return [
'name' => 'required|min:2',
'webhook_url' => 'required|url:http,https',
'event' => 'required',
@ -122,7 +122,7 @@ class Webhook extends Base_Model {
'hidden' => 'default:0',
'integration' => 'required|min:2',
'date_last_failed' => 'default:',
);
];
}
/**
@ -140,7 +140,7 @@ class Webhook extends Base_Model {
*
* @param string $name Webhook name, which is used as product title as well.
*/
public function set_name($name) {
public function set_name($name): void {
$this->name = $name;
}
@ -160,7 +160,7 @@ class Webhook extends Base_Model {
*
* @param string $webhook_url The URL used for the webhook call.
*/
public function set_webhook_url($webhook_url) {
public function set_webhook_url($webhook_url): void {
$this->webhook_url = $webhook_url;
}
@ -180,7 +180,7 @@ class Webhook extends Base_Model {
*
* @param string $event The event that needs to be fired for this webhook to be sent.
*/
public function set_event($event) {
public function set_event($event): void {
$this->event = $event;
}
@ -200,7 +200,7 @@ class Webhook extends Base_Model {
*
* @param int $event_count How many times this webhook was sent.
*/
public function set_event_count($event_count) {
public function set_event_count($event_count): void {
$this->event_count = $event_count;
}
@ -224,7 +224,7 @@ class Webhook extends Base_Model {
* @param boolean $active Set this webhook as active (true), which means available will fire when the event occur, or inactive (false).
* @return void
*/
public function set_active($active) {
public function set_active($active): void {
$this->active = (bool) wu_string_to_bool($active);
}
@ -244,7 +244,7 @@ class Webhook extends Base_Model {
*
* @param boolean $hidden Is this webhook hidden.
*/
public function set_hidden($hidden) {
public function set_hidden($hidden): void {
$this->hidden = $hidden;
}
@ -288,7 +288,7 @@ class Webhook extends Base_Model {
* @param string $date_created Date when this was created.
* @return void
*/
public function set_date_created($date_created) {
public function set_date_created($date_created): void {
$this->date_created = $date_created;
}
@ -298,7 +298,7 @@ class Webhook extends Base_Model {
*
* @param string $integration The integration that created this webhook.
*/
public function set_integration($integration) {
public function set_integration($integration): void {
$this->integration = $integration;
}

View File

@ -60,7 +60,7 @@ trait Billable {
* @param array|\WP_Ultimo\Objects\Billing_Address $billing_address The billing address.
* @return void
*/
public function set_billing_address($billing_address) {
public function set_billing_address($billing_address): void {
if (is_array($billing_address)) {
$billing_address = new Billing_Address($billing_address);

View File

@ -23,7 +23,7 @@ trait Limitable {
* @since 2.0.0
* @var array
*/
protected $_limitations = array();
protected $_limitations = [];
/**
* List of limitations that need to be merged.
@ -54,7 +54,7 @@ trait Limitable {
* This is because we don't want to limit sites other than the customer owned ones.
*/
if ($this->model === 'site' && $this->get_type() !== Site_Type::CUSTOMER_OWNED) {
return new Limitations(array());
return new Limitations([]);
}
$cache_key = $waterfall ? '_composite_limitations_' : '_limitations_';
@ -70,16 +70,16 @@ trait Limitable {
}
if ( ! is_array($this->meta)) {
$this->meta = array();
$this->meta = [];
}
if (did_action('muplugins_loaded') === false) {
$modules_data = $this->get_meta('wu_limitations', array());
$modules_data = $this->get_meta('wu_limitations', []);
} else {
$modules_data = Limitations::early_get_limitations($this->model, $this->get_id());
}
$limitations = new Limitations(array());
$limitations = new Limitations([]);
if ($waterfall) {
$limitations = $limitations->merge(...$this->limitations_to_merge());
@ -155,9 +155,9 @@ trait Limitable {
* @since 2.0.5
* @return void
*/
public function sync_plugins() {
public function sync_plugins(): void {
$sites = array();
$sites = [];
if ($this->model === 'site') {
$sites[] = $this;
@ -201,7 +201,7 @@ trait Limitable {
* @since 2.0.0
* @return void
*/
public function handle_limitations() {
public function handle_limitations(): void {
/*
* Only handle limitations if there are to handle in the first place.
*/
@ -213,14 +213,14 @@ trait Limitable {
$saved_limitations = $object_limitations->to_array();
$modules_to_save = array();
$modules_to_save = [];
$limitations = Limitations::repository();
$current_limitations = $this->get_limitations(true, true);
foreach ($limitations as $limitation_id => $class_name) {
$module = wu_get_isset($saved_limitations, $limitation_id, array());
$module = wu_get_isset($saved_limitations, $limitation_id, []);
try {
if (is_string($module)) {
@ -265,10 +265,10 @@ trait Limitable {
public function get_applicable_product_slugs() {
if ($this->model === 'product') {
return array($this->get_slug());
return [$this->get_slug()];
}
$slugs = array();
$slugs = [];
if ($this->model === 'membership') {
$membership = $this;