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

[CMSP-664] Update linting for latest Pantheon WP Coding Standards #131

Merged
merged 6 commits into from
Sep 12, 2023
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
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The `master` branch matches the latest stable release deployed to [wp.org](wp.or

You may notice there are three sets of tests running:

* [PHPCS](https://github.com/squizlabs/PHP_CodeSniffer) to detect violations of `wp-coding-standards/wpcs` coding standards.
* [PHPCS](https://github.com/squizlabs/PHP_CodeSniffer) to detect violations of [Pantheon WP Coding Standards](https://github.com/pantheon-systems/Pantheon-WP-Coding-Standards).
* [PHPUnit](https://phpunit.de/) test suite.
* [Behat](http://behat.org/) test suite against a Pantheon site, to ensure the plugin's compatibility with the Pantheon platform.

Expand Down Expand Up @@ -54,4 +54,4 @@ Note that dependencies are installed via Composer and the `vendor` directory is
* Add a new `** Latest **` heading to the changelog
* `git add -A .`
* `git commit -m "Prepare X.Y.X-dev"`
* `git push origin develop`
* `git push origin develop`
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ By default, the Pantheon HUD appears for logged-in users with the `manage_option
## Changelog ##
### 0.4.4-dev ###
* Update CONTRIBUTING.md [[#123](https://github.com/pantheon-systems/pantheon-hud/pull/123)]
* Added "environment-indicator" to tags [[#]()]
* Added "environment-indicator" to tags [[#128](https://github.com/pantheon-systems/pantheon-hud/pull/128)]
* Updates Pantheon WP Coding Standards to 2.0 [[#131](https://github.com/pantheon-systems/pantheon-hud/pull/131)]

### 0.4.3 (April 6, 2023) ###
* Update Composer dependencies [[#116](https://github.com/pantheon-systems/pantheon-hud/pull/116)] [[#118](https://github.com/pantheon-systems/pantheon-hud/pull/118)]
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"require-dev": {
"pantheon-systems/pantheon-wordpress-upstream-tests": "dev-master",
"pantheon-systems/pantheon-wp-coding-standards": "^1.0.0",
"pantheon-systems/pantheon-wp-coding-standards": "^2.0",
"phpunit/phpunit": "^9",
"yoast/phpunit-polyfills": "^2.0",
"symfony/yaml": "^5.4 || ^6"
Expand Down
492 changes: 318 additions & 174 deletions composer.lock

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions inc/class-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ private function fetch_api_data( $url ) {

// For those developing locally who know what they're doing.
} elseif ( $pem_file || ( defined( 'PANTHEON_HUD_PHPUNIT_RUNNING' ) && PANTHEON_HUD_PHPUNIT_RUNNING ) ) {
$require_curl = function() {
$require_curl = function () {
return [ 'curl' ];
};
add_filter( 'http_api_transports', $require_curl );
$client_cert = function( $handle ) use ( $pem_file ) {
$client_cert = function ( $handle ) use ( $pem_file ) {
curl_setopt( $handle, CURLOPT_SSLCERT, $pem_file ); // phpcs:ignore WordPress.WP.AlternativeFunctions
};
add_action( 'http_api_curl', $client_cert );
Expand All @@ -197,5 +197,4 @@ private function fetch_api_data( $url ) {
}
return [];
}

}
3 changes: 1 addition & 2 deletions inc/class-toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function add_admin_bar_inline_styles() {
wp_add_inline_script( 'admin-bar', $script );
add_filter(
'amp_dev_mode_element_xpaths',
static function( $xpaths ) {
static function ( $xpaths ) {
$xpaths[] = '//script[ contains( text(), "wp-admin-bar-pantheon-hud" ) ]';
return $xpaths;
}
Expand Down Expand Up @@ -239,5 +239,4 @@ static function( $xpaths ) {
private function get_environment() {
return ! empty( $_ENV['PANTHEON_ENVIRONMENT'] ) ? $_ENV['PANTHEON_ENVIRONMENT'] : 'local';
}

}
4 changes: 2 additions & 2 deletions pantheon-hud.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

add_action(
'init',
function() {
function () {
$view_pantheon_hud = apply_filters( 'pantheon_hud_current_user_can_view', current_user_can( 'manage_options' ) );
if ( $view_pantheon_hud ) {
Pantheon\HUD\Toolbar::get_instance();
Expand All @@ -25,7 +25,7 @@ function() {
);

spl_autoload_register(
function( $pantheon_class ) {
function ( $pantheon_class ) {
$class = ltrim( $pantheon_class, '\\' );
if ( 0 !== stripos( $class, 'Pantheon\HUD\\' ) ) {
return;
Expand Down
8 changes: 7 additions & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards for Plugins">
<ruleset name="Pantheon WP Coding Standards">
<description>Generally-applicable sniffs for WordPress plugins</description>

<!-- Check all PHP files in directory tree by default. -->
Expand All @@ -22,4 +22,10 @@
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>

<!-- Allow $_ENV['PANTHEON_*'] variables to be unsanitized as they are trusted from the Pantheon platform. -->
<rule ref="WordPress.Security.ValidatedSanitizedInput.InputNotSanitized">
<exclude-pattern>*/inc/class-api.php</exclude-pattern>
<exclude-pattern>*/inc/class-toolbar.php</exclude-pattern>
</rule>
</ruleset>
3 changes: 2 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ By default, the Pantheon HUD appears for logged-in users with the `manage_option
== Changelog ==
= 0.4.4-dev =
* Update CONTRIBUTING.md [[#123](https://github.com/pantheon-systems/pantheon-hud/pull/123)]
* Added "environment-indicator" to tags [[#]()]
* Added "environment-indicator" to tags [[#128](https://github.com/pantheon-systems/pantheon-hud/pull/128)]
* Updates Pantheon WP Coding Standards to 2.0 [[#131](https://github.com/pantheon-systems/pantheon-hud/pull/131)]

= 0.4.3 (April 6, 2023) =
* Update Composer dependencies [[#116](https://github.com/pantheon-systems/pantheon-hud/pull/116)] [[#118](https://github.com/pantheon-systems/pantheon-hud/pull/118)]
Expand Down