Making WordPress.org


Ignore:
Timestamp:
04/05/2024 04:55:33 AM (15 months ago)
Author:
dd32
Message:

Plugin Directory: Expand the trademark checks to match multiple trademarks in the field checked.

Simplifies the error message and centralises the 3 uses of it.

See #5868.

File:
1 edited

Legend:

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

    r13460 r13462  
    396396
    397397            case 'trademarked_name':
    398                 $trademark = $data['trademark'];
    399                 $context   = $data['context'];
    400 
    401                 if ( str_ends_with( $trademark, '-' ) ) {
    402                     // Trademarks ending in "-" indicate slug cannot BEGIN with that term.
    403                     return sprintf(
    404                         /* translators: 1: plugin name/slug, 2: trademarked term, 3: plugin email address */
    405                         __( 'The plugin name includes a restricted term. Your chosen plugin name - %1$s - contains the restricted term "%2$s" and cannot be used to begin your slug, permalink, display name, or plugin name. We disallow the use of certain terms in ways that are abused, or potentially infringe on and/or are misleading with regards to trademarks. If you feel this is in error, such as you legally own the trademark for the term, please email us at %4$s and explain your situation.', 'wporg-plugins' ),
    406                         '<code>' . esc_html( $context ) . '</code>',
    407                         '<code>' . esc_html( trim( $trademark, '-' ) ) . '</code>',
    408                         '<code>plugins@wordpress.org</code>'
     398            case 'trademarked_slug':
     399            case 'trademarked':
     400                $trademarks = (array) $data['trademark'];
     401                $context    = $data['context'];
     402                $messages   = [];
     403   
     404                $cannot_start_with = array_filter( $trademarks, function( $slug ) {
     405                    return str_ends_with( $slug, '-' );
     406                } );
     407                $cannot_contain    = array_diff( $trademarks, $cannot_start_with );
     408
     409                if ( $cannot_start_with ) {
     410                    $messages[] = sprintf(
     411                        /* translators: 1: plugin slug, 2: trademarked term, 3: 'Plugin Name:', 4: plugin email address */
     412                        _n(
     413                            'Your chosen plugin name - %1$s - contains the restricted term "%2$s" which cannot be used to begin your permalink or display name. We disallow the use of certain terms in ways that are abused, or potentially infringe on and/or are misleading with regards to trademarks.',
     414                            'Your chosen plugin name - %1$s - contains the restricted terms "%2$s" which cannot be used to begin your permalink or display name. We disallow the use of certain terms in ways that are abused, or potentially infringe on and/or are misleading with regards to trademarks.',
     415                            count( $cannot_start_with ),
     416                            'wporg-plugins'
     417                        ),
     418                        '<code>' . $context . '</code>',
     419                        '<code>' . implode( '</code>", "<code>', $cannot_start_with ) . '</code>'
    409420                    );
    410                 } else {
    411                     // Trademarks that do NOT end in "-" indicate slug cannot contain term at all.
    412                     return sprintf(
    413                         /* translators: 1: plugin name/slug, 2: trademarked term, 3: plugin email address */
    414                         __( 'The plugin name includes a restricted term. Your chosen plugin name - %1$s - contains the restricted term "%2$s" and cannot be used at all in your plugin permalink nor the display name. If you feel this is in error, such as you legally own the trademark for a term, please email us at %3$s and explain your situation.', 'wporg-plugins' ),
    415                         '<code>' . esc_html( $context ) . '</code>',
    416                         '<code>' . esc_html( trim( $trademark, '-' ) ) . '</code>',
    417                         '<code>plugins@wordpress.org</code>'
     421                }
     422                if ( $cannot_contain ) {
     423                    $messages[] = sprintf(
     424                        /* translators: 1: plugin slug, 2: trademarked term, 3: 'Plugin Name:', 4: plugin email address */
     425                        _n(
     426                            'Your chosen plugin name - %1$s - contains the restricted term "%2$s", which cannot be used at all in your plugin permalink nor the display name.',
     427                            'Your chosen plugin name - %1$s - contains the restricted terms "%2$s", which cannot be used at all in your plugin permalink nor the display name.',
     428                            count( $cannot_contain ),
     429                            'wporg-plugins'
     430                        ),
     431                        '<code>' . $context . '</code>',
     432                        '<code>' . implode( '</code>", "<code>', $cannot_contain ) . '</code>'
    418433                    );
    419434                }
     435
     436                return implode( '<br>', $messages );
    420437
    421438            /* The are not generated by the Readme Parser, but rather the import parser. */
Note: See TracChangeset for help on using the changeset viewer.