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/api/routes/class-plugin-upload.php

    r13460 r13462  
    66use WordPressdotorg\Plugin_Directory\API\Base;
    77use WordPressdotorg\Plugin_Directory\Shortcodes\Upload_Handler;
     8use WordPressdotorg\Plugin_Directory\Readme\Validator as Readme_Validator;
     9use WordPressdotorg\Plugin_Directory\Trademarks;
    810use WP_REST_Server;
    911use WP_Error;
     
    141143        }
    142144
    143         // Duplicated from Upload handler.
    144145        // Make sure it doesn't use a TRADEMARK protected slug.
    145146        $has_trademarked_slug = Trademarks::check_slug( $slug, wp_get_current_user() );
    146147        if ( $has_trademarked_slug ) {
    147             $error = __( 'That plugin slug includes a restricted term.', 'wporg-plugins' );
    148 
    149             if ( $has_trademarked_slug === trim( $has_trademarked_slug, '-' ) ) {
    150                 // Trademarks that do NOT end in "-" indicate slug cannot contain term at all.
    151                 $message = sprintf(
    152                     /* translators: 1: plugin slug, 2: trademarked term, 3: 'Plugin Name:', 4: plugin email address */
    153                     __( 'Your chosen plugin slug - %1$s - contains the restricted term "%2$s", which cannot be used at all in your plugin permalink nor the display name.', 'wporg-plugins' ),
    154                     '<code>' . $slug . '</code>',
    155                     '<code>' . trim( $has_trademarked_slug, '-' ) . '</code>'
    156                 );
    157             } else {
    158                 // Trademarks ending in "-" indicate slug cannot BEGIN with that term.
    159                 $message = sprintf(
    160                     /* translators: 1: plugin slug, 2: trademarked term, 3: 'Plugin Name:', 4: plugin email address */
    161                     __( 'Your chosen plugin slug - %1$s - contains the restricted term "%2$s" and 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.', 'wporg-plugins' ),
    162                     '<code>' . $slug . '</code>',
    163                     '<code>' . trim( $has_trademarked_slug, '-' ) . '</code>'
    164                 );
    165             }
    166 
    167             return new WP_Error( 'trademarked_slug', $error . ' ' . $message );
     148            return new WP_Error(
     149                'trademarked_slug',
     150                Readme_Validator::instance()->translate_code_to_message(
     151                    'trademarked_slug',
     152                    [
     153                        'trademark' => $has_trademarked_slug,
     154                        'context'   => $slug
     155                    ]
     156                )
     157            );
    168158        }
    169159
Note: See TracChangeset for help on using the changeset viewer.