array( 'type' => 'string', 'description' => __( 'Repeater or flexible-content field name (e.g. cards) or field key.', 'acrossai-abilities-manager' ), ), 'row' => array( 'type' => 'object', 'description' => __( 'Sub-field name => value for the new row.', 'acrossai-abilities-manager' ), ), 'position' => array( 'type' => 'integer', 'minimum' => 1, 'description' => __( '1-based position to insert at. Omit to append.', 'acrossai-abilities-manager' ), ), ); } protected function required_input(): array { return array( 'selector', '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' => false, ); } 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; } $row = isset( $input['row'] ) && is_array( $input['row'] ) ? $input['row'] : array(); $position = isset( $input['position'] ) ? (int) $input['position'] : null; $index = Field_Repository::add_row( $selector, (array) Slash_Input::slash( $row, $input ), $target, $position ); if ( is_wp_error( $index ) ) { return $index; } return array( 'index' => $index, 'row_count' => Field_Repository::row_count( $selector, $target ), 'message' => sprintf( /* translators: 1: row index, 2: field name */ __( 'Row %1$d added to "%2$s".', 'acrossai-abilities-manager' ), $index, $selector ), ); } }