* Update translation text domain * Escape everything that should be escaped. * Add nonce checks where needed. * Sanitize all inputs. * Apply Code style changes across the codebase. * Correct many deprecation notices. * Optimize load order of many filters. * Add Proper Build script * Use emojii flags * Fix i18n deprecation notice for translating too early * Put all scripts in footer and load async
63 lines
1.1 KiB
PHP
63 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* Adds a validation rule for products.
|
|
*
|
|
* @package WP_Ultimo
|
|
* @subpackage Helpers/Validation_Rules
|
|
* @since 2.0.4
|
|
*/
|
|
|
|
namespace WP_Ultimo\Helpers\Validation_Rules;
|
|
|
|
use Rakit\Validation\Rule;
|
|
|
|
// Exit if accessed directly
|
|
defined('ABSPATH') || exit;
|
|
|
|
/**
|
|
* Validates products.
|
|
*
|
|
* @since 2.0.4
|
|
*/
|
|
class Products extends Rule {
|
|
|
|
/**
|
|
* Error message to be returned when this value has been used.
|
|
*
|
|
* @since 2.0.4
|
|
* @var string
|
|
*/
|
|
protected $message = '';
|
|
|
|
/**
|
|
* Parameters that this rule accepts.
|
|
*
|
|
* @since 2.0.4
|
|
* @var array
|
|
*/
|
|
protected $fillableParams = []; // phpcs:ignore
|
|
/**
|
|
* Performs the actual check.
|
|
*
|
|
* @since 2.0.4
|
|
*
|
|
* @param mixed $products Value being checked.
|
|
*/
|
|
public function check($products) : bool { // phpcs:ignore
|
|
|
|
$products = (array) $products;
|
|
|
|
$product_objects = array_map('wu_get_product', $products);
|
|
|
|
[$plan, $additional_products] = wu_segregate_products($product_objects);
|
|
|
|
if ($plan) {
|
|
return true;
|
|
}
|
|
|
|
$this->message = __('A plan is required.', 'wp-multisite-waas');
|
|
|
|
return false;
|
|
}
|
|
}
|