Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
210 changes: 210 additions & 0 deletions .github/workflows/plugin-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
name: WordPress Plugin Check

on:
pull_request:
types: [opened, synchronize, reopened]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
plugin-check:
name: WordPress.org Guidelines Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Composer dependencies
run: composer install --no-dev --optimize-autoloader

- uses: wordpress/plugin-check-action@v1
id: plugin-check
with:
categories: plugin_repo,security,performance,general
exclude-directories: |
tests
bin
.github
ignore-codes: |
WordPress.WP.I18n.TextDomainMismatch
textdomain_mismatch
hidden_files
WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound
WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound
WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
WordPress.WP.EnqueuedResourceParameters.MissingVersion
include-experimental: true
repo-token: ''

- name: Plugin Check Summary
if: always()
env:
RESULTS_FILE: ${{ runner.temp }}/plugin-check-results.txt
run: |
echo "## WordPress Plugin Check Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY

if [ ! -s "$RESULTS_FILE" ]; then
echo "No results file found or file is empty." >> $GITHUB_STEP_SUMMARY
echo "Check the action logs for details." >> $GITHUB_STEP_SUMMARY
exit 0
fi

PARSED=$(RESULTS_FILE="$RESULTS_FILE" python3 << 'PYEOF'
import json, os, re

results_path = os.environ["RESULTS_FILE"]

high_risk_codes = [
"plugin_updater", "code_obfuscation", "no_unfiltered_uploads",
"trademarked_term", "trademarks"
]
high_risk_messages = [
r"Plugin Updater detected", r"Missing.*License.*Plugin Header",
r"restricted term", r"Unescaped parameter.*\$wpdb",
r"Use placeholders and.*\$wpdb->prepare"
]
medium_risk_codes = [
"missing_direct_file_access_protection", "trunk_stable_tag",
"mismatched_plugin_name", "application_detected"
]
medium_risk_messages = [
r"Missing.*\$domain.*parameter", r"has been deprecated",
r"wp_get_sites", r"cURL functions is highly discouraged"
]

high, medium, other = [], [], []

try:
with open(results_path, "r") as f:
content = f.read().strip()

all_issues = []
try:
data = json.loads(content)
if isinstance(data, list):
all_issues = data
elif isinstance(data, dict):
for fp, issues in data.items():
if isinstance(issues, list):
for issue in issues:
issue['_file'] = fp
all_issues.append(issue)
except json.JSONDecodeError:
for line in content.split('\n'):
line = line.strip()
if not line:
continue
try:
parsed = json.loads(line)
if isinstance(parsed, list):
all_issues.extend(parsed)
elif isinstance(parsed, dict):
all_issues.append(parsed)
except json.JSONDecodeError:
continue

for issue in all_issues:
code = issue.get('code', '')
msg = issue.get('message', '')
itype = issue.get('type', 'ERROR')
line_num = issue.get('line', 0)
file_path = issue.get('_file', '')

prefix = "❌" if itype == "ERROR" else "⚠️"
location = ""
if file_path:
location = f" ({file_path}"
if line_num and line_num > 0:
location += f", line {line_num}"
location += ")"
elif line_num and line_num > 0:
location = f" (line {line_num})"

readable = f"{prefix} {msg}{location}"

is_high = code in high_risk_codes
if not is_high:
for p in high_risk_messages:
if re.search(p, msg, re.IGNORECASE):
is_high = True
break

is_medium = code in medium_risk_codes
if not is_medium and not is_high:
for p in medium_risk_messages:
if re.search(p, msg, re.IGNORECASE):
is_medium = True
break

if is_high:
high.append(readable)
elif is_medium:
medium.append(readable)
else:
other.append(readable)

def dedup(lst):
seen = set()
result = []
for item in lst:
if item not in seen:
seen.add(item)
result.append(item)
return result

high, medium, other = dedup(high), dedup(medium), dedup(other)

print("---HIGH---")
for i in high: print(i)
print("---MEDIUM---")
for i in medium: print(i)
print("---OTHER---")
for i in other: print(i)
print("---COUNTS---")
print(f"{len(high)}|{len(medium)}|{len(other)}")

except Exception as e:
print(f"Parse error: {e}", file=__import__('sys').stderr)
print("---HIGH---\n---MEDIUM---\n---OTHER---\n---COUNTS---\n0|0|0")
PYEOF
)

HIGH_SECTION=$(echo "$PARSED" | sed -n '/^---HIGH---$/,/^---MEDIUM---$/p' | sed '1d;$d')
MEDIUM_SECTION=$(echo "$PARSED" | sed -n '/^---MEDIUM---$/,/^---OTHER---$/p' | sed '1d;$d')
OTHER_SECTION=$(echo "$PARSED" | sed -n '/^---OTHER---$/,/^---COUNTS---$/p' | sed '1d;$d')
COUNTS=$(echo "$PARSED" | tail -1)
OTHER_COUNT=$(echo "$COUNTS" | cut -d'|' -f3)

echo "### 🚨 HIGH RISK — Can cause plugin closure or suspension" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ -n "$HIGH_SECTION" ]; then
echo "$HIGH_SECTION" >> $GITHUB_STEP_SUMMARY
else
echo "✅ No high-risk issues found." >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY

echo "### ⚠️ MEDIUM RISK — Commonly flagged in wordpress.org reviews" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ -n "$MEDIUM_SECTION" ]; then
echo "$MEDIUM_SECTION" >> $GITHUB_STEP_SUMMARY
else
echo "✅ No medium-risk issues found." >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY

echo "<details>" >> $GITHUB_STEP_SUMMARY
echo "<summary>📋 Other issues ($OTHER_COUNT) — click to expand</summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ -n "$OTHER_SECTION" ]; then
echo "$OTHER_SECTION" >> $GITHUB_STEP_SUMMARY
else
echo "No other issues." >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "</details>" >> $GITHUB_STEP_SUMMARY
16 changes: 8 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 33 additions & 8 deletions includes/front.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ final class Menu_Icons_Front_End {
*/
protected static $hidden_label_class = 'visuallyhidden';

/**
* Align-self map for vertical-align values.
*
* @access private
* @var array
*/
private static $align_self_map = array(
'top' => 'flex-start',
'middle' => 'center',
'bottom' => 'flex-end',
'baseline' => 'baseline',
);


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

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

// Special handling for vertical-align because it affects the layout of flex containers.
if ( 'vertical_align' === $key ) {
if ( ! isset( $meta[ $key ] ) || $meta[ $key ] === $rule['value'] ) {
continue;
}

$stored = $meta[ $key ];
$style_a[ $rule['property'] ] = $stored;
$style_a['align-self'] = isset( self::$align_self_map[ $stored ] ) ? self::$align_self_map[ $stored ] : 'center';
continue;
}

if ( ! isset( $meta[ $key ] ) || $meta[ $key ] === $rule['value'] ) {
continue;
}
Expand All @@ -355,13 +380,13 @@ public static function get_icon_style( $meta, $keys, $as_attribute = true ) {
return $style_s;
}

foreach ( $style_a as $key => $value ) {
$style_s .= "{$key}:{$value};";
foreach ( $style_a as $prop => $value ) {
$style_s .= "{$prop}:{$value};";
}

$style_s = esc_attr( $style_s );

if ( $as_attribute ) {
if ( $as_attribute ) {
$style_s = sprintf( ' style="%s"', $style_s );
}

Expand Down Expand Up @@ -483,10 +508,10 @@ public static function get_svg_icon( $meta ) {
}
}
if ( ! empty( $width ) ) {
$width = sprintf( ' width="%d"', $width );
$width = sprintf( ' width="%d"', esc_attr( $width ) );
}
if ( ! empty( $height ) ) {
$height = sprintf( ' height="%d"', $height );
$height = sprintf( ' height="%d"', esc_attr( $height ) );
}
$image_alt = get_post_meta( $meta['icon'], '_wp_attachment_image_alt', true );
$image_alt = $image_alt ? wp_strip_all_tags( $image_alt ) : '';
Expand All @@ -495,9 +520,9 @@ public static function get_svg_icon( $meta ) {
esc_url( wp_get_attachment_url( $meta['icon'] ) ),
esc_attr( $classes ),
esc_attr( $image_alt ),
esc_attr( $width ),
esc_attr( $height ),
esc_attr( $style )
$width,
$height,
$style
);
}

Expand Down
8 changes: 8 additions & 0 deletions includes/meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ public static function get( $id, $defaults = array() ) {
$value['position'] = $defaults['position'];
}

// Backward-compatibility: values removed in favour of align-self support.
$supported_vertical_align = array( 'top', 'middle', 'bottom', 'baseline' );
if ( isset( $value['vertical_align'] ) &&
! in_array( $value['vertical_align'], $supported_vertical_align, true )
) {
$value['vertical_align'] = 'middle';
}

if ( isset( $value['size'] ) && ! isset( $value['font_size'] ) ) {
$value['font_size'] = $value['size'];
unset( $value['size'] );
Expand Down
16 changes: 0 additions & 16 deletions includes/settings.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php

/**
Expand Down Expand Up @@ -157,8 +157,8 @@
return $nav_menu_selected_id;
}

if ( is_admin() && isset( $_REQUEST['menu'] ) ) {

Check warning on line 160 in includes/settings.php

View workflow job for this annotation

GitHub Actions / WordPress.org Guidelines Check

WordPress.Security.NonceVerification.Recommended

Processing form data without nonce verification.
$menu_id = absint( $_REQUEST['menu'] );

Check warning on line 161 in includes/settings.php

View workflow job for this annotation

GitHub Actions / WordPress.org Guidelines Check

WordPress.Security.NonceVerification.Recommended

Processing form data without nonce verification.
} else {
$menu_id = absint( get_user_option( 'nav_menu_recently_edited' ) );
}
Expand Down Expand Up @@ -234,11 +234,11 @@
if ( ! empty( $_POST['menu-icons']['settings'] ) ) {
check_admin_referer( self::UPDATE_KEY, self::UPDATE_KEY );

$redirect_url = self::_update_settings( $_POST['menu-icons']['settings'] ); // Input var okay.

Check warning on line 237 in includes/settings.php

View workflow job for this annotation

GitHub Actions / WordPress.org Guidelines Check

WordPress.Security.ValidatedSanitizedInput.InputNotSanitized

Detected usage of a non-sanitized input variable: $_POST['menu-icons']['settings']

Check warning on line 237 in includes/settings.php

View workflow job for this annotation

GitHub Actions / WordPress.org Guidelines Check

WordPress.Security.ValidatedSanitizedInput.MissingUnslash

$_POST['menu-icons']['settings'] not unslashed before sanitization. Use wp_unslash() or similar
wp_redirect( $redirect_url );

Check warning on line 238 in includes/settings.php

View workflow job for this annotation

GitHub Actions / WordPress.org Guidelines Check

WordPress.Security.SafeRedirect.wp_redirect_wp_redirect

wp_redirect() found. Using wp_safe_redirect(), along with the "allowed_redirect_hosts" filter if needed, can help avoid any chances of malicious redirects within code. It is also important to remember to call exit() after a redirect so that no other unwanted code is executed.
} elseif ( ! empty( $_REQUEST[ self::RESET_KEY ] ) ) {
check_admin_referer( self::RESET_KEY, self::RESET_KEY );
wp_redirect( self::_reset_settings() );

Check warning on line 241 in includes/settings.php

View workflow job for this annotation

GitHub Actions / WordPress.org Guidelines Check

WordPress.Security.SafeRedirect.wp_redirect_wp_redirect

wp_redirect() found. Using wp_safe_redirect(), along with the "allowed_redirect_hosts" filter if needed, can help avoid any chances of malicious redirects within code. It is also important to remember to call exit() after a redirect so that no other unwanted code is executed.
}
}

Expand Down Expand Up @@ -320,7 +320,7 @@
wp_send_json_error();
}

$redirect_url = self::_update_settings( $_POST['menu-icons']['settings'] ); // Input var okay.

Check warning on line 323 in includes/settings.php

View workflow job for this annotation

GitHub Actions / WordPress.org Guidelines Check

WordPress.Security.ValidatedSanitizedInput.InputNotSanitized

Detected usage of a non-sanitized input variable: $_POST['menu-icons']['settings']

Check warning on line 323 in includes/settings.php

View workflow job for this annotation

GitHub Actions / WordPress.org Guidelines Check

WordPress.Security.ValidatedSanitizedInput.MissingUnslash

$_POST['menu-icons']['settings'] not unslashed before sanitization. Use wp_unslash() or similar
wp_send_json_success( array( 'redirectUrl' => $redirect_url ) );
}

Expand Down Expand Up @@ -535,18 +535,10 @@
'label' => __( 'Vertical Align', 'menu-icons' ),
'default' => 'middle',
'choices' => array(
array(
'value' => 'super',
'label' => __( 'Super', 'menu-icons' ),
),
array(
'value' => 'top',
'label' => __( 'Top', 'menu-icons' ),
),
array(
'value' => 'text-top',
'label' => __( 'Text Top', 'menu-icons' ),
),
array(
'value' => 'middle',
'label' => __( 'Middle', 'menu-icons' ),
Expand All @@ -555,18 +547,10 @@
'value' => 'baseline',
'label' => __( 'Baseline', 'menu-icons' ),
),
array(
'value' => 'text-bottom',
'label' => __( 'Text Bottom', 'menu-icons' ),
),
array(
'value' => 'bottom',
'label' => __( 'Bottom', 'menu-icons' ),
),
array(
'value' => 'sub',
'label' => __( 'Sub', 'menu-icons' ),
),
),
),
'font_size' => array(
Expand Down
Loading