Skip to content

Instantly share code, notes, and snippets.

@itthinx
Last active January 4, 2025 14:08
Show Gist options
  • Select an option

  • Save itthinx/d64d87a3f0ebff8d557f6dec15cd8707 to your computer and use it in GitHub Desktop.

Select an option

Save itthinx/d64d87a3f0ebff8d557f6dec15cd8707 to your computer and use it in GitHub Desktop.
Enable the reactify-classic-payments-settings feature available as of WooCommerce 9.6.
<?php
/**
* Plugin Name: WC Enable Reactify Classic Payments Settings
* Description: Enable the reactify-classic-payments-settings feature available as of WooCommerce 9.6.
* Requires Plugins: woocommerce
* WC requires at least: 9.6
*/
if ( !defined( 'ABSPATH' ) ) {
exit;
}
/**
* Plugin class.
*/
class WC_Enable_Reactify_Class_Payments_Settings {
/**
* Enable the reactify-classic-payments-settings feature.
*/
public static function init() {
add_filter( 'woocommerce_admin_get_feature_config', array( __CLASS__, 'woocommerce_admin_get_feature_config' ), PHP_INT_MAX );
// Trying to enable reactify-classic-payments-settings this way has no effect as the feature is not registered
// if ( !\Automattic\WooCommerce\Admin\Features\Features::is_enabled( 'reactify-classic-payments-settings' ) ) {
// \Automattic\WooCommerce\Admin\Features\Features::enable( 'reactify-classic-payments-settings' );
// }
// register_deactivation_hook( __FILE__, array( __CLASS__, 'deactivate' ) );
}
/**
* Filter the features and enable the reactify-classic-payments-settings.
*
* @param array $feature_config
*
* @return boolean
*/
public static function woocommerce_admin_get_feature_config( $feature_config ) {
if ( is_array( $feature_config ) ) {
$feature_config['reactify-classic-payments-settings'] = true;
}
return $feature_config;
}
/**
* Disable feature on deactivation.
*
* @param boolean $network_wide
*/
public static function deactivate( $network_wide = false ) {
if ( \Automattic\WooCommerce\Admin\Features\Features::is_enabled( 'reactify-classic-payments-settings' ) ) {
\Automattic\WooCommerce\Admin\Features\Features::disable( 'reactify-classic-payments-settings' );
}
}
}
add_action( 'init', array( 'WC_Enable_Reactify_Class_Payments_Settings', 'init' ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment