Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
931 changes: 818 additions & 113 deletions assets/css/plugin-check-admin.css

Large diffs are not rendered by default.

1,354 changes: 1,092 additions & 262 deletions assets/js/plugin-check-admin.js

Large diffs are not rendered by default.

88 changes: 17 additions & 71 deletions includes/Admin/Admin_Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,83 +372,29 @@ public function filter_plugin_action_links( $actions, $plugin_file, $plugin_data
}

/**
* Render the results table templates in the footer.
* Renders the results templates in the footer.
*
* @since 1.0.0
*/
public function admin_footer() {
ob_start();
require WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . 'templates/results-table.php';
$results_table_template = ob_get_clean();
wp_print_inline_script_tag(
$results_table_template,
array(
'id' => 'tmpl-plugin-check-results-table',
'type' => 'text/template',
)
);

ob_start();
require WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . 'templates/results-row.php';
$results_row_template = ob_get_clean();
wp_print_inline_script_tag(
$results_row_template,
array(
'id' => 'tmpl-plugin-check-results-row',
'type' => 'text/template',
)
$templates = array(
'plugin-check-results-group' => 'templates/results-group.php',
'plugin-check-results-row' => 'templates/results-row.php',
'plugin-check-results-false-positives' => 'templates/results-false-positives.php',
);

ob_start();
require WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . 'templates/results-false-positives.php';
$results_false_positives_template = ob_get_clean();
wp_print_inline_script_tag(
$results_false_positives_template,
array(
'id' => 'tmpl-plugin-check-results-false-positives',
'type' => 'text/template',
)
);

ob_start();
require WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . 'templates/results-complete.php';
$results_row_template = ob_get_clean();
wp_print_inline_script_tag(
$results_row_template,
array(
'id' => 'tmpl-plugin-check-results-complete',
'type' => 'text/template',
)
);
?>
<style>
#plugin-check__results .notice,
#plugin-check__results .notice + h4 {
margin-top: 20px;
}
#plugin-check__results h4:first-child {
margin-top: 80.5px;
}
@media ( max-width: 782px ) {
#plugin-check__results h4:first-child {
margin-top: 88.5px;
}
}
.plugin-check__export-controls {
margin-top: 24px;
display: flex;
gap: 8px;
flex-wrap: wrap;
}
.plugin-check__export-controls.is-hidden {
display: none;
}
/** Plugin Check Client Errors **/
#plugin-check__client-error.is-hidden {
display: none;
}
</style>
<?php
foreach ( $templates as $template_id => $template_file ) {
ob_start();
require WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . $template_file;
$template = ob_get_clean();
wp_print_inline_script_tag(
$template,
array(
'id' => 'tmpl-' . $template_id,
'type' => 'text/template',
)
);
}
}

/**
Expand Down
238 changes: 153 additions & 85 deletions templates/admin-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,91 +15,89 @@

<?php if ( ! empty( $available_plugins ) ) { ?>

<form>
<h2>
<label class="title" for="plugin-check__plugins-dropdown">
<?php esc_html_e( 'Check the Plugin', 'plugin-check' ); ?>
</label>
</h2>

<p id="plugin-check__description">
<?php esc_html_e( 'Select a plugin to check it for best practices in several categories and security issues. For more information about the checks, use the Help tab at the top of this page.', 'plugin-check' ); ?>
</p>

<select id="plugin-check__plugins-dropdown" name="plugin_check_plugins" aria-describedby="plugin-check__description">
<?php if ( 1 !== count( $available_plugins ) ) { ?>
<option value=""><?php esc_html_e( 'Select Plugin', 'plugin-check' ); ?></option>
<?php } ?>
<?php foreach ( $available_plugins as $plugin_basename => $available_plugin ) { ?>
<option value="<?php echo esc_attr( $plugin_basename ); ?>"<?php selected( $selected_plugin_basename, $plugin_basename ); ?>>
<?php echo esc_html( $available_plugin['Name'] ); ?>
</option>
<?php } ?>
</select>

<input type="submit" value="<?php esc_attr_e( 'Check it!', 'plugin-check' ); ?>" id="plugin-check__submit" class="button button-primary" />
<span id="plugin-check__spinner" class="spinner" style="float: none;"></span>
<div class="notice notice-error is-hidden" role="alert" tabindex="-1" id="plugin-check__client-error"></div>
<div class="plugin-check__options">
<div>
<h4><?php esc_html_e( 'Categories', 'plugin-check' ); ?></h4>
<?php if ( ! empty( $categories ) ) : ?>
<table id="plugin-check__categories">
<?php foreach ( $categories as $category => $label ) : ?>
<tr>
<td>
<fieldset>
<legend class="screen-reader-text"><?php echo esc_html( $label ); ?></legend>
<label for="<?php echo esc_attr( $category ); ?>">
<input type="checkbox" id="<?php echo esc_attr( $category ); ?>" name="categories" value="<?php echo esc_attr( $category ); ?>" <?php checked( in_array( $category, $user_enabled_categories, true ) ); ?> />
<?php echo esc_html( $label ); ?>
</label>
</fieldset>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
</div>
<div id="plugin-check__types-container">
<h4><?php esc_html_e( 'Types', 'plugin-check' ); ?></h4>
<?php if ( ! empty( $types ) ) : ?>
<table id="plugin-check__types">
<?php foreach ( $types as $type => $label ) : ?>
<tr>
<td>
<fieldset>
<legend class="screen-reader-text"><?php echo esc_html( $label ); ?></legend>
<label for="<?php echo esc_attr( $type ); ?>">
<input type="checkbox" id="<?php echo esc_attr( $type ); ?>" name="types" value="<?php echo esc_attr( $type ); ?>" checked="checked" />
<?php echo esc_html( $label ); ?>
</label>
</fieldset>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
</div>
<div id="plugin-check__ai-container">
<h4><?php esc_html_e( 'AI Settings', 'plugin-check' ); ?></h4>
<p>
<label><input type="checkbox" value="use-ai" id="plugin-check__use-ai" /> <?php esc_html_e( 'Enable AI Analysis', 'plugin-check' ); ?></label>
</p>
</div>
<div id="plugin-check__pcpignore-container">
<h4><?php esc_html_e( 'Custom Exclusions', 'plugin-check' ); ?></h4>
<p>
<label><input type="checkbox" value="use-pcpignore" id="plugin-check__use-pcpignore" /> <?php esc_html_e( 'Use .pcpignore custom exclusions', 'plugin-check' ); ?></label>
</p>
</div>
</div>
<?php if ( $has_experimental_checks ) { ?>
<p>
<label><input type="checkbox" value="include-experimental" id="plugin-check__include-experimental" /> <?php esc_html_e( 'Include Experimental Checks', 'plugin-check' ); ?></label>
<form class="plugin-check__run">
<div class="plugin-check__run-main">
<h2>
<label class="title" for="plugin-check__plugins-dropdown">
<?php esc_html_e( 'Check the Plugin', 'plugin-check' ); ?>
</label>
</h2>

<p id="plugin-check__description">
<?php esc_html_e( 'Select a plugin to check it for best practices in several categories and security issues. For more information about the checks, use the Help tab at the top of this page.', 'plugin-check' ); ?>
</p>
<?php } ?>

<select id="plugin-check__plugins-dropdown" name="plugin_check_plugins" aria-describedby="plugin-check__description">
<?php if ( 1 !== count( $available_plugins ) ) { ?>
<option value=""><?php esc_html_e( 'Select Plugin', 'plugin-check' ); ?></option>
<?php } ?>
<?php foreach ( $available_plugins as $plugin_basename => $available_plugin ) { ?>
<option value="<?php echo esc_attr( $plugin_basename ); ?>"<?php selected( $selected_plugin_basename, $plugin_basename ); ?>>
<?php echo esc_html( $available_plugin['Name'] ); ?>
</option>
<?php } ?>
</select>

<input type="submit" value="<?php esc_attr_e( 'Check it!', 'plugin-check' ); ?>" id="plugin-check__submit" class="button button-primary" />
<span id="plugin-check__spinner" class="spinner"></span>
</div>

<div class="notice notice-error inline is-hidden" role="alert" tabindex="-1" id="plugin-check__client-error"></div>

<details class="plugin-check__options" id="plugin-check__options">
<summary>
<span class="plugin-check__options-label">
<span class="plugin-check__chevron" aria-hidden="true"></span>
<?php esc_html_e( 'Options', 'plugin-check' ); ?>
</span>
<span class="plugin-check__options-summary" id="plugin-check__options-summary"></span>
<span class="plugin-check__options-edit" aria-hidden="true"><?php esc_html_e( 'Edit', 'plugin-check' ); ?></span>
</summary>

<div class="plugin-check__options-grid">
<fieldset id="plugin-check__categories">
<legend><?php esc_html_e( 'Categories', 'plugin-check' ); ?></legend>
<?php foreach ( $categories as $category => $label ) : ?>
<label for="<?php echo esc_attr( $category ); ?>">
<input type="checkbox" id="<?php echo esc_attr( $category ); ?>" name="categories" value="<?php echo esc_attr( $category ); ?>" <?php checked( in_array( $category, $user_enabled_categories, true ) ); ?> />
<?php echo esc_html( $label ); ?>
</label>
<?php endforeach; ?>
</fieldset>

<fieldset id="plugin-check__types-container">
<legend><?php esc_html_e( 'Types', 'plugin-check' ); ?></legend>
<?php foreach ( $types as $type => $label ) : ?>
<label for="<?php echo esc_attr( $type ); ?>">
<input type="checkbox" id="<?php echo esc_attr( $type ); ?>" name="types" value="<?php echo esc_attr( $type ); ?>" checked="checked" />
<?php echo esc_html( $label ); ?>
</label>
<?php endforeach; ?>
</fieldset>

<fieldset id="plugin-check__ai-container">
<legend><?php esc_html_e( 'AI Settings', 'plugin-check' ); ?></legend>
<label>
<input type="checkbox" value="use-ai" id="plugin-check__use-ai" data-label="<?php esc_attr_e( 'AI Analysis', 'plugin-check' ); ?>" />
<?php esc_html_e( 'Enable AI Analysis', 'plugin-check' ); ?>
</label>
</fieldset>

<fieldset id="plugin-check__pcpignore-container">
<legend><?php esc_html_e( 'Custom Exclusions', 'plugin-check' ); ?></legend>
<label>
<input type="checkbox" value="use-pcpignore" id="plugin-check__use-pcpignore" data-label=".pcpignore" />
<?php esc_html_e( 'Use .pcpignore custom exclusions', 'plugin-check' ); ?>
</label>
<?php if ( $has_experimental_checks ) { ?>
<label>
<input type="checkbox" value="include-experimental" id="plugin-check__include-experimental" data-label="<?php esc_attr_e( 'Experimental', 'plugin-check' ); ?>" />
<?php esc_html_e( 'Include Experimental Checks', 'plugin-check' ); ?>
</label>
<?php } ?>
</fieldset>
</div>
</details>
</form>

<?php } else { ?>
Expand All @@ -109,7 +107,77 @@
<?php } ?>
</div>

<div id="plugin-check__export-controls" class="plugin-check__export-controls"></div>
<div id="plugin-check__results"></div>
<div id="plugin-check__report" class="plugin-check__report" hidden>
<section class="plugin-check__summary" id="plugin-check__summary">
<div>
<h2 class="plugin-check__summary-title" id="plugin-check__summary-title"></h2>
<p class="plugin-check__summary-meta" id="plugin-check__summary-meta"></p>
</div>
<div id="plugin-check__export-controls" class="plugin-check__export-controls"></div>
</section>

<div class="plugin-check__stats">
<button type="button" class="plugin-check__stat" data-filter-type="all" aria-pressed="true">
<span class="plugin-check__stat-label"><?php esc_html_e( 'Total issues', 'plugin-check' ); ?></span>
<span class="plugin-check__stat-value" data-count="all">0</span>
</button>
<button type="button" class="plugin-check__stat plugin-check__stat--error" data-filter-type="ERROR" aria-pressed="false">
<span class="plugin-check__stat-label"><span class="plugin-check__dot plugin-check__dot--error" aria-hidden="true"></span><?php esc_html_e( 'Errors', 'plugin-check' ); ?></span>
<span class="plugin-check__stat-value" data-count="ERROR">0</span>
</button>
<button type="button" class="plugin-check__stat plugin-check__stat--warning" data-filter-type="WARNING" aria-pressed="false">
<span class="plugin-check__stat-label"><span class="plugin-check__dot plugin-check__dot--warning" aria-hidden="true"></span><?php esc_html_e( 'Warnings', 'plugin-check' ); ?></span>
<span class="plugin-check__stat-value" data-count="WARNING">0</span>
</button>
<div class="plugin-check__stat">
<span class="plugin-check__stat-label"><?php esc_html_e( 'Files affected', 'plugin-check' ); ?></span>
<span class="plugin-check__stat-value" data-count="files">0</span>
</div>
</div>

<div class="plugin-check__layout">
<aside class="plugin-check__panel">
<div class="plugin-check__panel-head">
<?php esc_html_e( 'Checks', 'plugin-check' ); ?>
<small id="plugin-check__checks-count"></small>
</div>
<ul class="plugin-check__checks" id="plugin-check__checks"></ul>
</aside>

<section class="plugin-check__panel">
<div class="plugin-check__toolbar">
<label class="screen-reader-text" for="plugin-check__search"><?php esc_html_e( 'Search results', 'plugin-check' ); ?></label>
<input id="plugin-check__search" class="plugin-check__search" type="search" placeholder="<?php esc_attr_e( 'Search messages, files or codes', 'plugin-check' ); ?>" />
<div class="plugin-check__segmented" role="group" aria-label="<?php esc_attr_e( 'Group results by', 'plugin-check' ); ?>">
<button type="button" data-group-by="file" aria-pressed="true"><?php esc_html_e( 'By file', 'plugin-check' ); ?></button>
<button type="button" data-group-by="check" aria-pressed="false"><?php esc_html_e( 'By check', 'plugin-check' ); ?></button>
</div>
<button type="button" class="button" id="plugin-check__toggle-all"><?php esc_html_e( 'Expand all', 'plugin-check' ); ?></button>
</div>

<div class="plugin-check__toolbar plugin-check__filters">
<strong><?php esc_html_e( 'Filter', 'plugin-check' ); ?></strong>
<div class="plugin-check__segmented" role="group" aria-label="<?php esc_attr_e( 'Result type', 'plugin-check' ); ?>">
<button type="button" data-filter-type="all" aria-pressed="true"><?php esc_html_e( 'All', 'plugin-check' ); ?> (<span data-count="all">0</span>)</button>
<button type="button" data-filter-type="ERROR" aria-pressed="false"><?php esc_html_e( 'Errors', 'plugin-check' ); ?> (<span data-count="ERROR">0</span>)</button>
<button type="button" data-filter-type="WARNING" aria-pressed="false"><?php esc_html_e( 'Warnings', 'plugin-check' ); ?> (<span data-count="WARNING">0</span>)</button>
</div>
<div class="plugin-check__combo">
<label for="plugin-check__check-input" class="screen-reader-text"><?php esc_html_e( 'Check', 'plugin-check' ); ?></label>
<input id="plugin-check__check-input" class="plugin-check__combo-input" type="text" role="combobox" autocomplete="off" aria-autocomplete="list" aria-expanded="false" aria-controls="plugin-check__check-list" placeholder="<?php esc_attr_e( 'All checks', 'plugin-check' ); ?>" />
<button type="button" class="plugin-check__combo-clear" id="plugin-check__combo-clear" aria-label="<?php esc_attr_e( 'Clear check filter', 'plugin-check' ); ?>" hidden>&times;</button>
<button type="button" class="plugin-check__combo-toggle" id="plugin-check__combo-toggle" aria-label="<?php esc_attr_e( 'Show checks', 'plugin-check' ); ?>" tabindex="-1"><span class="dashicons dashicons-arrow-down-alt2" aria-hidden="true"></span></button>
<ul class="plugin-check__combo-list" id="plugin-check__check-list" role="listbox" aria-label="<?php esc_attr_e( 'Checks', 'plugin-check' ); ?>" hidden></ul>
</div>
<label><input type="checkbox" id="plugin-check__hide-dev" /> <?php esc_html_e( 'Hide development files', 'plugin-check' ); ?></label>
</div>

<div class="plugin-check__active-filter" id="plugin-check__active-filter" hidden></div>
<div id="plugin-check__results"></div>
</section>
</div>

<div id="plugin-check__false-positives-container"></div>
</div>

</div>
3 changes: 0 additions & 3 deletions templates/results-complete.php

This file was deleted.

33 changes: 33 additions & 0 deletions templates/results-group.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* Template for one group of results: a file, or a check.
*
* @package plugin-check
*/

?>
<details class="plugin-check__group" data-key="{{ data.key }}" <# if ( data.open ) { #>open<# } #>>
<summary>
<span class="plugin-check__chevron" aria-hidden="true"></span>
<span class="plugin-check__path">
<span class="plugin-check__path-dir">{{ data.dir }}</span><span class="plugin-check__path-base">{{ data.base }}</span>
</span>
<# if ( data.isDev ) { #>
<span class="plugin-check__tag"><?php esc_html_e( 'development file', 'plugin-check' ); ?></span>
<# } #>
<span class="plugin-check__badges">
<# if ( data.errorLabel ) { #>
<span class="plugin-check__badge plugin-check__badge--error">{{ data.errorLabel }}</span>
<# } #>
<# if ( data.warningLabel ) { #>
<span class="plugin-check__badge plugin-check__badge--warning">{{ data.warningLabel }}</span>
<# } #>
</span>
</summary>
<ul class="plugin-check__issues"></ul>
<# if ( data.moreLabel ) { #>
<div class="plugin-check__more">
<button type="button" class="button" data-show-more="{{ data.key }}">{{ data.moreLabel }}</button>
</div>
<# } #>
</details>
Loading