Skip to content

Commit fdaba03

Browse files
release: fixes
- Fixed issue with SVG menu icons rendering too small - Fixed issue with vertical alignment not working on frontend
2 parents 7e618a8 + b98e885 commit fdaba03

4 files changed

Lines changed: 251 additions & 24 deletions

File tree

.github/workflows/plugin-check.yml

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
name: WordPress Plugin Check
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
plugin-check:
13+
name: WordPress.org Guidelines Check
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Install Composer dependencies
19+
run: composer install --no-dev --optimize-autoloader
20+
21+
- uses: wordpress/plugin-check-action@v1
22+
id: plugin-check
23+
with:
24+
categories: plugin_repo,security,performance,general
25+
exclude-directories: |
26+
tests
27+
bin
28+
.github
29+
ignore-codes: |
30+
WordPress.WP.I18n.TextDomainMismatch
31+
textdomain_mismatch
32+
hidden_files
33+
WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
34+
WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound
35+
WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
36+
WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
37+
WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound
38+
WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
39+
WordPress.WP.EnqueuedResourceParameters.MissingVersion
40+
include-experimental: true
41+
repo-token: ''
42+
43+
- name: Plugin Check Summary
44+
if: always()
45+
env:
46+
RESULTS_FILE: ${{ runner.temp }}/plugin-check-results.txt
47+
run: |
48+
echo "## WordPress Plugin Check Results" >> $GITHUB_STEP_SUMMARY
49+
echo "" >> $GITHUB_STEP_SUMMARY
50+
51+
if [ ! -s "$RESULTS_FILE" ]; then
52+
echo "No results file found or file is empty." >> $GITHUB_STEP_SUMMARY
53+
echo "Check the action logs for details." >> $GITHUB_STEP_SUMMARY
54+
exit 0
55+
fi
56+
57+
PARSED=$(RESULTS_FILE="$RESULTS_FILE" python3 << 'PYEOF'
58+
import json, os, re
59+
60+
results_path = os.environ["RESULTS_FILE"]
61+
62+
high_risk_codes = [
63+
"plugin_updater", "code_obfuscation", "no_unfiltered_uploads",
64+
"trademarked_term", "trademarks"
65+
]
66+
high_risk_messages = [
67+
r"Plugin Updater detected", r"Missing.*License.*Plugin Header",
68+
r"restricted term", r"Unescaped parameter.*\$wpdb",
69+
r"Use placeholders and.*\$wpdb->prepare"
70+
]
71+
medium_risk_codes = [
72+
"missing_direct_file_access_protection", "trunk_stable_tag",
73+
"mismatched_plugin_name", "application_detected"
74+
]
75+
medium_risk_messages = [
76+
r"Missing.*\$domain.*parameter", r"has been deprecated",
77+
r"wp_get_sites", r"cURL functions is highly discouraged"
78+
]
79+
80+
high, medium, other = [], [], []
81+
82+
try:
83+
with open(results_path, "r") as f:
84+
content = f.read().strip()
85+
86+
all_issues = []
87+
try:
88+
data = json.loads(content)
89+
if isinstance(data, list):
90+
all_issues = data
91+
elif isinstance(data, dict):
92+
for fp, issues in data.items():
93+
if isinstance(issues, list):
94+
for issue in issues:
95+
issue['_file'] = fp
96+
all_issues.append(issue)
97+
except json.JSONDecodeError:
98+
for line in content.split('\n'):
99+
line = line.strip()
100+
if not line:
101+
continue
102+
try:
103+
parsed = json.loads(line)
104+
if isinstance(parsed, list):
105+
all_issues.extend(parsed)
106+
elif isinstance(parsed, dict):
107+
all_issues.append(parsed)
108+
except json.JSONDecodeError:
109+
continue
110+
111+
for issue in all_issues:
112+
code = issue.get('code', '')
113+
msg = issue.get('message', '')
114+
itype = issue.get('type', 'ERROR')
115+
line_num = issue.get('line', 0)
116+
file_path = issue.get('_file', '')
117+
118+
prefix = "❌" if itype == "ERROR" else "⚠️"
119+
location = ""
120+
if file_path:
121+
location = f" ({file_path}"
122+
if line_num and line_num > 0:
123+
location += f", line {line_num}"
124+
location += ")"
125+
elif line_num and line_num > 0:
126+
location = f" (line {line_num})"
127+
128+
readable = f"{prefix} {msg}{location}"
129+
130+
is_high = code in high_risk_codes
131+
if not is_high:
132+
for p in high_risk_messages:
133+
if re.search(p, msg, re.IGNORECASE):
134+
is_high = True
135+
break
136+
137+
is_medium = code in medium_risk_codes
138+
if not is_medium and not is_high:
139+
for p in medium_risk_messages:
140+
if re.search(p, msg, re.IGNORECASE):
141+
is_medium = True
142+
break
143+
144+
if is_high:
145+
high.append(readable)
146+
elif is_medium:
147+
medium.append(readable)
148+
else:
149+
other.append(readable)
150+
151+
def dedup(lst):
152+
seen = set()
153+
result = []
154+
for item in lst:
155+
if item not in seen:
156+
seen.add(item)
157+
result.append(item)
158+
return result
159+
160+
high, medium, other = dedup(high), dedup(medium), dedup(other)
161+
162+
print("---HIGH---")
163+
for i in high: print(i)
164+
print("---MEDIUM---")
165+
for i in medium: print(i)
166+
print("---OTHER---")
167+
for i in other: print(i)
168+
print("---COUNTS---")
169+
print(f"{len(high)}|{len(medium)}|{len(other)}")
170+
171+
except Exception as e:
172+
print(f"Parse error: {e}", file=__import__('sys').stderr)
173+
print("---HIGH---\n---MEDIUM---\n---OTHER---\n---COUNTS---\n0|0|0")
174+
PYEOF
175+
)
176+
177+
HIGH_SECTION=$(echo "$PARSED" | sed -n '/^---HIGH---$/,/^---MEDIUM---$/p' | sed '1d;$d')
178+
MEDIUM_SECTION=$(echo "$PARSED" | sed -n '/^---MEDIUM---$/,/^---OTHER---$/p' | sed '1d;$d')
179+
OTHER_SECTION=$(echo "$PARSED" | sed -n '/^---OTHER---$/,/^---COUNTS---$/p' | sed '1d;$d')
180+
COUNTS=$(echo "$PARSED" | tail -1)
181+
OTHER_COUNT=$(echo "$COUNTS" | cut -d'|' -f3)
182+
183+
echo "### 🚨 HIGH RISK — Can cause plugin closure or suspension" >> $GITHUB_STEP_SUMMARY
184+
echo "" >> $GITHUB_STEP_SUMMARY
185+
if [ -n "$HIGH_SECTION" ]; then
186+
echo "$HIGH_SECTION" >> $GITHUB_STEP_SUMMARY
187+
else
188+
echo "✅ No high-risk issues found." >> $GITHUB_STEP_SUMMARY
189+
fi
190+
echo "" >> $GITHUB_STEP_SUMMARY
191+
192+
echo "### ⚠️ MEDIUM RISK — Commonly flagged in wordpress.org reviews" >> $GITHUB_STEP_SUMMARY
193+
echo "" >> $GITHUB_STEP_SUMMARY
194+
if [ -n "$MEDIUM_SECTION" ]; then
195+
echo "$MEDIUM_SECTION" >> $GITHUB_STEP_SUMMARY
196+
else
197+
echo "✅ No medium-risk issues found." >> $GITHUB_STEP_SUMMARY
198+
fi
199+
echo "" >> $GITHUB_STEP_SUMMARY
200+
201+
echo "<details>" >> $GITHUB_STEP_SUMMARY
202+
echo "<summary>📋 Other issues ($OTHER_COUNT) — click to expand</summary>" >> $GITHUB_STEP_SUMMARY
203+
echo "" >> $GITHUB_STEP_SUMMARY
204+
if [ -n "$OTHER_SECTION" ]; then
205+
echo "$OTHER_SECTION" >> $GITHUB_STEP_SUMMARY
206+
else
207+
echo "No other issues." >> $GITHUB_STEP_SUMMARY
208+
fi
209+
echo "" >> $GITHUB_STEP_SUMMARY
210+
echo "</details>" >> $GITHUB_STEP_SUMMARY

includes/front.php

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ final class Menu_Icons_Front_End {
5151
*/
5252
protected static $hidden_label_class = 'visuallyhidden';
5353

54+
/**
55+
* Align-self map for vertical-align values.
56+
*
57+
* @access private
58+
* @var array
59+
*/
60+
private static $align_self_map = array(
61+
'top' => 'flex-start',
62+
'middle' => 'center',
63+
'bottom' => 'flex-end',
64+
'baseline' => 'baseline',
65+
);
66+
5467

5568
/**
5669
* Add hooks for front-end functionalities
@@ -339,6 +352,18 @@ public static function get_icon_style( $meta, $keys, $as_attribute = true ) {
339352

340353
$rule = self::$default_style[ $key ];
341354

355+
// Special handling for vertical-align because it affects the layout of flex containers.
356+
if ( 'vertical_align' === $key ) {
357+
if ( ! isset( $meta[ $key ] ) || $meta[ $key ] === $rule['value'] ) {
358+
continue;
359+
}
360+
361+
$stored = $meta[ $key ];
362+
$style_a[ $rule['property'] ] = $stored;
363+
$style_a['align-self'] = isset( self::$align_self_map[ $stored ] ) ? self::$align_self_map[ $stored ] : 'center';
364+
continue;
365+
}
366+
342367
if ( ! isset( $meta[ $key ] ) || $meta[ $key ] === $rule['value'] ) {
343368
continue;
344369
}
@@ -355,13 +380,13 @@ public static function get_icon_style( $meta, $keys, $as_attribute = true ) {
355380
return $style_s;
356381
}
357382

358-
foreach ( $style_a as $key => $value ) {
359-
$style_s .= "{$key}:{$value};";
383+
foreach ( $style_a as $prop => $value ) {
384+
$style_s .= "{$prop}:{$value};";
360385
}
361386

362387
$style_s = esc_attr( $style_s );
363388

364-
if ( $as_attribute ) {
389+
if ( $as_attribute ) {
365390
$style_s = sprintf( ' style="%s"', $style_s );
366391
}
367392

@@ -483,10 +508,10 @@ public static function get_svg_icon( $meta ) {
483508
}
484509
}
485510
if ( ! empty( $width ) ) {
486-
$width = sprintf( ' width="%d"', $width );
511+
$width = sprintf( ' width="%d"', esc_attr( $width ) );
487512
}
488513
if ( ! empty( $height ) ) {
489-
$height = sprintf( ' height="%d"', $height );
514+
$height = sprintf( ' height="%d"', esc_attr( $height ) );
490515
}
491516
$image_alt = get_post_meta( $meta['icon'], '_wp_attachment_image_alt', true );
492517
$image_alt = $image_alt ? wp_strip_all_tags( $image_alt ) : '';
@@ -495,9 +520,9 @@ public static function get_svg_icon( $meta ) {
495520
esc_url( wp_get_attachment_url( $meta['icon'] ) ),
496521
esc_attr( $classes ),
497522
esc_attr( $image_alt ),
498-
esc_attr( $width ),
499-
esc_attr( $height ),
500-
esc_attr( $style )
523+
$width,
524+
$height,
525+
$style
501526
);
502527
}
503528

includes/meta.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ public static function get( $id, $defaults = array() ) {
103103
$value['position'] = $defaults['position'];
104104
}
105105

106+
// Backward-compatibility: values removed in favour of align-self support.
107+
$supported_vertical_align = array( 'top', 'middle', 'bottom', 'baseline' );
108+
if ( isset( $value['vertical_align'] ) &&
109+
! in_array( $value['vertical_align'], $supported_vertical_align, true )
110+
) {
111+
$value['vertical_align'] = 'middle';
112+
}
113+
106114
if ( isset( $value['size'] ) && ! isset( $value['font_size'] ) ) {
107115
$value['font_size'] = $value['size'];
108116
unset( $value['size'] );

includes/settings.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -535,18 +535,10 @@ public static function get_settings_fields( array $values = array() ) {
535535
'label' => __( 'Vertical Align', 'menu-icons' ),
536536
'default' => 'middle',
537537
'choices' => array(
538-
array(
539-
'value' => 'super',
540-
'label' => __( 'Super', 'menu-icons' ),
541-
),
542538
array(
543539
'value' => 'top',
544540
'label' => __( 'Top', 'menu-icons' ),
545541
),
546-
array(
547-
'value' => 'text-top',
548-
'label' => __( 'Text Top', 'menu-icons' ),
549-
),
550542
array(
551543
'value' => 'middle',
552544
'label' => __( 'Middle', 'menu-icons' ),
@@ -555,18 +547,10 @@ public static function get_settings_fields( array $values = array() ) {
555547
'value' => 'baseline',
556548
'label' => __( 'Baseline', 'menu-icons' ),
557549
),
558-
array(
559-
'value' => 'text-bottom',
560-
'label' => __( 'Text Bottom', 'menu-icons' ),
561-
),
562550
array(
563551
'value' => 'bottom',
564552
'label' => __( 'Bottom', 'menu-icons' ),
565553
),
566-
array(
567-
'value' => 'sub',
568-
'label' => __( 'Sub', 'menu-icons' ),
569-
),
570554
),
571555
),
572556
'font_size' => array(

0 commit comments

Comments
 (0)