Upgrade to PHPUnit 10, add PHPCS with WPCS compliance, add phpcs CI job
All checks were successful
Create Release Package / PHP Lint (push) Successful in 48s
Create Release Package / PHP CodeSniffer (push) Successful in 52s
Create Release Package / PHP Unit (push) Successful in 53s
Create Release Package / build-release (push) Successful in 59s

- Upgrade PHPUnit 9.6 → 10, update phpunit.xml.dist schema
- Add PHPCS 3.13 with WordPress-Extra + PHPCompatibilityWP standards
- PHPCBF auto-fix + manual fixes for full WPCS compliance
- Add phpcs job to release workflow (parallel with lint)
- Pin composer platform to PHP 8.3 to prevent incompatible dep locks

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-01 13:25:02 +01:00
parent a7d6a57f01
commit dea1b055b2
16 changed files with 2006 additions and 1365 deletions

View File

@@ -17,74 +17,80 @@
* WC tested up to: 10.0
*/
defined('ABSPATH') || exit;
defined( 'ABSPATH' ) || exit;
// Define plugin constants
define('WC_COMPOSABLE_PRODUCT_VERSION', '1.3.1');
define('WC_COMPOSABLE_PRODUCT_FILE', __FILE__);
define('WC_COMPOSABLE_PRODUCT_PATH', plugin_dir_path(__FILE__));
define('WC_COMPOSABLE_PRODUCT_URL', plugin_dir_url(__FILE__));
define('WC_COMPOSABLE_PRODUCT_BASENAME', plugin_basename(__FILE__));
define( 'WC_COMPOSABLE_PRODUCT_VERSION', '1.3.1' );
define( 'WC_COMPOSABLE_PRODUCT_FILE', __FILE__ );
define( 'WC_COMPOSABLE_PRODUCT_PATH', plugin_dir_path( __FILE__ ) );
define( 'WC_COMPOSABLE_PRODUCT_URL', plugin_dir_url( __FILE__ ) );
define( 'WC_COMPOSABLE_PRODUCT_BASENAME', plugin_basename( __FILE__ ) );
// Load Composer autoloader
if (file_exists(WC_COMPOSABLE_PRODUCT_PATH . 'vendor/autoload.php')) {
require_once WC_COMPOSABLE_PRODUCT_PATH . 'vendor/autoload.php';
if ( file_exists( WC_COMPOSABLE_PRODUCT_PATH . 'vendor/autoload.php' ) ) {
require_once WC_COMPOSABLE_PRODUCT_PATH . 'vendor/autoload.php';
}
/**
* Check if WooCommerce is active
*/
function wc_composable_product_check_woocommerce() {
if (!class_exists('WooCommerce')) {
add_action('admin_notices', function() {
?>
<div class="notice notice-error">
<p><?php esc_html_e('WooCommerce Composable Products requires WooCommerce to be installed and active.', 'wc-composable-product'); ?></p>
</div>
<?php
});
return false;
}
return true;
if ( ! class_exists( 'WooCommerce' ) ) {
add_action(
'admin_notices',
function () {
?>
<div class="notice notice-error">
<p><?php esc_html_e( 'WooCommerce Composable Products requires WooCommerce to be installed and active.', 'wc-composable-product' ); ?></p>
</div>
<?php
}
);
return false;
}
return true;
}
/**
* Initialize the plugin
*/
function wc_composable_product_init() {
if (!wc_composable_product_check_woocommerce()) {
return;
}
if ( ! wc_composable_product_check_woocommerce() ) {
return;
}
// Load text domain
load_plugin_textdomain('wc-composable-product', false, dirname(WC_COMPOSABLE_PRODUCT_BASENAME) . '/languages');
// Load text domain
load_plugin_textdomain( 'wc-composable-product', false, dirname( WC_COMPOSABLE_PRODUCT_BASENAME ) . '/languages' );
// Initialize main plugin class
Magdev\WcComposableProduct\Plugin::instance();
// Initialize main plugin class
Magdev\WcComposableProduct\Plugin::instance();
}
// Use woocommerce_init to ensure all WooCommerce classes including settings are loaded
add_action('woocommerce_init', 'wc_composable_product_init');
add_action( 'woocommerce_init', 'wc_composable_product_init' );
/**
* Declare HPOS compatibility
*/
add_action('before_woocommerce_init', function() {
if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true);
}
});
add_action(
'before_woocommerce_init',
function () {
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
}
}
);
/**
* Activation hook
*/
function wc_composable_product_activate() {
if (!class_exists('WooCommerce')) {
deactivate_plugins(WC_COMPOSABLE_PRODUCT_BASENAME);
wp_die(
esc_html__('This plugin requires WooCommerce to be installed and active.', 'wc-composable-product'),
esc_html__('Plugin Activation Error', 'wc-composable-product'),
array('back_link' => true)
);
}
if ( ! class_exists( 'WooCommerce' ) ) {
deactivate_plugins( WC_COMPOSABLE_PRODUCT_BASENAME );
wp_die(
esc_html__( 'This plugin requires WooCommerce to be installed and active.', 'wc-composable-product' ),
esc_html__( 'Plugin Activation Error', 'wc-composable-product' ),
array( 'back_link' => true )
);
}
}
register_activation_hook(__FILE__, 'wc_composable_product_activate');
register_activation_hook( __FILE__, 'wc_composable_product_activate' );