$definition['name'], 'role' => $definition['role'], 'description' => $definition['description'], 'instructions' => $definition['instructions'], 'abilities' => $definition['abilities'], 'vibes' => $definition['vibes'], 'face' => $definition['face'], 'faceSeed' => $definition['faceSeed'], ) ); if ( is_wp_error( $user ) ) { // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log error_log( '[openstation] Default agent "' . $definition['name'] . '" failed to seed: ' . $user->get_error_message() ); continue; } openstation_agent_update( $user->ID, array( 'triggers' => $definition['triggers'] ) ); } update_option( OPENSTATION_AGENTS_DEFAULTS_SEEDED_OPTION, '1', false ); } /** * Hook wrapper — seed only on wp-admin requests by a user who could * create agents anyway. Keeps the seeder out of front-end requests, * cron, and the PHPUnit bootstrap (tests call the pure function). * * @return void */ function openstation_agents_maybe_seed_defaults() { if ( ! is_admin() || ! current_user_can( 'edit_users' ) ) { return; } openstation_agents_seed_defaults(); } add_action( 'admin_init', 'openstation_agents_maybe_seed_defaults' );