Everywhere yoda conditions are
This commit is contained in:
@ -533,6 +533,7 @@ class Cart implements \JsonSerializable {
|
||||
|
||||
$this->cart_descriptor = $descriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decides if we are trying to recover a payment.
|
||||
*
|
||||
@ -707,6 +708,7 @@ class Cart implements \JsonSerializable {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses the membership to decide if this is a upgrade/downgrade/addon cart.
|
||||
*
|
||||
@ -1050,6 +1052,7 @@ class Cart implements \JsonSerializable {
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for variations of the plans with same duration.
|
||||
*
|
||||
@ -1235,6 +1238,7 @@ class Cart implements \JsonSerializable {
|
||||
|
||||
$this->add_line_item($credit_line_item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a discount code to the cart.
|
||||
*
|
||||
@ -1485,6 +1489,7 @@ class Cart implements \JsonSerializable {
|
||||
|
||||
krsort($this->line_items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new product to the cart.
|
||||
*
|
||||
@ -1762,6 +1767,7 @@ class Cart implements \JsonSerializable {
|
||||
|
||||
return $this->recovered_payment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add discount to the order.
|
||||
*
|
||||
@ -1787,6 +1793,7 @@ class Cart implements \JsonSerializable {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get registration fees.
|
||||
*
|
||||
@ -2137,6 +2145,7 @@ class Cart implements \JsonSerializable {
|
||||
|
||||
return $smallest_trial;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the timestamp of the next charge, if recurring.
|
||||
*
|
||||
|
@ -516,7 +516,7 @@ class Checkout_Pages {
|
||||
|
||||
$function_caller = wu_get_function_caller(5);
|
||||
|
||||
if ($function_caller === 'wp_auth_check_html') {
|
||||
if ('wp_auth_check_html' === $function_caller) {
|
||||
return $login_url;
|
||||
}
|
||||
|
||||
|
@ -311,10 +311,10 @@ class Checkout {
|
||||
*
|
||||
* @since 2.0.8
|
||||
*/
|
||||
if ($key === 'template_id') {
|
||||
if ('template_id' === $key) {
|
||||
$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);
|
||||
|
||||
$wp_site = get_site_by_path($d->domain, $d->path);
|
||||
@ -550,6 +550,7 @@ class Checkout {
|
||||
|
||||
wp_send_json_success($results);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process an order.
|
||||
*
|
||||
@ -892,6 +893,7 @@ class Checkout {
|
||||
*/
|
||||
return $success_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
|
||||
if (empty($form_slug) || $form_slug === 'none') {
|
||||
if (empty($form_slug) || 'none' === $form_slug) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1131,6 +1133,7 @@ class Checkout {
|
||||
do_action('wu_handle_user_meta_fields', $user_meta_repository, $user, $customer, $this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a membership exists, otherwise, creates a new one.
|
||||
*
|
||||
@ -1181,6 +1184,7 @@ class Checkout {
|
||||
|
||||
return $membership;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* check if it is already taken.
|
||||
*/
|
||||
if (empty($site_url) || $auto_generate_url === 'username') {
|
||||
if ($auto_generate_url === 'username') {
|
||||
if (empty($site_url) || 'username' === $auto_generate_url) {
|
||||
if ('username' === $auto_generate_url) {
|
||||
$site_url = $this->customer->get_username();
|
||||
|
||||
$site_title = $site_title ?: $site_url;
|
||||
@ -1339,7 +1343,7 @@ class Checkout {
|
||||
*/
|
||||
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 [];
|
||||
}
|
||||
|
||||
@ -1357,6 +1361,7 @@ class Checkout {
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a pending payment exists, otherwise, creates a new one.
|
||||
*
|
||||
@ -1821,7 +1826,7 @@ class Checkout {
|
||||
$stack = array_merge($session, $_REQUEST);
|
||||
}
|
||||
|
||||
if ($rules === null) {
|
||||
if (null === $rules) {
|
||||
$rules = $this->get_validation_rules();
|
||||
}
|
||||
|
||||
@ -2102,7 +2107,7 @@ class Checkout {
|
||||
*
|
||||
* In that case, we simply return.
|
||||
*/
|
||||
if ($status === false) {
|
||||
if (false === $status) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2320,7 +2325,7 @@ class Checkout {
|
||||
* it means that we don't have a step name set
|
||||
* so we need to set it to the first.
|
||||
*/
|
||||
if ($current_step_index === false) {
|
||||
if (false === $current_step_index) {
|
||||
$current_step_index = 0;
|
||||
}
|
||||
|
||||
|
@ -959,12 +959,7 @@ class Legacy_Checkout {
|
||||
public function has_plan_step(): bool {
|
||||
|
||||
$transient = static::get_transient();
|
||||
|
||||
if (isset($transient['skip_plan']) && isset($transient['plan_id']) && isset($transient['plan_freq'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return !(isset($transient['skip_plan']) && isset($transient['plan_id']) && isset($transient['plan_freq']));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1048,9 +1043,9 @@ class Legacy_Checkout {
|
||||
|
||||
$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;
|
||||
$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;
|
||||
}
|
||||
|
||||
@ -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" 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 {
|
||||
|
||||
$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));
|
||||
}
|
||||
@ -1332,7 +1327,7 @@ class Legacy_Checkout {
|
||||
function ($steps) use ($step, $id, $order, $field) {
|
||||
|
||||
// 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'));
|
||||
}
|
||||
|
||||
|
@ -372,6 +372,7 @@ class Line_Item implements \JsonSerializable {
|
||||
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get product associated with this line item.
|
||||
*
|
||||
|
@ -224,7 +224,7 @@ abstract class Base_Signup_Field {
|
||||
$width = (int) wu_get_isset($this->attributes, 'width');
|
||||
|
||||
if ($width) {
|
||||
if ($width !== 100) {
|
||||
if (100 !== $width) {
|
||||
$styles[] = 'float: left';
|
||||
|
||||
$styles[] = sprintf('width: %s%%', $width);
|
||||
@ -332,7 +332,7 @@ abstract class Base_Signup_Field {
|
||||
|
||||
$field['default'] = wu_get_isset($this->defaults(), $key, '');
|
||||
|
||||
if ($value === null) {
|
||||
if (null === $value) {
|
||||
$value = $field['default'];
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ class Signup_Field_Checkbox extends Base_Signup_Field {
|
||||
|
||||
$value = $this->get_value();
|
||||
|
||||
if ($value !== '' && (bool) $value === true) {
|
||||
if ('' !== $value && (bool) $value === true) {
|
||||
$checkout_fields[ $attributes['id'] ]['html_attr']['checked'] = 'checked';
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ class Signup_Field_Order_Summary extends Base_Signup_Field {
|
||||
|
||||
return 'order_summary';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the icon to be used on the selector.
|
||||
*
|
||||
|
@ -33,6 +33,7 @@ class Signup_Field_Period_Selection extends Base_Signup_Field {
|
||||
|
||||
return 'period_selection';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
|
||||
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_enqueue_script('wu-legacy-signup');
|
||||
|
@ -33,6 +33,7 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field {
|
||||
|
||||
return 'pricing_table';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
|
||||
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_add_inline_style('legacy-shortcodes', \WP_Ultimo\Checkout\Legacy_Checkout::get_instance()->get_legacy_dynamic_styles());
|
||||
|
@ -32,6 +32,7 @@ class Signup_Field_Products extends Base_Signup_Field {
|
||||
|
||||
return 'products';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the icon to be used on the selector.
|
||||
*
|
||||
|
@ -32,6 +32,7 @@ class Signup_Field_Shortcode extends Base_Signup_Field {
|
||||
|
||||
return 'shortcode';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the icon to be used on the selector.
|
||||
*
|
||||
|
@ -32,6 +32,7 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
|
||||
|
||||
return 'site_url';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the domain options.
|
||||
*
|
||||
|
@ -33,6 +33,7 @@ class Signup_Field_Steps extends Base_Signup_Field {
|
||||
|
||||
return 'steps';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the icon to be used on the selector.
|
||||
*
|
||||
|
@ -34,6 +34,7 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
|
||||
|
||||
return 'template_selection';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
|
||||
if ($selection_type === 'name') {
|
||||
if ('name' === $selection_type) {
|
||||
return explode(',', $attributes['template_selection_sites']);
|
||||
}
|
||||
|
||||
if ($selection_type === 'all') {
|
||||
if ('all' === $selection_type) {
|
||||
return wu_get_site_templates(['fields' => 'blog_id']);
|
||||
}
|
||||
|
||||
if ($selection_type === 'categories') {
|
||||
if ('categories' === $selection_type) {
|
||||
return array_column(
|
||||
\WP_Ultimo\Models\Site::get_all_by_categories(
|
||||
$attributes['template_selection_categories'],
|
||||
|
@ -29,6 +29,7 @@ class Base_Field_Template {
|
||||
* @var string
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@ -92,6 +93,7 @@ class Base_Field_Template {
|
||||
|
||||
return __('Description', 'wp-ultimo');
|
||||
}
|
||||
|
||||
/**
|
||||
* The preview image of the field template.
|
||||
*
|
||||
|
Reference in New Issue
Block a user