Prep Plugin for release on WordPress.org

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.
This commit is contained in:
David Stone
2025-04-07 09:15:21 -06:00
parent f05ab77418
commit a815fdf179
290 changed files with 2999 additions and 3269 deletions

View File

@ -6,20 +6,14 @@
*/
?>
<div id="dashboard-filters" class="wp-filter wu-filter">
<ul class="filter-links">
<?php foreach ($views as $tab => $view) : ?>
<li class="<?php echo $tab === $active_tab ? 'current' : ''; ?>">
<a href="<?php echo esc_attr($view['url']); ?>"
class="<?php echo $tab === $active_tab ? 'current wu-font-medium' : ''; ?> wu-loader">
<?php echo $view['label']; ?>
</a>
</li>
<?php endforeach; ?>
<?php foreach ($views as $tab => $view) : ?>
<li class="<?php echo esc_attr($tab === $active_tab ? 'current' : ''); ?>">
<a href="<?php echo esc_url($view['url']); ?>" class="wu-loader <?php echo esc_attr($tab === $active_tab ? 'current wu-font-medium' : ''); ?>">
<?php echo esc_html($view['label']); ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<ul class="filter-links sm:wu-float-right sm:wu-w-1/2 lg:wu-w-1/4 wu--mx-2 wu-block sm:wu-inline-block">
@ -29,38 +23,29 @@
id="wu-date-range"
style="min-height: 28px;"
class="wu-border-0 wu-border-l wu-border-gray-300 wu-bg-gray-100 wu-w-full wu-text-right wu-py-3 wu-outline-none wu-rounded-none"
placeholder="Loading..."
placeholder="<?php esc_html_e('Loading...'); ?>'"
>
</li>
</ul>
<ul class="wu-hidden md:wu-inline-block filter-links sm:wu-float-right md:wu-mr-6">
<?php foreach ($preset_options as $slug => $preset) : ?>
<?php
$link = add_query_arg(
$link = add_query_arg(
[
'start_date' => $preset['start_date'],
'end_date' => $preset['end_date'],
'preset' => $slug,
]
);
$request_slug = wu_request('preset', 'none');
?>
<li class="<?php echo $slug === $request_slug ? 'current' : ''; ?>">
<a href="<?php echo esc_attr($link); ?>"
class="<?php echo $slug === $request_slug ? 'current wu-font-medium' : ''; ?> wu-loader">
<?php echo $preset['label']; ?>
</a>
</li>
<?php endforeach; ?>
<li class="<?php echo esc_attr($slug === $request_slug ? 'current' : ''); ?>">
<a href="<?php echo esc_url($link); ?>" class="wu-loader <?php echo esc_attr($slug === $request_slug ? 'current wu-font-medium' : ''); ?>">
<?php echo esc_html($preset['label']); ?>
</a>
</li>
<?php endforeach; ?>
</ul>
</div>

View File

@ -7,37 +7,37 @@
?>
<div class="wu-styling">
<div class="wu-widget-inset">
<div class="wu-widget-inset">
<?php
<?php
$data = [];
$slug = 'signup_countries';
$headers = [
__('Country', 'wp-multisite-waas'),
__('Customer Count', 'wp-multisite-waas'),
];
$data = [];
$slug = 'signup_countries';
$headers = [
__('Country', 'wp-multisite-waas'),
__('Customer Count', 'wp-multisite-waas'),
];
foreach ($countries as $country_code => $count) {
$line = [
wu_get_country_name($country_code),
$count,
];
foreach ($countries as $country_code => $count) {
$line = [
wu_get_country_name($country_code),
$count,
];
$data[] = $line;
}
$data[] = $line;
}
$page->render_csv_button(
[
'headers' => $headers,
'data' => $data,
'slug' => $slug,
]
);
$page->render_csv_button(
[
'headers' => $headers,
'data' => $data,
'slug' => $slug,
]
);
?>
?>
</div>
</div>
</div>
@ -45,68 +45,61 @@ $page->render_csv_button(
<div class="wu-advanced-filters wu--mx-3 wu--mb-3 wu-mt-3">
<table class="wp-list-table widefat fixed striped wu-border-t-0 wu-border-l-0 wu-border-r-0">
<thead>
<tr>
<th><?php esc_html_e('Country', 'wp-multisite-waas'); ?></th>
<th class="wu-text-right"><?php esc_html_e('Customer Count', 'wp-multisite-waas'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($countries as $country_code => $count) : ?>
<table class="wp-list-table widefat fixed striped wu-border-t-0 wu-border-l-0 wu-border-r-0">
<thead>
<tr>
<td>
<th><?php esc_html_e('Country', 'wp-multisite-waas'); ?></th>
<th class="wu-text-right"><?php esc_html_e('Customer Count', 'wp-multisite-waas'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($countries as $country_code => $count) : ?>
<tr>
<td>
<?php
printf(
'<span class="wu-flag-icon wu-w-5 wu-mr-1" %s>%s</span>',
wu_tooltip_text(esc_html(wu_get_country_name($country_code))), // phpcs:ignore WordPress.Security.EscapeOutput
esc_html(wu_get_flag_emoji($country_code)),
);
?>
<?php echo esc_html(wu_get_country_name($country_code)); ?>
</td>
<td class="wu-text-right"><?php echo esc_html($count); ?></td>
</tr>
<?php
printf(
'<span class="wu-flag-icon wu-w-5 wu-mr-1" %s>%s</span>',
wu_tooltip_text(wu_get_country_name($country_code)), // phpcs:ignore WordPress.Security.EscapeOutput
esc_html(wu_get_flag_emoji($country_code)),
);
$state_list = wu_get_states_of_customers($country_code);
$_state_count = 0;
?>
<?php echo esc_html(wu_get_country_name($country_code)); ?>
</td>
<td class="wu-text-right"><?php echo esc_html($count); ?></td>
</tr>
<?php
<?php foreach ($state_list as $state => $state_count) : ?>
<tr>
<td class="wu-text-xs">|&longrightarrow; <?php echo esc_html($state); ?></td>
<td class="wu-text-right"><?php echo esc_html($state_count); ?></td>
</tr>
<?php endforeach; ?>
$state_list = wu_get_states_of_customers($country_code);
$_state_count = 0;
?>
<?php
foreach ($state_list as $state => $state_count) :
$_state_count += $state_count;
?>
<tr>
<td class="wu-text-xs">|&longrightarrow; <?php echo esc_html($state); ?></td>
<td class="wu-text-right"><?php echo esc_html($state_count); ?></td>
</tr>
<?php if ($state_list && $count - $_state_count >= 0) : ?>
<tr>
<td class="wu-text-xs">|&longrightarrow; <?php esc_html_e('Other', 'wp-multisite-waas'); ?></td>
<td class="wu-text-right"><?php echo esc_html($count - $_state_count); ?></td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
<?php if ($state_list && $count - $_state_count >= 0) : ?>
</tbody>
<tr>
<td class="wu-text-xs">|&longrightarrow; <?php esc_html_e('Other', 'wp-multisite-waas'); ?></td>
<td class="wu-text-right"><?php echo esc_html($count - $_state_count); ?></td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
</tbody>
</table>
</table>
</div>
@ -114,7 +107,7 @@ $page->render_csv_button(
<div class="wu-bg-gray-100 wu-p-4 wu-rounded wu-mt-6">
<?php esc_html_e('No countries registered yet.', 'wp-multisite-waas'); ?>
<?php esc_html_e('No countries registered yet.', 'wp-multisite-waas'); ?>
</div>

View File

@ -8,37 +8,35 @@
<div class="wu-styling">
<div class="wu-widget-inset">
<div class="wu-widget-inset">
<?php
<?php
$data = [];
$slug = 'signup_forms';
$headers = [
__('Checkout Form', 'wp-multisite-waas'),
__('Signups', 'wp-multisite-waas'),
];
$data = [];
$slug = 'signup_forms';
$headers = [
__('Checkout Form', 'wp-multisite-waas'),
__('Signups', 'wp-multisite-waas'),
];
foreach ($forms as $form) {
$line = [
esc_html($form->signup_form),
intval($form->count), // Ensure count is an integer and properly escaped
];
foreach ($forms as $form) {
$line = [
$form->signup_form,
$form->count,
];
$data[] = $line;
}
$data[] = $line;
} // end foreach;
$page->render_csv_button(
[
'headers' => $headers,
'data' => $data,
'slug' => $slug,
]
);
?>
$page->render_csv_button(
[
'headers' => $headers,
'data' => $data,
'slug' => $slug,
]
);
?>
</div>
</div>
</div>
@ -46,34 +44,34 @@ $page->render_csv_button(
<div class="wu-advanced-filters wu--mx-3 wu--mb-3 wu-mt-3">
<table class="wp-list-table widefat fixed striped wu-border-t-0 wu-border-l-0 wu-border-r-0">
<thead>
<tr>
<th><?php _e('Checkout Form', 'wp-multisite-waas'); ?></th>
<th class="wu-text-right"><?php _e('Signups', 'wp-multisite-waas'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($forms as $form) : ?>
<table class="wp-list-table widefat fixed striped wu-border-t-0 wu-border-l-0 wu-border-r-0">
<thead>
<tr>
<td>
<?php echo $form->signup_form; ?>
<?php if ('by-admin' === $form->signup_form) : ?>
<?php echo wu_tooltip(__('Customers created via the admin panel, by super admins.', 'wp-multisite-waas')); ?>
<?php endif; ?>
</td>
<td class="wu-text-right"><?php echo $form->count; ?></td>
<th><?php esc_html_e('Checkout Form', 'wp-multisite-waas'); ?></th>
<th class="wu-text-right"><?php esc_html_e('Signups', 'wp-multisite-waas'); ?></th>
</tr>
</thead>
<?php endforeach; ?>
<tbody>
</tbody>
<?php foreach ($forms as $form) : ?>
</table>
<tr>
<td>
<?php echo esc_html($form->signup_form); ?>
<?php if ('by-admin' === $form->signup_form) : ?>
<?php echo wp_kses_post(wu_tooltip(__('Customers created via the admin panel, by super admins.', 'wp-multisite-waas'))); ?>
<?php endif; ?>
</td>
<td class="wu-text-right"><?php echo intval($form->count); ?></td> <!-- Ensure count is an integer and properly escaped -->
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
@ -81,7 +79,7 @@ $page->render_csv_button(
<div class="wu-bg-gray-100 wu-p-4 wu-rounded wu-mt-6">
<?php _e('No data yet.', 'wp-multisite-waas'); ?>
<?php esc_html_e('No data yet.', 'wp-multisite-waas'); ?>
</div>

View File

@ -28,7 +28,7 @@ foreach ($sites as $site_visits) {
];
$data[] = $line;
} // end foreach;
}
$page->render_csv_button(
[
@ -52,8 +52,8 @@ $page->render_csv_button(
<thead>
<tr>
<th class="wu-w-8/12"><?php _e('Site', 'wp-multisite-waas'); ?></th>
<th class="wu-text-right"><?php _e('Visits', 'wp-multisite-waas'); ?></th>
<th class="wu-w-8/12"><?php esc_html_e('Site', 'wp-multisite-waas'); ?></th>
<th class="wu-text-right"><?php esc_html_e('Visits', 'wp-multisite-waas'); ?></th>
</tr>
</thead>
@ -64,22 +64,22 @@ $page->render_csv_button(
<tr>
<td class="wu-align-middle">
<span class="wu-uppercase wu-text-xs wu-text-gray-700 wu-font-bold">
<?php echo $site_visits->site->get_title(); ?>
<?php echo esc_html($site_visits->site->get_title()); ?>
</span>
<div class="sm:wu-flex">
<a title="<?php _e('Homepage', 'wp-multisite-waas'); ?>" href="<?php echo esc_attr(get_home_url($site_visits->site->get_id())); ?>" class="wu-no-underline wu-flex wu-items-center wu-text-xs wp-ui-text-highlight">
<a title="<?php esc_html_e('Homepage', 'wp-multisite-waas'); ?>" href="<?php echo esc_attr(get_home_url($site_visits->site->get_id())); ?>" class="wu-no-underline wu-flex wu-items-center wu-text-xs wp-ui-text-highlight">
<span class="dashicons-wu-link1 wu-align-middle wu-mr-1"></span>
<?php _e('Homepage', 'wp-multisite-waas'); ?>
<?php esc_html_e('Homepage', 'wp-multisite-waas'); ?>
</a>
<a title="<?php _e('Dashboard', 'wp-multisite-waas'); ?>" href="<?php echo esc_attr(get_admin_url($site_visits->site->get_id())); ?>" class="wu-no-underline wu-flex wu-items-center wu-text-xs wp-ui-text-highlight sm:wu-mt-0 sm:wu-ml-6">
<a title="<?php esc_html_e('Dashboard', 'wp-multisite-waas'); ?>" href="<?php echo esc_attr(get_admin_url($site_visits->site->get_id())); ?>" class="wu-no-underline wu-flex wu-items-center wu-text-xs wp-ui-text-highlight sm:wu-mt-0 sm:wu-ml-6">
<span class="dashicons-wu-browser wu-align-middle wu-mr-1"></span>
<?php _e('Dashboard', 'wp-multisite-waas'); ?>
<?php esc_html_e('Dashboard', 'wp-multisite-waas'); ?>
</a>
@ -102,7 +102,7 @@ $page->render_csv_button(
<div class="wu-bg-gray-100 wu-p-4 wu-rounded wu-mt-6">
<?php _e('No visits registered in this period.', 'wp-multisite-waas'); ?>
<?php esc_html_e('No visits registered in this period.', 'wp-multisite-waas'); ?>
</div>

View File

@ -11,7 +11,7 @@
<span class="wu-blinking-animation">
<?php _e('Loading...', 'wp-multisite-waas'); ?>
<?php esc_html_e('Loading...', 'wp-multisite-waas'); ?>
</span>

View File

@ -6,70 +6,42 @@
*/
?>
<div class="wu-styling">
<ul class="md:wu-flex wu-my-0 wu-mx-0">
<li class="wu-p-2 wu-w-full md:wu-w-full wu-relative">
<div>
<strong class="wu-text-gray-800 wu-text-2xl md:wu-text-xl">
<?php echo $new_accounts; ?>
</strong>
</div>
<div class="wu-text-sm wu-text-gray-600">
<span class="wu-block"><?php _e('New Memberships', 'wp-multisite-waas'); ?></span>
</div>
</li>
<li class="wu-p-2 wu-w-full md:wu-w-full wu-relative">
<div>
<strong class="wu-text-gray-800 wu-text-2xl md:wu-text-xl">
<?php echo esc_html($new_accounts); ?>
</strong>
</div>
<div class="wu-text-sm wu-text-gray-600">
<span class="wu-block"><?php esc_html_e('New Memberships', 'wp-multisite-waas'); ?></span>
</div>
</li>
</ul>
<div class="wu--mx-3 wu--mb-3 wu-mt-2">
<table class="wp-list-table widefat fixed striped wu-border-t-1 wu-border-l-0 wu-border-r-0">
<thead>
<tr>
<th><?php _e('Product Name', 'wp-multisite-waas'); ?></th>
<th class="wu-text-right"><?php _e('New Memberships', 'wp-multisite-waas'); ?></th>
</tr>
</thead>
<tbody>
<?php if ($products) : ?>
<?php foreach ($products as $product) : ?>
<table class="wp-list-table widefat fixed striped wu-border-t-1 wu-border-l-0 wu-border-r-0">
<thead>
<tr>
<td>
<?php echo $product->name; ?>
</td>
<td class="wu-text-right">
<?php echo $product->count; ?>
</td>
<th><?php esc_html_e('Product Name', 'wp-multisite-waas'); ?></th>
<th class="wu-text-right"><?php esc_html_e('New Memberships', 'wp-multisite-waas'); ?></th>
</tr>
<?php endforeach; ?>
<?php else : ?>
<tr>
<td colspan="2">
<?php _e('No Products found.', 'wp-multisite-waas'); ?>
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</thead>
<tbody>
<?php if ($products) : ?>
<?php foreach ($products as $product) : ?>
<tr>
<td><?php echo esc_html($product->name); ?></td>
<td class="wu-text-right"><?php echo esc_html($product->count); ?></td>
</tr>
<?php endforeach; ?>
<?php else : ?>
<tr>
<td colspan="2">
<?php esc_html_e('No Products found.', 'wp-multisite-waas'); ?>
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>

View File

@ -20,7 +20,7 @@
</div>
<div class="wu-text-md wu-text-gray-600">
<span class="wu-block"><?php _e('MRR', 'wp-multisite-waas'); ?></span>
<span class="wu-block"><?php esc_html_e('MRR', 'wp-multisite-waas'); ?></span>
</div>
</li>
@ -36,7 +36,7 @@
</div>
<div class="wu-text-md wu-text-gray-600">
<span class="wu-block"><?php _e('Gross Revenue', 'wp-multisite-waas'); ?></span>
<span class="wu-block"><?php esc_html_e('Gross Revenue', 'wp-multisite-waas'); ?></span>
</div>
</li>
@ -52,7 +52,7 @@
</div>
<div class="wu-text-md wu-text-gray-600">
<span class="wu-block"><?php _e('Refunded', 'wp-multisite-waas'); ?></span>
<span class="wu-block"><?php esc_html_e('Refunded', 'wp-multisite-waas'); ?></span>
</div>
</li>
@ -65,8 +65,8 @@
<thead>
<tr>
<th><?php _e('Product', 'wp-multisite-waas'); ?></th>
<th class="wu-text-right"><?php _e('Revenue', 'wp-multisite-waas'); ?></th>
<th><?php esc_html_e('Product', 'wp-multisite-waas'); ?></th>
<th class="wu-text-right"><?php esc_html_e('Revenue', 'wp-multisite-waas'); ?></th>
</tr>
</thead>
@ -91,7 +91,7 @@
<tr>
<td colspan="2">
<?php _e('No Products found.', 'wp-multisite-waas'); ?>
<?php esc_html_e('No Products found.', 'wp-multisite-waas'); ?>
</td>
</tr>

View File

@ -29,7 +29,7 @@
];
$data[] = $line;
} // end foreach;
}
$page->render_csv_button(
[
@ -45,10 +45,10 @@
<thead>
<tr>
<th><?php _e('Tax', 'wp-multisite-waas'); ?></th>
<th><?php _e('Rate', 'wp-multisite-waas'); ?></th>
<th><?php _e('Orders', 'wp-multisite-waas'); ?></th>
<th><?php _e('Tax Total', 'wp-multisite-waas'); ?></th>
<th><?php esc_html_e('Tax', 'wp-multisite-waas'); ?></th>
<th><?php esc_html_e('Rate', 'wp-multisite-waas'); ?></th>
<th><?php esc_html_e('Orders', 'wp-multisite-waas'); ?></th>
<th><?php esc_html_e('Tax Total', 'wp-multisite-waas'); ?></th>
</tr>
</thead>
@ -59,18 +59,10 @@
<?php foreach ($taxes_by_rate as $tax_line) : ?>
<tr>
<td>
<?php echo wu_get_isset($tax_line, 'title', 'No Name'); ?>
</td>
<td>
<?php echo $tax_line['tax_rate']; ?>%
</td>
<td>
<?php echo $tax_line['order_count']; ?>
</td>
<td>
<?php echo wu_format_currency($tax_line['tax_total']); ?>
</td>
<td><?php echo esc_html(wu_get_isset($tax_line, 'title', 'No Name')); ?></td>
<td><?php echo esc_html($tax_line['tax_rate']); ?>%</td>
<td><?php echo esc_html($tax_line['order_count']); ?></td>
<td><?php echo esc_html(wu_format_currency($tax_line['tax_total'])); ?></td>
</tr>
<?php endforeach; ?>
@ -79,7 +71,7 @@
<tr>
<td colspan="4">
<?php _e('No Taxes found.', 'wp-multisite-waas'); ?>
<?php esc_html_e('No Taxes found.', 'wp-multisite-waas'); ?>
</td>
</tr>

View File

@ -31,7 +31,7 @@
];
$data[] = $line;
} // end foreach;
}
$page->render_csv_button(
[
@ -47,11 +47,11 @@
<thead>
<tr>
<th class="wu-w-1/3"><?php _e('Day', 'wp-multisite-waas'); ?></th>
<th><?php _e('Orders', 'wp-multisite-waas'); ?></th>
<th><?php _e('Total Sales', 'wp-multisite-waas'); ?></th>
<th><?php _e('Tax Total', 'wp-multisite-waas'); ?></th>
<th><?php _e('Net Profit', 'wp-multisite-waas'); ?></th>
<th class="wu-w-1/3"><?php esc_html_e('Day', 'wp-multisite-waas'); ?></th>
<th><?php esc_html_e('Orders', 'wp-multisite-waas'); ?></th>
<th><?php esc_html_e('Total Sales', 'wp-multisite-waas'); ?></th>
<th><?php esc_html_e('Tax Total', 'wp-multisite-waas'); ?></th>
<th><?php esc_html_e('Net Profit', 'wp-multisite-waas'); ?></th>
</tr>
</thead>
@ -62,21 +62,11 @@
<?php foreach ($taxes_by_day as $day => $tax_line) : ?>
<tr>
<td>
<?php echo date_i18n(get_option('date_format'), strtotime($day)); ?>
</td>
<td>
<?php echo $tax_line['order_count']; ?>
</td>
<td>
<?php echo wu_format_currency($tax_line['total']); ?>
</td>
<td>
<?php echo wu_format_currency($tax_line['tax_total']); ?>
</td>
<td>
<?php echo wu_format_currency($tax_line['net_profit']); ?>
</td>
<td><?php echo esc_html(date_i18n(get_option('date_format'), strtotime($day))); ?></td>
<td><?php echo intval($tax_line['order_count']); ?></td>
<td><?php echo esc_html(wu_format_currency($tax_line['total'])); ?></td>
<td><?php echo esc_html(wu_format_currency($tax_line['tax_total'])); ?></td>
<td><?php echo esc_html(wu_format_currency($tax_line['net_profit'])); ?></td>
</tr>
<?php endforeach; ?>
@ -85,7 +75,7 @@
<tr>
<td colspan="4">
<?php _e('No Taxes found.', 'wp-multisite-waas'); ?>
<?php esc_html_e('No Taxes found.', 'wp-multisite-waas'); ?>
</td>
</tr>

View File

@ -11,7 +11,7 @@
<span class="wu-blinking-animation">
<?php _e('Loading...', 'wp-multisite-waas'); ?>
<?php esc_html_e('Loading...', 'wp-multisite-waas'); ?>
</span>

View File

@ -11,7 +11,7 @@
<span class="wu-blinking-animation">
<?php _e('Loading...', 'wp-multisite-waas'); ?>
<?php esc_html_e('Loading...', 'wp-multisite-waas'); ?>
</span>