AgenticController.php
4 months ago
AgenticWebhookManager.php
7 months ago
AgenticWebhookPayloadBuilder.php
7 months ago
AgenticController.php
51 lines
| 1 | <?php |
| 2 | declare(strict_types=1); |
| 3 | |
| 4 | namespace Automattic\WooCommerce\Internal\Admin\Agentic; |
| 5 | |
| 6 | use Automattic\Jetpack\Constants; |
| 7 | use Automattic\WooCommerce\Internal\RegisterHooksInterface; |
| 8 | use Automattic\WooCommerce\Utilities\FeaturesUtil; |
| 9 | |
| 10 | /** |
| 11 | * AgenticController class |
| 12 | * |
| 13 | * Main controller for Agentic Commerce Protocol features. |
| 14 | * Manages initialization of webhooks and future settings for the Agentic feature. |
| 15 | * |
| 16 | * @since 10.3.0 |
| 17 | */ |
| 18 | class AgenticController implements RegisterHooksInterface { |
| 19 | /** |
| 20 | * Register this class instance to the appropriate hooks. |
| 21 | * |
| 22 | * @internal |
| 23 | */ |
| 24 | public function register() { |
| 25 | // Don't register hooks during installation. |
| 26 | if ( Constants::is_true( 'WC_INSTALLING' ) ) { |
| 27 | return; |
| 28 | } |
| 29 | |
| 30 | // We want to run on init for translations but before woocommerce_init so that |
| 31 | // we can hook the new integration settings page. We should be able to simplify |
| 32 | // this by just hooking here when we no longer need to check if the feature is enabled. |
| 33 | add_action( 'before_woocommerce_init', array( $this, 'on_init' ) ); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Hook into WordPress on init. |
| 38 | * |
| 39 | * @internal |
| 40 | */ |
| 41 | public function on_init() { |
| 42 | // Bail if the feature is not enabled. |
| 43 | if ( ! FeaturesUtil::feature_is_enabled( 'agentic_checkout' ) ) { |
| 44 | return; |
| 45 | } |
| 46 | |
| 47 | // Resolve webhook manager from container. |
| 48 | wc_get_container()->get( AgenticWebhookManager::class )->register(); |
| 49 | } |
| 50 | } |
| 51 |