Skip to content

Commit ca09235

Browse files
add phpcs
1 parent 4ad3256 commit ca09235

File tree

9 files changed

+878
-751
lines changed

9 files changed

+878
-751
lines changed

.editorconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ charset = utf-8
1111
end_of_line = lf
1212
insert_final_newline = true
1313
trim_trailing_whitespace = true
14-
indent_style = tab
14+
indent_style = space
15+
indent_size = 4
1516

1617
[*.{yaml,yml}]
1718
indent_style = space

.github/workflows/check-php-syntax.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,8 @@ jobs:
2121

2222
# Lint every PHP source file using PHP interpreter
2323
- run: composer run check-syntax
24+
25+
- run: composer install --no-progress
26+
if: ${{ matrix.php-versions }} == '8.3'
27+
- run: ./vendor/bin/phpcs -ns
28+
if: ${{ matrix.php-versions }} == '8.3'

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,8 @@
1717
},
1818
"scripts": {
1919
"check-syntax": "find . -name '*.php' -not -path './vendor/*' -not -path './node_modules/*' -print0 | xargs -0 -n1 php -l"
20+
},
21+
"require-dev": {
22+
"squizlabs/php_codesniffer": "^3.11"
2023
}
2124
}

composer.lock

Lines changed: 87 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mailchimp-top-bar.php

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -28,50 +28,48 @@
2828
along with this program. If not, see <https://www.gnu.org/licenses/>.
2929
*/
3030

31-
defined( 'ABSPATH' ) or exit;
31+
defined('ABSPATH') or exit;
3232

33-
add_action( 'plugins_loaded', function() {
34-
// check for MailChimp for WordPress (version 3.0 or higher)
35-
if ( !defined( 'MC4WP_VERSION' ) || version_compare( MC4WP_VERSION, '3.0', '<' ) ) {
36-
// Show notice to user
37-
add_action( 'admin_notices', function() {
33+
add_action('plugins_loaded', function () {
34+
// check for MailChimp for WordPress (version 3.0 or higher)
35+
if (!defined('MC4WP_VERSION') || version_compare(MC4WP_VERSION, '3.0', '<')) {
36+
// Show notice to user
37+
add_action('admin_notices', function () {
3838

39-
// only show to user with caps
40-
if( ! current_user_can( 'install_plugins' ) ) {
41-
return;
42-
}
39+
// only show to user with caps
40+
if (! current_user_can('install_plugins')) {
41+
return;
42+
}
4343

44-
add_thickbox();
45-
$url = network_admin_url( 'plugin-install.php?tab=plugin-information&plugin=mailchimp-for-wp&TB_iframe=true&width=600&height=550' );
46-
?>
47-
<div class="notice notice-warning is-dismissible">
48-
<p><?php printf( __( 'Please install or update <a href="%s" class="thickbox">%s</a> in order to use %s.', 'mailchimp-top-bar' ), $url, '<strong>MailChimp for WordPress</strong> (version 3.0 or higher)', 'MailChimp Top Bar' ); ?></p>
49-
</div>
50-
<?php
51-
});
52-
return;
53-
}
44+
add_thickbox();
45+
$url = network_admin_url('plugin-install.php?tab=plugin-information&plugin=mailchimp-for-wp&TB_iframe=true&width=600&height=550');
46+
?>
47+
<div class="notice notice-warning is-dismissible">
48+
<p><?php printf(__('Please install or update <a href="%s" class="thickbox">%s</a> in order to use %s.', 'mailchimp-top-bar'), $url, '<strong>MailChimp for WordPress</strong> (version 3.0 or higher)', 'MailChimp Top Bar'); ?></p>
49+
</div>
50+
<?php
51+
});
52+
return;
53+
}
5454

5555

56-
define('MAILCHIMP_TOP_BAR_FILE', __FILE__);
57-
define('MAILCHIMP_TOP_BAR_DIR', __DIR__);
58-
define('MAILCHIMP_TOP_BAR_VERSION', '1.6.2');
56+
define('MAILCHIMP_TOP_BAR_FILE', __FILE__);
57+
define('MAILCHIMP_TOP_BAR_DIR', __DIR__);
58+
define('MAILCHIMP_TOP_BAR_VERSION', '1.6.2');
5959

60-
require __DIR__ . '/src/functions.php';
60+
require __DIR__ . '/src/functions.php';
6161

62-
if( ! is_admin() ) {
63-
// frontend code
64-
require __DIR__ . '/src/Bar.php';
65-
$bar = new MailChimp\TopBar\Bar();
66-
$bar->add_hooks();
67-
} elseif( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
68-
// ajax code
69-
70-
} else {
71-
// admin code
72-
require __DIR__ . '/src/Admin.php';
73-
$admin = new Mailchimp\TopBar\Admin();
74-
$admin->add_hooks();
75-
}
76-
77-
}, 30 );
62+
if (! is_admin()) {
63+
// frontend code
64+
require __DIR__ . '/src/Bar.php';
65+
$bar = new MailChimp\TopBar\Bar();
66+
$bar->add_hooks();
67+
} elseif (defined('DOING_AJAX') && DOING_AJAX) {
68+
// ajax code
69+
} else {
70+
// admin code
71+
require __DIR__ . '/src/Admin.php';
72+
$admin = new Mailchimp\TopBar\Admin();
73+
$admin->add_hooks();
74+
}
75+
}, 30);

phpcs.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="rules">
3+
<description>rules</description>
4+
<arg name="colors"/>
5+
<file>src/</file>
6+
<file>mailchimp-top-bar.php</file>
7+
<exclude-pattern>*\.(html|css|js)</exclude-pattern>
8+
<rule ref="Generic.Arrays.DisallowLongArraySyntax.Found"/>
9+
<rule ref="PSR12">
10+
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
11+
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />
12+
</rule>
13+
</ruleset>

0 commit comments

Comments
 (0)