Making WordPress.org


Ignore:
Timestamp:
11/20/2018 05:36:35 AM (7 years ago)
Author:
dd32
Message:

Plugin Directory: Readme: Validate the Tested up to and Requires at least fields contain a WordPress version value.

This commit will strip Tested up to/Requires at least values which are invalid versions, or higher than trunk/master - For example, currently that's 5.0, a value of '6.0' will be ignored, and 'Tested up to: PHP 5.2.4' will be also be ignored.

Fixes #3936

File:
1 edited

Legend:

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

    r7356 r7874  
    6969
    7070        // Warnings.
    71         if ( empty( $readme->requires ) ) {
     71        if ( isset( $readme->warnings['requires_header_ignored'] ) ) {
     72            $latest_wordpress_version = defined( 'WP_CORE_STABLE_BRANCH' ) ? WP_CORE_STABLE_BRANCH : '5.0';
     73
     74            /* translators: 1: plugin header tag; 2: Example version 5.0. 3: Example version 4.9. */
     75            $warnings[] = sprintf(
     76                __( 'The Requires at least field was ignored. %1$s field should only contain a valid WordPress version such as %2$s or %3$s.', 'wporg-plugins' ),
     77                '<code>Requires at least</code>',
     78                '<code>' . number_format( $latest_wordpress_version, 1 ) . '</code>',
     79                '<code>' . number_format( $latest_wordpress_version - 0.1, 1 ) . '</code>'
     80            );
     81        } elseif ( empty( $readme->requires ) ) {
    7282            /* translators: %s: plugin header tag */
    7383            $warnings[] = sprintf( __( '%s field is missing.', 'wporg-plugins' ), '<code>Requires at least</code>' );
    7484        }
    75         if ( empty( $readme->tested ) ) {
     85
     86        if ( isset( $readme->warnings['tested_header_ignored'] ) ) {
     87            $latest_wordpress_version = defined( 'WP_CORE_STABLE_BRANCH' ) ? WP_CORE_STABLE_BRANCH : '5.0';
     88
     89            /* translators: 1: plugin header tag; 2: Example version 5.0. 3: Example version 5.1. */
     90            $warnings[] = sprintf(
     91                __( 'The Tested up to field was ignored. %1$s field should only contain a valid WordPress version such as %2$s or %3$s.', 'wporg-plugins' ),
     92                '<code>Tested up to</code>',
     93                '<code>' . number_format( $latest_wordpress_version, 1 ) . '</code>',
     94                '<code>' . number_format( $latest_wordpress_version + 0.1, 1 ) . '</code>'
     95            );
     96        } elseif ( empty( $readme->tested ) ) {
    7697            /* translators: %s: plugin header tag */
    7798            $warnings[] = sprintf( __( '%s field is missing.', 'wporg-plugins' ), '<code>Tested up to</code>' );
    7899        }
    79         if ( isset( $readme->warnings['requires_php_ignored'] ) ) {
     100
     101        if ( isset( $readme->warnings['requires_php_header_ignored'] ) ) {
    80102            /* translators: 1: plugin header tag; 2: Example version 5.2.4. 3: Example version 7.0. */
    81103            $warnings[] = sprintf( __( 'The Requires PHP field was ignored. %1$s field should only contain a PHP version such as %2$s or %3$s.', 'wporg-plugins' ), '<code>Requires PHP</code>', '<code>5.2.4</code>', '<code>7.0</code>' );
     
    88110            $warnings[] = sprintf( __( '%1$s field is missing.  Hint: If you treat %2$s as stable, put %3$s.', 'wporg-plugins' ), '<code>Stable tag</code>', '<code>/trunk/</code>', '<code>Stable tag: trunk</code>' );
    89111        }
    90         if ( ! count( $readme->contributors ) ) {
    91             /* translators: %s: plugin header tag */
    92             $warnings[] = sprintf( __( '%s field is missing.', 'wporg-plugins' ), '<code>Contributors</code>' );
    93         }
     112
    94113        if ( isset( $readme->warnings['contributor_ignored'] ) ) {
    95114            /* translators: %s: plugin header tag */
    96115            $warnings[] = sprintf( __( 'One or more contributors listed were ignored. %s field should only contain WordPress.org usernames.', 'wporg-plugins' ), '<code>Contributors</code>' );
     116        } elseif ( ! count( $readme->contributors ) ) {
     117            /* translators: %s: plugin header tag */
     118            $warnings[] = sprintf( __( '%s field is missing.', 'wporg-plugins' ), '<code>Contributors</code>' );
    97119        }
    98120
Note: See TracChangeset for help on using the changeset viewer.