Skip to content

Commit bc67543

Browse files
committed
Add .distignore, update composer.json to require PHP 7.4, introduce coding standards configuration with phpcs.xml and grumphp.yml. Remove obsolete phpcs.xml.dist and update psalm.xml to target main plugin file. Add readme.txt for plugin documentation.
1 parent 0797d6c commit bc67543

File tree

8 files changed

+296
-66
lines changed

8 files changed

+296
-66
lines changed

.distignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/.git
2+
/.github
3+
/.wordpress-org
4+
/config
5+
/node_modules
6+
/src
7+
/tests
8+
9+
.distignore
10+
.gitattributes
11+
.gitignore
12+
.nvmrc
13+
.plugin-data
14+
.wp-env.json
15+
CHANGELOG.md
16+
composer.json
17+
composer.lock
18+
grumphp.yml
19+
LICENSE.md
20+
package.json
21+
package-lock.json
22+
phpcs.xml
23+
phpcs.xml.dist
24+
phpunit.xml.dist
25+
psalm.xml
26+
README.md
27+
webpack.config.js

composer.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"source": "https://github.com/BeAPI/disable-comments"
2626
},
2727
"require": {
28-
"php": ">=8.1",
28+
"php": ">=7.4",
2929
"composer/installers": "^1.0 || ^2.0"
3030
},
3131
"require-dev": {
@@ -38,11 +38,6 @@
3838
"vimeo/psalm": "^5.25",
3939
"wp-coding-standards/wpcs": "^3.1"
4040
},
41-
"autoload": {
42-
"files": [
43-
"disable-comments.php"
44-
]
45-
},
4641
"config": {
4742
"allow-plugins": {
4843
"composer/installers": true,

disable-comments.php

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function init() {
8181
add_filter( 'rest_endpoints', __NAMESPACE__ . '\\filter_rest_endpoints' );
8282

8383
// Disable inserting comments via REST API.
84-
add_filter( 'rest_pre_insert_comment', __NAMESPACE__ . '\\disable_rest_api_comments', 10, 2 );
84+
add_filter( 'rest_pre_insert_comment', __NAMESPACE__ . '\\__return_null', 10, 2 );
8585

8686
// Disable Gutenberg comments blocks.
8787
add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\\disable_comments_blocks' );
@@ -309,19 +309,6 @@ function filter_rest_endpoints( $endpoints ) {
309309
return $endpoints;
310310
}
311311

312-
/**
313-
* Disable inserting comments via REST API.
314-
*
315-
* @since 1.0.0
316-
*
317-
* @param array $prepared_comment The prepared comment data.
318-
* @param \WP_REST_Request $request The REST request object.
319-
* @return null
320-
*/
321-
function disable_rest_api_comments( $prepared_comment, $request ) {
322-
return null;
323-
}
324-
325312
/**
326313
* Disable Gutenberg comments blocks.
327314
* Enqueues JavaScript to unregister all comment-related blocks from the block editor.
@@ -342,4 +329,3 @@ function disable_comments_blocks() {
342329

343330
// Initialize the plugin.
344331
init();
345-

grumphp.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# grumphp.yml
2+
grumphp:
3+
tasks:
4+
git_blacklist:
5+
keywords:
6+
- "var_dump("
7+
- "<<<<<<< HEAD"
8+
whitelist_patterns: []
9+
triggered_by: ['php']
10+
regexp_type: G
11+
phplint:
12+
exclude: ['vendor']
13+
jobs: ~
14+
triggered_by: ['php', 'phtml', 'php3', 'php4', 'php5', 'php7']
15+
phpcs:
16+
standard: ['phpcs.xml.dist']
17+
triggered_by: [php]
18+
composer:
19+
no_check_all: true
20+
no_check_publish: true
21+
no_local_repository: true
22+
jsonlint:
23+
ignore_patterns: []
24+
detect_key_conflicts: false
25+
psalm:
26+
config: psalm.xml
27+
triggered_by: ['php']
28+
show_info: true
29+
testsuites: []
30+
extensions: []

phpcs.xml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="disable-comments">
3+
<description>Coding Standards for disable-comments plugin</description>
4+
5+
<!-- Scan all files in directory -->
6+
<file>.</file>
7+
8+
<!-- Scan only PHP files -->
9+
<arg name="extensions" value="php"/>
10+
11+
<!-- Ignore Composer dependencies -->
12+
<exclude-pattern>languages/</exclude-pattern>
13+
<exclude-pattern>vendor/</exclude-pattern>
14+
<exclude-pattern>tests/</exclude-pattern>
15+
<exclude-pattern>.ddev/</exclude-pattern>
16+
<exclude-pattern>.git/</exclude-pattern>
17+
<exclude-pattern>.github/</exclude-pattern>
18+
<exclude-pattern>.wordpress-org/</exclude-pattern>
19+
<exclude-pattern>config/</exclude-pattern>
20+
<exclude-pattern>node_modules/</exclude-pattern>
21+
<exclude-pattern>src/</exclude-pattern>
22+
<exclude-pattern>tests/</exclude-pattern>
23+
<exclude-pattern>wp-env.json</exclude-pattern>
24+
25+
<!-- Show colors in console -->
26+
<arg value="-colors"/>
27+
28+
<!-- Show sniff codes in all reports -->
29+
<arg value="ns"/>
30+
31+
<!-- Show progress. -->
32+
<arg value="p"/>
33+
34+
<!-- Set ini. -->
35+
<ini name="memory_limit" value="512M"/>
36+
<ini name="max_execution_time" value="-1"/>
37+
38+
<!-- Use WordPress Extra as a base -->
39+
<rule ref="WordPress-Extra">
40+
<!-- Exclude as we use a custom autoloader. -->
41+
<exclude name="WordPress.Files.FileName"/>
42+
43+
<!-- Exclude as it conflict with @var declaration. -->
44+
<exclude name="Squiz.PHP.CommentedOutCode"/>
45+
46+
<!-- Exclude as we use custom naming for our class. -->
47+
<exclude name="WordPress.Files.FileName.InvalidClassFileName"/>
48+
49+
<!-- Exclude as we use the short array syntax over the long one. -->
50+
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
51+
</rule>
52+
<config name="minimum_supported_wp_version" value="5.0"/>
53+
54+
<rule ref="PHPCompatibilityWP"/>
55+
<config name="testVersion" value="7.4-"/>
56+
57+
58+
<rule ref="WordPress.Security.ValidatedSanitizedInput">
59+
<properties>
60+
<property name="customSanitizingFunctions" type="array">
61+
<element value="wc_clean"/>
62+
<element value="wc_sanitize_tooltip"/>
63+
<element value="wc_format_decimal"/>
64+
<element value="wc_stock_amount"/>
65+
<element value="wc_sanitize_permalink"/>
66+
<element value="wc_sanitize_textarea"/>
67+
</property>
68+
</properties>
69+
</rule>
70+
71+
<rule ref="WordPress.Security.EscapeOutput">
72+
<properties>
73+
<property name="customEscapingFunctions" type="array">
74+
<element value="wc_help_tip"/>
75+
<element value="wc_sanitize_tooltip"/>
76+
<element value="wc_selected"/>
77+
<element value="wc_kses_notice"/>
78+
<element value="wc_esc_json"/>
79+
<element value="wc_query_string_form_fields"/>
80+
<element value="wc_make_phone_clickable"/>
81+
</property>
82+
</properties>
83+
</rule>
84+
85+
<rule ref="WordPress.WP.I18n">
86+
<properties>
87+
<property name="text_domain" type="array">
88+
<element value="disable-comments"/>
89+
</property>
90+
</properties>
91+
</rule>
92+
<rule ref="WordPress.WhiteSpace.ControlStructureSpacing">
93+
<properties>
94+
<property name="blank_line_check" value="true"/>
95+
</properties>
96+
</rule>
97+
</ruleset>

phpcs.xml.dist

Lines changed: 0 additions & 44 deletions
This file was deleted.

psalm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
77
>
88
<projectFiles>
9-
<directory name="." />
9+
<file name="disable-comments.php"/>
1010
</projectFiles>
1111

1212
<issueHandlers>

0 commit comments

Comments
 (0)