array( 'type' => 'string', 'description' => __( 'Repeater or flexible-content field name (e.g. cards) or field key.', 'acrossai-abilities-manager' ), ), 'index' => array( 'type' => 'integer', 'minimum' => 1, 'description' => __( '1-based row index, matching ACF\'s own API. The first row is 1, not 0.', 'acrossai-abilities-manager' ), ), 'row' => array( 'type' => 'object', 'description' => __( 'Sub-field name => new value. Omitted sub-fields keep their current values.', 'acrossai-abilities-manager' ), ), ); } protected function required_input(): array { return array( 'selector', 'index', 'row', ); } protected function output_properties(): array { return array( 'index' => array( 'type' => 'integer' ), 'row_count' => array( 'type' => 'integer' ), ); } protected function annotations(): array { return array( 'readonly' => false, 'destructive' => false, 'idempotent' => true, ); } protected function run( array $input ) { $target = Acf_Target::resolve( $input ); if ( is_wp_error( $target ) ) { return $target; } $selector = (string) $input['selector']; $typed = Field_Repository::assert_type( $selector, $target, array( 'repeater', 'flexible_content' ) ); if ( is_wp_error( $typed ) ) { return $typed; } $index = (int) $input['index']; $count = Field_Repository::row_count( $selector, $target ); $range = Field_Repository::assert_index( $index, $count ); if ( is_wp_error( $range ) ) { return $range; } $row = isset( $input['row'] ) && is_array( $input['row'] ) ? $input['row'] : array(); $written = Field_Repository::update_row( $selector, $index, (array) Slash_Input::slash( $row, $input ), $target ); if ( is_wp_error( $written ) ) { return $written; } return array( 'index' => $index, 'row_count' => $count, 'message' => sprintf( /* translators: 1: row index, 2: field name */ __( 'Row %1$d of "%2$s" updated.', 'acrossai-abilities-manager' ), $index, $selector ), ); } }