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

* Update translation text domain
* Escape everything that should be escaped.
* Add nonce checks where needed.
* Sanitize all inputs.
* Apply Code style changes across the codebase.
* Correct many deprecation notices.
* Optimize load order of many filters.
* Add Proper Build script
* Use emojii flags
* Fix i18n deprecation  notice for translating too early
* Put all scripts in footer and load async
This commit is contained in:
David Stone
2025-04-14 11:36:46 -06:00
committed by GitHub
parent a31cfcb565
commit d88e50df38
1087 changed files with 12586 additions and 18535 deletions

View File

@ -138,15 +138,15 @@ class Limitation_Manager {
$fields = [
'confirm' => [
'type' => 'toggle',
'title' => __('Confirm Reset', 'wp-ultimo'),
'desc' => __('This action can not be undone.', 'wp-ultimo'),
'title' => __('Confirm Reset', 'wp-multisite-waas'),
'desc' => __('This action can not be undone.', 'wp-multisite-waas'),
'html_attr' => [
'v-model' => 'confirmed',
],
],
'submit_button' => [
'type' => 'submit',
'title' => __('Reset Limitations', 'wp-ultimo'),
'title' => __('Reset Limitations', 'wp-multisite-waas'),
'value' => 'save',
'classes' => 'button button-primary wu-w-full',
'wrapper_classes' => 'wu-items-end',
@ -165,13 +165,13 @@ class Limitation_Manager {
];
$form_attributes = [
'title' => __('Reset', 'wp-ultimo'),
'title' => __('Reset', 'wp-multisite-waas'),
'views' => 'admin-pages/fields',
'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0',
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
'html_attr' => [
'data-wu-app' => 'reset_limitations',
'data-state' => json_encode(
'data-state' => wp_json_encode(
[
'confirmed' => false,
]
@ -200,7 +200,7 @@ class Limitation_Manager {
wp_send_json_error(
new \WP_Error(
'parameters-not-found',
__('Required parameters are missing.', 'wp-ultimo')
__('Required parameters are missing.', 'wp-multisite-waas')
)
);
}
@ -228,22 +228,22 @@ class Limitation_Manager {
*
* @since 2.0.0
*
* @param \WP_Ultimo\Models\Trait\Trait_Limitable $object Model to test.
* @param \WP_Ultimo\Models\Limitable $object_model Model to test.
* @return string
*/
public function get_object_type($object) {
public function get_object_type($object_model) {
$model = false;
if (is_a($object, \WP_Ultimo\Models\Site::class)) {
if (is_a($object_model, \WP_Ultimo\Models\Site::class)) {
$model = 'site';
} elseif (is_a($object, WP_Ultimo\Models\Membership::class)) {
} elseif (is_a($object_model, \WP_Ultimo\Models\Membership::class)) {
$model = 'membership';
} elseif (is_a($object, \WP_Ultimo\Models\Product::class)) {
} elseif (is_a($object_model, \WP_Ultimo\Models\Product::class)) {
$model = 'product';
}
return apply_filters('wu_limitations_get_object_type', $model);
return apply_filters('wu_limitations_get_object_type', $model, $object_model);
}
/**
@ -251,18 +251,18 @@ class Limitation_Manager {
*
* @since 2.0.0
*
* @param array $sections List of tabbed widget sections.
* @param \WP_Ultimo\Models\Trait\Trait_Limitable $object The model being edited.
* @param array $sections List of tabbed widget sections.
* @param \WP_Ultimo\Models\Limitable $object_model The model being edited.
* @return array
*/
public function add_limitation_sections($sections, $object) {
public function add_limitation_sections($sections, $object_model) {
if ($this->get_object_type($object) === 'site' && $object->get_type() !== Site_Type::CUSTOMER_OWNED) {
$html = sprintf('<span class="wu--mt-4 wu-p-2 wu-bg-blue-100 wu-text-blue-600 wu-rounded wu-block">%s</span>', __('Limitations are only available for customer-owned sites. You need to change the type to Customer-owned and save this site before the options are shown.', 'wp-ultimo'));
if ( $this->get_object_type($object_model) === 'site' && $object_model->get_type() !== Site_Type::CUSTOMER_OWNED) {
$html = sprintf('<span class="wu--mt-4 wu-p-2 wu-bg-blue-100 wu-text-blue-600 wu-rounded wu-block">%s</span>', __('Limitations are only available for customer-owned sites. You need to change the type to Customer-owned and save this site before the options are shown.', 'wp-multisite-waas'));
$sections['sites'] = [
'title' => __('Limits', 'wp-ultimo'),
'desc' => __('Only customer-owned sites have limitations.', 'wp-ultimo'),
'title' => __('Limits', 'wp-multisite-waas'),
'desc' => __('Only customer-owned sites have limitations.', 'wp-multisite-waas'),
'icon' => 'dashicons-wu-browser',
'fields' => [
'note' => [
@ -275,15 +275,15 @@ class Limitation_Manager {
return $sections;
}
if ($this->get_object_type($object) !== 'site') {
if ( $this->get_object_type($object_model) !== 'site') {
$sections['sites'] = [
'title' => __('Sites', 'wp-ultimo'),
'desc' => __('Control limitations imposed to the number of sites allowed for memberships attached to this product.', 'wp-ultimo'),
'title' => __('Sites', 'wp-multisite-waas'),
'desc' => __('Control limitations imposed to the number of sites allowed for memberships attached to this product.', 'wp-multisite-waas'),
'icon' => 'dashicons-wu-browser',
'fields' => $this->get_sites_fields($object),
'fields' => $this->get_sites_fields($object_model),
'v-show' => "get_state_value('product_type', 'none') !== 'service'",
'state' => [
'limit_sites' => $object->get_limitations()->sites->is_enabled(),
'limit_sites' => $object_model->get_limitations()->sites->is_enabled(),
],
];
}
@ -293,18 +293,18 @@ class Limitation_Manager {
*/
if ((bool) wu_get_setting('enable_visits_limiting', true)) {
$sections['visits'] = [
'title' => __('Visits', 'wp-ultimo'),
'desc' => __('Control limitations imposed to the number of unique visitors allowed for memberships attached to this product.', 'wp-ultimo'),
'title' => __('Visits', 'wp-multisite-waas'),
'desc' => __('Control limitations imposed to the number of unique visitors allowed for memberships attached to this product.', 'wp-multisite-waas'),
'icon' => 'dashicons-wu-man',
'v-show' => "get_state_value('product_type', 'none') !== 'service'",
'state' => [
'limit_visits' => $object->get_limitations()->visits->is_enabled(),
'limit_visits' => $object_model->get_limitations()->visits->is_enabled(),
],
'fields' => [
'modules[visits][enabled]' => [
'type' => 'toggle',
'title' => __('Limit Unique Visits', 'wp-ultimo'),
'desc' => __('Toggle this option to enable unique visits limitation.', 'wp-ultimo'),
'title' => __('Limit Unique Visits', 'wp-multisite-waas'),
'desc' => __('Toggle this option to enable unique visits limitation.', 'wp-multisite-waas'),
'value' => 10,
'html_attr' => [
'v-model' => 'limit_visits',
@ -313,16 +313,16 @@ class Limitation_Manager {
],
];
if ('product' !== $object->model) {
$sections['visits']['fields']['modules_visits_overwrite'] = $this->override_notice($object->get_limitations(false)->visits->has_own_enabled());
if ( 'product' !== $object_model->model) {
$sections['visits']['fields']['modules_visits_overwrite'] = $this->override_notice($object_model->get_limitations(false)->visits->has_own_enabled());
}
$sections['visits']['fields']['modules[visits][limit]'] = [
'type' => 'number',
'title' => __('Unique Visits Quota', 'wp-ultimo'),
'desc' => __('Set a top limit for the number of monthly unique visits. Leave empty or 0 to allow for unlimited visits.', 'wp-ultimo'),
'placeholder' => __('e.g. 10000', 'wp-ultimo'),
'value' => $object->get_limitations()->visits->get_limit(),
'title' => __('Unique Visits Quota', 'wp-multisite-waas'),
'desc' => __('Set a top limit for the number of monthly unique visits. Leave empty or 0 to allow for unlimited visits.', 'wp-multisite-waas'),
'placeholder' => __('e.g. 10000', 'wp-multisite-waas'),
'value' => $object_model->get_limitations()->visits->get_limit(),
'wrapper_html_attr' => [
'v-show' => 'limit_visits',
'v-cloak' => '1',
@ -332,20 +332,20 @@ class Limitation_Manager {
],
];
if ('product' !== $object->model) {
$sections['visits']['fields']['allowed_visits_overwrite'] = $this->override_notice($object->get_limitations(false)->visits->has_own_limit(), ['limit_visits']);
if ( 'product' !== $object_model->model) {
$sections['visits']['fields']['allowed_visits_overwrite'] = $this->override_notice($object_model->get_limitations(false)->visits->has_own_limit(), ['limit_visits']);
}
/*
* If this is a site edit screen, show the current values
* for visits and the reset date
*/
if ($this->get_object_type($object) === 'site') {
if ( $this->get_object_type($object_model) === 'site') {
$sections['visits']['fields']['visits_count'] = [
'type' => 'text-display',
'title' => __('Current Unique Visits Count this Month', 'wp-ultimo'),
'desc' => __('Current visits count for this particular site.', 'wp-ultimo'),
'display_value' => sprintf('%s visit(s)', $object->get_visits_count()),
'title' => __('Current Unique Visits Count this Month', 'wp-multisite-waas'),
'desc' => __('Current visits count for this particular site.', 'wp-multisite-waas'),
'display_value' => sprintf('%s visit(s)', $object_model->get_visits_count()),
'wrapper_html_attr' => [
'v-show' => 'limit_visits',
'v-cloak' => '1',
@ -355,18 +355,18 @@ class Limitation_Manager {
}
$sections['users'] = [
'title' => __('Users', 'wp-ultimo'),
'desc' => __('Control limitations imposed to the number of user allowed for memberships attached to this product.', 'wp-ultimo'),
'title' => __('Users', 'wp-multisite-waas'),
'desc' => __('Control limitations imposed to the number of user allowed for memberships attached to this product.', 'wp-multisite-waas'),
'icon' => 'dashicons-wu-users',
'v-show' => "get_state_value('product_type', 'none') !== 'service'",
'state' => [
'limit_users' => $object->get_limitations()->users->is_enabled(),
'limit_users' => $object_model->get_limitations()->users->is_enabled(),
],
'fields' => [
'modules[users][enabled]' => [
'type' => 'toggle',
'title' => __('Limit User', 'wp-ultimo'),
'desc' => __('Enable user limitations for this product.', 'wp-ultimo'),
'title' => __('Limit User', 'wp-multisite-waas'),
'desc' => __('Enable user limitations for this product.', 'wp-multisite-waas'),
'html_attr' => [
'v-model' => 'limit_users',
],
@ -374,25 +374,25 @@ class Limitation_Manager {
],
];
if ('product' !== $object->model) {
$sections['users']['fields']['modules_user_overwrite'] = $this->override_notice($object->get_limitations(false)->users->has_own_enabled());
if ( 'product' !== $object_model->model) {
$sections['users']['fields']['modules_user_overwrite'] = $this->override_notice($object_model->get_limitations(false)->users->has_own_enabled());
}
$this->register_user_fields($sections, $object);
$this->register_user_fields($sections, $object_model);
$sections['post_types'] = [
'title' => __('Post Types', 'wp-ultimo'),
'desc' => __('Control limitations imposed to the number of posts allowed for memberships attached to this product.', 'wp-ultimo'),
'title' => __('Post Types', 'wp-multisite-waas'),
'desc' => __('Control limitations imposed to the number of posts allowed for memberships attached to this product.', 'wp-multisite-waas'),
'icon' => 'dashicons-wu-book',
'v-show' => "get_state_value('product_type', 'none') !== 'service'",
'state' => [
'limit_post_types' => $object->get_limitations()->post_types->is_enabled(),
'limit_post_types' => $object_model->get_limitations()->post_types->is_enabled(),
],
'fields' => [
'modules[post_types][enabled]' => [
'type' => 'toggle',
'title' => __('Limit Post Types', 'wp-ultimo'),
'desc' => __('Toggle this option to set limits to each post type.', 'wp-ultimo'),
'title' => __('Limit Post Types', 'wp-multisite-waas'),
'desc' => __('Toggle this option to set limits to each post type.', 'wp-multisite-waas'),
'value' => false,
'html_attr' => [
'v-model' => 'limit_post_types',
@ -401,34 +401,34 @@ class Limitation_Manager {
],
];
if ('product' !== $object->model) {
$sections['post_types']['fields']['post_quota_overwrite'] = $this->override_notice($object->get_limitations(false)->post_types->has_own_enabled());
if ( 'product' !== $object_model->model) {
$sections['post_types']['fields']['post_quota_overwrite'] = $this->override_notice($object_model->get_limitations(false)->post_types->has_own_enabled());
}
$sections['post_types']['post_quota_note'] = [
'type' => 'note',
'desc' => __('<strong>Note:</strong> Using the fields below you can set a post limit for each of the post types activated. <br>Toggle the switch to <strong>deactivate</strong> the post type altogether. Leave 0 or blank for unlimited posts.', 'wp-ultimo'),
'desc' => __('<strong>Note:</strong> Using the fields below you can set a post limit for each of the post types activated. <br>Toggle the switch to <strong>deactivate</strong> the post type altogether. Leave 0 or blank for unlimited posts.', 'wp-multisite-waas'),
'wrapper_html_attr' => [
'v-show' => 'limit_post_types',
'v-cloak' => '1',
],
];
$this->register_post_type_fields($sections, $object);
$this->register_post_type_fields($sections, $object_model);
$sections['limit_disk_space'] = [
'title' => __('Disk Space', 'wp-ultimo'),
'desc' => __('Control limitations imposed to the disk space allowed for memberships attached to this entity.', 'wp-ultimo'),
'title' => __('Disk Space', 'wp-multisite-waas'),
'desc' => __('Control limitations imposed to the disk space allowed for memberships attached to this entity.', 'wp-multisite-waas'),
'icon' => 'dashicons-wu-drive',
'v-show' => "get_state_value('product_type', 'none') !== 'service'",
'state' => [
'limit_disk_space' => $object->get_limitations()->disk_space->is_enabled(),
'limit_disk_space' => $object_model->get_limitations()->disk_space->is_enabled(),
],
'fields' => [
'modules[disk_space][enabled]' => [
'type' => 'toggle',
'title' => __('Limit Disk Space per Site', 'wp-ultimo'),
'desc' => __('Enable disk space limitations for this entity.', 'wp-ultimo'),
'title' => __('Limit Disk Space per Site', 'wp-multisite-waas'),
'desc' => __('Enable disk space limitations for this entity.', 'wp-multisite-waas'),
'value' => true,
'html_attr' => [
'v-model' => 'limit_disk_space',
@ -437,41 +437,41 @@ class Limitation_Manager {
],
];
if ('product' !== $object->model) {
$sections['limit_disk_space']['fields']['disk_space_modules_overwrite'] = $this->override_notice($object->get_limitations(false)->disk_space->has_own_enabled());
if ( 'product' !== $object_model->model) {
$sections['limit_disk_space']['fields']['disk_space_modules_overwrite'] = $this->override_notice($object_model->get_limitations(false)->disk_space->has_own_enabled());
}
$sections['limit_disk_space']['fields']['modules[disk_space][limit]'] = [
'type' => 'number',
'title' => __('Disk Space Allowance', 'wp-ultimo'),
'desc' => __('Set a limit in MBs for the disk space for <strong>each</strong> individual site.', 'wp-ultimo'),
'title' => __('Disk Space Allowance', 'wp-multisite-waas'),
'desc' => __('Set a limit in MBs for the disk space for <strong>each</strong> individual site.', 'wp-multisite-waas'),
'min' => 0,
'placeholder' => 100,
'value' => $object->get_limitations()->disk_space->get_limit(),
'value' => $object_model->get_limitations()->disk_space->get_limit(),
'wrapper_html_attr' => [
'v-show' => "get_state_value('product_type', 'none') !== 'service' && limit_disk_space",
'v-cloak' => '1',
],
];
if ('product' !== $object->model) {
$sections['limit_disk_space']['fields']['disk_space_override'] = $this->override_notice($object->get_limitations(false)->disk_space->has_own_limit(), ['limit_disk_space']);
if ( 'product' !== $object_model->model) {
$sections['limit_disk_space']['fields']['disk_space_override'] = $this->override_notice($object_model->get_limitations(false)->disk_space->has_own_limit(), ['limit_disk_space']);
}
$sections['custom_domain'] = [
'title' => __('Custom Domains', 'wp-ultimo'),
'desc' => __('Limit the number of users on each role, posts, pages, and more.', 'wp-ultimo'),
'title' => __('Custom Domains', 'wp-multisite-waas'),
'desc' => __('Limit the number of users on each role, posts, pages, and more.', 'wp-multisite-waas'),
'icon' => 'dashicons-wu-link1',
'v-show' => "get_state_value('product_type', 'none') !== 'service'",
'state' => [
'allow_domain_mapping' => $object->get_limitations()->domain_mapping->is_enabled(),
'allow_domain_mapping' => $object_model->get_limitations()->domain_mapping->is_enabled(),
],
'fields' => [
'modules[domain_mapping][enabled]' => [
'type' => 'toggle',
'title' => __('Allow Custom Domains', 'wp-ultimo'),
'desc' => __('Toggle this option on to allow this plan to enable custom domains for sign-ups on this plan.', 'wp-ultimo'),
'value' => $object->get_limitations()->domain_mapping->is_enabled(),
'title' => __('Allow Custom Domains', 'wp-multisite-waas'),
'desc' => __('Toggle this option on to allow this plan to enable custom domains for sign-ups on this plan.', 'wp-multisite-waas'),
'value' => $object_model->get_limitations()->domain_mapping->is_enabled(),
'wrapper_html_attr' => [
'v-cloak' => '1',
],
@ -482,13 +482,13 @@ class Limitation_Manager {
],
];
if ('product' !== $object->model) {
$sections['custom_domain']['fields']['custom_domain_override'] = $this->override_notice($object->get_limitations(false)->domain_mapping->has_own_enabled(), ['allow_domain_mapping']);
if ( 'product' !== $object_model->model) {
$sections['custom_domain']['fields']['custom_domain_override'] = $this->override_notice($object_model->get_limitations(false)->domain_mapping->has_own_enabled(), ['allow_domain_mapping']);
}
$sections['allowed_themes'] = [
'title' => __('Themes', 'wp-ultimo'),
'desc' => __('Limit the number of users on each role, posts, pages, and more.', 'wp-ultimo'),
'title' => __('Themes', 'wp-multisite-waas'),
'desc' => __('Limit the number of users on each role, posts, pages, and more.', 'wp-multisite-waas'),
'icon' => 'dashicons-wu-palette',
'v-show' => "get_state_value('product_type', 'none') !== 'service'",
'state' => [
@ -497,24 +497,24 @@ class Limitation_Manager {
'fields' => [
'themes' => [
'type' => 'html',
'title' => __('Themes', 'wp-ultimo'),
'desc' => __('Select how the themes installed on the network should behave.', 'wp-ultimo'),
'content' => fn() => $this->get_theme_selection_list($object, $sections['allowed_themes']),
'title' => __('Themes', 'wp-multisite-waas'),
'desc' => __('Select how the themes installed on the network should behave.', 'wp-multisite-waas'),
'content' => fn() => $this->get_theme_selection_list($object_model, $sections['allowed_themes']),
],
],
];
$sections['allowed_plugins'] = [
'title' => __('Plugins', 'wp-ultimo'),
'desc' => __('You can choose the behavior of each plugin installed on the platform.', 'wp-ultimo'),
'title' => __('Plugins', 'wp-multisite-waas'),
'desc' => __('You can choose the behavior of each plugin installed on the platform.', 'wp-multisite-waas'),
'icon' => 'dashicons-wu-power-plug',
'v-show' => "get_state_value('product_type', 'none') !== 'service'",
'fields' => [
'plugins' => [
'type' => 'html',
'title' => __('Plugins', 'wp-ultimo'),
'desc' => __('Select how the plugins installed on the network should behave.', 'wp-ultimo'),
'content' => fn() => $this->get_plugin_selection_list($object),
'title' => __('Plugins', 'wp-multisite-waas'),
'desc' => __('Select how the plugins installed on the network should behave.', 'wp-multisite-waas'),
'content' => fn() => $this->get_plugin_selection_list($object_model),
],
],
];
@ -522,20 +522,20 @@ class Limitation_Manager {
$reset_url = wu_get_form_url(
'confirm_limitations_reset',
[
'id' => $object->get_id(),
'model' => $object->model,
'id' => $object_model->get_id(),
'model' => $object_model->model,
]
);
$sections['reset_limitations'] = [
'title' => __('Reset Limitations', 'wp-ultimo'),
'desc' => __('Reset the limitations applied to this element.', 'wp-ultimo'),
'title' => __('Reset Limitations', 'wp-multisite-waas'),
'desc' => __('Reset the limitations applied to this element.', 'wp-multisite-waas'),
'icon' => 'dashicons-wu-back-in-time',
'fields' => [
'reset_permissions' => [
'type' => 'note',
'title' => sprintf("%s<span class='wu-normal-case wu-block wu-text-xs wu-font-normal wu-mt-1'>%s</span>", __('Reset Limitations', 'wp-ultimo'), __('Use this option to reset the custom limitations applied to this object.', 'wp-ultimo')),
'desc' => sprintf('<a href="%s" title="%s" class="wubox button-primary">%s</a>', $reset_url, __('Reset Limitations', 'wp-ultimo'), __('Reset Limitations', 'wp-ultimo')),
'title' => sprintf("%s<span class='wu-normal-case wu-block wu-text-xs wu-font-normal wu-mt-1'>%s</span>", __('Reset Limitations', 'wp-multisite-waas'), __('Use this option to reset the custom limitations applied to this object.', 'wp-multisite-waas')),
'desc' => sprintf('<a href="%s" title="%s" class="wubox button-primary">%s</a>', $reset_url, __('Reset Limitations', 'wp-multisite-waas'), __('Reset Limitations', 'wp-multisite-waas')),
],
],
];
@ -554,7 +554,7 @@ class Limitation_Manager {
*/
protected function override_notice($show = false, $additional_checks = []) {
$text = sprintf('<p class="wu-m-0 wu-p-2 wu-bg-blue-100 wu-text-blue-600 wu-rounded">%s</p>', __('This value is being applied only to this entity. Changes made to the membership or product permissions will not affect this particular value.', 'wp-ultimo'));
$text = sprintf('<p class="wu-m-0 wu-p-2 wu-bg-blue-100 wu-text-blue-600 wu-rounded">%s</p>', __('This value is being applied only to this entity. Changes made to the membership or product permissions will not affect this particular value.', 'wp-multisite-waas'));
return [
'desc' => $text,
@ -573,23 +573,23 @@ class Limitation_Manager {
*
* @since 2.0.0
*
* @param array $sections Sections and fields.
* @param \WP_Ultimo\Models\Trait\Trait_Limitable $object The object being edit.
* @param array $sections Sections and fields.
* @param \WP_Ultimo\Models\Limitable $object_model The object being edit.
* @return void
*/
public function register_user_fields(&$sections, $object): void {
public function register_user_fields(&$sections, $object_model): void {
$user_roles = get_editable_roles();
$sections['users']['state']['roles'] = [];
foreach ($user_roles as $user_role_slug => $user_role) {
$sections['users']['state']['roles'][ $user_role_slug ] = $object->get_limitations()->users->{$user_role_slug};
$sections['users']['state']['roles'][ $user_role_slug ] = $object_model->get_limitations()->users->{$user_role_slug};
$sections['users']['fields'][ "control_{$user_role_slug}" ] = [
'type' => 'group',
'title' => sprintf(__('Limit %s Role', 'wp-ultimo'), $user_role['name']),
'desc' => sprintf(__('The customer will be able to create %s users(s) of this user role.', 'wp-ultimo'), "{{ roles['{$user_role_slug}'].enabled ? ( parseInt(roles['{$user_role_slug}'].number, 10) ? roles['{$user_role_slug}'].number : '" . __('unlimited', 'wp-ultimo') . "' ) : '" . __('no', 'wp-ultimo') . "' }}"),
'title' => sprintf(__('Limit %s Role', 'wp-multisite-waas'), $user_role['name']),
'desc' => sprintf(__('The customer will be able to create %s users(s) of this user role.', 'wp-multisite-waas'), "{{ roles['{$user_role_slug}'].enabled ? ( parseInt(roles['{$user_role_slug}'].number, 10) ? roles['{$user_role_slug}'].number : '" . __('unlimited', 'wp-multisite-waas') . "' ) : '" . __('no', 'wp-multisite-waas') . "' }}"),
'tooltip' => '',
'wrapper_html_attr' => [
'v-bind:class' => "!roles['{$user_role_slug}'].enabled ? 'wu-opacity-75' : ''",
@ -599,7 +599,7 @@ class Limitation_Manager {
'fields' => [
"modules[users][limit][{$user_role_slug}][number]" => [
'type' => 'number',
'placeholder' => sprintf(__('%s Role Quota. e.g. 10', 'wp-ultimo'), $user_role['name']),
'placeholder' => sprintf(__('%s Role Quota. e.g. 10', 'wp-multisite-waas'), $user_role['name']),
'min' => 0,
'wrapper_classes' => 'wu-w-full',
'html_attr' => [
@ -620,8 +620,8 @@ class Limitation_Manager {
/*
* Add override notice.
*/
if ('product' !== $object->model) {
$sections['users']['fields'][ "override_{$user_role_slug}" ] = $this->override_notice($object->get_limitations(false)->users->exists($user_role_slug), ['limit_users']);
if ('product' !== $object_model->model) {
$sections['users']['fields'][ "override_{$user_role_slug}" ] = $this->override_notice($object_model->get_limitations(false)->users->exists($user_role_slug), ['limit_users']);
}
}
}
@ -631,23 +631,23 @@ class Limitation_Manager {
*
* @since 2.0.0
*
* @param array $sections Sections and fields.
* @param \WP_Ultimo\Models\Trait\Trait_Limitable $object The object being edit.
* @param array $sections Sections and fields.
* @param \WP_Ultimo\Models\Limitable $object_model The object being edit.
* @return void
*/
public function register_post_type_fields(&$sections, $object): void {
public function register_post_type_fields(&$sections, $object_model): void {
$post_types = get_post_types([], 'objects');
$sections['post_types']['state']['types'] = [];
foreach ($post_types as $post_type_slug => $post_type) {
$sections['post_types']['state']['types'][ $post_type_slug ] = $object->get_limitations()->post_types->{$post_type_slug};
$sections['post_types']['state']['types'][ $post_type_slug ] = $object_model->get_limitations()->post_types->{$post_type_slug};
$sections['post_types']['fields'][ "control_{$post_type_slug}" ] = [
'type' => 'group',
'title' => sprintf(__('Limit %s', 'wp-ultimo'), $post_type->label),
'desc' => sprintf(__('The customer will be able to create %s post(s) of this post type.', 'wp-ultimo'), "{{ types['{$post_type_slug}'].enabled ? ( parseInt(types['{$post_type_slug}'].number, 10) ? types['{$post_type_slug}'].number : '" . __('unlimited', 'wp-ultimo') . "' ) : '" . __('no', 'wp-ultimo') . "' }}"),
'title' => sprintf(__('Limit %s', 'wp-multisite-waas'), $post_type->label),
'desc' => sprintf(__('The customer will be able to create %s post(s) of this post type.', 'wp-multisite-waas'), "{{ types['{$post_type_slug}'].enabled ? ( parseInt(types['{$post_type_slug}'].number, 10) ? types['{$post_type_slug}'].number : '" . __('unlimited', 'wp-multisite-waas') . "' ) : '" . __('no', 'wp-multisite-waas') . "' }}"),
'tooltip' => '',
'wrapper_html_attr' => [
'v-bind:class' => "!types['{$post_type_slug}'].enabled ? 'wu-opacity-75' : ''",
@ -657,7 +657,7 @@ class Limitation_Manager {
'fields' => [
"modules[post_types][limit][{$post_type_slug}][number]" => [
'type' => 'number',
'placeholder' => sprintf(__('%s Quota. e.g. 200', 'wp-ultimo'), $post_type->label),
'placeholder' => sprintf(__('%s Quota. e.g. 200', 'wp-multisite-waas'), $post_type->label),
'min' => 0,
'wrapper_classes' => 'wu-w-full',
'html_attr' => [
@ -678,9 +678,9 @@ class Limitation_Manager {
/*
* Add override notice.
*/
if ('product' !== $object->model) {
if ('product' !== $object_model->model) {
$sections['post_types']['fields'][ "override_{$post_type_slug}" ] = $this->override_notice(
$object->get_limitations(false)->post_types->exists($post_type_slug),
$object_model->get_limitations(false)->post_types->exists($post_type_slug),
[
'limit_post_types',
]
@ -694,25 +694,25 @@ class Limitation_Manager {
*
* @since 2.0.0
*
* @param \WP_Ultimo\Models\Trait\Trait_Limitable $object The model being edited.
* @param \WP_Ultimo\Models\Limitable $object_model The model being edited.
* @return array
*/
protected function get_sites_fields($object) {
protected function get_sites_fields($object_model) {
$fields = [
'modules[sites][enabled]' => [
'type' => 'toggle',
'title' => __('Limit Sites', 'wp-ultimo'),
'desc' => __('Enable site limitations for this product.', 'wp-ultimo'),
'value' => $object->get_limitations()->sites->is_enabled(),
'title' => __('Limit Sites', 'wp-multisite-waas'),
'desc' => __('Enable site limitations for this product.', 'wp-multisite-waas'),
'value' => $object_model->get_limitations()->sites->is_enabled(),
'html_attr' => [
'v-model' => 'limit_sites',
],
],
];
if ('product' !== $object->model) {
$fields['sites_overwrite'] = $this->override_notice($object->get_limitations(false)->sites->has_own_enabled());
if ('product' !== $object_model->model) {
$fields['sites_overwrite'] = $this->override_notice($object_model->get_limitations(false)->sites->has_own_enabled());
}
/*
@ -720,7 +720,7 @@ class Limitation_Manager {
*/
$fields['site_not_allowed_note'] = [
'type' => 'note',
'desc' => __('The product type selection does not support allowing for the creating of extra sites.', 'wp-ultimo'),
'desc' => __('The product type selection does not support allowing for the creating of extra sites.', 'wp-multisite-waas'),
'tooltip' => '',
'wrapper_html_attr' => [
'v-show' => "get_state_value('product_type', 'none') === 'service' && limit_sites",
@ -731,21 +731,21 @@ class Limitation_Manager {
$fields['modules[sites][limit]'] = [
'type' => 'number',
'min' => 1,
'title' => __('Site Allowance', 'wp-ultimo'),
'desc' => __('This is the number of sites the customer will be able to create under this membership.', 'wp-ultimo'),
'title' => __('Site Allowance', 'wp-multisite-waas'),
'desc' => __('This is the number of sites the customer will be able to create under this membership.', 'wp-multisite-waas'),
'placeholder' => 1,
'value' => $object->get_limitations()->sites->get_limit(),
'value' => $object_model->get_limitations()->sites->get_limit(),
'wrapper_html_attr' => [
'v-show' => "get_state_value('product_type', 'none') !== 'service' && limit_sites",
'v-cloak' => '1',
],
];
if ('product' !== $object->model) {
$fields['sites_overwrite_2'] = $this->override_notice($object->get_limitations(false)->sites->has_own_limit(), ["get_state_value('product_type', 'none') !== 'service' && limit_sites"]);
if ('product' !== $object_model->model) {
$fields['sites_overwrite_2'] = $this->override_notice($object_model->get_limitations(false)->sites->has_own_limit(), ["get_state_value('product_type', 'none') !== 'service' && limit_sites"]);
}
return apply_filters('wu_limitations_get_sites_fields', $fields, $object, $this);
return apply_filters('wu_limitations_get_sites_fields', $fields, $object_model, $this);
}
/**
@ -753,10 +753,10 @@ class Limitation_Manager {
*
* @since 2.0.0
*
* @param \WP_Ultimo\Models\Trait\Trait_Limitable $object The model being edited.
* @param \WP_Ultimo\Models\Limitable $object_model The model being edited.
* @return string
*/
public function get_plugin_selection_list($object) {
public function get_plugin_selection_list($object_model) {
$all_plugins = $this->get_all_plugins();
@ -764,7 +764,7 @@ class Limitation_Manager {
'limitations/plugin-selector',
[
'plugins' => $all_plugins,
'object' => $object,
'object' => $object_model,
]
);
}
@ -774,11 +774,11 @@ class Limitation_Manager {
*
* @since 2.0.0
*
* @param \WP_Ultimo\Models\Trait\Trait_Limitable $object The model being edited.
* @param array $section The section array.
* @param \WP_Ultimo\Models\Limitable $obj The model being edited.
* @param array $section The section array.
* @return string
*/
public function get_theme_selection_list($object, &$section) {
public function get_theme_selection_list($obj, &$section) {
$all_themes = $this->get_all_themes();
@ -787,7 +787,7 @@ class Limitation_Manager {
[
'section' => $section,
'themes' => $all_themes,
'object' => $object,
'object' => $obj,
]
);
}