From 8f772f1583615b7e527d006ef44f612510c21d4a Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 17 May 2026 18:19:20 +0000 Subject: [PATCH] Fix: Apply WordPress Coding Standards (PHPCS) formatting to class-fields.php Converted tabs to spaces and fixed indentation/formatting violations to comply with WordPress Coding Standards. https://claude.ai/code/session_01JB1xUQM892bVZ4Yv3MZjvq --- includes/class-fields.php | 121 +++++++++++++++++---------------- tests/test-fields-extended.php | 16 ++--- 2 files changed, 69 insertions(+), 68 deletions(-) diff --git a/includes/class-fields.php b/includes/class-fields.php index 7a2eb10..9116273 100644 --- a/includes/class-fields.php +++ b/includes/class-fields.php @@ -21,6 +21,7 @@ */ class ODW_Fields { + /** * Registers WordPress hooks. */ @@ -52,14 +53,14 @@ private static function register_required_fields(): void { ->where( 'post_type', '=', 'odw_dataset' ) ->set_priority( 'high' ) - // ----------------------------------------------------------------- - // Tab 1 — Grundlegende Informationen - // ----------------------------------------------------------------- + // ----------------------------------------------------------------- + // Tab 1 — Grundlegende Informationen + // ----------------------------------------------------------------- ->add_tab( __( '1 — Grundlegende Informationen', 'open-data-wizard' ), array( Field::make( 'html', 'odw_tab1_hint' ) - ->set_html( '

' . esc_html__( 'Pflichtfelder gemäß DCAT-AP 3.0. Ohne diese Angaben kann der Datensatz nicht veröffentlicht werden.', 'open-data-wizard' ) . '

' ), + ->set_html( '

' . esc_html__( 'Pflichtfelder gemäß DCAT-AP 3.0. Ohne diese Angaben kann der Datensatz nicht veröffentlicht werden.', 'open-data-wizard' ) . '

' ), Field::make( 'text', 'odw_publisher', __( 'Wer gibt diese Daten heraus?', 'open-data-wizard' ) ) ->set_required( true ) @@ -79,9 +80,9 @@ private static function register_required_fields(): void { ) ) - // ----------------------------------------------------------------- - // Tab 2 — Inhaltliche Angaben - // ----------------------------------------------------------------- + // ----------------------------------------------------------------- + // Tab 2 — Inhaltliche Angaben + // ----------------------------------------------------------------- ->add_tab( __( '2 — Inhaltliche Angaben', 'open-data-wizard' ), array( @@ -112,9 +113,9 @@ private static function register_required_fields(): void { ) ) - // ----------------------------------------------------------------- - // Tab 3 — Datenbereitstellung (Lizenz + Distribution) - // ----------------------------------------------------------------- + // ----------------------------------------------------------------- + // Tab 3 — Datenbereitstellung (Lizenz + Distribution) + // ----------------------------------------------------------------- ->add_tab( __( '3 — Datenbereitstellung', 'open-data-wizard' ), array( @@ -159,14 +160,14 @@ private static function register_required_fields(): void { ) ) - // ----------------------------------------------------------------- - // Tab 4 — Erweiterte Angaben (unverändert) - // ----------------------------------------------------------------- + // ----------------------------------------------------------------- + // Tab 4 — Erweiterte Angaben (unverändert) + // ----------------------------------------------------------------- ->add_tab( __( '4 — Erweiterte Angaben', 'open-data-wizard' ), array( Field::make( 'html', 'odw_ext_hint_landing' ) - ->set_html( '

' . esc_html__( 'Projektseite & Aktualität', 'open-data-wizard' ) . '

' ), + ->set_html( '

' . esc_html__( 'Projektseite & Aktualität', 'open-data-wizard' ) . '

' ), Field::make( 'text', 'odw_landing_page', __( 'Wo finde ich mehr Informationen zu diesem Projekt?', 'open-data-wizard' ) ) ->set_attribute( 'type', 'url' ) @@ -178,7 +179,7 @@ private static function register_required_fields(): void { ->set_help_text( __( 'AKTUALISIERUNGSFREQUENZ (dct:accrualPeriodicity)', 'open-data-wizard' ) . "\n\n" . __( 'Beispiel: Täglich, Monatlich, Jährlich, Unregelmäßig', 'open-data-wizard' ) ), Field::make( 'html', 'odw_ext_hint_coverage' ) - ->set_html( '

' . esc_html__( 'Abdeckung', 'open-data-wizard' ) . '

' ), + ->set_html( '

' . esc_html__( 'Abdeckung', 'open-data-wizard' ) . '

' ), Field::make( 'select', 'odw_political_geocoding_level', __( 'Auf welcher Verwaltungsebene wurden diese Daten erhoben?', 'open-data-wizard' ) ) ->add_options( self::get_political_geocoding_level_options() ) @@ -199,7 +200,7 @@ private static function register_required_fields(): void { ->set_help_text( __( 'ZEITLICHER BEZUG — ENDE (dct:temporal)', 'open-data-wizard' ) . "\n\n" . __( 'Beispiel: 2024-12-31', 'open-data-wizard' ) ), Field::make( 'html', 'odw_ext_hint_contact' ) - ->set_html( '

' . esc_html__( 'Kontaktpunkt (dcat:contactPoint)', 'open-data-wizard' ) . '

' ), + ->set_html( '

' . esc_html__( 'Kontaktpunkt (dcat:contactPoint)', 'open-data-wizard' ) . '

' ), Field::make( 'text', 'odw_contact_name', __( 'Wer ist Ansprechperson für Fragen zu diesen Daten?', 'open-data-wizard' ) ) ->set_attribute( 'placeholder', __( 'z.B. Open Data Team', 'open-data-wizard' ) ) @@ -217,14 +218,14 @@ private static function register_required_fields(): void { ) ) - // ----------------------------------------------------------------- - // Tab 5 — Vorschau - // ----------------------------------------------------------------- + // ----------------------------------------------------------------- + // Tab 5 — Vorschau + // ----------------------------------------------------------------- ->add_tab( __( '5 — Vorschau', 'open-data-wizard' ), array( Field::make( 'html', 'odw_preview_html' ) - ->set_html( self::get_preview_html() ), + ->set_html( self::get_preview_html() ), ) ); } @@ -309,7 +310,7 @@ public static function load_field_definitions(): array { return array(); } - $data = require $file; + $data = include $file; return is_array( $data ) ? $data : array(); } @@ -325,7 +326,7 @@ private static function load_format_list(): array { return array(); } - $data = require $file; + $data = include $file; return is_array( $data ) ? $data : array(); } @@ -463,7 +464,7 @@ public static function get_license_options(): array { * Translate a license URI to its human-readable label. * Checks known options first, then the external licenses.txt list. * - * @param string $uri License URI (or 'sonstige'). + * @param string $uri License URI (or 'sonstige'). * @return string Human-readable label, or the URI itself if not found. */ public static function get_license_label( string $uri ): string { @@ -544,7 +545,7 @@ public static function get_format_options(): array { /** * Format MIME-type mapping — loaded from config/dct-format-list.php. * - * @param string $format Short format label (e.g. "CSV"). + * @param string $format Short format label (e.g. "CSV"). * @return string MIME type, or the original format string if unknown. */ public static function get_format_mime( string $format ): string { @@ -555,7 +556,7 @@ public static function get_format_mime( string $format ): string { /** * Maps a short format label to its EU Publications Office file-type URI. * - * @param string $format Short format label (e.g. "CSV"). + * @param string $format Short format label (e.g. "CSV"). * @return string EU file-type URI, or the original string if unknown. */ public static function get_format_eu_uri( string $format ): string { @@ -619,31 +620,31 @@ private static function get_preview_html(): string { ?>

- - + +

- '; - echo esc_html( wp_json_encode( $json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) ); - echo ''; - } else { - echo '

' . esc_html__( 'Noch keine Daten vorhanden. Bitte erst Pflichtfelder befüllen und speichern.', 'open-data-wizard' ) . '

'; - } - } - ?> + '; + echo esc_html( wp_json_encode( $json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) ); + echo ''; + } else { + echo '

' . esc_html__( 'Noch keine Daten vorhanden. Bitte erst Pflichtfelder befüllen und speichern.', 'open-data-wizard' ) . '

'; + } + } + ?>
- +

- +

- +
|null JSON-LD array, or null when the post is not a valid dataset. */ function odw_build_dataset_jsonld( int $post_id ): ?array { @@ -665,21 +666,21 @@ function odw_build_dataset_jsonld( int $post_id ): ?array { return null; } - $title = $post->post_title; - $description = carbon_get_post_meta( $post_id, 'odw_description' ); - $publisher = carbon_get_post_meta( $post_id, 'odw_publisher' ); - $language = carbon_get_post_meta( $post_id, 'odw_language' ); - $keywords = carbon_get_post_meta( $post_id, 'odw_keywords' ); - $theme = carbon_get_post_meta( $post_id, 'odw_theme' ); - $issued = carbon_get_post_meta( $post_id, 'odw_issued' ); - $modified = get_post_meta( $post_id, '_odw_modified', true ); - $dist_access_url = (string) carbon_get_post_meta( $post_id, 'odw_access_url' ); - $dist_format = (string) carbon_get_post_meta( $post_id, 'odw_format' ); - $dist_byte_size = (string) carbon_get_post_meta( $post_id, 'odw_byte_size' ); - $dist_license = (string) carbon_get_post_meta( $post_id, 'odw_license' ); - $dist_license_custom = (string) carbon_get_post_meta( $post_id, 'odw_license_custom' ); - $dist_attribution = (string) carbon_get_post_meta( $post_id, 'odw_attribution_text' ); - $cessda_topic = (string) carbon_get_post_meta( $post_id, 'odw_cessda_topic' ); + $title = $post->post_title; + $description = carbon_get_post_meta( $post_id, 'odw_description' ); + $publisher = carbon_get_post_meta( $post_id, 'odw_publisher' ); + $language = carbon_get_post_meta( $post_id, 'odw_language' ); + $keywords = carbon_get_post_meta( $post_id, 'odw_keywords' ); + $theme = carbon_get_post_meta( $post_id, 'odw_theme' ); + $issued = carbon_get_post_meta( $post_id, 'odw_issued' ); + $modified = get_post_meta( $post_id, '_odw_modified', true ); + $dist_access_url = (string) carbon_get_post_meta( $post_id, 'odw_access_url' ); + $dist_format = (string) carbon_get_post_meta( $post_id, 'odw_format' ); + $dist_byte_size = (string) carbon_get_post_meta( $post_id, 'odw_byte_size' ); + $dist_license = (string) carbon_get_post_meta( $post_id, 'odw_license' ); + $dist_license_custom = (string) carbon_get_post_meta( $post_id, 'odw_license_custom' ); + $dist_attribution = (string) carbon_get_post_meta( $post_id, 'odw_attribution_text' ); + $cessda_topic = (string) carbon_get_post_meta( $post_id, 'odw_cessda_topic' ); // Extended DCAT-AP fields (Tab 4). $landing_page = (string) carbon_get_post_meta( $post_id, 'odw_landing_page' ); @@ -850,7 +851,7 @@ function odw_build_dataset_jsonld( int $post_id ): ?array { * Supports the legacy single-field format (byte_size in bytes) * and the new composite format (byte_size_value + byte_size_unit). * - * @param array $dist Distribution sub-array from Carbon Fields. + * @param array $dist Distribution sub-array from Carbon Fields. * @return int Byte count, or 0 if not set. */ function odw_compute_byte_size( array $dist ): int { diff --git a/tests/test-fields-extended.php b/tests/test-fields-extended.php index 8fed61c..061c223 100644 --- a/tests/test-fields-extended.php +++ b/tests/test-fields-extended.php @@ -541,9 +541,9 @@ public function test_build_distribution_attribution_text(): void { 26, 'odw_dataset', array( - 'odw_access_url' => 'https://example.com/data.csv', - 'odw_format' => 'CSV', - 'odw_byte_size' => '', + 'odw_access_url' => 'https://example.com/data.csv', + 'odw_format' => 'CSV', + 'odw_byte_size' => '', 'odw_attribution_text' => 'Daten von Musterorganisation e.V.', ) ); @@ -583,11 +583,11 @@ public function test_build_distribution_sonstige_license_uses_custom_uri(): void 28, 'odw_dataset', array( - 'odw_access_url' => 'https://example.com/data.csv', - 'odw_format' => 'CSV', - 'odw_byte_size' => '', - 'odw_license' => 'sonstige', - 'odw_license_custom' => $custom_uri, + 'odw_access_url' => 'https://example.com/data.csv', + 'odw_format' => 'CSV', + 'odw_byte_size' => '', + 'odw_license' => 'sonstige', + 'odw_license_custom' => $custom_uri, ) );