Skip to content
Draft
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
1 change: 1 addition & 0 deletions .distignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Directories
/.wordpress-org
/.git
Expand All @@ -7,6 +7,7 @@
# Files
/.distignore
/.gitignore
/.phpcs.xml.dist
/.wp-env.json
/composer.json
/composer.lock
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: WPCS check
uses: 10up/wpcs-action@stable
with:
standard: WordPress
standard: .phpcs.xml.dist
paths: .

plugin-check:
Expand All @@ -52,3 +52,7 @@ jobs:
uses: wordpress/plugin-check-action@v1.1.6
with:
wp-version: "latest"
# Development-only files that ship excluded via .distignore but are
# present in the CI checkout; skip them so Plugin Check doesn't flag
# them as hidden/application files.
exclude-files: .wp-env.json,.phpcs.xml.dist
41 changes: 41 additions & 0 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0"?>
<ruleset name="Plugin Report">
<description>Coding standards for the Plugin Report plugin.</description>

<!-- Show sniff codes and progress; the CI workflow passes the path to scan. -->
<arg value="ps"/>
<arg name="extensions" value="php"/>

<!-- Directories that don't need linting. -->
<exclude-pattern>/vendor/*</exclude-pattern>
<exclude-pattern>/node_modules/*</exclude-pattern>

<rule ref="WordPress">
<!--
The plugin ships as a single bootstrap file named after the plugin
(rt-plugin-report.php). Renaming it to class-*.php would break the
plugin entry point, so the class-file naming rule does not apply.
-->
<exclude name="WordPress.Files.FileName.InvalidClassFileName"/>
</rule>

<!-- Recognise the plugin's text domain. -->
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="plugin-report"/>
</property>
</properties>
</rule>

<!-- Recognise the plugin's global prefixes. -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<property name="prefixes" type="array">
<element value="RT_Plugin_Report"/>
<element value="rt_plugin_report"/>
<element value="plugin_report"/>
</property>
</properties>
</rule>
</ruleset>
20 changes: 8 additions & 12 deletions rt-plugin-report.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php
/**
* Plugin Name: Plugin Report
Expand Down Expand Up @@ -25,7 +25,7 @@
/**
* Plugin Report main class.
*/
class RT_Plugin_Report {

Check warning on line 28 in rt-plugin-report.php

View workflow job for this annotation

GitHub Actions / Plugin Check

WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound

Classes declared by a theme/plugin should start with the theme/plugin prefix. Found: "RT_Plugin_Report".

// CSS class constants.
const CSS_CLASS_LOW = 'pr-risk-low';
Expand Down Expand Up @@ -464,14 +464,12 @@
// Plugin is available on wp.org.
$html .= '<td class="' . esc_attr( self::CSS_CLASS_LOW ) . '">wordpress.org</td>';
}
} elseif ( $parsed_repo_url && isset( $parsed_repo_url['host'] ) ) {
// Update URI is a valid URL, display the host.
$html .= '<td class="' . esc_attr( self::CSS_CLASS_MED ) . '">' . esc_html( $repo_host ) . '</td>';
} else {
if ( $parsed_repo_url && isset( $parsed_repo_url['host'] ) ) { // phpcs:ignore Universal.ControlStructures.DisallowLonelyIf.Found
// Update URI is a valid URL, display the host.
$html .= '<td class="' . esc_attr( self::CSS_CLASS_MED ) . '">' . esc_html( $repo_host ) . '</td>';
} else {
// Some other value (like 'false'), so assume updates are disabled.
$html .= '<td class="' . esc_attr( self::CSS_CLASS_MED ) . '">' . esc_html__( 'Updates disabled', 'plugin-report' ) . '</td>';
}
// Some other value (like 'false'), so assume updates are disabled.
$html .= '<td class="' . esc_attr( self::CSS_CLASS_MED ) . '">' . esc_html__( 'Updates disabled', 'plugin-report' ) . '</td>';
}
} elseif ( version_compare( $wp_version, '5.8', '<' ) ) {
$html .= $this->render_error_cell( esc_html__( 'Only available in WP 5.8+', 'plugin-report' ) );
Expand Down Expand Up @@ -531,12 +529,10 @@
// Auto-update.
if ( version_compare( $wp_version, '5.5', '<' ) ) {
$html .= '<td>' . esc_html__( 'Requires WordPress 5.5 or higher', 'plugin-report' ) . '</td>';
} elseif ( isset( $report['auto-update'] ) && $report['auto-update'] ) {
$html .= '<td class="' . esc_attr( self::CSS_CLASS_LOW ) . '">' . esc_html__( 'Enabled', 'plugin-report' ) . '</td>';
} else {
if ( isset( $report['auto-update'] ) && $report['auto-update'] ) { // phpcs:ignore Universal.ControlStructures.DisallowLonelyIf.Found
$html .= '<td class="' . esc_attr( self::CSS_CLASS_LOW ) . '">' . esc_html__( 'Enabled', 'plugin-report' ) . '</td>';
} else {
$html .= '<td>' . esc_html__( 'Not enabled', 'plugin-report' ) . '</td>';
}
$html .= '<td>' . esc_html__( 'Not enabled', 'plugin-report' ) . '</td>';
}

// Last updates.
Expand Down
Loading