array( 'type' => 'integer', 'minimum' => 1, ), ); } protected function output_properties(): array { return array( 'form_id' => array( 'type' => 'integer' ), 'messages' => array( 'type' => 'array' ), ); } protected function required_input(): array { return array( 'form_id' ); } protected function annotations(): array { return array( 'readonly' => true, 'destructive' => false, 'idempotent' => true, ); } protected function run( array $input ) { $form = Form_Repository::get( absint( $input['form_id'] ?? 0 ) ); if ( is_wp_error( $form ) ) { return $form; } $current = (array) $form->prop( 'messages' ); $defaults = Form_Repository::default_messages(); $rows = array(); foreach ( $defaults as $slug => $default ) { $text = isset( $current[ $slug ] ) ? (string) $current[ $slug ] : $default; $rows[] = array( 'slug' => $slug, 'text' => $text, 'default' => $default, 'customised' => $text !== $default, ); } return array( 'form_id' => (int) $form->id(), 'messages' => $rows, 'message' => sprintf( /* translators: %d: number of messages */ _n( '%d message.', '%d messages.', count( $rows ), 'acrossai-abilities-manager' ), count( $rows ) ), ); } }