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

@ -56,7 +56,7 @@ class Block_Manager extends Base_Manager {
[
[
'slug' => 'wp-ultimo',
'title' => __('Multisite WaaS', 'wp-ultimo'),
'title' => __('Multisite WaaS', 'wp-multisite-waas'),
],
]
);

View File

@ -127,7 +127,7 @@ class Broadcast_Manager extends Base_Manager {
$target_products = wu_request('target_products', '');
if ( ! $target_customers && ! $target_products) {
wp_send_json_error(new \WP_Error('error', __('No product or customer target was selected.', 'wp-ultimo')));
wp_send_json_error(new \WP_Error('error', __('No product or customer target was selected.', 'wp-multisite-waas')));
}
$broadcast_type = wu_request('type', 'broadcast_notice');
@ -248,7 +248,7 @@ class Broadcast_Manager extends Base_Manager {
}
}
$error = new \WP_Error('mail-error', __('Something wrong happened.', 'wp-ultimo'));
$error = new \WP_Error('mail-error', __('Something wrong happened.', 'wp-multisite-waas'));
wp_send_json_error($error);
}

View File

@ -11,7 +11,7 @@
namespace WP_Ultimo\Managers;
use WP_Ultimo\Managers\Base_Manager;
use WP_Ultimo\Checkout\Checkout;
use WP_Ultimo\Models\Customer;
use WP_Ultimo\Database\Memberships\Membership_Status;
@ -62,7 +62,7 @@ class Customer_Manager extends Base_Manager {
function () {
Event_Manager::register_model_events(
'customer',
__('Customer', 'wp-ultimo'),
__('Customer', 'wp-multisite-waas'),
['created', 'updated']
);
}
@ -89,7 +89,7 @@ class Customer_Manager extends Base_Manager {
public function handle_resend_verification_email(): void {
if ( ! check_ajax_referer('wu_resend_verification_email_nonce', false, false)) {
wp_send_json_error(new \WP_Error('not-allowed', __('Error: you are not allowed to perform this action.', 'wp-ultimo')));
wp_send_json_error(new \WP_Error('not-allowed', __('Error: you are not allowed to perform this action.', 'wp-multisite-waas')));
exit;
}
@ -97,7 +97,7 @@ class Customer_Manager extends Base_Manager {
$customer = wu_get_current_customer();
if ( ! $customer) {
wp_send_json_error(new \WP_Error('customer-not-found', __('Error: customer not found.', 'wp-ultimo')));
wp_send_json_error(new \WP_Error('customer-not-found', __('Error: customer not found.', 'wp-multisite-waas')));
exit;
}
@ -129,7 +129,7 @@ class Customer_Manager extends Base_Manager {
*
* @since 2.0.0
*
* @param WP_User $user The WP User object of the user that logged in.
* @param \WP_User $user The WP User object of the user that logged in.
* @return void
*/
public function log_ip_and_last_login($user): void {
@ -200,13 +200,15 @@ class Customer_Manager extends Base_Manager {
wp_die(
sprintf(
/* translators: the placeholder is the login URL */
__('You must be authenticated in order to verify your email address. <a href=%s>Click here</a> to access your account.', 'wp-ultimo'),
wp_login_url(
add_query_arg(
[
'email-verification-key' => $email_verify_key,
'customer' => $customer_hash,
]
wp_kses_post(__('You must be authenticated in order to verify your email address. <a href=%s>Click here</a> to access your account.', 'wp-multisite-waas')),
esc_attr(
wp_login_url(
add_query_arg(
[
'email-verification-key' => $email_verify_key,
'customer' => $customer_hash,
]
)
)
)
)
@ -214,31 +216,31 @@ class Customer_Manager extends Base_Manager {
}
if ( ! $customer_to_verify) {
wp_die(__('Invalid verification key.', 'wp-ultimo'));
wp_die(wp_kses_post(__('<strong>ERROR:</strong> Invalid verification key.', 'wp-multisite-waas')));
}
$current_customer = wu_get_current_customer();
if ( ! $current_customer) {
wp_die(__('Invalid verification key.', 'wp-ultimo'));
wp_die(wp_kses_post(__('<strong>Error:</strong> Invalid verification key.', 'wp-multisite-waas')));
}
if ($current_customer->get_id() !== $customer_to_verify->get_id()) {
wp_die(__('Invalid verification key.', 'wp-ultimo'));
wp_die(esc_html__('Invalid verification key.', 'wp-multisite-waas'));
}
if ($customer_to_verify->get_email_verification() !== 'pending') {
wp_die(__('Invalid verification key.', 'wp-ultimo'));
wp_die(esc_html__('Invalid verification key.', 'wp-multisite-waas'));
}
$key = $customer_to_verify->get_verification_key();
if ( ! $key) {
wp_die(__('Invalid verification key.', 'wp-ultimo'));
wp_die(wp_kses_post(__('<strong>Error:</strong> Invalid verification key.', 'wp-multisite-waas')));
}
if ($key !== $email_verify_key) {
wp_die(__('Invalid verification key.', 'wp-ultimo'));
wp_die(esc_html__('Invalid verification key.', 'wp-multisite-waas'));
}
/*
@ -287,13 +289,13 @@ class Customer_Manager extends Base_Manager {
wu_get_registration_url()
);
wp_redirect($redirect_url);
wp_safe_redirect($redirect_url);
exit;
}
}
wp_redirect(get_admin_url($customer_to_verify->get_primary_site_id()));
wp_safe_redirect(get_admin_url($customer_to_verify->get_primary_site_id()));
exit;
}

View File

@ -12,7 +12,6 @@
namespace WP_Ultimo\Managers;
use WP_Ultimo\Managers\Base_Manager;
use WP_Ultimo\Domain_Mapping\Helper;
// Exit if accessed directly
@ -72,7 +71,7 @@ class Domain_Manager extends Base_Manager {
* @since 2.0.0
*
* @param string $id The id of the integration. e.g. runcloud.
* @return WP_Ultimo\Integrations\Host_Providers\Base_Host_Provider
* @return \WP_Ultimo\Integrations\Host_Providers\Base_Host_Provider|false
*/
public function get_integration_instance($id) {
@ -255,8 +254,8 @@ class Domain_Manager extends Base_Manager {
'domain-mapping',
'domain_mapping_header',
[
'title' => __('Domain Mapping Settings', 'wp-ultimo'),
'desc' => __('Define the domain mapping settings for your network.', 'wp-ultimo'),
'title' => __('Domain Mapping Settings', 'wp-multisite-waas'),
'desc' => __('Define the domain mapping settings for your network.', 'wp-multisite-waas'),
'type' => 'header',
]
);
@ -265,8 +264,8 @@ class Domain_Manager extends Base_Manager {
'domain-mapping',
'enable_domain_mapping',
[
'title' => __('Enable Domain Mapping?', 'wp-ultimo'),
'desc' => __('Do you want to enable domain mapping?', 'wp-ultimo'),
'title' => __('Enable Domain Mapping?', 'wp-multisite-waas'),
'desc' => __('Do you want to enable domain mapping?', 'wp-multisite-waas'),
'type' => 'toggle',
'default' => 1,
]
@ -276,16 +275,16 @@ class Domain_Manager extends Base_Manager {
'domain-mapping',
'force_admin_redirect',
[
'title' => __('Force Admin Redirect', 'wp-ultimo'),
'desc' => __('Select how you want your users to access the admin panel if they have mapped domains.', 'wp-ultimo') . '<br><br>' . __('Force Redirect to Mapped Domain: your users with mapped domains will be redirected to theirdomain.com/wp-admin, even if they access using yournetworkdomain.com/wp-admin.', 'wp-ultimo') . '<br><br>' . __('Force Redirect to Network Domain: your users with mapped domains will be redirect to yournetworkdomain.com/wp-admin, even if they access using theirdomain.com/wp-admin.', 'wp-ultimo'),
'title' => __('Force Admin Redirect', 'wp-multisite-waas'),
'desc' => __('Select how you want your users to access the admin panel if they have mapped domains.', 'wp-multisite-waas') . '<br><br>' . __('Force Redirect to Mapped Domain: your users with mapped domains will be redirected to theirdomain.com/wp-admin, even if they access using yournetworkdomain.com/wp-admin.', 'wp-multisite-waas') . '<br><br>' . __('Force Redirect to Network Domain: your users with mapped domains will be redirect to yournetworkdomain.com/wp-admin, even if they access using theirdomain.com/wp-admin.', 'wp-multisite-waas'),
'tooltip' => '',
'type' => 'select',
'default' => 'both',
'require' => ['enable_domain_mapping' => 1],
'options' => [
'both' => __('Allow access to the admin by both mapped domain and network domain', 'wp-ultimo'),
'force_map' => __('Force Redirect to Mapped Domain', 'wp-ultimo'),
'force_network' => __('Force Redirect to Network Domain', 'wp-ultimo'),
'both' => __('Allow access to the admin by both mapped domain and network domain', 'wp-multisite-waas'),
'force_map' => __('Force Redirect to Mapped Domain', 'wp-multisite-waas'),
'force_network' => __('Force Redirect to Network Domain', 'wp-multisite-waas'),
],
]
);
@ -294,8 +293,8 @@ class Domain_Manager extends Base_Manager {
'domain-mapping',
'custom_domains',
[
'title' => __('Enable Custom Domains?', 'wp-ultimo'),
'desc' => __('Toggle this option if you wish to allow end-customers to add their own domains. This can be controlled on a plan per plan basis.', 'wp-ultimo'),
'title' => __('Enable Custom Domains?', 'wp-multisite-waas'),
'desc' => __('Toggle this option if you wish to allow end-customers to add their own domains. This can be controlled on a plan per plan basis.', 'wp-multisite-waas'),
'type' => 'toggle',
'default' => 1,
'require' => [
@ -308,9 +307,9 @@ class Domain_Manager extends Base_Manager {
'domain-mapping',
'domain_mapping_instructions',
[
'title' => __('Add New Domain Instructions', 'wp-ultimo'),
'tooltip' => __('Display a customized message with instructions for the mapping and alerting the end-user of the risks of mapping a misconfigured domain.', 'wp-ultimo'),
'desc' => __('You can use the placeholder <code>%NETWORK_DOMAIN%</code> and <code>%NETWORK_IP%</code>.', 'wp-ultimo'),
'title' => __('Add New Domain Instructions', 'wp-multisite-waas'),
'tooltip' => __('Display a customized message with instructions for the mapping and alerting the end-user of the risks of mapping a misconfigured domain.', 'wp-multisite-waas'),
'desc' => __('You can use the placeholder <code>%NETWORK_DOMAIN%</code> and <code>%NETWORK_IP%</code>.', 'wp-multisite-waas'),
'type' => 'textarea',
'default' => [$this, 'default_domain_mapping_instructions'],
'html_attr' => [
@ -336,8 +335,8 @@ class Domain_Manager extends Base_Manager {
'sso',
'sso_header',
[
'title' => __('Single Sign-On Settings', 'wp-ultimo'),
'desc' => __('Settings to configure the Single Sign-On functionality of WP Multisite WaaS, responsible for keeping customers and admins logged in across all network domains.', 'wp-ultimo'),
'title' => __('Single Sign-On Settings', 'wp-multisite-waas'),
'desc' => __('Settings to configure the Single Sign-On functionality of WP Multisite WaaS, responsible for keeping customers and admins logged in across all network domains.', 'wp-multisite-waas'),
'type' => 'header',
]
);
@ -346,8 +345,8 @@ class Domain_Manager extends Base_Manager {
'sso',
'enable_sso',
[
'title' => __('Enable Single Sign-On', 'wp-ultimo'),
'desc' => __('Enables the Single Sign-on functionality.', 'wp-ultimo'),
'title' => __('Enable Single Sign-On', 'wp-multisite-waas'),
'desc' => __('Enables the Single Sign-on functionality.', 'wp-multisite-waas'),
'type' => 'toggle',
'default' => 1,
]
@ -357,8 +356,8 @@ class Domain_Manager extends Base_Manager {
'sso',
'restrict_sso_to_login_pages',
[
'title' => __('Restrict SSO Checks to Login Pages', 'wp-ultimo'),
'desc' => __('The Single Sign-on feature adds one extra ajax calls to every page load on sites with custom domains active to check if it should perform an auth loopback. You can restrict these extra calls to the login pages of sub-sites using this option. If enabled, SSO will only work on login pages.', 'wp-ultimo'),
'title' => __('Restrict SSO Checks to Login Pages', 'wp-multisite-waas'),
'desc' => __('The Single Sign-on feature adds one extra ajax calls to every page load on sites with custom domains active to check if it should perform an auth loopback. You can restrict these extra calls to the login pages of sub-sites using this option. If enabled, SSO will only work on login pages.', 'wp-multisite-waas'),
'type' => 'toggle',
'default' => 0,
'require' => [
@ -371,8 +370,8 @@ class Domain_Manager extends Base_Manager {
'sso',
'enable_sso_loading_overlay',
[
'title' => __('Enable SSO Loading Overlay', 'wp-ultimo'),
'desc' => __('When active, a loading overlay will be added on-top of the site currently being viewed while the SSO auth loopback is performed on the background.', 'wp-ultimo'),
'title' => __('Enable SSO Loading Overlay', 'wp-multisite-waas'),
'desc' => __('When active, a loading overlay will be added on-top of the site currently being viewed while the SSO auth loopback is performed on the background.', 'wp-multisite-waas'),
'type' => 'toggle',
'default' => 1,
'require' => [
@ -391,11 +390,11 @@ class Domain_Manager extends Base_Manager {
$instructions = [];
$instructions[] = __("Cool! You're about to make this site accessible using your own domain name!", 'wp-ultimo');
$instructions[] = __("Cool! You're about to make this site accessible using your own domain name!", 'wp-multisite-waas');
$instructions[] = __("For that to work, you'll need to create a new CNAME record pointing to <code>%NETWORK_DOMAIN%</code> on your DNS manager.", 'wp-ultimo');
$instructions[] = __("For that to work, you'll need to create a new CNAME record pointing to <code>%NETWORK_DOMAIN%</code> on your DNS manager.", 'wp-multisite-waas');
$instructions[] = __('After you finish that step, come back to this screen and click the button below.', 'wp-ultimo');
$instructions[] = __('After you finish that step, come back to this screen and click the button below.', 'wp-multisite-waas');
return implode(PHP_EOL . PHP_EOL, $instructions);
}
@ -480,7 +479,7 @@ class Domain_Manager extends Base_Manager {
$domain_url = $domain->get_domain();
// translators: %s is the domain name
wu_log_add("domain-{$domain_url}", sprintf(__('Starting Check for %s', 'wp-ultimo'), $domain_url));
wu_log_add("domain-{$domain_url}", sprintf(__('Starting Check for %s', 'wp-multisite-waas'), $domain_url));
if ('checking-dns' === $stage) {
if ($domain->has_correct_dns()) {
@ -490,7 +489,7 @@ class Domain_Manager extends Base_Manager {
wu_log_add(
"domain-{$domain_url}",
__('- DNS propagation finished, advancing domain to next step...', 'wp-ultimo')
__('- DNS propagation finished, advancing domain to next step...', 'wp-multisite-waas')
);
wu_enqueue_async_action(
@ -517,7 +516,7 @@ class Domain_Manager extends Base_Manager {
wu_log_add(
"domain-{$domain_url}",
// translators: %d is the number of minutes to try again.
sprintf(__('- DNS propagation checks tried for the max amount of times (5 times, one every %d minutes). Marking as failed.', 'wp-ultimo'), $try_again_time)
sprintf(__('- DNS propagation checks tried for the max amount of times (5 times, one every %d minutes). Marking as failed.', 'wp-multisite-waas'), $try_again_time)
);
return;
@ -526,7 +525,7 @@ class Domain_Manager extends Base_Manager {
wu_log_add(
"domain-{$domain_url}",
// translators: %d is the number of minutes before trying again.
sprintf(__('- DNS propagation not finished, retrying in %d minutes...', 'wp-ultimo'), $try_again_time)
sprintf(__('- DNS propagation not finished, retrying in %d minutes...', 'wp-multisite-waas'), $try_again_time)
);
wu_schedule_single_action(
@ -551,7 +550,7 @@ class Domain_Manager extends Base_Manager {
wu_log_add(
"domain-{$domain_url}",
__('- Valid SSL cert found. Marking domain as done.', 'wp-ultimo')
__('- Valid SSL cert found. Marking domain as done.', 'wp-multisite-waas')
);
return;
@ -567,7 +566,7 @@ class Domain_Manager extends Base_Manager {
wu_log_add(
"domain-{$domain_url}",
// translators: %d is the number of minutes to try again.
sprintf(__('- SSL checks tried for the max amount of times (5 times, one every %d minutes). Marking as ready without SSL.', 'wp-ultimo'), $try_again_time)
sprintf(__('- SSL checks tried for the max amount of times (5 times, one every %d minutes). Marking as ready without SSL.', 'wp-multisite-waas'), $try_again_time)
);
return;
@ -576,7 +575,7 @@ class Domain_Manager extends Base_Manager {
wu_log_add(
"domain-{$domain_url}",
// translators: %d is the number of minutes before trying again.
sprintf(__('- SSL Cert not found, retrying in %d minute(s)...', 'wp-ultimo'), $try_again_time)
sprintf(__('- SSL Cert not found, retrying in %d minute(s)...', 'wp-multisite-waas'), $try_again_time)
);
wu_schedule_single_action(
@ -665,7 +664,7 @@ class Domain_Manager extends Base_Manager {
$domain = wu_request('domain');
if ( ! $domain) {
wp_send_json_error(new \WP_Error('domain-missing', __('A valid domain was not passed.', 'wp-ultimo')));
wp_send_json_error(new \WP_Error('domain-missing', __('A valid domain was not passed.', 'wp-multisite-waas')));
}
$auth_ns = [];
@ -678,7 +677,7 @@ class Domain_Manager extends Base_Manager {
wp_send_json_error(
new \WP_Error(
'error',
__('Not able to fetch DNS entries.', 'wp-ultimo'),
__('Not able to fetch DNS entries.', 'wp-multisite-waas'),
[
'exception' => $e->getMessage(),
]
@ -687,7 +686,7 @@ class Domain_Manager extends Base_Manager {
}
if (false === $result) {
wp_send_json_error(new \WP_Error('error', __('Not able to fetch DNS entries.', 'wp-ultimo')));
wp_send_json_error(new \WP_Error('error', __('Not able to fetch DNS entries.', 'wp-multisite-waas')));
}
wp_send_json_success(
@ -738,7 +737,7 @@ class Domain_Manager extends Base_Manager {
if ( ! $integration) {
wp_send_json_error(
[
'message' => __('Invalid Integration ID', 'wp-ultimo'),
'message' => __('Invalid Integration ID', 'wp-multisite-waas'),
]
);
}
@ -750,14 +749,15 @@ class Domain_Manager extends Base_Manager {
wp_send_json_error(
[
'message' => sprintf(
__('The necessary constants were not found on your wp-config.php file: %s', 'wp-ultimo'),
// translators: %s is the name of the missing constant
__('The necessary constants were not found on your wp-config.php file: %s', 'wp-multisite-waas'),
implode(', ', $integration->get_missing_constants())
),
]
);
}
return $integration->test_connection();
$integration->test_connection();
}
/**

View File

@ -133,7 +133,7 @@ class Email_Manager extends Base_Manager {
$to = $email->get_target_list($payload);
if (empty($to)) {
wu_log_add('mailer', __('No targets found.', 'wp-ultimo'));
wu_log_add('mailer', __('No targets found.', 'wp-multisite-waas'));
return;
}
@ -218,8 +218,8 @@ class Email_Manager extends Base_Manager {
'emails',
'sender_header',
[
'title' => __('Sender Settings', 'wp-ultimo'),
'desc' => __('Change the settings of the email headers, like from and name.', 'wp-ultimo'),
'title' => __('Sender Settings', 'wp-multisite-waas'),
'desc' => __('Change the settings of the email headers, like from and name.', 'wp-multisite-waas'),
'type' => 'header',
]
);
@ -228,8 +228,8 @@ class Email_Manager extends Base_Manager {
'emails',
'from_name',
[
'title' => __('"From" Name', 'wp-ultimo'),
'desc' => __('How the sender name will appear in emails sent by WP Multisite WaaS.', 'wp-ultimo'),
'title' => __('"From" Name', 'wp-multisite-waas'),
'desc' => __('How the sender name will appear in emails sent by WP Multisite WaaS.', 'wp-multisite-waas'),
'type' => 'text',
'placeholder' => get_network_option(null, 'site_name'),
'default' => get_network_option(null, 'site_name'),
@ -243,8 +243,8 @@ class Email_Manager extends Base_Manager {
'emails',
'from_email',
[
'title' => __('"From" E-mail', 'wp-ultimo'),
'desc' => __('How the sender email will appear in emails sent by WP Multisite WaaS.', 'wp-ultimo'),
'title' => __('"From" E-mail', 'wp-multisite-waas'),
'desc' => __('How the sender email will appear in emails sent by WP Multisite WaaS.', 'wp-multisite-waas'),
'type' => 'email',
'placeholder' => get_network_option(null, 'admin_email'),
'default' => get_network_option(null, 'admin_email'),
@ -258,8 +258,8 @@ class Email_Manager extends Base_Manager {
'emails',
'template_header',
[
'title' => __('Template Settings', 'wp-ultimo'),
'desc' => __('Change the settings of the email templates.', 'wp-ultimo'),
'title' => __('Template Settings', 'wp-multisite-waas'),
'desc' => __('Change the settings of the email templates.', 'wp-multisite-waas'),
'type' => 'header',
]
);
@ -268,13 +268,13 @@ class Email_Manager extends Base_Manager {
'emails',
'email_template_type',
[
'title' => __('Email Templates Style', 'wp-ultimo'),
'desc' => __('Choose if email body will be sent using the HTML template or in plain text.', 'wp-ultimo'),
'title' => __('Email Templates Style', 'wp-multisite-waas'),
'desc' => __('Choose if email body will be sent using the HTML template or in plain text.', 'wp-multisite-waas'),
'type' => 'select',
'default' => 'html',
'options' => [
'html' => __('HTML Emails', 'wp-ultimo'),
'plain' => __('Plain Emails', 'wp-ultimo'),
'html' => __('HTML Emails', 'wp-multisite-waas'),
'plain' => __('Plain Emails', 'wp-multisite-waas'),
],
'html_attr' => [
'v-model' => 'emails_template',
@ -286,8 +286,8 @@ class Email_Manager extends Base_Manager {
'emails',
'expiring_header',
[
'title' => __('Expiring Notification Settings', 'wp-ultimo'),
'desc' => __('Change the settings for the expiring notification (trials and subscriptions) emails.', 'wp-ultimo'),
'title' => __('Expiring Notification Settings', 'wp-multisite-waas'),
'desc' => __('Change the settings for the expiring notification (trials and subscriptions) emails.', 'wp-multisite-waas'),
'type' => 'header',
]
);
@ -296,10 +296,10 @@ class Email_Manager extends Base_Manager {
'emails',
'expiring_days',
[
'title' => __('Days to Expire', 'wp-ultimo'),
'desc' => __('Select when we should send the notification email. If you select 3 days, for example, a notification email will be sent to every membership (or trial period) expiring in the next 3 days. Memberships are checked hourly.', 'wp-ultimo'),
'title' => __('Days to Expire', 'wp-multisite-waas'),
'desc' => __('Select when we should send the notification email. If you select 3 days, for example, a notification email will be sent to every membership (or trial period) expiring in the next 3 days. Memberships are checked hourly.', 'wp-multisite-waas'),
'type' => 'number',
'placeholder' => __('e.g. 3', 'wp-ultimo'),
'placeholder' => __('e.g. 3', 'wp-multisite-waas'),
'html_attr' => [
'v-model' => 'expiring_days',
],
@ -383,6 +383,9 @@ class Email_Manager extends Base_Manager {
* @return void
*/
public function register_all_default_system_emails(): void {
// TODO: Don't render every email until they are used.
/*
* Payment Successful - Admin
*/
@ -391,7 +394,7 @@ class Email_Manager extends Base_Manager {
'event' => 'payment_received',
'slug' => 'payment_received_admin',
'target' => 'admin',
'title' => __('You got a new payment!', 'wp-ultimo'),
'title' => __('You got a new payment!', 'wp-multisite-waas'),
'content' => wu_get_template_contents('emails/admin/payment-received'),
]
);
@ -404,7 +407,7 @@ class Email_Manager extends Base_Manager {
'event' => 'payment_received',
'slug' => 'payment_received_customer',
'target' => 'customer',
'title' => __('We got your payment!', 'wp-ultimo'),
'title' => __('We got your payment!', 'wp-multisite-waas'),
'content' => wu_get_template_contents('emails/customer/payment-received'),
]
);
@ -417,7 +420,7 @@ class Email_Manager extends Base_Manager {
'event' => 'site_published',
'target' => 'admin',
'slug' => 'site_published_admin',
'title' => __('A new site was created on your Network!', 'wp-ultimo'),
'title' => __('A new site was created on your Network!', 'wp-multisite-waas'),
'content' => wu_get_template_contents('emails/admin/site-published'),
]
);
@ -430,7 +433,7 @@ class Email_Manager extends Base_Manager {
'event' => 'site_published',
'target' => 'customer',
'slug' => 'site_published_customer',
'title' => __('Your site is ready!', 'wp-ultimo'),
'title' => __('Your site is ready!', 'wp-multisite-waas'),
'content' => wu_get_template_contents('emails/customer/site-published'),
]
);
@ -443,7 +446,7 @@ class Email_Manager extends Base_Manager {
'event' => 'confirm_email_address',
'target' => 'customer',
'slug' => 'confirm_email_address',
'title' => __('Confirm your email address!', 'wp-ultimo'),
'title' => __('Confirm your email address!', 'wp-multisite-waas'),
'content' => wu_get_template_contents('emails/customer/confirm-email-address'),
]
);
@ -456,7 +459,7 @@ class Email_Manager extends Base_Manager {
'event' => 'domain_created',
'target' => 'admin',
'slug' => 'domain_created_admin',
'title' => __('A new domain was added to your Network!', 'wp-ultimo'),
'title' => __('A new domain was added to your Network!', 'wp-multisite-waas'),
'content' => wu_get_template_contents('emails/admin/domain-created'),
]
);
@ -469,7 +472,7 @@ class Email_Manager extends Base_Manager {
'event' => 'renewal_payment_created',
'target' => 'customer',
'slug' => 'renewal_payment_created',
'title' => __('You have a new pending payment!', 'wp-ultimo'),
'title' => __('You have a new pending payment!', 'wp-multisite-waas'),
'content' => wu_get_template_contents('emails/customer/renewal-payment-created'),
]
);

View File

@ -11,7 +11,6 @@
namespace WP_Ultimo\Managers;
use WP_Ultimo\Managers\Base_Manager;
use WP_Ultimo\Models\Base_Model;
use WP_Ultimo\Models\Event;
@ -93,10 +92,11 @@ class Event_Manager extends Base_Manager {
* @param string $model The model name.
* @param array $data The data being saved, serialized.
* @param array $data_unserialized The data being saved, un-serialized.
* @param Base_Model $object The object being saved.
* @param Base_Model $obj The object being saved.
*
* @return void
*/
public function log_transitions($model, $data, $data_unserialized, $object) {
public function log_transitions($model, $data, $data_unserialized, $obj) {
if ('event' === $model) {
return;
@ -106,7 +106,7 @@ class Event_Manager extends Base_Manager {
* Editing Model
*/
if (wu_get_isset($data_unserialized, 'id')) {
$original = $object->_get_original();
$original = $obj->_get_original();
$diff = wu_array_recursive_diff($data_unserialized, $original);
@ -147,7 +147,7 @@ class Event_Manager extends Base_Manager {
return;
}
if (empty(json_encode($old_value)) && empty(json_encode($new_value))) {
if (empty(wp_json_encode($old_value)) && empty(wp_json_encode($new_value))) {
return;
}
@ -161,7 +161,7 @@ class Event_Manager extends Base_Manager {
'severity' => Event::SEVERITY_INFO,
'slug' => 'changed',
'object_type' => $model,
'object_id' => $object->get_id(),
'object_id' => $obj->get_id(),
'payload' => $changed,
];
} else {
@ -169,7 +169,7 @@ class Event_Manager extends Base_Manager {
'severity' => Event::SEVERITY_INFO,
'slug' => 'created',
'object_type' => $model,
'object_id' => $object->get_id(),
'object_id' => $obj->get_id(),
'payload' => [],
];
}
@ -179,7 +179,7 @@ class Event_Manager extends Base_Manager {
$event_data['author_id'] = get_current_user_id();
}
return wu_create_event($event_data);
wu_create_event($event_data);
}
/**
@ -191,19 +191,19 @@ class Event_Manager extends Base_Manager {
public function event_payload_preview(): void {
if ( ! wu_request('event')) {
wp_send_json_error(new \WP_Error('error', __('No event was selected.', 'wp-ultimo')));
wp_send_json_error(new \WP_Error('error', __('No event was selected.', 'wp-multisite-waas')));
}
$slug = wu_request('event');
if ( ! $slug) {
wp_send_json_error(new \WP_Error('not-found', __('Event was not found.', 'wp-ultimo')));
wp_send_json_error(new \WP_Error('not-found', __('Event was not found.', 'wp-multisite-waas')));
}
$event = wu_get_event_type($slug);
if ( ! $event) {
wp_send_json_error(new \WP_Error('not-found', __('Data not found.', 'wp-ultimo')));
wp_send_json_error(new \WP_Error('not-found', __('Data not found.', 'wp-multisite-waas')));
} else {
$payload = isset($event['payload']) ? wu_maybe_lazy_load_payload($event['payload']) : '{}';
@ -231,7 +231,6 @@ class Event_Manager extends Base_Manager {
'desc' => '$desc',
'class_name' => '$class_name',
'active' => 'in_array($id, $active_gateways, true)',
'active' => 'in_array($id, $active_gateways, true)',
'gateway' => '$class_name', // Deprecated.
'hidden' => false,
];
@ -313,7 +312,7 @@ class Event_Manager extends Base_Manager {
* @since 2.0.0
*
* @param string $slug of the event.
* @return array $event with event params.
* @return array|false $event with event params.
*/
public function get_event($slug) {
@ -367,8 +366,8 @@ class Event_Manager extends Base_Manager {
wu_register_event_type(
'payment_received',
[
'name' => __('Payment Received', 'wp-ultimo'),
'desc' => __('This event is fired every time a new payment is received, regardless of the payment status.', 'wp-ultimo'),
'name' => __('Payment Received', 'wp-multisite-waas'),
'desc' => __('This event is fired every time a new payment is received, regardless of the payment status.', 'wp-multisite-waas'),
'payload' => fn() => array_merge(
wu_generate_event_payload('payment'),
wu_generate_event_payload('membership'),
@ -390,8 +389,8 @@ class Event_Manager extends Base_Manager {
wu_register_event_type(
'site_published',
[
'name' => __('Site Published', 'wp-ultimo'),
'desc' => __('This event is fired every time a new site is created tied to a membership, or transitions from a pending state to a published state.', 'wp-ultimo'),
'name' => __('Site Published', 'wp-multisite-waas'),
'desc' => __('This event is fired every time a new site is created tied to a membership, or transitions from a pending state to a published state.', 'wp-multisite-waas'),
'payload' => fn() => array_merge(
wu_generate_event_payload('site'),
wu_generate_event_payload('customer'),
@ -407,8 +406,8 @@ class Event_Manager extends Base_Manager {
wu_register_event_type(
'confirm_email_address',
[
'name' => __('Email Verification Needed', 'wp-ultimo'),
'desc' => __('This event is fired every time a new customer is added with an email verification status of pending.', 'wp-ultimo'),
'name' => __('Email Verification Needed', 'wp-multisite-waas'),
'desc' => __('This event is fired every time a new customer is added with an email verification status of pending.', 'wp-multisite-waas'),
'payload' => fn() => array_merge(
[
'verification_link' => 'https://linktoverifyemail.com',
@ -425,8 +424,8 @@ class Event_Manager extends Base_Manager {
wu_register_event_type(
'domain_created',
[
'name' => __('New Domain Mapping Added', 'wp-ultimo'),
'desc' => __('This event is fired every time a new domain mapping is added by a customer.', 'wp-ultimo'),
'name' => __('New Domain Mapping Added', 'wp-multisite-waas'),
'desc' => __('This event is fired every time a new domain mapping is added by a customer.', 'wp-multisite-waas'),
'payload' => fn() => array_merge(
wu_generate_event_payload('domain'),
wu_generate_event_payload('site'),
@ -449,8 +448,8 @@ class Event_Manager extends Base_Manager {
wu_register_event_type(
'renewal_payment_created',
[
'name' => __('New Renewal Payment Created', 'wp-ultimo'),
'desc' => __('This event is fired every time a new renewal payment is created by WP Multisite WaaS.', 'wp-ultimo'),
'name' => __('New Renewal Payment Created', 'wp-multisite-waas'),
'desc' => __('This event is fired every time a new renewal payment is created by WP Multisite WaaS.', 'wp-multisite-waas'),
'payload' => fn() => array_merge(
[
'default_payment_url' => 'https://linktopayment.com',
@ -470,8 +469,8 @@ class Event_Manager extends Base_Manager {
wu_register_event_type(
$model . '_' . $type,
[
'name' => sprintf(__('%1$s %2$s', 'wp-ultimo'), $params['label'], ucfirst($type)),
'desc' => sprintf(__('This event is fired every time a %1$s is %2$s by WP Multisite WaaS.', 'wp-ultimo'), $params['label'], $type),
'name' => sprintf(__('%1$s %2$s', 'wp-multisite-waas'), $params['label'], ucfirst($type)),
'desc' => sprintf(__('This event is fired every time a %1$s is %2$s by WP Multisite WaaS.', 'wp-multisite-waas'), $params['label'], $type),
'deprecated_args' => [],
'payload' => fn() => $this->get_model_payload($model),
]
@ -563,13 +562,13 @@ class Event_Manager extends Base_Manager {
if (method_exists($obj, 'get_billing_address') || method_exists($obj, 'get_membership')) {
if (null !== $model_object) {
$payload = method_exists($obj, 'get_billing_address')
? array_merge(
$payload,
$obj->get_billing_address()->to_array()
) : array_merge(
$payload,
$obj->get_membership()->get_billing_address()->to_array()
);
? array_merge(
$payload,
$obj->get_billing_address()->to_array()
) : array_merge(
$payload,
$obj->get_membership()->get_billing_address()->to_array()
);
} else {
$payload = array_merge(
$payload,
@ -621,7 +620,8 @@ class Event_Manager extends Base_Manager {
}
}
wu_log_add('wu-cron', sprintf(__('Removed %1$d events successfully. Failed to remove %2$d events.', 'wp-ultimo'), $success_count, count($events_to_remove) - $success_count));
// Translators: 1: Number of successfully removed events. 2: Number of failed events to remove.
wu_log_add('wu-cron', sprintf(__('Removed %1$d events successfully. Failed to remove %2$d events.', 'wp-multisite-waas'), $success_count, count($events_to_remove) - $success_count));
return true;
}
@ -657,7 +657,7 @@ class Event_Manager extends Base_Manager {
*
* @since 2.0.0
*
* @param WP_REST_Request $request The request sent.
* @param \WP_REST_Request $request The request sent.
* @return mixed
*/
public function get_hooks_rest($request) {

View File

@ -61,7 +61,7 @@ class Field_Templates_Manager extends Base_Manager {
$template_class = $this->get_template_class($template_parts[0], $template_parts[1]);
if ( ! $template_class) {
wp_send_json_error(new \WP_Error('template', __('Template not found.', 'wp-ultimo')));
wp_send_json_error(new \WP_Error('template', __('Template not found.', 'wp-multisite-waas')));
}
$key = $template_parts[0];

View File

@ -64,7 +64,7 @@ class Form_Manager extends Base_Manager {
*/
public function display_form_unavailable($error = false): void {
$message = __('Form not available', 'wp-ultimo');
$message = __('Form not available', 'wp-multisite-waas');
if (is_wp_error($error)) {
$message = $error->get_error_message();
@ -352,7 +352,7 @@ class Form_Manager extends Base_Manager {
$object = apply_filters("wu_delete_form_get_object_{$model}", $object, $id, $model);
if ( ! $object) {
$this->display_form_unavailable(new \WP_Error('not-found', __('Object not found.', 'wp-ultimo')));
$this->display_form_unavailable(new \WP_Error('not-found', __('Object not found.', 'wp-multisite-waas')));
return;
}
@ -362,16 +362,16 @@ class Form_Manager extends Base_Manager {
[
'confirm' => [
'type' => 'toggle',
'title' => __('Confirm Deletion', 'wp-ultimo'),
'desc' => __('This action can not be undone.', 'wp-ultimo'),
'title' => __('Confirm Deletion', 'wp-multisite-waas'),
'desc' => __('This action can not be undone.', 'wp-multisite-waas'),
'html_attr' => [
'v-model' => 'confirmed',
],
],
'submit_button' => [
'type' => 'submit',
'title' => __('Delete', 'wp-ultimo'),
'placeholder' => __('Delete', 'wp-ultimo'),
'title' => __('Delete', 'wp-multisite-waas'),
'placeholder' => __('Delete', 'wp-multisite-waas'),
'value' => 'save',
'classes' => 'button button-primary wu-w-full',
'wrapper_classes' => 'wu-items-end',
@ -471,7 +471,7 @@ class Form_Manager extends Base_Manager {
$object = apply_filters("wu_delete_form_get_object_{$model}", $object, $id, $model);
if ( ! $object) {
wp_send_json_error(new \WP_Error('not-found', __('Object not found.', 'wp-ultimo')));
wp_send_json_error(new \WP_Error('not-found', __('Object not found.', 'wp-multisite-waas')));
}
/*
@ -496,7 +496,7 @@ class Form_Manager extends Base_Manager {
wp_send_json_success($data_json_success);
} else {
wp_send_json_error(new \WP_Error('model-not-found', __('Something went wrong.', 'wp-ultimo')));
wp_send_json_error(new \WP_Error('model-not-found', __('Something went wrong.', 'wp-multisite-waas')));
}
}
@ -517,8 +517,8 @@ class Form_Manager extends Base_Manager {
[
'confirm' => [
'type' => 'toggle',
'title' => __('Confirm Action', 'wp-ultimo'),
'desc' => __('Review this action carefully.', 'wp-ultimo'),
'title' => __('Confirm Action', 'wp-multisite-waas'),
'desc' => __('Review this action carefully.', 'wp-multisite-waas'),
'html_attr' => [
'v-model' => 'confirmed',
],

View File

@ -12,7 +12,6 @@
namespace WP_Ultimo\Managers;
use Psr\Log\LogLevel;
use WP_Ultimo\Managers\Base_Manager;
use WP_Ultimo\Gateways\Ignorable_Exception;
use WP_Ultimo\Gateways\Free_Gateway;
@ -278,11 +277,11 @@ class Gateway_Manager extends Base_Manager {
$gateway = wu_get_gateway($gateway_id);
if ( ! $gateway) {
$error = new \WP_Error('missing_gateway', esc_html__('Missing gateway parameter.', 'wp-ultimo'));
$error = new \WP_Error('missing_gateway', esc_html__('Missing gateway parameter.', 'wp-multisite-waas'));
wp_die(
$error,
esc_html__('Error', 'wp-ultimo'),
$error, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
esc_html__('Error', 'wp-multisite-waas'),
[
'back_link' => true,
'response' => '200',
@ -310,8 +309,8 @@ class Gateway_Manager extends Base_Manager {
if (is_wp_error($results)) {
wp_die(
$results,
__('Error', 'wp-ultimo'),
$results, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
esc_html__('Error', 'wp-multisite-waas'),
[
'back_link' => true,
'response' => '200',
@ -322,8 +321,8 @@ class Gateway_Manager extends Base_Manager {
$error = new \WP_Error('confirm-error-' . $e->getCode(), $e->getMessage());
wp_die(
$error,
__('Error', 'wp-ultimo'),
$error, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
esc_html__('Error', 'wp-multisite-waas'),
[
'back_link' => true,
'response' => '200',
@ -338,7 +337,15 @@ class Gateway_Manager extends Base_Manager {
* Add a filter to bypass the checkout form.
* This is used for PayPal confirmation page.
*/
add_action('wu_bypass_checkout_form', fn($bypass, $atts) => $output, 10, 2);
add_action(
'wu_bypass_checkout_form',
function ($output) {
return $output;
},
10,
1
);
}
}
@ -354,8 +361,8 @@ class Gateway_Manager extends Base_Manager {
'payment-gateways',
'active_gateways',
[
'title' => __('Active Payment Gateways', 'wp-ultimo'),
'desc' => __('Payment gateways are what your customers will use to pay.', 'wp-ultimo'),
'title' => __('Active Payment Gateways', 'wp-multisite-waas'),
'desc' => __('Payment gateways are what your customers will use to pay.', 'wp-multisite-waas'),
'type' => 'multiselect',
'columns' => 2,
'options' => [$this, 'get_gateways_as_options'],
@ -393,31 +400,31 @@ class Gateway_Manager extends Base_Manager {
/*
* Free Payments
*/
wu_register_gateway('free', __('Free', 'wp-ultimo'), '', Free_Gateway::class, true);
wu_register_gateway('free', __('Free', 'wp-multisite-waas'), '', Free_Gateway::class, true);
/*
* Stripe Payments
*/
$stripe_desc = __('Stripe is a suite of payment APIs that powers commerce for businesses of all sizes, including subscription management.', 'wp-ultimo');
wu_register_gateway('stripe', __('Stripe', 'wp-ultimo'), $stripe_desc, Stripe_Gateway::class);
$stripe_desc = __('Stripe is a suite of payment APIs that powers commerce for businesses of all sizes, including subscription management.', 'wp-multisite-waas');
wu_register_gateway('stripe', __('Stripe', 'wp-multisite-waas'), $stripe_desc, Stripe_Gateway::class);
/*
* Stripe Checkout Payments
*/
$stripe_checkout_desc = __('Stripe Checkout is the hosted solution for checkouts using Stripe.', 'wp-ultimo');
wu_register_gateway('stripe-checkout', __('Stripe Checkout', 'wp-ultimo'), $stripe_checkout_desc, Stripe_Checkout_Gateway::class);
$stripe_checkout_desc = __('Stripe Checkout is the hosted solution for checkouts using Stripe.', 'wp-multisite-waas');
wu_register_gateway('stripe-checkout', __('Stripe Checkout', 'wp-multisite-waas'), $stripe_checkout_desc, Stripe_Checkout_Gateway::class);
/*
* PayPal Payments
*/
$paypal_desc = __('PayPal is the leading provider in checkout solutions and it is the easier way to get your network subscriptions going.', 'wp-ultimo');
wu_register_gateway('paypal', __('PayPal', 'wp-ultimo'), $paypal_desc, PayPal_Gateway::class);
$paypal_desc = __('PayPal is the leading provider in checkout solutions and it is the easier way to get your network subscriptions going.', 'wp-multisite-waas');
wu_register_gateway('paypal', __('PayPal', 'wp-multisite-waas'), $paypal_desc, PayPal_Gateway::class);
/*
* Manual Payments
*/
$manual_desc = __('Use the Manual Gateway to allow users to pay you directly via bank transfers, checks, or other channels.', 'wp-ultimo');
wu_register_gateway('manual', __('Manual', 'wp-ultimo'), $manual_desc, Manual_Gateway::class);
$manual_desc = __('Use the Manual Gateway to allow users to pay you directly via bank transfers, checks, or other channels.', 'wp-multisite-waas');
wu_register_gateway('manual', __('Manual', 'wp-multisite-waas'), $manual_desc, Manual_Gateway::class);
}
/**
@ -448,7 +455,7 @@ class Gateway_Manager extends Base_Manager {
*
* @since 2.0.0
* @param string $id The id of the gateway.
* @return array
* @return array|false
*/
public function get_gateway($id) {
@ -471,7 +478,7 @@ class Gateway_Manager extends Base_Manager {
// Checks if gateway was already added
if ($this->is_gateway_registered($id)) {
return;
return false;
}
$active_gateways = (array) wu_get_setting('active_gateways', []);
@ -533,7 +540,7 @@ class Gateway_Manager extends Base_Manager {
*/
add_action(
'wu_checkout_gateway_fields',
function ($checkout) use ($gateway) {
function () use ($gateway) {
$field_content = call_user_func([$gateway, 'fields']);
@ -541,15 +548,13 @@ class Gateway_Manager extends Base_Manager {
?>
<div v-cloak v-show="gateway == '<?php echo esc_attr($gateway->get_id()); ?>' && order && order.should_collect_payment" class="wu-overflow">
<?php echo $field_content; ?>
</div>
<div v-cloak v-show="gateway == '<?php echo esc_attr($gateway->get_id()); ?>' && order && order.should_collect_payment" class="wu-overflow">
<?php echo $field_content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
<?php
echo ob_get_clean();
echo ob_get_clean(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
);
}

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,
]
);
}

View File

@ -60,7 +60,7 @@ class Membership_Manager extends Base_Manager {
add_action(
'init',
function () {
Event_Manager::register_model_events('membership', __('Membership', 'wp-ultimo'), ['created', 'updated']);
Event_Manager::register_model_events('membership', __('Membership', 'wp-multisite-waas'), ['created', 'updated']);
}
);
@ -128,7 +128,7 @@ class Membership_Manager extends Base_Manager {
$membership = wu_get_membership($membership_id);
if ( ! $membership) {
return new \WP_Error('error', __('An unexpected error happened.', 'wp-ultimo'));
return new \WP_Error('error', __('An unexpected error happened.', 'wp-multisite-waas'));
}
$status = $membership->publish_pending_site();
@ -152,7 +152,7 @@ class Membership_Manager extends Base_Manager {
$membership = wu_get_membership_by_hash($membership_id);
if ( ! $membership) {
return new \WP_Error('error', __('An unexpected error happened.', 'wp-ultimo'));
return new \WP_Error('error', __('An unexpected error happened.', 'wp-multisite-waas'));
}
$pending_site = $membership->get_pending_site();
@ -186,13 +186,13 @@ class Membership_Manager extends Base_Manager {
$membership = wu_get_membership($membership_id);
if ( ! $membership) {
return new \WP_Error('error', __('An unexpected error happened.', 'wp-ultimo'));
return new \WP_Error('error', __('An unexpected error happened.', 'wp-multisite-waas'));
}
$scheduled_swap = $membership->get_scheduled_swap();
if (empty($scheduled_swap)) {
return new \WP_Error('error', __('An unexpected error happened.', 'wp-ultimo'));
return new \WP_Error('error', __('An unexpected error happened.', 'wp-multisite-waas'));
}
$order = $scheduled_swap->order;
@ -207,12 +207,12 @@ class Membership_Manager extends Base_Manager {
if (is_wp_error($status)) {
$wpdb->query('ROLLBACK');
return new \WP_Error('error', __('An unexpected error happened.', 'wp-ultimo'));
return new \WP_Error('error', __('An unexpected error happened.', 'wp-multisite-waas'));
}
} catch (\Throwable $exception) {
$wpdb->query('ROLLBACK');
return new \WP_Error('error', __('An unexpected error happened.', 'wp-ultimo'));
return new \WP_Error('error', __('An unexpected error happened.', 'wp-multisite-waas'));
}
/*
@ -308,7 +308,7 @@ class Membership_Manager extends Base_Manager {
$target_customer = wu_get_customer($target_customer_id);
if ( ! $membership || ! $target_customer || absint($membership->get_customer_id()) === absint($target_customer->get_id())) {
return new \WP_Error('error', __('An unexpected error happened.', 'wp-ultimo'));
return new \WP_Error('error', __('An unexpected error happened.', 'wp-multisite-waas'));
}
$wpdb->query('START TRANSACTION');
@ -380,7 +380,7 @@ class Membership_Manager extends Base_Manager {
$membership = wu_get_membership($membership_id);
if ( ! $membership) {
return new \WP_Error('error', __('An unexpected error happened.', 'wp-ultimo'));
return new \WP_Error('error', __('An unexpected error happened.', 'wp-multisite-waas'));
}
$wpdb->query('START TRANSACTION');

View File

@ -11,8 +11,6 @@
namespace WP_Ultimo\Managers;
use WP_Ultimo\Managers\Base_Manager;
// Exit if accessed directly
defined('ABSPATH') || exit;
@ -110,11 +108,11 @@ class Notes_Manager extends Base_Manager {
* @since 2.0.0
*
* @param array $sections Array sections.
* @param object $object The object.
* @param object $obj The object.
*
* @return array
*/
public function add_notes_options_section($sections, $object) {
public function add_notes_options_section($sections, $obj) {
if ( ! current_user_can('read_notes') && ! current_user_can('edit_notes')) {
return $sections;
@ -131,8 +129,8 @@ class Notes_Manager extends Base_Manager {
'content' => wu_get_template_contents(
'base/edit/display-notes',
[
'notes' => $object->get_notes(),
'model' => $object->model,
'notes' => $obj->get_notes(),
'model' => $obj->model,
]
),
];
@ -142,18 +140,18 @@ class Notes_Manager extends Base_Manager {
if (current_user_can('delete_notes')) {
$fields_buttons['button_clear_notes'] = [
'type' => 'link',
'display_value' => __('Clear Notes', 'wp-ultimo'),
'display_value' => __('Clear Notes', 'wp-multisite-waas'),
'wrapper_classes' => 'wu-mb-0',
'classes' => 'button wubox',
'html_attr' => [
'href' => wu_get_form_url(
'clear_notes',
[
'object_id' => $object->get_id(),
'model' => $object->model,
'object_id' => $obj->get_id(),
'model' => $obj->model,
]
),
'title' => __('Clear Notes', 'wp-ultimo'),
'title' => __('Clear Notes', 'wp-multisite-waas'),
],
];
}
@ -161,19 +159,19 @@ class Notes_Manager extends Base_Manager {
if (current_user_can('edit_notes')) {
$fields_buttons['button_add_note'] = [
'type' => 'link',
'display_value' => __('Add new Note', 'wp-ultimo'),
'display_value' => __('Add new Note', 'wp-multisite-waas'),
'wrapper_classes' => 'wu-mb-0',
'classes' => 'button button-primary wubox wu-absolute wu-right-5',
'html_attr' => [
'href' => wu_get_form_url(
'add_note',
[
'object_id' => $object->get_id(),
'model' => $object->model,
'object_id' => $obj->get_id(),
'model' => $obj->model,
'height' => 306,
]
),
'title' => __('Add new Note', 'wp-ultimo'),
'title' => __('Add new Note', 'wp-multisite-waas'),
],
];
}
@ -185,8 +183,8 @@ class Notes_Manager extends Base_Manager {
];
$sections['notes'] = [
'title' => __('Notes', 'wp-ultimo'),
'desc' => __('Add notes to this model.', 'wp-ultimo'),
'title' => __('Notes', 'wp-multisite-waas'),
'desc' => __('Add notes to this model.', 'wp-multisite-waas'),
'icon' => 'dashicons-wu-text-document',
'order' => 1001,
'fields' => $fields,
@ -207,8 +205,8 @@ class Notes_Manager extends Base_Manager {
'content' => [
'id' => 'content',
'type' => 'wp-editor',
'title' => __('Note Content', 'wp-ultimo'),
'desc' => __('Basic formatting is supported.', 'wp-ultimo'),
'title' => __('Note Content', 'wp-multisite-waas'),
'desc' => __('Basic formatting is supported.', 'wp-multisite-waas'),
'settings' => [
'tinymce' => [
'toolbar1' => 'bold,italic,strikethrough,link,unlink,undo,redo,pastetext',
@ -220,8 +218,8 @@ class Notes_Manager extends Base_Manager {
],
'submit_add_note' => [
'type' => 'submit',
'title' => __('Add Note', 'wp-ultimo'),
'placeholder' => __('Add Note', 'wp-ultimo'),
'title' => __('Add Note', 'wp-multisite-waas'),
'placeholder' => __('Add Note', 'wp-multisite-waas'),
'value' => 'save',
'classes' => 'wu-w-full button button-primary',
'wrapper_classes' => 'wu-items-end',
@ -308,16 +306,16 @@ class Notes_Manager extends Base_Manager {
$fields = [
'confirm_clear_notes' => [
'type' => 'toggle',
'title' => __('Confirm clear all notes?', 'wp-ultimo'),
'desc' => __('This action can not be undone.', 'wp-ultimo'),
'title' => __('Confirm clear all notes?', 'wp-multisite-waas'),
'desc' => __('This action can not be undone.', 'wp-multisite-waas'),
'html_attr' => [
'v-model' => 'confirmed',
],
],
'submit_clear_notes' => [
'type' => 'submit',
'title' => __('Clear Notes', 'wp-ultimo'),
'placeholder' => __('Clear Notes', 'wp-ultimo'),
'title' => __('Clear Notes', 'wp-multisite-waas'),
'placeholder' => __('Clear Notes', 'wp-multisite-waas'),
'value' => 'save',
'classes' => 'wu-w-full button button-primary',
'wrapper_classes' => 'wu-items-end',
@ -403,16 +401,16 @@ class Notes_Manager extends Base_Manager {
$fields = [
'confirm_delete_note' => [
'type' => 'toggle',
'title' => __('Confirm clear the note?', 'wp-ultimo'),
'desc' => __('This action can not be undone.', 'wp-ultimo'),
'title' => __('Confirm clear the note?', 'wp-multisite-waas'),
'desc' => __('This action can not be undone.', 'wp-multisite-waas'),
'html_attr' => [
'v-model' => 'confirmed',
],
],
'submit_delete_note' => [
'type' => 'submit',
'title' => __('Clear Note', 'wp-ultimo'),
'placeholder' => __('Clear Note', 'wp-ultimo'),
'title' => __('Clear Note', 'wp-multisite-waas'),
'placeholder' => __('Clear Note', 'wp-multisite-waas'),
'value' => 'save',
'classes' => 'wu-w-full button button-primary',
'wrapper_classes' => 'wu-items-end',
@ -475,7 +473,7 @@ class Notes_Manager extends Base_Manager {
$status = $object->delete_note($note_id);
if (is_wp_error($status) || false === $status) {
wp_send_json_error(new \WP_Error('not-found', __('Note not found', 'wp-ultimo')));
wp_send_json_error(new \WP_Error('not-found', __('Note not found', 'wp-multisite-waas')));
}
wp_send_json_success(

View File

@ -39,7 +39,7 @@ class Notification_Manager {
*/
public function init(): void {
add_action('wp_ultimo_load', [$this, 'add_settings']);
add_action('init', [$this, 'add_settings']);
if (is_admin() && ! is_network_admin()) {
add_action('admin_init', [$this, 'hide_notifications_subsites']);
@ -121,8 +121,8 @@ class Notification_Manager {
'sites',
'hide_notifications_subsites',
[
'title' => __('Hide Admin Notices on Sites', 'wp-ultimo'),
'desc' => __('Hide all admin notices on network sites, except for WP Multisite WaaS broadcasts.', 'wp-ultimo'),
'title' => __('Hide Admin Notices on Sites', 'wp-multisite-waas'),
'desc' => __('Hide all admin notices on network sites, except for WP Multisite WaaS broadcasts.', 'wp-multisite-waas'),
'type' => 'toggle',
'default' => 0,
'order' => 25,

View File

@ -66,7 +66,7 @@ class Payment_Manager extends Base_Manager {
function () {
Event_Manager::register_model_events(
'payment',
__('Payment', 'wp-ultimo'),
__('Payment', 'wp-multisite-waas'),
['created', 'updated']
);
}
@ -169,7 +169,7 @@ class Payment_Manager extends Base_Manager {
wp_enqueue_style('wu-admin');
add_wubox();
$form_title = __('Pending Payments', 'wp-ultimo');
$form_title = __('Pending Payments', 'wp-multisite-waas');
$form_url = wu_get_form_url('pending_payments');
wp_add_inline_script('wubox', "document.addEventListener('DOMContentLoaded', function(){wubox.show('$form_title', '$form_url');});");
@ -225,7 +225,7 @@ class Payment_Manager extends Base_Manager {
}
}
$message = ! empty($pending_payments) ? __('You have pending payments on your account!', 'wp-ultimo') : __('You do not have pending payments on your account!', 'wp-ultimo');
$message = ! empty($pending_payments) ? __('You have pending payments on your account!', 'wp-multisite-waas') : __('You do not have pending payments on your account!', 'wp-multisite-waas');
/**
* Allow user to change the message about the pending payments.
@ -252,7 +252,7 @@ class Payment_Manager extends Base_Manager {
$url = $payment->get_payment_url();
$html = sprintf('<a href="%s" class="button-primary">%s</a>', $url, __('Pay Now', 'wp-ultimo'));
$html = sprintf('<a href="%s" class="button-primary">%s</a>', $url, __('Pay Now', 'wp-multisite-waas'));
$title = $slug;
@ -291,13 +291,13 @@ class Payment_Manager extends Base_Manager {
*/
if ( ! wp_verify_nonce(wu_request('key'), 'see_invoice')) {
// wp_die(__('You do not have permissions to access this file.', 'wp-ultimo'));
// wp_die(__('You do not have permissions to access this file.', 'wp-multisite-waas'));
}
$payment = wu_get_payment_by_hash(wu_request('reference'));
if ( ! $payment) {
wp_die(__('This invoice does not exist.', 'wp-ultimo'));
wp_die(__('This invoice does not exist.', 'wp-multisite-waas'));
}
$invoice = new Invoice($payment);
@ -329,7 +329,7 @@ class Payment_Manager extends Base_Manager {
$target_customer = wu_get_customer($target_customer_id);
if ( ! $payment || ! $target_customer || $payment->get_customer_id() === $target_customer->get_id()) {
return new \WP_Error('error', __('An unexpected error happened.', 'wp-ultimo'));
return new \WP_Error('error', __('An unexpected error happened.', 'wp-multisite-waas'));
}
$wpdb->query('START TRANSACTION');
@ -374,7 +374,7 @@ class Payment_Manager extends Base_Manager {
$payment = wu_get_payment($payment_id);
if ( ! $payment) {
return new \WP_Error('error', __('An unexpected error happened.', 'wp-ultimo'));
return new \WP_Error('error', __('An unexpected error happened.', 'wp-multisite-waas'));
}
$wpdb->query('START TRANSACTION');

View File

@ -11,7 +11,6 @@
namespace WP_Ultimo\Managers;
use WP_Ultimo\Managers\Base_Manager;
use WP_Ultimo\Helpers\Screenshot;
use WP_Ultimo\Database\Sites\Site_Type;
use WP_Ultimo\Database\Memberships\Membership_Status;
@ -132,7 +131,7 @@ class Site_Manager extends Base_Manager {
}
if (preg_match('/[^a-z0-9-]+/', (string) $result['blogname'])) {
$result['errors']->add('blogname', __('Site names can only contain lowercase letters (a-z), numbers, and hyphens.', 'wp-ultimo'));
$result['errors']->add('blogname', __('Site names can only contain lowercase letters (a-z), numbers, and hyphens.', 'wp-multisite-waas'));
}
}
@ -165,7 +164,7 @@ class Site_Manager extends Base_Manager {
$customer = wu_get_current_customer();
if ( ! $customer || ! $membership || $customer->get_id() !== $membership->get_customer_id()) {
$errors->add('not-owner', __('You do not have the necessary permissions to create a site to this membership', 'wp-ultimo'));
$errors->add('not-owner', __('You do not have the necessary permissions to create a site to this membership', 'wp-multisite-waas'));
}
if ($errors->has_errors() === false) {
@ -230,7 +229,7 @@ class Site_Manager extends Base_Manager {
$redirect_url
);
wp_redirect($redirect_url);
wp_safe_redirect($redirect_url);
exit;
}
@ -307,18 +306,17 @@ class Site_Manager extends Base_Manager {
if (false === $can_access) {
if ($redirect_url) {
wp_redirect($redirect_url);
wp_safe_redirect($redirect_url);
exit;
}
wp_die(
new \WP_Error(
new \WP_Error( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'not-available',
// phpcs:ignore
sprintf( __('This site is not available at the moment.<br><small>If you are the site admin, click <a href="%s">here</a> to login.</small>', 'wp-ultimo'), wp_login_url()),
sprintf(__('This site is not available at the moment.<br><small>If you are the site admin, click <a href="%s">here</a> to login.</small>', 'wp-multisite-waas'), wp_login_url()), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
[
'title' => __('Site not available', 'wp-ultimo'),
'title' => esc_html__('Site not available', 'wp-multisite-waas'),
]
),
'',
@ -370,7 +368,7 @@ class Site_Manager extends Base_Manager {
if ( ! $site) {
wp_send_json_error(
new \WP_Error('missing-site', __('Site not found.', 'wp-ultimo'))
new \WP_Error('missing-site', __('Site not found.', 'wp-multisite-waas'))
);
}
@ -380,7 +378,7 @@ class Site_Manager extends Base_Manager {
if ( ! $attachment_id) {
wp_send_json_error(
new \WP_Error('error', __('We were not able to fetch the screenshot.', 'wp-ultimo'))
new \WP_Error('error', __('We were not able to fetch the screenshot.', 'wp-multisite-waas'))
);
}
@ -405,10 +403,8 @@ class Site_Manager extends Base_Manager {
public function additional_thumbnail_sizes(): void {
if (is_main_site()) {
add_image_size('wu-thumb-large', 900, 675, ['center', 'top']); // (cropped)
add_image_size('wu-thumb-medium', 400, 300, ['center', 'top']); // (cropped)
add_image_size('wu-thumb-large', 900, 675, ['center', 'top']); // cropped
add_image_size('wu-thumb-medium', 400, 300, ['center', 'top']); // cropped
}
}
@ -421,7 +417,7 @@ class Site_Manager extends Base_Manager {
public function add_no_index_warning(): void {
if (wu_get_setting('stop_template_indexing', false)) {
add_meta_box('wu-warnings', __('WP Multisite WaaS - Search Engines', 'wp-ultimo'), [$this, 'render_no_index_warning'], 'dashboard-network', 'normal', 'high');
add_meta_box('wu-warnings', __('WP Multisite WaaS - Search Engines', 'wp-multisite-waas'), [$this, 'render_no_index_warning'], 'dashboard-network', 'normal', 'high');
}
}
@ -431,21 +427,22 @@ class Site_Manager extends Base_Manager {
* @since 2.0.0
* @return void
*/
public function render_no_index_warning(): void { // phpcs:disable ?>
public function render_no_index_warning(): void {
?>
<div class="wu-styling">
<div class="wu-border-l-4 wu-border-yellow-500 wu-border-solid wu-border-0 wu-px-4 wu-py-2 wu--m-3">
<p><?php _e('Your WP Multisite WaaS settings are configured to <strong>prevent search engines such as Google from indexing your template sites</strong>.', 'wp-ultimo'); ?></p>
<p><?php echo wp_kses_post(__('Your WP Multisite WaaS settings are configured to <strong>prevent search engines such as Google from indexing your template sites</strong>.', 'wp-multisite-waas')); ?></p>
<p><?php printf(__('If you are experiencing negative SEO impacts on other sites in your network, consider disabling this setting <a href="%s">here</a>.', 'wp-ultimo'), wu_network_admin_url('wp-ultimo-settings', ['tab' => 'sites'])); ?></p>
<p><?php echo wp_kses_post(sprintf(__('If you are experiencing negative SEO impacts on other sites in your network, consider disabling this setting <a href="%s">here</a>.', 'wp-multisite-waas'), wu_network_admin_url('wp-ultimo-settings', ['tab' => 'sites']))); ?></p>
</div>
</div>
<?php // phpcs:enable
<?php
}
/**
@ -467,7 +464,7 @@ class Site_Manager extends Base_Manager {
add_filter('wp_robots', 'wp_robots_no_robots'); // WordPress 5.7+
} else {
wp_no_robots();
wp_no_robots(); // phpcs:ignore WordPress.WP.DeprecatedFunctions.wp_no_robotsFound
}
}
}
@ -540,7 +537,7 @@ class Site_Manager extends Base_Manager {
*/
public function add_notices_to_default_site_page(): void {
$notice = __('Hey there! We highly recommend managing your network sites using the WP Multisite WaaS &rarr; Sites page. <br>If you want to avoid confusion, you can also hide this page from the admin panel completely on the WP Multisite WaaS &rarr; Settings &rarr; Whitelabel options.', 'wp-ultimo');
$notice = __('Hey there! We highly recommend managing your network sites using the WP Multisite WaaS &rarr; Sites page. <br>If you want to avoid confusion, you can also hide this page from the admin panel completely on the WP Multisite WaaS &rarr; Settings &rarr; Whitelabel options.', 'wp-multisite-waas');
WP_Ultimo()->notices->add(
$notice,
@ -549,11 +546,11 @@ class Site_Manager extends Base_Manager {
'wu-sites-use-wp-ultimo',
[
[
'title' => __('Go to the WP Multisite WaaS Sites page &rarr;', 'wp-ultimo'),
'title' => __('Go to the WP Multisite WaaS Sites page &rarr;', 'wp-multisite-waas'),
'url' => wu_network_admin_url('wp-ultimo-sites'),
],
[
'title' => __('Go to the Whitelabel Settings &rarr;', 'wp-ultimo'),
'title' => __('Go to the Whitelabel Settings &rarr;', 'wp-multisite-waas'),
'url' => wu_network_admin_url(
'wp-ultimo-settings',
[
@ -794,11 +791,10 @@ class Site_Manager extends Base_Manager {
* Site_Type::CUSTOMER_OWNED or without this meta
*/
$args = [
'number' => '',
'site__in' => $site_ids,
'update_site_meta_cache' => false,
'number' => 40,
'meta_query' => [
'meta_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'relation' => 'OR',
[
'key' => 'wu_type',

View File

@ -69,7 +69,7 @@ class Visits_Manager {
}
if ($site->has_limitations() && $site->get_visits_count() > $site->get_limitations()->visits->get_limit()) {
wp_die(__('This site is not available at this time.', 'wp-ultimo'), __('Not available', 'wp-ultimo'), 404);
wp_die(__('This site is not available at this time.', 'wp-multisite-waas'), __('Not available', 'wp-multisite-waas'), 404);
}
}

View File

@ -11,7 +11,6 @@
namespace WP_Ultimo\Managers;
use WP_Ultimo\Managers\Base_Manager;
use WP_Ultimo\Models\Webhook;
use WP_Ultimo\Logger;
@ -126,7 +125,7 @@ class Webhook_Manager extends Base_Manager {
public function send_webhook($webhook, $data, $blocking = true, $count = true) {
if ( ! $data) {
return;
return null;
}
$request = wp_remote_post(
@ -196,7 +195,7 @@ class Webhook_Manager extends Base_Manager {
if ( ! current_user_can('manage_network')) {
wp_send_json(
[
'response' => __('You do not have enough permissions to send a test event.', 'wp-ultimo'),
'response' => __('You do not have enough permissions to send a test event.', 'wp-multisite-waas'),
'webhooks' => Webhook::get_items_as_array(),
]
);
@ -205,9 +204,7 @@ class Webhook_Manager extends Base_Manager {
$event = wu_get_event_type($_POST['webhook_event']);
$webhook_data = [
'webhook_url' => $_POST['webhook_url'],
'event' => $_POST['webhook_event'],
'active' => true,
'active' => true,
];
$webhook = new Webhook($webhook_data);
@ -249,8 +246,7 @@ class Webhook_Manager extends Base_Manager {
';
if ( ! current_user_can('manage_network')) {
echo __('You do not have enough permissions to read the logs of this webhook.', 'wp-ultimo');
esc_html_e('You do not have enough permissions to read the logs of this webhook.', 'wp-multisite-waas');
exit;
}
@ -271,7 +267,7 @@ class Webhook_Manager extends Base_Manager {
Logger::read_lines("webhook-$id", 5)
);
echo implode('', $logs);
echo implode('', $logs); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
exit;
}
@ -291,7 +287,7 @@ class Webhook_Manager extends Base_Manager {
*/
protected function create_event($event_name, $id, $url, $data, $response, $is_error = false) {
$message = sprintf('Sent a %s event to the URL %s with data: %s ', $event_name, $url, json_encode($data));
$message = sprintf('Sent a %s event to the URL %s with data: %s ', $event_name, $url, wp_json_encode($data));
if ( ! $is_error) {
$message .= empty($response) ? sprintf('Got response: %s', $response) : 'To debug the remote server response, turn the "Wait for Response" option on the WP Multisite WaaS Settings > API & Webhooks Tab';