Making WordPress.org


Ignore:
Timestamp:
04/30/2024 04:41:42 AM (14 months ago)
Author:
dd32
Message:

Plugin Directory: Readme: Validate that the license field contains a likely valid license.

This adds to the existing "no license" with two new ones:

  • Warning: License appears to be not-GPL-compatible, invalid
  • Note: We could not parse the license specified, unknown

Fixes #1944.

File:
1 edited

Legend:

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

    r13524 r13618  
    145145        }
    146146
    147         if ( empty( $readme->license ) ) {
     147        if ( ! empty( $readme->warnings['license_missing'] ) ) {
    148148            $warnings['license_missing'] = true;
     149        } elseif ( ! empty( $readme->warnings['invalid_license'] ) ) {
     150            $errors['invalid_license'] = $readme->warnings['invalid_license'];
     151        } elseif ( ! empty( $readme->warnings['unknown_license'] ) ) {
     152            $notes['unknown_license'] = $readme->warnings['unknown_license'];
    149153        }
    150154
     
    398402            case 'donate_link_missing':
    399403                return __( 'No donate link was found', 'wporg-plugins' );
     404
    400405            case 'license_missing':
    401406                return sprintf(
    402                     /* translators: 1: 'License' */
    403                     __( 'The %1$s field is missing or invalid. A GPLv2 or later compatible license should be specified.', 'wporg-plugins' ),
    404                     '<code>License</code>'
     407                    /* translators: 1: 'License', 2: Link to a compatible licenses page. */
     408                    __( 'The %1$s field is missing. <a href="%2$s">A GPLv2 or later compatible license</a> should be specified.', 'wporg-plugins' ),
     409                    '<code>License</code>',
     410                    'https://www.gnu.org/licenses/license-list.en.html'
     411                );
     412
     413            case 'invalid_license':
     414                return sprintf(
     415                    /* translators: 1: 'License', 2: Link to a compatible licenses page. */
     416                    __( 'The %1$s field appears to be invalid. <a href="%2$s">A GPLv2 or later compatible license</a> should be specified.', 'wporg-plugins' ),
     417                    '<code>License</code>',
     418                    'https://www.gnu.org/licenses/license-list.en.html'
     419                );
     420
     421            case 'unknown_license':
     422                return sprintf(
     423                    /* translators: 1: 'License', 2: Link to a compatible licenses page. */
     424                    __( 'The %1$s field could not be validated. <a href="%2$s">A GPLv2 or later compatible license</a> should be specified. The specified license may be compatible.', 'wporg-plugins' ),
     425                    '<code>License</code>',
     426                    'https://www.gnu.org/licenses/license-list.en.html'
    405427                );
    406428
Note: See TracChangeset for help on using the changeset viewer.