Update registration

This commit is contained in:
Mike Jolley 2019-06-19 14:48:11 +01:00
parent bd3828e727
commit 3e3d2f3f85
1 changed files with 2 additions and 2 deletions

View File

@ -28,10 +28,10 @@ $init_callback = include __DIR__ . '/init.php';
* This callback registers this version of the API with WooCommerce. * This callback registers this version of the API with WooCommerce.
*/ */
$register_callback = function() use ( $version, $init_callback ) { $register_callback = function() use ( $version, $init_callback ) {
if ( ! is_callable( array( wc()->api, 'register' ) ) ) { if ( ! class_exists( '\WooCommerce\Core\PackageManager' ) ) {
return; return;
} }
wc()->api->register( $version, $init_callback, __DIR__ ); \WooCommerce\Core\PackageManager::register( 'woocommerce-rest-api', $version, $init_callback, __DIR__ );
}; };
add_action( 'woocommerce_loaded', $register_callback ); add_action( 'woocommerce_loaded', $register_callback );