Use PHP 7.4 featers and PHP 8 polyfills
This commit is contained in:
@ -17,11 +17,11 @@ defined('ABSPATH') || exit;
|
||||
* @param array $args List of the page arguments.
|
||||
* @return string
|
||||
*/
|
||||
function wu_render_empty_state($args = array()) {
|
||||
function wu_render_empty_state($args = []) {
|
||||
|
||||
$args = wp_parse_args(
|
||||
$args,
|
||||
array(
|
||||
[
|
||||
'message' => __('This is not yet available...'),
|
||||
'sub_message' => __('We\'re still working on this part of the product.'),
|
||||
'link_label' => __('← Go Back', 'wp-ultimo'),
|
||||
@ -29,7 +29,7 @@ function wu_render_empty_state($args = array()) {
|
||||
'link_classes' => '',
|
||||
'link_icon' => '',
|
||||
'display_background_image' => true,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
return wu_get_template_contents('base/empty-state', $args);
|
||||
@ -55,17 +55,17 @@ function wu_wrap_use_container() {
|
||||
* @param array $second_row The second row, on the right.
|
||||
* @return string
|
||||
*/
|
||||
function wu_responsive_table_row($args = array(), $first_row = array(), $second_row = array()) {
|
||||
function wu_responsive_table_row($args = [], $first_row = [], $second_row = []) {
|
||||
|
||||
$args = wp_parse_args(
|
||||
$args,
|
||||
array(
|
||||
[
|
||||
'id' => '',
|
||||
'title' => __('No Title', 'wp-ultimo'),
|
||||
'url' => '#',
|
||||
'status' => '',
|
||||
'image' => '',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
return wu_get_template_contents('base/responsive-table-row', compact('args', 'first_row', 'second_row'));
|
||||
|
@ -22,7 +22,7 @@ use WP_Ultimo\Helpers\Arr;
|
||||
*/
|
||||
function wu_array_flatten($array, $indexes = false) {
|
||||
|
||||
$return = array();
|
||||
$return = [];
|
||||
|
||||
array_walk_recursive(
|
||||
$array,
|
||||
@ -99,9 +99,9 @@ function wu_array_merge_recursive_distinct(array &$array1, array &$array2, $shou
|
||||
* @param array $to_keep List of keys to keep regardless of diff status.
|
||||
* @return array
|
||||
*/
|
||||
function wu_array_recursive_diff($array1, $array2, $to_keep = array()) {
|
||||
function wu_array_recursive_diff($array1, $array2, $to_keep = []) {
|
||||
|
||||
$arr_return = array();
|
||||
$arr_return = [];
|
||||
|
||||
$array1 = (array) $array1;
|
||||
$array2 = (array) $array2;
|
||||
@ -175,13 +175,13 @@ function wu_array_map_keys($callable, $array): array {
|
||||
*/
|
||||
function wu_key_map_to_array($assoc_array, $key_name = 'id', $value_name = 'value') {
|
||||
|
||||
$results = array();
|
||||
$results = [];
|
||||
|
||||
foreach ($assoc_array as $key => &$value) {
|
||||
$results[] = array(
|
||||
$results[] = [
|
||||
$key_name => $key,
|
||||
$value_name => $value,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
return $results;
|
||||
|
@ -19,10 +19,10 @@ use WP_Ultimo\Models\Broadcast;
|
||||
* @param array $query Query arguments.
|
||||
* @return \WP_Ultimo\Models\Broadcast[]
|
||||
*/
|
||||
function wu_get_broadcasts($query = array()) {
|
||||
function wu_get_broadcasts($query = []) {
|
||||
|
||||
if ( ! isset($query['type__in'])) {
|
||||
$query['type__in'] = array('broadcast_email', 'broadcast_notice');
|
||||
$query['type__in'] = ['broadcast_email', 'broadcast_notice'];
|
||||
}
|
||||
|
||||
return \WP_Ultimo\Models\Broadcast::query($query);
|
||||
@ -45,17 +45,17 @@ function wu_get_broadcast_by($column, $value) {
|
||||
return $first_attempt;
|
||||
}
|
||||
|
||||
$query = array(
|
||||
$query = [
|
||||
'number' => 1,
|
||||
'type__in' => array('broadcast_email', 'broadcast_notice'),
|
||||
);
|
||||
'type__in' => ['broadcast_email', 'broadcast_notice'],
|
||||
];
|
||||
|
||||
$query['meta_query'] = array(
|
||||
array(
|
||||
$query['meta_query'] = [
|
||||
[
|
||||
'key' => $column,
|
||||
'value' => $value,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$results = \WP_Ultimo\Models\Broadcast::query($query);
|
||||
|
||||
@ -96,7 +96,7 @@ function wu_get_broadcast_targets($broadcast_id, $type) {
|
||||
return explode(',', $targets[ $type ]);
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -113,18 +113,18 @@ function wu_create_broadcast($broadcast_data) {
|
||||
|
||||
$broadcast_data = wp_parse_args(
|
||||
$broadcast_data,
|
||||
array(
|
||||
[
|
||||
'type' => 'broadcast_notice',
|
||||
'notice_type' => 'success',
|
||||
'date_created' => wu_get_current_time('mysql', true),
|
||||
'date_modified' => wu_get_current_time('mysql', true),
|
||||
'migrated_from_id' => 0,
|
||||
'skip_validation' => false,
|
||||
'message_targets' => array(
|
||||
'customers' => array(),
|
||||
'products' => array(),
|
||||
),
|
||||
)
|
||||
'message_targets' => [
|
||||
'customers' => [],
|
||||
'products' => [],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$broadcast = new Broadcast($broadcast_data);
|
||||
|
@ -33,7 +33,7 @@ function wu_get_checkout_form($checkout_form_id) {
|
||||
* @param array $query Query arguments.
|
||||
* @return \WP_Ultimo\Models\Checkout_Form[]
|
||||
*/
|
||||
function wu_get_checkout_forms($query = array()) {
|
||||
function wu_get_checkout_forms($query = []) {
|
||||
|
||||
return \WP_Ultimo\Models\Checkout_Form::query($query);
|
||||
}
|
||||
@ -96,14 +96,14 @@ function wu_create_checkout_form($checkout_form_data) {
|
||||
|
||||
$checkout_form_data = wp_parse_args(
|
||||
$checkout_form_data,
|
||||
array(
|
||||
[
|
||||
'name' => false,
|
||||
'slug' => false,
|
||||
'settings' => array(),
|
||||
'allowed_countries' => array(),
|
||||
'settings' => [],
|
||||
'allowed_countries' => [],
|
||||
'date_created' => wu_get_current_time('mysql', true),
|
||||
'date_modified' => wu_get_current_time('mysql', true),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$checkout_form = new Checkout_Form($checkout_form_data);
|
||||
@ -121,7 +121,7 @@ function wu_create_checkout_form($checkout_form_data) {
|
||||
*/
|
||||
function wu_get_available_domain_options() {
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$main_form = wu_get_checkout_form_by_slug('main-form');
|
||||
|
||||
@ -129,9 +129,9 @@ function wu_get_available_domain_options() {
|
||||
$fields = $main_form->get_all_fields_by_type('site_url');
|
||||
} else {
|
||||
$forms = wu_get_checkout_forms(
|
||||
array(
|
||||
[
|
||||
'number' => 1,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if ($forms) {
|
||||
@ -139,11 +139,11 @@ function wu_get_available_domain_options() {
|
||||
}
|
||||
}
|
||||
|
||||
$domain_options = array();
|
||||
$domain_options = [];
|
||||
|
||||
if ($fields) {
|
||||
foreach ($fields as $field) {
|
||||
$available_domains = isset($field['available_domains']) ? $field['available_domains'] : '';
|
||||
$available_domains = $field['available_domains'] ?? '';
|
||||
|
||||
$field_domain_options = explode(PHP_EOL, (string) $available_domains);
|
||||
|
||||
@ -167,7 +167,7 @@ function wu_is_form_field_pre_selected($field_slug) {
|
||||
|
||||
$checkout = Checkout::get_instance();
|
||||
|
||||
$pre_selected = $checkout->request_or_session('pre_selected', array());
|
||||
$pre_selected = $checkout->request_or_session('pre_selected', []);
|
||||
|
||||
$from_request = stripslashes_deep(wu_get_isset($_GET, $field_slug)) || isset($pre_selected[ $field_slug ]);
|
||||
|
||||
|
@ -64,15 +64,15 @@ function wu_stripe_generate_idempotency_key($args, $context = 'new') {
|
||||
* @param array $fields List of signup field types.
|
||||
* @return array
|
||||
*/
|
||||
function wu_create_checkout_fields($fields = array()) {
|
||||
function wu_create_checkout_fields($fields = []) {
|
||||
|
||||
$field_types = Signup_Fields_Manager::get_instance()->get_field_types();
|
||||
|
||||
$actual_fields = array();
|
||||
$actual_fields = [];
|
||||
|
||||
// Extra check to prevent error messages from being displayed.
|
||||
if ( ! is_array($fields)) {
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
}
|
||||
|
||||
foreach ($fields as $field) {
|
||||
@ -117,10 +117,10 @@ function wu_create_checkout_fields($fields = array()) {
|
||||
*/
|
||||
$field = wp_parse_args(
|
||||
$field,
|
||||
array(
|
||||
[
|
||||
'element_classes' => '',
|
||||
'classes' => '',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$field_array = $field_class->to_fields_array($field);
|
||||
@ -290,7 +290,7 @@ function wu_register_field_template($field_type, $field_template_id, $field_temp
|
||||
'wu_checkout_field_templates',
|
||||
function ($field_templates) use ($field_type, $field_template_id, $field_template_class_name) {
|
||||
|
||||
$field_templates_for_field_type = wu_get_isset($field_templates, $field_type, array());
|
||||
$field_templates_for_field_type = wu_get_isset($field_templates, $field_type, []);
|
||||
|
||||
$field_templates_for_field_type[ $field_template_id ] = $field_template_class_name;
|
||||
|
||||
|
@ -45,7 +45,7 @@ function wu_color($hex) {
|
||||
*/
|
||||
function wu_get_random_color($index) {
|
||||
|
||||
$colors = array(
|
||||
$colors = [
|
||||
'wu-bg-red-500',
|
||||
'wu-bg-green-500',
|
||||
'wu-bg-blue-500',
|
||||
@ -53,7 +53,7 @@ function wu_get_random_color($index) {
|
||||
'wu-bg-orange-500',
|
||||
'wu-bg-purple-500',
|
||||
'wu-bg-pink-500',
|
||||
);
|
||||
];
|
||||
|
||||
return wu_get_isset($colors, $index, $colors[ rand(0, count($colors) - 1) ]);
|
||||
return wu_get_isset($colors, $index, $colors[ random_int(0, count($colors) - 1) ]);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ function wu_get_countries() {
|
||||
|
||||
return apply_filters(
|
||||
'wu_get_countries',
|
||||
array(
|
||||
[
|
||||
'AF' => __('Afghanistan', 'wp-ultimo'),
|
||||
'AX' => __('Åland Islands', 'wp-ultimo'),
|
||||
'AL' => __('Albania', 'wp-ultimo'),
|
||||
@ -269,7 +269,7 @@ function wu_get_countries() {
|
||||
'YE' => __('Yemen', 'wp-ultimo'),
|
||||
'ZM' => __('Zambia', 'wp-ultimo'),
|
||||
'ZW' => __('Zimbabwe', 'wp-ultimo'),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -282,9 +282,9 @@ function wu_get_countries() {
|
||||
function wu_get_countries_as_options() {
|
||||
|
||||
return array_merge(
|
||||
array(
|
||||
[
|
||||
'' => __('Select Country', 'wp-ultimo'),
|
||||
),
|
||||
],
|
||||
wu_get_countries()
|
||||
);
|
||||
}
|
||||
@ -299,7 +299,7 @@ function wu_get_countries_as_options() {
|
||||
* @param array $fallback_attributes Fallback attributes if the country class is not present.
|
||||
* @return \WP_Ultimo\Country\Country
|
||||
*/
|
||||
function wu_get_country($country_code, $name = null, $fallback_attributes = array()) {
|
||||
function wu_get_country($country_code, $name = null, $fallback_attributes = []) {
|
||||
|
||||
$country_code = strtoupper($country_code);
|
||||
|
||||
@ -324,9 +324,9 @@ function wu_get_country($country_code, $name = null, $fallback_attributes = arra
|
||||
*/
|
||||
function wu_get_country_states($country_code, $key_name = 'id', $value_name = 'value') {
|
||||
|
||||
static $state_options = array();
|
||||
static $state_options = [];
|
||||
|
||||
$options = array();
|
||||
$options = [];
|
||||
|
||||
$cache = wu_get_isset($state_options, $country_code, false);
|
||||
|
||||
@ -360,11 +360,11 @@ function wu_get_country_states($country_code, $key_name = 'id', $value_name = 'v
|
||||
*/
|
||||
function wu_get_country_cities($country_code, $states, $key_name = 'id', $value_name = 'value') {
|
||||
|
||||
static $city_options = array();
|
||||
static $city_options = [];
|
||||
|
||||
$states = (array) $states;
|
||||
|
||||
$options = array();
|
||||
$options = [];
|
||||
|
||||
foreach ($states as $state_code) {
|
||||
$cache = wu_get_isset($city_options, $state_code, false);
|
||||
@ -441,7 +441,7 @@ function wu_get_countries_of_customers($count = 10, $start_date = false, $end_da
|
||||
|
||||
$results = $wpdb->get_results($query); // phpcs:ignore
|
||||
|
||||
$countries = array();
|
||||
$countries = [];
|
||||
|
||||
foreach ($results as $result) {
|
||||
$countries[ $result->country ] = $result->count;
|
||||
@ -464,7 +464,7 @@ function wu_get_states_of_customers($country_code, $count = 100, $start_date = f
|
||||
|
||||
global $wpdb;
|
||||
|
||||
static $states = array();
|
||||
static $states = [];
|
||||
|
||||
$table_name = "{$wpdb->base_prefix}wu_customermeta";
|
||||
$customer_table_name = "{$wpdb->base_prefix}wu_customers";
|
||||
@ -480,7 +480,7 @@ function wu_get_states_of_customers($country_code, $count = 100, $start_date = f
|
||||
$states = wu_get_country_states('BR', false);
|
||||
|
||||
if (empty($states)) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
$states_in = implode("','", array_keys($states));
|
||||
@ -501,10 +501,10 @@ function wu_get_states_of_customers($country_code, $count = 100, $start_date = f
|
||||
$results = $wpdb->get_results($query); // phpcs:ignore
|
||||
|
||||
if (empty($results)) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
$_states = array();
|
||||
$_states = [];
|
||||
|
||||
foreach ($results as $result) {
|
||||
$final_label = sprintf('%s (%s)', $states[ $result->state ], $result->state);
|
||||
|
@ -18,7 +18,7 @@ function wu_get_currencies(): array {
|
||||
|
||||
$currencies = apply_filters(
|
||||
'wu_currencies',
|
||||
array(
|
||||
[
|
||||
'AED' => __('United Arab Emirates Dirham', 'wp-ultimo'),
|
||||
'ARS' => __('Argentine Peso', 'wp-ultimo'),
|
||||
'AUD' => __('Australian Dollars', 'wp-ultimo'),
|
||||
@ -68,7 +68,7 @@ function wu_get_currencies(): array {
|
||||
'USD' => __('US Dollars', 'wp-ultimo'),
|
||||
'VND' => __('Vietnamese Dong', 'wp-ultimo'),
|
||||
'EGP' => __('Egyptian Pound', 'wp-ultimo'),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
return array_unique($currencies);
|
||||
@ -238,26 +238,26 @@ function wu_format_currency($value, $currency = null, $format = null, $thousands
|
||||
|
||||
$value = wu_to_float($value);
|
||||
|
||||
$args = array(
|
||||
$args = [
|
||||
'currency' => $currency,
|
||||
'format' => $format,
|
||||
'thousands_sep' => $thousands_sep,
|
||||
'decimal_sep' => $decimal_sep,
|
||||
'precision' => $precision,
|
||||
);
|
||||
];
|
||||
|
||||
// Remove invalid args
|
||||
$args = array_filter($args);
|
||||
|
||||
$atts = wp_parse_args(
|
||||
$args,
|
||||
array(
|
||||
[
|
||||
'currency' => wu_get_setting('currency_symbol'),
|
||||
'format' => wu_get_setting('currency_position'),
|
||||
'thousands_sep' => wu_get_setting('thousand_separator'),
|
||||
'decimal_sep' => wu_get_setting('decimal_separator'),
|
||||
'precision' => (int) wu_get_setting('precision', 2),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$currency_symbol = wu_get_currency_symbol($atts['currency']);
|
||||
@ -280,7 +280,7 @@ function wu_format_currency($value, $currency = null, $format = null, $thousands
|
||||
*/
|
||||
function wu_is_zero_decimal_currency($currency = 'USD') {
|
||||
|
||||
$zero_dec_currencies = array(
|
||||
$zero_dec_currencies = [
|
||||
'BIF', // Burundian Franc
|
||||
'CLP', // Chilean Peso
|
||||
'DJF', // Djiboutian Franc
|
||||
@ -296,7 +296,7 @@ function wu_is_zero_decimal_currency($currency = 'USD') {
|
||||
'XAF', // Central African CFA Franc
|
||||
'XOF', // West African CFA Franc
|
||||
'XPF', // CFP Franc
|
||||
);
|
||||
];
|
||||
|
||||
return apply_filters('wu_is_zero_decimal_currency', in_array($currency, $zero_dec_currencies, true));
|
||||
}
|
||||
|
@ -57,16 +57,16 @@ function wu_get_customer_by_hash($hash) {
|
||||
* @param array $query Query arguments.
|
||||
* @return \WP_Ultimo\Models\Customer[]
|
||||
*/
|
||||
function wu_get_customers($query = array()) {
|
||||
function wu_get_customers($query = []) {
|
||||
|
||||
if ( ! empty($query['search'])) {
|
||||
$user_ids = get_users(
|
||||
array(
|
||||
[
|
||||
'blog_id' => 0,
|
||||
'number' => -1,
|
||||
'search' => '*' . $query['search'] . '*',
|
||||
'fields' => 'ids',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if ( ! empty($user_ids)) {
|
||||
@ -120,7 +120,7 @@ function wu_create_customer($customer_data) {
|
||||
|
||||
$customer_data = wp_parse_args(
|
||||
$customer_data,
|
||||
array(
|
||||
[
|
||||
'user_id' => false,
|
||||
'email' => false,
|
||||
'username' => false,
|
||||
@ -128,13 +128,13 @@ function wu_create_customer($customer_data) {
|
||||
'vip' => false,
|
||||
'ip' => false,
|
||||
'email_verification' => 'none',
|
||||
'meta' => array(),
|
||||
'meta' => [],
|
||||
'date_registered' => wu_get_current_time('mysql', true),
|
||||
'date_modified' => wu_get_current_time('mysql', true),
|
||||
'last_login' => wu_get_current_time('mysql', true),
|
||||
'signup_form' => 'by-admin',
|
||||
'billing_address' => array(),
|
||||
)
|
||||
'billing_address' => [],
|
||||
]
|
||||
);
|
||||
|
||||
$user = get_user_by('email', $customer_data['email']);
|
||||
@ -166,7 +166,7 @@ function wu_create_customer($customer_data) {
|
||||
}
|
||||
|
||||
$customer = new Customer(
|
||||
array(
|
||||
[
|
||||
'user_id' => $user_id,
|
||||
'email_verification' => $customer_data['email_verification'],
|
||||
'meta' => $customer_data['meta'],
|
||||
@ -175,7 +175,7 @@ function wu_create_customer($customer_data) {
|
||||
'billing_address' => $customer_data['billing_address'],
|
||||
'last_login' => $customer_data['last_login'],
|
||||
'type' => 'customer',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$saved = $customer->save();
|
||||
@ -196,11 +196,11 @@ function wu_create_customer($customer_data) {
|
||||
*/
|
||||
function wu_get_customer_meta_types($form_slugs = false) {
|
||||
|
||||
$meta_keys = array();
|
||||
$meta_keys = [];
|
||||
|
||||
$query = array(
|
||||
$query = [
|
||||
'number' => 99999,
|
||||
);
|
||||
];
|
||||
|
||||
if (is_array($form_slugs)) {
|
||||
$query['slug__in'] = (array) $form_slugs;
|
||||
@ -212,7 +212,7 @@ function wu_get_customer_meta_types($form_slugs = false) {
|
||||
$customer_meta_fields = $form->get_all_meta_fields('customer_meta');
|
||||
|
||||
foreach ($customer_meta_fields as $customer_meta_field) {
|
||||
$meta_keys[ $customer_meta_field['id'] ] = array(
|
||||
$meta_keys[ $customer_meta_field['id'] ] = [
|
||||
'type' => $customer_meta_field['type'],
|
||||
'title' => $customer_meta_field['name'],
|
||||
'description' => wu_get_isset($customer_meta_field, 'description', ''),
|
||||
@ -220,11 +220,11 @@ function wu_get_customer_meta_types($form_slugs = false) {
|
||||
'default' => wu_get_isset($customer_meta_field, 'default', ''),
|
||||
'id' => wu_get_isset($customer_meta_field, 'id', ''),
|
||||
'step' => wu_get_isset($customer_meta_field, 'step', ''),
|
||||
'options' => wu_get_isset($customer_meta_field, 'options', array()),
|
||||
'options' => wu_get_isset($customer_meta_field, 'options', []),
|
||||
'form' => $form->get_slug(),
|
||||
'value' => '',
|
||||
'exists' => false,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,12 +243,12 @@ function wu_get_customer_meta_types($form_slugs = false) {
|
||||
*/
|
||||
function wu_get_all_customer_meta($customer_id, $include_unset = true) {
|
||||
|
||||
$all_meta = array();
|
||||
$all_meta = [];
|
||||
|
||||
$customer = wu_get_customer($customer_id);
|
||||
|
||||
if ($include_unset) {
|
||||
$form_slugs = $customer ? array($customer->get_signup_form()) : false;
|
||||
$form_slugs = $customer ? [$customer->get_signup_form()] : false;
|
||||
|
||||
$all_meta = array_merge($all_meta, wu_get_customer_meta_types($form_slugs));
|
||||
}
|
||||
@ -323,16 +323,16 @@ function wu_update_customer_meta($customer_id, $key, $value, $type = null, $titl
|
||||
}
|
||||
|
||||
if ($type) {
|
||||
$custom_keys = $customer->get_meta('wu_custom_meta_keys', array());
|
||||
$custom_keys = $customer->get_meta('wu_custom_meta_keys', []);
|
||||
|
||||
$custom_keys = array_merge(
|
||||
$custom_keys,
|
||||
array(
|
||||
$key => array(
|
||||
[
|
||||
$key => [
|
||||
'type' => $type,
|
||||
'title' => $title,
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$customer->update_meta('wu_custom_meta_keys', $custom_keys);
|
||||
@ -358,7 +358,7 @@ function wu_delete_customer_meta($customer_id, $meta_key) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$custom_keys = $customer->get_meta('wu_custom_meta_keys', array());
|
||||
$custom_keys = $customer->get_meta('wu_custom_meta_keys', []);
|
||||
|
||||
if (isset($custom_keys[ $meta_key ])) {
|
||||
unset($custom_keys[ $meta_key ]);
|
||||
@ -378,15 +378,15 @@ function wu_delete_customer_meta($customer_id, $meta_key) {
|
||||
* @param array $allowed_gateways The list of allowed gateways to search.
|
||||
* @return string
|
||||
*/
|
||||
function wu_get_customer_gateway_id($customer_id, $allowed_gateways = array()) {
|
||||
function wu_get_customer_gateway_id($customer_id, $allowed_gateways = []) {
|
||||
|
||||
$memberships = wu_get_memberships(
|
||||
array(
|
||||
[
|
||||
'customer_id' => absint($customer_id),
|
||||
'gateway__in' => $allowed_gateways,
|
||||
'number' => 1,
|
||||
'gateway_customer_id__not_in' => array(''),
|
||||
)
|
||||
'gateway_customer_id__not_in' => [''],
|
||||
]
|
||||
);
|
||||
|
||||
return ! empty($memberships) ? $memberships[0]->get_gateway_customer_id() : '';
|
||||
@ -406,9 +406,9 @@ function wu_get_customer_gateway_id($customer_id, $allowed_gateways = array()) {
|
||||
* @param string $suffix Append string to username to make it unique.
|
||||
* @return string Generated username.
|
||||
*/
|
||||
function wu_username_from_email($email, $new_user_args = array(), $suffix = '') {
|
||||
function wu_username_from_email($email, $new_user_args = [], $suffix = '') {
|
||||
|
||||
$username_parts = array();
|
||||
$username_parts = [];
|
||||
|
||||
if (isset($new_user_args['first_name'])) {
|
||||
$username_parts[] = sanitize_user($new_user_args['first_name'], true);
|
||||
@ -426,13 +426,13 @@ function wu_username_from_email($email, $new_user_args = array(), $suffix = '')
|
||||
$email_parts = explode('@', $email);
|
||||
$email_username = $email_parts[0];
|
||||
|
||||
$common_emails = array(
|
||||
$common_emails = [
|
||||
'sales',
|
||||
'hello',
|
||||
'mail',
|
||||
'contact',
|
||||
'info',
|
||||
);
|
||||
];
|
||||
|
||||
// Exclude common prefixes.
|
||||
if (in_array($email_username, $common_emails, true)) {
|
||||
@ -450,11 +450,11 @@ function wu_username_from_email($email, $new_user_args = array(), $suffix = '')
|
||||
$username .= $suffix;
|
||||
}
|
||||
|
||||
$illegal_logins = (array) apply_filters('illegal_user_logins', array()); // phpcs:ignore
|
||||
$illegal_logins = (array) apply_filters('illegal_user_logins', []); // phpcs:ignore
|
||||
|
||||
// Stop illegal logins and generate a new random username.
|
||||
if (in_array(strtolower($username), array_map('strtolower', $illegal_logins), true)) {
|
||||
$new_args = array();
|
||||
$new_args = [];
|
||||
|
||||
/**
|
||||
* Filter generated customer username.
|
||||
|
@ -20,10 +20,10 @@ function wu_drop_tables() {
|
||||
|
||||
$tables = apply_filters('wu_drop_tables', \WP_Ultimo\Loaders\Table_Loader::get_instance()->get_tables());
|
||||
|
||||
$except = array(
|
||||
$except = [
|
||||
'blogs',
|
||||
'blogmeta',
|
||||
);
|
||||
];
|
||||
|
||||
$except = apply_filters('wu_drop_tables_except', $except);
|
||||
|
||||
|
@ -167,7 +167,7 @@ function wu_human_time_diff($from, $limit = '-5 days', $to = false): string {
|
||||
*/
|
||||
function wu_convert_php_date_format_to_moment_js_format($php_date_format): string {
|
||||
|
||||
$replacements = array(
|
||||
$replacements = [
|
||||
'A' => 'A', // for the sake of escaping below
|
||||
'a' => 'a', // for the sake of escaping below
|
||||
'B' => '', // Swatch internet time (.beats), no equivalent
|
||||
@ -206,7 +206,7 @@ function wu_convert_php_date_format_to_moment_js_format($php_date_format): strin
|
||||
'y' => 'YY',
|
||||
'Z' => '', // time zone offset in minutes => moment().zone();
|
||||
'z' => 'DDD',
|
||||
);
|
||||
];
|
||||
|
||||
// Converts escaped characters.
|
||||
foreach ($replacements as $from => $to) {
|
||||
|
@ -44,7 +44,7 @@ function wu_get_discount_code($discount_code_id) {
|
||||
* @param array $query Query arguments.
|
||||
* @return \WP_Ultimo\Models\Discount_Code[]
|
||||
*/
|
||||
function wu_get_discount_codes($query = array()) {
|
||||
function wu_get_discount_codes($query = []) {
|
||||
|
||||
return \WP_Ultimo\Models\Discount_Code::query($query);
|
||||
}
|
||||
@ -87,7 +87,7 @@ function wu_create_discount_code($discount_code_data) {
|
||||
|
||||
$discount_code_data = wp_parse_args(
|
||||
$discount_code_data,
|
||||
array(
|
||||
[
|
||||
'max_uses' => true,
|
||||
'name' => false,
|
||||
'code' => false,
|
||||
@ -99,7 +99,7 @@ function wu_create_discount_code($discount_code_data) {
|
||||
'date_created' => wu_get_current_time('mysql', true),
|
||||
'date_modified' => wu_get_current_time('mysql', true),
|
||||
'skip_validation' => false,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$discount_code = new Discount_Code($discount_code_data);
|
||||
|
@ -32,7 +32,7 @@ function wu_get_domain($domain_id) {
|
||||
* @param array $query Query arguments.
|
||||
* @return \WP_Ultimo\Models\Domain[]
|
||||
*/
|
||||
function wu_get_domains($query = array()) {
|
||||
function wu_get_domains($query = []) {
|
||||
|
||||
return \WP_Ultimo\Models\Domain::query($query);
|
||||
}
|
||||
@ -62,7 +62,7 @@ function wu_create_domain($domain_data) {
|
||||
|
||||
$domain_data = wp_parse_args(
|
||||
$domain_data,
|
||||
array(
|
||||
[
|
||||
'blog_id' => false,
|
||||
'domain' => false,
|
||||
'active' => true,
|
||||
@ -71,7 +71,7 @@ function wu_create_domain($domain_data) {
|
||||
'stage' => 'checking-dns',
|
||||
'date_created' => wu_get_current_time('mysql', true),
|
||||
'date_modified' => wu_get_current_time('mysql', true),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$domain = new Domain($domain_data);
|
||||
@ -85,7 +85,7 @@ function wu_create_domain($domain_data) {
|
||||
/*
|
||||
* Add the processing.
|
||||
*/
|
||||
wu_enqueue_async_action('wu_async_process_domain_stage', array('domain_id' => $domain->get_id()), 'domain');
|
||||
wu_enqueue_async_action('wu_async_process_domain_stage', ['domain_id' => $domain->get_id()], 'domain');
|
||||
|
||||
return $domain;
|
||||
}
|
||||
|
@ -48,17 +48,17 @@ function wu_get_email_by($column, $value) {
|
||||
* @param array $query Query arguments.
|
||||
* @return Email[]
|
||||
*/
|
||||
function wu_get_emails($query = array()) {
|
||||
function wu_get_emails($query = []) {
|
||||
|
||||
$query['type__in'] = array('system_email');
|
||||
$query['type__in'] = ['system_email'];
|
||||
|
||||
if (wu_get_isset($query, 'event')) {
|
||||
$query['meta_query'] = array(
|
||||
'event_query' => array(
|
||||
$query['meta_query'] = [
|
||||
'event_query' => [
|
||||
'key' => 'wu_system_email_event',
|
||||
'value' => wu_get_isset($query, 'event'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
return Email::query($query);
|
||||
@ -74,10 +74,10 @@ function wu_get_emails($query = array()) {
|
||||
function wu_get_all_system_emails() {
|
||||
|
||||
return Email::query(
|
||||
array(
|
||||
'status__in' => array('draft', 'publish'),
|
||||
'type__in' => array('system_email'),
|
||||
)
|
||||
[
|
||||
'status__in' => ['draft', 'publish'],
|
||||
'type__in' => ['system_email'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ function wu_create_default_system_email($slug) {
|
||||
* @param array $args With content, subject and other arguments, has shortcodes, mail type.
|
||||
* @return array
|
||||
*/
|
||||
function wu_send_mail($from = array(), $to = array(), $args = array()) {
|
||||
function wu_send_mail($from = [], $to = [], $args = []) {
|
||||
|
||||
return Sender::send_mail($from, $to, $args);
|
||||
}
|
||||
@ -154,7 +154,7 @@ function wu_create_email($email_data) {
|
||||
|
||||
$email_data = wp_parse_args(
|
||||
$email_data,
|
||||
array(
|
||||
[
|
||||
'type' => 'system_email',
|
||||
'event' => 'Laborum consectetur',
|
||||
'title' => 'Lorem Ipsum',
|
||||
@ -162,7 +162,7 @@ function wu_create_email($email_data) {
|
||||
'target' => 'admin',
|
||||
'date_created' => wu_get_current_time('mysql', true),
|
||||
'date_modified' => wu_get_current_time('mysql', true),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$email = new Email($email_data);
|
||||
|
@ -91,7 +91,7 @@ function wu_get_event_type($slug) {
|
||||
* @param array $query Query arguments.
|
||||
* @return \WP_Ultimo\Models\Event[]
|
||||
*/
|
||||
function wu_get_events($query = array()) {
|
||||
function wu_get_events($query = []) {
|
||||
|
||||
return \WP_Ultimo\Models\Event::query($query);
|
||||
}
|
||||
@ -135,19 +135,19 @@ function wu_create_event($event_data) {
|
||||
|
||||
$event_data = wp_parse_args(
|
||||
$event_data,
|
||||
array(
|
||||
[
|
||||
'severity' => Event::SEVERITY_NEUTRAL,
|
||||
'initiator' => 'system',
|
||||
'author_id' => $author_id,
|
||||
'object_type' => 'network',
|
||||
'object_id' => 0,
|
||||
'date_created' => wu_get_current_time('mysql', true),
|
||||
'payload' => array(
|
||||
'payload' => [
|
||||
'key' => 'None',
|
||||
'old_value' => 'None',
|
||||
'new_value' => 'None',
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$event = new Event($event_data);
|
||||
@ -170,7 +170,7 @@ function wu_create_event($event_data) {
|
||||
*/
|
||||
function wu_generate_event_payload($model_name, $model = false): array {
|
||||
|
||||
$payload = array();
|
||||
$payload = [];
|
||||
|
||||
if ( ! $model) {
|
||||
switch ($model_name) {
|
||||
@ -195,14 +195,14 @@ function wu_generate_event_payload($model_name, $model = false): array {
|
||||
}
|
||||
|
||||
if ( ! $model) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
if ($model_name === 'customer') {
|
||||
$payload = $model->to_search_results();
|
||||
|
||||
$payload = array(
|
||||
$payload = [
|
||||
'customer_id' => $payload['id'],
|
||||
'customer_name' => $payload['display_name'],
|
||||
'customer_user_id' => $payload['user_id'],
|
||||
@ -212,17 +212,17 @@ function wu_generate_event_payload($model_name, $model = false): array {
|
||||
'customer_billing_address' => $payload['billing_address'],
|
||||
'customer_manage_url' => wu_network_admin_url(
|
||||
'wp-ultimo-edit-customer',
|
||||
array(
|
||||
[
|
||||
'id' => $model->get_id(),
|
||||
)
|
||||
]
|
||||
),
|
||||
);
|
||||
];
|
||||
} elseif ($model_name === 'membership') {
|
||||
$payload = $model->to_search_results();
|
||||
|
||||
$p = $payload;
|
||||
|
||||
$payload = array(
|
||||
$payload = [
|
||||
'membership_id' => $p['id'],
|
||||
'membership_status' => $p['status'],
|
||||
'membership_reference_code' => $p['reference_code'],
|
||||
@ -236,15 +236,15 @@ function wu_generate_event_payload($model_name, $model = false): array {
|
||||
'membership_date_expiration' => $p['date_expiration'],
|
||||
'membership_manage_url' => wu_network_admin_url(
|
||||
'wp-ultimo-edit-membership',
|
||||
array(
|
||||
[
|
||||
'id' => $model->get_id(),
|
||||
)
|
||||
]
|
||||
),
|
||||
);
|
||||
];
|
||||
} elseif ($model_name === 'product') {
|
||||
$payload = $model->to_search_results();
|
||||
|
||||
$payload = array(
|
||||
$payload = [
|
||||
'product_id' => $payload['id'],
|
||||
'product_amount' => wu_format_currency($payload['amount'], $payload['currency']),
|
||||
'product_amount_raw' => $payload['amount'],
|
||||
@ -255,15 +255,15 @@ function wu_generate_event_payload($model_name, $model = false): array {
|
||||
'product_image' => $payload['image'],
|
||||
'product_manage_url' => wu_network_admin_url(
|
||||
'wp-ultimo-edit-payment',
|
||||
array(
|
||||
[
|
||||
'id' => $model->get_id(),
|
||||
)
|
||||
]
|
||||
),
|
||||
);
|
||||
];
|
||||
} elseif ($model_name === 'payment') {
|
||||
$payload = $model->to_search_results();
|
||||
|
||||
$payload = array(
|
||||
$payload = [
|
||||
'payment_id' => $payload['id'],
|
||||
'payment_status' => $payload['status'],
|
||||
'payment_reference_code' => $payload['reference_code'],
|
||||
@ -280,15 +280,15 @@ function wu_generate_event_payload($model_name, $model = false): array {
|
||||
'payment_invoice_url' => $model->get_invoice_url(),
|
||||
'payment_manage_url' => wu_network_admin_url(
|
||||
'wp-ultimo-edit-payment',
|
||||
array(
|
||||
[
|
||||
'id' => $model->get_id(),
|
||||
)
|
||||
]
|
||||
),
|
||||
);
|
||||
];
|
||||
} elseif ($model_name === 'site') {
|
||||
$payload = $model->to_search_results();
|
||||
|
||||
$payload = array(
|
||||
$payload = [
|
||||
'site_id' => $payload['blog_id'],
|
||||
'site_title' => $payload['title'],
|
||||
'site_description' => $payload['description'],
|
||||
@ -296,15 +296,15 @@ function wu_generate_event_payload($model_name, $model = false): array {
|
||||
'site_admin_url' => get_admin_url($model->get_id()),
|
||||
'site_manage_url' => wu_network_admin_url(
|
||||
'wp-ultimo-edit-site',
|
||||
array(
|
||||
[
|
||||
'id' => $model->get_id(),
|
||||
)
|
||||
]
|
||||
),
|
||||
);
|
||||
];
|
||||
} elseif ($model_name === 'domain') {
|
||||
$payload = $model->to_search_results();
|
||||
|
||||
$payload = array(
|
||||
$payload = [
|
||||
'domain_id' => $payload['id'],
|
||||
'domain_domain' => $payload['domain'],
|
||||
'domain_site_id' => $payload['blog_id'],
|
||||
@ -315,11 +315,11 @@ function wu_generate_event_payload($model_name, $model = false): array {
|
||||
'domain_date_created' => $payload['date_created'],
|
||||
'domain_manage_url' => wu_network_admin_url(
|
||||
'wp-ultimo-edit-domain',
|
||||
array(
|
||||
[
|
||||
'id' => $model->get_id(),
|
||||
)
|
||||
]
|
||||
),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
return $payload;
|
||||
|
@ -23,12 +23,12 @@ function wu_calculate_mrr() {
|
||||
$total_mrr = 0;
|
||||
|
||||
$memberships = wu_get_memberships(
|
||||
array(
|
||||
[
|
||||
'recurring' => true,
|
||||
'status__in' => array(
|
||||
'status__in' => [
|
||||
Membership_Status::ACTIVE,
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
foreach ($memberships as $membership) {
|
||||
@ -38,7 +38,7 @@ function wu_calculate_mrr() {
|
||||
continue;
|
||||
}
|
||||
|
||||
$duration = $membership->get_duration() ? $membership->get_duration() : 1;
|
||||
$duration = $membership->get_duration() ?: 1;
|
||||
|
||||
$duration_unit = $membership->get_duration_unit();
|
||||
|
||||
@ -113,14 +113,14 @@ function wu_calculate_revenue($start_date = false, $end_date = false, $inclusive
|
||||
|
||||
$total_revenue = 0;
|
||||
|
||||
$query_args = array(
|
||||
'fields' => array('total'),
|
||||
'date_query' => array(),
|
||||
'status__in' => array(
|
||||
$query_args = [
|
||||
'fields' => ['total'],
|
||||
'date_query' => [],
|
||||
'status__in' => [
|
||||
Payment_Status::COMPLETED,
|
||||
Payment_Status::PARTIAL,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
if ($start_date) {
|
||||
$query_args['date_query']['column'] = 'date_created';
|
||||
@ -157,14 +157,14 @@ function wu_calculate_refunds($start_date = false, $end_date = false, $inclusive
|
||||
|
||||
$total_revenue = 0;
|
||||
|
||||
$query_args = array(
|
||||
'fields' => array('refund_total'),
|
||||
'date_query' => array(),
|
||||
'status__in' => array(
|
||||
$query_args = [
|
||||
'fields' => ['refund_total'],
|
||||
'date_query' => [],
|
||||
'status__in' => [
|
||||
Payment_Status::REFUND,
|
||||
Payment_Status::PARTIAL_REFUND,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
if ($start_date) {
|
||||
$query_args['date_query']['column'] = 'date_created';
|
||||
@ -199,9 +199,9 @@ function wu_calculate_refunds($start_date = false, $end_date = false, $inclusive
|
||||
*/
|
||||
function wu_calculate_taxes_by_rate($start_date = false, $end_date = false, $inclusive = true) {
|
||||
|
||||
$query_args = array(
|
||||
'date_query' => array(),
|
||||
);
|
||||
$query_args = [
|
||||
'date_query' => [],
|
||||
];
|
||||
|
||||
if ($start_date) {
|
||||
$query_args['date_query']['after'] = $start_date;
|
||||
@ -215,7 +215,7 @@ function wu_calculate_taxes_by_rate($start_date = false, $end_date = false, $inc
|
||||
|
||||
$order = 0;
|
||||
|
||||
$taxes_paid_list = array();
|
||||
$taxes_paid_list = [];
|
||||
|
||||
$line_items_groups = \WP_Ultimo\Checkout\Line_Item::get_line_items($query_args);
|
||||
|
||||
@ -230,14 +230,14 @@ function wu_calculate_taxes_by_rate($start_date = false, $end_date = false, $inc
|
||||
}
|
||||
|
||||
if ( ! wu_get_isset($taxes_paid_list, $tax_name)) {
|
||||
$taxes_paid_list[ $tax_name ] = array(
|
||||
$taxes_paid_list[ $tax_name ] = [
|
||||
'title' => $tax_name,
|
||||
'country' => '',
|
||||
'state' => '',
|
||||
'order_count' => $order,
|
||||
'tax_rate' => $line_item->get_tax_rate(),
|
||||
'tax_total' => $line_item->get_tax_total(),
|
||||
);
|
||||
];
|
||||
} else {
|
||||
$taxes_paid_list[ $tax_name ]['tax_total'] += $line_item->get_tax_total();
|
||||
$taxes_paid_list[ $tax_name ]['order_count'] += $order;
|
||||
@ -260,10 +260,10 @@ function wu_calculate_taxes_by_rate($start_date = false, $end_date = false, $inc
|
||||
*/
|
||||
function wu_calculate_financial_data_by_product($start_date = false, $end_date = false, $inclusive = true) {
|
||||
|
||||
$query_args = array(
|
||||
'date_query' => array(),
|
||||
$query_args = [
|
||||
'date_query' => [],
|
||||
'payment_status' => Payment_Status::COMPLETED,
|
||||
);
|
||||
];
|
||||
|
||||
if ($start_date) {
|
||||
$query_args['date_query']['after'] = $start_date;
|
||||
@ -277,15 +277,15 @@ function wu_calculate_financial_data_by_product($start_date = false, $end_date =
|
||||
|
||||
$line_items_groups = \WP_Ultimo\Checkout\Line_Item::get_line_items($query_args);
|
||||
|
||||
$data = array();
|
||||
$data = [];
|
||||
|
||||
$products = wu_get_products();
|
||||
|
||||
foreach ($products as $product) {
|
||||
$data[ $product->get_id() ] = array(
|
||||
$data[ $product->get_id() ] = [
|
||||
'label' => $product->get_name(),
|
||||
'revenue' => 0,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($line_items_groups as $line_items_group) {
|
||||
@ -321,9 +321,9 @@ function wu_calculate_financial_data_by_product($start_date = false, $end_date =
|
||||
*/
|
||||
function wu_calculate_taxes_by_day($start_date = false, $end_date = false, $inclusive = true) {
|
||||
|
||||
$query_args = array(
|
||||
'date_query' => array(),
|
||||
);
|
||||
$query_args = [
|
||||
'date_query' => [],
|
||||
];
|
||||
|
||||
if ($start_date) {
|
||||
$query_args['date_query']['after'] = $start_date;
|
||||
@ -337,7 +337,7 @@ function wu_calculate_taxes_by_day($start_date = false, $end_date = false, $incl
|
||||
|
||||
$line_items_groups = \WP_Ultimo\Checkout\Line_Item::get_line_items($query_args);
|
||||
|
||||
$data = array();
|
||||
$data = [];
|
||||
|
||||
$period = new \DatePeriod(
|
||||
new \DateTime($start_date),
|
||||
@ -348,12 +348,12 @@ function wu_calculate_taxes_by_day($start_date = false, $end_date = false, $incl
|
||||
$days = array_reverse(iterator_to_array($period));
|
||||
|
||||
foreach ($days as $day_datetime) {
|
||||
$data[ $day_datetime->format('Y-m-d') ] = array(
|
||||
$data[ $day_datetime->format('Y-m-d') ] = [
|
||||
'order_count' => 0,
|
||||
'total' => 0,
|
||||
'tax_total' => 0,
|
||||
'net_profit' => 0,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($line_items_groups as $line_items_group) {
|
||||
@ -361,12 +361,12 @@ function wu_calculate_taxes_by_day($start_date = false, $end_date = false, $incl
|
||||
$date = gmdate('Y-m-d', strtotime((string) $line_item->date_created));
|
||||
|
||||
if ( ! wu_get_isset($data, $date)) {
|
||||
$data[ $date ] = array(
|
||||
$data[ $date ] = [
|
||||
'order_count' => 0,
|
||||
'total' => $line_item->get_total(),
|
||||
'tax_total' => $line_item->get_tax_total(),
|
||||
'net_profit' => $line_item->get_total() - $line_item->get_tax_total(),
|
||||
);
|
||||
];
|
||||
} else {
|
||||
$data[ $date ]['order_count'] += 1;
|
||||
$data[ $date ]['total'] += $line_item->get_total();
|
||||
@ -393,17 +393,17 @@ function wu_calculate_taxes_by_month() {
|
||||
return $cache;
|
||||
}
|
||||
|
||||
$query_args = array(
|
||||
'date_query' => array(
|
||||
$query_args = [
|
||||
'date_query' => [
|
||||
'after' => 'first day of January this year',
|
||||
'before' => 'last day of December this year',
|
||||
'inclusive' => true,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$line_items_groups = \WP_Ultimo\Checkout\Line_Item::get_line_items($query_args);
|
||||
|
||||
$data = array();
|
||||
$data = [];
|
||||
|
||||
$period = new \DatePeriod(
|
||||
new \DateTime($query_args['date_query']['after']),
|
||||
@ -414,12 +414,12 @@ function wu_calculate_taxes_by_month() {
|
||||
$months = iterator_to_array($period);
|
||||
|
||||
foreach ($months as $month_datetime) {
|
||||
$data[ $month_datetime->format('n') ] = array(
|
||||
$data[ $month_datetime->format('n') ] = [
|
||||
'order_count' => 0,
|
||||
'total' => 0,
|
||||
'tax_total' => 0,
|
||||
'net_profit' => 0,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($line_items_groups as $line_items_group) {
|
||||
@ -427,12 +427,12 @@ function wu_calculate_taxes_by_month() {
|
||||
$date = gmdate('n', strtotime((string) $line_item->date_created));
|
||||
|
||||
if ( ! wu_get_isset($data, $date)) {
|
||||
$data[ $date ] = array(
|
||||
$data[ $date ] = [
|
||||
'order_count' => 0,
|
||||
'total' => $line_item->get_total(),
|
||||
'tax_total' => $line_item->get_tax_total(),
|
||||
'net_profit' => $line_item->get_total() - $line_item->get_tax_total(),
|
||||
);
|
||||
];
|
||||
} else {
|
||||
$data[ $date ]['order_count'] += 1;
|
||||
$data[ $date ]['total'] += $line_item->get_total();
|
||||
@ -461,9 +461,9 @@ function wu_calculate_signups_by_form($start_date = false, $end_date = false, $i
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$query = array(
|
||||
'date_query' => array(),
|
||||
);
|
||||
$query = [
|
||||
'date_query' => [],
|
||||
];
|
||||
|
||||
if ($start_date) {
|
||||
$query['date_query']['after'] = $start_date;
|
||||
|
@ -25,7 +25,7 @@ use WP_Ultimo\Managers\Form_Manager;
|
||||
* @param array $atts Form attributes, check wp_parse_atts call below.
|
||||
* @return mixed
|
||||
*/
|
||||
function wu_register_form($form_id, $atts = array()) {
|
||||
function wu_register_form($form_id, $atts = []) {
|
||||
|
||||
return Form_Manager::get_instance()->register_form($form_id, $atts);
|
||||
}
|
||||
@ -41,16 +41,16 @@ function wu_register_form($form_id, $atts = array()) {
|
||||
* @param boolean $inline If this form is has content.
|
||||
* @return string
|
||||
*/
|
||||
function wu_get_form_url($form_id, $atts = array(), $inline = false) {
|
||||
function wu_get_form_url($form_id, $atts = [], $inline = false) {
|
||||
|
||||
if ($inline) {
|
||||
$atts = wp_parse_args(
|
||||
$atts,
|
||||
array(
|
||||
[
|
||||
'inlineId' => $form_id,
|
||||
'width' => '400',
|
||||
'height' => '360',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
// TB_inline?height=300&width=300&inlineId=wu-add-field
|
||||
|
@ -52,9 +52,9 @@ function wu_get_gateways() {
|
||||
*/
|
||||
function wu_get_active_gateways() {
|
||||
|
||||
$gateways = array();
|
||||
$gateways = [];
|
||||
|
||||
$active_gateways = (array) wu_get_setting('active_gateways', array());
|
||||
$active_gateways = (array) wu_get_setting('active_gateways', []);
|
||||
|
||||
foreach ($active_gateways as $active_gateway) {
|
||||
if (Gateway_Manager::get_instance()->is_gateway_registered($active_gateway)) {
|
||||
@ -95,7 +95,7 @@ function wu_get_gateway($id, $subscription = null) {
|
||||
*/
|
||||
function wu_get_gateway_as_options() {
|
||||
|
||||
$options = array();
|
||||
$options = [];
|
||||
|
||||
foreach (wu_get_gateways() as $gateway_slug => $gateway) {
|
||||
$instance = class_exists($gateway['class_name']) ? new $gateway['class_name']() : false;
|
||||
@ -118,7 +118,7 @@ function wu_get_gateway_as_options() {
|
||||
*/
|
||||
function wu_get_active_gateway_as_options() {
|
||||
|
||||
$options = array();
|
||||
$options = [];
|
||||
|
||||
foreach (wu_get_active_gateways() as $gateway_slug => $gateway) {
|
||||
$instance = class_exists($gateway['class_name']) ? new $gateway['class_name']() : false;
|
||||
|
@ -16,7 +16,7 @@ defined('ABSPATH') || exit;
|
||||
* @param array $data Content.
|
||||
* @return void
|
||||
*/
|
||||
function wu_generate_csv($file_name, $data = array()) {
|
||||
function wu_generate_csv($file_name, $data = []) {
|
||||
|
||||
$fp = fopen('php://output', 'w');
|
||||
|
||||
|
@ -69,7 +69,7 @@ function wu_get_isset($array, $key, $default = false) {
|
||||
$array = (array) $array;
|
||||
}
|
||||
|
||||
return isset($array[ $key ]) ? $array[ $key ] : $default;
|
||||
return $array[ $key ] ?? $default;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -251,7 +251,7 @@ function wu_get_function_caller($depth = 1) {
|
||||
|
||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $depth + 1);
|
||||
|
||||
$caller = isset($backtrace[ $depth ]['function']) ? $backtrace[ $depth ]['function'] : null;
|
||||
$caller = $backtrace[ $depth ]['function'] ?? null;
|
||||
|
||||
return $caller;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ if (!function_exists('validate_user_form')) {
|
||||
* @param array $attributes
|
||||
* @return void
|
||||
*/
|
||||
function wu_create_html_attributes_from_array($attributes = array()) {
|
||||
function wu_create_html_attributes_from_array($attributes = []) {
|
||||
|
||||
$output = '';
|
||||
|
||||
@ -80,7 +80,7 @@ function wu_create_html_attributes_from_array($attributes = array()) {
|
||||
* @param string $option_label
|
||||
* @return void
|
||||
*/
|
||||
function wu_print_signup_field_option($option_value, $option_label, $field = array()) { ?>
|
||||
function wu_print_signup_field_option($option_value, $option_label, $field = []) { ?>
|
||||
|
||||
<option <?php selected(isset($field['default']) && $field['default'] == $option_value); ?> value="<?php echo $option_value; ?>"><?php echo $option_label; ?></option>
|
||||
|
||||
@ -94,7 +94,7 @@ function wu_print_signup_field_option($option_value, $option_label, $field = arr
|
||||
* @param array $options
|
||||
* @return void
|
||||
*/
|
||||
function wu_print_signup_field_options($options, $field = array()) {
|
||||
function wu_print_signup_field_options($options, $field = []) {
|
||||
|
||||
foreach ($options as $option_value => $option_label) {
|
||||
|
||||
@ -246,7 +246,7 @@ function wu_print_signup_field($field_slug, $field, $results) {
|
||||
<p <?php echo $wrapper_attributes; ?> id="<?php echo $field_slug; ?>-field" <?php echo $wrapper_attributes; ?> style="<?php echo $display ? '' : 'display: none'; ?>" >
|
||||
|
||||
<label for="<?php echo $field_slug; ?>"><?php echo $field['name']; ?> <?php echo wu_tooltip($field['tooltip']); ?><br>
|
||||
<input <?php echo $attributes; ?> <?php echo isset($field['required']) && $field['required'] ? 'required' : ''; ?> type="<?php echo $field['type']; ?>" name="<?php echo $field_slug; ?>" id="<?php echo $field_slug; ?>" class="input" value="<?php echo isset($results[$field_slug]) ? $results[$field_slug] : ''; ?>" size="20"></label>
|
||||
<input <?php echo $attributes; ?> <?php echo isset($field['required']) && $field['required'] ? 'required' : ''; ?> type="<?php echo $field['type']; ?>" name="<?php echo $field_slug; ?>" id="<?php echo $field_slug; ?>" class="input" value="<?php echo $results[$field_slug] ?? ''; ?>" size="20"></label>
|
||||
|
||||
|
||||
<?php
|
||||
@ -273,13 +273,13 @@ function wu_print_signup_field($field_slug, $field, $results) {
|
||||
|
||||
$suffix = WP_Ultimo()->min;
|
||||
|
||||
wp_enqueue_script('wu-password-verify', WP_Ultimo()->get_asset("wu-password-verify$suffix.js", 'js'), array('jquery'), true);
|
||||
wp_enqueue_script('wu-password-verify', WP_Ultimo()->get_asset("wu-password-verify$suffix.js", 'js'), ['jquery'], true);
|
||||
|
||||
?>
|
||||
|
||||
<span class="password-input-wrapper" style="display: block;">
|
||||
<label for="<?php echo $field_slug; ?>"><?php echo $field['name']; ?> <?php echo wu_tooltip($field['tooltip']); ?><br>
|
||||
<input <?php echo $attributes; ?> <?php echo isset($field['required']) && $field['required'] ? 'required' : ''; ?> type="<?php echo $field['type']; ?>" name="<?php echo $field_slug; ?>" id="<?php echo $field_slug; ?>" class="input" value="<?php echo isset($results[$field_slug]) ? $results[$field_slug] : ''; ?>" data-reveal="1" data-pw="<?php echo esc_attr( wp_generate_password( 16 ) ); ?>" class="input" size="20" autocomplete="off" aria-describedby="pass-strength-result" />
|
||||
<input <?php echo $attributes; ?> <?php echo isset($field['required']) && $field['required'] ? 'required' : ''; ?> type="<?php echo $field['type']; ?>" name="<?php echo $field_slug; ?>" id="<?php echo $field_slug; ?>" class="input" value="<?php echo $results[$field_slug] ?? ''; ?>" data-reveal="1" data-pw="<?php echo esc_attr( wp_generate_password( 16 ) ); ?>" class="input" size="20" autocomplete="off" aria-describedby="pass-strength-result" />
|
||||
</span>
|
||||
|
||||
<span style="display: block; margin-top: -16px; opacity: 1; height: 36px;" id="pass-strength-result" class="hide-if-no-js" aria-live="polite"><?php _e( 'Strength indicator' ); ?></span>
|
||||
@ -296,7 +296,7 @@ function wu_print_signup_field($field_slug, $field, $results) {
|
||||
<?php else : ?>
|
||||
|
||||
<label for="<?php echo $field_slug; ?>"><?php echo $field['name']; ?> <?php echo wu_tooltip($field['tooltip']); ?><br>
|
||||
<input <?php echo $attributes; ?> <?php echo isset($field['required']) && $field['required'] ? 'required' : ''; ?> type="<?php echo $field['type']; ?>" name="<?php echo $field_slug; ?>" id="<?php echo $field_slug; ?>" class="input" value="<?php echo isset($results[$field_slug]) ? $results[$field_slug] : ''; ?>" size="20"></label>
|
||||
<input <?php echo $attributes; ?> <?php echo isset($field['required']) && $field['required'] ? 'required' : ''; ?> type="<?php echo $field['type']; ?>" name="<?php echo $field_slug; ?>" id="<?php echo $field_slug; ?>" class="input" value="<?php echo $results[$field_slug] ?? ''; ?>" size="20"></label>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
@ -356,7 +356,7 @@ function wu_print_signup_field($field_slug, $field, $results) {
|
||||
|
||||
<label for="<?php echo $field_slug; ?>"><?php echo $field['name']; ?> <?php echo wu_tooltip($field['tooltip']); ?><br>
|
||||
|
||||
<select <?php echo $attributes; ?> <?php echo isset($field['required']) && $field['required'] ? 'required' : ''; ?> name="<?php echo $field_slug; ?>" id="<?php echo $field_slug; ?>" class="input" value="<?php echo isset($results[$field_slug]) ? $results[$field_slug] : ''; ?>">
|
||||
<select <?php echo $attributes; ?> <?php echo isset($field['required']) && $field['required'] ? 'required' : ''; ?> name="<?php echo $field_slug; ?>" id="<?php echo $field_slug; ?>" class="input" value="<?php echo $results[$field_slug] ?? ''; ?>">
|
||||
|
||||
<?php wu_print_signup_field_options($field['options'], $field); ?>
|
||||
|
||||
@ -424,7 +424,7 @@ function wu_print_signup_field($field_slug, $field, $results) {
|
||||
* @param array $user_meta
|
||||
* @return int|bool
|
||||
*/
|
||||
function wu_create_user(array $user_data, array $plan_data, array $user_meta = array()) {
|
||||
function wu_create_user(array $user_data, array $plan_data, array $user_meta = []) {
|
||||
|
||||
return WU_Signup()->create_user($user_data, $plan_data, $user_meta);
|
||||
|
||||
@ -442,7 +442,7 @@ function wu_create_user(array $user_data, array $plan_data, array $user_meta = a
|
||||
* @param array $site_meta
|
||||
* @return void
|
||||
*/
|
||||
function wu_create_site_legacy($user_id, array $site_data, $template_id = false, $site_meta = array()) {
|
||||
function wu_create_site_legacy($user_id, array $site_data, $template_id = false, $site_meta = []) {
|
||||
|
||||
return WU_Signup()->create_site($user_id, $site_data, $template_id, $site_meta);
|
||||
|
||||
|
@ -55,7 +55,7 @@ defined('ABSPATH') || exit;
|
||||
function wu_has_product($product_slug, $blocking = false, $site_id = '') {
|
||||
|
||||
if ( ! is_array($product_slug)) {
|
||||
$product_slug = array($product_slug);
|
||||
$product_slug = [$product_slug];
|
||||
}
|
||||
|
||||
if (empty($site_id)) {
|
||||
@ -152,10 +152,10 @@ function wu_generate_upgrade_to_unlock_url($args) {
|
||||
|
||||
$args = wp_parse_args(
|
||||
$args,
|
||||
array(
|
||||
[
|
||||
'module' => false,
|
||||
'type' => false,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$membership = wu_get_current_site()->get_membership();
|
||||
@ -190,18 +190,18 @@ function wu_generate_upgrade_to_unlock_button($title, $args) {
|
||||
|
||||
$args = wp_parse_args(
|
||||
$args,
|
||||
array(
|
||||
[
|
||||
'module' => false,
|
||||
'type' => false,
|
||||
'classes' => '',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$url = wu_generate_upgrade_to_unlock_url(
|
||||
array(
|
||||
[
|
||||
'module' => $args['module'],
|
||||
'type' => $args['type'],
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$element = sprintf(
|
||||
@ -230,13 +230,13 @@ function wu_async_activate_plugins($site_id, $plugins, $network_wide = false, $s
|
||||
|
||||
wu_enqueue_async_action(
|
||||
'wu_async_handle_plugins',
|
||||
array(
|
||||
[
|
||||
'action' => 'activate',
|
||||
'site_id' => $site_id,
|
||||
'plugins' => $plugins,
|
||||
'network_wide' => $network_wide,
|
||||
'silent' => $silent,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -255,13 +255,13 @@ function wu_async_deactivate_plugins($site_id, $plugins, $network_wide = false,
|
||||
|
||||
wu_enqueue_async_action(
|
||||
'wu_async_handle_plugins',
|
||||
array(
|
||||
[
|
||||
'action' => 'deactivate',
|
||||
'site_id' => $site_id,
|
||||
'plugins' => $plugins,
|
||||
'network_wide' => $network_wide,
|
||||
'silent' => $silent,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -278,9 +278,9 @@ function wu_async_switch_theme($site_id, $theme_stylesheet) {
|
||||
|
||||
wu_enqueue_async_action(
|
||||
'wu_async_switch_theme',
|
||||
array(
|
||||
[
|
||||
'site_id' => $site_id,
|
||||
'theme_stylesheet' => $theme_stylesheet,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ defined('ABSPATH') || exit;
|
||||
* @param array $state_array The array to convert.
|
||||
* @return string
|
||||
*/
|
||||
function wu_convert_to_state($state_array = array()) {
|
||||
function wu_convert_to_state($state_array = []) {
|
||||
|
||||
$object = (object) $state_array; // Force object to prevent issues with Vue.
|
||||
|
||||
@ -35,20 +35,20 @@ function wu_convert_to_state($state_array = array()) {
|
||||
function wu_remove_empty_p($content): ?string {
|
||||
|
||||
$content = preg_replace(
|
||||
array(
|
||||
[
|
||||
'#<p>\s*<(div|aside|section|article|header|footer)#',
|
||||
'#</(div|aside|section|article|header|footer)>\s*</p>#',
|
||||
'#</(div|aside|section|article|header|footer)>\s*<br ?/?>#',
|
||||
'#<(div|aside|section|article|header|footer)(.*?)>\s*</p>#',
|
||||
'#<p>\s*</(div|aside|section|article|header|footer)#',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'<$1',
|
||||
'</$1>',
|
||||
'</$1>',
|
||||
'<$1$2>',
|
||||
'</$1',
|
||||
),
|
||||
],
|
||||
$content
|
||||
);
|
||||
|
||||
@ -73,7 +73,7 @@ function wu_remove_empty_p($content): ?string {
|
||||
*
|
||||
* @param array $attributes The list of attributes.
|
||||
*/
|
||||
function wu_array_to_html_attrs($attributes = array()): string {
|
||||
function wu_array_to_html_attrs($attributes = []): string {
|
||||
|
||||
$attributes = array_map(fn($key, $value) => $key . '="' . htmlspecialchars((string) $value) . '"', array_keys($attributes), $attributes);
|
||||
|
||||
@ -148,9 +148,9 @@ function wu_preview_image($image_url, $label = false): string {
|
||||
*/
|
||||
function wu_get_icons_list() {
|
||||
|
||||
$all_icons = array();
|
||||
$all_icons = [];
|
||||
|
||||
$all_icons['WP Ultimo Icons'] = array(
|
||||
$all_icons['WP Ultimo Icons'] = [
|
||||
'dashicons-wu-add_task',
|
||||
'dashicons-wu-address',
|
||||
'dashicons-wu-add-to-list',
|
||||
@ -487,9 +487,9 @@ function wu_get_icons_list() {
|
||||
'dashicons-wu-wallet',
|
||||
'dashicons-wu-warning',
|
||||
'dashicons-wu-wp-ultimo',
|
||||
);
|
||||
];
|
||||
|
||||
$all_icons['Dashicons'] = array(
|
||||
$all_icons['Dashicons'] = [
|
||||
'dashicons-before dashicons-admin-appearance',
|
||||
'dashicons-before dashicons-admin-collapse',
|
||||
'dashicons-before dashicons-admin-comments',
|
||||
@ -744,7 +744,7 @@ function wu_get_icons_list() {
|
||||
'dashicons-before dashicons-wordpress',
|
||||
'dashicons-before dashicons-yes-alt',
|
||||
'dashicons-before dashicons-yes',
|
||||
);
|
||||
];
|
||||
|
||||
return apply_filters('wu_icons_list', $all_icons);
|
||||
}
|
||||
|
@ -60,14 +60,14 @@ function wu_get_membership_by_hash($hash) {
|
||||
* @param array $query Query arguments.
|
||||
* @return Membership[]
|
||||
*/
|
||||
function wu_get_memberships($query = array()) {
|
||||
function wu_get_memberships($query = []) {
|
||||
|
||||
if ( ! empty($query['search'])) {
|
||||
$customer_ids = wu_get_customers(
|
||||
array(
|
||||
[
|
||||
'search' => $query['search'],
|
||||
'fields' => 'ids',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if ( ! empty($customer_ids)) {
|
||||
@ -93,7 +93,7 @@ function wu_create_membership($membership_data) {
|
||||
* Shortcode atts clean the array from not-allowed keys, so we don't need to worry much.
|
||||
*/
|
||||
$membership_data = shortcode_atts(
|
||||
array(
|
||||
[
|
||||
'customer_id' => false,
|
||||
'user_id' => false,
|
||||
'migrated_from_id' => 0,
|
||||
@ -122,7 +122,7 @@ function wu_create_membership($membership_data) {
|
||||
'date_modified' => wu_get_current_time('mysql', true),
|
||||
'date_expiration' => wu_get_current_time('mysql', true),
|
||||
'skip_validation' => false,
|
||||
),
|
||||
],
|
||||
$membership_data
|
||||
);
|
||||
|
||||
@ -184,16 +184,16 @@ function wu_get_membership_customers($product_id) {
|
||||
* @param boolean $amount The amount. Increases accuracy.
|
||||
* @return \WP_Ultimo\Models\Membership|false
|
||||
*/
|
||||
function wu_get_membership_by_customer_gateway_id($customer_gateway_id, $allowed_gateways = array(), $amount = false) {
|
||||
function wu_get_membership_by_customer_gateway_id($customer_gateway_id, $allowed_gateways = [], $amount = false) {
|
||||
|
||||
$search_data = array(
|
||||
$search_data = [
|
||||
'gateway__in' => $allowed_gateways,
|
||||
'number' => 1,
|
||||
'gateway_customer_id__in' => array($customer_gateway_id),
|
||||
'status__in' => array('pending'),
|
||||
'gateway_customer_id__in' => [$customer_gateway_id],
|
||||
'status__in' => ['pending'],
|
||||
'orderby' => 'id',
|
||||
'order' => 'DESC',
|
||||
);
|
||||
];
|
||||
|
||||
if ( ! empty($amount)) {
|
||||
$search_data['initial_amount'] = $amount;
|
||||
@ -222,13 +222,13 @@ function wu_get_membership_product_price($membership, $product_id, $quantity, $o
|
||||
|
||||
// Create a Cart with this product
|
||||
$cart = new Cart(
|
||||
array(
|
||||
[
|
||||
'duration' => $membership->get_duration(),
|
||||
'duration_unit' => $membership->get_duration_unit(),
|
||||
'country' => $address->billing_country,
|
||||
'state' => $address->billing_state,
|
||||
'city' => $address->billing_city,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$discount_code = $membership->get_discount_code();
|
||||
@ -245,11 +245,11 @@ function wu_get_membership_product_price($membership, $product_id, $quantity, $o
|
||||
|
||||
$payment_data = array_merge(
|
||||
$cart->to_payment_data(),
|
||||
array(
|
||||
[
|
||||
'customer_id' => $membership->get_customer_id(),
|
||||
'membership_id' => $membership->get_id(),
|
||||
'gateway' => $membership->get_gateway(),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
// create a temporary payment to see the price.
|
||||
@ -301,11 +301,11 @@ function wu_membership_create_new_payment($membership, $should_cancel_pending_pa
|
||||
|
||||
$payment_data = array_merge(
|
||||
$cart->to_payment_data(),
|
||||
array(
|
||||
[
|
||||
'customer_id' => $membership->get_customer_id(),
|
||||
'membership_id' => $membership->get_id(),
|
||||
'gateway' => $membership->get_gateway(),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
// We will save the payment after we recalculate the totals.
|
||||
@ -347,13 +347,13 @@ function wu_get_membership_new_cart($membership) {
|
||||
$address = $membership->get_billing_address();
|
||||
|
||||
$cart = new Cart(
|
||||
array(
|
||||
[
|
||||
'duration' => $membership->get_duration(),
|
||||
'duration_unit' => $membership->get_duration_unit(),
|
||||
'country' => $address->billing_country,
|
||||
'state' => $address->billing_state,
|
||||
'city' => $address->billing_city,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$discount_code = $membership->get_discount_code();
|
||||
@ -371,7 +371,7 @@ function wu_get_membership_new_cart($membership) {
|
||||
if (round(abs($difference), wu_currency_decimal_filter()) > 0) {
|
||||
$type_translate = $difference < 0 ? __('credit', 'wp-ultimo') : __('debit', 'wp-ultimo');
|
||||
|
||||
$line_item_params = array(
|
||||
$line_item_params = [
|
||||
'hash' => 'ADJUSTMENT',
|
||||
'type' => $difference < 0 ? 'credit' : 'fee',
|
||||
// translators: %s is the type of adjustment (credit or debit).
|
||||
@ -384,7 +384,7 @@ function wu_get_membership_new_cart($membership) {
|
||||
'quantity' => 1,
|
||||
'duration' => $membership->get_duration(),
|
||||
'duration_unit' => $membership->get_duration_unit(),
|
||||
);
|
||||
];
|
||||
|
||||
$adjustment_line_item = new \WP_Ultimo\Checkout\Line_Item($line_item_params);
|
||||
|
||||
@ -398,7 +398,7 @@ function wu_get_membership_new_cart($membership) {
|
||||
$difference = $membership->get_initial_amount() - $cart->get_total();
|
||||
$type_translate = $difference < 0 ? __('credit', 'wp-ultimo') : __('debit', 'wp-ultimo');
|
||||
|
||||
$line_item_params = array(
|
||||
$line_item_params = [
|
||||
'hash' => 'INITADJUSTMENT',
|
||||
'type' => $difference < 0 ? 'credit' : 'fee',
|
||||
// translators: %s is the type of adjustment (credit or debit).
|
||||
@ -409,7 +409,7 @@ function wu_get_membership_new_cart($membership) {
|
||||
'taxable' => false,
|
||||
'recurring' => false,
|
||||
'quantity' => 1,
|
||||
);
|
||||
];
|
||||
|
||||
$adjustment_line_item = new \WP_Ultimo\Checkout\Line_Item($line_item_params);
|
||||
|
||||
@ -440,9 +440,9 @@ function wu_get_membership_update_url($membership) {
|
||||
|
||||
if ($url) {
|
||||
return add_query_arg(
|
||||
array(
|
||||
[
|
||||
'membership' => $membership_hash,
|
||||
),
|
||||
],
|
||||
$url
|
||||
);
|
||||
}
|
||||
@ -455,10 +455,10 @@ function wu_get_membership_update_url($membership) {
|
||||
|
||||
if (count($sites) > 0) {
|
||||
return add_query_arg(
|
||||
array(
|
||||
[
|
||||
'page' => 'wu-checkout',
|
||||
'membership' => $membership_hash,
|
||||
),
|
||||
],
|
||||
get_admin_url($sites[0]->get_id())
|
||||
);
|
||||
}
|
||||
@ -467,10 +467,10 @@ function wu_get_membership_update_url($membership) {
|
||||
$url = $checkout_pages->get_page_url('register');
|
||||
|
||||
return add_query_arg(
|
||||
array(
|
||||
[
|
||||
'membership' => $membership_hash,
|
||||
'wu_form' => 'wu-checkout',
|
||||
),
|
||||
],
|
||||
$url
|
||||
);
|
||||
}
|
||||
|
@ -20,12 +20,12 @@ function wu_mock_site($seed = false) {
|
||||
|
||||
$atts = apply_filters(
|
||||
'wu_mock_site',
|
||||
array(
|
||||
[
|
||||
'title' => __('Example Site', 'wp-ultimo'),
|
||||
'description' => __('This is an example of a site description.', 'wp-ultimo'),
|
||||
'domain' => __('examplesite.dev', 'wp-ultimo'),
|
||||
'path' => '/',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if ($seed) {
|
||||
@ -45,14 +45,14 @@ function wu_mock_site($seed = false) {
|
||||
function wu_mock_membership() {
|
||||
|
||||
return new \WP_Ultimo\Models\Membership(
|
||||
array(
|
||||
[
|
||||
'billing_address' => new \WP_Ultimo\Objects\Billing_Address(
|
||||
array(
|
||||
[
|
||||
'company_name' => 'Company Co.',
|
||||
'billing_email' => 'company@co.dev',
|
||||
)
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -65,9 +65,9 @@ function wu_mock_membership() {
|
||||
function wu_mock_product() {
|
||||
|
||||
$product = new \WP_Ultimo\Models\Product(
|
||||
array(
|
||||
[
|
||||
'name' => __('Test Product', 'wp-ultimo'),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$product->_mocked = true;
|
||||
@ -84,18 +84,18 @@ function wu_mock_product() {
|
||||
function wu_mock_customer() {
|
||||
|
||||
$customer = new \WP_Ultimo\Models\Customer(
|
||||
array(
|
||||
[
|
||||
'billing_address' => new \WP_Ultimo\Objects\Billing_Address(
|
||||
array(
|
||||
[
|
||||
'company_name' => 'Company Co.',
|
||||
'billing_email' => 'company@co.dev',
|
||||
)
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$customer->_user = (object) array(
|
||||
'data' => (object) array(
|
||||
$customer->_user = (object) [
|
||||
'data' => (object) [
|
||||
'ID' => '1',
|
||||
'user_login' => 'mockeduser',
|
||||
'user_pass' => 'passwordhash',
|
||||
@ -108,8 +108,8 @@ function wu_mock_customer() {
|
||||
'display_name' => 'John McMocked',
|
||||
'spam' => '0',
|
||||
'deleted' => '0',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
return $customer;
|
||||
}
|
||||
@ -125,15 +125,15 @@ function wu_mock_payment() {
|
||||
$payment = new \WP_Ultimo\Models\Payment();
|
||||
|
||||
$line_item = new \WP_Ultimo\Checkout\Line_Item(
|
||||
array(
|
||||
[
|
||||
'product' => wu_mock_product(),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$payment->set_line_items(
|
||||
array(
|
||||
[
|
||||
$line_item,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
return $payment;
|
||||
@ -148,14 +148,14 @@ function wu_mock_payment() {
|
||||
function wu_mock_domain() {
|
||||
|
||||
$domain = new \WP_Ultimo\Models\Domain(
|
||||
array(
|
||||
[
|
||||
'blog_id' => 1,
|
||||
'domain' => 'example.com',
|
||||
'active' => true,
|
||||
'primary_domain' => true,
|
||||
'secure' => true,
|
||||
'stage' => 'checking-dns',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
return $domain;
|
||||
|
@ -37,10 +37,10 @@ function wu_cast_model_to_array($model) {
|
||||
*/
|
||||
function wu_models_to_options($models, $label_field = 'name') {
|
||||
|
||||
$options_list = array();
|
||||
$options_list = [];
|
||||
|
||||
foreach ($models as $model) {
|
||||
$options_list[ $model->get_id() ] = call_user_func(array($model, "get_{$label_field}"));
|
||||
$options_list[ $model->get_id() ] = call_user_func([$model, "get_{$label_field}"]);
|
||||
}
|
||||
|
||||
return $options_list;
|
||||
@ -56,7 +56,7 @@ function wu_models_to_options($models, $label_field = 'name') {
|
||||
*/
|
||||
function wu_model_get_schema($class_name) {
|
||||
|
||||
$schema = array();
|
||||
$schema = [];
|
||||
|
||||
if (method_exists($class_name, 'get_schema')) {
|
||||
$schema = $class_name::get_schema();
|
||||
@ -75,13 +75,13 @@ function wu_model_get_schema($class_name) {
|
||||
*/
|
||||
function wu_model_get_required_fields($class_name) {
|
||||
|
||||
$required_fields = array();
|
||||
$required_fields = [];
|
||||
|
||||
if (method_exists($class_name, 'validation_rules')) {
|
||||
$validation_rules = (new $class_name())->validation_rules();
|
||||
|
||||
foreach ($validation_rules as $field => $validation_rule) {
|
||||
if (strpos((string) $validation_rule, 'required|') !== false || $validation_rule === 'required') {
|
||||
if (str_contains((string) $validation_rule, 'required|') || $validation_rule === 'required') {
|
||||
$required_fields[] = $field;
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ defined('ABSPATH') || exit;
|
||||
*/
|
||||
function wu_extract_number($str) {
|
||||
|
||||
$matches = array();
|
||||
$matches = [];
|
||||
|
||||
preg_match_all('/\d+/', $str, $matches);
|
||||
|
||||
|
@ -17,7 +17,7 @@ defined('ABSPATH') || exit;
|
||||
* @param mixed $default The default value.
|
||||
* @return mixed
|
||||
*/
|
||||
function wu_get_option($option_name = 'settings', $default = array()) {
|
||||
function wu_get_option($option_name = 'settings', $default = []) {
|
||||
|
||||
$option_value = get_network_option(null, wu_slugify($option_name), $default);
|
||||
|
||||
|
@ -33,7 +33,7 @@ function wu_get_payment($payment_id) {
|
||||
* @param array $query Query arguments.
|
||||
* @return \WP_Ultimo\Models\Payment[]
|
||||
*/
|
||||
function wu_get_payments($query = array()) {
|
||||
function wu_get_payments($query = []) {
|
||||
|
||||
return \WP_Ultimo\Models\Payment::query($query);
|
||||
}
|
||||
@ -99,9 +99,9 @@ function wu_create_payment($payment_data, $save = true) {
|
||||
* Shortcode atts clean the array from not-allowed keys, so we don't need to worry much.
|
||||
*/
|
||||
$payment_data = shortcode_atts(
|
||||
array(
|
||||
'line_items' => array(),
|
||||
'meta' => array(),
|
||||
[
|
||||
'line_items' => [],
|
||||
'meta' => [],
|
||||
'customer_id' => false,
|
||||
'membership_id' => false,
|
||||
'parent_id' => '',
|
||||
@ -119,7 +119,7 @@ function wu_create_payment($payment_data, $save = true) {
|
||||
'date_modified' => wu_get_current_time('mysql', true),
|
||||
'migrated_from_id' => 0,
|
||||
'skip_validation' => false,
|
||||
),
|
||||
],
|
||||
$payment_data
|
||||
);
|
||||
|
||||
@ -145,10 +145,10 @@ function wu_create_payment($payment_data, $save = true) {
|
||||
*/
|
||||
function wu_get_refundable_payment_types() {
|
||||
|
||||
$refundable_payment_types = array(
|
||||
$refundable_payment_types = [
|
||||
Payment_Status::COMPLETED,
|
||||
Payment_Status::PARTIAL_REFUND,
|
||||
);
|
||||
];
|
||||
|
||||
return apply_filters('wu_get_refundable_payment_type', $refundable_payment_types);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ function wu_get_product($product_id_or_slug) {
|
||||
* @param array $query Query arguments.
|
||||
* @return Product[]
|
||||
*/
|
||||
function wu_get_products($query = array()) {
|
||||
function wu_get_products($query = []) {
|
||||
|
||||
return Product::query($query);
|
||||
}
|
||||
@ -49,7 +49,7 @@ function wu_get_products($query = array()) {
|
||||
* @param array $query Query arguments.
|
||||
* @return Product[]
|
||||
*/
|
||||
function wu_get_plans($query = array()) {
|
||||
function wu_get_plans($query = []) {
|
||||
|
||||
$query['type'] = 'plan';
|
||||
|
||||
@ -70,7 +70,7 @@ function wu_get_plans($query = array()) {
|
||||
*/
|
||||
function wu_get_plans_as_options() {
|
||||
|
||||
$options = array();
|
||||
$options = [];
|
||||
|
||||
foreach (wu_get_plans() as $plan) {
|
||||
$options[ $plan->get_id() ] = $plan->get_name();
|
||||
@ -117,7 +117,7 @@ function wu_create_product($product_data) {
|
||||
|
||||
$product_data = wp_parse_args(
|
||||
$product_data,
|
||||
array(
|
||||
[
|
||||
'name' => false,
|
||||
'description' => false,
|
||||
'currency' => false,
|
||||
@ -139,10 +139,10 @@ function wu_create_product($product_data) {
|
||||
'date_created' => wu_get_current_time('mysql', true),
|
||||
'date_modified' => wu_get_current_time('mysql', true),
|
||||
'migrated_from_id' => 0,
|
||||
'meta' => array(),
|
||||
'available_addons' => array(),
|
||||
'meta' => [],
|
||||
'available_addons' => [],
|
||||
'group' => '',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$product = new Product($product_data);
|
||||
@ -177,7 +177,7 @@ function wu_get_product_groups(): array {
|
||||
*/
|
||||
function wu_segregate_products($products) {
|
||||
|
||||
$results = array(false, array());
|
||||
$results = [false, []];
|
||||
|
||||
foreach ($products as $product) {
|
||||
if (is_a($product, Product::class) === false) {
|
||||
|
@ -34,7 +34,7 @@ function wu_reflection_parse_object_arguments($class_name) {
|
||||
|
||||
$doc_block_factory = DocBlockFactory::createInstance();
|
||||
|
||||
$arguments = array();
|
||||
$arguments = [];
|
||||
|
||||
/**
|
||||
* Tries to fetch the database schema, if one exists.
|
||||
@ -55,11 +55,11 @@ function wu_reflection_parse_object_arguments($class_name) {
|
||||
$param = $doc_block->getTagsByName('param');
|
||||
|
||||
if (isset($param[0]) && is_object($param[0])) {
|
||||
$arguments[ $column['name'] ] = array(
|
||||
$arguments[ $column['name'] ] = [
|
||||
'description' => (string) $param[0]->getDescription(),
|
||||
'type' => (string) $param[0]->getType(),
|
||||
'required' => false, // Actual value set later
|
||||
);
|
||||
];
|
||||
|
||||
if ($db_schema) {
|
||||
$db_column = wu_array_find_first_by($db_schema, 'name', $column['name']);
|
||||
@ -78,7 +78,7 @@ function wu_reflection_parse_object_arguments($class_name) {
|
||||
if (isset($option[0])) {
|
||||
$description = (string) $option[0]->getDescription();
|
||||
|
||||
if (strpos($description, '\\WP_Ultimo\\') !== false) {
|
||||
if (str_contains($description, '\\WP_Ultimo\\')) {
|
||||
$enum_options = new $description();
|
||||
|
||||
$arguments[ $column['name'] ]['enum'] = array_map('strtolower', array_keys(array_flip($enum_options->get_options())));
|
||||
@ -103,17 +103,17 @@ function wu_reflection_parse_object_arguments($class_name) {
|
||||
*/
|
||||
function wu_reflection_parse_arguments_from_setters($class_name, $return_schema = true) {
|
||||
|
||||
$arguments = array();
|
||||
$arguments = [];
|
||||
|
||||
foreach (get_class_methods($class_name) as $setter_name) {
|
||||
if (preg_match('/^set_/', $setter_name)) {
|
||||
$argument = str_replace('set_', '', $setter_name);
|
||||
|
||||
if ($return_schema) {
|
||||
$arguments[] = array(
|
||||
$arguments[] = [
|
||||
'name' => $argument,
|
||||
'type' => '',
|
||||
);
|
||||
];
|
||||
} else {
|
||||
$arguments[] = $argument;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ function wu_rest_get_endpoint_schema($class_name, $context = 'create', $force_ge
|
||||
|
||||
$from_cache = false;
|
||||
|
||||
$schema = array();
|
||||
$schema = [];
|
||||
|
||||
$endpoint = wu_rest_get_endpoint_from_class_name($class_name);
|
||||
|
||||
|
@ -34,7 +34,7 @@ function wu_get_next_queue_run() {
|
||||
* @param string $group The group to assign this job to.
|
||||
* @return int The action ID.
|
||||
*/
|
||||
function wu_enqueue_async_action($hook, $args = array(), $group = '') {
|
||||
function wu_enqueue_async_action($hook, $args = [], $group = '') {
|
||||
|
||||
return wu_switch_blog_and_run(fn() => as_enqueue_async_action($hook, $args, $group));
|
||||
}
|
||||
@ -51,7 +51,7 @@ function wu_enqueue_async_action($hook, $args = array(), $group = '') {
|
||||
*
|
||||
* @return int The action ID.
|
||||
*/
|
||||
function wu_schedule_single_action($timestamp, $hook, $args = array(), $group = '') {
|
||||
function wu_schedule_single_action($timestamp, $hook, $args = [], $group = '') {
|
||||
|
||||
return wu_switch_blog_and_run(fn() => as_schedule_single_action($timestamp, $hook, $args, $group));
|
||||
}
|
||||
@ -69,7 +69,7 @@ function wu_schedule_single_action($timestamp, $hook, $args = array(), $group =
|
||||
*
|
||||
* @return int The action ID.
|
||||
*/
|
||||
function wu_schedule_recurring_action($timestamp, $interval_in_seconds, $hook, $args = array(), $group = '') {
|
||||
function wu_schedule_recurring_action($timestamp, $interval_in_seconds, $hook, $args = [], $group = '') {
|
||||
|
||||
return wu_switch_blog_and_run(fn() => as_schedule_recurring_action($timestamp, $interval_in_seconds, $hook, $args, $group));
|
||||
}
|
||||
@ -99,7 +99,7 @@ function wu_schedule_recurring_action($timestamp, $interval_in_seconds, $hook, $
|
||||
*
|
||||
* @return int The action ID.
|
||||
*/
|
||||
function wu_schedule_cron_action($timestamp, $schedule, $hook, $args = array(), $group = '') {
|
||||
function wu_schedule_cron_action($timestamp, $schedule, $hook, $args = [], $group = '') {
|
||||
|
||||
return wu_switch_blog_and_run(fn() => as_schedule_cron_action($timestamp, $schedule, $hook, $args, $group));
|
||||
}
|
||||
@ -115,7 +115,7 @@ function wu_schedule_cron_action($timestamp, $schedule, $hook, $args = array(),
|
||||
*
|
||||
* @return string|null The scheduled action ID if a scheduled action was found, or null if no matching action found.
|
||||
*/
|
||||
function wu_unschedule_action($hook, $args = array(), $group = '') {
|
||||
function wu_unschedule_action($hook, $args = [], $group = '') {
|
||||
|
||||
return wu_switch_blog_and_run(fn() => as_unschedule_action($hook, $args, $group));
|
||||
}
|
||||
@ -129,7 +129,7 @@ function wu_unschedule_action($hook, $args = array(), $group = '') {
|
||||
* @param array $args Args that would have been passed to the job.
|
||||
* @param string $group The group the job is assigned to.
|
||||
*/
|
||||
function wu_unschedule_all_actions($hook, $args = array(), $group = '') {
|
||||
function wu_unschedule_all_actions($hook, $args = [], $group = '') {
|
||||
|
||||
return wu_switch_blog_and_run(fn() => as_unschedule_all_actions($hook, $args, $group));
|
||||
}
|
||||
@ -166,7 +166,7 @@ function wu_next_scheduled_action($hook, $args = null, $group = '') {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function wu_get_scheduled_actions($args = array(), $return_format = OBJECT) {
|
||||
function wu_get_scheduled_actions($args = [], $return_format = OBJECT) {
|
||||
|
||||
return wu_switch_blog_and_run(fn() => as_get_scheduled_actions($args, $return_format));
|
||||
}
|
||||
|
@ -106,11 +106,11 @@ function wu_register_settings_side_panel($section_slug, $atts) {
|
||||
|
||||
$atts = wp_parse_args(
|
||||
$atts,
|
||||
array(
|
||||
[
|
||||
'title' => __('Side Panel', 'wp-ultimo'),
|
||||
'render' => '__return_false',
|
||||
'show' => '__return_true',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$callback = wu_get_isset($atts, 'show', '__return_true');
|
||||
@ -154,7 +154,7 @@ function wu_get_network_logo($size = 'full') {
|
||||
return $settings_logo[0];
|
||||
}
|
||||
|
||||
$logo = wu_get_asset('logo.png', 'img');
|
||||
$logo = wu_get_asset('logo.webp', 'img');
|
||||
|
||||
$custom_logo = wp_get_attachment_image_src(get_theme_mod('custom_logo'), $size);
|
||||
|
||||
@ -173,7 +173,7 @@ function wu_get_network_logo($size = 'full') {
|
||||
*/
|
||||
function wu_get_network_favicon($size = '48') {
|
||||
|
||||
$custom_icon = get_site_icon_url($size, wu_get_asset('badge.png', 'img'), wu_get_main_site_id());
|
||||
$custom_icon = get_site_icon_url($size, wu_get_asset('badge.webp', 'img'), wu_get_main_site_id());
|
||||
|
||||
return $custom_icon;
|
||||
}
|
||||
|
@ -53,15 +53,15 @@ function wu_get_site_by_hash($hash) {
|
||||
* @param array $query Query arguments.
|
||||
* @return \WP_Ultimo\Models\Site[]
|
||||
*/
|
||||
function wu_get_sites($query = array()) {
|
||||
function wu_get_sites($query = []) {
|
||||
|
||||
if ( ! empty($query['search'])) {
|
||||
$domain_ids = wu_get_domains(
|
||||
array(
|
||||
[
|
||||
'number' => -1,
|
||||
'search' => '*' . $query['search'] . '*',
|
||||
'fields' => array('blog_id'),
|
||||
)
|
||||
'fields' => ['blog_id'],
|
||||
]
|
||||
);
|
||||
|
||||
$domain_ids = array_column($domain_ids, 'blog_id');
|
||||
@ -84,13 +84,13 @@ function wu_get_sites($query = array()) {
|
||||
* @param array $query Query arguments.
|
||||
* @return array
|
||||
*/
|
||||
function wu_get_site_templates($query = array()) {
|
||||
function wu_get_site_templates($query = []) {
|
||||
|
||||
$query = wp_parse_args(
|
||||
$query,
|
||||
array(
|
||||
[
|
||||
'number' => 9999, // By default, we try to get ALL available templates.
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
return \WP_Ultimo\Models\Site::get_all_by_type('site_template', $query);
|
||||
@ -108,7 +108,7 @@ function wu_handle_site_domain($domain) {
|
||||
|
||||
global $current_site;
|
||||
|
||||
if (strpos($domain, 'http') === false) {
|
||||
if (! str_contains($domain, 'http')) {
|
||||
$domain = "https://{$domain}";
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ function wu_create_site($site_data) {
|
||||
|
||||
$site_data = wp_parse_args(
|
||||
$site_data,
|
||||
array(
|
||||
[
|
||||
'domain' => $current_site->domain,
|
||||
'path' => '/',
|
||||
'title' => false,
|
||||
@ -139,7 +139,7 @@ function wu_create_site($site_data) {
|
||||
'featured_image_id' => 0,
|
||||
'duplication_arguments' => false,
|
||||
'public' => true,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$site = new \WP_Ultimo\Models\Site($site_data);
|
||||
@ -166,7 +166,7 @@ function wu_get_site_domain_and_path($path_or_subdomain = '/', $base_domain = fa
|
||||
|
||||
$path_or_subdomain = trim($path_or_subdomain, '/');
|
||||
|
||||
$domain = $base_domain ? $base_domain : $current_site->domain;
|
||||
$domain = $base_domain ?: $current_site->domain;
|
||||
|
||||
$d = new \stdClass();
|
||||
|
||||
|
@ -55,7 +55,7 @@ function wu_set_order_from_index($list, $order_key = 'order') {
|
||||
|
||||
foreach ($list as &$item) {
|
||||
if (isset($item[ $order_key ]) === false) {
|
||||
$index = $index ? $index : 1; // phpcs:ignore
|
||||
$index = $index ?: 1; // phpcs:ignore
|
||||
|
||||
$item[ $order_key ] = $index * 10;
|
||||
|
||||
|
@ -34,7 +34,7 @@ function wu_string_to_bool($string) {
|
||||
*/
|
||||
function wu_slug_to_name($slug) {
|
||||
|
||||
$slug = str_replace(array('-', '_'), ' ', $slug);
|
||||
$slug = str_replace(['-', '_'], ' ', $slug);
|
||||
|
||||
return ucwords($slug);
|
||||
}
|
||||
|
@ -47,9 +47,9 @@ function wu_get_tax_category($tax_category = 'default') {
|
||||
return wu_get_isset(
|
||||
$tax_categories,
|
||||
$tax_category,
|
||||
array(
|
||||
'rates' => array(),
|
||||
)
|
||||
[
|
||||
'rates' => [],
|
||||
]
|
||||
);
|
||||
}
|
||||
/**
|
||||
@ -128,12 +128,12 @@ function wu_get_tax_amount($base_price, $amount, $type, $format = true, $inclusi
|
||||
function wu_get_applicable_tax_rates($country, $tax_category = 'default', $state = '*', $city = '*') {
|
||||
|
||||
if ( ! $country) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
$tax_category = wu_get_tax_category($tax_category);
|
||||
|
||||
$results = array();
|
||||
$results = [];
|
||||
|
||||
foreach ($tax_category['rates'] as &$rate) {
|
||||
/*
|
||||
@ -144,11 +144,11 @@ function wu_get_applicable_tax_rates($country, $tax_category = 'default', $state
|
||||
|
||||
$keys_of_interest = array_intersect_key(
|
||||
$rate,
|
||||
array(
|
||||
[
|
||||
'country' => 1,
|
||||
'state' => 1,
|
||||
'city' => 1,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$priority = 0;
|
||||
|
@ -17,7 +17,7 @@ defined('ABSPATH') || exit;
|
||||
* @param string|false $default_view View to be used if the view passed is not found. Used as fallback.
|
||||
* @return void
|
||||
*/
|
||||
function wu_get_template($view, $args = array(), $default_view = false) {
|
||||
function wu_get_template($view, $args = [], $default_view = false) {
|
||||
|
||||
/**
|
||||
* Allow plugin developers to add extra variable to the render context globally.
|
||||
@ -49,12 +49,12 @@ function wu_get_template($view, $args = array(), $default_view = false) {
|
||||
*/
|
||||
$replaceable_views = apply_filters(
|
||||
'wu_view_override_replaceable_views',
|
||||
array(
|
||||
[
|
||||
'signup',
|
||||
'emails',
|
||||
'forms',
|
||||
'checkout',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
/*
|
||||
@ -81,7 +81,7 @@ function wu_get_template($view, $args = array(), $default_view = false) {
|
||||
* @param string|false $default_view View to be used if the view passed is not found. Used as fallback.
|
||||
* @return string
|
||||
*/
|
||||
function wu_get_template_contents($view, $args = array(), $default_view = false) {
|
||||
function wu_get_template_contents($view, $args = [], $default_view = false) {
|
||||
|
||||
ob_start();
|
||||
|
||||
|
@ -50,7 +50,7 @@ function wu_replace_scheme($url, $new_scheme = '') {
|
||||
* @param array $query URL query parameters.
|
||||
* @return string
|
||||
*/
|
||||
function wu_network_admin_url($path, $query = array()) {
|
||||
function wu_network_admin_url($path, $query = []) {
|
||||
|
||||
$path = sprintf('admin.php?page=%s', $path);
|
||||
|
||||
@ -70,7 +70,7 @@ function wu_network_admin_url($path, $query = array()) {
|
||||
* @param null|string $scheme URL scheme. Follows the same rules as the scheme param of get_home_url.
|
||||
* @return string
|
||||
*/
|
||||
function wu_ajax_url($when = null, $query_args = array(), $site_id = false, $scheme = null) {
|
||||
function wu_ajax_url($when = null, $query_args = [], $site_id = false, $scheme = null) {
|
||||
|
||||
if (empty($site_id)) {
|
||||
$site_id = get_current_blog_id();
|
||||
@ -79,7 +79,7 @@ function wu_ajax_url($when = null, $query_args = array(), $site_id = false, $sch
|
||||
$base_url = get_home_url($site_id, '', $scheme);
|
||||
|
||||
if ( ! is_array($query_args)) {
|
||||
$query_args = array();
|
||||
$query_args = [];
|
||||
}
|
||||
|
||||
$query_args['wu-ajax'] = 1;
|
||||
|
@ -22,7 +22,7 @@ function wu_get_roles_as_options($add_default_option = false) {
|
||||
require_once ABSPATH . 'wp-admin/includes/user.php';
|
||||
}
|
||||
|
||||
$roles = array();
|
||||
$roles = [];
|
||||
|
||||
if ($add_default_option) {
|
||||
$roles['default'] = __('Use WP Multisite WaaS default', 'wp-ultimo');
|
||||
|
@ -19,7 +19,7 @@ use WP_Ultimo\Models\Webhook;
|
||||
* @param array $query Query arguments.
|
||||
* @return \WP_Ultimo\Models\Webhook[]
|
||||
*/
|
||||
function wu_get_webhooks($query = array()) {
|
||||
function wu_get_webhooks($query = []) {
|
||||
|
||||
return \WP_Ultimo\Models\Webhook::query($query);
|
||||
}
|
||||
@ -51,7 +51,7 @@ function wu_create_webhook($webhook_data) {
|
||||
|
||||
$webhook_data = wp_parse_args(
|
||||
$webhook_data,
|
||||
array(
|
||||
[
|
||||
'name' => false,
|
||||
'webhook_url' => false,
|
||||
'event' => false,
|
||||
@ -60,7 +60,7 @@ function wu_create_webhook($webhook_data) {
|
||||
'date_created' => wu_get_current_time('mysql', true),
|
||||
'date_modified' => wu_get_current_time('mysql', true),
|
||||
'migrated_from_id' => 0,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$webhook = new Webhook($webhook_data);
|
||||
|
Reference in New Issue
Block a user