From ffec1b831b89ac1d7dd41764b7d620c963dd6f08 Mon Sep 17 00:00:00 2001 From: Jason Date: Wed, 7 Oct 2026 11:20:52 -0700 Subject: [PATCH 01/11] build: :arrow_up: Update the PHPCS toolchain past its advisories composer audit flagged high-severity advisories in squizlabs/ php_codesniffer, phpcsstandards/phpcsutils and wp-coding-standards/wpcs. All three are dev-only and never shipped in the release zip, but they run on every lint, locally and soon in CI. Lock-only update within the existing constraints: WPCS 3.4.1, PHP_CodeSniffer 3.13.6, PHPCSUtils 1.2.3. composer audit is now clean. Refs #14 Co-Authored-By: Claude Opus 5.5 (1M context) --- composer.lock | 136 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 81 insertions(+), 55 deletions(-) diff --git a/composer.lock b/composer.lock index 8acf70d..893d0e7 100644 --- a/composer.lock +++ b/composer.lock @@ -60,29 +60,29 @@ "packages-dev": [ { "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v1.0.0", + "version": "v1.2.1", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/composer-installer.git", - "reference": "4be43904336affa5c2f70744a348312336afd0da" + "reference": "963f0c67bffde0eac41b56be71ac0e8ba132f0bd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/4be43904336affa5c2f70744a348312336afd0da", - "reference": "4be43904336affa5c2f70744a348312336afd0da", + "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/963f0c67bffde0eac41b56be71ac0e8ba132f0bd", + "reference": "963f0c67bffde0eac41b56be71ac0e8ba132f0bd", "shasum": "" }, "require": { - "composer-plugin-api": "^1.0 || ^2.0", + "composer-plugin-api": "^2.2", "php": ">=5.4", - "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" + "squizlabs/php_codesniffer": "^3.1.0 || ^4.0" }, "require-dev": { - "composer/composer": "*", + "composer/composer": "^2.2", "ext-json": "*", "ext-zip": "*", - "php-parallel-lint/php-parallel-lint": "^1.3.1", - "phpcompatibility/php-compatibility": "^9.0", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcompatibility/php-compatibility": "^9.0 || ^10.0.0@dev", "yoast/phpunit-polyfills": "^1.0" }, "type": "composer-plugin", @@ -101,9 +101,9 @@ "authors": [ { "name": "Franck Nijhof", - "email": "franck.nijhof@dealerdirect.com", - "homepage": "http://www.frenck.nl", - "role": "Developer / IT Manager" + "email": "opensource@frenck.dev", + "homepage": "https://frenck.dev", + "role": "Open source developer" }, { "name": "Contributors", @@ -111,7 +111,6 @@ } ], "description": "PHP_CodeSniffer Standards Composer Installer Plugin", - "homepage": "http://www.dealerdirect.com", "keywords": [ "PHPCodeSniffer", "PHP_CodeSniffer", @@ -132,9 +131,28 @@ ], "support": { "issues": "https://github.com/PHPCSStandards/composer-installer/issues", + "security": "https://github.com/PHPCSStandards/composer-installer/security/policy", "source": "https://github.com/PHPCSStandards/composer-installer" }, - "time": "2023-01-05T11:28:13+00:00" + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2026-05-06T08:26:05+00:00" }, { "name": "myclabs/deep-copy", @@ -373,29 +391,29 @@ }, { "name": "phpcsstandards/phpcsextra", - "version": "1.2.1", + "version": "1.5.1", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHPCSExtra.git", - "reference": "11d387c6642b6e4acaf0bd9bf5203b8cca1ec489" + "reference": "39467533fdb742446d68c1d10ac33d625ee0311c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/11d387c6642b6e4acaf0bd9bf5203b8cca1ec489", - "reference": "11d387c6642b6e4acaf0bd9bf5203b8cca1ec489", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/39467533fdb742446d68c1d10ac33d625ee0311c", + "reference": "39467533fdb742446d68c1d10ac33d625ee0311c", "shasum": "" }, "require": { "php": ">=5.4", - "phpcsstandards/phpcsutils": "^1.0.9", - "squizlabs/php_codesniffer": "^3.8.0" + "phpcsstandards/phpcsutils": "^1.2.3", + "squizlabs/php_codesniffer": "^3.13.5 || ^4.0.1" }, "require-dev": { "php-parallel-lint/php-console-highlighter": "^1.0", - "php-parallel-lint/php-parallel-lint": "^1.3.2", - "phpcsstandards/phpcsdevcs": "^1.1.6", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcsstandards/phpcsdevcs": "^1.2.0", "phpcsstandards/phpcsdevtools": "^1.2.1", - "phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" }, "type": "phpcodesniffer-standard", "extra": { @@ -445,35 +463,39 @@ { "url": "https://opencollective.com/php_codesniffer", "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" } ], - "time": "2023-12-08T16:49:07+00:00" + "time": "2026-07-27T11:13:17+00:00" }, { "name": "phpcsstandards/phpcsutils", - "version": "1.0.12", + "version": "1.2.3", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", - "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c" + "reference": "5f35d9408c54d7b529501f3c688b6eae562aea1f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/87b233b00daf83fb70f40c9a28692be017ea7c6c", - "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/5f35d9408c54d7b529501f3c688b6eae562aea1f", + "reference": "5f35d9408c54d7b529501f3c688b6eae562aea1f", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", "php": ">=5.4", - "squizlabs/php_codesniffer": "^3.10.0 || 4.0.x-dev@dev" + "squizlabs/php_codesniffer": "^3.13.5 || ^4.0.1" }, "require-dev": { "ext-filter": "*", "php-parallel-lint/php-console-highlighter": "^1.0", - "php-parallel-lint/php-parallel-lint": "^1.3.2", - "phpcsstandards/phpcsdevcs": "^1.1.6", - "yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0" + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcsstandards/phpcsdevcs": "^1.2.0", + "yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0 || ^3.0.0" }, "type": "phpcodesniffer-standard", "extra": { @@ -510,6 +532,7 @@ "phpcodesniffer-standard", "phpcs", "phpcs3", + "phpcs4", "standards", "static analysis", "tokens", @@ -533,9 +556,13 @@ { "url": "https://opencollective.com/php_codesniffer", "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" } ], - "time": "2024-05-20T13:34:27+00:00" + "time": "2026-07-27T10:28:41+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1919,16 +1946,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.11.2", + "version": "3.13.6", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "1368f4a58c3c52114b86b1abe8f4098869cb0079" + "reference": "4c378e1a528ea066890fc2397cbdd2f94eb2fc91" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/1368f4a58c3c52114b86b1abe8f4098869cb0079", - "reference": "1368f4a58c3c52114b86b1abe8f4098869cb0079", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/4c378e1a528ea066890fc2397cbdd2f94eb2fc91", + "reference": "4c378e1a528ea066890fc2397cbdd2f94eb2fc91", "shasum": "" }, "require": { @@ -1945,11 +1972,6 @@ "bin/phpcs" ], "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } - }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" @@ -1993,9 +2015,13 @@ { "url": "https://opencollective.com/php_codesniffer", "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" } ], - "time": "2024-12-11T16:04:26+00:00" + "time": "2026-08-06T00:17:32+00:00" }, { "name": "staabm/side-effects-detector", @@ -2101,16 +2127,16 @@ }, { "name": "wp-coding-standards/wpcs", - "version": "3.1.0", + "version": "3.4.1", "source": { "type": "git", "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", - "reference": "9333efcbff231f10dfd9c56bb7b65818b4733ca7" + "reference": "ec2ff942335f33683a5957a85d138753876a05cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/9333efcbff231f10dfd9c56bb7b65818b4733ca7", - "reference": "9333efcbff231f10dfd9c56bb7b65818b4733ca7", + "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/ec2ff942335f33683a5957a85d138753876a05cf", + "reference": "ec2ff942335f33683a5957a85d138753876a05cf", "shasum": "" }, "require": { @@ -2118,17 +2144,17 @@ "ext-libxml": "*", "ext-tokenizer": "*", "ext-xmlreader": "*", - "php": ">=5.4", - "phpcsstandards/phpcsextra": "^1.2.1", - "phpcsstandards/phpcsutils": "^1.0.10", - "squizlabs/php_codesniffer": "^3.9.0" + "php": ">=7.2", + "phpcsstandards/phpcsextra": "^1.5.1", + "phpcsstandards/phpcsutils": "^1.2.3", + "squizlabs/php_codesniffer": "^3.13.5" }, "require-dev": { "php-parallel-lint/php-console-highlighter": "^1.0.0", - "php-parallel-lint/php-parallel-lint": "^1.3.2", - "phpcompatibility/php-compatibility": "^9.0", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcompatibility/php-compatibility": "^10.0.0@dev", "phpcsstandards/phpcsdevtools": "^1.2.0", - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^8.0 || ^9.0" }, "suggest": { "ext-iconv": "For improved results", @@ -2163,7 +2189,7 @@ "type": "custom" } ], - "time": "2024-03-25T16:39:00+00:00" + "time": "2026-07-27T11:53:23+00:00" } ], "aliases": [], From 5c1a4428ad191f15f8fd7a3aaec3927749860549 Mon Sep 17 00:00:00 2001 From: Jason Date: Wed, 7 Oct 2026 11:22:16 -0700 Subject: [PATCH 02/11] build: :wrench: Add a PHPCS ruleset so composer lint works composer lint ran bare phpcs with no ruleset and no path, so it exited 3 without checking anything. phpcs.xml.dist selects the WordPress standard, the jc prefix and the jc-core-functionality text domain, and excludes vendor/, node_modules/ and tests/ (the PHPUnit bootstrap stubs core functions by their real, unprefixed names). Only the prefix-length check is disabled: renaming every function and the public jc_csp_* filters to satisfy a 3-character minimum would break existing hooks. Declares Requires at least 6.5 (block bindings, Requires Plugins and script modules all need it) and Requires PHP 8.0 (the live server), so WordPress refuses to activate on anything older and the ruleset's minimum_wp_version has a source. lint and lint-fix now resolve phpcs and phpcbf from vendor/bin through Composer. Refs #14 Co-Authored-By: Claude Opus 5.5 (1M context) --- composer.json | 4 ++-- phpcs.xml.dist | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ plugin.php | 4 ++++ 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 phpcs.xml.dist diff --git a/composer.json b/composer.json index 9f8255c..39d4ac7 100644 --- a/composer.json +++ b/composer.json @@ -15,8 +15,8 @@ "phpunit/phpunit": "^12" }, "scripts": { - "lint": "./vendor/bin/phpcs", - "lint-fix": "./vendor/bin/phpcbf --extensions=php .", + "lint": "phpcs", + "lint-fix": "phpcbf", "test": "phpunit" }, "config": { diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..1f180c9 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,53 @@ + + + WordPress Coding Standards for the jc-core-functionality plugin. + + + . + + /vendor/* + /node_modules/* + + /tests/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugin.php b/plugin.php index ea4fdaa..809df0e 100644 --- a/plugin.php +++ b/plugin.php @@ -9,7 +9,11 @@ * License: GPL-2.0-or-later * License URI: https://www.gnu.org/licenses/gpl-2.0.html * Text Domain: jc-core-functionality + * Requires at least: 6.5 + * Requires PHP: 8.0 * Requires Plugins: advanced-custom-fields-pro + * + * @package jc_Custom_Functionality */ // Block direct access. From 78a8b921c1bf0af806352f0a81b3026eb7b20e6f Mon Sep 17 00:00:00 2001 From: Jason Date: Wed, 7 Oct 2026 11:22:17 -0700 Subject: [PATCH 03/11] style: :rotating_light: Clear the remaining PHPCS errors The 23 errors left after the phpcbf pass needed judgment rather than auto-fixing: function docblocks with @param/@return, sentence-case inline comments, $quoteTitle -> $quote_title, and the plugin header's @package tag. jc_add_json_save_point() drops its unused $path parameter; WordPress still passes it, and PHP ignores extra arguments to userland callbacks. Hook registrations move below the functions they register, which is where WPCS expects them; they still run at file load, so behavior is unchanged. composer lint now exits 0. Refs #14 Co-Authored-By: Claude Opus 5.5 (1M context) --- lib/functions/general.php | 48 +++++++++++++++++++++++++----------- lib/functions/gtm.php | 3 +++ lib/functions/settings.php | 14 ++++++++--- lib/functions/shortcodes.php | 13 +++++++--- plugin.php | 9 ++++--- 5 files changed, 61 insertions(+), 26 deletions(-) diff --git a/lib/functions/general.php b/lib/functions/general.php index d9182ba..4d1ef01 100644 --- a/lib/functions/general.php +++ b/lib/functions/general.php @@ -18,7 +18,10 @@ } /** - * Add new load point for JSON + * Load ACF JSON (field groups, post types) from the plugin. + * + * @param string[] $paths ACF JSON load paths. + * @return string[] */ function jc_add_json_load_point( $paths ) { // Remove the original path (optional). @@ -32,17 +35,22 @@ function jc_add_json_load_point( $paths ) { add_filter( 'acf/settings/load_json', 'jc_add_json_load_point' ); /** - * Add new save point for JSON + * Save ACF JSON edits into the plugin, so they ship with it. + * + * WordPress passes the current save path; it is replaced, not used. + * + * @return string */ -function jc_add_json_save_point( $path ) { +function jc_add_json_save_point() { return JC_DIR . '/acf-json'; } add_filter( 'acf/settings/save_json', 'jc_add_json_save_point' ); -// Register Meta Fields - -add_action( 'init', 'jc_acf_register_meta' ); - +/** + * Register ACF-backed post meta so it is readable through the REST API. + * + * @return void + */ function jc_acf_register_meta() { $terms = array( 'subtitle' ); @@ -59,13 +67,13 @@ function jc_acf_register_meta() { ); } } +add_action( 'init', 'jc_acf_register_meta' ); - -// Register Custom Block Binding Source - -// Copyright -add_action( 'init', 'jc_register_block_bindings' ); - +/** + * Register the plugin's block bindings sources. + * + * @return void + */ function jc_register_block_bindings() { register_block_bindings_source( 'jc/copyright', @@ -82,13 +90,23 @@ function jc_register_block_bindings() { ) ); } +add_action( 'init', 'jc_register_block_bindings' ); -// Copyright callback +/** + * Value for the jc/copyright binding. + * + * @return string "© " in the site's timezone. + */ function jc_copyright_binding() { return '© ' . wp_date( 'Y' ); } -// User Data callback +/** + * Value for the jc/user-data binding. + * + * @param array $source_args Binding args: `key` (name, description or avatar) and `userId`. + * @return string|null Null when the args are missing or invalid. + */ function jc_user_data_bindings( $source_args ) { // If no key or user ID argument is set, bail early. if ( ! isset( $source_args['key'] ) || ! isset( $source_args['userId'] ) ) { diff --git a/lib/functions/gtm.php b/lib/functions/gtm.php index 59c5094..bbad6d6 100644 --- a/lib/functions/gtm.php +++ b/lib/functions/gtm.php @@ -40,6 +40,9 @@ function jc_google_tag_manager_head() { echo "\n"; } +/** + * Print the GTM