Skip to content
This repository was archived by the owner on Jun 17, 2025. It is now read-only.

Commit 91bfbbe

Browse files
authored
Update linting, add GitHub action and fix linting errors (#3)
1 parent a7fe078 commit 91bfbbe

23 files changed

+613
-164
lines changed

.github/workflows/code-linting.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Code Linting - PHP
2+
3+
on:
4+
pull_request:
5+
branches: [trunk]
6+
push:
7+
branches: [trunk]
8+
9+
jobs:
10+
phpcs_check:
11+
name: PHPCS check
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
16+
- name: Setup PHP
17+
uses: shivammathur/setup-php@a7f90656b3be3996d1ec5501e8e25d5d35aa9bb2 # v2.15.0
18+
with:
19+
php-version: 7.4
20+
- name: Get composer cache directory
21+
id: composer-cache
22+
run: |
23+
echo "::set-output name=dir::$(composer config cache-files-dir)"
24+
- name: Cache composer dependencies
25+
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6
26+
with:
27+
path: ${{ steps.composer-cache.outputs.dir }}
28+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
29+
restore-keys: |
30+
${{ runner.os }}-composer-
31+
- name: Install composer packages
32+
run: composer install --no-progress
33+
- name: Check PHP coding standards using PHPCS
34+
run: composer lint -- --runtime-set ignore_warnings_on_exit true --runtime-set testVersion 5.8-

block-pattern-explorer.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
*
1515
* @package Block Pattern Explorer
1616
*/
17+
1718
namespace BlockPatternExplorer;
1819

1920
defined( 'ABSPATH' ) || exit;
2021

2122
define( 'BPE_ABSPATH', dirname( __FILE__ ) . '/' );
22-
define( 'BPE_VERSION', get_file_data( __FILE__, [ 'Version' ] )[0] );
23+
define( 'BPE_VERSION', get_file_data( __FILE__, [ 'Version' ] )[0] ); // phpcs:ignore
2324
define( 'BPE_PLUGIN_DIR_URL', plugin_dir_url( __FILE__ ) );
2425

2526
/**
@@ -65,7 +66,7 @@ function get_asset_file( $filepath ) {
6566
$asset_path = BPE_ABSPATH . $filepath . '.asset.php';
6667

6768
return file_exists( $asset_path )
68-
? include $asset_path
69+
? require_once $asset_path
6970
: array(
7071
'dependencies' => array(),
7172
'version' => BPE_VERSION,
@@ -99,7 +100,7 @@ function enqueue_script_translations() {
99100
add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\enqueue_script_translations' );
100101

101102
// Custom pattern category type implementation.
102-
include_once BPE_ABSPATH . '/includes/custom/add-pattern-category-type-support.php';
103+
require_once BPE_ABSPATH . '/includes/add-pattern-category-type-support.php';
103104

104105
// (Experimental) Will be used once Block Editor settings are filterable in core.
105-
//include_once BPE_ABSPATH . '/includes/core/add-pattern-category-type-support.php';
106+
// include_once BPE_ABSPATH . '/includes/core/add-pattern-category-type-support.php';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('lodash', 'wp-a11y', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-notices', 'wp-primitives'), 'version' => '92e92240fc3ee8aebe874be25d25f2b1');
1+
<?php return array('dependencies' => array('lodash', 'wp-a11y', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-primitives'), 'version' => '6e96279ccef5c66a8125afa3f907e9d0');

build/block-pattern-explorer-editor.js

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

build/style-block-pattern-explorer-editor-styles.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

composer.json

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
{
2-
"name": "block-pattern-explorer",
3-
"description": "An experimental plugin to preview and insert block patterns in the Block Editor.",
4-
"type": "wordpress-plugin",
5-
"license": "GPL-2.0-or-later",
6-
"require": {},
7-
"require-dev": {
8-
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
9-
"squizlabs/php_codesniffer": "^3.4.2",
10-
"phpcompatibility/php-compatibility": "^9.2.0",
11-
"phpcompatibility/phpcompatibility-wp": "^2.1",
12-
"wp-coding-standards/wpcs": "^2.1.1"
13-
},
14-
"scripts": {
15-
"lint": "@php ./vendor/bin/phpcs",
16-
"lint-fix": "@php ./vendor/bin/phpcbf"
17-
}
2+
"name": "wpengine/block-pattern-explorer",
3+
"type": "wordpress-plugin",
4+
"description": "An experimental plugin to preview and insert block patterns in the Block Editor.",
5+
"homepage": "https://github.com/wpengine/block-pattern-explorer",
6+
"license": "GPL-2.0-or-later",
7+
"require": {
8+
"php": ">=5.6"
9+
},
10+
"require-dev": {
11+
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
12+
"squizlabs/php_codesniffer": "^3.4.2",
13+
"phpcompatibility/php-compatibility": "^9.2.0",
14+
"phpcompatibility/phpcompatibility-wp": "^2.1",
15+
"wp-coding-standards/wpcs": "^2.1.1"
16+
},
17+
"scripts": {
18+
"lint": "@php ./vendor/bin/phpcs",
19+
"lint-fix": "@php ./vendor/bin/phpcbf"
20+
},
21+
"config": {
22+
"allow-plugins": {
23+
"dealerdirect/phpcodesniffer-composer-installer": true
24+
}
25+
}
1826
}

0 commit comments

Comments
 (0)