WC_Install::maybe_activate_legacy_api_enabled_optionprivate staticWC 1.0

If in a previous version of WooCommerce the Legacy REST API plugin was installed manually but the core Legacy REST API was kept disabled, now the Legacy API is still disabled and can't be manually enabled from settings UI (the plugin, which is now in control, won't allow that), which is weird and confusing. So we detect this case and explicitly enable it.

Method of the class: WC_Install{}

No Hooks.

Returns

null. Nothing (null).

Usage

$result = WC_Install::maybe_activate_legacy_api_enabled_option();

WC_Install::maybe_activate_legacy_api_enabled_option() code WC 10.8.1

private static function maybe_activate_legacy_api_enabled_option() {
	if ( ! self::is_new_install() && is_plugin_active( 'woocommerce-legacy-rest-api/woocommerce-legacy-rest-api.php' ) && 'yes' !== get_option( 'woocommerce_api_enabled' ) ) {
		update_option( 'woocommerce_api_enabled', 'yes' );
	}
}