register_classes( self::ABILITY_CLASSES ); } /** * For an FSI import driven by the loopback (marked by * `McpCore\Support\AjaxLoopbackDispatcher` via `templately_mcp_driven`), * impose a finite PHP time limit. * * FSI runs under `set_time_limit(0)`, which makes `Helper::fsi_should_exit()`'s * max_execution_time check a no-op; restoring a finite limit here re-enables * that existing per-item time-box so a heavy runner splits into short slices. * Hooked after the importer's own `set_time_limit(0)` and before the runner * loop. * * @return void */ public static function cap_loopback_slice_time(): void { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- the underlying ajax handler already verifies the nonce; this only reads a boolean routing flag. if ( ! empty( $_REQUEST['templately_mcp_driven'] ) ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- set_time_limit may be disabled on some hosts; a warning there is harmless and the cap is best-effort. @set_time_limit( self::LOOPBACK_TIME_LIMIT ); } } }