Skip to content

Commit 3e1b0e8

Browse files
authored
code changes for wp.org review (#183)
* Use enqueue style for invoice preview * Fix replacing active button for themes that are not allowed on current plan * Use proper inline styles * Cleanup unused legacy code * more better processing of post * Add more comments related to nonce * ignore more dirs * only support WP 6.2 * more comments * add missing text domain * remove tranlation files for review on wp.org * Move invoice css to external sheet * add ABSPATH checks * use inline styles instead of inline stylesheets * Update Readme with more third party information * remove unused support widget * Avoid ignoring the escape errors * Escape more things * Add more used attributes to allowed html * avoid warnings with null strings
1 parent cb5832b commit 3e1b0e8

171 files changed

Lines changed: 1107 additions & 138945 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

assets/css/invoice.css

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
.invoice-box {
2+
width: 100%;
3+
margin: auto;
4+
font-size: 16px;
5+
line-height: 24px;
6+
color: #555;
7+
}
8+
9+
.invoice-box table {
10+
width: 100%;
11+
line-height: inherit;
12+
text-align: left;
13+
}
14+
15+
.invoice-box table td {
16+
padding: 5px;
17+
vertical-align: top;
18+
}
19+
20+
.invoice-box table tr td:nth-child(2) {
21+
text-align: right;
22+
}
23+
24+
.invoice-box table tr.top table td {
25+
padding-bottom: 20px;
26+
}
27+
28+
.invoice-box table tr.top table td.title {
29+
font-size: 45px;
30+
line-height: 45px;
31+
color: #333;
32+
}
33+
34+
.invoice-box table tr.information table td {
35+
padding-bottom: 40px;
36+
}
37+
38+
.invoice-box table tr.heading td {
39+
background: #eee;
40+
border-bottom: 1px solid #ddd;
41+
font-weight: 500;
42+
}
43+
44+
.invoice-box table {
45+
border-collapse: 1px;
46+
}
47+
48+
.invoice-box table tr.heading th {
49+
border-left: 1px solid #ddd;
50+
border-right: 1px solid #ddd;
51+
}
52+
53+
.invoice-box table tr.item td {
54+
vertical-align: middle;
55+
}
56+
57+
.invoice-box table tr.heading th {
58+
background: #eee;
59+
border-top: 1px solid #ddd;
60+
border-bottom: 1px solid #ddd;
61+
padding: 10px;
62+
text-align: right;
63+
font-weight: bold;
64+
text-transform: uppercase;
65+
font-size: 80%;
66+
}
67+
68+
.invoice-box table tr.details td {
69+
padding: 10px;
70+
}
71+
72+
.invoice-box table tr.item td{
73+
border-bottom: 1px solid #eee;
74+
padding: 10px;
75+
}
76+
77+
.invoice-box table tr.item.last td {
78+
border-bottom: none;
79+
}
80+
81+
.invoice-box table tr.total td {
82+
border-top: 2px solid #eee;
83+
font-weight: bold;
84+
padding-bottom: 60px;
85+
padding-top: 10px;
86+
text-align: right;
87+
}
88+
89+
@media only screen and (max-width: 600px) {
90+
.invoice-box table tr.top table td {
91+
width: 100%;
92+
display: block;
93+
text-align: center;
94+
}
95+
96+
.invoice-box table tr.information table td {
97+
width: 100%;
98+
display: block;
99+
text-align: center;
100+
}
101+
}
102+
103+
/** RTL **/
104+
.rtl {
105+
direction: rtl;
106+
107+
}
108+
109+
.rtl table {
110+
text-align: right;
111+
}
112+
113+
.rtl table tr td:nth-child(2) {
114+
text-align: left;
115+
}

assets/css/invoice.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/support.js

Lines changed: 0 additions & 71 deletions
This file was deleted.

assets/js/support.min.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@
134134
"vendor/delight-im/cookie/.travis-ci-apache",
135135
"vendor/doctrine",
136136
".distignore",
137-
"encrypt-sectrets.php"
137+
"encrypt-sectrets.php",
138+
"scripts",
139+
"mu-plugins"
138140
]
139141
},
140142
"extra": {

inc/admin-pages/class-broadcast-edit-admin-page.php

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -205,17 +205,6 @@ public function output_default_widget_customer_targets(): void {
205205

206206
$customer_link = wu_network_admin_url('wp-ultimo-edit-customer', $url_atts);
207207

208-
$avatar = get_avatar(
209-
$customer->get_user_id(),
210-
32,
211-
'identicon',
212-
'',
213-
[
214-
'force_display' => true,
215-
'class' => 'wu-rounded-full wu-border-solid wu-border-1 wu-border-white hover:wu-border-gray-400',
216-
]
217-
);
218-
219208
$display_name = $customer->get_display_name();
220209

221210
$id = $customer->get_id();
@@ -232,7 +221,16 @@ public function output_default_widget_customer_targets(): void {
232221
</a>',
233222
esc_attr($customer_link),
234223
esc_html($display_name),
235-
$avatar, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
224+
get_avatar(
225+
$customer->get_user_id(),
226+
32,
227+
'identicon',
228+
'',
229+
[
230+
'force_display' => true,
231+
'class' => 'wu-rounded-full wu-border-solid wu-border-1 wu-border-white hover:wu-border-gray-400',
232+
]
233+
),
236234
esc_html($id),
237235
esc_html($email)
238236
);
@@ -245,16 +243,6 @@ public function output_default_widget_customer_targets(): void {
245243

246244
$email = $customer->get_email_address();
247245

248-
$avatar = get_avatar(
249-
$email,
250-
32,
251-
'identicon',
252-
'',
253-
[
254-
'class' => 'wu-rounded-full wu-border-solid wu-border-1 wu-border-white hover:wu-border-gray-400',
255-
]
256-
);
257-
258246
$url_atts = [
259247
'id' => $customer->get_id(),
260248
];
@@ -265,7 +253,15 @@ public function output_default_widget_customer_targets(): void {
265253
"<div class='wu-flex wu--mr-4'><a role='tooltip' aria-label='%s' href='%s'>%s</a></div>",
266254
esc_attr($tooltip_name),
267255
esc_attr($customer_link),
268-
$avatar // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
256+
get_avatar(
257+
$email,
258+
32,
259+
'identicon',
260+
'',
261+
[
262+
'class' => 'wu-rounded-full wu-border-solid wu-border-1 wu-border-white hover:wu-border-gray-400',
263+
]
264+
)
269265
);
270266
}
271267

@@ -459,6 +455,7 @@ public function query_filter($args) {
459455
*/
460456
public function get_object() {
461457

458+
// Data is only being fetch, nothing is being modified, no need for nonce check.
462459
if (isset($_GET['id'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
463460
$query = new \WP_Ultimo\Database\Broadcasts\Broadcast_Query();
464461

inc/admin-pages/class-checkout-form-edit-admin-page.php

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function init(): void {
9191

9292
parent::init();
9393

94-
add_action('init', [$this, 'generate_checkout_form_preview'], 9);
94+
$this->generate_checkout_form_preview();
9595

9696
add_action('wp_ajax_wu_save_editor_session', [$this, 'save_editor_session']);
9797

@@ -171,8 +171,6 @@ public function content_checkout_form_by_settings(): void {
171171
return;
172172
}
173173

174-
$content = '';
175-
176174
$key = wp_get_session_token();
177175

178176
$session = \WP_Session_Tokens::get_instance(get_current_user_id());
@@ -193,12 +191,20 @@ public function content_checkout_form_by_settings(): void {
193191
$current_user = wp_set_current_user(0);
194192
}
195193

194+
wp_enqueue_scripts();
195+
196+
wp_print_head_scripts();
197+
198+
printf('<body %s>', 'class="' . esc_attr(implode(' ', get_body_class('wu-styling'))) . '"');
199+
200+
echo '<div class="wu-p-6">';
201+
196202
$count = count($settings);
197203

198204
foreach ($settings as $index => $step) {
199205
$final_fields = wu_create_checkout_fields($step['fields']);
200206

201-
$content .= wu_get_template_contents(
207+
wu_get_template(
202208
'checkout/form',
203209
[
204210
'step' => $step,
@@ -212,20 +218,10 @@ public function content_checkout_form_by_settings(): void {
212218
);
213219

214220
if ($index < $count - 1) {
215-
$content .= sprintf('<hr class="sm:wu-bg-transparent wu-hr-text wu-font-semibold wu-my-4 wu-mt-6 wu-text-gray-600 wu-text-sm" data-content="%s">', esc_attr__('Step Separator', 'multisite-ultimate'));
221+
printf('<hr class="sm:wu-bg-transparent wu-hr-text wu-font-semibold wu-my-4 wu-mt-6 wu-text-gray-600 wu-text-sm" data-content="%s">', esc_attr__('Step Separator', 'multisite-ultimate'));
216222
}
217223
}
218224

219-
wp_enqueue_scripts();
220-
221-
wp_print_head_scripts();
222-
223-
printf('<body %s>', 'class="' . esc_attr(implode(' ', get_body_class('wu-styling'))) . '"');
224-
225-
echo '<div class="wu-p-6">';
226-
227-
echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
228-
229225
wp_print_footer_scripts();
230226

231227
echo '</div></body>';

inc/admin-pages/class-customer-edit-admin-page.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -997,9 +997,9 @@ public function render_country() {
997997

998998
if ($country_code) {
999999
$html = sprintf(
1000-
'<span>%s</span><span class="wu-flag-icon wu-w-5 wu-ml-1" %s>%s</span>',
1000+
'<span>%s</span><span class="wu-flag-icon wu-w-5 wu-ml-1" role="tooltip" aria-label="%s">%s</span>',
10011001
$country_name,
1002-
wu_tooltip_text($country_name),
1002+
esc_attr($country_name),
10031003
wu_get_flag_emoji((string) $country_code)
10041004
);
10051005
} else {

inc/admin-pages/class-dashboard-admin-page.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -608,20 +608,16 @@ public function render_csv_button($args): void {
608608

609609
$data_strings = wp_json_encode($args['data']);
610610

611-
$html = '<div class="wu-bg-gray-100 wu-p-2 wu-text-right wu-border-0 wu-border-b wu-border-solid wu-border-gray-400">
611+
printf(
612+
'<div class="wu-bg-gray-100 wu-p-2 wu-text-right wu-border-0 wu-border-b wu-border-solid wu-border-gray-400">
612613
<a href="#" attr-slug-csv="%2$s" class="wu-export-button wu-no-underline wu-text-gray-800 wu-text-xs">
613614
<span class="dashicons-wu-download wu-mr-1"></span> %1$s
614615
</a>
615616
<input type="hidden" id="csv_headers_%2$s" value="%3$s" />
616617
<input type="hidden" id="csv_data_%2$s" value="%4$s" />
617618
<input type="hidden" id="csv_action_%2$s" value="%5$s" />
618-
</div>';
619-
620-
$html = apply_filters('wu_export_html_render', $html, $html);
621-
622-
printf(
623-
$html, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
624-
apply_filters('wu_export_data_table_label', esc_html__('CSV', 'multisite-ultimate')), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
619+
</div>',
620+
esc_html__('CSV', 'multisite-ultimate'),
625621
esc_attr($slug),
626622
esc_attr($header_strings),
627623
esc_attr($data_strings),

inc/admin-pages/class-edit-admin-page.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,8 @@ protected function add_list_table_widget($id, $atts = []) {
401401
$atts,
402402
[
403403
'widget_id' => $id,
404-
'before' => '',
405-
'after' => '',
404+
'before' => fn() => null,
405+
'after' => fn() => null,
406406
'title' => __('List Table', 'multisite-ultimate'),
407407
'position' => 'advanced',
408408
'screen' => get_current_screen(),

0 commit comments

Comments
 (0)