includes/class-some-class.php * ------------------------------------------------------------------------- */ spl_autoload_register( function ( $class ) { if ( strpos( $class, 'Agencoen\\' ) !== 0 ) { return; } $relative = substr( $class, strlen( 'Agencoen\\' ) ); $relative = strtolower( str_replace( '_', '-', $relative ) ); $file = AGENCOEN_PLUGIN_DIR . 'includes/class-' . $relative . '.php'; if ( is_readable( $file ) ) { require $file; } } ); /* * ------------------------------------------------------------------------- * High-Performance Order Storage (HPOS) compatibility * (The hook only fires when WooCommerce is active; harmless otherwise.) * ------------------------------------------------------------------------- */ add_action( 'before_woocommerce_init', function () { if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', AGENCOEN_PLUGIN_FILE, true ); } } ); /* * ------------------------------------------------------------------------- * Requirement checks + boot * ------------------------------------------------------------------------- */ /** * Determine whether the plugin's requirements are met. * * PHP 8.0 is the only hard requirement since 4.0.0; WooCommerce gates the * commerce screens at runtime instead of blocking activation. * * @return string Empty string when OK, otherwise a human-readable reason. */ function agencoen_requirements_error() { if ( version_compare( PHP_VERSION, '8.0', '<' ) ) { return sprintf( /* translators: %s: current PHP version. */ __( 'Rezolve Ai requires PHP 8.0 or higher. You are running %s.', 'agentic-commerce-engine' ), PHP_VERSION ); } return ''; } /** * Boot the plugin once all plugins (including WooCommerce, if any) are loaded. */ function agencoen_boot() { $error = agencoen_requirements_error(); if ( '' !== $error ) { add_action( 'admin_notices', function () use ( $error ) { echo '

' . esc_html( $error ) . '

'; } ); return; } \Agencoen\Plugin::instance(); } add_action( 'plugins_loaded', 'agencoen_boot', 20 ); /* * ------------------------------------------------------------------------- * Activation / Deactivation * ------------------------------------------------------------------------- */ register_activation_hook( __FILE__, function () { require_once AGENCOEN_PLUGIN_DIR . 'includes/class-settings.php'; require_once AGENCOEN_PLUGIN_DIR . 'includes/class-db.php'; \Agencoen\Settings::set_activation_defaults(); \Agencoen\Db::install(); // Schedule the recurring heartbeat. if ( ! wp_next_scheduled( 'agencoen_heartbeat' ) ) { wp_schedule_event( time() + HOUR_IN_SECONDS, 'hourly', 'agencoen_heartbeat' ); } // Daily crawler-log maintenance (prune + optional report-back). if ( ! wp_next_scheduled( 'agencoen_bot_prune' ) ) { wp_schedule_event( time() + DAY_IN_SECONDS, 'daily', 'agencoen_bot_prune' ); } // The UCP routes are rewrite rules, so they 404 until the rules are // rebuilt. Activation is the only moment we can be sure of doing it. flush_rewrite_rules(); } ); register_deactivation_hook( __FILE__, function () { // Clear every recurring/queued event this plugin owns. $hooks = array( 'agencoen_heartbeat', 'agencoen_scheduled_sync', 'agencoen_sync_continue', 'agencoen_auto_apply_sweep', 'agencoen_auto_apply_drain', 'agencoen_poll_enrichment', 'agencoen_bot_prune', 'agencoen_bot_report', 'agencoen_content_poll', 'agencoen_review_sync', 'agencoen_review_backfill', ); foreach ( $hooks as $hook ) { wp_clear_scheduled_hook( $hook ); } // Drop our rewrite rules with us, so /.well-known/ucp stops answering // rather than 404ing through a stale rule. flush_rewrite_rules(); } );