Skip to content

Commit 8cf583a

Browse files
committed
finish checker
1 parent 1710afe commit 8cf583a

4 files changed

Lines changed: 117 additions & 40 deletions

File tree

assets/css/plugin-check-admin.css

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,59 @@
8585
white-space: pre-wrap;
8686
word-wrap: break-word;
8787
}
88+
89+
/* Plugin Check Namer styles */
90+
.plugin-check-namer-spinner {
91+
float: none;
92+
margin-left: 10px;
93+
}
94+
95+
.plugin-check-namer-hidden {
96+
display: none;
97+
}
98+
99+
.plugin-check-namer-verdict-container {
100+
margin-bottom: 20px;
101+
padding: 15px;
102+
background: #fff;
103+
border-left: 4px solid #2271b1;
104+
}
105+
106+
.plugin-check-namer-verdict-item {
107+
margin: 0 0 10px 0;
108+
}
109+
110+
.plugin-check-namer-meta {
111+
margin: 0 0 5px 0;
112+
color: #646970;
113+
font-style: italic;
114+
font-size: 0.9em;
115+
}
116+
117+
.plugin-check-namer-tokens {
118+
margin: 0;
119+
}
120+
121+
.plugin-check-namer-confusion {
122+
margin-top: 20px;
123+
}
124+
125+
.plugin-check-namer-confusion-item {
126+
margin-bottom: 15px;
127+
padding: 10px;
128+
background: #fff;
129+
border-left: 4px solid #2271b1;
130+
}
131+
132+
.plugin-check-namer-confusion-item-others {
133+
border-left-color: #dba617;
134+
}
135+
136+
.plugin-check-namer-confusion-meta {
137+
color: #646970;
138+
}
139+
140+
.plugin-check-namer-confusion-text {
141+
color: #646970;
142+
font-size: 0.9em;
143+
}

assets/js/plugin-check-namer.js

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@
9393
if ( ! name ) {
9494
setText( errorEl, pluginCheckNamer.messages.missingName );
9595
if ( errorEl ) {
96-
errorEl.style.display = 'block';
96+
errorEl.classList.remove( 'plugin-check-namer-hidden' );
9797
}
9898
return;
9999
}
100100

101101
// Clear previous results.
102102
if ( resultWrap ) {
103-
resultWrap.style.display = 'none';
103+
resultWrap.classList.add( 'plugin-check-namer-hidden' );
104104
}
105105
if ( verdictEl ) {
106106
setText( verdictEl, '' );
@@ -109,36 +109,36 @@
109109
setHtml( explainEl, '' );
110110
}
111111
if ( errorEl ) {
112-
errorEl.style.display = 'none';
112+
errorEl.classList.add( 'plugin-check-namer-hidden' );
113113
setText( errorEl, '' );
114114
}
115115

116116
if ( confusionPluginsDiv ) {
117-
confusionPluginsDiv.style.display = 'none';
117+
confusionPluginsDiv.classList.add( 'plugin-check-namer-hidden' );
118118
}
119119
if ( confusionPluginsList ) {
120120
confusionPluginsList.innerHTML = '';
121121
}
122122
if ( confusionOthersDiv ) {
123-
confusionOthersDiv.style.display = 'none';
123+
confusionOthersDiv.classList.add( 'plugin-check-namer-hidden' );
124124
}
125125
if ( confusionOthersList ) {
126126
confusionOthersList.innerHTML = '';
127127
}
128128
if ( timingDiv ) {
129-
timingDiv.style.display = 'none';
129+
timingDiv.classList.add( 'plugin-check-namer-hidden' );
130130
}
131131
if ( timingValue ) {
132132
setText( timingValue, '' );
133133
}
134134
if ( tokensDiv ) {
135-
tokensDiv.style.display = 'none';
135+
tokensDiv.classList.add( 'plugin-check-namer-hidden' );
136136
}
137137
if ( tokensValue ) {
138138
setText( tokensValue, '' );
139139
}
140140
if ( verdictContainer ) {
141-
verdictContainer.style.display = 'none';
141+
verdictContainer.classList.add( 'plugin-check-namer-hidden' );
142142
}
143143

144144
// Record start time.
@@ -186,6 +186,11 @@
186186
verdict.indexOf( 'no issues' ) !== -1
187187
) {
188188
borderColor = '#00a32a'; // Green for good.
189+
} else if (
190+
verdict.indexOf( 'generally allowable' ) !== -1 ||
191+
verdict.indexOf( 'allowable' ) !== -1
192+
) {
193+
borderColor = '#2271b1'; // Blue for generally allowable.
189194
} else if (
190195
verdict.indexOf( 'review' ) !== -1 ||
191196
verdict.indexOf( 'medium' ) !== -1 ||
@@ -200,7 +205,7 @@
200205
}
201206

202207
verdictContainer.style.borderLeftColor = borderColor;
203-
verdictContainer.style.display = 'block';
208+
verdictContainer.classList.remove( 'plugin-check-namer-hidden' );
204209
}
205210

206211
// Calculate and display elapsed time.
@@ -211,7 +216,7 @@
211216
);
212217
timingValue.textContent =
213218
elapsedSeconds + ' ' + 'seconds';
214-
timingDiv.style.display = 'block';
219+
timingDiv.classList.remove( 'plugin-check-namer-hidden' );
215220
}
216221

217222
// Display token usage if available.
@@ -259,7 +264,7 @@
259264
}
260265

261266
tokensValue.textContent = tokensText;
262-
tokensDiv.style.display = 'block';
267+
tokensDiv.classList.remove( 'plugin-check-namer-hidden' );
263268
}
264269

265270
// Display confusion_existing_plugins if available.
@@ -273,14 +278,13 @@
273278
payload.data.confusion_existing_plugins.forEach(
274279
function ( plugin ) {
275280
const div = document.createElement( 'div' );
276-
div.style.cssText =
277-
'margin-bottom: 15px; padding: 10px; background: #fff; border-left: 4px solid #2271b1;';
281+
div.className = 'plugin-check-namer-confusion-item';
278282
div.innerHTML =
279283
'<strong>' +
280284
escapeHtml( plugin.name || '' ) +
281285
'</strong>' +
282286
( plugin.active_installations
283-
? ' <span style="color: #646970;">(' +
287+
? ' <span class="plugin-check-namer-confusion-meta">(' +
284288
escapeHtml(
285289
plugin.active_installations
286290
) +
@@ -289,12 +293,12 @@
289293
')</span>'
290294
: '' ) +
291295
( plugin.owner_username
292-
? ' <span style="color: #646970;"> - ' +
296+
? ' <span class="plugin-check-namer-confusion-meta"> - ' +
293297
escapeHtml( plugin.owner_username ) +
294298
'</span>'
295299
: '' ) +
296300
'<br>' +
297-
'<span style="color: #646970; font-size: 0.9em;">' +
301+
'<span class="plugin-check-namer-confusion-text">' +
298302
escapeHtml( plugin.explanation || '' ) +
299303
'</span>' +
300304
( plugin.link
@@ -307,9 +311,9 @@
307311
confusionPluginsList.appendChild( div );
308312
}
309313
);
310-
confusionPluginsDiv.style.display = 'block';
314+
confusionPluginsDiv.classList.remove( 'plugin-check-namer-hidden' );
311315
} else if ( confusionPluginsDiv ) {
312-
confusionPluginsDiv.style.display = 'none';
316+
confusionPluginsDiv.classList.add( 'plugin-check-namer-hidden' );
313317
}
314318

315319
// Display confusion_existing_others if available.
@@ -323,14 +327,13 @@
323327
payload.data.confusion_existing_others.forEach(
324328
function ( item ) {
325329
const div = document.createElement( 'div' );
326-
div.style.cssText =
327-
'margin-bottom: 15px; padding: 10px; background: #fff; border-left: 4px solid #dba617;';
330+
div.className = 'plugin-check-namer-confusion-item plugin-check-namer-confusion-item-others';
328331
div.innerHTML =
329332
'<strong>' +
330333
escapeHtml( item.name || '' ) +
331334
'</strong>' +
332335
'<br>' +
333-
'<span style="color: #646970; font-size: 0.9em;">' +
336+
'<span class="plugin-check-namer-confusion-text">' +
334337
escapeHtml( item.explanation || '' ) +
335338
'</span>' +
336339
( item.link
@@ -343,13 +346,13 @@
343346
confusionOthersList.appendChild( div );
344347
}
345348
);
346-
confusionOthersDiv.style.display = 'block';
349+
confusionOthersDiv.classList.remove( 'plugin-check-namer-hidden' );
347350
} else if ( confusionOthersDiv ) {
348-
confusionOthersDiv.style.display = 'none';
351+
confusionOthersDiv.classList.add( 'plugin-check-namer-hidden' );
349352
}
350353

351354
if ( resultWrap ) {
352-
resultWrap.style.display = 'block';
355+
resultWrap.classList.remove( 'plugin-check-namer-hidden' );
353356
}
354357
} )
355358
.catch( function ( err ) {
@@ -360,7 +363,7 @@
360363
: pluginCheckNamer.messages.genericError
361364
);
362365
if ( errorEl ) {
363-
errorEl.style.display = 'block';
366+
errorEl.classList.remove( 'plugin-check-namer-hidden' );
364367
}
365368
} )
366369
.finally( function () {

includes/Admin/Namer_Page.php

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ public function enqueue_scripts( $hook_suffix ) {
9292
return;
9393
}
9494

95+
wp_enqueue_style(
96+
'plugin-check-admin',
97+
plugins_url( 'assets/css/plugin-check-admin.css', WP_PLUGIN_CHECK_MAIN_FILE ),
98+
array(),
99+
WP_PLUGIN_CHECK_VERSION
100+
);
101+
95102
wp_enqueue_script(
96103
'plugin-check-namer',
97104
plugins_url( 'assets/js/plugin-check-namer.js', WP_PLUGIN_CHECK_MAIN_FILE ),
@@ -266,10 +273,6 @@ public function render_page() {
266273
<div class="wrap">
267274
<h1><?php echo esc_html__( 'Plugin Check Namer Tool', 'plugin-check' ); ?></h1>
268275

269-
<p class="description">
270-
<?php echo esc_html__( 'Disclaimer: This tool provides guidance only and is not definitive. It contains a prompt that is used to evaluate the similarity of a plugin name to other plugin names and ensure compliance with trademark regulations.', 'plugin-check' ); ?>
271-
</p>
272-
273276
<form id="plugin-check-namer-form" method="post">
274277
<table class="form-table" role="presentation">
275278
<tbody>
@@ -294,40 +297,47 @@ class="large-text"
294297
</tbody>
295298
</table>
296299

297-
<p class="submit" style="text-align: left;">
300+
<p class="description">
301+
<strong><?php echo esc_html__( 'Note:', 'plugin-check' ); ?></strong>
302+
<br/>
303+
<?php echo esc_html__( 'This tool provides guidance only and is not definitive. It contains a prompt that is used to evaluate the similarity of a plugin name to other plugin names and ensure compliance with trademark regulations.', 'plugin-check' ); ?>
304+
<br/>
305+
<?php echo esc_html__( 'This analysis performs two AI checks for similarity and trademark conflicts, which may take a moment to complete.', 'plugin-check' ); ?>
306+
</p>
307+
<p class="submit">
298308
<button type="submit" class="button button-primary" id="plugin-check-namer-submit"><?php echo esc_html__( 'Evaluate name', 'plugin-check' ); ?></button>
299-
<span class="spinner" id="plugin-check-namer-spinner" style="float: none; margin-left: 10px;"></span>
309+
<span class="spinner plugin-check-namer-spinner" id="plugin-check-namer-spinner"></span>
300310
</p>
301311
</form>
302312

303-
<div id="plugin-check-namer-error" class="notice notice-error" style="display: none;"><p></p></div>
313+
<div id="plugin-check-namer-error" class="notice notice-error plugin-check-namer-hidden"><p></p></div>
304314

305-
<div id="plugin-check-namer-result" style="display: none;">
315+
<div id="plugin-check-namer-result" class="plugin-check-namer-hidden">
306316
<h2><?php echo esc_html__( 'Result', 'plugin-check' ); ?></h2>
307-
<div id="plugin-check-namer-verdict-container" style="display: none; margin-bottom: 20px; padding: 15px; background: #fff; border-left: 4px solid #2271b1;">
308-
<p style="margin: 0 0 10px 0;">
317+
<div id="plugin-check-namer-verdict-container" class="plugin-check-namer-verdict-container plugin-check-namer-hidden">
318+
<p class="plugin-check-namer-verdict-item">
309319
<strong><?php echo esc_html__( 'Verdict:', 'plugin-check' ); ?></strong>
310320
<span id="plugin-check-namer-verdict"></span>
311321
</p>
312-
<p style="margin: 0 0 10px 0;">
322+
<p class="plugin-check-namer-verdict-item">
313323
<strong><?php echo esc_html__( 'Explanation:', 'plugin-check' ); ?></strong>
314324
<span id="plugin-check-namer-explanation"></span>
315325
</p>
316-
<p id="plugin-check-namer-timing" style="display: none; margin: 0 0 5px 0; color: #646970; font-style: italic; font-size: 0.9em;">
326+
<p id="plugin-check-namer-timing" class="plugin-check-namer-meta plugin-check-namer-hidden">
317327
<strong><?php echo esc_html__( 'Analysis completed in:', 'plugin-check' ); ?></strong>
318328
<span id="plugin-check-namer-timing-value"></span>
319329
</p>
320-
<p id="plugin-check-namer-tokens" style="display: none; margin: 0; color: #646970; font-style: italic; font-size: 0.9em;">
330+
<p id="plugin-check-namer-tokens" class="plugin-check-namer-meta plugin-check-namer-hidden">
321331
<strong><?php echo esc_html__( 'Tokens used:', 'plugin-check' ); ?></strong>
322332
<span id="plugin-check-namer-tokens-value"></span>
323333
</p>
324334
</div>
325-
<div id="plugin-check-namer-confusion-plugins" style="display: none; margin-top: 20px;">
335+
<div id="plugin-check-namer-confusion-plugins" class="plugin-check-namer-confusion plugin-check-namer-hidden">
326336
<p><strong><?php echo esc_html__( 'Similar Existing Plugins', 'plugin-check' ); ?></strong></p>
327337
<div id="plugin-check-namer-confusion-plugins-list"></div>
328338
</div>
329339

330-
<div id="plugin-check-namer-confusion-others" style="display: none; margin-top: 20px;">
340+
<div id="plugin-check-namer-confusion-others" class="plugin-check-namer-confusion plugin-check-namer-hidden">
331341
<h3><?php echo esc_html__( 'Similar Existing Projects/Trademarks', 'plugin-check' ); ?></h3>
332342
<div id="plugin-check-namer-confusion-others-list"></div>
333343
</div>

includes/Traits/AI_Check_Names.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,14 @@ protected function build_verdict( $decoded ) {
359359
return '⚠️ ' . __( 'Issues Found', 'plugin-check' ) . ': ' . implode( ', ', $issues );
360360
}
361361

362+
// Check for suggestions, trademarks, or other indicators that suggest it's not clearly OK.
363+
$has_suggestions = ! empty( $decoded['suggested_display_name'] ) || ! empty( $decoded['suggested_slug'] );
364+
$has_trademarks = ! empty( $decoded['trademarks_or_project_names_array'] ) && is_array( $decoded['trademarks_or_project_names_array'] ) && count( $decoded['trademarks_or_project_names_array'] ) > 0;
365+
366+
if ( $has_suggestions || $has_trademarks ) {
367+
return 'ℹ️ ' . __( 'Generally Allowable', 'plugin-check' );
368+
}
369+
362370
return '' . __( 'No Issues Detected', 'plugin-check' );
363371
}
364372

0 commit comments

Comments
 (0)