Making WordPress.org


Ignore:
Timestamp:
02/22/2024 05:46:59 AM (3 years ago)
Author:
dd32
Message:

Plugin Directory: Introduce a maximum length to the readme sections.

See #7477.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-validator.php

    r13133 r13235  
    181181                        );
    182182                } elseif( isset( $readme->warnings['trimmed_short_description'] ) ) {
    183                         $notes[] = sprintf(
     183                        $warnings[] = sprintf(
    184184                                /* translators: %s: section title */
    185185                                __( 'The %s section is too long and was truncated. A maximum of 150 characters is supported.', 'wporg-plugins' ),
    186                                 '<code>Short Description</code>'
     186                                '<code>Short Description</code>',
     187                                number_format_i18n( $readme->maximum_field_lengths['short_description'] )
     188                        );
     189                }
     190
     191                $trimmed_sections = array_filter( $readme->warnings, function( $warning ) {
     192                        return str_contains( $warning, 'trimmed_section_' );
     193                }, ARRAY_FILTER_USE_KEY );
     194                foreach ( $trimmed_sections as $section_name => $dummy ) {
     195                        $section_name = str_replace( 'trimmed_section_', '', $section_name );
     196                        $warnings[]   = sprintf(
     197                                /* translators: %s: section title */
     198                                __( 'The %s section is too long and was truncated. A maximum of %s words is supported.', 'wporg-plugins' ),
     199                                '<code>' . esc_html( ucwords( str_replace( '_', ' ', $section_name ) ) ) . '</code>',
     200                                number_format_i18n( $readme->maximum_field_lengths[ 'section' ] )
    187201                        );
    188202                }
Note: See TracChangeset for help on using the changeset viewer.