Use PHP 7.4 featers and PHP 8 polyfills
This commit is contained in:
@ -31,13 +31,13 @@ class Block_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
global $wp_version;
|
||||
|
||||
$hook = version_compare($wp_version, '5.8', '<') ? 'block_categories' : 'block_categories_all';
|
||||
|
||||
add_filter($hook, array($this, 'add_wp_ultimo_block_category'), 1, 2);
|
||||
add_filter($hook, [$this, 'add_wp_ultimo_block_category'], 1, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,12 +53,12 @@ class Block_Manager extends Base_Manager {
|
||||
|
||||
return array_merge(
|
||||
$categories,
|
||||
array(
|
||||
array(
|
||||
[
|
||||
[
|
||||
'slug' => 'wp-ultimo',
|
||||
'title' => __('Multisite WaaS', 'wp-ultimo'),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ class Broadcast_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $model_class = '\\WP_Ultimo\\Models\\Broadcast';
|
||||
protected $model_class = \WP_Ultimo\Models\Broadcast::class;
|
||||
|
||||
/**
|
||||
* Instantiate the necessary hooks.
|
||||
@ -51,7 +51,7 @@ class Broadcast_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
$this->enable_rest_api();
|
||||
|
||||
@ -61,7 +61,7 @@ class Broadcast_Manager extends Base_Manager {
|
||||
* Add unseen broadcast notices to the panel.
|
||||
*/
|
||||
if ( ! is_network_admin() && ! is_main_site()) {
|
||||
add_action('init', array($this, 'add_unseen_broadcast_notices'));
|
||||
add_action('init', [$this, 'add_unseen_broadcast_notices']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ class Broadcast_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function add_unseen_broadcast_notices() {
|
||||
public function add_unseen_broadcast_notices(): void {
|
||||
|
||||
$current_customer = wu_get_current_customer();
|
||||
|
||||
@ -80,12 +80,12 @@ class Broadcast_Manager extends Base_Manager {
|
||||
}
|
||||
|
||||
$all_broadcasts = Broadcast::query(
|
||||
array(
|
||||
[
|
||||
'number' => 10,
|
||||
'order' => 'DESC',
|
||||
'order_by' => 'id',
|
||||
'type__in' => array('broadcast_notice'),
|
||||
)
|
||||
'type__in' => ['broadcast_notice'],
|
||||
]
|
||||
);
|
||||
|
||||
if (isset($all_broadcasts)) {
|
||||
@ -94,7 +94,7 @@ class Broadcast_Manager extends Base_Manager {
|
||||
$targets = $this->get_all_notice_customer_targets($broadcast->get_id());
|
||||
|
||||
if ( ! is_array($targets)) {
|
||||
$targets = array($targets);
|
||||
$targets = [$targets];
|
||||
}
|
||||
|
||||
$dismissed = get_user_meta(get_current_user_id(), 'wu_dismissed_admin_notices');
|
||||
@ -118,7 +118,7 @@ class Broadcast_Manager extends Base_Manager {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle_broadcast() {
|
||||
public function handle_broadcast(): void {
|
||||
|
||||
$args = $_POST;
|
||||
|
||||
@ -135,10 +135,10 @@ class Broadcast_Manager extends Base_Manager {
|
||||
$args['type'] = $broadcast_type;
|
||||
|
||||
if ($broadcast_type === 'broadcast_notice') {
|
||||
$targets = array(
|
||||
$targets = [
|
||||
'customers' => $target_customers,
|
||||
'products' => $target_products,
|
||||
);
|
||||
];
|
||||
|
||||
$args['targets'] = $targets;
|
||||
|
||||
@ -152,18 +152,18 @@ class Broadcast_Manager extends Base_Manager {
|
||||
$redirect = current_user_can('wu_edit_broadcasts') ? 'wp-ultimo-edit-broadcast' : 'wp-ultimo-broadcasts';
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => add_query_arg('id', $saved->get_id(), wu_network_admin_url($redirect)),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if ($args['type'] === 'broadcast_email') {
|
||||
$to = array();
|
||||
$to = [];
|
||||
|
||||
$bcc = array();
|
||||
$bcc = [];
|
||||
|
||||
$targets = array();
|
||||
$targets = [];
|
||||
|
||||
if ($args['target_customers']) {
|
||||
$customers = explode(',', (string) $args['target_customers']);
|
||||
@ -174,7 +174,7 @@ class Broadcast_Manager extends Base_Manager {
|
||||
if ($args['target_products']) {
|
||||
$product_targets = explode(',', (string) $args['target_products']);
|
||||
|
||||
$customers = array();
|
||||
$customers = [];
|
||||
|
||||
foreach ($product_targets as $product_id) {
|
||||
$customers = array_merge($customers, wu_get_membership_customers($product_id));
|
||||
@ -192,36 +192,36 @@ class Broadcast_Manager extends Base_Manager {
|
||||
$customer = wu_get_customer($target);
|
||||
|
||||
if ($customer) {
|
||||
$to[] = array(
|
||||
$to[] = [
|
||||
'name' => $customer->get_display_name(),
|
||||
'email' => $customer->get_email_address(),
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! isset($args['custom_sender'])) {
|
||||
$from = array(
|
||||
$from = [
|
||||
'name' => wu_get_setting('from_name', get_network_option(null, 'site_name')),
|
||||
'email' => wu_get_setting('from_email', get_network_option(null, 'admin_email')),
|
||||
);
|
||||
];
|
||||
} else {
|
||||
$from = array(
|
||||
$from = [
|
||||
'name' => $args['custom_sender']['from_name'],
|
||||
'email' => $args['custom_sender']['from_email'],
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$template_type = wu_get_setting('email_template_type', 'html');
|
||||
|
||||
$template_type = $template_type ? $template_type : 'html';
|
||||
$template_type = $template_type ?: 'html';
|
||||
|
||||
$send_args = array(
|
||||
$send_args = [
|
||||
'site_name' => get_network_option(null, 'site_name'),
|
||||
'site_url' => get_site_url(),
|
||||
'type' => $template_type,
|
||||
'subject' => $args['subject'],
|
||||
'content' => $args['content'],
|
||||
);
|
||||
];
|
||||
|
||||
try {
|
||||
$status = Sender::send_mail($from, $to, $send_args);
|
||||
@ -232,18 +232,18 @@ class Broadcast_Manager extends Base_Manager {
|
||||
}
|
||||
|
||||
if ($status) {
|
||||
$args['targets'] = array(
|
||||
$args['targets'] = [
|
||||
'customers' => $args['target_customers'],
|
||||
'products' => $args['target_products'],
|
||||
);
|
||||
];
|
||||
|
||||
// then we save with the message status (success, fail)
|
||||
$this->save_broadcast($args);
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => wu_network_admin_url('wp-ultimo-broadcasts'),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -263,12 +263,12 @@ class Broadcast_Manager extends Base_Manager {
|
||||
*/
|
||||
public function save_broadcast($args) {
|
||||
|
||||
$broadcast_data = array(
|
||||
$broadcast_data = [
|
||||
'type' => $args['type'],
|
||||
'name' => $args['subject'],
|
||||
'content' => $args['content'],
|
||||
'status' => 'publish',
|
||||
);
|
||||
];
|
||||
|
||||
$broadcast = new Broadcast($broadcast_data);
|
||||
|
||||
@ -306,7 +306,7 @@ class Broadcast_Manager extends Base_Manager {
|
||||
return (array) $targets[ $type ];
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -323,7 +323,7 @@ class Broadcast_Manager extends Base_Manager {
|
||||
|
||||
$products = $this->get_broadcast_targets($object_id, 'products');
|
||||
|
||||
$product_customers = array();
|
||||
$product_customers = [];
|
||||
|
||||
if (is_array($products) && $products[0]) {
|
||||
foreach ($products as $product_key => $product) {
|
||||
|
@ -29,7 +29,7 @@ class Cache_Manager {
|
||||
* @since 2.1.2
|
||||
* @return void
|
||||
*/
|
||||
public function flush_known_caches() {
|
||||
public function flush_known_caches(): void {
|
||||
|
||||
/**
|
||||
* Iterate through known caching plugins methods and flush them
|
||||
@ -38,7 +38,7 @@ class Cache_Manager {
|
||||
* To support more caching plugins, just add a method to this class suffixed with '_cache_flush'
|
||||
*/
|
||||
foreach (get_class_methods($this) as $method) {
|
||||
if (substr_compare($method, '_cache_flush', -strlen('_cache_flush')) === 0) {
|
||||
if (str_ends_with($method, '_cache_flush')) {
|
||||
$this->$method();
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class Checkout_Form_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $model_class = '\\WP_Ultimo\\Models\\Checkout_Form';
|
||||
protected $model_class = \WP_Ultimo\Models\Checkout_Form::class;
|
||||
|
||||
/**
|
||||
* Instantiate the necessary hooks.
|
||||
@ -49,7 +49,7 @@ class Checkout_Form_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
$this->enable_rest_api();
|
||||
|
||||
|
@ -43,7 +43,7 @@ class Customer_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $model_class = '\\WP_Ultimo\\Models\\Customer';
|
||||
protected $model_class = \WP_Ultimo\Models\Customer::class;
|
||||
|
||||
/**
|
||||
* Instantiate the necessary hooks.
|
||||
@ -51,7 +51,7 @@ class Customer_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
$this->enable_rest_api();
|
||||
|
||||
@ -63,21 +63,21 @@ class Customer_Manager extends Base_Manager {
|
||||
Event_Manager::register_model_events(
|
||||
'customer',
|
||||
__('Customer', 'wp-ultimo'),
|
||||
array('created', 'updated')
|
||||
['created', 'updated']
|
||||
);
|
||||
}
|
||||
);
|
||||
add_action('wp_login', array($this, 'log_ip_and_last_login'), 10, 2);
|
||||
add_action('wp_login', [$this, 'log_ip_and_last_login'], 10, 2);
|
||||
|
||||
add_filter('heartbeat_send', array($this, 'on_heartbeat_send'));
|
||||
add_filter('heartbeat_send', [$this, 'on_heartbeat_send']);
|
||||
|
||||
add_action('wu_transition_customer_email_verification', array($this, 'transition_customer_email_verification'), 10, 3);
|
||||
add_action('wu_transition_customer_email_verification', [$this, 'transition_customer_email_verification'], 10, 3);
|
||||
|
||||
add_action('init', array($this, 'maybe_verify_email_address'));
|
||||
add_action('init', [$this, 'maybe_verify_email_address']);
|
||||
|
||||
add_action('wu_maybe_create_customer', array($this, 'maybe_add_to_main_site'), 10, 2);
|
||||
add_action('wu_maybe_create_customer', [$this, 'maybe_add_to_main_site'], 10, 2);
|
||||
|
||||
add_action('wp_ajax_wu_resend_verification_email', array($this, 'handle_resend_verification_email'));
|
||||
add_action('wp_ajax_wu_resend_verification_email', [$this, 'handle_resend_verification_email']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,7 +86,7 @@ class Customer_Manager extends Base_Manager {
|
||||
* @since 2.0.4
|
||||
* @return void
|
||||
*/
|
||||
public function handle_resend_verification_email() {
|
||||
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')));
|
||||
@ -132,7 +132,7 @@ class Customer_Manager extends Base_Manager {
|
||||
* @param WP_User $user The WP User object of the user that logged in.
|
||||
* @return void
|
||||
*/
|
||||
public function log_ip_and_last_login($user) {
|
||||
public function log_ip_and_last_login($user): void {
|
||||
|
||||
if ( ! is_a($user, '\WP_User')) {
|
||||
$user = get_user_by('login', $user);
|
||||
@ -161,7 +161,7 @@ class Customer_Manager extends Base_Manager {
|
||||
* @param integer $customer_id Customer ID.
|
||||
* @return void
|
||||
*/
|
||||
public function transition_customer_email_verification($old_status, $new_status, $customer_id) {
|
||||
public function transition_customer_email_verification($old_status, $new_status, $customer_id): void {
|
||||
|
||||
if ($new_status !== 'pending') {
|
||||
return;
|
||||
@ -184,7 +184,7 @@ class Customer_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function maybe_verify_email_address() {
|
||||
public function maybe_verify_email_address(): void {
|
||||
|
||||
$email_verify_key = wu_request('email-verification-key');
|
||||
|
||||
@ -203,10 +203,10 @@ class Customer_Manager extends Base_Manager {
|
||||
__('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(
|
||||
array(
|
||||
[
|
||||
'email-verification-key' => $email_verify_key,
|
||||
'customer' => $customer_hash,
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -280,10 +280,10 @@ class Customer_Manager extends Base_Manager {
|
||||
|
||||
if ($payments) {
|
||||
$redirect_url = add_query_arg(
|
||||
array(
|
||||
[
|
||||
'payment' => $payments[0]->get_hash(),
|
||||
'status' => 'done',
|
||||
),
|
||||
],
|
||||
wu_get_registration_url()
|
||||
);
|
||||
|
||||
@ -307,7 +307,7 @@ class Customer_Manager extends Base_Manager {
|
||||
* @param Checkout $checkout The checkout object.
|
||||
* @return void
|
||||
*/
|
||||
public function maybe_add_to_main_site($customer, $checkout) {
|
||||
public function maybe_add_to_main_site($customer, $checkout): void {
|
||||
|
||||
if ( ! wu_get_setting('add_users_to_main_site')) {
|
||||
return;
|
||||
|
@ -42,7 +42,7 @@ class Discount_Code_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $model_class = '\\WP_Ultimo\\Models\\Discount_Code';
|
||||
protected $model_class = \WP_Ultimo\Models\Discount_Code::class;
|
||||
|
||||
/**
|
||||
* Instantiate the necessary hooks.
|
||||
@ -50,13 +50,13 @@ class Discount_Code_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
$this->enable_rest_api();
|
||||
|
||||
$this->enable_wp_cli();
|
||||
|
||||
add_action('wu_gateway_payment_processed', array($this, 'maybe_add_use_on_payment_received'));
|
||||
add_action('wu_gateway_payment_processed', [$this, 'maybe_add_use_on_payment_received']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,7 +67,7 @@ class Discount_Code_Manager extends Base_Manager {
|
||||
* @param \WP_Ultimo\Models\Payment $payment The payment received.
|
||||
* @return void
|
||||
*/
|
||||
public function maybe_add_use_on_payment_received($payment) {
|
||||
public function maybe_add_use_on_payment_received($payment): void {
|
||||
|
||||
if ( ! $payment) {
|
||||
return;
|
||||
|
@ -43,7 +43,7 @@ class Domain_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $model_class = '\\WP_Ultimo\\Models\\Domain';
|
||||
protected $model_class = \WP_Ultimo\Models\Domain::class;
|
||||
|
||||
/**
|
||||
* Holds a list of the current integrations for domain mapping.
|
||||
@ -51,7 +51,7 @@ class Domain_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $integrations = array();
|
||||
protected $integrations = [];
|
||||
|
||||
/**
|
||||
* Returns the list of available host integrations.
|
||||
@ -93,7 +93,7 @@ class Domain_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
$this->enable_rest_api();
|
||||
|
||||
@ -101,37 +101,37 @@ class Domain_Manager extends Base_Manager {
|
||||
|
||||
$this->set_cookie_domain();
|
||||
|
||||
add_action('plugins_loaded', array($this, 'load_integrations'));
|
||||
add_action('plugins_loaded', [$this, 'load_integrations']);
|
||||
|
||||
add_action('wp_ajax_wu_test_hosting_integration', array($this, 'test_integration'));
|
||||
add_action('wp_ajax_wu_test_hosting_integration', [$this, 'test_integration']);
|
||||
|
||||
add_action('wp_ajax_wu_get_dns_records', array($this, 'get_dns_records'));
|
||||
add_action('wp_ajax_wu_get_dns_records', [$this, 'get_dns_records']);
|
||||
|
||||
add_action('wu_async_remove_old_primary_domains', array($this, 'async_remove_old_primary_domains'));
|
||||
add_action('wu_async_remove_old_primary_domains', [$this, 'async_remove_old_primary_domains']);
|
||||
|
||||
add_action('wu_async_process_domain_stage', array($this, 'async_process_domain_stage'), 10, 2);
|
||||
add_action('wu_async_process_domain_stage', [$this, 'async_process_domain_stage'], 10, 2);
|
||||
|
||||
add_action('wu_transition_domain_domain', array($this, 'send_domain_to_host'), 10, 3);
|
||||
add_action('wu_transition_domain_domain', [$this, 'send_domain_to_host'], 10, 3);
|
||||
|
||||
add_action('wu_settings_domain_mapping', array($this, 'add_domain_mapping_settings'));
|
||||
add_action('wu_settings_domain_mapping', [$this, 'add_domain_mapping_settings']);
|
||||
|
||||
add_action('wu_settings_sso', array($this, 'add_sso_settings'));
|
||||
add_action('wu_settings_sso', [$this, 'add_sso_settings']);
|
||||
|
||||
/*
|
||||
* Add and remove mapped domains
|
||||
*/
|
||||
|
||||
add_action('wu_domain_created', array($this, 'handle_domain_created'), 10, 3);
|
||||
add_action('wu_domain_created', [$this, 'handle_domain_created'], 10, 3);
|
||||
|
||||
add_action('wu_domain_post_delete', array($this, 'handle_domain_deleted'), 10, 3);
|
||||
add_action('wu_domain_post_delete', [$this, 'handle_domain_deleted'], 10, 3);
|
||||
|
||||
/*
|
||||
* Add and remove sub-domains
|
||||
*/
|
||||
|
||||
add_action('wp_insert_site', array($this, 'handle_site_created'));
|
||||
add_action('wp_insert_site', [$this, 'handle_site_created']);
|
||||
|
||||
add_action('wp_delete_site', array($this, 'handle_site_deleted'));
|
||||
add_action('wp_delete_site', [$this, 'handle_site_deleted']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -156,7 +156,7 @@ class Domain_Manager extends Base_Manager {
|
||||
* @param \WP_Site $site The site being added.
|
||||
* @return void
|
||||
*/
|
||||
public function handle_site_created($site) {
|
||||
public function handle_site_created($site): void {
|
||||
|
||||
global $current_site;
|
||||
|
||||
@ -166,10 +166,10 @@ class Domain_Manager extends Base_Manager {
|
||||
return;
|
||||
}
|
||||
|
||||
$args = array(
|
||||
$args = [
|
||||
'subdomain' => $site->domain,
|
||||
'site_id' => $site->blog_id,
|
||||
);
|
||||
];
|
||||
|
||||
wu_enqueue_async_action('wu_add_subdomain', $args, 'domain');
|
||||
}
|
||||
@ -182,7 +182,7 @@ class Domain_Manager extends Base_Manager {
|
||||
* @param \WP_Site $site The site being removed.
|
||||
* @return void
|
||||
*/
|
||||
public function handle_site_deleted($site) {
|
||||
public function handle_site_deleted($site): void {
|
||||
|
||||
global $current_site;
|
||||
|
||||
@ -192,10 +192,10 @@ class Domain_Manager extends Base_Manager {
|
||||
return;
|
||||
}
|
||||
|
||||
$args = array(
|
||||
$args = [
|
||||
'subdomain' => $site->domain,
|
||||
'site_id' => $site->blog_id,
|
||||
);
|
||||
];
|
||||
|
||||
wu_enqueue_async_action('wu_remove_subdomain', $args, 'domain');
|
||||
}
|
||||
@ -210,7 +210,7 @@ class Domain_Manager extends Base_Manager {
|
||||
* @param \WP_Ultimo\Models\Membership $membership The membership.
|
||||
* @return void
|
||||
*/
|
||||
public function handle_domain_created($domain, $site, $membership) {
|
||||
public function handle_domain_created($domain, $site, $membership): void {
|
||||
|
||||
$payload = array_merge(
|
||||
wu_generate_event_payload('domain', $domain),
|
||||
@ -231,13 +231,13 @@ class Domain_Manager extends Base_Manager {
|
||||
* @param \WP_Ultimo\Models\Domain $domain The domain being deleted.
|
||||
* @return void
|
||||
*/
|
||||
public function handle_domain_deleted($result, $domain) {
|
||||
public function handle_domain_deleted($result, $domain): void {
|
||||
|
||||
if ($result) {
|
||||
$args = array(
|
||||
$args = [
|
||||
'domain' => $domain->get_domain(),
|
||||
'site_id' => $domain->get_site_id(),
|
||||
);
|
||||
];
|
||||
|
||||
wu_enqueue_async_action('wu_remove_domain', $args, 'domain');
|
||||
}
|
||||
@ -249,78 +249,78 @@ class Domain_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function add_domain_mapping_settings() {
|
||||
public function add_domain_mapping_settings(): void {
|
||||
|
||||
wu_register_settings_field(
|
||||
'domain-mapping',
|
||||
'domain_mapping_header',
|
||||
array(
|
||||
[
|
||||
'title' => __('Domain Mapping Settings', 'wp-ultimo'),
|
||||
'desc' => __('Define the domain mapping settings for your network.', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_settings_field(
|
||||
'domain-mapping',
|
||||
'enable_domain_mapping',
|
||||
array(
|
||||
[
|
||||
'title' => __('Enable Domain Mapping?', 'wp-ultimo'),
|
||||
'desc' => __('Do you want to enable domain mapping?', 'wp-ultimo'),
|
||||
'type' => 'toggle',
|
||||
'default' => 1,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_settings_field(
|
||||
'domain-mapping',
|
||||
'force_admin_redirect',
|
||||
array(
|
||||
[
|
||||
'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'),
|
||||
'tooltip' => '',
|
||||
'type' => 'select',
|
||||
'default' => 'both',
|
||||
'require' => array('enable_domain_mapping' => 1),
|
||||
'options' => array(
|
||||
'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'),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_settings_field(
|
||||
'domain-mapping',
|
||||
'custom_domains',
|
||||
array(
|
||||
[
|
||||
'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'),
|
||||
'type' => 'toggle',
|
||||
'default' => 1,
|
||||
'require' => array(
|
||||
'require' => [
|
||||
'enable_domain_mapping' => true,
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_settings_field(
|
||||
'domain-mapping',
|
||||
'domain_mapping_instructions',
|
||||
array(
|
||||
[
|
||||
'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'),
|
||||
'type' => 'textarea',
|
||||
'default' => array($this, 'default_domain_mapping_instructions'),
|
||||
'html_attr' => array(
|
||||
'default' => [$this, 'default_domain_mapping_instructions'],
|
||||
'html_attr' => [
|
||||
'rows' => 8,
|
||||
),
|
||||
'require' => array(
|
||||
],
|
||||
'require' => [
|
||||
'enable_domain_mapping' => true,
|
||||
'custom_domains' => true,
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -330,55 +330,55 @@ class Domain_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function add_sso_settings() {
|
||||
public function add_sso_settings(): void {
|
||||
|
||||
wu_register_settings_field(
|
||||
'sso',
|
||||
'sso_header',
|
||||
array(
|
||||
[
|
||||
'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'),
|
||||
'type' => 'header',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_settings_field(
|
||||
'sso',
|
||||
'enable_sso',
|
||||
array(
|
||||
[
|
||||
'title' => __('Enable Single Sign-On', 'wp-ultimo'),
|
||||
'desc' => __('Enables the Single Sign-on functionality.', 'wp-ultimo'),
|
||||
'type' => 'toggle',
|
||||
'default' => 1,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_settings_field(
|
||||
'sso',
|
||||
'restrict_sso_to_login_pages',
|
||||
array(
|
||||
[
|
||||
'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'),
|
||||
'type' => 'toggle',
|
||||
'default' => 0,
|
||||
'require' => array(
|
||||
'require' => [
|
||||
'enable_sso' => true,
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_settings_field(
|
||||
'sso',
|
||||
'enable_sso_loading_overlay',
|
||||
array(
|
||||
[
|
||||
'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'),
|
||||
'type' => 'toggle',
|
||||
'default' => 1,
|
||||
'require' => array(
|
||||
'require' => [
|
||||
'enable_sso' => true,
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
/**
|
||||
@ -388,7 +388,7 @@ class Domain_Manager extends Base_Manager {
|
||||
*/
|
||||
public function default_domain_mapping_instructions(): string {
|
||||
|
||||
$instructions = array();
|
||||
$instructions = [];
|
||||
|
||||
$instructions[] = __("Cool! You're about to make this site accessible using your own domain name!", 'wp-ultimo');
|
||||
|
||||
@ -437,15 +437,15 @@ class Domain_Manager extends Base_Manager {
|
||||
* @param int $item_id The id of the element transitioning.
|
||||
* @return void
|
||||
*/
|
||||
public function send_domain_to_host($old_value, $new_value, $item_id) {
|
||||
public function send_domain_to_host($old_value, $new_value, $item_id): void {
|
||||
|
||||
if ($old_value !== $new_value) {
|
||||
$domain = wu_get_domain($item_id);
|
||||
|
||||
$args = array(
|
||||
$args = [
|
||||
'domain' => $new_value,
|
||||
'site_id' => $domain->get_site_id(),
|
||||
);
|
||||
];
|
||||
|
||||
wu_enqueue_async_action('wu_add_domain', $args, 'domain');
|
||||
}
|
||||
@ -460,7 +460,7 @@ class Domain_Manager extends Base_Manager {
|
||||
* @param int $tries Number of tries.
|
||||
* @return void
|
||||
*/
|
||||
public function async_process_domain_stage($domain_id, $tries = 0) {
|
||||
public function async_process_domain_stage($domain_id, $tries = 0): void {
|
||||
|
||||
$domain = wu_get_domain($domain_id);
|
||||
|
||||
@ -494,10 +494,10 @@ class Domain_Manager extends Base_Manager {
|
||||
|
||||
wu_enqueue_async_action(
|
||||
'wu_async_process_domain_stage',
|
||||
array(
|
||||
[
|
||||
'domain_id' => $domain_id,
|
||||
'tries' => 0,
|
||||
),
|
||||
],
|
||||
'domain'
|
||||
);
|
||||
|
||||
@ -531,10 +531,10 @@ class Domain_Manager extends Base_Manager {
|
||||
wu_schedule_single_action(
|
||||
strtotime("+{$try_again_time} minutes"),
|
||||
'wu_async_process_domain_stage',
|
||||
array(
|
||||
[
|
||||
'domain_id' => $domain_id,
|
||||
'tries' => $tries,
|
||||
),
|
||||
],
|
||||
'domain'
|
||||
);
|
||||
|
||||
@ -581,10 +581,10 @@ class Domain_Manager extends Base_Manager {
|
||||
wu_schedule_single_action(
|
||||
strtotime("+{$try_again_time} minutes"),
|
||||
'wu_async_process_domain_stage',
|
||||
array(
|
||||
[
|
||||
'domain_id' => $domain_id,
|
||||
'tries' => $tries,
|
||||
),
|
||||
],
|
||||
'domain'
|
||||
);
|
||||
|
||||
@ -602,17 +602,17 @@ class Domain_Manager extends Base_Manager {
|
||||
*/
|
||||
public static function dns_get_record($domain) {
|
||||
|
||||
$results = array();
|
||||
$results = [];
|
||||
|
||||
wu_setup_memory_limit_trap('json');
|
||||
|
||||
wu_try_unlimited_server_limits();
|
||||
|
||||
$record_types = array(
|
||||
$record_types = [
|
||||
'NS',
|
||||
'CNAME',
|
||||
'A',
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($record_types as $record_type) {
|
||||
$chain = new \RemotelyLiving\PHPDNS\Resolvers\Chain(
|
||||
@ -625,7 +625,7 @@ class Domain_Manager extends Base_Manager {
|
||||
$records = $chain->getRecords($domain, $record_type);
|
||||
|
||||
foreach ($records as $record_data) {
|
||||
$record = array();
|
||||
$record = [];
|
||||
|
||||
$record['type'] = $record_type;
|
||||
|
||||
@ -659,7 +659,7 @@ class Domain_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function get_dns_records() {
|
||||
public function get_dns_records(): void {
|
||||
|
||||
$domain = wu_request('domain');
|
||||
|
||||
@ -667,9 +667,9 @@ class Domain_Manager extends Base_Manager {
|
||||
wp_send_json_error(new \WP_Error('domain-missing', __('A valid domain was not passed.', 'wp-ultimo')));
|
||||
}
|
||||
|
||||
$auth_ns = array();
|
||||
$auth_ns = [];
|
||||
|
||||
$additional = array();
|
||||
$additional = [];
|
||||
|
||||
try {
|
||||
$result = self::dns_get_record($domain);
|
||||
@ -678,9 +678,9 @@ class Domain_Manager extends Base_Manager {
|
||||
new \WP_Error(
|
||||
'error',
|
||||
__('Not able to fetch DNS entries.', 'wp-ultimo'),
|
||||
array(
|
||||
[
|
||||
'exception' => $e->getMessage(),
|
||||
)
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -690,12 +690,12 @@ class Domain_Manager extends Base_Manager {
|
||||
}
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'entries' => $result,
|
||||
'auth' => $auth_ns,
|
||||
'additional' => $additional,
|
||||
'network_ip' => Helper::get_network_public_ip(),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -709,7 +709,7 @@ class Domain_Manager extends Base_Manager {
|
||||
* @param array $domains List of domain ids.
|
||||
* @return void
|
||||
*/
|
||||
public function async_remove_old_primary_domains($domains) {
|
||||
public function async_remove_old_primary_domains($domains): void {
|
||||
|
||||
foreach ($domains as $domain_id) {
|
||||
$domain = wu_get_domain($domain_id);
|
||||
@ -736,9 +736,9 @@ class Domain_Manager extends Base_Manager {
|
||||
|
||||
if ( ! $integration) {
|
||||
wp_send_json_error(
|
||||
array(
|
||||
[
|
||||
'message' => __('Invalid Integration ID', 'wp-ultimo'),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -747,12 +747,12 @@ class Domain_Manager extends Base_Manager {
|
||||
*/
|
||||
if ( ! $integration->is_setup()) {
|
||||
wp_send_json_error(
|
||||
array(
|
||||
[
|
||||
'message' => sprintf(
|
||||
__('The necessary constants were not found on your wp-config.php file: %s', 'wp-ultimo'),
|
||||
implode(', ', $integration->get_missing_constants())
|
||||
),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -765,7 +765,7 @@ class Domain_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function load_integrations() {
|
||||
public function load_integrations(): void {
|
||||
/*
|
||||
* Loads our RunCloud integration.
|
||||
*/
|
||||
|
@ -45,7 +45,7 @@ class Email_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $model_class = '\\WP_Ultimo\\Models\\Email';
|
||||
protected $model_class = \WP_Ultimo\Models\Email::class;
|
||||
|
||||
/**
|
||||
* All default system emails and their original content.
|
||||
@ -61,7 +61,7 @@ class Email_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
$this->enable_rest_api();
|
||||
|
||||
@ -77,21 +77,21 @@ class Email_Manager extends Base_Manager {
|
||||
/*
|
||||
* Adds the Email fields
|
||||
*/
|
||||
add_action('wu_settings_emails', array($this, 'add_email_fields'));
|
||||
add_action('wu_settings_emails', [$this, 'add_email_fields']);
|
||||
|
||||
add_action('wu_event', array($this, 'send_system_email'), 10, 2);
|
||||
add_action('wu_event', [$this, 'send_system_email'], 10, 2);
|
||||
|
||||
/*
|
||||
* Registering a callback action to a schedule send.
|
||||
*/
|
||||
add_action('wu_send_schedule_system_email', array($this, 'send_schedule_system_email'), 10, 5);
|
||||
add_action('wu_send_schedule_system_email', [$this, 'send_schedule_system_email'], 10, 3);
|
||||
|
||||
/*
|
||||
* Create a log when a mail send fails.
|
||||
*/
|
||||
add_action('wp_mail_failed', array($this, 'log_mailer_failure'));
|
||||
add_action('wp_mail_failed', [$this, 'log_mailer_failure']);
|
||||
|
||||
add_action('wp_ajax_wu_get_event_payload_placeholders', array($this, 'get_event_placeholders'));
|
||||
add_action('wp_ajax_wu_get_event_payload_placeholders', [$this, 'get_event_placeholders']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,28 +101,28 @@ class Email_Manager extends Base_Manager {
|
||||
* @param array $payload Payload of the event.
|
||||
* @return void.
|
||||
*/
|
||||
public function send_system_email($slug, $payload) {
|
||||
public function send_system_email($slug, $payload): void {
|
||||
|
||||
$all_emails = wu_get_emails(
|
||||
array(
|
||||
[
|
||||
'event' => $slug,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$original_from = array(
|
||||
$original_from = [
|
||||
'name' => wu_get_setting('from_name'),
|
||||
'email' => wu_get_setting('from_email'),
|
||||
);
|
||||
];
|
||||
|
||||
/*
|
||||
* Loop through all the emails registered.
|
||||
*/
|
||||
foreach ($all_emails as $email) {
|
||||
if ($email->get_custom_sender()) {
|
||||
$from = array(
|
||||
$from = [
|
||||
'name' => $email->get_custom_sender_name(),
|
||||
'email' => $email->get_custom_sender_email(),
|
||||
);
|
||||
];
|
||||
} else {
|
||||
$from = $original_from;
|
||||
}
|
||||
@ -138,12 +138,12 @@ class Email_Manager extends Base_Manager {
|
||||
return;
|
||||
}
|
||||
|
||||
$args = array(
|
||||
$args = [
|
||||
'style' => $email->get_style(),
|
||||
'content' => $email->get_content(),
|
||||
'subject' => get_network_option(null, 'site_name') . ' - ' . $email->get_title(),
|
||||
'payload' => $payload,
|
||||
);
|
||||
];
|
||||
|
||||
/*
|
||||
* Add the invoice attachment, if need be.
|
||||
@ -174,7 +174,7 @@ class Email_Manager extends Base_Manager {
|
||||
* @param string $email_subject The email subject, to avoid attaching a file to the wrong email.
|
||||
* @return void
|
||||
*/
|
||||
public function attach_file_by_url($file_url, $file_name, $email_subject = '') {
|
||||
public function attach_file_by_url($file_url, $file_name, $email_subject = ''): void {
|
||||
|
||||
add_action(
|
||||
'phpmailer_init',
|
||||
@ -187,9 +187,9 @@ class Email_Manager extends Base_Manager {
|
||||
|
||||
$response = wp_remote_get(
|
||||
$file_url,
|
||||
array(
|
||||
[
|
||||
'timeout' => 50,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if (is_wp_error($response)) {
|
||||
@ -212,98 +212,98 @@ class Email_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function add_email_fields() {
|
||||
public function add_email_fields(): void {
|
||||
|
||||
wu_register_settings_field(
|
||||
'emails',
|
||||
'sender_header',
|
||||
array(
|
||||
[
|
||||
'title' => __('Sender Settings', 'wp-ultimo'),
|
||||
'desc' => __('Change the settings of the email headers, like from and name.', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_settings_field(
|
||||
'emails',
|
||||
'from_name',
|
||||
array(
|
||||
[
|
||||
'title' => __('"From" Name', 'wp-ultimo'),
|
||||
'desc' => __('How the sender name will appear in emails sent by WP Multisite WaaS.', 'wp-ultimo'),
|
||||
'type' => 'text',
|
||||
'placeholder' => get_network_option(null, 'site_name'),
|
||||
'default' => get_network_option(null, 'site_name'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'from_name',
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_settings_field(
|
||||
'emails',
|
||||
'from_email',
|
||||
array(
|
||||
[
|
||||
'title' => __('"From" E-mail', 'wp-ultimo'),
|
||||
'desc' => __('How the sender email will appear in emails sent by WP Multisite WaaS.', 'wp-ultimo'),
|
||||
'type' => 'email',
|
||||
'placeholder' => get_network_option(null, 'admin_email'),
|
||||
'default' => get_network_option(null, 'admin_email'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'from_email',
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_settings_field(
|
||||
'emails',
|
||||
'template_header',
|
||||
array(
|
||||
[
|
||||
'title' => __('Template Settings', 'wp-ultimo'),
|
||||
'desc' => __('Change the settings of the email templates.', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_settings_field(
|
||||
'emails',
|
||||
'email_template_type',
|
||||
array(
|
||||
[
|
||||
'title' => __('Email Templates Style', 'wp-ultimo'),
|
||||
'desc' => __('Choose if email body will be sent using the HTML template or in plain text.', 'wp-ultimo'),
|
||||
'type' => 'select',
|
||||
'default' => 'html',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'html' => __('HTML Emails', 'wp-ultimo'),
|
||||
'plain' => __('Plain Emails', 'wp-ultimo'),
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'emails_template',
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_settings_field(
|
||||
'emails',
|
||||
'expiring_header',
|
||||
array(
|
||||
[
|
||||
'title' => __('Expiring Notification Settings', 'wp-ultimo'),
|
||||
'desc' => __('Change the settings for the expiring notification (trials and subscriptions) emails.', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_settings_field(
|
||||
'emails',
|
||||
'expiring_days',
|
||||
array(
|
||||
[
|
||||
'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'),
|
||||
'type' => 'number',
|
||||
'placeholder' => __('e.g. 3', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'expiring_days',
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -315,7 +315,7 @@ class Email_Manager extends Base_Manager {
|
||||
* @param array $args System email params.
|
||||
* @return void.
|
||||
*/
|
||||
public function register_default_system_email($args) {
|
||||
public function register_default_system_email($args): void {
|
||||
|
||||
$this->registered_default_system_emails[ $args['slug'] ] = $args;
|
||||
}
|
||||
@ -336,7 +336,7 @@ class Email_Manager extends Base_Manager {
|
||||
|
||||
$email_args = wp_parse_args(
|
||||
$args,
|
||||
array(
|
||||
[
|
||||
'event' => '',
|
||||
'title' => '',
|
||||
'content' => '',
|
||||
@ -349,7 +349,7 @@ class Email_Manager extends Base_Manager {
|
||||
'date_registered' => wu_get_current_time('mysql', true),
|
||||
'date_modified' => wu_get_current_time('mysql', true),
|
||||
'status' => 'publish',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$email = new Email($email_args);
|
||||
@ -366,7 +366,7 @@ class Email_Manager extends Base_Manager {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function create_all_system_emails() {
|
||||
public function create_all_system_emails(): void {
|
||||
|
||||
$system_emails = wu_get_default_system_emails();
|
||||
|
||||
@ -382,96 +382,96 @@ class Email_Manager extends Base_Manager {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register_all_default_system_emails() {
|
||||
public function register_all_default_system_emails(): void {
|
||||
/*
|
||||
* Payment Successful - Admin
|
||||
*/
|
||||
$this->register_default_system_email(
|
||||
array(
|
||||
[
|
||||
'event' => 'payment_received',
|
||||
'slug' => 'payment_received_admin',
|
||||
'target' => 'admin',
|
||||
'title' => __('You got a new payment!', 'wp-ultimo'),
|
||||
'content' => wu_get_template_contents('emails/admin/payment-received'),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
/*
|
||||
* Payment Successful - Customer
|
||||
*/
|
||||
$this->register_default_system_email(
|
||||
array(
|
||||
[
|
||||
'event' => 'payment_received',
|
||||
'slug' => 'payment_received_customer',
|
||||
'target' => 'customer',
|
||||
'title' => __('We got your payment!', 'wp-ultimo'),
|
||||
'content' => wu_get_template_contents('emails/customer/payment-received'),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
/*
|
||||
* Site Published - Admin
|
||||
*/
|
||||
$this->register_default_system_email(
|
||||
array(
|
||||
[
|
||||
'event' => 'site_published',
|
||||
'target' => 'admin',
|
||||
'slug' => 'site_published_admin',
|
||||
'title' => __('A new site was created on your Network!', 'wp-ultimo'),
|
||||
'content' => wu_get_template_contents('emails/admin/site-published'),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
/*
|
||||
* Site Published - Customer
|
||||
*/
|
||||
$this->register_default_system_email(
|
||||
array(
|
||||
[
|
||||
'event' => 'site_published',
|
||||
'target' => 'customer',
|
||||
'slug' => 'site_published_customer',
|
||||
'title' => __('Your site is ready!', 'wp-ultimo'),
|
||||
'content' => wu_get_template_contents('emails/customer/site-published'),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
/*
|
||||
* Site Published - Customer
|
||||
*/
|
||||
$this->register_default_system_email(
|
||||
array(
|
||||
[
|
||||
'event' => 'confirm_email_address',
|
||||
'target' => 'customer',
|
||||
'slug' => 'confirm_email_address',
|
||||
'title' => __('Confirm your email address!', 'wp-ultimo'),
|
||||
'content' => wu_get_template_contents('emails/customer/confirm-email-address'),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
/*
|
||||
* Domain Created - Admin
|
||||
*/
|
||||
$this->register_default_system_email(
|
||||
array(
|
||||
[
|
||||
'event' => 'domain_created',
|
||||
'target' => 'admin',
|
||||
'slug' => 'domain_created_admin',
|
||||
'title' => __('A new domain was added to your Network!', 'wp-ultimo'),
|
||||
'content' => wu_get_template_contents('emails/admin/domain-created'),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
/*
|
||||
* Pending Renewal Payment Created - Customer
|
||||
*/
|
||||
$this->register_default_system_email(
|
||||
array(
|
||||
[
|
||||
'event' => 'renewal_payment_created',
|
||||
'target' => 'customer',
|
||||
'slug' => 'renewal_payment_created',
|
||||
'title' => __('You have a new pending payment!', 'wp-ultimo'),
|
||||
'content' => wu_get_template_contents('emails/customer/renewal-payment-created'),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
do_action('wu_system_emails_after_register');
|
||||
@ -515,7 +515,7 @@ class Email_Manager extends Base_Manager {
|
||||
*/
|
||||
public function get_event_placeholders($slug = '') {
|
||||
|
||||
$placeholders = array();
|
||||
$placeholders = [];
|
||||
|
||||
if (wu_request('email_event')) {
|
||||
$slug = wu_request('email_event');
|
||||
@ -528,10 +528,10 @@ class Email_Manager extends Base_Manager {
|
||||
foreach (wu_maybe_lazy_load_payload($event['payload']) as $placeholder => $value) {
|
||||
$name = ucwords(str_replace('_', ' ', $placeholder));
|
||||
|
||||
$placeholders[] = array(
|
||||
$placeholders[] = [
|
||||
'name' => $name,
|
||||
'placeholder' => $placeholder,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -551,13 +551,11 @@ class Email_Manager extends Base_Manager {
|
||||
* @param array $to Email targets.
|
||||
* @param string $subject Email subject.
|
||||
* @param string $template Email content.
|
||||
* @param array $headers Email headers.
|
||||
* @param array $attachments Email attachments.
|
||||
* @return mixed
|
||||
*/
|
||||
public function send_schedule_system_email($to, $subject, $template, $headers, $attachments) {
|
||||
public function send_schedule_system_email($to, $subject, $template) {
|
||||
|
||||
return Sender::send_mail($to, $subject, $template, $headers, $attachments);
|
||||
return Sender::send_mail($to, $subject, $template);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -568,7 +566,7 @@ class Email_Manager extends Base_Manager {
|
||||
* @param \WP_Error $error The error with the mailer.
|
||||
* @return void.
|
||||
*/
|
||||
public function log_mailer_failure($error) {
|
||||
public function log_mailer_failure($error): void {
|
||||
|
||||
if (is_wp_error($error)) {
|
||||
wu_log_add('mailer-errors', $error->get_error_message(), LogLevel::ERROR);
|
||||
|
@ -43,7 +43,7 @@ class Event_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $model_class = '\\WP_Ultimo\\Models\\Event';
|
||||
protected $model_class = \WP_Ultimo\Models\Event::class;
|
||||
|
||||
/**
|
||||
* Holds the list of available events for webhooks.
|
||||
@ -51,7 +51,7 @@ class Event_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $events = array();
|
||||
protected $events = [];
|
||||
|
||||
/**
|
||||
* The list of registered models events.
|
||||
@ -59,7 +59,7 @@ class Event_Manager extends Base_Manager {
|
||||
* @since 2.1.4
|
||||
* @var array
|
||||
*/
|
||||
protected $models_events = array();
|
||||
protected $models_events = [];
|
||||
|
||||
/**
|
||||
* Instantiate the necessary hooks.
|
||||
@ -67,21 +67,21 @@ class Event_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
$this->enable_rest_api();
|
||||
|
||||
$this->enable_wp_cli();
|
||||
|
||||
add_action('init', array($this, 'register_all_events'));
|
||||
add_action('init', [$this, 'register_all_events']);
|
||||
|
||||
add_action('wp_ajax_wu_get_event_payload_preview', array($this, 'event_payload_preview'));
|
||||
add_action('wp_ajax_wu_get_event_payload_preview', [$this, 'event_payload_preview']);
|
||||
|
||||
add_action('rest_api_init', array($this, 'hooks_endpoint'));
|
||||
add_action('rest_api_init', [$this, 'hooks_endpoint']);
|
||||
|
||||
add_action('wu_model_post_save', array($this, 'log_transitions'), 10, 4);
|
||||
add_action('wu_model_post_save', [$this, 'log_transitions'], 10, 4);
|
||||
|
||||
add_action('wu_daily', array($this, 'clean_old_events'));
|
||||
add_action('wu_daily', [$this, 'clean_old_events']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -112,7 +112,7 @@ class Event_Manager extends Base_Manager {
|
||||
|
||||
$keys_to_remove = apply_filters(
|
||||
'wu_exclude_transitions_keys',
|
||||
array(
|
||||
[
|
||||
'meta',
|
||||
'last_login',
|
||||
'ips',
|
||||
@ -121,7 +121,7 @@ class Event_Manager extends Base_Manager {
|
||||
'_compiled_product_list',
|
||||
'_gateway_info',
|
||||
'_limitations',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
foreach ($keys_to_remove as $key_to_remove) {
|
||||
@ -135,7 +135,7 @@ class Event_Manager extends Base_Manager {
|
||||
return;
|
||||
}
|
||||
|
||||
$changed = array();
|
||||
$changed = [];
|
||||
|
||||
/**
|
||||
* Loop changed data.
|
||||
@ -151,27 +151,27 @@ class Event_Manager extends Base_Manager {
|
||||
return;
|
||||
}
|
||||
|
||||
$changed[ $key ] = array(
|
||||
$changed[ $key ] = [
|
||||
'old_value' => $old_value,
|
||||
'new_value' => $new_value,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$event_data = array(
|
||||
$event_data = [
|
||||
'severity' => Event::SEVERITY_INFO,
|
||||
'slug' => 'changed',
|
||||
'object_type' => $model,
|
||||
'object_id' => $object->get_id(),
|
||||
'payload' => $changed,
|
||||
);
|
||||
];
|
||||
} else {
|
||||
$event_data = array(
|
||||
$event_data = [
|
||||
'severity' => Event::SEVERITY_INFO,
|
||||
'slug' => 'created',
|
||||
'object_type' => $model,
|
||||
'object_id' => $object->get_id(),
|
||||
'payload' => array(),
|
||||
);
|
||||
'payload' => [],
|
||||
];
|
||||
}
|
||||
|
||||
if ( ! empty($_POST) && is_user_logged_in()) {
|
||||
@ -188,7 +188,7 @@ class Event_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function event_payload_preview() {
|
||||
public function event_payload_preview(): void {
|
||||
|
||||
if ( ! wu_request('event')) {
|
||||
wp_send_json_error(new \WP_Error('error', __('No event was selected.', 'wp-ultimo')));
|
||||
@ -223,9 +223,9 @@ class Event_Manager extends Base_Manager {
|
||||
/*
|
||||
* We use this to order the options.
|
||||
*/
|
||||
$event_type_settings = wu_get_setting('saving_type', array());
|
||||
$event_type_settings = wu_get_setting('saving_type', []);
|
||||
|
||||
$types = array(
|
||||
$types = [
|
||||
'id' => '$id',
|
||||
'title' => '$title',
|
||||
'desc' => '$desc',
|
||||
@ -234,7 +234,7 @@ class Event_Manager extends Base_Manager {
|
||||
'active' => 'in_array($id, $active_gateways, true)',
|
||||
'gateway' => '$class_name', // Deprecated.
|
||||
'hidden' => false,
|
||||
);
|
||||
];
|
||||
|
||||
$types = array_filter($types, fn($item) => $item['hidden'] === false);
|
||||
|
||||
@ -256,14 +256,14 @@ class Event_Manager extends Base_Manager {
|
||||
$registered_event = $this->get_event($slug);
|
||||
|
||||
if ( ! $registered_event) {
|
||||
return array('error' => 'Event not found');
|
||||
return ['error' => 'Event not found'];
|
||||
}
|
||||
|
||||
$payload_diff = array_diff_key(wu_maybe_lazy_load_payload($registered_event['payload']), $payload);
|
||||
|
||||
if (isset($payload_diff[0])) {
|
||||
foreach ($payload_diff[0] as $diff_key => $diff_value) {
|
||||
return array('error' => 'Param required:' . $diff_key);
|
||||
return ['error' => 'Param required:' . $diff_key];
|
||||
}
|
||||
}
|
||||
|
||||
@ -337,17 +337,17 @@ class Event_Manager extends Base_Manager {
|
||||
* @param array $payload with event params.
|
||||
* @return void.
|
||||
*/
|
||||
public function save_event($slug, $payload) {
|
||||
public function save_event($slug, $payload): void {
|
||||
|
||||
$event = new Event(
|
||||
array(
|
||||
[
|
||||
'object_id' => wu_get_isset($payload, 'object_id', ''),
|
||||
'object_type' => wu_get_isset($payload, 'object_type', ''),
|
||||
'severity' => wu_get_isset($payload, 'type', Event::SEVERITY_INFO),
|
||||
'date_created' => wu_get_current_time('mysql', true),
|
||||
'slug' => strtolower($slug),
|
||||
'payload' => $payload,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$event->save();
|
||||
@ -359,14 +359,14 @@ class Event_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_all_events() {
|
||||
public function register_all_events(): void {
|
||||
|
||||
/**
|
||||
* Payment Received.
|
||||
*/
|
||||
wu_register_event_type(
|
||||
'payment_received',
|
||||
array(
|
||||
[
|
||||
'name' => __('Payment Received', 'wp-ultimo'),
|
||||
'desc' => __('This event is fired every time a new payment is received, regardless of the payment status.', 'wp-ultimo'),
|
||||
'payload' => fn() => array_merge(
|
||||
@ -374,14 +374,14 @@ class Event_Manager extends Base_Manager {
|
||||
wu_generate_event_payload('membership'),
|
||||
wu_generate_event_payload('customer')
|
||||
),
|
||||
'deprecated_args' => array(
|
||||
'deprecated_args' => [
|
||||
'user_id' => 'customer_user_id',
|
||||
'amount' => 'payment_total',
|
||||
'gateway' => 'payment_gateway',
|
||||
'status' => 'payment_status',
|
||||
'date' => 'payment_date_created',
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
/**
|
||||
@ -389,7 +389,7 @@ class Event_Manager extends Base_Manager {
|
||||
*/
|
||||
wu_register_event_type(
|
||||
'site_published',
|
||||
array(
|
||||
[
|
||||
'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'),
|
||||
'payload' => fn() => array_merge(
|
||||
@ -397,8 +397,8 @@ class Event_Manager extends Base_Manager {
|
||||
wu_generate_event_payload('customer'),
|
||||
wu_generate_event_payload('membership')
|
||||
),
|
||||
'deprecated_args' => array(),
|
||||
)
|
||||
'deprecated_args' => [],
|
||||
]
|
||||
);
|
||||
|
||||
/**
|
||||
@ -406,17 +406,17 @@ class Event_Manager extends Base_Manager {
|
||||
*/
|
||||
wu_register_event_type(
|
||||
'confirm_email_address',
|
||||
array(
|
||||
[
|
||||
'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'),
|
||||
'payload' => fn() => array_merge(
|
||||
array(
|
||||
[
|
||||
'verification_link' => 'https://linktoverifyemail.com',
|
||||
),
|
||||
],
|
||||
wu_generate_event_payload('customer')
|
||||
),
|
||||
'deprecated_args' => array(),
|
||||
)
|
||||
'deprecated_args' => [],
|
||||
]
|
||||
);
|
||||
|
||||
/**
|
||||
@ -424,7 +424,7 @@ class Event_Manager extends Base_Manager {
|
||||
*/
|
||||
wu_register_event_type(
|
||||
'domain_created',
|
||||
array(
|
||||
[
|
||||
'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'),
|
||||
'payload' => fn() => array_merge(
|
||||
@ -433,14 +433,14 @@ class Event_Manager extends Base_Manager {
|
||||
wu_generate_event_payload('membership'),
|
||||
wu_generate_event_payload('customer')
|
||||
),
|
||||
'deprecated_args' => array(
|
||||
'deprecated_args' => [
|
||||
'user_id' => 1,
|
||||
'user_site_id' => 1,
|
||||
'mapped_domain' => 'mydomain.com',
|
||||
'user_site_url' => 'http://test.mynetwork.com/',
|
||||
'network_ip' => '125.399.3.23',
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
/**
|
||||
@ -448,19 +448,19 @@ class Event_Manager extends Base_Manager {
|
||||
*/
|
||||
wu_register_event_type(
|
||||
'renewal_payment_created',
|
||||
array(
|
||||
[
|
||||
'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'),
|
||||
'payload' => fn() => array_merge(
|
||||
array(
|
||||
[
|
||||
'default_payment_url' => 'https://linktopayment.com',
|
||||
),
|
||||
],
|
||||
wu_generate_event_payload('payment'),
|
||||
wu_generate_event_payload('membership'),
|
||||
wu_generate_event_payload('customer')
|
||||
),
|
||||
'deprecated_args' => array(),
|
||||
)
|
||||
'deprecated_args' => [],
|
||||
]
|
||||
);
|
||||
|
||||
$models = $this->models_events;
|
||||
@ -469,16 +469,16 @@ class Event_Manager extends Base_Manager {
|
||||
foreach ($params['types'] as $type) {
|
||||
wu_register_event_type(
|
||||
$model . '_' . $type,
|
||||
array(
|
||||
[
|
||||
'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),
|
||||
'deprecated_args' => array(),
|
||||
'deprecated_args' => [],
|
||||
'payload' => fn() => $this->get_model_payload($model),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
add_action("wu_{$model}_post_save", array($this, 'dispatch_base_model_event'), 10, 3);
|
||||
add_action("wu_{$model}_post_save", [$this, 'dispatch_base_model_event'], 10, 3);
|
||||
}
|
||||
|
||||
do_action('wu_register_all_events');
|
||||
@ -496,10 +496,10 @@ class Event_Manager extends Base_Manager {
|
||||
|
||||
$instance = self::get_instance();
|
||||
|
||||
$instance->models_events[ $slug ] = array(
|
||||
$instance->models_events[ $slug ] = [
|
||||
'label' => $label,
|
||||
'types' => $event_types,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -574,9 +574,7 @@ class Event_Manager extends Base_Manager {
|
||||
$payload = array_merge(
|
||||
$payload,
|
||||
array_map(
|
||||
function () {
|
||||
return '';
|
||||
},
|
||||
fn() => '',
|
||||
\WP_Ultimo\Objects\Billing_Address::fields()
|
||||
)
|
||||
);
|
||||
@ -603,14 +601,14 @@ class Event_Manager extends Base_Manager {
|
||||
}
|
||||
|
||||
$events_to_remove = wu_get_events(
|
||||
array(
|
||||
[
|
||||
'number' => 100,
|
||||
'date_query' => array(
|
||||
'date_query' => [
|
||||
'column' => 'date_created',
|
||||
'before' => "-{$threshold_days} days",
|
||||
'inclusive' => true,
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$success_count = 0;
|
||||
@ -635,7 +633,7 @@ class Event_Manager extends Base_Manager {
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function hooks_endpoint() {
|
||||
public function hooks_endpoint(): void {
|
||||
|
||||
if ( ! wu_get_setting('enable_api', true)) {
|
||||
return;
|
||||
@ -646,11 +644,11 @@ class Event_Manager extends Base_Manager {
|
||||
register_rest_route(
|
||||
$api->get_namespace(),
|
||||
'/hooks',
|
||||
array(
|
||||
[
|
||||
'methods' => 'GET',
|
||||
'callback' => array($this, 'get_hooks_rest'),
|
||||
'permission_callback' => array($api, 'check_authorization'),
|
||||
)
|
||||
'callback' => [$this, 'get_hooks_rest'],
|
||||
'permission_callback' => [$api, 'check_authorization'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ class Field_Templates_Manager extends Base_Manager {
|
||||
* @since 2.2.0
|
||||
* @var array
|
||||
*/
|
||||
protected $holders = array();
|
||||
protected $holders = [];
|
||||
|
||||
/**
|
||||
* Initialize the managers with the necessary hooks.
|
||||
@ -39,11 +39,11 @@ class Field_Templates_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
add_action('wu_ajax_nopriv_wu_render_field_template', array($this, 'serve_field_template'));
|
||||
add_action('wu_ajax_nopriv_wu_render_field_template', [$this, 'serve_field_template']);
|
||||
|
||||
add_action('wu_ajax_wu_render_field_template', array($this, 'serve_field_template'));
|
||||
add_action('wu_ajax_wu_render_field_template', [$this, 'serve_field_template']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,7 +52,7 @@ class Field_Templates_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function serve_field_template() {
|
||||
public function serve_field_template(): void {
|
||||
|
||||
$template = wu_replace_dashes(wu_request('template'));
|
||||
|
||||
@ -69,9 +69,9 @@ class Field_Templates_Manager extends Base_Manager {
|
||||
$attributes = apply_filters("wu_{$key}_render_attributes", wu_request('attributes'));
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'html' => $template_class->render($attributes),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -88,55 +88,55 @@ class Field_Templates_Manager extends Base_Manager {
|
||||
*/
|
||||
public function get_field_templates() {
|
||||
|
||||
$field_templates = array();
|
||||
$field_templates = [];
|
||||
|
||||
/*
|
||||
* Adds default template selection templates.
|
||||
*/
|
||||
$field_templates['template_selection'] = array(
|
||||
'clean' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Field_Templates\\Template_Selection\\Clean_Template_Selection_Field_Template',
|
||||
'minimal' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Field_Templates\\Template_Selection\\Minimal_Template_Selection_Field_Template',
|
||||
'legacy' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Field_Templates\\Template_Selection\\Legacy_Template_Selection_Field_Template',
|
||||
);
|
||||
$field_templates['template_selection'] = [
|
||||
'clean' => \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Template_Selection\Clean_Template_Selection_Field_Template::class,
|
||||
'minimal' => \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Template_Selection\Minimal_Template_Selection_Field_Template::class,
|
||||
'legacy' => \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Template_Selection\Legacy_Template_Selection_Field_Template::class,
|
||||
];
|
||||
|
||||
/*
|
||||
* Adds the default period selector templates.
|
||||
*/
|
||||
$field_templates['period_selection'] = array(
|
||||
'clean' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Field_Templates\\Period_Selection\\Clean_Period_Selection_Field_Template',
|
||||
'legacy' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Field_Templates\\Period_Selection\\Legacy_Period_Selection_Field_Template',
|
||||
);
|
||||
$field_templates['period_selection'] = [
|
||||
'clean' => \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Period_Selection\Clean_Period_Selection_Field_Template::class,
|
||||
'legacy' => \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Period_Selection\Legacy_Period_Selection_Field_Template::class,
|
||||
];
|
||||
|
||||
/*
|
||||
* Adds the default pricing table templates.
|
||||
*/
|
||||
$field_templates['pricing_table'] = array(
|
||||
'list' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Field_Templates\\Pricing_Table\\List_Pricing_Table_Field_Template',
|
||||
'legacy' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Field_Templates\\Pricing_Table\\Legacy_Pricing_Table_Field_Template',
|
||||
);
|
||||
$field_templates['pricing_table'] = [
|
||||
'list' => \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Pricing_Table\List_Pricing_Table_Field_Template::class,
|
||||
'legacy' => \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Pricing_Table\Legacy_Pricing_Table_Field_Template::class,
|
||||
];
|
||||
|
||||
/*
|
||||
* Adds the default order-bump templates.
|
||||
*/
|
||||
$field_templates['order_bump'] = array(
|
||||
'simple' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Field_Templates\\Order_Bump\\Simple_Order_Bump_Field_Template',
|
||||
);
|
||||
$field_templates['order_bump'] = [
|
||||
'simple' => \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Order_Bump\Simple_Order_Bump_Field_Template::class,
|
||||
];
|
||||
|
||||
/*
|
||||
* Adds the default order-summary templates.
|
||||
*/
|
||||
$field_templates['order_summary'] = array(
|
||||
'clean' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Field_Templates\\Order_Summary\\Clean_Order_Summary_Field_Template',
|
||||
);
|
||||
$field_templates['order_summary'] = [
|
||||
'clean' => \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Order_Summary\Clean_Order_Summary_Field_Template::class,
|
||||
];
|
||||
|
||||
/*
|
||||
* Adds the default order-summary templates.
|
||||
*/
|
||||
$field_templates['steps'] = array(
|
||||
'clean' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Field_Templates\\Steps\\Clean_Steps_Field_Template',
|
||||
'minimal' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Field_Templates\\Steps\\Minimal_Steps_Field_Template',
|
||||
'legacy' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Field_Templates\\Steps\\Legacy_Steps_Field_Template',
|
||||
);
|
||||
$field_templates['steps'] = [
|
||||
'clean' => \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Steps\Clean_Steps_Field_Template::class,
|
||||
'minimal' => \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Steps\Minimal_Steps_Field_Template::class,
|
||||
'legacy' => \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Steps\Legacy_Steps_Field_Template::class,
|
||||
];
|
||||
|
||||
/*
|
||||
* Allow developers to add new field templates
|
||||
@ -167,7 +167,7 @@ class Field_Templates_Manager extends Base_Manager {
|
||||
*/
|
||||
public function get_templates($field_type) {
|
||||
|
||||
return wu_get_isset($this->get_field_templates(), $field_type, array());
|
||||
return wu_get_isset($this->get_field_templates(), $field_type, []);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -198,7 +198,7 @@ class Field_Templates_Manager extends Base_Manager {
|
||||
|
||||
$templates = $this->get_instantiated_field_types($field_type);
|
||||
|
||||
$options = array();
|
||||
$options = [];
|
||||
|
||||
foreach ($templates as $template_id => $template) {
|
||||
$options[ $template_id ] = $template->get_title();
|
||||
@ -219,15 +219,15 @@ class Field_Templates_Manager extends Base_Manager {
|
||||
|
||||
$templates = $this->get_instantiated_field_types($field_type);
|
||||
|
||||
$options = array();
|
||||
$options = [];
|
||||
|
||||
foreach ($templates as $template_id => $template) {
|
||||
$options[ $template_id ] = array(
|
||||
$options[ $template_id ] = [
|
||||
'id' => $template_id,
|
||||
'title' => $template->get_title(),
|
||||
'description' => $template->get_description(),
|
||||
'preview' => $template->get_preview(),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
return $options;
|
||||
@ -258,7 +258,7 @@ class Field_Templates_Manager extends Base_Manager {
|
||||
$holder_name = "instantiated_{$field_type}_templates";
|
||||
|
||||
if ( ! isset($this->holders[ $holder_name ]) || $this->holders[ $holder_name ] === null) {
|
||||
$this->holders[ $holder_name ] = array_map(array($this, 'instantiate_field_template'), $this->get_templates($field_type));
|
||||
$this->holders[ $holder_name ] = array_map([$this, 'instantiate_field_template'], $this->get_templates($field_type));
|
||||
}
|
||||
|
||||
return $this->holders[ $holder_name ];
|
||||
|
@ -31,7 +31,7 @@ class Form_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $registered_forms = array();
|
||||
protected $registered_forms = [];
|
||||
|
||||
/**
|
||||
* Instantiate the necessary hooks.
|
||||
@ -39,13 +39,13 @@ class Form_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
add_action('wu_ajax_wu_form_display', array($this, 'display_form'));
|
||||
add_action('wu_ajax_wu_form_display', [$this, 'display_form']);
|
||||
|
||||
add_action('wu_ajax_wu_form_handler', array($this, 'handle_form'));
|
||||
add_action('wu_ajax_wu_form_handler', [$this, 'handle_form']);
|
||||
|
||||
add_action('wu_register_forms', array($this, 'register_action_forms'));
|
||||
add_action('wu_register_forms', [$this, 'register_action_forms']);
|
||||
|
||||
add_action('wu_page_load', 'add_wubox');
|
||||
|
||||
@ -62,7 +62,7 @@ class Form_Manager extends Base_Manager {
|
||||
* @param \WP_Error|false $error Error message, if applicable.
|
||||
* @return void
|
||||
*/
|
||||
public function display_form_unavailable($error = false) {
|
||||
public function display_form_unavailable($error = false): void {
|
||||
|
||||
$message = __('Form not available', 'wp-ultimo');
|
||||
|
||||
@ -93,7 +93,7 @@ class Form_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function display_form() {
|
||||
public function display_form(): void {
|
||||
|
||||
$this->security_checks();
|
||||
|
||||
@ -104,9 +104,9 @@ class Form_Manager extends Base_Manager {
|
||||
$form['id'],
|
||||
$this->get_form_url(
|
||||
$form['id'],
|
||||
array(
|
||||
[
|
||||
'action' => 'wu_form_handler',
|
||||
)
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
@ -118,7 +118,7 @@ class Form_Manager extends Base_Manager {
|
||||
</ul>
|
||||
</div>',
|
||||
$form['id'] . '_errors',
|
||||
htmlspecialchars(json_encode(array('errors' => array())))
|
||||
htmlspecialchars(json_encode(['errors' => []]))
|
||||
);
|
||||
|
||||
call_user_func($form['render']);
|
||||
@ -140,7 +140,7 @@ class Form_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_form() {
|
||||
public function handle_form(): void {
|
||||
|
||||
$this->security_checks();
|
||||
|
||||
@ -239,17 +239,17 @@ class Form_Manager extends Base_Manager {
|
||||
* @param array $atts Form attributes, check wp_parse_atts call below.
|
||||
* @return void
|
||||
*/
|
||||
public function register_form($id, $atts = array()) {
|
||||
public function register_form($id, $atts = []) {
|
||||
|
||||
$atts = wp_parse_args(
|
||||
$atts,
|
||||
array(
|
||||
[
|
||||
'id' => $id,
|
||||
'form' => '',
|
||||
'capability' => 'manage_network',
|
||||
'handler' => '__return_false',
|
||||
'render' => '__return_empty_string',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
// Checks if gateway was already added
|
||||
@ -271,16 +271,16 @@ class Form_Manager extends Base_Manager {
|
||||
* @param array $atts List of parameters, check wp_parse_args below.
|
||||
* @return string
|
||||
*/
|
||||
public function get_form_url($form_id, $atts = array()) {
|
||||
public function get_form_url($form_id, $atts = []) {
|
||||
|
||||
$atts = wp_parse_args(
|
||||
$atts,
|
||||
array(
|
||||
[
|
||||
'form' => $form_id,
|
||||
'action' => 'wu_form_display',
|
||||
'width' => '400',
|
||||
'height' => '360',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
return add_query_arg($atts, wu_ajax_url('init'));
|
||||
@ -291,28 +291,28 @@ class Form_Manager extends Base_Manager {
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public function register_action_forms() {
|
||||
public function register_action_forms(): void {
|
||||
|
||||
$model = wu_request('model');
|
||||
|
||||
wu_register_form(
|
||||
'delete_modal',
|
||||
array(
|
||||
'render' => array($this, 'render_model_delete_form'),
|
||||
'handler' => array($this, 'handle_model_delete_form'),
|
||||
[
|
||||
'render' => [$this, 'render_model_delete_form'],
|
||||
'handler' => [$this, 'handle_model_delete_form'],
|
||||
'capability' => "wu_delete_{$model}s",
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_form(
|
||||
'bulk_actions',
|
||||
array(
|
||||
'render' => array($this, 'render_bulk_action_form'),
|
||||
'handler' => array($this, 'handle_bulk_action_form'),
|
||||
)
|
||||
[
|
||||
'render' => [$this, 'render_bulk_action_form'],
|
||||
'handler' => [$this, 'handle_bulk_action_form'],
|
||||
]
|
||||
);
|
||||
|
||||
add_action('wu_handle_bulk_action_form', array($this, 'default_bulk_action_handler'), 100, 3);
|
||||
add_action('wu_handle_bulk_action_form', [$this, 'default_bulk_action_handler'], 100, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -321,7 +321,7 @@ class Form_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_model_delete_form() {
|
||||
public function render_model_delete_form(): void {
|
||||
|
||||
$model = wu_request('model');
|
||||
|
||||
@ -333,7 +333,7 @@ class Form_Manager extends Base_Manager {
|
||||
/*
|
||||
* Handle metadata elements passed as model
|
||||
*/
|
||||
if (strpos((string) $model, '_meta_') !== false) {
|
||||
if (str_contains((string) $model, '_meta_')) {
|
||||
$elements = explode('_meta_', (string) $model);
|
||||
|
||||
$model = $elements[0];
|
||||
@ -358,62 +358,62 @@ class Form_Manager extends Base_Manager {
|
||||
|
||||
$fields = apply_filters(
|
||||
"wu_form_fields_delete_{$model}_modal",
|
||||
array(
|
||||
'confirm' => array(
|
||||
[
|
||||
'confirm' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Confirm Deletion', 'wp-ultimo'),
|
||||
'desc' => __('This action can not be undone.', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'confirmed',
|
||||
),
|
||||
),
|
||||
'submit_button' => array(
|
||||
],
|
||||
],
|
||||
'submit_button' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Delete', 'wp-ultimo'),
|
||||
'placeholder' => __('Delete', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-bind:disabled' => '!confirmed',
|
||||
),
|
||||
),
|
||||
'id' => array(
|
||||
],
|
||||
],
|
||||
'id' => [
|
||||
'type' => 'hidden',
|
||||
'value' => $object->get_id(),
|
||||
),
|
||||
'meta_key' => array(
|
||||
],
|
||||
'meta_key' => [
|
||||
'type' => 'hidden',
|
||||
'value' => $meta_key,
|
||||
),
|
||||
'redirect_to' => array(
|
||||
],
|
||||
'redirect_to' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('redirect_to'),
|
||||
),
|
||||
'model' => array(
|
||||
],
|
||||
'model' => [
|
||||
'type' => 'hidden',
|
||||
'value' => $model,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
$object
|
||||
);
|
||||
|
||||
$form_attributes = apply_filters(
|
||||
"wu_form_attributes_delete_{$model}_modal",
|
||||
array(
|
||||
[
|
||||
'title' => 'Delete',
|
||||
'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' => array(
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'true',
|
||||
'data-state' => json_encode(
|
||||
array(
|
||||
[
|
||||
'confirmed' => false,
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form('total-actions', $fields, $form_attributes);
|
||||
@ -430,7 +430,7 @@ class Form_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_model_delete_form() {
|
||||
public function handle_model_delete_form(): void {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
@ -451,9 +451,9 @@ class Form_Manager extends Base_Manager {
|
||||
if ($meta_key) {
|
||||
$status = delete_metadata('wu_membership', wu_request('id'), 'pending_site');
|
||||
|
||||
$data_json_success = array(
|
||||
$data_json_success = [
|
||||
'redirect_url' => add_query_arg('deleted', 1, $redirect_to),
|
||||
);
|
||||
];
|
||||
|
||||
wp_send_json_success($data_json_success);
|
||||
|
||||
@ -488,9 +488,9 @@ class Form_Manager extends Base_Manager {
|
||||
|
||||
$data_json_success = apply_filters(
|
||||
"wu_data_json_success_delete_{$model}_modal",
|
||||
array(
|
||||
'redirect_url' => wu_network_admin_url("wp-ultimo-{$plural_name}", array('deleted' => 1)),
|
||||
)
|
||||
[
|
||||
'redirect_url' => wu_network_admin_url("wp-ultimo-{$plural_name}", ['deleted' => 1]),
|
||||
]
|
||||
);
|
||||
|
||||
wp_send_json_success($data_json_success);
|
||||
@ -505,7 +505,7 @@ class Form_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_bulk_action_form() {
|
||||
public function render_bulk_action_form(): void {
|
||||
|
||||
$action = wu_request('bulk_action');
|
||||
|
||||
@ -513,56 +513,56 @@ class Form_Manager extends Base_Manager {
|
||||
|
||||
$fields = apply_filters(
|
||||
"wu_bulk_actions_{$model}_{$action}",
|
||||
array(
|
||||
'confirm' => array(
|
||||
[
|
||||
'confirm' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Confirm Action', 'wp-ultimo'),
|
||||
'desc' => __('Review this action carefully.', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'confirmed',
|
||||
),
|
||||
),
|
||||
'submit_button' => array(
|
||||
],
|
||||
],
|
||||
'submit_button' => [
|
||||
'type' => 'submit',
|
||||
'title' => wu_slug_to_name($action),
|
||||
'placeholder' => wu_slug_to_name($action),
|
||||
'value' => 'save',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-bind:disabled' => '!confirmed',
|
||||
),
|
||||
),
|
||||
'model' => array(
|
||||
],
|
||||
],
|
||||
'model' => [
|
||||
'type' => 'hidden',
|
||||
'value' => $model,
|
||||
),
|
||||
'bulk_action' => array(
|
||||
],
|
||||
'bulk_action' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('bulk_action'),
|
||||
),
|
||||
'ids' => array(
|
||||
],
|
||||
'ids' => [
|
||||
'type' => 'hidden',
|
||||
'value' => implode(',', wu_request('bulk-delete', '')),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form_attributes = apply_filters(
|
||||
"wu_bulk_actions_{$action}_form",
|
||||
array(
|
||||
[
|
||||
'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' => array(
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'true',
|
||||
'data-state' => json_encode(
|
||||
array(
|
||||
[
|
||||
'confirmed' => false,
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form('total-actions', $fields, $form_attributes);
|
||||
@ -576,7 +576,7 @@ class Form_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_bulk_action_form() {
|
||||
public function handle_bulk_action_form(): void {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
@ -601,7 +601,7 @@ class Form_Manager extends Base_Manager {
|
||||
* @param array $ids The ids list.
|
||||
* @return void
|
||||
*/
|
||||
public function default_bulk_action_handler($action, $model, $ids) {
|
||||
public function default_bulk_action_handler($action, $model, $ids): void {
|
||||
|
||||
$status = \WP_Ultimo\List_Tables\Base_List_Table::process_bulk_action();
|
||||
|
||||
@ -610,9 +610,9 @@ class Form_Manager extends Base_Manager {
|
||||
}
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => add_query_arg($action, count($ids), wu_get_current_url()),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class Gateway_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $registered_gateways = array();
|
||||
protected $registered_gateways = [];
|
||||
|
||||
/**
|
||||
* Lists the gateways that are enabled.
|
||||
@ -47,7 +47,7 @@ class Gateway_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $enabled_gateways = array();
|
||||
protected $enabled_gateways = [];
|
||||
|
||||
/**
|
||||
* Keeps a list of the gateways with auto-renew.
|
||||
@ -55,7 +55,7 @@ class Gateway_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $auto_renewable_gateways = array();
|
||||
protected $auto_renewable_gateways = [];
|
||||
|
||||
/**
|
||||
* Instantiate the necessary hooks.
|
||||
@ -63,9 +63,9 @@ class Gateway_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
add_action('plugins_loaded', array($this, 'on_load'));
|
||||
add_action('plugins_loaded', [$this, 'on_load']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -74,11 +74,11 @@ class Gateway_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function on_load() {
|
||||
public function on_load(): void {
|
||||
/*
|
||||
* Adds our own default gateways.
|
||||
*/
|
||||
add_action('wu_register_gateways', array($this, 'add_default_gateways'), 5);
|
||||
add_action('wu_register_gateways', [$this, 'add_default_gateways'], 5);
|
||||
/*
|
||||
* Allow developers to add new gateways.
|
||||
*/
|
||||
@ -93,24 +93,24 @@ class Gateway_Manager extends Base_Manager {
|
||||
/*
|
||||
* Adds the Gateway selection fields
|
||||
*/
|
||||
add_action('init', array($this, 'add_gateway_selector_field'));
|
||||
add_action('init', [$this, 'add_gateway_selector_field']);
|
||||
|
||||
/*
|
||||
* Handle gateway confirmations.
|
||||
* We need it both on the front-end and the back-end.
|
||||
*/
|
||||
add_action('template_redirect', array($this, 'process_gateway_confirmations'), -99999);
|
||||
add_action('load-admin_page_wu-checkout', array($this, 'process_gateway_confirmations'), -99999);
|
||||
add_action('template_redirect', [$this, 'process_gateway_confirmations'], -99999);
|
||||
add_action('load-admin_page_wu-checkout', [$this, 'process_gateway_confirmations'], -99999);
|
||||
|
||||
/*
|
||||
* Waits for webhook signals and deal with them.
|
||||
*/
|
||||
add_action('init', array($this, 'maybe_process_webhooks'), 1);
|
||||
add_action('init', [$this, 'maybe_process_webhooks'], 1);
|
||||
|
||||
/*
|
||||
* Waits for webhook signals and deal with them.
|
||||
*/
|
||||
add_action('admin_init', array($this, 'maybe_process_v1_webhooks'), 1);
|
||||
add_action('admin_init', [$this, 'maybe_process_v1_webhooks'], 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -119,7 +119,7 @@ class Gateway_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function maybe_process_webhooks() {
|
||||
public function maybe_process_webhooks(): void {
|
||||
|
||||
$gateway = wu_request('wu-gateway');
|
||||
|
||||
@ -185,15 +185,15 @@ class Gateway_Manager extends Base_Manager {
|
||||
* @since 2.0.4
|
||||
* @return void
|
||||
*/
|
||||
public function maybe_process_v1_webhooks() {
|
||||
public function maybe_process_v1_webhooks(): void {
|
||||
|
||||
$action = wu_request('action', '');
|
||||
|
||||
if ($action && strpos((string) $action, 'notify_gateway_') !== false) {
|
||||
if ($action && str_contains((string) $action, 'notify_gateway_')) {
|
||||
/*
|
||||
* Get the gateway id from the action.
|
||||
*/
|
||||
$gateway_id = str_replace(array('nopriv_', 'notify_gateway_'), '', (string) $action);
|
||||
$gateway_id = str_replace(['nopriv_', 'notify_gateway_'], '', (string) $action);
|
||||
|
||||
$gateway = wu_get_gateway($gateway_id);
|
||||
|
||||
@ -260,7 +260,7 @@ class Gateway_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function process_gateway_confirmations() {
|
||||
public function process_gateway_confirmations(): void {
|
||||
/*
|
||||
* First we check for the confirmation parameter.
|
||||
*/
|
||||
@ -270,7 +270,7 @@ class Gateway_Manager extends Base_Manager {
|
||||
|
||||
ob_start();
|
||||
|
||||
add_filter('body_class', fn($classes) => array_merge($classes, array('wu-process-confirmation')));
|
||||
add_filter('body_class', fn($classes) => array_merge($classes, ['wu-process-confirmation']));
|
||||
|
||||
$gateway_id = sanitize_text_field(wu_request('wu-confirm'));
|
||||
|
||||
@ -282,10 +282,10 @@ class Gateway_Manager extends Base_Manager {
|
||||
wp_die(
|
||||
$error,
|
||||
__('Error', 'wp-ultimo'),
|
||||
array(
|
||||
[
|
||||
'back_link' => true,
|
||||
'response' => '200',
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -311,10 +311,10 @@ class Gateway_Manager extends Base_Manager {
|
||||
wp_die(
|
||||
$results,
|
||||
__('Error', 'wp-ultimo'),
|
||||
array(
|
||||
[
|
||||
'back_link' => true,
|
||||
'response' => '200',
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
@ -323,10 +323,10 @@ class Gateway_Manager extends Base_Manager {
|
||||
wp_die(
|
||||
$error,
|
||||
__('Error', 'wp-ultimo'),
|
||||
array(
|
||||
[
|
||||
'back_link' => true,
|
||||
'response' => '200',
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -347,19 +347,19 @@ class Gateway_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function add_gateway_selector_field() {
|
||||
public function add_gateway_selector_field(): void {
|
||||
|
||||
wu_register_settings_field(
|
||||
'payment-gateways',
|
||||
'active_gateways',
|
||||
array(
|
||||
[
|
||||
'title' => __('Active Payment Gateways', 'wp-ultimo'),
|
||||
'desc' => __('Payment gateways are what your customers will use to pay.', 'wp-ultimo'),
|
||||
'type' => 'multiselect',
|
||||
'columns' => 2,
|
||||
'options' => array($this, 'get_gateways_as_options'),
|
||||
'default' => array(),
|
||||
)
|
||||
'options' => [$this, 'get_gateways_as_options'],
|
||||
'default' => [],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -373,7 +373,7 @@ class Gateway_Manager extends Base_Manager {
|
||||
/*
|
||||
* We use this to order the options.
|
||||
*/
|
||||
$active_gateways = wu_get_setting('active_gateways', array());
|
||||
$active_gateways = wu_get_setting('active_gateways', []);
|
||||
|
||||
$gateways = $this->get_registered_gateways();
|
||||
|
||||
@ -388,7 +388,7 @@ class Gateway_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function add_default_gateways() {
|
||||
public function add_default_gateways(): void {
|
||||
/*
|
||||
* Free Payments
|
||||
*/
|
||||
@ -473,10 +473,10 @@ class Gateway_Manager extends Base_Manager {
|
||||
return;
|
||||
}
|
||||
|
||||
$active_gateways = (array) wu_get_setting('active_gateways', array());
|
||||
$active_gateways = (array) wu_get_setting('active_gateways', []);
|
||||
|
||||
// Adds to the global
|
||||
$this->registered_gateways[ $id ] = array(
|
||||
$this->registered_gateways[ $id ] = [
|
||||
'id' => $id,
|
||||
'title' => $title,
|
||||
'desc' => $desc,
|
||||
@ -485,7 +485,7 @@ class Gateway_Manager extends Base_Manager {
|
||||
'active' => in_array($id, $active_gateways, true),
|
||||
'hidden' => (bool) $hidden,
|
||||
'gateway' => $class_name, // Deprecated.
|
||||
);
|
||||
];
|
||||
|
||||
$this->install_hooks($class_name);
|
||||
|
||||
@ -501,7 +501,7 @@ class Gateway_Manager extends Base_Manager {
|
||||
* @param string $class_name Gateway class name.
|
||||
* @return void
|
||||
*/
|
||||
public function install_hooks($class_name) {
|
||||
public function install_hooks($class_name): void {
|
||||
|
||||
$gateway = new $class_name();
|
||||
|
||||
@ -515,18 +515,18 @@ class Gateway_Manager extends Base_Manager {
|
||||
$this->auto_renewable_gateways[] = $gateway_id;
|
||||
}
|
||||
|
||||
add_action('wu_checkout_scripts', array($gateway, 'register_scripts'));
|
||||
add_action('wu_checkout_scripts', [$gateway, 'register_scripts']);
|
||||
|
||||
$gateway->hooks();
|
||||
add_action('wu_settings_payment_gateways', array($gateway, 'settings'));
|
||||
add_action('wu_settings_payment_gateways', [$gateway, 'settings']);
|
||||
|
||||
add_action("wu_{$gateway_id}_process_webhooks", array($gateway, 'process_webhooks'));
|
||||
add_action("wu_{$gateway_id}_process_webhooks", [$gateway, 'process_webhooks']);
|
||||
|
||||
add_action("wu_{$gateway_id}_remote_payment_url", array($gateway, 'get_payment_url_on_gateway'));
|
||||
add_action("wu_{$gateway_id}_remote_payment_url", [$gateway, 'get_payment_url_on_gateway']);
|
||||
|
||||
add_action("wu_{$gateway_id}_remote_subscription_url", array($gateway, 'get_subscription_url_on_gateway'));
|
||||
add_action("wu_{$gateway_id}_remote_subscription_url", [$gateway, 'get_subscription_url_on_gateway']);
|
||||
|
||||
add_action("wu_{$gateway_id}_remote_customer_url", array($gateway, 'get_customer_url_on_gateway'));
|
||||
add_action("wu_{$gateway_id}_remote_customer_url", [$gateway, 'get_customer_url_on_gateway']);
|
||||
|
||||
/*
|
||||
* Renders the gateway fields.
|
||||
@ -535,7 +535,7 @@ class Gateway_Manager extends Base_Manager {
|
||||
'wu_checkout_gateway_fields',
|
||||
function ($checkout) use ($gateway) {
|
||||
|
||||
$field_content = call_user_func(array($gateway, 'fields'));
|
||||
$field_content = call_user_func([$gateway, 'fields']);
|
||||
|
||||
ob_start();
|
||||
|
||||
|
@ -33,23 +33,23 @@ class Limitation_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
if (WP_Ultimo()->is_loaded() === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
add_filter('wu_product_options_sections', array($this, 'add_limitation_sections'), 10, 2);
|
||||
add_filter('wu_product_options_sections', [$this, 'add_limitation_sections'], 10, 2);
|
||||
|
||||
add_filter('wu_membership_options_sections', array($this, 'add_limitation_sections'), 10, 2);
|
||||
add_filter('wu_membership_options_sections', [$this, 'add_limitation_sections'], 10, 2);
|
||||
|
||||
add_filter('wu_site_options_sections', array($this, 'add_limitation_sections'), 10, 2);
|
||||
add_filter('wu_site_options_sections', [$this, 'add_limitation_sections'], 10, 2);
|
||||
|
||||
add_action('plugins_loaded', array($this, 'register_forms'));
|
||||
add_action('plugins_loaded', [$this, 'register_forms']);
|
||||
|
||||
add_action('wu_async_handle_plugins', array($this, 'async_handle_plugins'), 10, 5);
|
||||
add_action('wu_async_handle_plugins', [$this, 'async_handle_plugins'], 10, 5);
|
||||
|
||||
add_action('wu_async_switch_theme', array($this, 'async_switch_theme'), 10, 2);
|
||||
add_action('wu_async_switch_theme', [$this, 'async_switch_theme'], 10, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,14 +116,14 @@ class Limitation_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_forms() {
|
||||
public function register_forms(): void {
|
||||
|
||||
wu_register_form(
|
||||
'confirm_limitations_reset',
|
||||
array(
|
||||
'render' => array($this, 'render_confirm_limitations_reset'),
|
||||
'handler' => array($this, 'handle_confirm_limitations_reset'),
|
||||
)
|
||||
[
|
||||
'render' => [$this, 'render_confirm_limitations_reset'],
|
||||
'handler' => [$this, 'handle_confirm_limitations_reset'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -133,51 +133,51 @@ class Limitation_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_confirm_limitations_reset() {
|
||||
public function render_confirm_limitations_reset(): void {
|
||||
|
||||
$fields = array(
|
||||
'confirm' => array(
|
||||
$fields = [
|
||||
'confirm' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Confirm Reset', 'wp-ultimo'),
|
||||
'desc' => __('This action can not be undone.', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'confirmed',
|
||||
),
|
||||
),
|
||||
'submit_button' => array(
|
||||
],
|
||||
],
|
||||
'submit_button' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Reset Limitations', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-bind:disabled' => '!confirmed',
|
||||
),
|
||||
),
|
||||
'id' => array(
|
||||
],
|
||||
],
|
||||
'id' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('id'),
|
||||
),
|
||||
'model' => array(
|
||||
],
|
||||
'model' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('model'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$form_attributes = array(
|
||||
$form_attributes = [
|
||||
'title' => __('Reset', 'wp-ultimo'),
|
||||
'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' => array(
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'reset_limitations',
|
||||
'data-state' => json_encode(
|
||||
array(
|
||||
[
|
||||
'confirmed' => false,
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form('reset_limitations', $fields, $form_attributes);
|
||||
|
||||
@ -190,7 +190,7 @@ class Limitation_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_confirm_limitations_reset() {
|
||||
public function handle_confirm_limitations_reset(): void {
|
||||
|
||||
$id = wu_request('id');
|
||||
|
||||
@ -211,15 +211,15 @@ class Limitation_Manager {
|
||||
Limitations::remove_limitations($model, $id);
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => wu_network_admin_url(
|
||||
"wp-ultimo-edit-{$model}",
|
||||
array(
|
||||
[
|
||||
'id' => $id,
|
||||
'updated' => 1,
|
||||
)
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -260,80 +260,80 @@ class Limitation_Manager {
|
||||
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'));
|
||||
|
||||
$sections['sites'] = array(
|
||||
$sections['sites'] = [
|
||||
'title' => __('Limits', 'wp-ultimo'),
|
||||
'desc' => __('Only customer-owned sites have limitations.', 'wp-ultimo'),
|
||||
'icon' => 'dashicons-wu-browser',
|
||||
'fields' => array(
|
||||
'note' => array(
|
||||
'fields' => [
|
||||
'note' => [
|
||||
'type' => 'html',
|
||||
'content' => $html,
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return $sections;
|
||||
}
|
||||
|
||||
if ($this->get_object_type($object) !== 'site') {
|
||||
$sections['sites'] = array(
|
||||
$sections['sites'] = [
|
||||
'title' => __('Sites', 'wp-ultimo'),
|
||||
'desc' => __('Control limitations imposed to the number of sites allowed for memberships attached to this product.', 'wp-ultimo'),
|
||||
'icon' => 'dashicons-wu-browser',
|
||||
'fields' => $this->get_sites_fields($object),
|
||||
'v-show' => "get_state_value('product_type', 'none') !== 'service'",
|
||||
'state' => array(
|
||||
'state' => [
|
||||
'limit_sites' => $object->get_limitations()->sites->is_enabled(),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/*
|
||||
* Add Visits limitation control
|
||||
*/
|
||||
if ((bool) wu_get_setting('enable_visits_limiting', true)) {
|
||||
$sections['visits'] = array(
|
||||
$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'),
|
||||
'icon' => 'dashicons-wu-man',
|
||||
'v-show' => "get_state_value('product_type', 'none') !== 'service'",
|
||||
'state' => array(
|
||||
'state' => [
|
||||
'limit_visits' => $object->get_limitations()->visits->is_enabled(),
|
||||
),
|
||||
'fields' => array(
|
||||
'modules[visits][enabled]' => array(
|
||||
],
|
||||
'fields' => [
|
||||
'modules[visits][enabled]' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Limit Unique Visits', 'wp-ultimo'),
|
||||
'desc' => __('Toggle this option to enable unique visits limitation.', 'wp-ultimo'),
|
||||
'value' => 10,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'limit_visits',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
if ($object->model !== 'product') {
|
||||
$sections['visits']['fields']['modules_visits_overwrite'] = $this->override_notice($object->get_limitations(false)->visits->has_own_enabled());
|
||||
}
|
||||
|
||||
$sections['visits']['fields']['modules[visits][limit]'] = array(
|
||||
$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(),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'limit_visits',
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
':min' => 'limit_visits ? 1 : -999',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
if ($object->model !== 'product') {
|
||||
$sections['visits']['fields']['allowed_visits_overwrite'] = $this->override_notice($object->get_limitations(false)->visits->has_own_limit(), array('limit_visits'));
|
||||
$sections['visits']['fields']['allowed_visits_overwrite'] = $this->override_notice($object->get_limitations(false)->visits->has_own_limit(), ['limit_visits']);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -341,38 +341,38 @@ class Limitation_Manager {
|
||||
* for visits and the reset date
|
||||
*/
|
||||
if ($this->get_object_type($object) === 'site') {
|
||||
$sections['visits']['fields']['visits_count'] = array(
|
||||
$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()),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'limit_visits',
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$sections['users'] = array(
|
||||
$sections['users'] = [
|
||||
'title' => __('Users', 'wp-ultimo'),
|
||||
'desc' => __('Control limitations imposed to the number of user allowed for memberships attached to this product.', 'wp-ultimo'),
|
||||
'icon' => 'dashicons-wu-users',
|
||||
'v-show' => "get_state_value('product_type', 'none') !== 'service'",
|
||||
'state' => array(
|
||||
'state' => [
|
||||
'limit_users' => $object->get_limitations()->users->is_enabled(),
|
||||
),
|
||||
'fields' => array(
|
||||
'modules[users][enabled]' => array(
|
||||
],
|
||||
'fields' => [
|
||||
'modules[users][enabled]' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Limit User', 'wp-ultimo'),
|
||||
'desc' => __('Enable user limitations for this product.', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'limit_users',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
if ($object->model !== 'product') {
|
||||
$sections['users']['fields']['modules_user_overwrite'] = $this->override_notice($object->get_limitations(false)->users->has_own_enabled());
|
||||
@ -380,165 +380,165 @@ class Limitation_Manager {
|
||||
|
||||
$this->register_user_fields($sections, $object);
|
||||
|
||||
$sections['post_types'] = array(
|
||||
$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'),
|
||||
'icon' => 'dashicons-wu-book',
|
||||
'v-show' => "get_state_value('product_type', 'none') !== 'service'",
|
||||
'state' => array(
|
||||
'state' => [
|
||||
'limit_post_types' => $object->get_limitations()->post_types->is_enabled(),
|
||||
),
|
||||
'fields' => array(
|
||||
'modules[post_types][enabled]' => array(
|
||||
],
|
||||
'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'),
|
||||
'value' => false,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'limit_post_types',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
if ($object->model !== 'product') {
|
||||
$sections['post_types']['fields']['post_quota_overwrite'] = $this->override_notice($object->get_limitations(false)->post_types->has_own_enabled());
|
||||
}
|
||||
|
||||
$sections['post_types']['post_quota_note'] = array(
|
||||
$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'),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'limit_post_types',
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$this->register_post_type_fields($sections, $object);
|
||||
|
||||
$sections['limit_disk_space'] = array(
|
||||
$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'),
|
||||
'icon' => 'dashicons-wu-drive',
|
||||
'v-show' => "get_state_value('product_type', 'none') !== 'service'",
|
||||
'state' => array(
|
||||
'state' => [
|
||||
'limit_disk_space' => $object->get_limitations()->disk_space->is_enabled(),
|
||||
),
|
||||
'fields' => array(
|
||||
'modules[disk_space][enabled]' => array(
|
||||
],
|
||||
'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'),
|
||||
'value' => true,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'limit_disk_space',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
if ($object->model !== 'product') {
|
||||
$sections['limit_disk_space']['fields']['disk_space_modules_overwrite'] = $this->override_notice($object->get_limitations(false)->disk_space->has_own_enabled());
|
||||
}
|
||||
|
||||
$sections['limit_disk_space']['fields']['modules[disk_space][limit]'] = array(
|
||||
$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'),
|
||||
'min' => 0,
|
||||
'placeholder' => 100,
|
||||
'value' => $object->get_limitations()->disk_space->get_limit(),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => "get_state_value('product_type', 'none') !== 'service' && limit_disk_space",
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
if ($object->model !== 'product') {
|
||||
$sections['limit_disk_space']['fields']['disk_space_override'] = $this->override_notice($object->get_limitations(false)->disk_space->has_own_limit(), array('limit_disk_space'));
|
||||
$sections['limit_disk_space']['fields']['disk_space_override'] = $this->override_notice($object->get_limitations(false)->disk_space->has_own_limit(), ['limit_disk_space']);
|
||||
}
|
||||
|
||||
$sections['custom_domain'] = array(
|
||||
$sections['custom_domain'] = [
|
||||
'title' => __('Custom Domains', 'wp-ultimo'),
|
||||
'desc' => __('Limit the number of users on each role, posts, pages, and more.', 'wp-ultimo'),
|
||||
'icon' => 'dashicons-wu-link1',
|
||||
'v-show' => "get_state_value('product_type', 'none') !== 'service'",
|
||||
'state' => array(
|
||||
'state' => [
|
||||
'allow_domain_mapping' => $object->get_limitations()->domain_mapping->is_enabled(),
|
||||
),
|
||||
'fields' => array(
|
||||
'modules[domain_mapping][enabled]' => array(
|
||||
],
|
||||
'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(),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'allow_domain_mapping',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
if ($object->model !== 'product') {
|
||||
$sections['custom_domain']['fields']['custom_domain_override'] = $this->override_notice($object->get_limitations(false)->domain_mapping->has_own_enabled(), array('allow_domain_mapping'));
|
||||
$sections['custom_domain']['fields']['custom_domain_override'] = $this->override_notice($object->get_limitations(false)->domain_mapping->has_own_enabled(), ['allow_domain_mapping']);
|
||||
}
|
||||
|
||||
$sections['allowed_themes'] = array(
|
||||
$sections['allowed_themes'] = [
|
||||
'title' => __('Themes', 'wp-ultimo'),
|
||||
'desc' => __('Limit the number of users on each role, posts, pages, and more.', 'wp-ultimo'),
|
||||
'icon' => 'dashicons-wu-palette',
|
||||
'v-show' => "get_state_value('product_type', 'none') !== 'service'",
|
||||
'state' => array(
|
||||
'state' => [
|
||||
'force_active_theme' => '',
|
||||
),
|
||||
'fields' => array(
|
||||
'themes' => array(
|
||||
],
|
||||
'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']),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$sections['allowed_plugins'] = array(
|
||||
$sections['allowed_plugins'] = [
|
||||
'title' => __('Plugins', 'wp-ultimo'),
|
||||
'desc' => __('You can choose the behavior of each plugin installed on the platform.', 'wp-ultimo'),
|
||||
'icon' => 'dashicons-wu-power-plug',
|
||||
'v-show' => "get_state_value('product_type', 'none') !== 'service'",
|
||||
'fields' => array(
|
||||
'plugins' => array(
|
||||
'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),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$reset_url = wu_get_form_url(
|
||||
'confirm_limitations_reset',
|
||||
array(
|
||||
[
|
||||
'id' => $object->get_id(),
|
||||
'model' => $object->model,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$sections['reset_limitations'] = array(
|
||||
$sections['reset_limitations'] = [
|
||||
'title' => __('Reset Limitations', 'wp-ultimo'),
|
||||
'desc' => __('Reset the limitations applied to this element.', 'wp-ultimo'),
|
||||
'icon' => 'dashicons-wu-back-in-time',
|
||||
'fields' => array(
|
||||
'reset_permissions' => array(
|
||||
'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')),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return $sections;
|
||||
}
|
||||
@ -552,20 +552,20 @@ class Limitation_Manager {
|
||||
* @param array $additional_checks Array containing javascript conditions that need to be met.
|
||||
* @return array
|
||||
*/
|
||||
protected function override_notice($show = false, $additional_checks = array()) {
|
||||
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'));
|
||||
|
||||
return array(
|
||||
return [
|
||||
'desc' => $text,
|
||||
'type' => 'note',
|
||||
'wrapper_classes' => 'wu-pt-0',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => ($additional_checks ? (implode(' && ', $additional_checks) . ' && ') : '') . var_export((bool) $show, true),
|
||||
'v-cloak' => '1',
|
||||
'style' => 'border-top-width: 0 !important',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -577,51 +577,51 @@ class Limitation_Manager {
|
||||
* @param \WP_Ultimo\Models\Trait\Trait_Limitable $object The object being edit.
|
||||
* @return void
|
||||
*/
|
||||
public function register_user_fields(&$sections, $object) {
|
||||
public function register_user_fields(&$sections, $object): void {
|
||||
|
||||
$user_roles = get_editable_roles();
|
||||
|
||||
$sections['users']['state']['roles'] = array();
|
||||
$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']['fields'][ "control_{$user_role_slug}" ] = array(
|
||||
$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') . "' }}"),
|
||||
'tooltip' => '',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-bind:class' => "!roles['{$user_role_slug}'].enabled ? 'wu-opacity-75' : ''",
|
||||
'v-show' => 'limit_users',
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
'fields' => array(
|
||||
"modules[users][limit][{$user_role_slug}][number]" => array(
|
||||
],
|
||||
'fields' => [
|
||||
"modules[users][limit][{$user_role_slug}][number]" => [
|
||||
'type' => 'number',
|
||||
'placeholder' => sprintf(__('%s Role Quota. e.g. 10', 'wp-ultimo'), $user_role['name']),
|
||||
'min' => 0,
|
||||
'wrapper_classes' => 'wu-w-full',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => "roles['{$user_role_slug}'].number",
|
||||
'v-bind:readonly' => "!roles['{$user_role_slug}'].enabled",
|
||||
),
|
||||
),
|
||||
"modules[users][limit][{$user_role_slug}][enabled]" => array(
|
||||
],
|
||||
],
|
||||
"modules[users][limit][{$user_role_slug}][enabled]" => [
|
||||
'type' => 'toggle',
|
||||
'wrapper_classes' => 'wu-mt-1',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => "roles['{$user_role_slug}'].enabled",
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
/*
|
||||
* Add override notice.
|
||||
*/
|
||||
if ($object->model !== 'product') {
|
||||
$sections['users']['fields'][ "override_{$user_role_slug}" ] = $this->override_notice($object->get_limitations(false)->users->exists($user_role_slug), array('limit_users'));
|
||||
$sections['users']['fields'][ "override_{$user_role_slug}" ] = $this->override_notice($object->get_limitations(false)->users->exists($user_role_slug), ['limit_users']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -635,45 +635,45 @@ class Limitation_Manager {
|
||||
* @param \WP_Ultimo\Models\Trait\Trait_Limitable $object The object being edit.
|
||||
* @return void
|
||||
*/
|
||||
public function register_post_type_fields(&$sections, $object) {
|
||||
public function register_post_type_fields(&$sections, $object): void {
|
||||
|
||||
$post_types = get_post_types(array(), 'objects');
|
||||
$post_types = get_post_types([], 'objects');
|
||||
|
||||
$sections['post_types']['state']['types'] = array();
|
||||
$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']['fields'][ "control_{$post_type_slug}" ] = array(
|
||||
$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') . "' }}"),
|
||||
'tooltip' => '',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-bind:class' => "!types['{$post_type_slug}'].enabled ? 'wu-opacity-75' : ''",
|
||||
'v-show' => 'limit_post_types',
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
'fields' => array(
|
||||
"modules[post_types][limit][{$post_type_slug}][number]" => array(
|
||||
],
|
||||
'fields' => [
|
||||
"modules[post_types][limit][{$post_type_slug}][number]" => [
|
||||
'type' => 'number',
|
||||
'placeholder' => sprintf(__('%s Quota. e.g. 200', 'wp-ultimo'), $post_type->label),
|
||||
'min' => 0,
|
||||
'wrapper_classes' => 'wu-w-full',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => "types['{$post_type_slug}'].number",
|
||||
'v-bind:readonly' => "!types['{$post_type_slug}'].enabled",
|
||||
),
|
||||
),
|
||||
"modules[post_types][limit][{$post_type_slug}][enabled]" => array(
|
||||
],
|
||||
],
|
||||
"modules[post_types][limit][{$post_type_slug}][enabled]" => [
|
||||
'type' => 'toggle',
|
||||
'wrapper_classes' => 'wu-mt-1',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => "types['{$post_type_slug}'].enabled",
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
/*
|
||||
* Add override notice.
|
||||
@ -681,9 +681,9 @@ class Limitation_Manager {
|
||||
if ($object->model !== 'product') {
|
||||
$sections['post_types']['fields'][ "override_{$post_type_slug}" ] = $this->override_notice(
|
||||
$object->get_limitations(false)->post_types->exists($post_type_slug),
|
||||
array(
|
||||
[
|
||||
'limit_post_types',
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -699,17 +699,17 @@ class Limitation_Manager {
|
||||
*/
|
||||
protected function get_sites_fields($object) {
|
||||
|
||||
$fields = array(
|
||||
'modules[sites][enabled]' => array(
|
||||
$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(),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'limit_sites',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
if ($object->model !== 'product') {
|
||||
$fields['sites_overwrite'] = $this->override_notice($object->get_limitations(false)->sites->has_own_enabled());
|
||||
@ -718,31 +718,31 @@ class Limitation_Manager {
|
||||
/*
|
||||
* Sites not supported on this type
|
||||
*/
|
||||
$fields['site_not_allowed_note'] = array(
|
||||
$fields['site_not_allowed_note'] = [
|
||||
'type' => 'note',
|
||||
'desc' => __('The product type selection does not support allowing for the creating of extra sites.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => "get_state_value('product_type', 'none') === 'service' && limit_sites",
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$fields['modules[sites][limit]'] = array(
|
||||
$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'),
|
||||
'placeholder' => 1,
|
||||
'value' => $object->get_limitations()->sites->get_limit(),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => "get_state_value('product_type', 'none') !== 'service' && limit_sites",
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
if ($object->model !== 'product') {
|
||||
$fields['sites_overwrite_2'] = $this->override_notice($object->get_limitations(false)->sites->has_own_limit(), array("get_state_value('product_type', 'none') !== 'service' && limit_sites"));
|
||||
$fields['sites_overwrite_2'] = $this->override_notice($object->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);
|
||||
@ -762,10 +762,10 @@ class Limitation_Manager {
|
||||
|
||||
return wu_get_template_contents(
|
||||
'limitations/plugin-selector',
|
||||
array(
|
||||
[
|
||||
'plugins' => $all_plugins,
|
||||
'object' => $object,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -784,11 +784,11 @@ class Limitation_Manager {
|
||||
|
||||
return wu_get_template_contents(
|
||||
'limitations/theme-selector',
|
||||
array(
|
||||
[
|
||||
'section' => $section,
|
||||
'themes' => $all_themes,
|
||||
'object' => $object,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -804,7 +804,7 @@ class Limitation_Manager {
|
||||
|
||||
$all_plugins = get_plugins();
|
||||
|
||||
$listed_plugins = array();
|
||||
$listed_plugins = [];
|
||||
|
||||
foreach ($all_plugins as $plugin_path => $plugin_info) {
|
||||
if (wu_get_isset($plugin_info, 'Network') === true) {
|
||||
@ -842,10 +842,10 @@ class Limitation_Manager {
|
||||
*/
|
||||
protected function plugin_exclusion_list() {
|
||||
|
||||
$exclusion_list = array(
|
||||
$exclusion_list = [
|
||||
'wp-ultimo/wp-ultimo.php',
|
||||
'user-switching/user-switching.php',
|
||||
);
|
||||
];
|
||||
|
||||
return apply_filters('wu_limitations_plugin_exclusion_list', $exclusion_list);
|
||||
}
|
||||
@ -858,7 +858,7 @@ class Limitation_Manager {
|
||||
*/
|
||||
protected function theme_exclusion_list() {
|
||||
|
||||
$exclusion_list = array();
|
||||
$exclusion_list = [];
|
||||
|
||||
return apply_filters('wu_limitations_theme_exclusion_list', $exclusion_list);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ class Membership_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $model_class = '\\WP_Ultimo\\Models\\Membership';
|
||||
protected $model_class = \WP_Ultimo\Models\Membership::class;
|
||||
|
||||
/**
|
||||
* Instantiate the necessary hooks.
|
||||
@ -51,7 +51,7 @@ class Membership_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
$this->enable_rest_api();
|
||||
|
||||
@ -60,34 +60,34 @@ class Membership_Manager extends Base_Manager {
|
||||
add_action(
|
||||
'init',
|
||||
function () {
|
||||
Event_Manager::register_model_events('membership', __('Membership', 'wp-ultimo'), array('created', 'updated'));
|
||||
Event_Manager::register_model_events('membership', __('Membership', 'wp-ultimo'), ['created', 'updated']);
|
||||
}
|
||||
);
|
||||
|
||||
add_action('wu_async_transfer_membership', array($this, 'async_transfer_membership'), 10, 2);
|
||||
add_action('wu_async_transfer_membership', [$this, 'async_transfer_membership'], 10, 2);
|
||||
|
||||
add_action('wu_async_delete_membership', array($this, 'async_delete_membership'), 10);
|
||||
add_action('wu_async_delete_membership', [$this, 'async_delete_membership'], 10);
|
||||
|
||||
/*
|
||||
* Transitions
|
||||
*/
|
||||
add_action('wu_transition_membership_status', array($this, 'mark_cancelled_date'), 10, 3);
|
||||
add_action('wu_transition_membership_status', [$this, 'mark_cancelled_date'], 10, 3);
|
||||
|
||||
add_action('wu_transition_membership_status', array($this, 'transition_membership_status'), 10, 3);
|
||||
add_action('wu_transition_membership_status', [$this, 'transition_membership_status'], 10, 3);
|
||||
|
||||
/*
|
||||
* Deal with delayed/schedule swaps
|
||||
*/
|
||||
add_action('wu_async_membership_swap', array($this, 'async_membership_swap'), 10);
|
||||
add_action('wu_async_membership_swap', [$this, 'async_membership_swap'], 10);
|
||||
|
||||
/*
|
||||
* Deal with pending sites creation
|
||||
*/
|
||||
add_action('wp_ajax_wu_publish_pending_site', array($this, 'publish_pending_site'));
|
||||
add_action('wp_ajax_wu_publish_pending_site', [$this, 'publish_pending_site']);
|
||||
|
||||
add_action('wp_ajax_wu_check_pending_site_created', array($this, 'check_pending_site_created'));
|
||||
add_action('wp_ajax_wu_check_pending_site_created', [$this, 'check_pending_site_created']);
|
||||
|
||||
add_action('wu_async_publish_pending_site', array($this, 'async_publish_pending_site'), 10);
|
||||
add_action('wu_async_publish_pending_site', [$this, 'async_publish_pending_site'], 10);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,7 +95,7 @@ class Membership_Manager extends Base_Manager {
|
||||
*
|
||||
* @since 2.0.11
|
||||
*/
|
||||
public function publish_pending_site() {
|
||||
public function publish_pending_site(): void {
|
||||
|
||||
check_ajax_referer('wu_publish_pending_site');
|
||||
|
||||
@ -103,7 +103,7 @@ class Membership_Manager extends Base_Manager {
|
||||
|
||||
// Don't make the request block till we finish, if possible.
|
||||
if ( function_exists('fastcgi_finish_request') && version_compare(phpversion(), '7.0.16', '>=') ) {
|
||||
wp_send_json(array('status' => 'creating-site'));
|
||||
wp_send_json(['status' => 'creating-site']);
|
||||
|
||||
fastcgi_finish_request();
|
||||
}
|
||||
@ -160,12 +160,12 @@ class Membership_Manager extends Base_Manager {
|
||||
/**
|
||||
* We do not have a pending site, so we can assume the site was created.
|
||||
*/
|
||||
wp_send_json(array('publish_status' => 'completed'));
|
||||
wp_send_json(['publish_status' => 'completed']);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
wp_send_json(array('publish_status' => $pending_site->is_publishing() ? 'running' : 'stopped'));
|
||||
wp_send_json(['publish_status' => $pending_site->is_publishing() ? 'running' : 'stopped']);
|
||||
|
||||
exit;
|
||||
}
|
||||
@ -235,21 +235,21 @@ class Membership_Manager extends Base_Manager {
|
||||
* @param integer $membership_id Payment ID.
|
||||
* @return void
|
||||
*/
|
||||
public function transition_membership_status($old_status, $new_status, $membership_id) {
|
||||
public function transition_membership_status($old_status, $new_status, $membership_id): void {
|
||||
|
||||
$allowed_previous_status = array(
|
||||
$allowed_previous_status = [
|
||||
Membership_Status::PENDING,
|
||||
Membership_Status::ON_HOLD,
|
||||
);
|
||||
];
|
||||
|
||||
if ( ! in_array($old_status, $allowed_previous_status, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$allowed_status = array(
|
||||
$allowed_status = [
|
||||
Membership_Status::ACTIVE,
|
||||
Membership_Status::TRIALING,
|
||||
);
|
||||
];
|
||||
|
||||
if ( ! in_array($new_status, $allowed_status, true)) {
|
||||
return;
|
||||
@ -277,7 +277,7 @@ class Membership_Manager extends Base_Manager {
|
||||
* @param int $item_id The membership id.
|
||||
* @return void
|
||||
*/
|
||||
public function mark_cancelled_date($old_value, $new_value, $item_id) {
|
||||
public function mark_cancelled_date($old_value, $new_value, $item_id): void {
|
||||
|
||||
if ($new_value === 'cancelled' && $new_value !== $old_value) {
|
||||
$membership = wu_get_membership($item_id);
|
||||
@ -316,14 +316,14 @@ class Membership_Manager extends Base_Manager {
|
||||
* Get Sites and move them over.
|
||||
*/
|
||||
$sites = wu_get_sites(
|
||||
array(
|
||||
'meta_query' => array(
|
||||
'membership_id' => array(
|
||||
[
|
||||
'meta_query' => [
|
||||
'membership_id' => [
|
||||
'key' => 'wu_membership_id',
|
||||
'value' => $membership->get_id(),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
foreach ($sites as $site) {
|
||||
@ -388,14 +388,14 @@ class Membership_Manager extends Base_Manager {
|
||||
* Get Sites and delete them.
|
||||
*/
|
||||
$sites = wu_get_sites(
|
||||
array(
|
||||
'meta_query' => array(
|
||||
'membership_id' => array(
|
||||
[
|
||||
'meta_query' => [
|
||||
'membership_id' => [
|
||||
'key' => 'wu_membership_id',
|
||||
'value' => $membership->get_id(),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
foreach ($sites as $site) {
|
||||
|
@ -47,17 +47,17 @@ class Notes_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
add_action('plugins_loaded', array($this, 'register_forms'));
|
||||
add_action('plugins_loaded', [$this, 'register_forms']);
|
||||
|
||||
add_filter('wu_membership_options_sections', array($this, 'add_notes_options_section'), 10, 2);
|
||||
add_filter('wu_membership_options_sections', [$this, 'add_notes_options_section'], 10, 2);
|
||||
|
||||
add_filter('wu_payments_options_sections', array($this, 'add_notes_options_section'), 10, 2);
|
||||
add_filter('wu_payments_options_sections', [$this, 'add_notes_options_section'], 10, 2);
|
||||
|
||||
add_filter('wu_customer_options_sections', array($this, 'add_notes_options_section'), 10, 2);
|
||||
add_filter('wu_customer_options_sections', [$this, 'add_notes_options_section'], 10, 2);
|
||||
|
||||
add_filter('wu_site_options_sections', array($this, 'add_notes_options_section'), 10, 2);
|
||||
add_filter('wu_site_options_sections', [$this, 'add_notes_options_section'], 10, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,17 +66,17 @@ class Notes_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_forms() {
|
||||
public function register_forms(): void {
|
||||
/*
|
||||
* Add note
|
||||
*/
|
||||
wu_register_form(
|
||||
'add_note',
|
||||
array(
|
||||
'render' => array($this, 'render_add_note_modal'),
|
||||
'handler' => array($this, 'handle_add_note_modal'),
|
||||
[
|
||||
'render' => [$this, 'render_add_note_modal'],
|
||||
'handler' => [$this, 'handle_add_note_modal'],
|
||||
'capability' => 'edit_notes',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
/*
|
||||
@ -84,11 +84,11 @@ class Notes_Manager extends Base_Manager {
|
||||
*/
|
||||
wu_register_form(
|
||||
'clear_notes',
|
||||
array(
|
||||
'render' => array($this, 'render_clear_notes_modal'),
|
||||
'handler' => array($this, 'handle_clear_notes_modal'),
|
||||
[
|
||||
'render' => [$this, 'render_clear_notes_modal'],
|
||||
'handler' => [$this, 'handle_clear_notes_modal'],
|
||||
'capability' => 'delete_notes',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
/*
|
||||
@ -96,11 +96,11 @@ class Notes_Manager extends Base_Manager {
|
||||
*/
|
||||
wu_register_form(
|
||||
'delete_note',
|
||||
array(
|
||||
'render' => array($this, 'render_delete_note_modal'),
|
||||
'handler' => array($this, 'handle_delete_note_modal'),
|
||||
[
|
||||
'render' => [$this, 'render_delete_note_modal'],
|
||||
'handler' => [$this, 'handle_delete_note_modal'],
|
||||
'capability' => 'delete_notes',
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -120,77 +120,77 @@ class Notes_Manager extends Base_Manager {
|
||||
return $sections;
|
||||
}
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$fields['notes_panel'] = array(
|
||||
$fields['notes_panel'] = [
|
||||
'type' => 'html',
|
||||
'wrapper_classes' => 'wu-m-0 wu-p-2 wu-notes-wrapper',
|
||||
'wrapper_html_attr' => array(
|
||||
'style' => sprintf('min-height: 500px; background: url("%s");', wu_get_asset('pattern-wp-ultimo.png')),
|
||||
),
|
||||
'wrapper_html_attr' => [
|
||||
'style' => sprintf('min-height: 500px; background: url("%s");', wu_get_asset('pattern-wp-ultimo.webp')),
|
||||
],
|
||||
'content' => wu_get_template_contents(
|
||||
'base/edit/display-notes',
|
||||
array(
|
||||
[
|
||||
'notes' => $object->get_notes(),
|
||||
'model' => $object->model,
|
||||
)
|
||||
]
|
||||
),
|
||||
);
|
||||
];
|
||||
|
||||
$fields_buttons = array();
|
||||
$fields_buttons = [];
|
||||
|
||||
if (current_user_can('delete_notes')) {
|
||||
$fields_buttons['button_clear_notes'] = array(
|
||||
$fields_buttons['button_clear_notes'] = [
|
||||
'type' => 'link',
|
||||
'display_value' => __('Clear Notes', 'wp-ultimo'),
|
||||
'wrapper_classes' => 'wu-mb-0',
|
||||
'classes' => 'button wubox',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'href' => wu_get_form_url(
|
||||
'clear_notes',
|
||||
array(
|
||||
[
|
||||
'object_id' => $object->get_id(),
|
||||
'model' => $object->model,
|
||||
)
|
||||
]
|
||||
),
|
||||
'title' => __('Clear Notes', 'wp-ultimo'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
if (current_user_can('edit_notes')) {
|
||||
$fields_buttons['button_add_note'] = array(
|
||||
$fields_buttons['button_add_note'] = [
|
||||
'type' => 'link',
|
||||
'display_value' => __('Add new Note', 'wp-ultimo'),
|
||||
'wrapper_classes' => 'wu-mb-0',
|
||||
'classes' => 'button button-primary wubox wu-absolute wu-right-5',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'href' => wu_get_form_url(
|
||||
'add_note',
|
||||
array(
|
||||
[
|
||||
'object_id' => $object->get_id(),
|
||||
'model' => $object->model,
|
||||
'height' => 306,
|
||||
)
|
||||
]
|
||||
),
|
||||
'title' => __('Add new Note', 'wp-ultimo'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
$fields['buttons'] = array(
|
||||
$fields['buttons'] = [
|
||||
'type' => 'group',
|
||||
'wrapper_classes' => 'wu-bg-white',
|
||||
'fields' => $fields_buttons,
|
||||
);
|
||||
];
|
||||
|
||||
$sections['notes'] = array(
|
||||
$sections['notes'] = [
|
||||
'title' => __('Notes', 'wp-ultimo'),
|
||||
'desc' => __('Add notes to this model.', 'wp-ultimo'),
|
||||
'icon' => 'dashicons-wu-text-document',
|
||||
'order' => 1001,
|
||||
'fields' => $fields,
|
||||
);
|
||||
];
|
||||
|
||||
return $sections;
|
||||
}
|
||||
@ -201,59 +201,59 @@ class Notes_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_add_note_modal() {
|
||||
public function render_add_note_modal(): void {
|
||||
|
||||
$fields = array(
|
||||
'content' => array(
|
||||
$fields = [
|
||||
'content' => [
|
||||
'id' => 'content',
|
||||
'type' => 'wp-editor',
|
||||
'title' => __('Note Content', 'wp-ultimo'),
|
||||
'desc' => __('Basic formatting is supported.', 'wp-ultimo'),
|
||||
'settings' => array(
|
||||
'tinymce' => array(
|
||||
'settings' => [
|
||||
'tinymce' => [
|
||||
'toolbar1' => 'bold,italic,strikethrough,link,unlink,undo,redo,pastetext',
|
||||
),
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'content',
|
||||
),
|
||||
),
|
||||
'submit_add_note' => array(
|
||||
],
|
||||
],
|
||||
'submit_add_note' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Add Note', 'wp-ultimo'),
|
||||
'placeholder' => __('Add Note', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'wu-w-full button button-primary',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
),
|
||||
'object_id' => array(
|
||||
],
|
||||
'object_id' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('object_id'),
|
||||
),
|
||||
'model' => array(
|
||||
],
|
||||
'model' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('model'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$fields = apply_filters('wu_notes_options_section_fields', $fields);
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'add_note',
|
||||
$fields,
|
||||
array(
|
||||
[
|
||||
'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' => array(
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'add_note',
|
||||
'data-state' => wu_convert_to_state(
|
||||
array(
|
||||
[
|
||||
'content' => '',
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -265,18 +265,18 @@ class Notes_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_add_note_modal() {
|
||||
public function handle_add_note_modal(): void {
|
||||
|
||||
$model = wu_request('model');
|
||||
$function_name = "wu_get_{$model}";
|
||||
$object = $function_name(wu_request('object_id'));
|
||||
|
||||
$status = $object->add_note(
|
||||
array(
|
||||
[
|
||||
'text' => wu_remove_empty_p(wu_request('content')),
|
||||
'author_id' => get_current_user_id(),
|
||||
'note_id' => uniqid(),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if (is_wp_error($status)) {
|
||||
@ -284,16 +284,16 @@ class Notes_Manager extends Base_Manager {
|
||||
}
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => wu_network_admin_url(
|
||||
"wp-ultimo-edit-{$model}",
|
||||
array(
|
||||
[
|
||||
'id' => $object->get_id(),
|
||||
'updated' => 1,
|
||||
'options' => 'notes',
|
||||
)
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -303,54 +303,54 @@ class Notes_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_clear_notes_modal() {
|
||||
public function render_clear_notes_modal(): void {
|
||||
|
||||
$fields = array(
|
||||
'confirm_clear_notes' => array(
|
||||
$fields = [
|
||||
'confirm_clear_notes' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Confirm clear all notes?', 'wp-ultimo'),
|
||||
'desc' => __('This action can not be undone.', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'confirmed',
|
||||
),
|
||||
),
|
||||
'submit_clear_notes' => array(
|
||||
],
|
||||
],
|
||||
'submit_clear_notes' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Clear Notes', 'wp-ultimo'),
|
||||
'placeholder' => __('Clear Notes', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'wu-w-full button button-primary',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-bind:disabled' => '!confirmed',
|
||||
),
|
||||
),
|
||||
'object_id' => array(
|
||||
],
|
||||
],
|
||||
'object_id' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('object_id'),
|
||||
),
|
||||
'model' => array(
|
||||
],
|
||||
'model' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('model'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'clear_notes',
|
||||
$fields,
|
||||
array(
|
||||
[
|
||||
'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' => array(
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'clear_notes',
|
||||
'data-state' => wu_convert_to_state(
|
||||
array(
|
||||
[
|
||||
'confirmed' => false,
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -362,7 +362,7 @@ class Notes_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_clear_notes_modal() {
|
||||
public function handle_clear_notes_modal(): void {
|
||||
|
||||
$model = wu_request('model');
|
||||
$function_name = "wu_get_{$model}";
|
||||
@ -379,16 +379,16 @@ class Notes_Manager extends Base_Manager {
|
||||
}
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => wu_network_admin_url(
|
||||
"wp-ultimo-edit-{$model}",
|
||||
array(
|
||||
[
|
||||
'id' => $object->get_id(),
|
||||
'deleted' => 1,
|
||||
'options' => 'notes',
|
||||
)
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -398,58 +398,58 @@ class Notes_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_delete_note_modal() {
|
||||
public function render_delete_note_modal(): void {
|
||||
|
||||
$fields = array(
|
||||
'confirm_delete_note' => array(
|
||||
$fields = [
|
||||
'confirm_delete_note' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Confirm clear the note?', 'wp-ultimo'),
|
||||
'desc' => __('This action can not be undone.', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'confirmed',
|
||||
),
|
||||
),
|
||||
'submit_delete_note' => array(
|
||||
],
|
||||
],
|
||||
'submit_delete_note' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Clear Note', 'wp-ultimo'),
|
||||
'placeholder' => __('Clear Note', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'wu-w-full button button-primary',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-bind:disabled' => '!confirmed',
|
||||
),
|
||||
),
|
||||
'object_id' => array(
|
||||
],
|
||||
],
|
||||
'object_id' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('object_id'),
|
||||
),
|
||||
'model' => array(
|
||||
],
|
||||
'model' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('model'),
|
||||
),
|
||||
'note_id' => array(
|
||||
],
|
||||
'note_id' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('note_id'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'delete_note',
|
||||
$fields,
|
||||
array(
|
||||
[
|
||||
'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' => array(
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'delete_note',
|
||||
'data-state' => wu_convert_to_state(
|
||||
array(
|
||||
[
|
||||
'confirmed' => false,
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -461,7 +461,7 @@ class Notes_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_delete_note_modal() {
|
||||
public function handle_delete_note_modal(): void {
|
||||
|
||||
$model = wu_request('model');
|
||||
$function_name = "wu_get_{$model}";
|
||||
@ -479,16 +479,16 @@ class Notes_Manager extends Base_Manager {
|
||||
}
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => wu_network_admin_url(
|
||||
"wp-ultimo-edit-{$model}",
|
||||
array(
|
||||
[
|
||||
'id' => $object->get_id(),
|
||||
'deleted' => 1,
|
||||
'options' => 'notes',
|
||||
)
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -37,12 +37,12 @@ class Notification_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
add_action('wp_ultimo_load', array($this, 'add_settings'));
|
||||
add_action('wp_ultimo_load', [$this, 'add_settings']);
|
||||
|
||||
if (is_admin() && ! is_network_admin()) {
|
||||
add_action('admin_init', array($this, 'hide_notifications_subsites'));
|
||||
add_action('admin_init', [$this, 'hide_notifications_subsites']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ class Notification_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function hide_notifications_subsites() {
|
||||
public function hide_notifications_subsites(): void {
|
||||
|
||||
if ( ! wu_get_setting('hide_notifications_subsites')) {
|
||||
return;
|
||||
@ -65,19 +65,19 @@ class Notification_Manager {
|
||||
*/
|
||||
$this->backwards_compatibility_list = apply_filters(
|
||||
'wu_hide_notifications_exclude_list',
|
||||
array(
|
||||
[
|
||||
'inject_admin_head_ads',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$cleaner = array($this, 'clear_callback_list');
|
||||
$cleaner = [$this, 'clear_callback_list'];
|
||||
|
||||
if (wu_get_isset($wp_filter, 'admin_notices')) {
|
||||
$wp_filter['admin_notices']->callbacks = array_filter($wp_filter['admin_notices']->callbacks, $cleaner === null ? fn($v, $k): bool => ! empty($v) : $cleaner, $cleaner === null ? ARRAY_FILTER_USE_BOTH : 0);
|
||||
$wp_filter['admin_notices']->callbacks = array_filter($wp_filter['admin_notices']->callbacks, $cleaner ?? fn($v, $k): bool => ! empty($v), $cleaner === null ? ARRAY_FILTER_USE_BOTH : 0);
|
||||
}
|
||||
|
||||
if (wu_get_isset($wp_filter, 'all_admin_notices')) {
|
||||
$wp_filter['all_admin_notices']->callbacks = array_filter($wp_filter['all_admin_notices']->callbacks, $cleaner === null ? fn($v, $k): bool => ! empty($v) : $cleaner, $cleaner === null ? ARRAY_FILTER_USE_BOTH : 0);
|
||||
$wp_filter['all_admin_notices']->callbacks = array_filter($wp_filter['all_admin_notices']->callbacks, $cleaner ?? fn($v, $k): bool => ! empty($v), $cleaner === null ? ARRAY_FILTER_USE_BOTH : 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ class Notification_Manager {
|
||||
|
||||
foreach ($keys as $key) {
|
||||
foreach ($this->backwards_compatibility_list as $key_to_keep) {
|
||||
if (strpos($key, (string) $key_to_keep) !== false) {
|
||||
if (str_contains($key, (string) $key_to_keep)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -115,18 +115,18 @@ class Notification_Manager {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add_settings() {
|
||||
public function add_settings(): void {
|
||||
|
||||
wu_register_settings_field(
|
||||
'sites',
|
||||
'hide_notifications_subsites',
|
||||
array(
|
||||
[
|
||||
'title' => __('Hide Admin Notices on Sites', 'wp-ultimo'),
|
||||
'desc' => __('Hide all admin notices on network sites, except for WP Multisite WaaS broadcasts.', 'wp-ultimo'),
|
||||
'type' => 'toggle',
|
||||
'default' => 0,
|
||||
'order' => 25,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class Payment_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $model_class = '\\WP_Ultimo\\Models\\Payment';
|
||||
protected $model_class = \WP_Ultimo\Models\Payment::class;
|
||||
|
||||
/**
|
||||
* Instantiate the necessary hooks.
|
||||
@ -53,7 +53,7 @@ class Payment_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
$this->enable_rest_api();
|
||||
|
||||
@ -67,25 +67,25 @@ class Payment_Manager extends Base_Manager {
|
||||
Event_Manager::register_model_events(
|
||||
'payment',
|
||||
__('Payment', 'wp-ultimo'),
|
||||
array('created', 'updated')
|
||||
['created', 'updated']
|
||||
);
|
||||
}
|
||||
);
|
||||
add_action('wp_login', array($this, 'check_pending_payments'), 10);
|
||||
add_action('wp_login', [$this, 'check_pending_payments'], 10);
|
||||
|
||||
add_action('wp_enqueue_scripts', array($this, 'show_pending_payments'), 10);
|
||||
add_action('wp_enqueue_scripts', [$this, 'show_pending_payments'], 10);
|
||||
|
||||
add_action('admin_enqueue_scripts', array($this, 'show_pending_payments'), 10);
|
||||
add_action('admin_enqueue_scripts', [$this, 'show_pending_payments'], 10);
|
||||
|
||||
add_action('init', array($this, 'invoice_viewer'));
|
||||
add_action('init', [$this, 'invoice_viewer']);
|
||||
|
||||
add_action('wu_async_transfer_payment', array($this, 'async_transfer_payment'), 10, 2);
|
||||
add_action('wu_async_transfer_payment', [$this, 'async_transfer_payment'], 10, 2);
|
||||
|
||||
add_action('wu_async_delete_payment', array($this, 'async_delete_payment'), 10);
|
||||
add_action('wu_async_delete_payment', [$this, 'async_delete_payment'], 10);
|
||||
|
||||
add_action('wu_gateway_payment_processed', array($this, 'handle_payment_success'), 10, 3);
|
||||
add_action('wu_gateway_payment_processed', [$this, 'handle_payment_success'], 10, 3);
|
||||
|
||||
add_action('wu_transition_payment_status', array($this, 'transition_payment_status'), 10, 3);
|
||||
add_action('wu_transition_payment_status', [$this, 'transition_payment_status'], 10, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -98,7 +98,7 @@ class Payment_Manager extends Base_Manager {
|
||||
* @param \WP_Ultimo\Gateways\Base_Gateway $gateway The gateway.
|
||||
* @return void
|
||||
*/
|
||||
public function handle_payment_success($payment, $membership, $gateway) {
|
||||
public function handle_payment_success($payment, $membership, $gateway): void {
|
||||
|
||||
$payload = array_merge(
|
||||
wu_generate_event_payload('payment', $payment),
|
||||
@ -115,7 +115,7 @@ class Payment_Manager extends Base_Manager {
|
||||
* @param \WP_User|string $user The WordPress user instance or user login.
|
||||
* @return void
|
||||
*/
|
||||
public function check_pending_payments($user) {
|
||||
public function check_pending_payments($user): void {
|
||||
|
||||
if ( ! is_main_site()) {
|
||||
return;
|
||||
@ -151,7 +151,7 @@ class Payment_Manager extends Base_Manager {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function show_pending_payments() {
|
||||
public function show_pending_payments(): void {
|
||||
|
||||
if ( ! is_user_logged_in()) {
|
||||
return;
|
||||
@ -183,15 +183,15 @@ class Payment_Manager extends Base_Manager {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register_forms() {
|
||||
public function register_forms(): void {
|
||||
|
||||
if (function_exists('wu_register_form')) {
|
||||
wu_register_form(
|
||||
'pending_payments',
|
||||
array(
|
||||
'render' => array($this, 'render_pending_payments'),
|
||||
[
|
||||
'render' => [$this, 'render_pending_payments'],
|
||||
'capability' => 'exist',
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -201,7 +201,7 @@ class Payment_Manager extends Base_Manager {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function render_pending_payments() {
|
||||
public function render_pending_payments(): void {
|
||||
|
||||
if ( ! is_user_logged_in()) {
|
||||
return;
|
||||
@ -215,7 +215,7 @@ class Payment_Manager extends Base_Manager {
|
||||
return;
|
||||
}
|
||||
|
||||
$pending_payments = array();
|
||||
$pending_payments = [];
|
||||
|
||||
foreach ($customer->get_memberships() as $membership) {
|
||||
$pending_payment = $membership->get_last_pending_payment();
|
||||
@ -238,14 +238,14 @@ class Payment_Manager extends Base_Manager {
|
||||
*/
|
||||
$message = apply_filters('wu_pending_payment_message', $message, $customer, $pending_payments);
|
||||
|
||||
$fields = array(
|
||||
'alert_text' => array(
|
||||
$fields = [
|
||||
'alert_text' => [
|
||||
'type' => 'note',
|
||||
'desc' => $message,
|
||||
'classes' => '',
|
||||
'wrapper_classes' => '',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($pending_payments as $payment) {
|
||||
$slug = $payment->get_hash();
|
||||
@ -256,21 +256,21 @@ class Payment_Manager extends Base_Manager {
|
||||
|
||||
$title = $slug;
|
||||
|
||||
$fields[] = array(
|
||||
$fields[] = [
|
||||
'type' => 'note',
|
||||
'title' => $title,
|
||||
'desc' => $html,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'pending-payments',
|
||||
$fields,
|
||||
array(
|
||||
[
|
||||
'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',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -283,7 +283,7 @@ class Payment_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function invoice_viewer() {
|
||||
public function invoice_viewer(): void {
|
||||
|
||||
if (wu_request('action') === 'invoice' && wu_request('reference') && wu_request('key')) {
|
||||
/*
|
||||
@ -414,9 +414,9 @@ class Payment_Manager extends Base_Manager {
|
||||
*/
|
||||
public function transition_payment_status($old_status, $new_status, $payment_id) {
|
||||
|
||||
$completable_statuses = array(
|
||||
$completable_statuses = [
|
||||
'completed',
|
||||
);
|
||||
];
|
||||
|
||||
if ( ! in_array($new_status, $completable_statuses, true)) {
|
||||
return;
|
||||
|
@ -42,7 +42,7 @@ class Product_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $model_class = '\\WP_Ultimo\\Models\\Product';
|
||||
protected $model_class = \WP_Ultimo\Models\Product::class;
|
||||
|
||||
/**
|
||||
* Instantiate the necessary hooks.
|
||||
@ -50,7 +50,7 @@ class Product_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
$this->enable_rest_api();
|
||||
|
||||
|
@ -47,31 +47,31 @@ class Signup_Fields_Manager extends Base_Manager {
|
||||
*/
|
||||
public function get_field_types() {
|
||||
|
||||
$field_types = array(
|
||||
'pricing_table' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Signup_Field_Pricing_Table',
|
||||
'period_selection' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Signup_Field_Period_Selection',
|
||||
'products' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Signup_Field_Products',
|
||||
'template_selection' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Signup_Field_Template_Selection',
|
||||
'username' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Signup_Field_Username',
|
||||
'email' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Signup_Field_Email',
|
||||
'password' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Signup_Field_Password',
|
||||
'site_title' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Signup_Field_Site_Title',
|
||||
'site_url' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Signup_Field_Site_Url',
|
||||
'discount_code' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Signup_Field_Discount_Code',
|
||||
'order_summary' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Signup_Field_Order_Summary',
|
||||
'payment' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Signup_Field_Payment',
|
||||
'order_bump' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Signup_Field_Order_Bump',
|
||||
'billing_address' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Signup_Field_Billing_Address',
|
||||
'steps' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Signup_Field_Steps',
|
||||
'text' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Signup_Field_Text',
|
||||
'checkbox' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Signup_Field_Checkbox',
|
||||
'color_picker' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Signup_Field_Color',
|
||||
'select' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Signup_Field_Select',
|
||||
'hidden' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Signup_Field_Hidden',
|
||||
'shortcode' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Signup_Field_Shortcode',
|
||||
'terms_of_use' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Signup_Field_Terms_Of_Use',
|
||||
'submit_button' => '\\WP_Ultimo\\Checkout\\Signup_Fields\\Signup_Field_Submit_Button',
|
||||
);
|
||||
$field_types = [
|
||||
'pricing_table' => \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Pricing_Table::class,
|
||||
'period_selection' => \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Period_Selection::class,
|
||||
'products' => \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Products::class,
|
||||
'template_selection' => \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Template_Selection::class,
|
||||
'username' => \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Username::class,
|
||||
'email' => \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Email::class,
|
||||
'password' => \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Password::class,
|
||||
'site_title' => \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Site_Title::class,
|
||||
'site_url' => \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Site_Url::class,
|
||||
'discount_code' => \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Discount_Code::class,
|
||||
'order_summary' => \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Order_Summary::class,
|
||||
'payment' => \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Payment::class,
|
||||
'order_bump' => \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Order_Bump::class,
|
||||
'billing_address' => \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Billing_Address::class,
|
||||
'steps' => \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Steps::class,
|
||||
'text' => \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Text::class,
|
||||
'checkbox' => \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Checkbox::class,
|
||||
'color_picker' => \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Color::class,
|
||||
'select' => \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Select::class,
|
||||
'hidden' => \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Hidden::class,
|
||||
'shortcode' => \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Shortcode::class,
|
||||
'terms_of_use' => \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Terms_Of_Use::class,
|
||||
'submit_button' => \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Submit_Button::class,
|
||||
];
|
||||
|
||||
/*
|
||||
* Allow developers to add new field types
|
||||
@ -114,7 +114,7 @@ class Signup_Fields_Manager extends Base_Manager {
|
||||
public function get_instantiated_field_types() {
|
||||
|
||||
if ($this->instantiated_field_types === null) {
|
||||
$this->instantiated_field_types = array_map(array($this, 'instantiate_field_type'), $this->get_field_types());
|
||||
$this->instantiated_field_types = array_map([$this, 'instantiate_field_type'], $this->get_field_types());
|
||||
}
|
||||
|
||||
return $this->instantiated_field_types;
|
||||
@ -173,7 +173,7 @@ class Signup_Fields_Manager extends Base_Manager {
|
||||
*/
|
||||
public function get_all_editor_fields() {
|
||||
|
||||
$all_editor_fields = array();
|
||||
$all_editor_fields = [];
|
||||
|
||||
$field_types = $this->get_instantiated_field_types();
|
||||
|
||||
|
@ -44,7 +44,7 @@ class Site_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $model_class = '\\WP_Ultimo\\Models\\Site';
|
||||
protected $model_class = \WP_Ultimo\Models\Site::class;
|
||||
|
||||
/**
|
||||
* Instantiate the necessary hooks.
|
||||
@ -52,53 +52,53 @@ class Site_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
$this->enable_rest_api();
|
||||
|
||||
$this->enable_wp_cli();
|
||||
|
||||
add_action('after_setup_theme', array($this, 'additional_thumbnail_sizes'));
|
||||
add_action('after_setup_theme', [$this, 'additional_thumbnail_sizes']);
|
||||
|
||||
add_action('wp_ajax_wu_get_screenshot', array($this, 'get_site_screenshot'));
|
||||
add_action('wp_ajax_wu_get_screenshot', [$this, 'get_site_screenshot']);
|
||||
|
||||
add_action('wu_async_take_screenshot', array($this, 'async_get_site_screenshot'));
|
||||
add_action('wu_async_take_screenshot', [$this, 'async_get_site_screenshot']);
|
||||
|
||||
add_action('init', array($this, 'lock_site'));
|
||||
add_action('init', [$this, 'lock_site']);
|
||||
|
||||
add_action('admin_init', array($this, 'add_no_index_warning'));
|
||||
add_action('admin_init', [$this, 'add_no_index_warning']);
|
||||
|
||||
add_action('wp_head', array($this, 'prevent_site_template_indexing'), 0);
|
||||
add_action('wp_head', [$this, 'prevent_site_template_indexing'], 0);
|
||||
|
||||
add_action('login_enqueue_scripts', array($this, 'custom_login_logo'));
|
||||
add_action('login_enqueue_scripts', [$this, 'custom_login_logo']);
|
||||
|
||||
add_filter('login_headerurl', array($this, 'login_header_url'));
|
||||
add_filter('login_headerurl', [$this, 'login_header_url']);
|
||||
|
||||
add_filter('login_headertext', array($this, 'login_header_text'));
|
||||
add_filter('login_headertext', [$this, 'login_header_text']);
|
||||
|
||||
add_action('wu_pending_site_published', array($this, 'handle_site_published'), 10, 2);
|
||||
add_action('wu_pending_site_published', [$this, 'handle_site_published'], 10, 2);
|
||||
|
||||
add_action('load-sites.php', array($this, 'add_notices_to_default_site_page'));
|
||||
add_action('load-sites.php', [$this, 'add_notices_to_default_site_page']);
|
||||
|
||||
add_action('load-site-new.php', array($this, 'add_notices_to_default_site_page'));
|
||||
add_action('load-site-new.php', [$this, 'add_notices_to_default_site_page']);
|
||||
|
||||
add_filter('mucd_string_to_replace', array($this, 'search_and_replace_on_duplication'), 10, 3);
|
||||
add_filter('mucd_string_to_replace', [$this, 'search_and_replace_on_duplication'], 10, 3);
|
||||
|
||||
add_filter('wu_site_created', array($this, 'search_and_replace_for_new_site'), 10, 2);
|
||||
add_filter('wu_site_created', [$this, 'search_and_replace_for_new_site'], 10, 2);
|
||||
|
||||
add_action('wu_handle_bulk_action_form_site_delete-pending', array($this, 'handle_delete_pending_sites'), 100, 3);
|
||||
add_action('wu_handle_bulk_action_form_site_delete-pending', [$this, 'handle_delete_pending_sites'], 100, 3);
|
||||
|
||||
add_action('users_list_table_query_args', array($this, 'hide_super_admin_from_list'), 10, 1);
|
||||
add_action('users_list_table_query_args', [$this, 'hide_super_admin_from_list'], 10, 1);
|
||||
|
||||
add_action('wu_before_handle_order_submission', array($this, 'maybe_validate_add_new_site'), 15);
|
||||
add_action('wu_before_handle_order_submission', [$this, 'maybe_validate_add_new_site'], 15);
|
||||
|
||||
add_action('wu_checkout_before_process_checkout', array($this, 'maybe_add_new_site'), 5);
|
||||
add_action('wu_checkout_before_process_checkout', [$this, 'maybe_add_new_site'], 5);
|
||||
|
||||
add_action('pre_get_blogs_of_user', array($this, 'hide_customer_sites_from_super_admin_list'), 999, 3);
|
||||
add_action('pre_get_blogs_of_user', [$this, 'hide_customer_sites_from_super_admin_list'], 999, 3);
|
||||
|
||||
add_filter('wpmu_validate_blog_signup', array($this, 'allow_hyphens_in_site_name'), 10, 1);
|
||||
add_filter('wpmu_validate_blog_signup', [$this, 'allow_hyphens_in_site_name'], 10, 1);
|
||||
|
||||
add_action('wu_daily', array($this, 'delete_pending_sites'));
|
||||
add_action('wu_daily', [$this, 'delete_pending_sites']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -147,17 +147,17 @@ class Site_Manager extends Base_Manager {
|
||||
* @param \WP_Ultimo\Checkout\Checkout $checkout The current checkout object.
|
||||
* @return void
|
||||
*/
|
||||
public function maybe_validate_add_new_site($checkout) {
|
||||
public function maybe_validate_add_new_site($checkout): void {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
if (wu_request('create-new-site') && wp_verify_nonce(wu_request('create-new-site'), 'create-new-site')) {
|
||||
$errors = new \WP_Error();
|
||||
|
||||
$rules = array(
|
||||
$rules = [
|
||||
'site_title' => 'min:4',
|
||||
'site_url' => 'required|lowercase|unique_site',
|
||||
);
|
||||
];
|
||||
|
||||
if ($checkout->is_last_step()) {
|
||||
$membership = WP_Ultimo()->currents->get_membership();
|
||||
@ -172,14 +172,14 @@ class Site_Manager extends Base_Manager {
|
||||
$d = wu_get_site_domain_and_path(wu_request('site_url', ''), $checkout->request_or_session('site_domain'));
|
||||
|
||||
$pending_site = $membership->create_pending_site(
|
||||
array(
|
||||
[
|
||||
'domain' => $d->domain,
|
||||
'path' => $d->path,
|
||||
'template_id' => $checkout->request_or_session('template_id'),
|
||||
'title' => $checkout->request_or_session('site_title'),
|
||||
'customer_id' => $customer->get_id(),
|
||||
'membership_id' => $membership->get_id(),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if (is_wp_error($pending_site)) {
|
||||
@ -197,7 +197,7 @@ class Site_Manager extends Base_Manager {
|
||||
wp_send_json_error($errors);
|
||||
}
|
||||
|
||||
wp_send_json_success(array());
|
||||
wp_send_json_success([]);
|
||||
} else {
|
||||
$validation = $checkout->validate($rules);
|
||||
|
||||
@ -207,7 +207,7 @@ class Site_Manager extends Base_Manager {
|
||||
|
||||
$wpdb->query('COMMIT');
|
||||
|
||||
wp_send_json_success(array());
|
||||
wp_send_json_success([]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -218,15 +218,15 @@ class Site_Manager extends Base_Manager {
|
||||
* @since 2.0.11
|
||||
* @return void
|
||||
*/
|
||||
public function maybe_add_new_site() {
|
||||
public function maybe_add_new_site(): void {
|
||||
|
||||
if (wu_request('create-new-site') && wp_verify_nonce(wu_request('create-new-site'), 'create-new-site')) {
|
||||
$redirect_url = wu_request('redirect_url', admin_url('admin.php?page=sites'));
|
||||
|
||||
$redirect_url = add_query_arg(
|
||||
array(
|
||||
[
|
||||
'new_site_created' => true,
|
||||
),
|
||||
],
|
||||
$redirect_url
|
||||
);
|
||||
|
||||
@ -245,7 +245,7 @@ class Site_Manager extends Base_Manager {
|
||||
* @param \WP_Ultimo\Models\Membership $membership The payment.
|
||||
* @return void
|
||||
*/
|
||||
public function handle_site_published($site, $membership) {
|
||||
public function handle_site_published($site, $membership): void {
|
||||
|
||||
$payload = array_merge(
|
||||
wu_generate_event_payload('site', $site),
|
||||
@ -264,7 +264,7 @@ class Site_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function lock_site() {
|
||||
public function lock_site(): void {
|
||||
|
||||
if (is_main_site() || is_admin() || wu_is_login_page() || wp_doing_ajax() || wu_request('wu-ajax')) {
|
||||
return;
|
||||
@ -317,12 +317,12 @@ class Site_Manager extends Base_Manager {
|
||||
'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()),
|
||||
array(
|
||||
[
|
||||
'title' => __('Site not available', 'wp-ultimo'),
|
||||
)
|
||||
]
|
||||
),
|
||||
'',
|
||||
array('code' => 200)
|
||||
['code' => 200]
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -362,7 +362,7 @@ class Site_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function get_site_screenshot() {
|
||||
public function get_site_screenshot(): void {
|
||||
|
||||
$site_id = wu_request('site_id');
|
||||
|
||||
@ -387,10 +387,10 @@ class Site_Manager extends Base_Manager {
|
||||
$attachment_url = wp_get_attachment_image_src($attachment_id, 'wu-thumb-medium');
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'attachment_id' => $attachment_id,
|
||||
'attachment_url' => $attachment_url[0],
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -402,12 +402,12 @@ class Site_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function additional_thumbnail_sizes() {
|
||||
public function additional_thumbnail_sizes(): void {
|
||||
|
||||
if (is_main_site()) {
|
||||
add_image_size('wu-thumb-large', 900, 675, array('center', 'top')); // (cropped)
|
||||
add_image_size('wu-thumb-large', 900, 675, ['center', 'top']); // (cropped)
|
||||
|
||||
add_image_size('wu-thumb-medium', 400, 300, array('center', 'top')); // (cropped)
|
||||
add_image_size('wu-thumb-medium', 400, 300, ['center', 'top']); // (cropped)
|
||||
|
||||
}
|
||||
}
|
||||
@ -418,10 +418,10 @@ class Site_Manager extends Base_Manager {
|
||||
* @since 1.9.8
|
||||
* @return void
|
||||
*/
|
||||
public function add_no_index_warning() {
|
||||
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'), array($this, 'render_no_index_warning'), 'dashboard-network', 'normal', 'high');
|
||||
add_meta_box('wu-warnings', __('WP Multisite WaaS - Search Engines', 'wp-ultimo'), [$this, 'render_no_index_warning'], 'dashboard-network', 'normal', 'high');
|
||||
}
|
||||
}
|
||||
|
||||
@ -431,7 +431,7 @@ class Site_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_no_index_warning() { // phpcs:disable ?>
|
||||
public function render_no_index_warning(): void { // phpcs:disable ?>
|
||||
|
||||
<div class="wu-styling">
|
||||
|
||||
@ -439,7 +439,7 @@ class Site_Manager extends Base_Manager {
|
||||
|
||||
<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 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', array('tab' => 'sites'))); ?></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>
|
||||
|
||||
</div>
|
||||
|
||||
@ -454,7 +454,7 @@ class Site_Manager extends Base_Manager {
|
||||
* @since 1.6.0
|
||||
* @return void
|
||||
*/
|
||||
public function prevent_site_template_indexing() {
|
||||
public function prevent_site_template_indexing(): void {
|
||||
|
||||
if ( ! wu_get_setting('stop_template_indexing', false)) {
|
||||
return;
|
||||
@ -479,7 +479,7 @@ class Site_Manager extends Base_Manager {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function custom_login_logo() {
|
||||
public function custom_login_logo(): void {
|
||||
|
||||
if ( ! wu_get_setting('subsite_custom_login_logo', false) || ! has_custom_logo()) {
|
||||
$logo = wu_get_network_logo();
|
||||
@ -538,7 +538,7 @@ class Site_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function add_notices_to_default_site_page() {
|
||||
public function add_notices_to_default_site_page(): void {
|
||||
|
||||
$notice = __('Hey there! We highly recommend managing your network sites using the WP Multisite WaaS → 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 → Settings → Whitelabel options.', 'wp-ultimo');
|
||||
|
||||
@ -547,21 +547,21 @@ class Site_Manager extends Base_Manager {
|
||||
'info',
|
||||
'network-admin',
|
||||
'wu-sites-use-wp-ultimo',
|
||||
array(
|
||||
array(
|
||||
[
|
||||
[
|
||||
'title' => __('Go to the WP Multisite WaaS Sites page →', 'wp-ultimo'),
|
||||
'url' => wu_network_admin_url('wp-ultimo-sites'),
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'title' => __('Go to the Whitelabel Settings →', 'wp-ultimo'),
|
||||
'url' => wu_network_admin_url(
|
||||
'wp-ultimo-settings',
|
||||
array(
|
||||
[
|
||||
'tab' => 'whitelabel',
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -593,9 +593,9 @@ class Site_Manager extends Base_Manager {
|
||||
*/
|
||||
public function get_search_and_replace_settings() {
|
||||
|
||||
$search_and_replace = wu_get_setting('search_and_replace', array());
|
||||
$search_and_replace = wu_get_setting('search_and_replace', []);
|
||||
|
||||
$pairs = array();
|
||||
$pairs = [];
|
||||
|
||||
foreach ($search_and_replace as $item) {
|
||||
if ((isset($item['search']) && ! empty($item['search'])) && isset($item['replace'])) {
|
||||
@ -614,7 +614,7 @@ class Site_Manager extends Base_Manager {
|
||||
* @param object $site The site object.
|
||||
* @return void
|
||||
*/
|
||||
public static function search_and_replace_for_new_site($data, $site) {
|
||||
public static function search_and_replace_for_new_site($data, $site): void {
|
||||
|
||||
$to_site_id = $site->get_id();
|
||||
|
||||
@ -626,7 +626,7 @@ class Site_Manager extends Base_Manager {
|
||||
* In order to be backwards compatible here, we'll have to do some crazy stuff,
|
||||
* like overload the form session with the meta data saved on the pending site.
|
||||
*/
|
||||
$transient = wu_get_site($to_site_id)->get_meta('wu_form_data', array());
|
||||
$transient = wu_get_site($to_site_id)->get_meta('wu_form_data', []);
|
||||
|
||||
wu_get_session('signup')->set('form', $transient);
|
||||
|
||||
@ -634,22 +634,22 @@ class Site_Manager extends Base_Manager {
|
||||
|
||||
$to_blog_prefix = $wpdb->get_blog_prefix($to_site_id);
|
||||
|
||||
$string_to_replace = apply_filters('mucd_string_to_replace', array(), false, $to_site_id); // phpcs:ignore
|
||||
$string_to_replace = apply_filters('mucd_string_to_replace', [], false, $to_site_id); // phpcs:ignore
|
||||
|
||||
$tables = array();
|
||||
$tables = [];
|
||||
|
||||
$to_blog_prefix_like = $wpdb->esc_like($to_blog_prefix);
|
||||
|
||||
$results = \MUCD_Data::do_sql_query('SHOW TABLES LIKE \'' . $to_blog_prefix_like . '%\'', 'col', false);
|
||||
|
||||
foreach ($results as $k => $v) {
|
||||
$tables[ str_replace($to_blog_prefix, '', (string) $v) ] = array();
|
||||
$tables[ str_replace($to_blog_prefix, '', (string) $v) ] = [];
|
||||
}
|
||||
|
||||
foreach ( $tables as $table => $col) {
|
||||
$results = \MUCD_Data::do_sql_query('SHOW COLUMNS FROM `' . $to_blog_prefix . $table . '`', 'col', false);
|
||||
|
||||
$columns = array();
|
||||
$columns = [];
|
||||
|
||||
foreach ($results as $k => $v) {
|
||||
$columns[] = $v;
|
||||
@ -691,7 +691,7 @@ class Site_Manager extends Base_Manager {
|
||||
* @param array $ids The ids list.
|
||||
* @return void
|
||||
*/
|
||||
public function handle_delete_pending_sites($action, $model, $ids) {
|
||||
public function handle_delete_pending_sites($action, $model, $ids): void {
|
||||
|
||||
foreach ($ids as $membership_id) {
|
||||
$membership = wu_get_membership($membership_id);
|
||||
@ -710,9 +710,9 @@ class Site_Manager extends Base_Manager {
|
||||
}
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => add_query_arg('deleted', count($ids), wu_get_current_url()),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -767,15 +767,15 @@ class Site_Manager extends Base_Manager {
|
||||
$keys = array_keys($keys);
|
||||
|
||||
foreach ($keys as $key) {
|
||||
if (substr_compare($key, 'capabilities', -strlen('capabilities')) !== 0) {
|
||||
if (! str_ends_with($key, 'capabilities')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($wpdb->base_prefix && strncmp($key, (string) $wpdb->base_prefix, strlen((string) $wpdb->base_prefix)) !== 0) {
|
||||
if ($wpdb->base_prefix && ! str_starts_with($key, (string) $wpdb->base_prefix)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$site_id = str_replace(array($wpdb->base_prefix, '_capabilities'), '', $key);
|
||||
$site_id = str_replace([$wpdb->base_prefix, '_capabilities'], '', $key);
|
||||
|
||||
if ( ! is_numeric($site_id)) {
|
||||
continue;
|
||||
@ -784,7 +784,7 @@ class Site_Manager extends Base_Manager {
|
||||
$site_ids[] = (int) $site_id;
|
||||
}
|
||||
|
||||
$sites = array();
|
||||
$sites = [];
|
||||
|
||||
if ( ! empty($site_ids)) {
|
||||
|
||||
@ -793,24 +793,24 @@ class Site_Manager extends Base_Manager {
|
||||
* sites with wu_type meta value different than
|
||||
* Site_Type::CUSTOMER_OWNED or without this meta
|
||||
*/
|
||||
$args = array(
|
||||
$args = [
|
||||
'number' => '',
|
||||
'site__in' => $site_ids,
|
||||
'update_site_meta_cache' => false,
|
||||
'number' => 40,
|
||||
'meta_query' => array(
|
||||
'meta_query' => [
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
[
|
||||
'key' => 'wu_type',
|
||||
'compare' => 'NOT EXISTS',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'key' => 'wu_type',
|
||||
'compare' => 'NOT LIKE',
|
||||
'value' => Site_Type::CUSTOMER_OWNED,
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
if ( ! $all) {
|
||||
$args['archived'] = 0;
|
||||
@ -819,9 +819,9 @@ class Site_Manager extends Base_Manager {
|
||||
}
|
||||
|
||||
$_sites = array_merge(
|
||||
array(
|
||||
[
|
||||
get_site(wu_get_main_site_id()),
|
||||
),
|
||||
],
|
||||
get_sites($args),
|
||||
);
|
||||
|
||||
@ -830,7 +830,7 @@ class Site_Manager extends Base_Manager {
|
||||
continue;
|
||||
}
|
||||
|
||||
$sites[ $site->id ] = (object) array(
|
||||
$sites[ $site->id ] = (object) [
|
||||
'userblog_id' => $site->id,
|
||||
'blogname' => $site->blogname,
|
||||
'domain' => $site->domain,
|
||||
@ -841,7 +841,7 @@ class Site_Manager extends Base_Manager {
|
||||
'mature' => $site->mature,
|
||||
'spam' => $site->spam,
|
||||
'deleted' => $site->deleted,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -865,7 +865,7 @@ class Site_Manager extends Base_Manager {
|
||||
*
|
||||
* @since 2.1.3
|
||||
*/
|
||||
public function delete_pending_sites() {
|
||||
public function delete_pending_sites(): void {
|
||||
|
||||
$pending_sites = \WP_Ultimo\Models\Site::get_all_by_type('pending');
|
||||
|
||||
|
@ -29,7 +29,7 @@ class Visits_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
if ((bool) wu_get_setting('enable_visits_limiting', true) === false || is_main_site()) {
|
||||
return; // Feature not active, bail.
|
||||
@ -40,11 +40,11 @@ class Visits_Manager {
|
||||
* Due to how caching plugins work, we need to count visits via ajax.
|
||||
* This adds the ajax endpoint that performs the counting.
|
||||
*/
|
||||
add_action('wp_ajax_nopriv_wu_count_visits', array($this, 'count_visits'), 10, 2);
|
||||
add_action('wp_ajax_nopriv_wu_count_visits', [$this, 'count_visits'], 10, 2);
|
||||
|
||||
add_action('wp_enqueue_scripts', array($this, 'enqueue_visit_counter_script'));
|
||||
add_action('wp_enqueue_scripts', [$this, 'enqueue_visit_counter_script']);
|
||||
|
||||
add_action('template_redirect', array($this, 'maybe_lock_site'));
|
||||
add_action('template_redirect', [$this, 'maybe_lock_site']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,7 +53,7 @@ class Visits_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function maybe_lock_site() {
|
||||
public function maybe_lock_site(): void {
|
||||
|
||||
$site = wu_get_current_site();
|
||||
|
||||
@ -86,7 +86,7 @@ class Visits_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function count_visits() {
|
||||
public function count_visits(): void {
|
||||
|
||||
if (is_main_site() && is_admin()) {
|
||||
return; // bail on main site.
|
||||
@ -126,22 +126,22 @@ class Visits_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue_visit_counter_script() {
|
||||
public function enqueue_visit_counter_script(): void {
|
||||
|
||||
if (is_user_logged_in()) {
|
||||
return; // bail if user is logged in.
|
||||
|
||||
}
|
||||
|
||||
wp_register_script('wu-visits-counter', wu_get_asset('visits-counter.js', 'js'), array(), wu_get_version());
|
||||
wp_register_script('wu-visits-counter', wu_get_asset('visits-counter.js', 'js'), [], wu_get_version());
|
||||
|
||||
wp_localize_script(
|
||||
'wu-visits-counter',
|
||||
'wu_visits_counter',
|
||||
array(
|
||||
[
|
||||
'ajaxurl' => admin_url('admin-ajax.php'),
|
||||
'code' => wp_create_nonce('wu-visit-counter'),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wp_enqueue_script('wu-visits-counter');
|
||||
|
@ -43,7 +43,7 @@ class Webhook_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $model_class = '\\WP_Ultimo\\Models\\Webhook';
|
||||
protected $model_class = \WP_Ultimo\Models\Webhook::class;
|
||||
|
||||
/**
|
||||
* Holds the list of available events for webhooks.
|
||||
@ -51,7 +51,7 @@ class Webhook_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $events = array();
|
||||
protected $events = [];
|
||||
|
||||
/**
|
||||
* Holds the list of all webhooks.
|
||||
@ -59,7 +59,7 @@ class Webhook_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $webhooks = array();
|
||||
protected $webhooks = [];
|
||||
|
||||
/**
|
||||
* Instantiate the necessary hooks.
|
||||
@ -67,15 +67,15 @@ class Webhook_Manager extends Base_Manager {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
$this->enable_rest_api();
|
||||
|
||||
$this->enable_wp_cli();
|
||||
|
||||
add_action('init', array($this, 'register_webhook_listeners'));
|
||||
add_action('init', [$this, 'register_webhook_listeners']);
|
||||
|
||||
add_action('wp_ajax_wu_send_test_event', array($this, 'send_test_event'));
|
||||
add_action('wp_ajax_wu_send_test_event', [$this, 'send_test_event']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,10 +84,10 @@ class Webhook_Manager extends Base_Manager {
|
||||
* @todo This needs to have a switch, allowing us to turn it on and off.
|
||||
* @return void.
|
||||
*/
|
||||
public function register_webhook_listeners() {
|
||||
public function register_webhook_listeners(): void {
|
||||
|
||||
foreach (wu_get_event_types() as $key => $event) {
|
||||
add_action('wu_event_' . $key, array($this, 'send_webhooks'));
|
||||
add_action('wu_event_' . $key, [$this, 'send_webhooks']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ class Webhook_Manager extends Base_Manager {
|
||||
* @param array $args with events slug and payload.
|
||||
* @return void
|
||||
*/
|
||||
public function send_webhooks($args) {
|
||||
public function send_webhooks($args): void {
|
||||
|
||||
$webhooks = Webhook::get_all();
|
||||
|
||||
@ -131,19 +131,17 @@ class Webhook_Manager extends Base_Manager {
|
||||
|
||||
$request = wp_remote_post(
|
||||
$webhook->get_webhook_url(),
|
||||
array(
|
||||
[
|
||||
'method' => 'POST',
|
||||
'timeout' => 45,
|
||||
'redirection' => 5,
|
||||
'headers' => array(
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json',
|
||||
),
|
||||
'cookies' => array(),
|
||||
],
|
||||
'cookies' => [],
|
||||
'body' => wp_json_encode($data),
|
||||
'blocking' => $blocking,
|
||||
),
|
||||
current_filter(),
|
||||
$webhook
|
||||
]
|
||||
);
|
||||
|
||||
if (is_wp_error($request)) {
|
||||
@ -193,34 +191,34 @@ class Webhook_Manager extends Base_Manager {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function send_test_event() {
|
||||
public function send_test_event(): void {
|
||||
|
||||
if ( ! current_user_can('manage_network')) {
|
||||
wp_send_json(
|
||||
array(
|
||||
[
|
||||
'response' => __('You do not have enough permissions to send a test event.', 'wp-ultimo'),
|
||||
'webhooks' => Webhook::get_items_as_array(),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$event = wu_get_event_type($_POST['webhook_event']);
|
||||
|
||||
$webhook_data = array(
|
||||
$webhook_data = [
|
||||
'webhook_url' => $_POST['webhook_url'],
|
||||
'event' => $_POST['webhook_event'],
|
||||
'active' => true,
|
||||
);
|
||||
];
|
||||
|
||||
$webhook = new Webhook($webhook_data);
|
||||
|
||||
$response = $this->send_webhook($webhook, wu_maybe_lazy_load_payload($event['payload']), true, false);
|
||||
|
||||
wp_send_json(
|
||||
array(
|
||||
[
|
||||
'response' => htmlentities2($response),
|
||||
'id' => wu_request('webhook_id'),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -229,7 +227,7 @@ class Webhook_Manager extends Base_Manager {
|
||||
*
|
||||
* @return void.
|
||||
*/
|
||||
public function serve_logs() {
|
||||
public function serve_logs(): void {
|
||||
|
||||
echo '<style>
|
||||
body {
|
||||
@ -263,7 +261,7 @@ class Webhook_Manager extends Base_Manager {
|
||||
|
||||
$line = str_replace(' - ', ' </strong> - ', $line);
|
||||
|
||||
$matches = array();
|
||||
$matches = [];
|
||||
|
||||
$line = str_replace('\'', '\\\'', $line);
|
||||
$line = preg_replace('~(\{(?:[^{}]|(?R))*\})~', '<pre><script>document.write(JSON.stringify(JSON.parse(\'${1}\'), null, 2));</script></pre>', $line);
|
||||
@ -301,14 +299,14 @@ class Webhook_Manager extends Base_Manager {
|
||||
$message .= sprintf('Got error: %s', $response);
|
||||
}
|
||||
|
||||
$event_data = array(
|
||||
$event_data = [
|
||||
'object_id' => $id,
|
||||
'object_type' => $this->slug,
|
||||
'slug' => $event_name,
|
||||
'payload' => array(
|
||||
'payload' => [
|
||||
'message' => $message,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
wu_create_event($event_data);
|
||||
}
|
||||
|
Reference in New Issue
Block a user