Everywhere yoda conditions are

This commit is contained in:
David Stone
2025-02-09 00:20:10 -07:00
parent d74f6d1a53
commit be0ab98895
213 changed files with 691 additions and 412 deletions

View File

@ -240,7 +240,7 @@ abstract class Base_Admin_Page {
global $submenu; global $submenu;
if ($this->get_submenu_title() && $this->type === 'menu' && isset($submenu[ $this->id ]) && $submenu[ $this->id ][0][3] === $this->get_title()) { if ($this->get_submenu_title() && 'menu' === $this->type && isset($submenu[ $this->id ]) && $submenu[ $this->id ][0][3] === $this->get_title()) {
$submenu[ $this->id ][0][0] = $this->get_submenu_title(); $submenu[ $this->id ][0][0] = $this->get_submenu_title();
} }
} }
@ -416,7 +416,7 @@ abstract class Base_Admin_Page {
/** /**
* Create the admin page or sub-page * Create the admin page or sub-page
*/ */
$this->page_hook = $this->type === 'menu' ? $this->add_toplevel_menu_page() : $this->add_submenu_page(); $this->page_hook = 'menu' === $this->type ? $this->add_toplevel_menu_page() : $this->add_submenu_page();
/** /**
* Add the default hooks * Add the default hooks

View File

@ -196,7 +196,7 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page {
*/ */
public function handle_edit_page(): void { public function handle_edit_page(): void {
$settings_to_save = wu_request('submit') !== 'restore' ? $_POST : []; // don't worry, this gets cleaned later on. $settings_to_save = 'restore' !== wu_request('submit') ? $_POST : []; // don't worry, this gets cleaned later on.
$this->save_page_settings($settings_to_save); $this->save_page_settings($settings_to_save);
@ -413,7 +413,7 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page {
*/ */
public function save_settings($meta_id, $user_id, $meta_key, $_meta_value): void { public function save_settings($meta_id, $user_id, $meta_key, $_meta_value): void {
if (wu_request('action') !== 'meta-box-order') { if ('meta-box-order' !== wu_request('action')) {
return; return;
} }

View File

@ -195,7 +195,7 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page {
</div>"; </div>";
break; break;
case $targets_count === 1: case 1 === $targets_count:
$customer = wu_get_customer($targets[0]); $customer = wu_get_customer($targets[0]);
$url_atts = [ $url_atts = [

View File

@ -118,7 +118,7 @@ class Broadcast_List_Admin_Page extends List_Admin_Page {
$display_targets = []; $display_targets = [];
if ($targets) { if ($targets) {
if ($target_type === 'customers') { if ('customers' === $target_type) {
foreach ($targets as $key => $value) { foreach ($targets as $key => $value) {
$customer = wu_get_customer($value); $customer = wu_get_customer($value);
@ -149,7 +149,7 @@ class Broadcast_List_Admin_Page extends List_Admin_Page {
} }
} }
if ($target_type === 'products') { if ('products' === $target_type) {
foreach ($targets as $key => $value) { foreach ($targets as $key => $value) {
$product = wu_get_product($value); $product = wu_get_product($value);

View File

@ -187,7 +187,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page {
$preview_type = wu_request('type', 'user'); $preview_type = wu_request('type', 'user');
if ($preview_type === 'visitor') { if ('visitor' === $preview_type) {
global $current_user; global $current_user;
$current_user = wp_set_current_user(0); $current_user = wp_set_current_user(0);
@ -549,13 +549,13 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page {
] ]
); );
if ($default_field_slug === 'name' || $default_field_slug === 'id' || $default_field_slug === 'default_value') { if ('name' === $default_field_slug || 'id' === $default_field_slug || 'default_value' === $default_field_slug) {
unset($default_field['wrapper_html_attr']['v-if']); unset($default_field['wrapper_html_attr']['v-if']);
$default_field['wrapper_html_attr']['v-show'] = sprintf('type && require("type", %s) && require("tab", "%s")', json_encode($reqs), $tab); $default_field['wrapper_html_attr']['v-show'] = sprintf('type && require("type", %s) && require("tab", "%s")', json_encode($reqs), $tab);
} }
if ($default_field_slug === 'id') { if ('id' === $default_field_slug) {
$default_field['html_attr']['v-bind:required'] = sprintf('type && require("type", %s) && require("tab", "content")', json_encode($reqs)); $default_field['html_attr']['v-bind:required'] = sprintf('type && require("type", %s) && require("tab", "content")', json_encode($reqs));
} }
} }
@ -701,7 +701,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page {
$state = array_map( $state = array_map(
function ($value) { function ($value) {
if ($value === 'false' || $value === 'true') { if ('false' === $value || 'true' === $value) {
$value = (int) wu_string_to_bool($value); $value = (int) wu_string_to_bool($value);
} }

View File

@ -623,6 +623,7 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page {
return $this->object; return $this->object;
} }
/** /**
* Discount_Codes have titles. * Discount_Codes have titles.
* *

View File

@ -511,6 +511,7 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
return $this->object; return $this->object;
} }
/** /**
* Domains have titles. * Domains have titles.
* *

View File

@ -367,7 +367,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
$show_modified = wu_get_isset($atts, 'modified', true); $show_modified = wu_get_isset($atts, 'modified', true);
if ($this->edit && $show_modified === true) { if ($this->edit && true === $show_modified) {
$atts['fields']['date_modified'] = [ $atts['fields']['date_modified'] = [
'title' => __('Last Modified at', 'wp-ultimo'), 'title' => __('Last Modified at', 'wp-ultimo'),
'type' => 'text-display', 'type' => 'text-display',

View File

@ -496,7 +496,7 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
*/ */
public function handle_page_redirect($page): void { public function handle_page_redirect($page): void {
if ($page->get_id() === 'wp-ultimo-edit-email') { if ('wp-ultimo-edit-email' === $page->get_id()) {
if (wu_request('test_notice')) { if (wu_request('test_notice')) {
$test_notice = wu_request('test_notice'); $test_notice = wu_request('test_notice');

View File

@ -276,6 +276,7 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
exit; exit;
} }
/** /**
* Events have titles. * Events have titles.
* *
@ -285,6 +286,7 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
return false; return false;
} }
/** /**
* Handles the save of this form. * Handles the save of this form.
* *

View File

@ -26,6 +26,7 @@ abstract class List_Admin_Page extends Base_Admin_Page {
* @var bool * @var bool
*/ */
public $has_search; public $has_search;
/** /**
* The id/name/slug of the object being edited/created. e.g: plan * The id/name/slug of the object being edited/created. e.g: plan
* *
@ -209,7 +210,7 @@ abstract class List_Admin_Page extends Base_Admin_Page {
*/ */
public function save_screen_option($value, $option, $other_value) { public function save_screen_option($value, $option, $other_value) {
return $value === false && is_numeric($other_value) ? (int) $other_value : $value; return false === $value && is_numeric($other_value) ? (int) $other_value : $value;
} }
/** /**

View File

@ -1120,6 +1120,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
return $this->object; return $this->object;
} }
/** /**
* Memberships have titles. * Memberships have titles.
* *
@ -1129,6 +1130,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
return false; return false;
} }
/** /**
* Handle convert to lifetime. * Handle convert to lifetime.
* *

View File

@ -537,7 +537,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
*/ */
$type = wu_request('type', 'product'); $type = wu_request('type', 'product');
if ($type === 'product') { if ('product' === $type) {
$product = wu_get_product(wu_request('product_id')); $product = wu_get_product(wu_request('product_id'));
if (empty($product)) { if (empty($product)) {
@ -1270,7 +1270,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
static $payment; static $payment;
if ($payment !== null) { if (null !== $payment) {
return $payment; return $payment;
} }
@ -1292,6 +1292,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
return new Payment(); return new Payment();
} }
/** /**
* Payments have titles. * Payments have titles.
* *

View File

@ -1050,6 +1050,7 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
return $this->object; return $this->object;
} }
/** /**
* Products have titles. * Products have titles.
* *

View File

@ -520,7 +520,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
wp_die(__('You do not have the permissions required to change settings.', 'wp-ultimo')); wp_die(__('You do not have the permissions required to change settings.', 'wp-ultimo'));
} }
if ( ! isset($_POST['active_gateways']) && wu_request('tab') === 'payment-gateways') { if ( ! isset($_POST['active_gateways']) && 'payment-gateways' === wu_request('tab')) {
$_POST['active_gateways'] = []; $_POST['active_gateways'] = [];
} }

View File

@ -735,9 +735,9 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
$step = wu_request('step'); $step = wu_request('step');
if ($step === 'your-company') { if ('your-company' === $step) {
$fields_to_save = $this->get_general_settings(); $fields_to_save = $this->get_general_settings();
} elseif ($step === 'payment-gateways') { } elseif ('payment-gateways' === $step) {
$fields_to_save = $this->get_payment_settings(); $fields_to_save = $this->get_payment_settings();
} else { } else {
return; return;

View File

@ -738,6 +738,7 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
return $this->object; return $this->object;
} }
/** /**
* Sites have titles. * Sites have titles.
* *

View File

@ -239,7 +239,7 @@ class Site_List_Admin_Page extends List_Admin_Page {
$domain_type = wu_request('tab', is_subdomain_install() ? 'sub-domain' : 'sub-directory'); $domain_type = wu_request('tab', is_subdomain_install() ? 'sub-domain' : 'sub-directory');
if ($domain_type === 'domain') { if ('domain' === $domain_type) {
$domain = wu_request('domain', ''); $domain = wu_request('domain', '');
$path = '/'; $path = '/';
} else { } else {

View File

@ -630,7 +630,7 @@ class System_Info_Admin_Page extends Base_Admin_Page {
// Finally get the correct version number // Finally get the correct version number
$known = ['Version', $browser_name_short, 'other']; $known = ['Version', $browser_name_short, 'other'];
$pattern = '#(?<browser>' . join('|', $known) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#'; $pattern = '#(?<browser>' . implode('|', $known) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
if ( ! preg_match_all($pattern, (string) $user_agent, $matches)) { if ( ! preg_match_all($pattern, (string) $user_agent, $matches)) {
// We have no matching number just continue // We have no matching number just continue
@ -639,7 +639,7 @@ class System_Info_Admin_Page extends Base_Admin_Page {
// See how many we have // See how many we have
$i = count($matches['browser']); $i = count($matches['browser']);
if ($i !== 1) { if (1 !== $i) {
// We will have two since we are not using 'other' argument yet // We will have two since we are not using 'other' argument yet
// See if version is before or after the name // See if version is before or after the name
@ -695,6 +695,7 @@ class System_Info_Admin_Page extends Base_Admin_Page {
return (array) get_option('active_plugins', []); return (array) get_option('active_plugins', []);
} }
/** /**
* Get memory usage * Get memory usage
*/ */

View File

@ -322,7 +322,7 @@ class View_Logs_Admin_Page extends Edit_Admin_Page {
$action = wu_request('submit_button', 'none'); $action = wu_request('submit_button', 'none');
if ($action === 'none') { if ('none' === $action) {
WP_Ultimo()->notices->add(__('Something wrong happened', 'wp-ultimo'), 'error', 'network-admin'); WP_Ultimo()->notices->add(__('Something wrong happened', 'wp-ultimo'), 'error', 'network-admin');
return; return;
@ -336,7 +336,7 @@ class View_Logs_Admin_Page extends Edit_Admin_Page {
return; return;
} }
if ($action === 'download') { if ('download' === $action) {
$file_name = str_replace(Logger::get_logs_folder(), '', (string) $file); $file_name = str_replace(Logger::get_logs_folder(), '', (string) $file);
header('Content-Type: application/octet-stream'); header('Content-Type: application/octet-stream');
@ -346,7 +346,7 @@ class View_Logs_Admin_Page extends Edit_Admin_Page {
readfile($file); readfile($file);
exit; exit;
} elseif ($action === 'delete') { } elseif ('delete' === $action) {
$status = unlink($file); $status = unlink($file);
if ( ! $status) { if ( ! $status) {

View File

@ -367,6 +367,7 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page {
return new Webhook(); return new Webhook();
} }
/** /**
* Webhooks have titles. * Webhooks have titles.
* *

View File

@ -110,7 +110,7 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page {
$this->register_page_settings(); $this->register_page_settings();
if ($this->current_site->get_type() === 'customer_owned') { if ('customer_owned' === $this->current_site->get_type()) {
parent::__construct(); parent::__construct();
add_action('admin_menu', [$this, 'unset_default_my_sites_menu']); add_action('admin_menu', [$this, 'unset_default_my_sites_menu']);
@ -187,7 +187,7 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page {
*/ */
public function force_screen_options(): void { public function force_screen_options(): void {
if (get_current_screen()->id !== 'toplevel_page_sites') { if ('toplevel_page_sites' !== get_current_screen()->id) {
return; return;
} }

View File

@ -274,7 +274,7 @@ class Register_Endpoint {
/* /*
* Deal with status changes. * Deal with status changes.
*/ */
if ($membership_status !== $membership->get_status()) { if ($membership->get_status() !== $membership_status) {
$membership->set_status($membership_status); $membership->set_status($membership_status);
$membership->save(); $membership->save();
@ -293,7 +293,7 @@ class Register_Endpoint {
} }
} }
if ($payment_status !== $payment->get_status()) { if ($payment->get_status() !== $payment_status) {
$payment->set_status($payment_status); $payment->set_status($payment_status);
$payment->save(); $payment->save();
@ -533,6 +533,7 @@ class Register_Endpoint {
return apply_filters('wu_rest_register_endpoint_args', $args, $this); return apply_filters('wu_rest_register_endpoint_args', $args, $this);
} }
/** /**
* Maybe create a customer, if needed. * Maybe create a customer, if needed.
* *
@ -675,6 +676,7 @@ class Register_Endpoint {
'site.site_title' => 'required_with:site|min:4', 'site.site_title' => 'required_with:site|min:4',
]; ];
} }
/** /**
* Validates the rules and make sure we only save models when necessary. * Validates the rules and make sure we only save models when necessary.
* *

View File

@ -152,6 +152,7 @@ trait Rest_Api {
do_action('wu_rest_register_routes_with_id', $routes, $this->get_rest_base(), 'update', $this); do_action('wu_rest_register_routes_with_id', $routes, $this->get_rest_base(), 'update', $this);
} }
/** /**
* Returns a specific item. * Returns a specific item.
* *
@ -170,6 +171,7 @@ trait Rest_Api {
return rest_ensure_response($item); return rest_ensure_response($item);
} }
/** /**
* Returns a list of items. * Returns a list of items.
* *
@ -184,6 +186,7 @@ trait Rest_Api {
return rest_ensure_response($items); return rest_ensure_response($items);
} }
/** /**
* Creates an item. * Creates an item.
* *
@ -220,6 +223,7 @@ trait Rest_Api {
return rest_ensure_response($item); return rest_ensure_response($item);
} }
/** /**
* Updates an item. * Updates an item.
* *
@ -247,7 +251,7 @@ trait Rest_Api {
foreach ($params as $param => $value) { foreach ($params as $param => $value) {
$set_method = "set_{$param}"; $set_method = "set_{$param}";
if ($param === 'meta') { if ('meta' === $param) {
$item->update_meta_batch($value); $item->update_meta_batch($value);
} elseif (method_exists($item, $set_method)) { } elseif (method_exists($item, $set_method)) {
call_user_func([$item, $set_method], $value); call_user_func([$item, $set_method], $value);
@ -279,6 +283,7 @@ trait Rest_Api {
return rest_ensure_response($item); return rest_ensure_response($item);
} }
/** /**
* Deletes an item. * Deletes an item.
* *
@ -464,7 +469,7 @@ trait Rest_Api {
'id', 'id',
]; ];
if ($this->slug === 'site') { if ('site' === $this->slug) {
$arr = [ $arr = [
'id', 'id',
'blog_id', 'blog_id',
@ -511,7 +516,7 @@ trait Rest_Api {
*/ */
apply_filters('wu_before_' . $this->slug . '_api_arguments', $args, $this); apply_filters('wu_before_' . $this->slug . '_api_arguments', $args, $this);
if ($this->slug !== 'broadcast' && isset($args['author_id'])) { if ('broadcast' !== $this->slug && isset($args['author_id'])) {
unset($args['author_id']); unset($args['author_id']);
} }
@ -547,15 +552,15 @@ trait Rest_Api {
unset($args['slug']); unset($args['slug']);
} }
if ($this->slug === 'product' && isset($args['price_variations'])) { if ('product' === $this->slug && isset($args['price_variations'])) {
unset($args['price_variations']); unset($args['price_variations']);
} }
if ($this->slug === 'payment' && isset($args['line_items'])) { if ('payment' === $this->slug && isset($args['line_items'])) {
unset($args['line_items']); unset($args['line_items']);
} }
if ($this->slug === 'site') { if ('site' === $this->slug) {
if (isset($args['duplication_arguments'])) { if (isset($args['duplication_arguments'])) {
unset($args['duplication_arguments']); unset($args['duplication_arguments']);
} }
@ -565,7 +570,7 @@ trait Rest_Api {
} }
} }
if ($this->slug === 'email') { if ('email' === $this->slug) {
if (isset($args['status'])) { if (isset($args['status'])) {
unset($args['status']); unset($args['status']);
} }
@ -575,7 +580,7 @@ trait Rest_Api {
} }
} }
if ($this->slug === 'broadcast') { if ('broadcast' === $this->slug) {
if (isset($args['message_targets'])) { if (isset($args['message_targets'])) {
unset($args['message_targets']); unset($args['message_targets']);
} }

View File

@ -200,6 +200,7 @@ trait WP_CLI {
$this $this
); );
} }
/** /**
* Allows the additional of additional parameters. * Allows the additional of additional parameters.
* *
@ -283,7 +284,7 @@ trait WP_CLI {
$success = $item->save(); $success = $item->save();
if ($success === true) { if (true === $success) {
$item_id = $item->get_id(); $item_id = $item->get_id();
if ( ! empty($array_assoc['porcelain'])) { if ( ! empty($array_assoc['porcelain'])) {
@ -327,7 +328,7 @@ trait WP_CLI {
foreach ($params as $param => $value) { foreach ($params as $param => $value) {
$set_method = "set_{$param}"; $set_method = "set_{$param}";
if ($param === 'meta') { if ('meta' === $param) {
$item->update_meta_batch($value); $item->update_meta_batch($value);
} elseif (method_exists($item, $set_method)) { } elseif (method_exists($item, $set_method)) {
call_user_func([$item, $set_method], $value); call_user_func([$item, $set_method], $value);

View File

@ -533,6 +533,7 @@ class Cart implements \JsonSerializable {
$this->cart_descriptor = $descriptor; $this->cart_descriptor = $descriptor;
} }
/** /**
* Decides if we are trying to recover a payment. * Decides if we are trying to recover a payment.
* *
@ -707,6 +708,7 @@ class Cart implements \JsonSerializable {
return true; return true;
} }
/** /**
* Uses the membership to decide if this is a upgrade/downgrade/addon cart. * Uses the membership to decide if this is a upgrade/downgrade/addon cart.
* *
@ -1050,6 +1052,7 @@ class Cart implements \JsonSerializable {
*/ */
return true; return true;
} }
/** /**
* Search for variations of the plans with same duration. * Search for variations of the plans with same duration.
* *
@ -1235,6 +1238,7 @@ class Cart implements \JsonSerializable {
$this->add_line_item($credit_line_item); $this->add_line_item($credit_line_item);
} }
/** /**
* Adds a discount code to the cart. * Adds a discount code to the cart.
* *
@ -1485,6 +1489,7 @@ class Cart implements \JsonSerializable {
krsort($this->line_items); krsort($this->line_items);
} }
/** /**
* Adds a new product to the cart. * Adds a new product to the cart.
* *
@ -1762,6 +1767,7 @@ class Cart implements \JsonSerializable {
return $this->recovered_payment; return $this->recovered_payment;
} }
/** /**
* Add discount to the order. * Add discount to the order.
* *
@ -1787,6 +1793,7 @@ class Cart implements \JsonSerializable {
return true; return true;
} }
/** /**
* Get registration discounts. * Get registration discounts.
* *
@ -1836,6 +1843,7 @@ class Cart implements \JsonSerializable {
return array_filter($this->line_items, fn($id) => in_array($id, $ids, true), ARRAY_FILTER_USE_KEY); return array_filter($this->line_items, fn($id) => in_array($id, $ids, true), ARRAY_FILTER_USE_KEY);
} }
/** /**
* Get registration fees. * Get registration fees.
* *
@ -2137,6 +2145,7 @@ class Cart implements \JsonSerializable {
return $smallest_trial; return $smallest_trial;
} }
/** /**
* Returns the timestamp of the next charge, if recurring. * Returns the timestamp of the next charge, if recurring.
* *

View File

@ -516,7 +516,7 @@ class Checkout_Pages {
$function_caller = wu_get_function_caller(5); $function_caller = wu_get_function_caller(5);
if ($function_caller === 'wp_auth_check_html') { if ('wp_auth_check_html' === $function_caller) {
return $login_url; return $login_url;
} }

View File

@ -311,10 +311,10 @@ class Checkout {
* *
* @since 2.0.8 * @since 2.0.8
*/ */
if ($key === 'template_id') { if ('template_id' === $key) {
$template_name = get_query_var('template_name', null); $template_name = get_query_var('template_name', null);
if ($template_name !== null) { if (null !== $template_name) {
$d = wu_get_site_domain_and_path($template_name); $d = wu_get_site_domain_and_path($template_name);
$wp_site = get_site_by_path($d->domain, $d->path); $wp_site = get_site_by_path($d->domain, $d->path);
@ -550,6 +550,7 @@ class Checkout {
wp_send_json_success($results); wp_send_json_success($results);
} }
/** /**
* Process an order. * Process an order.
* *
@ -892,6 +893,7 @@ class Checkout {
*/ */
return $success_data; return $success_data;
} }
/** /**
* Checks if a customer exists, otherwise, creates a new one. * Checks if a customer exists, otherwise, creates a new one.
* *
@ -1059,7 +1061,7 @@ class Checkout {
*/ */
protected function handle_customer_meta_fields($customer, $form_slug) { protected function handle_customer_meta_fields($customer, $form_slug) {
if (empty($form_slug) || $form_slug === 'none') { if (empty($form_slug) || 'none' === $form_slug) {
return; return;
} }
@ -1131,6 +1133,7 @@ class Checkout {
do_action('wu_handle_user_meta_fields', $user_meta_repository, $user, $customer, $this); do_action('wu_handle_user_meta_fields', $user_meta_repository, $user, $customer, $this);
} }
} }
/** /**
* Checks if a membership exists, otherwise, creates a new one. * Checks if a membership exists, otherwise, creates a new one.
* *
@ -1181,6 +1184,7 @@ class Checkout {
return $membership; return $membership;
} }
/** /**
* Checks if a pending site exists, otherwise, creates a new one. * Checks if a pending site exists, otherwise, creates a new one.
* *
@ -1235,8 +1239,8 @@ class Checkout {
* The strategy here is simple, we basically set the site_url to the username and * The strategy here is simple, we basically set the site_url to the username and
* check if it is already taken. * check if it is already taken.
*/ */
if (empty($site_url) || $auto_generate_url === 'username') { if (empty($site_url) || 'username' === $auto_generate_url) {
if ($auto_generate_url === 'username') { if ('username' === $auto_generate_url) {
$site_url = $this->customer->get_username(); $site_url = $this->customer->get_username();
$site_title = $site_title ?: $site_url; $site_title = $site_title ?: $site_url;
@ -1339,7 +1343,7 @@ class Checkout {
*/ */
protected function get_site_meta_fields($form_slug, $meta_type = 'site_meta') { protected function get_site_meta_fields($form_slug, $meta_type = 'site_meta') {
if (empty($form_slug) || $form_slug === 'none') { if (empty($form_slug) || 'none' === $form_slug) {
return []; return [];
} }
@ -1357,6 +1361,7 @@ class Checkout {
return $list; return $list;
} }
/** /**
* Checks if a pending payment exists, otherwise, creates a new one. * Checks if a pending payment exists, otherwise, creates a new one.
* *
@ -1821,7 +1826,7 @@ class Checkout {
$stack = array_merge($session, $_REQUEST); $stack = array_merge($session, $_REQUEST);
} }
if ($rules === null) { if (null === $rules) {
$rules = $this->get_validation_rules(); $rules = $this->get_validation_rules();
} }
@ -2102,7 +2107,7 @@ class Checkout {
* *
* In that case, we simply return. * In that case, we simply return.
*/ */
if ($status === false) { if (false === $status) {
return; return;
} }
@ -2320,7 +2325,7 @@ class Checkout {
* it means that we don't have a step name set * it means that we don't have a step name set
* so we need to set it to the first. * so we need to set it to the first.
*/ */
if ($current_step_index === false) { if (false === $current_step_index) {
$current_step_index = 0; $current_step_index = 0;
} }

View File

@ -959,12 +959,7 @@ class Legacy_Checkout {
public function has_plan_step(): bool { public function has_plan_step(): bool {
$transient = static::get_transient(); $transient = static::get_transient();
return !(isset($transient['skip_plan']) && isset($transient['plan_id']) && isset($transient['plan_freq']));
if (isset($transient['skip_plan']) && isset($transient['plan_id']) && isset($transient['plan_freq'])) {
return false;
}
return true;
} }
/** /**
@ -1048,9 +1043,9 @@ class Legacy_Checkout {
$keys = array_keys($this->steps); $keys = array_keys($this->steps);
$search_key = array_search($this->step, array_keys($this->steps)) - 1 >= 0 ? array_search($this->step, array_keys($this->steps)) - 1 : false; $search_key = array_search($this->step, array_keys($this->steps)) - 1 >= 0 ? array_search($this->step, array_keys($this->steps)) - 1 : false;
$key = $search_key === false ? '' : $keys[ $search_key ]; $key = false === $search_key ? '' : $keys[ $search_key ];
if ( ! $key || $key == 'begin-signup') { if ( ! $key || 'begin-signup' == $key) {
return false; return false;
} }
@ -1096,7 +1091,7 @@ class Legacy_Checkout {
?> ?>
<?php if ($step == 'plan') { ?> <?php if ('plan' == $step) { ?>
<input type="hidden" name="wu_action" value="wu_new_user"> <input type="hidden" name="wu_action" value="wu_new_user">
<input type="hidden" id="wu_plan_freq" name="plan_freq" value="<?php echo $freq; ?>"> <input type="hidden" id="wu_plan_freq" name="plan_freq" value="<?php echo $freq; ?>">
@ -1267,7 +1262,7 @@ class Legacy_Checkout {
*/ */
public function array_filter_key(array $array, $callback): array { public function array_filter_key(array $array, $callback): array {
$matched_keys = array_filter(array_keys($array), $callback ?? fn($v, $k): bool => ! empty($v), $callback === null ? ARRAY_FILTER_USE_BOTH : 0); $matched_keys = array_filter(array_keys($array), $callback ?? fn($v, $k): bool => ! empty($v), null === $callback ? ARRAY_FILTER_USE_BOTH : 0);
return array_intersect_key($array, array_flip($matched_keys)); return array_intersect_key($array, array_flip($matched_keys));
} }
@ -1332,7 +1327,7 @@ class Legacy_Checkout {
function ($steps) use ($step, $id, $order, $field) { function ($steps) use ($step, $id, $order, $field) {
// Checks for honey-trap id // Checks for honey-trap id
if ($id === 'site_url') { if ('site_url' === $id) {
wp_die(__('Please, do not use the "site_url" as one of your custom fields\' ids. We use it as a honeytrap field to prevent spam registration. Consider alternatives such as "url" or "website".', 'wp-ultimo')); wp_die(__('Please, do not use the "site_url" as one of your custom fields\' ids. We use it as a honeytrap field to prevent spam registration. Consider alternatives such as "url" or "website".', 'wp-ultimo'));
} }

View File

@ -372,6 +372,7 @@ class Line_Item implements \JsonSerializable {
$this->type = $type; $this->type = $type;
} }
/** /**
* Get product associated with this line item. * Get product associated with this line item.
* *

View File

@ -224,7 +224,7 @@ abstract class Base_Signup_Field {
$width = (int) wu_get_isset($this->attributes, 'width'); $width = (int) wu_get_isset($this->attributes, 'width');
if ($width) { if ($width) {
if ($width !== 100) { if (100 !== $width) {
$styles[] = 'float: left'; $styles[] = 'float: left';
$styles[] = sprintf('width: %s%%', $width); $styles[] = sprintf('width: %s%%', $width);
@ -332,7 +332,7 @@ abstract class Base_Signup_Field {
$field['default'] = wu_get_isset($this->defaults(), $key, ''); $field['default'] = wu_get_isset($this->defaults(), $key, '');
if ($value === null) { if (null === $value) {
$value = $field['default']; $value = $field['default'];
} }

View File

@ -201,7 +201,7 @@ class Signup_Field_Checkbox extends Base_Signup_Field {
$value = $this->get_value(); $value = $this->get_value();
if ($value !== '' && (bool) $value === true) { if ('' !== $value && (bool) $value === true) {
$checkout_fields[ $attributes['id'] ]['html_attr']['checked'] = 'checked'; $checkout_fields[ $attributes['id'] ]['html_attr']['checked'] = 'checked';
} }

View File

@ -33,6 +33,7 @@ class Signup_Field_Order_Summary extends Base_Signup_Field {
return 'order_summary'; return 'order_summary';
} }
/** /**
* Returns if this field should be present on the checkout flow or not. * Returns if this field should be present on the checkout flow or not.
* *
@ -81,6 +82,7 @@ class Signup_Field_Order_Summary extends Base_Signup_Field {
return __('Adds a summary table with prices, key subscription dates, discounts, and taxes.', 'wp-ultimo'); return __('Adds a summary table with prices, key subscription dates, discounts, and taxes.', 'wp-ultimo');
} }
/** /**
* Returns the icon to be used on the selector. * Returns the icon to be used on the selector.
* *

View File

@ -33,6 +33,7 @@ class Signup_Field_Period_Selection extends Base_Signup_Field {
return 'period_selection'; return 'period_selection';
} }
/** /**
* Returns if this field should be present on the checkout flow or not. * Returns if this field should be present on the checkout flow or not.
* *
@ -81,6 +82,7 @@ class Signup_Field_Period_Selection extends Base_Signup_Field {
return __('Adds a period selector, that allows customers to switch between different billing periods.', 'wp-ultimo'); return __('Adds a period selector, that allows customers to switch between different billing periods.', 'wp-ultimo');
} }
/** /**
* Returns the icon to be used on the selector. * Returns the icon to be used on the selector.
* *
@ -285,7 +287,7 @@ class Signup_Field_Period_Selection extends Base_Signup_Field {
*/ */
public function to_fields_array($attributes) { public function to_fields_array($attributes) {
if (wu_get_isset($attributes, 'period_selection_template') === 'legacy') { if ('legacy' === wu_get_isset($attributes, 'period_selection_template')) {
wp_register_script('wu-legacy-signup', wu_get_asset('legacy-signup.js', 'js'), ['wu-functions'], wu_get_version()); wp_register_script('wu-legacy-signup', wu_get_asset('legacy-signup.js', 'js'), ['wu-functions'], wu_get_version());
wp_enqueue_script('wu-legacy-signup'); wp_enqueue_script('wu-legacy-signup');

View File

@ -33,6 +33,7 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field {
return 'pricing_table'; return 'pricing_table';
} }
/** /**
* Returns if this field should be present on the checkout flow or not. * Returns if this field should be present on the checkout flow or not.
* *
@ -81,6 +82,7 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field {
return __('Adds a pricing table section that customers can use to choose a plan to subscribe to.', 'wp-ultimo'); return __('Adds a pricing table section that customers can use to choose a plan to subscribe to.', 'wp-ultimo');
} }
/** /**
* Returns the icon to be used on the selector. * Returns the icon to be used on the selector.
* *
@ -244,7 +246,7 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field {
*/ */
public function to_fields_array($attributes) { public function to_fields_array($attributes) {
if (wu_get_isset($attributes, 'pricing_table_template') === 'legacy') { if ('legacy' === wu_get_isset($attributes, 'pricing_table_template')) {
wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), ['dashicons'], wu_get_version()); wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), ['dashicons'], wu_get_version());
wp_add_inline_style('legacy-shortcodes', \WP_Ultimo\Checkout\Legacy_Checkout::get_instance()->get_legacy_dynamic_styles()); wp_add_inline_style('legacy-shortcodes', \WP_Ultimo\Checkout\Legacy_Checkout::get_instance()->get_legacy_dynamic_styles());

View File

@ -32,6 +32,7 @@ class Signup_Field_Products extends Base_Signup_Field {
return 'products'; return 'products';
} }
/** /**
* Returns if this field should be present on the checkout flow or not. * Returns if this field should be present on the checkout flow or not.
* *
@ -80,6 +81,7 @@ class Signup_Field_Products extends Base_Signup_Field {
return __('Hidden field used to pre-select products. This is useful when you have a signup page for specific offering/bundles and do not want your customers to be able to choose plans and products manually.', 'wp-ultimo'); return __('Hidden field used to pre-select products. This is useful when you have a signup page for specific offering/bundles and do not want your customers to be able to choose plans and products manually.', 'wp-ultimo');
} }
/** /**
* Returns the icon to be used on the selector. * Returns the icon to be used on the selector.
* *

View File

@ -32,6 +32,7 @@ class Signup_Field_Shortcode extends Base_Signup_Field {
return 'shortcode'; return 'shortcode';
} }
/** /**
* Returns if this field should be present on the checkout flow or not. * Returns if this field should be present on the checkout flow or not.
* *
@ -80,6 +81,7 @@ class Signup_Field_Shortcode extends Base_Signup_Field {
return __('Displays the content of a given WordPress shortcode. Can be useful to insert content from other plugins inside a WP Multisite WaaS checkout form.', 'wp-ultimo'); return __('Displays the content of a given WordPress shortcode. Can be useful to insert content from other plugins inside a WP Multisite WaaS checkout form.', 'wp-ultimo');
} }
/** /**
* Returns the icon to be used on the selector. * Returns the icon to be used on the selector.
* *

View File

@ -32,6 +32,7 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
return 'site_url'; return 'site_url';
} }
/** /**
* Returns if this field should be present on the checkout flow or not. * Returns if this field should be present on the checkout flow or not.
* *
@ -41,6 +42,7 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
return false; return false;
} }
/** /**
* Defines if this field/element is related to site creation or not. * Defines if this field/element is related to site creation or not.
* *
@ -89,6 +91,7 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
return __('Adds a Site URL field. This is used to set the URL of the site being created.', 'wp-ultimo'); return __('Adds a Site URL field. This is used to set the URL of the site being created.', 'wp-ultimo');
} }
/** /**
* Returns the icon to be used on the selector. * Returns the icon to be used on the selector.
* *
@ -362,6 +365,7 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
return $checkout_fields; return $checkout_fields;
} }
/** /**
* Get the domain options. * Get the domain options.
* *

View File

@ -33,6 +33,7 @@ class Signup_Field_Steps extends Base_Signup_Field {
return 'steps'; return 'steps';
} }
/** /**
* Returns if this field should be present on the checkout flow or not. * Returns if this field should be present on the checkout flow or not.
* *
@ -81,6 +82,7 @@ class Signup_Field_Steps extends Base_Signup_Field {
return __('Adds a list of the steps.', 'wp-ultimo'); return __('Adds a list of the steps.', 'wp-ultimo');
} }
/** /**
* Returns the icon to be used on the selector. * Returns the icon to be used on the selector.
* *

View File

@ -34,6 +34,7 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
return 'template_selection'; return 'template_selection';
} }
/** /**
* Returns if this field should be present on the checkout flow or not. * Returns if this field should be present on the checkout flow or not.
* *
@ -82,6 +83,7 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
return __('Adds a template selection section. This allows the customer to choose a pre-built site to be used as a template for the site being currently created.', 'wp-ultimo'); return __('Adds a template selection section. This allows the customer to choose a pre-built site to be used as a template for the site being currently created.', 'wp-ultimo');
} }
/** /**
* Returns the icon to be used on the selector. * Returns the icon to be used on the selector.
* *
@ -375,15 +377,15 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
$selection_type = wu_get_isset($attributes, 'template_selection_type', 'name'); $selection_type = wu_get_isset($attributes, 'template_selection_type', 'name');
if ($selection_type === 'name') { if ('name' === $selection_type) {
return explode(',', $attributes['template_selection_sites']); return explode(',', $attributes['template_selection_sites']);
} }
if ($selection_type === 'all') { if ('all' === $selection_type) {
return wu_get_site_templates(['fields' => 'blog_id']); return wu_get_site_templates(['fields' => 'blog_id']);
} }
if ($selection_type === 'categories') { if ('categories' === $selection_type) {
return array_column( return array_column(
\WP_Ultimo\Models\Site::get_all_by_categories( \WP_Ultimo\Models\Site::get_all_by_categories(
$attributes['template_selection_categories'], $attributes['template_selection_categories'],

View File

@ -29,6 +29,7 @@ class Base_Field_Template {
* @var string * @var string
*/ */
protected $id; protected $id;
/** /**
* @var array * @var array
*/ */
@ -92,6 +93,7 @@ class Base_Field_Template {
return __('Description', 'wp-ultimo'); return __('Description', 'wp-ultimo');
} }
/** /**
* The preview image of the field template. * The preview image of the field template.
* *

View File

@ -42,6 +42,7 @@ class Ajax {
*/ */
add_action('wp_ajax_wu_list_table_fetch_ajax_results', [$this, 'refresh_list_table']); add_action('wp_ajax_wu_list_table_fetch_ajax_results', [$this, 'refresh_list_table']);
} }
/** /**
* Reverts the name of the table being processed. * Reverts the name of the table being processed.
* *
@ -301,6 +302,7 @@ class Ajax {
wp_send_json($data); wp_send_json($data);
} }
/** /**
* Search for WP Multisite WaaS settings to help customers find them. * Search for WP Multisite WaaS settings to help customers find them.
* *

View File

@ -92,7 +92,7 @@ class API {
public function maybe_bypass_wp_auth($result) { public function maybe_bypass_wp_auth($result) {
// Another plugin already bypass this request // Another plugin already bypass this request
if ($result === true) { if (true === $result) {
return $result; return $result;
} }
@ -411,7 +411,7 @@ class API {
$api_secret = wu_get_isset($params, 'api_secret', wu_get_isset($params, 'api-secret')); $api_secret = wu_get_isset($params, 'api_secret', wu_get_isset($params, 'api-secret'));
} }
if ($api_key === false) { if (false === $api_key) {
return false; return false;
} }

View File

@ -224,7 +224,7 @@ class Async_Calls {
foreach ($results as $result) { foreach ($results as $result) {
$status = wu_get_isset($result, 'success', false); $status = wu_get_isset($result, 'success', false);
if ($status === false) { if (false === $status) {
return $result; return $result;
} }
} }

View File

@ -70,7 +70,7 @@ class Dashboard_Widgets {
global $pagenow; global $pagenow;
if ( ! $pagenow || $pagenow !== 'index.php') { if ( ! $pagenow || 'index.php' !== $pagenow) {
return; return;
} }

View File

@ -88,7 +88,7 @@ class Domain_Mapping {
$is_enabled = (bool) wu_get_setting_early('enable_domain_mapping'); $is_enabled = (bool) wu_get_setting_early('enable_domain_mapping');
if ($is_enabled === false) { if (false === $is_enabled) {
return; return;
} }
@ -241,6 +241,7 @@ class Domain_Mapping {
return [$nowww, $www]; return [$nowww, $www];
} }
/** /**
* Checks if we have a site associated with the domain being accessed * Checks if we have a site associated with the domain being accessed
* *
@ -468,7 +469,7 @@ class Domain_Mapping {
*/ */
public function replace_url($url, $current_mapping = null) { public function replace_url($url, $current_mapping = null) {
if ($current_mapping === null) { if (null === $current_mapping) {
$current_mapping = $this->current_mapping; $current_mapping = $this->current_mapping;
} }
@ -509,7 +510,7 @@ class Domain_Mapping {
$current_mapping = $this->current_mapping; $current_mapping = $this->current_mapping;
if (empty($current_mapping) || $site_id !== $current_mapping->get_site_id()) { if (empty($current_mapping) || $current_mapping->get_site_id() !== $site_id) {
return $url; return $url;
} }

View File

@ -69,6 +69,7 @@ class Geolocation {
private static function supports_geolite2(): bool { private static function supports_geolite2(): bool {
return false; // version_compare( PHP_VERSION, '5.4.0', '>=' ); return false; // version_compare( PHP_VERSION, '5.4.0', '>=' );
} }
/** /**
* Check if geolocation is enabled. * Check if geolocation is enabled.
* *
@ -144,6 +145,7 @@ class Geolocation {
} elseif ( isset( $_SERVER['REMOTE_ADDR'] ) ) { // @codingStandardsIgnoreLine } elseif ( isset( $_SERVER['REMOTE_ADDR'] ) ) { // @codingStandardsIgnoreLine
return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ); // @codingStandardsIgnoreLine return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ); // @codingStandardsIgnoreLine
} }
return ''; return '';
} }
@ -289,6 +291,7 @@ class Geolocation {
wp_clear_scheduled_hook( 'wu_geoip_updater' ); wp_clear_scheduled_hook( 'wu_geoip_updater' );
wp_schedule_event( strtotime( 'first tuesday of next month' ), 'monthly', 'wu_geoip_updater' ); wp_schedule_event( strtotime( 'first tuesday of next month' ), 'monthly', 'wu_geoip_updater' );
} }
// Delete temp file regardless of success. // Delete temp file regardless of success.
$wp_filesystem->delete( $tmp_database_path ); $wp_filesystem->delete( $tmp_database_path );
} else { } else {

View File

@ -55,11 +55,11 @@ class Logger extends AbstractLogger {
$allowed_log_level = wu_get_setting('error_logging_level', 'default'); $allowed_log_level = wu_get_setting('error_logging_level', 'default');
if ($allowed_log_level === 'disabled') { if ('disabled' === $allowed_log_level) {
return; return;
} }
if ($allowed_log_level === 'default') { if ('default' === $allowed_log_level) {
/** /**
* Get from default php reporting level * Get from default php reporting level
* *
@ -96,7 +96,7 @@ class Logger extends AbstractLogger {
if ( ! in_array($log_level, $current_log_levels, true) && ($reporting_level & ~E_ALL)) { if ( ! in_array($log_level, $current_log_levels, true) && ($reporting_level & ~E_ALL)) {
return; return;
} }
} elseif ($allowed_log_level === 'errors' && $log_level !== LogLevel::ERROR && $log_level !== LogLevel::CRITICAL) { } elseif ('errors' === $allowed_log_level && LogLevel::ERROR !== $log_level && LogLevel::CRITICAL !== $log_level) {
return; return;
} }

View File

@ -128,6 +128,7 @@ class Requirements {
public static function is_unit_test() { public static function is_unit_test() {
return defined('WP_TESTS_MULTISITE') && WP_TESTS_MULTISITE; return defined('WP_TESTS_MULTISITE') && WP_TESTS_MULTISITE;
} }
/** /**
* Check if the PHP version requirements are met * Check if the PHP version requirements are met
* *
@ -143,6 +144,7 @@ class Requirements {
return true; return true;
} }
/** /**
* Check if the WordPress version requirements are met * Check if the WordPress version requirements are met
* *
@ -217,6 +219,7 @@ class Requirements {
return true; return true;
} }
/** /**
* Check if the install is a Multisite install * Check if the install is a Multisite install
* *
@ -232,6 +235,7 @@ class Requirements {
return true; return true;
} }
/** /**
* Check if WP Multisite WaaS is network active. * Check if WP Multisite WaaS is network active.
* *

View File

@ -35,6 +35,7 @@ class Session_Cookie implements Session {
* @var boolean * @var boolean
*/ */
protected $loaded = false; protected $loaded = false;
/** /**
* @var string * @var string
*/ */
@ -91,6 +92,7 @@ class Session_Cookie implements Session {
return is_array($this->data) && isset($this->data[ $key ]) ? $this->data[ $key ] : null; return is_array($this->data) && isset($this->data[ $key ]) ? $this->data[ $key ] : null;
} }
/** /**
* Set the value of a session key. * Set the value of a session key.
* *
@ -105,6 +107,7 @@ class Session_Cookie implements Session {
return true; return true;
} }
/** /**
* Appends values to a given key, instead of replacing it. * Appends values to a given key, instead of replacing it.
* *
@ -121,6 +124,7 @@ class Session_Cookie implements Session {
return true; return true;
} }
/** /**
* Writes to the session and closes the connection. * Writes to the session and closes the connection.
* *
@ -129,7 +133,7 @@ class Session_Cookie implements Session {
*/ */
public function commit($expire = null): bool { public function commit($expire = null): bool {
if ($expire === null) { if (null === $expire) {
$expire = HOUR_IN_SECONDS; $expire = HOUR_IN_SECONDS;
} }

View File

@ -87,7 +87,7 @@ class Settings {
global $current_site; global $current_site;
if ($network_id !== $current_site->id) { if ($current_site->id !== $network_id) {
return $status; return $status;
} }
@ -110,7 +110,7 @@ class Settings {
global $current_site; global $current_site;
if ($network_id !== $current_site->id) { if ($current_site->id !== $network_id) {
return $status; return $status;
} }
@ -131,7 +131,7 @@ class Settings {
global $current_site; global $current_site;
if ($network_id !== $current_site->id || is_bool($status)) { if ($current_site->id !== $network_id || is_bool($status)) {
return $status; return $status;
} }
@ -249,7 +249,7 @@ class Settings {
/** /**
* For the current tab, we need to assume toggle fields. * For the current tab, we need to assume toggle fields.
*/ */
if ($section_slug === wu_request('tab', 'general') && $field->type === 'toggle' && ! isset($settings_to_save[ $field_slug ])) { if (wu_request('tab', 'general') === $section_slug && $field->type === 'toggle' && ! isset($settings_to_save[ $field_slug ])) {
$new_value = false; $new_value = false;
} }
@ -298,6 +298,7 @@ class Settings {
if ( $this->sections ) { if ( $this->sections ) {
return $this->sections; return $this->sections;
} }
$this->default_sections(); $this->default_sections();
$this->sections = apply_filters( $this->sections = apply_filters(
'wu_settings_get_sections', 'wu_settings_get_sections',
@ -455,14 +456,14 @@ class Settings {
$model_name = wu_get_isset($atts['html_attr'], 'data-model'); $model_name = wu_get_isset($atts['html_attr'], 'data-model');
if ($model_name) { if ($model_name) {
if (function_exists("wu_get_{$model_name}") || $model_name === 'page') { if (function_exists("wu_get_{$model_name}") || 'page' === $model_name) {
$original_html_attr = $atts['html_attr']; $original_html_attr = $atts['html_attr'];
$atts['html_attr'] = function () use ($field_slug, $model_name, $atts, $original_html_attr) { $atts['html_attr'] = function () use ($field_slug, $model_name, $atts, $original_html_attr) {
$value = wu_get_setting($field_slug); $value = wu_get_setting($field_slug);
if ($model_name === 'page') { if ('page' === $model_name) {
$new_attrs['data-selected'] = get_post($value); $new_attrs['data-selected'] = get_post($value);
} else { } else {
$data_selected = call_user_func("wu_get_{$model_name}", $value); $data_selected = call_user_func("wu_get_{$model_name}", $value);

View File

@ -291,7 +291,7 @@ class Sunrise {
return true; return true;
} }
if ($sunrise_found === false) { if (false === $sunrise_found) {
$error = [ $error = [
'message' => __('File not found.', 'wp-ultimo'), 'message' => __('File not found.', 'wp-ultimo'),
]; ];
@ -425,9 +425,9 @@ class Sunrise {
$is_active = isset($meta['active']) && $meta['active']; $is_active = isset($meta['active']) && $meta['active'];
if ($is_active && $mode === 'activating') { if ($is_active && 'activating' === $mode) {
return false; return false;
} elseif ( ! $is_active && $mode === 'deactivating') { } elseif ( ! $is_active && 'deactivating' === $mode) {
return false; return false;
} }
@ -457,10 +457,10 @@ class Sunrise {
] ]
); );
if ($mode === 'activating') { if ('activating' === $mode) {
$to_save['active'] = true; $to_save['active'] = true;
$to_save['last_activated'] = $now; $to_save['last_activated'] = $now;
} elseif ($mode === 'deactivating') { } elseif ('deactivating' === $mode) {
$to_save['active'] = false; $to_save['active'] = false;
$to_save['last_deactivated'] = $now; $to_save['last_deactivated'] = $now;
} else { } else {

View File

@ -30,6 +30,7 @@ class User_Switching {
add_action('plugins_loaded', [$this, 'register_forms']); add_action('plugins_loaded', [$this, 'register_forms']);
} }
/** /**
* Check if Plugin User Switching is activated * Check if Plugin User Switching is activated
* *

View File

@ -441,7 +441,7 @@ class General_Compat {
$file_path = get_parent_theme_file_path('includes/lib/inc/functions.php'); $file_path = get_parent_theme_file_path('includes/lib/inc/functions.php');
if ($theme === 'avada' && file_exists($file_path)) { if ('avada' === $theme && file_exists($file_path)) {
require_once get_parent_theme_file_path('includes/lib/inc/functions.php'); require_once get_parent_theme_file_path('includes/lib/inc/functions.php');

View File

@ -375,14 +375,14 @@ class Legacy_Shortcodes {
'required' => true, 'required' => true,
'pricing_table_products' => implode(',', wu_get_plans($search_arguments)), 'pricing_table_products' => implode(',', wu_get_plans($search_arguments)),
'pricing_table_template' => $layout, 'pricing_table_template' => $layout,
'element_classes' => $layout === 'legacy' ? 'wu-content-plan' : '', 'element_classes' => 'legacy' === $layout ? 'wu-content-plan' : '',
]; ];
/** /**
* If not using the legacy checkout, * If not using the legacy checkout,
* we'll need a submit field. * we'll need a submit field.
*/ */
if ($layout !== 'legacy') { if ('legacy' !== $layout) {
$fields[] = [ $fields[] = [
'step' => 'checkout', 'step' => 'checkout',
'name' => __('Get Started &rarr;', 'wp-ultimo'), 'name' => __('Get Started &rarr;', 'wp-ultimo'),
@ -528,7 +528,7 @@ class Legacy_Shortcodes {
'template_selection_sites' => implode(',', $templates ?: wu_get_site_templates($search_arguments)), 'template_selection_sites' => implode(',', $templates ?: wu_get_site_templates($search_arguments)),
'template_selection_template' => $layout, 'template_selection_template' => $layout,
'cols' => $atts['cols'], 'cols' => $atts['cols'],
'element_classes' => $layout === 'legacy' ? 'wu-content-templates' : '', 'element_classes' => 'legacy' === $layout ? 'wu-content-templates' : '',
]; ];
$steps = [ $steps = [
@ -589,6 +589,7 @@ class Legacy_Shortcodes {
] ]
); );
} }
/** /**
* Makes sure we don't return any invalid values. * Makes sure we don't return any invalid values.
* *

View File

@ -224,7 +224,7 @@ class Multiple_Accounts_Compat {
* belong to the sub-site in question, so we unset the user * belong to the sub-site in question, so we unset the user
* currently logged in. * currently logged in.
*/ */
if ($has_user === false) { if (false === $has_user) {
wu_x_header('X-Ultimo-Multiple-Accounts: user-unset'); wu_x_header('X-Ultimo-Multiple-Accounts: user-unset');
$current_user = null; $current_user = null;
@ -305,7 +305,7 @@ class Multiple_Accounts_Compat {
*/ */
public function add_column_content($null, $column, $user_id): void { public function add_column_content($null, $column, $user_id): void {
if ($column === 'multiple_accounts') { if ('multiple_accounts' === $column) {
// Get user email // Get user email
$user = get_user_by('ID', $user_id); $user = get_user_by('ID', $user_id);
@ -399,6 +399,7 @@ class Multiple_Accounts_Compat {
// If nothing was found return false; // If nothing was found return false;
return $has_user; return $has_user;
} }
/** /**
* Gets the right user when logging-in. * Gets the right user when logging-in.
* *
@ -457,6 +458,7 @@ class Multiple_Accounts_Compat {
return $can; return $can;
} }
/** /**
* Gets the right user for a given domain. * Gets the right user for a given domain.
* *
@ -477,7 +479,7 @@ class Multiple_Accounts_Compat {
// Loop the results and check which one is in this group // Loop the results and check which one is in this group
foreach ($users->results as $user_with_email) { foreach ($users->results as $user_with_email) {
$conditions = $password == false ? true : wp_check_password($password, $user_with_email->user_pass, $user_with_email->ID); $conditions = false == $password ? true : wp_check_password($password, $user_with_email->user_pass, $user_with_email->ID);
// Check for the pertinence of that user in this site // Check for the pertinence of that user in this site
if ($conditions && $this->user_can_for_blog($user_with_email, get_current_blog_id(), 'read')) { if ($conditions && $this->user_can_for_blog($user_with_email, get_current_blog_id(), 'read')) {

View File

@ -100,11 +100,11 @@ abstract class Country {
$placeholder_option = []; $placeholder_option = [];
if ($placeholder !== false && $options) { if (false !== $placeholder && $options) {
$division_name = $this->get_administrative_division_name(); $division_name = $this->get_administrative_division_name();
// translators: %s is the name of the administrative division (state, province, etc). // translators: %s is the name of the administrative division (state, province, etc).
$placeholder_option[''] = $placeholder !== '' ? $placeholder : sprintf(__('Select your %s', 'wp-ultimo'), $division_name); $placeholder_option[''] = '' !== $placeholder ? $placeholder : sprintf(__('Select your %s', 'wp-ultimo'), $division_name);
} }
return array_merge($placeholder_option, $options); return array_merge($placeholder_option, $options);
@ -161,8 +161,8 @@ abstract class Country {
$placeholder_option = []; $placeholder_option = [];
if ($placeholder !== false && $options) { if (false !== $placeholder && $options) {
$placeholder_option[''] = $placeholder !== '' ? $placeholder : __('Select your city', 'wp-ultimo'); $placeholder_option[''] = '' !== $placeholder ? $placeholder : __('Select your city', 'wp-ultimo');
} }
$options = array_combine($options, $options); $options = array_combine($options, $options);

View File

@ -86,6 +86,7 @@ final class Checkout_Forms_Table extends Table {
date_modified datetime DEFAULT NULL, date_modified datetime DEFAULT NULL,
PRIMARY KEY (id)"; PRIMARY KEY (id)";
} }
/** /**
* Fixes the datetime columns to accept null. * Fixes the datetime columns to accept null.
* *

View File

@ -93,6 +93,7 @@ final class Discount_Codes_Table extends Table {
date_modified datetime NULL, date_modified datetime NULL,
PRIMARY KEY (id)"; PRIMARY KEY (id)";
} }
/** /**
* Fixes the datetime columns to accept null. * Fixes the datetime columns to accept null.
* *

View File

@ -27,9 +27,13 @@ class Domain_Stage extends Enum {
const __default = 'checking-dns'; // phpcs:ignore const __default = 'checking-dns'; // phpcs:ignore
const FAILED = 'failed'; const FAILED = 'failed';
const CHECKING_DNS = 'checking-dns'; const CHECKING_DNS = 'checking-dns';
const CHECKING_SSL = 'checking-ssl-cert'; const CHECKING_SSL = 'checking-ssl-cert';
const DONE_WITHOUT_SSL = 'done-without-ssl'; const DONE_WITHOUT_SSL = 'done-without-ssl';
const DONE = 'done'; const DONE = 'done';
/** /**

View File

@ -88,6 +88,7 @@ final class Domains_Table extends Table {
KEY blog_id (blog_id,domain,active), KEY blog_id (blog_id,domain,active),
KEY domain (domain)"; KEY domain (domain)";
} }
/** /**
* Fixes the datetime columns to accept null. * Fixes the datetime columns to accept null.
* *

View File

@ -23,6 +23,7 @@ abstract class Enum {
* The default value. * The default value.
*/ */
const __default = false; const __default = false;
// phpcs:ignore // phpcs:ignore
/** /**
* The options available. * The options available.
@ -31,10 +32,12 @@ abstract class Enum {
* @var array * @var array
*/ */
static $options = []; static $options = [];
/** /**
* @var string * @var string
*/ */
private $value = ''; private $value = '';
/** /**
* Constructor method. Takes the value you want to set. * Constructor method. Takes the value you want to set.
* *
@ -54,6 +57,7 @@ abstract class Enum {
* @return array * @return array
*/ */
abstract protected function classes(); abstract protected function classes();
/** /**
* Returns an array with values => labels. * Returns an array with values => labels.
* *
@ -61,6 +65,7 @@ abstract class Enum {
* @return void * @return void
*/ */
abstract protected function labels(); abstract protected function labels();
/** /**
* Returns an array with values => labels. * Returns an array with values => labels.
* *
@ -186,7 +191,7 @@ abstract class Enum {
static $instance; static $instance;
if ($instance === null) { if (null === $instance) {
$instance = new static(); $instance = new static();
} }

View File

@ -51,11 +51,7 @@ abstract class Table extends \BerlinDB\Database\Table {
return false; return false;
} }
if ( ! is_main_site()) { return (bool) is_main_site();
return false;
}
return true;
} }
/** /**

View File

@ -89,6 +89,7 @@ final class Events_Table extends Table {
KEY author_id (author_id), KEY author_id (author_id),
KEY initiator (initiator)"; KEY initiator (initiator)";
} }
/** /**
* Fixes the datetime columns to accept null. * Fixes the datetime columns to accept null.
* *

View File

@ -27,10 +27,15 @@ class Membership_Status extends Enum {
const __default = 'pending'; // phpcs:ignore const __default = 'pending'; // phpcs:ignore
const PENDING = 'pending'; const PENDING = 'pending';
const ACTIVE = 'active'; const ACTIVE = 'active';
const TRIALING = 'trialing'; const TRIALING = 'trialing';
const EXPIRED = 'expired'; const EXPIRED = 'expired';
const ON_HOLD = 'on-hold'; const ON_HOLD = 'on-hold';
const CANCELLED = 'cancelled'; const CANCELLED = 'cancelled';
/** /**

View File

@ -112,6 +112,7 @@ final class Memberships_Table extends Table {
KEY status (status), KEY status (status),
KEY disabled (disabled)"; KEY disabled (disabled)";
} }
/** /**
* Fixes the datetime columns to accept null. * Fixes the datetime columns to accept null.
* *

View File

@ -27,11 +27,17 @@ class Payment_Status extends Enum {
const __default = 'pending'; // phpcs:ignore const __default = 'pending'; // phpcs:ignore
const PENDING = 'pending'; const PENDING = 'pending';
const COMPLETED = 'completed'; const COMPLETED = 'completed';
const REFUND = 'refunded'; const REFUND = 'refunded';
const PARTIAL_REFUND = 'partially-refunded'; const PARTIAL_REFUND = 'partially-refunded';
const PARTIAL = 'partially-paid'; const PARTIAL = 'partially-paid';
const FAILED = 'failed'; const FAILED = 'failed';
const CANCELLED = 'cancelled'; const CANCELLED = 'cancelled';
/** /**

View File

@ -155,6 +155,7 @@ final class Payments_Table extends Table {
// Return success/fail // Return success/fail
return $this->is_success($result); return $this->is_success($result);
} }
/** /**
* Fixes the datetime columns to accept null. * Fixes the datetime columns to accept null.
* *

View File

@ -88,6 +88,7 @@ final class Posts_Table extends Table {
status varchar(100) NOT NULL default 'draft', status varchar(100) NOT NULL default 'draft',
PRIMARY KEY (id)"; PRIMARY KEY (id)";
} }
/** /**
* Fixes the datetime columns to accept null. * Fixes the datetime columns to accept null.
* *

View File

@ -27,7 +27,9 @@ class Product_Type extends Enum {
const __default = 'plan'; // phpcs:ignore const __default = 'plan'; // phpcs:ignore
const PLAN = 'plan'; const PLAN = 'plan';
const PACKAGE = 'package'; const PACKAGE = 'package';
const SERVICE = 'service'; const SERVICE = 'service';
/** /**

View File

@ -154,6 +154,7 @@ final class Products_Table extends Table {
// Return success/fail // Return success/fail
return $this->is_success($result); return $this->is_success($result);
} }
/** /**
* Fixes the datetime columns to accept null. * Fixes the datetime columns to accept null.
* *

View File

@ -27,10 +27,15 @@ class Site_Type extends Enum {
const __default = 'default'; // phpcs:ignore const __default = 'default'; // phpcs:ignore
const REGULAR = 'default'; const REGULAR = 'default';
const SITE_TEMPLATE = 'site_template'; const SITE_TEMPLATE = 'site_template';
const CUSTOMER_OWNED = 'customer_owned'; const CUSTOMER_OWNED = 'customer_owned';
const PENDING = 'pending'; const PENDING = 'pending';
const EXTERNAL = 'external'; const EXTERNAL = 'external';
const MAIN = 'main'; const MAIN = 'main';
/** /**

View File

@ -94,6 +94,7 @@ final class Webhooks_Table extends Table {
// phpcs:enable // phpcs:enable
} }
/** /**
* Fixes the datetime columns to accept null. * Fixes the datetime columns to accept null.
* *

View File

@ -718,7 +718,7 @@ class Debug {
); );
} }
if ($result === false) { if (false === $result) {
throw new \Exception("Error $table"); throw new \Exception("Error $table");
} }
} }

View File

@ -570,6 +570,7 @@ class WU_Util {
return $signups; return $signups;
} }
/** /**
* Deprecated: users_on_trial * Deprecated: users_on_trial
* *
@ -656,9 +657,9 @@ class WU_Logger {
$alternative = "\\WP_Ultimo\\Logger::$method_name"; $alternative = "\\WP_Ultimo\\Logger::$method_name";
if ($method_name === 'add') { if ('add' === $method_name) {
$alternative = 'wu_log_add'; $alternative = 'wu_log_add';
} elseif ($method_name === 'clear') { } elseif ('clear' === $method_name) {
$alternative = 'wu_log_clear'; $alternative = 'wu_log_clear';
} }
@ -873,7 +874,7 @@ class WU_Coupon extends \WP_Ultimo\Models\Discount_Code {
*/ */
public function after_set($key, $value): void { public function after_set($key, $value): void {
if ($key === 'title') { if ('title' === $key) {
$this->set_code($value); $this->set_code($value);
$this->set_name($value); $this->set_name($value);
@ -931,7 +932,7 @@ class WU_Plan extends \WP_Ultimo\Models\Product {
*/ */
public function __get($key) { public function __get($key) {
if ($key === 'price_1') { if ('price_1' === $key) {
return $this->get_amount(); return $this->get_amount();
} }
@ -952,7 +953,7 @@ class WU_Plan extends \WP_Ultimo\Models\Product {
*/ */
public function after_set($key, $value): void { public function after_set($key, $value): void {
if ($key === 'price_1') { if ('price_1' === $key) {
$this->set_amount($value); $this->set_amount($value);
} }
} }
@ -1147,9 +1148,10 @@ class WU_Transactions {
$date = new \DateTime(); $date = new \DateTime();
return $type === 'mysql' ? $date->format('Y-m-d H:i:s') : $date->format('U'); return 'mysql' === $type ? $date->format('Y-m-d H:i:s') : $date->format('U');
} }
} }
/* /*
* Functions * Functions
*/ */
@ -1216,6 +1218,7 @@ function wu_get_plan_by_slug($plan_slug) {
return wu_get_product_by_slug($plan_slug); return wu_get_product_by_slug($plan_slug);
} }
/** /**
* Deprecated: Returns a subscription object based on the user. * Deprecated: Returns a subscription object based on the user.
* *
@ -1234,6 +1237,7 @@ function wu_get_subscription($user_id) {
return wu_get_membership_by('user_id', $user_id); return wu_get_membership_by('user_id', $user_id);
} }
/** /**
* Deprecated: Returns a subscription object based on the integration key. * Deprecated: Returns a subscription object based on the integration key.
* *
@ -1248,6 +1252,7 @@ function wu_get_subscription_by_integration_key($integration_key) {
return wu_get_membership_by('gateway_subscription_id', $integration_key); return wu_get_membership_by('gateway_subscription_id', $integration_key);
} }
/** /**
* Deprecated: Return a subscription object based on the current user. * Deprecated: Return a subscription object based on the current user.
* *
@ -1280,7 +1285,7 @@ function wu_is_active_subscriber($user_id = false) {
_deprecated_function(__FUNCTION__, '2.0.0'); _deprecated_function(__FUNCTION__, '2.0.0');
if ($user_id === false) { if (false === $user_id) {
$membership = wu_get_current_site()->get_membership(); $membership = wu_get_current_site()->get_membership();
} else { } else {
$membership = wu_get_membership_by('user_id', get_current_user_id()); $membership = wu_get_membership_by('user_id', get_current_user_id());
@ -1335,6 +1340,7 @@ function wu_get_active_gateway() {
return reset($active_gateways); return reset($active_gateways);
} }
/** /**
* Deprecated: Generates the price description. * Deprecated: Generates the price description.
* *

View File

@ -123,7 +123,7 @@ class Toolkit {
$class_name = str_replace('_', '-', strtolower($path)); $class_name = str_replace('_', '-', strtolower($path));
$args = $manager->get_arguments_schema($context === 'update'); $args = $manager->get_arguments_schema('update' === $context);
file_put_contents(wu_path("/mpb/data/endpoint/.endpoint-$class_name-$context"), json_encode($args)); // phpcs:ignore file_put_contents(wu_path("/mpb/data/endpoint/.endpoint-$class_name-$context"), json_encode($args)); // phpcs:ignore
} }
@ -214,7 +214,7 @@ class Toolkit {
*/ */
public function die($should_die = true): void { public function die($should_die = true): void {
if ($should_die === true) { if (true === $should_die) {
$should_die = is_admin() ? 'admin_enqueue_scripts' : 'wp_enqueue_scripts'; $should_die = is_admin() ? 'admin_enqueue_scripts' : 'wp_enqueue_scripts';
} }
@ -234,9 +234,9 @@ class Toolkit {
$listener = wu_request(self::LISTENER_PARAM, 'no-dev-param'); $listener = wu_request(self::LISTENER_PARAM, 'no-dev-param');
if ($listener === 'no-dev-param') { if ('no-dev-param' === $listener) {
return current($arguments); return current($arguments);
} elseif ($listener === '') { } elseif ('' === $listener) {
$listener = 'index'; $listener = 'index';
} }

View File

@ -62,6 +62,7 @@ class Helper {
*/ */
return apply_filters('wu_is_development_mode', $is_development_mode, $site_url); return apply_filters('wu_is_development_mode', $is_development_mode, $site_url);
} }
/** /**
* Gets the local IP address of the network. * Gets the local IP address of the network.
* *
@ -137,6 +138,7 @@ class Helper {
*/ */
return apply_filters('wu_get_network_public_ip', $_ip_address, false); return apply_filters('wu_get_network_public_ip', $_ip_address, false);
} }
/** /**
* Checks if a given domain name has a valid associated SSL certificate. * Checks if a given domain name has a valid associated SSL certificate.
* *

View File

@ -139,7 +139,7 @@ class Primary_Domain {
$redirect_settings = wu_get_setting('force_admin_redirect', 'both'); $redirect_settings = wu_get_setting('force_admin_redirect', 'both');
if ($redirect_settings === 'both') { if ('both' === $redirect_settings) {
return; return;
} }
@ -159,11 +159,11 @@ class Primary_Domain {
$redirect_url = false; $redirect_url = false;
if ($redirect_settings === 'force_map' && $current_url_to_compare !== $mapped_url_to_compare) { if ('force_map' === $redirect_settings && $current_url_to_compare !== $mapped_url_to_compare) {
$redirect_url = Domain_Mapping::get_instance()->replace_url(wu_get_current_url(), $mapped_domain); $redirect_url = Domain_Mapping::get_instance()->replace_url(wu_get_current_url(), $mapped_domain);
$query_args = array_map(fn($value) => Domain_Mapping::get_instance()->replace_url($value, $mapped_domain), $query_args); $query_args = array_map(fn($value) => Domain_Mapping::get_instance()->replace_url($value, $mapped_domain), $query_args);
} elseif ($redirect_settings === 'force_network' && $current_url_to_compare === $mapped_url_to_compare) { } elseif ('force_network' === $redirect_settings && $current_url_to_compare === $mapped_url_to_compare) {
$redirect_url = wu_restore_original_url(wu_get_current_url(), $site->get_id()); $redirect_url = wu_restore_original_url(wu_get_current_url(), $site->get_id());
$query_args = array_map(fn($value) => wu_restore_original_url($value, $site->get_id()), $query_args); $query_args = array_map(fn($value) => wu_restore_original_url($value, $site->get_id()), $query_args);

View File

@ -78,7 +78,7 @@ if ( ! class_exists('MUCD_Data') ) {
$schema = DB_NAME; $schema = DB_NAME;
// Get sources Tables // Get sources Tables
if ($from_site_id == MUCD_PRIMARY_SITE_ID) { if (MUCD_PRIMARY_SITE_ID == $from_site_id) {
$from_site_table = self::get_primary_tables($from_site_prefix); $from_site_table = self::get_primary_tables($from_site_prefix);
} else { } else {
$sql_query = $wpdb->prepare('SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = \'%s\' AND TABLE_NAME LIKE \'%s\'', $schema, $from_site_prefix_like . '%'); $sql_query = $wpdb->prepare('SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = \'%s\' AND TABLE_NAME LIKE \'%s\'', $schema, $from_site_prefix_like . '%');
@ -319,10 +319,11 @@ if ( ! class_exists('MUCD_Data') ) {
$new = $val; $new = $val;
if (is_string($val)) { if (is_string($val)) {
$pos = strpos($val, $to_string); $pos = strpos($val, $to_string);
if ($pos === false) { if (false === $pos) {
$new = str_replace($from_string, $to_string, $val); $new = str_replace($from_string, $to_string, $val);
} }
} }
return $new; return $new;
} }
@ -398,6 +399,7 @@ if ( ! class_exists('MUCD_Data') ) {
} else { } else {
$row[ $field ] = self::replace($row[ $field ], $from_string, $to_string); $row[ $field ] = self::replace($row[ $field ], $from_string, $to_string);
} }
return $row[ $field ]; return $row[ $field ];
} }

View File

@ -77,7 +77,7 @@ if ( ! class_exists('MUCD_Duplicate') ) {
self::bypass_server_limit(); self::bypass_server_limit();
// Copy Site - File // Copy Site - File
if ($copy_file == 'yes') { if ('yes' == $copy_file) {
do_action('mucd_before_copy_files', $from_site_id, $to_site_id); do_action('mucd_before_copy_files', $from_site_id, $to_site_id);
$result = MUCD_Files::copy_files($from_site_id, $to_site_id); $result = MUCD_Files::copy_files($from_site_id, $to_site_id);
do_action('mucd_after_copy_files', $from_site_id, $to_site_id); do_action('mucd_after_copy_files', $from_site_id, $to_site_id);
@ -89,7 +89,7 @@ if ( ! class_exists('MUCD_Duplicate') ) {
do_action('mucd_after_copy_data', $from_site_id, $to_site_id); do_action('mucd_after_copy_data', $from_site_id, $to_site_id);
// Copy Site - Users // Copy Site - Users
if ($keep_users == 'yes') { if ('yes' == $keep_users) {
do_action('mucd_before_copy_users', $from_site_id, $to_site_id); do_action('mucd_before_copy_users', $from_site_id, $to_site_id);
$result = self::copy_users($from_site_id, $to_site_id); $result = self::copy_users($from_site_id, $to_site_id);
do_action('mucd_after_copy_users', $from_site_id, $to_site_id); do_action('mucd_after_copy_users', $from_site_id, $to_site_id);
@ -190,6 +190,7 @@ if ( ! class_exists('MUCD_Duplicate') ) {
continue; continue;
} }
} }
update_user_meta($user->ID, $to_site_prefix . $raw_meta_name, maybe_unserialize($metavalue)); update_user_meta($user->ID, $to_site_prefix . $raw_meta_name, maybe_unserialize($metavalue));
} }
} }
@ -211,8 +212,9 @@ if ( ! class_exists('MUCD_Duplicate') ) {
if (isset($data['log-path']) && ! empty($data['log-path'])) { if (isset($data['log-path']) && ! empty($data['log-path'])) {
$log_name = @date('Y_m_d_His') . '-' . $data['domain'] . '.log'; $log_name = @date('Y_m_d_His') . '-' . $data['domain'] . '.log';
if (! str_ends_with((string) $data['log-path'], '/')) { if (! str_ends_with((string) $data['log-path'], '/')) {
$data['log-path'] = $data['log-path'] . '/'; $data['log-path'] .= '/';
} }
self::$log = new MUCD_Log(true, $data['log-path'], $log_name); self::$log = new MUCD_Log(true, $data['log-path'], $log_name);
} }
} else { } else {
@ -273,6 +275,7 @@ if ( ! class_exists('MUCD_Duplicate') ) {
if (self::log() !== false) { if (self::log() !== false) {
return self::$log->file_url(); return self::$log->file_url();
} }
return false; return false;
} }

View File

@ -16,7 +16,7 @@ if ( ! class_exists('MUCD_Files') ) {
switch_to_blog($from_site_id); switch_to_blog($from_site_id);
$wp_upload_info = wp_upload_dir(); $wp_upload_info = wp_upload_dir();
$from_dir['path'] = $wp_upload_info['basedir']; $from_dir['path'] = $wp_upload_info['basedir'];
$from_site_id == MUCD_PRIMARY_SITE_ID ? $from_dir['exclude'] = MUCD_Option::get_primary_dir_exclude() : $from_dir['exclude'] = []; MUCD_PRIMARY_SITE_ID == $from_site_id ? $from_dir['exclude'] = MUCD_Option::get_primary_dir_exclude() : $from_dir['exclude'] = [];
// Switch to Destination site and get uploads info // Switch to Destination site and get uploads info
switch_to_blog($to_site_id); switch_to_blog($to_site_id);
@ -38,6 +38,7 @@ if ( ! class_exists('MUCD_Files') ) {
if (isset($dir['to_dir_path']) && ! self::init_dir($dir['to_dir_path'])) { if (isset($dir['to_dir_path']) && ! self::init_dir($dir['to_dir_path'])) {
self::mkdir_error($dir['to_dir_path']); self::mkdir_error($dir['to_dir_path']);
} }
MUCD_Duplicate::write_log('Copy files from ' . $dir['from_dir_path'] . ' to ' . $dir['to_dir_path']); MUCD_Duplicate::write_log('Copy files from ' . $dir['from_dir_path'] . ' to ' . $dir['to_dir_path']);
self::recurse_copy($dir['from_dir_path'], $dir['to_dir_path'], $dir['exclude_dirs']); self::recurse_copy($dir['from_dir_path'], $dir['to_dir_path'], $dir['exclude_dirs']);
} }
@ -59,7 +60,7 @@ if ( ! class_exists('MUCD_Files') ) {
$dir = opendir($src); $dir = opendir($src);
@mkdir($dst); @mkdir($dst);
while (false !== ($file = readdir($dir)) ) { while (false !== ($file = readdir($dir)) ) {
if (($file != '.') && ($file != '..')) { if (('.' != $file) && ('..' != $file)) {
if ( is_dir($src . '/' . $file) ) { if ( is_dir($src . '/' . $file) ) {
if ( ! in_array($file, $exclude_dirs)) { if ( ! in_array($file, $exclude_dirs)) {
self::recurse_copy($src . '/' . $file, $dst . '/' . $file); self::recurse_copy($src . '/' . $file, $dst . '/' . $file);
@ -69,6 +70,7 @@ if ( ! class_exists('MUCD_Files') ) {
} }
} }
} }
closedir($dir); closedir($dir);
} }
@ -88,6 +90,7 @@ if ( ! class_exists('MUCD_Files') ) {
if ( ! is_writable($path)) { if ( ! is_writable($path)) {
return chmod($path, 0777); return chmod($path, 0777);
} }
return true; return true;
} }
@ -106,7 +109,7 @@ if ( ! class_exists('MUCD_Files') ) {
if (is_dir($dir)) { if (is_dir($dir)) {
$objects = scandir($dir); $objects = scandir($dir);
foreach ($objects as $object) { foreach ($objects as $object) {
if ($object != '.' && $object != '..') { if ('.' != $object && '..' != $object) {
if (filetype($dir . '/' . $object) == 'dir') { if (filetype($dir . '/' . $object) == 'dir') {
self::rrmdir($dir . '/' . $object); self::rrmdir($dir . '/' . $object);
} else { } else {
@ -114,6 +117,7 @@ if ( ! class_exists('MUCD_Files') ) {
} }
} }
} }
reset($objects); reset($objects);
rmdir($dir); rmdir($dir);
} }
@ -135,6 +139,7 @@ if ( ! class_exists('MUCD_Files') ) {
if ( $log_url = MUCD_Duplicate::log_url() ) { if ( $log_url = MUCD_Duplicate::log_url() ) {
echo '<a href="' . $log_url . '">' . MUCD_NETWORK_PAGE_DUPLICATE_VIEW_LOG . '</a>'; echo '<a href="' . $log_url . '">' . MUCD_NETWORK_PAGE_DUPLICATE_VIEW_LOG . '</a>';
} }
MUCD_Functions::remove_blog(self::$to_site_id); MUCD_Functions::remove_blog(self::$to_site_id);
wp_die(); wp_die();
} }

View File

@ -15,8 +15,9 @@ if ( ! class_exists('MUCD_Functions') ) {
if (strpos($path, ':') == 1 && preg_match('/[a-zA-Z]/', $path[0])) { if (strpos($path, ':') == 1 && preg_match('/[a-zA-Z]/', $path[0])) {
$tmp = substr($path, 2); $tmp = substr($path, 2);
$bool = preg_match('/^[^*?"<>|:]*$/', $tmp); $bool = preg_match('/^[^*?"<>|:]*$/', $tmp);
return ($bool == 1); // so that it will return only true and false return (1 == $bool); // so that it will return only true and false
} }
return false; return false;
} }
@ -30,7 +31,7 @@ if ( ! class_exists('MUCD_Functions') ) {
public static function valid_unix_dir_path($path) { public static function valid_unix_dir_path($path) {
$reg = '/^(\/([a-zA-Z0-9+$_.-])+)*\/?$/'; $reg = '/^(\/([a-zA-Z0-9+$_.-])+)*\/?$/';
$bool = preg_match($reg, $path); $bool = preg_match($reg, $path);
return ($bool == 1); return (1 == $bool);
} }
/** /**
@ -74,10 +75,7 @@ if ( ! class_exists('MUCD_Functions') ) {
return true; return true;
} }
if ( get_blog_option($blog_id, 'mucd_duplicable', 'no') == 'yes') { return get_blog_option($blog_id, 'mucd_duplicable', 'no') == 'yes';
return true;
}
return false;
} }
/** /**
@ -109,10 +107,11 @@ if ( ! class_exists('MUCD_Functions') ) {
*/ */
public static function value_in_array($value, $array, $key): bool { public static function value_in_array($value, $array, $key): bool {
foreach ($array as $row) { foreach ($array as $row) {
if (isset($row[ $key ]) && $value == $row[ $key ]) { if (isset($row[ $key ]) && $row[ $key ] == $value) {
return true; return true;
} }
} }
return false; return false;
} }
@ -194,6 +193,7 @@ if ( ! class_exists('MUCD_Functions') ) {
foreach ($sites as $key => $site) { foreach ($sites as $key => $site) {
$sites[ $key ] = (array) $site; $sites[ $key ] = (array) $site;
} }
return $sites; return $sites;
} else { } else {
$defaults = ['limit' => MUCD_MAX_NUMBER_OF_SITE]; $defaults = ['limit' => MUCD_MAX_NUMBER_OF_SITE];

View File

@ -8,20 +8,24 @@ if ( ! class_exists('MUCD_Log') ) {
* @readonly * @readonly
*/ */
private string $log_file_path; private string $log_file_path;
/** /**
* @readonly * @readonly
*/ */
private string $log_file_url; private string $log_file_url;
private $fp; private $fp;
/** /**
* @var boolean * @var boolean
*/ */
public $mod; public $mod;
/** /**
* @var string * @var string
*/ */
private $log_dir_path = ''; private $log_dir_path = '';
/** /**
* @var string * @var string
*/ */
@ -43,7 +47,7 @@ if ( ! class_exists('MUCD_Log') ) {
$this->log_file_url = str_replace(ABSPATH, get_site_url(1, '/'), $log_dir_path) . $log_file_name; $this->log_file_url = str_replace(ABSPATH, get_site_url(1, '/'), $log_dir_path) . $log_file_name;
if ( $mod !== false) { if ( false !== $mod) {
$this->init_file(); $this->init_file();
} }
} }
@ -119,9 +123,11 @@ if ( ! class_exists('MUCD_Log') ) {
if ( ! $this->fp = @fopen($this->log_file_path, 'a') ) { if ( ! $this->fp = @fopen($this->log_file_path, 'a') ) {
return false; return false;
} }
chmod($this->log_file_path, 0777); chmod($this->log_file_path, 0777);
return true; return true;
} }
return false; return false;
} }
@ -138,6 +144,7 @@ if ( ! class_exists('MUCD_Log') ) {
fwrite($this->fp, "$time $message" . "\r\n"); fwrite($this->fp, "$time $message" . "\r\n");
return true; return true;
} }
return false; return false;
} }

View File

@ -19,6 +19,7 @@ if ( ! class_exists('MUCD_Option') ) {
$blog_id = $blog['blog_id']; $blog_id = $blog['blog_id'];
add_blog_option($blog_id, 'mucd_duplicable', $blogs_value); add_blog_option($blog_id, 'mucd_duplicable', $blogs_value);
} }
add_site_option('mucd_duplicables', $network_value); add_site_option('mucd_duplicables', $network_value);
} }
@ -34,6 +35,7 @@ if ( ! class_exists('MUCD_Option') ) {
$blog_id = $blog['blog_id']; $blog_id = $blog['blog_id'];
delete_blog_option($blog_id, 'mucd_duplicable'); delete_blog_option($blog_id, 'mucd_duplicable');
} }
delete_site_option('mucd_duplicables'); delete_site_option('mucd_duplicables');
} }

View File

@ -114,7 +114,7 @@ function wu_array_recursive_diff($array1, $array2, $to_keep = []) {
if (count($array_recursive_diff)) { if (count($array_recursive_diff)) {
$arr_return[ $key ] = $array_recursive_diff; $arr_return[ $key ] = $array_recursive_diff;
} }
} elseif ((! is_null($value) && $value != $array2[ $key ]) || ($value && $array2[ $key ] && in_array($key, $to_keep, true))) { } elseif ((! is_null($value) && $array2[ $key ] != $value) || ($value && $array2[ $key ] && in_array($key, $to_keep, true))) {
// phpcs:ignore // phpcs:ignore
$arr_return[ $key ] = $value; $arr_return[ $key ] = $value;
@ -126,6 +126,7 @@ function wu_array_recursive_diff($array1, $array2, $to_keep = []) {
return $arr_return; return $arr_return;
} }
/** /**
* Array map implementation to deal with keys. * Array map implementation to deal with keys.
* *

View File

@ -37,6 +37,7 @@ function wu_get_checkout_forms($query = []) {
return \WP_Ultimo\Models\Checkout_Form::query($query); return \WP_Ultimo\Models\Checkout_Form::query($query);
} }
/** /**
* Returns a checkout_form based on slug. * Returns a checkout_form based on slug.
* *
@ -56,7 +57,7 @@ function wu_get_checkout_form_by_slug($checkout_form_slug) {
* *
* @see wu_checkout_form_membership_change_form_fields filter. * @see wu_checkout_form_membership_change_form_fields filter.
*/ */
if ($checkout_form_slug === 'wu-checkout') { if ('wu-checkout' === $checkout_form_slug) {
$checkout_form = new \WP_Ultimo\Models\Checkout_Form(); $checkout_form = new \WP_Ultimo\Models\Checkout_Form();
$checkout_fields = Checkout_Form::membership_change_form_fields(); $checkout_fields = Checkout_Form::membership_change_form_fields();
@ -64,7 +65,7 @@ function wu_get_checkout_form_by_slug($checkout_form_slug) {
$checkout_form->set_settings($checkout_fields); $checkout_form->set_settings($checkout_fields);
return $checkout_form; return $checkout_form;
} elseif ($checkout_form_slug === 'wu-add-new-site') { } elseif ('wu-add-new-site' === $checkout_form_slug) {
$checkout_form = new \WP_Ultimo\Models\Checkout_Form(); $checkout_form = new \WP_Ultimo\Models\Checkout_Form();
$checkout_fields = Checkout_Form::add_new_site_form_fields(); $checkout_fields = Checkout_Form::add_new_site_form_fields();
@ -72,7 +73,7 @@ function wu_get_checkout_form_by_slug($checkout_form_slug) {
$checkout_form->set_settings($checkout_fields); $checkout_form->set_settings($checkout_fields);
return $checkout_form; return $checkout_form;
} elseif ($checkout_form_slug === 'wu-finish-checkout') { } elseif ('wu-finish-checkout' === $checkout_form_slug) {
$checkout_form = new \WP_Ultimo\Models\Checkout_Form(); $checkout_form = new \WP_Ultimo\Models\Checkout_Form();
$checkout_fields = Checkout_Form::finish_checkout_form_fields(); $checkout_fields = Checkout_Form::finish_checkout_form_fields();
@ -84,6 +85,7 @@ function wu_get_checkout_form_by_slug($checkout_form_slug) {
return \WP_Ultimo\Models\Checkout_Form::get_by('slug', $checkout_form_slug); return \WP_Ultimo\Models\Checkout_Form::get_by('slug', $checkout_form_slug);
} }
/** /**
* Creates a new checkout form. * Creates a new checkout form.
* *

View File

@ -97,12 +97,12 @@ function wu_create_checkout_fields($fields = []) {
*/ */
$visibility = wu_get_isset($field, 'logged', 'always'); $visibility = wu_get_isset($field, 'logged', 'always');
if ($visibility !== 'always') { if ('always' !== $visibility) {
if ($visibility === 'guests_only' && is_user_logged_in()) { if ('guests_only' === $visibility && is_user_logged_in()) {
continue; continue;
} }
if ($visibility === 'logged_only' && ! is_user_logged_in()) { if ('logged_only' === $visibility && ! is_user_logged_in()) {
continue; continue;
} }
} }
@ -174,6 +174,7 @@ function wu_get_registration_url($path = false) {
return $url . $path; return $url . $path;
} }
/** /**
* Returns the URL for the login page. * Returns the URL for the login page.
* *

View File

@ -23,6 +23,7 @@ function wu_get_customer($customer_id) {
return \WP_Ultimo\Models\Customer::get_by_id($customer_id); return \WP_Ultimo\Models\Customer::get_by_id($customer_id);
} }
/** /**
* Returns a single customer defined by a particular column and value. * Returns a single customer defined by a particular column and value.
* *
@ -36,6 +37,7 @@ function wu_get_customer_by($column, $value) {
return \WP_Ultimo\Models\Customer::get_by($column, $value); return \WP_Ultimo\Models\Customer::get_by($column, $value);
} }
/** /**
* Gets a customer based on the hash. * Gets a customer based on the hash.
* *
@ -83,6 +85,7 @@ function wu_get_customers($query = []) {
return \WP_Ultimo\Models\Customer::query($query); return \WP_Ultimo\Models\Customer::query($query);
} }
/** /**
* Returns a customer based on user_id. * Returns a customer based on user_id.
* *
@ -95,6 +98,7 @@ function wu_get_customer_by_user_id($user_id) {
return \WP_Ultimo\Models\Customer::get_by('user_id', $user_id); return \WP_Ultimo\Models\Customer::get_by('user_id', $user_id);
} }
/** /**
* Returns the current customer. * Returns the current customer.
* *
@ -105,6 +109,7 @@ function wu_get_current_customer() {
return wu_get_customer_by_user_id(get_current_user_id()); return wu_get_customer_by_user_id(get_current_user_id());
} }
/** /**
* Creates a new customer. * Creates a new customer.
* *
@ -154,7 +159,7 @@ function wu_create_customer($customer_data) {
return $user_id; return $user_id;
} }
if ($user_id === false) { if (false === $user_id) {
return new \WP_Error('user', __('We were not able to create a new user with the provided username and email address combination.', 'wp-ultimo'), $customer_data); return new \WP_Error('user', __('We were not able to create a new user with the provided username and email address combination.', 'wp-ultimo'), $customer_data);
} }
} else { } else {

View File

@ -127,6 +127,7 @@ function wu_filter_duration_unit($unit, $length) {
return $new_unit; return $new_unit;
} }
/** /**
* Get the human time diff. * Get the human time diff.
* *
@ -148,7 +149,7 @@ function wu_human_time_diff($from, $limit = '-5 days', $to = false): string {
return sprintf(__('on %s', 'wp-ultimo'), date_i18n(get_option('date_format'), $timestamp_from)); return sprintf(__('on %s', 'wp-ultimo'), date_i18n(get_option('date_format'), $timestamp_from));
} }
if ($to === false) { if (false === $to) {
$to = wu_get_current_time('timestamp'); // phpcs:ignore $to = wu_get_current_time('timestamp'); // phpcs:ignore
} }

View File

@ -23,6 +23,7 @@ function wu_get_discount_code_by_code($coupon_code) {
return \WP_Ultimo\Models\Discount_Code::get_by('code', $coupon_code); return \WP_Ultimo\Models\Discount_Code::get_by('code', $coupon_code);
} }
/** /**
* Gets a discount code based on the ID. * Gets a discount code based on the ID.
* *
@ -48,6 +49,7 @@ function wu_get_discount_codes($query = []) {
return \WP_Ultimo\Models\Discount_Code::query($query); return \WP_Ultimo\Models\Discount_Code::query($query);
} }
/** /**
* Calculates the discounted price after running it through the discount code. * Calculates the discounted price after running it through the discount code.
* *
@ -61,9 +63,9 @@ function wu_get_discount_codes($query = []) {
*/ */
function wu_get_discounted_price($base_price, $amount, $type, $format = true) { function wu_get_discounted_price($base_price, $amount, $type, $format = true) {
if ($type === 'percentage') { if ('percentage' === $type) {
$discounted_price = $base_price - ($base_price * ($amount / 100)); $discounted_price = $base_price - ($base_price * ($amount / 100));
} elseif ($type === 'absolute') { } elseif ('absolute' === $type) {
$discounted_price = $base_price - $amount; $discounted_price = $base_price - $amount;
} }
@ -73,6 +75,7 @@ function wu_get_discounted_price($base_price, $amount, $type, $format = true) {
return number_format((float) $discounted_price, 2); return number_format((float) $discounted_price, 2);
} }
/** /**
* Creates a new discount code. * Creates a new discount code.
* *

View File

@ -36,6 +36,7 @@ function wu_get_domains($query = []) {
return \WP_Ultimo\Models\Domain::query($query); return \WP_Ultimo\Models\Domain::query($query);
} }
/** /**
* Returns a domain based on domain. * Returns a domain based on domain.
* *
@ -48,6 +49,7 @@ function wu_get_domain_by_domain($domain) {
return \WP_Ultimo\Models\Domain::get_by('domain', $domain); return \WP_Ultimo\Models\Domain::get_by('domain', $domain);
} }
/** /**
* Creates a new domain. * Creates a new domain.
* *

View File

@ -95,6 +95,7 @@ function wu_get_events($query = []) {
return \WP_Ultimo\Models\Event::query($query); return \WP_Ultimo\Models\Event::query($query);
} }
/** /**
* Gets a event on the ID. * Gets a event on the ID.
* *
@ -107,6 +108,7 @@ function wu_get_event($event_id) {
return \WP_Ultimo\Models\Event::get_by_id($event_id); return \WP_Ultimo\Models\Event::get_by_id($event_id);
} }
/** /**
* Returns a event based on slug. * Returns a event based on slug.
* *
@ -119,6 +121,7 @@ function wu_get_event_by_slug($event_slug) {
return \WP_Ultimo\Models\Event::get_by('slug', $event_slug); return \WP_Ultimo\Models\Event::get_by('slug', $event_slug);
} }
/** /**
* Creates a new event. * Creates a new event.
* *
@ -199,7 +202,7 @@ function wu_generate_event_payload($model_name, $model = false): array {
} }
} }
if ($model_name === 'customer') { if ('customer' === $model_name) {
$payload = $model->to_search_results(); $payload = $model->to_search_results();
$payload = [ $payload = [
@ -217,7 +220,7 @@ function wu_generate_event_payload($model_name, $model = false): array {
] ]
), ),
]; ];
} elseif ($model_name === 'membership') { } elseif ('membership' === $model_name) {
$payload = $model->to_search_results(); $payload = $model->to_search_results();
$p = $payload; $p = $payload;
@ -241,7 +244,7 @@ function wu_generate_event_payload($model_name, $model = false): array {
] ]
), ),
]; ];
} elseif ($model_name === 'product') { } elseif ('product' === $model_name) {
$payload = $model->to_search_results(); $payload = $model->to_search_results();
$payload = [ $payload = [
@ -260,7 +263,7 @@ function wu_generate_event_payload($model_name, $model = false): array {
] ]
), ),
]; ];
} elseif ($model_name === 'payment') { } elseif ('payment' === $model_name) {
$payload = $model->to_search_results(); $payload = $model->to_search_results();
$payload = [ $payload = [
@ -285,7 +288,7 @@ function wu_generate_event_payload($model_name, $model = false): array {
] ]
), ),
]; ];
} elseif ($model_name === 'site') { } elseif ('site' === $model_name) {
$payload = $model->to_search_results(); $payload = $model->to_search_results();
$payload = [ $payload = [
@ -301,7 +304,7 @@ function wu_generate_event_payload($model_name, $model = false): array {
] ]
), ),
]; ];
} elseif ($model_name === 'domain') { } elseif ('domain' === $model_name) {
$payload = $model->to_search_results(); $payload = $model->to_search_results();
$payload = [ $payload = [

View File

@ -61,7 +61,7 @@ function wu_maybe_create_folder($folder, ...$path) {
if ( ! file_exists($htaccess)) { if ( ! file_exists($htaccess)) {
$fp = @fopen($htaccess, 'w'); $fp = @fopen($htaccess, 'w');
@fputs($fp, 'deny from all'); // phpcs:ignore @fwrite($fp, 'deny from all'); // phpcs:ignore
@fclose($fp); // phpcs:ignore @fclose($fp); // phpcs:ignore
} }
@ -72,7 +72,7 @@ function wu_maybe_create_folder($folder, ...$path) {
if ( ! file_exists($index)) { if ( ! file_exists($index)) {
$fp = @fopen($index, 'w'); $fp = @fopen($index, 'w');
@fputs($fp, ''); // phpcs:ignore @fwrite($fp, ''); // phpcs:ignore
@fclose($fp); // phpcs:ignore @fclose($fp); // phpcs:ignore
} }

View File

@ -100,7 +100,7 @@ function wu_get_gateway_as_options() {
foreach (wu_get_gateways() as $gateway_slug => $gateway) { foreach (wu_get_gateways() as $gateway_slug => $gateway) {
$instance = class_exists($gateway['class_name']) ? new $gateway['class_name']() : false; $instance = class_exists($gateway['class_name']) ? new $gateway['class_name']() : false;
if ($instance === false || $gateway['hidden']) { if (false === $instance || $gateway['hidden']) {
continue; continue;
} }
@ -123,7 +123,7 @@ function wu_get_active_gateway_as_options() {
foreach (wu_get_active_gateways() as $gateway_slug => $gateway) { foreach (wu_get_active_gateways() as $gateway_slug => $gateway) {
$instance = class_exists($gateway['class_name']) ? new $gateway['class_name']() : false; $instance = class_exists($gateway['class_name']) ? new $gateway['class_name']() : false;
if ($instance === false || $gateway['hidden']) { if (false === $instance || $gateway['hidden']) {
continue; continue;
} }

View File

@ -98,6 +98,7 @@ function wu_slugify($term) {
return "wp-ultimo_$term"; return "wp-ultimo_$term";
} }
/** /**
* Returns the full path to the plugin folder. * Returns the full path to the plugin folder.
* *
@ -168,7 +169,7 @@ function wu_are_code_comments_available() {
static $res; static $res;
if ($res === null) { if (null === $res) {
$res = (bool) (new \ReflectionFunction(__FUNCTION__))->getDocComment(); $res = (bool) (new \ReflectionFunction(__FUNCTION__))->getDocComment();
} }
@ -184,7 +185,7 @@ function wu_are_code_comments_available() {
*/ */
function wu_path_join(...$parts): string { function wu_path_join(...$parts): string {
if (sizeof($parts) === 0) { if (count($parts) === 0) {
return ''; return '';
} }
@ -255,6 +256,7 @@ function wu_get_function_caller($depth = 1) {
return $caller; return $caller;
} }
/** /**
* Checks if a particular plugin is skipped in a CLI context. * Checks if a particular plugin is skipped in a CLI context.
* *

View File

@ -382,8 +382,7 @@ function wu_print_signup_field($field_slug, $field, $results) {
case 'checkbox': case 'checkbox':
$checked = isset($field['check_if']) && isset($result[$field['check_if']]) $checked = isset($field['check_if']) && isset($result[$field['check_if']])
|| (isset($field['check_if']) && isset($_POST[$field['check_if']]) && $_POST[$field['check_if']]) || (isset($field['check_if']) && isset($_POST[$field['check_if']]) && $_POST[$field['check_if']])
|| (isset($field['checked']) && $field['checked']) || (isset($field['checked']) && $field['checked']);
? true : false;
?> ?>
<p> <p>

View File

@ -54,6 +54,7 @@ function wu_remove_empty_p($content): ?string {
return preg_replace('#<p>(\s|&nbsp;)*+(<br\s*/*>)*(\s|&nbsp;)*</p>#i', '', $content); return preg_replace('#<p>(\s|&nbsp;)*+(<br\s*/*>)*(\s|&nbsp;)*</p>#i', '', $content);
} }
/** /**
* Generates a string containing html attributes to be used inside html tags. * Generates a string containing html attributes to be used inside html tags.
* *
@ -107,6 +108,7 @@ function wu_tooltip($tooltip, $icon = 'dashicons-editor-help') {
return $markup; return $markup;
} }
/** /**
* Adds a tooltip to a HTML element. Needs to be echo'ed. * Adds a tooltip to a HTML element. Needs to be echo'ed.
* *
@ -118,6 +120,7 @@ function wu_tooltip_text($tooltip): string {
return sprintf('role="tooltip" aria-label="%s"', esc_attr($tooltip)); return sprintf('role="tooltip" aria-label="%s"', esc_attr($tooltip));
} }
/** /**
* Adds a preview tag that displays the image passed on hover. * Adds a preview tag that displays the image passed on hover.
* *

View File

@ -26,6 +26,7 @@ function wu_get_membership($membership_id) {
return Membership::get_by_id($membership_id); return Membership::get_by_id($membership_id);
} }
/** /**
* Returns a single membership defined by a particular column and value. * Returns a single membership defined by a particular column and value.
* *
@ -39,6 +40,7 @@ function wu_get_membership_by($column, $value) {
return Membership::get_by($column, $value); return Membership::get_by($column, $value);
} }
/** /**
* Gets a membership based on the hash. * Gets a membership based on the hash.
* *
@ -79,6 +81,7 @@ function wu_get_memberships($query = []) {
return Membership::query($query); return Membership::query($query);
} }
/** /**
* Creates a new membership. * Creates a new membership.
* *
@ -165,6 +168,7 @@ function wu_get_membership_customers($product_id) {
return $results; return $results;
} }
/** /**
* Returns a membership based on the customer gateway ID. * Returns a membership based on the customer gateway ID.
* *
@ -267,6 +271,7 @@ function wu_get_membership_product_price($membership, $product_id, $quantity, $o
return $temp_payment->get_total(); return $temp_payment->get_total();
} }
/** /**
* Creates a new payment for a membership. * Creates a new payment for a membership.
* *

View File

@ -81,7 +81,7 @@ function wu_model_get_required_fields($class_name) {
$validation_rules = (new $class_name())->validation_rules(); $validation_rules = (new $class_name())->validation_rules();
foreach ($validation_rules as $field => $validation_rule) { foreach ($validation_rules as $field => $validation_rule) {
if (str_contains((string) $validation_rule, 'required|') || $validation_rule === 'required') { if (str_contains((string) $validation_rule, 'required|') || 'required' === $validation_rule) {
$required_fields[] = $field; $required_fields[] = $field;
} }
} }

View File

@ -119,7 +119,7 @@ function wu_is_login_page() {
$is_login_element_present = \WP_Ultimo\UI\Login_Form_Element::get_instance()->is_actually_loaded(); $is_login_element_present = \WP_Ultimo\UI\Login_Form_Element::get_instance()->is_actually_loaded();
$is_default_wp_login = $pagenow === 'wp-login.php'; $is_default_wp_login = 'wp-login.php' === $pagenow;
return $is_login_element_present || $is_default_wp_login; return $is_login_element_present || $is_default_wp_login;
} }

Some files were not shown because too many files have changed in this diff Show More