Updated compat declaration snippet to check for class existence after all plugins are loaded.
parent
48de685c45
commit
7c03873d37
|
@ -191,26 +191,26 @@ function render_xyz_metabox( $post_or_order_object ) {
|
|||
|
||||
## Declaring extension (in)compatibility
|
||||
|
||||
Once you examined the extension's code, you can declare whether it's compatible with HPOS or not. We've prepared an API to make this easy. To declare your extension compatible, use the following code:
|
||||
Once you examined the extension's code, you can declare whether it's compatible with HPOS or not. We've prepared an API to make this easy. To **declare your extension compatible**, use the following code:
|
||||
|
||||
```php
|
||||
|
||||
if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
|
||||
add_action('before_woocommerce_init', function() {
|
||||
add_action('before_woocommerce_init', function() {
|
||||
if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
|
||||
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', 'my-plugin-name/my-plugin-name.php', true);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
If you know your code doesn't support HPOS, you should declare incompatibility in the following way:
|
||||
If you know your code doesn't support HPOS, you should declare **incompatibility** in the following way:
|
||||
```php
|
||||
|
||||
if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
|
||||
add_action('before_woocommerce_init', function() {
|
||||
add_action('before_woocommerce_init', function() {
|
||||
if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
|
||||
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', 'my-plugin-name/my-plugin-name.php', false);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in New Issue