Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v3] clean up dependencies and fix codestyle pipeline #575

Merged
merged 4 commits into from
Mar 17, 2024
Merged
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
20 changes: 0 additions & 20 deletions .eslintrc

This file was deleted.

18 changes: 4 additions & 14 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.3', '7.2', '5.4']
php-versions: ['7.3', '7.2']
steps:
- uses: actions/checkout@master
- name: Setup PHP
Expand All @@ -15,9 +15,6 @@ jobs:
extensions: mbstring, intl
ini-values: post_max_size=256M, short_open_tag=On
tools: phpunit, composer
- name: Set COMPOSER environment variable for 5.4
if: matrix.php-versions == '5.4'
run: echo "COMPOSER=composer-php-5-4.json" >> $GITHUB_ENV
- name: Run tests
run: |
composer install
Expand Down Expand Up @@ -85,16 +82,9 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.2'
extensions: mbstring, intl
ini-values: post_max_size=256M, short_open_tag=On
tools: phpunit, composer
- uses: actions/setup-node@v2
with:
node-version: '14'
php-version: '8.2'
tools: composer
- name: Run code style checks for CSS, JavaScript and PHP
run: |
composer install
npm install
composer lint-all
composer install --ignore-platform-req=php
composer cs
5 changes: 0 additions & 5 deletions .stylelintrc.json

This file was deleted.

43 changes: 0 additions & 43 deletions composer-php-5-4.json

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"phpcompatibility/phpcompatibility-wp": "^2.1",
"phpunit/phpunit": "^4",
"wp-cli/wp-cli-bundle": "@stable",
"wp-coding-standards/wpcs": "^2.3"
"wp-coding-standards/wpcs": "^3.0"
},
"autoload": {
"psr-4": {
Expand Down
31 changes: 1 addition & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,5 @@
"version": "3.0.0",
"description": "Antispam Bee blocks spam comments and trackbacks effectively and without captchas.",
"author": "pluginkollektiv",
"license": "GPL-2.0-or-later",
"main": "build/index.js",
"scripts": {
"build": "wp-scripts build",
"check-engines": "wp-scripts check-engines",
"check-licenses": "wp-scripts check-licenses",
"format:js": "wp-scripts format-js",
"format:js:src": "wp-scripts format-js ./src",
"lint:css": "wp-scripts lint-style",
"lint:css:src": "wp-scripts lint-style 'src/**/*.css'",
"lint:js": "wp-scripts lint-js",
"lint:js:src": "wp-scripts lint-js ./src",
"lint:md:docs": "wp-scripts lint-md-docs",
"lint:md:js": "wp-scripts lint-md-js",
"lint:pkg-json": "wp-scripts lint-pkg-json",
"packages-update": "wp-scripts packages-update",
"postpackages-update": "npm run build",
"start": "wp-scripts start",
"test:e2e": "wp-scripts test-e2e",
"test:unit": "wp-scripts test-unit-js"
},
"devDependencies": {
"@wordpress/scripts": "^18.1.0",
"classnames": "^2.3.1",
"svg-spritemap-webpack-plugin": "^4.3.3",
"url-loader": "^4.1.1"
},
"dependencies": {
"raphael": "^2.3.0"
}
"license": "GPL-2.0-or-later"
}
2 changes: 1 addition & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

<rule ref="WordPress">
<!-- As we use PHP 5.4+ now, we can use the short array syntax -->
<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found" />
<exclude name="Universal.Arrays.DisallowShortArraySyntax.Found" />
<!-- Uncomment if you develop a theme with templates for CPTs having a prefix -->
<exclude name="WordPress.Files.FileName" />
<!-- Uncomment for projects using the metabox toolbox -->
Expand Down
16 changes: 8 additions & 8 deletions src/Admin/CommentsColumns.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static function register_plugin_columns( $columns ) {
/**
* Display plugin column values on comments screen
*
* @param string $column Currently selected column.
* @param string $column Currently selected column.
* @param integer $comment_id Comment ID.
*
* @since 2.6.0
Expand Down Expand Up @@ -141,19 +141,19 @@ public static function filter_columns() {
global $wpdb;
?>
<label class="screen-reader-text"
for="filter-by-comment-spam-reason"><?php esc_html_e( 'Filter by spam reason', 'antispam-bee' ); ?></label>
for="filter-by-comment-spam-reason"><?php esc_html_e( 'Filter by spam reason', 'antispam-bee' ); ?></label>
<select id="filter-by-comment-spam-reason" name="comment_spam_reason">
<option value=""><?php esc_html_e( 'All spam reasons', 'antispam-bee' ); ?></option>
<?php
$spam_reason = isset( $_GET['comment_spam_reason'] ) ? sanitize_text_field( wp_unslash( $_GET['comment_spam_reason'] ) ) : '';
// phpcs:ignore WordPress.DB.DirectDatabaseQuery
$tmp = $wpdb->get_results( "SELECT meta_value FROM {$wpdb->prefix}commentmeta WHERE meta_key = 'antispam_bee_reason' GROUP BY meta_value", ARRAY_A );
$tmp = $wpdb->get_results( "SELECT meta_value FROM {$wpdb->prefix}commentmeta WHERE meta_key = 'antispam_bee_reason' GROUP BY meta_value", ARRAY_A );
$reasons = [];
foreach ( $tmp as $t ) {
$reasons = array_merge( $reasons, explode( ',', $t['meta_value'] ) );
}

$reasons = array_unique( $reasons );
$reasons = array_unique( $reasons );
$reason_mapping = PluginUpdate::$spam_reasons_mapping;

foreach ( $reasons as $reason ) {
Expand Down Expand Up @@ -202,13 +202,13 @@ public static function filter_by_spam_reason( $query ) {
$query->query_vars['meta_query'] = [
'relation' => 'OR',
[
'key' => 'antispam_bee_reason',
'value' => $spam_reason,
'key' => 'antispam_bee_reason',
'value' => $spam_reason,
'compare' => 'LIKE',
],
[
'key' => 'antispam_bee_reason',
'value' => array_flip( $reasons_mapping )[ $spam_reason ],
'key' => 'antispam_bee_reason',
'value' => array_flip( $reasons_mapping )[ $spam_reason ],
'compare' => 'LIKE',
],
];
Expand Down
24 changes: 12 additions & 12 deletions src/Admin/DashboardWidgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@ public static function add_dashboard_count( $items = array() ) {
echo '<style>#dashboard_right_now .ab-count::before {content: "\f117"} #dashboard_right_now .ab-current-spam::before {content: "\f17e"}</style>';

$items[] = '<span class="ab-count">' . esc_html(
sprintf(
sprintf(
// translators: The number of spam comments Antispam Bee blocked so far.
__( '%s comments blocked', 'antispam-bee' ),
self::get_spam_count()
)
) . '</span>';
__( '%s comments blocked', 'antispam-bee' ),
self::get_spam_count()
)
) . '</span>';

$link = add_query_arg( 'comment_status', 'spam', admin_url( 'edit-comments.php' ) );
$link = add_query_arg( 'comment_status', 'spam', admin_url( 'edit-comments.php' ) );
$comments_number = wp_count_comments();
$items[] = '<a href="' . $link . '" class="ab-current-spam">' . esc_html(
sprintf(
$items[] = '<a href="' . $link . '" class="ab-current-spam">' . esc_html(
sprintf(
// translators: The number of spam comments in the local spam database.
__( '%s comments in local spam db', 'antispam-bee' ),
self::format_number( $comments_number->spam )
)
) . '</a>';
__( '%s comments in local spam db', 'antispam-bee' ),
self::format_number( $comments_number->spam )
)
) . '</a>';

return $items;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Admin/Fields/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ abstract class Field {
/**
* Initializing field
*
* @param string $type Item type.
* @param array $option Field options.
* @param string $type Item type.
* @param array $option Field options.
* @param class-string<Controllable> $controllable The related controllable.
*/
public function __construct( $type, $option, $controllable ) {
Expand All @@ -64,7 +64,7 @@ public function get_name() {
* @return string Label of the field.
*/
public function get_label() {
$kses = isset( $this->option['label_kses'] ) ? $this->option['label_kses'] : [];
$kses = isset( $this->option['label_kses'] ) ? $this->option['label_kses'] : [];
$label = isset( $this->option['label'] ) ? $this->option['label'] : '';
if ( ! $kses ) {
return esc_html( $label );
Expand Down
19 changes: 12 additions & 7 deletions src/Admin/Section.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ class Section {
/**
* Initializing Tab.
*
* @param string $slug Slug of the tab.
* @param string $title Title for tab.
* @param string $description Description of the tab.
* @param string $slug Slug of the tab.
* @param string $title Title for tab.
* @param string $description Description of the tab.
* @param string|null $type Item type (e.g. comment, trackback).
*/
public function __construct( $slug, $title, $description = '', $type = null ) {
Expand Down Expand Up @@ -189,10 +189,15 @@ public function get_callback() {
* Renders the settings section.
*/
public function render() {
add_settings_section( $this->get_slug(), $this->get_title(), [
$this,
'get_callback'
], SettingsPage::SETTINGS_PAGE_SLUG );
add_settings_section(
$this->get_slug(),
$this->get_title(),
[
$this,
'get_callback',
],
SettingsPage::SETTINGS_PAGE_SLUG
);

foreach ( $this->get_rows() as $row ) {
add_settings_field(
Expand Down
4 changes: 2 additions & 2 deletions src/Admin/SettingsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ public function options_page() {
<li>
<?php if ( $tab->get_slug() === $this->active_tab ) : ?>
<a href="?page=antispam_bee&tab=<?php echo esc_attr( $tab->get_slug() ); ?>"
class="nav-tab nav-tab-active"><?php echo esc_html( $tab->get_title() ); ?></a>
class="nav-tab nav-tab-active"><?php echo esc_html( $tab->get_title() ); ?></a>
<?php else : ?>
<a href="?page=antispam_bee&tab=<?php echo esc_attr( $tab->get_slug() ); ?>"
class="nav-tab"><?php echo esc_html( $tab->get_title() ); ?></a>
class="nav-tab"><?php echo esc_html( $tab->get_title() ); ?></a>
<?php endif; ?>
</li>
<?php endforeach; ?>
Expand Down
4 changes: 2 additions & 2 deletions src/Admin/Tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class Tab {
/**
* Initialize the tab.
*
* @param string $slug Title for tab
* @param string $title Title for tab
* @param string $slug Title for tab
* @param string $title Title for tab
* @param Section[] $sections Sections object array.
*/
public function __construct( $slug, $title, $sections = [] ) {
Expand Down
2 changes: 0 additions & 2 deletions src/GeneralOptions/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public static function get_options() {
*
* @return void
* @since 3.0.0
*
*/
public static function init() {
add_filter( 'antispam_bee_general_options', [ static::class, 'add_general_option' ] );
Expand All @@ -48,7 +47,6 @@ public static function init() {
*
* @return mixed
* @since 3.0.0
*
*/
public static function add_general_option( $options ) {
$options[] = static::class;
Expand Down
2 changes: 1 addition & 1 deletion src/Handlers/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static function process( $comment ) {
/**
* Filter processable comment types.
*
* @param array $types List of comment types
* @param array $types List of comment types
*/
$comment_types = (array) apply_filters( 'antispam_bee_comment_types', [ '', 'comment', 'review' ] );

Expand Down
1 change: 0 additions & 1 deletion src/Handlers/PluginStateChangeHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public static function uninstall() {
self::maybe_remove_antispam_bee_data();
restore_current_blog();
}

}

private static function maybe_remove_antispam_bee_data() {
Expand Down
Loading
Loading