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/shortcodes/class-upload-handler.php

    r13460 r13462  
    66use WordPressdotorg\Plugin_Directory\Readme\Parser;
    77use WordPressdotorg\Plugin_Directory\Plugin_Directory;
     8use WordPressdotorg\Plugin_Directory\Readme\Validator as Readme_Validator;
    89use WordPressdotorg\Plugin_Directory\Tools;
    910use WordPressdotorg\Plugin_Directory\Tools\Filesystem;
     
    168169        }
    169170
    170         // Make sure it doesn't use a TRADEMARK protected slug.
    171         if ( ! $updating_existing ) {
     171        // Make sure it doesn't use a TRADEMARK. We check the name first, and then the slug.
     172        $has_trademarked_slug = Trademarks::check( $this->plugin['Name'], wp_get_current_user() );
     173        $trademark_context    = $this->plugin['Name'];
     174
     175        if ( ! $has_trademarked_slug && ! $updating_existing ) {
     176            // Check the slug on new submissions in addition to the name.
    172177            $has_trademarked_slug = Trademarks::check_slug( $this->plugin_slug, wp_get_current_user() );
    173         } else {
    174             // If we're updating an existing plugin, we need to check the new name, but the slug may be different.
    175             $has_trademarked_slug = Trademarks::check( $this->plugin['Name'], wp_get_current_user() );
    176         }
    177 
    178         if ( false !== $has_trademarked_slug && ! $has_upload_token ) {
    179             $error = __( 'Error: The plugin name includes a restricted term.', 'wporg-plugins' );
    180 
    181             if ( $has_trademarked_slug === trim( $has_trademarked_slug, '-' ) ) {
    182                 // Trademarks that do NOT end in "-" indicate slug cannot contain term at all.
    183                 $message = sprintf(
    184                     /* translators: 1: plugin slug, 2: trademarked term, 3: 'Plugin Name:', 4: plugin email address */
    185                     __( '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. To proceed with this submission you must remove "%2$s" from the %3$s line in both your main plugin file and readme entirely. Once you\'ve finished, you may upload the plugin again. Do not attempt to work around this by removing letters (i.e. WordPess) or using numbers (4 instead of A). Those are seen as intentional actions to avoid our restrictions, and are not permitted. If you feel this is in error, such as you legally own the trademark for a term, please email us at %4$s and explain your situation.', 'wporg-plugins' ),
    186                     '<code>' . esc_html( $this->plugin['Name'] ) . '</code>',
    187                     trim( $has_trademarked_slug, '-' ),
    188                     '<code>Plugin Name:</code>',
    189                     '<code>plugins@wordpress.org</code>'
    190                 );
    191             } else {
    192                 // Trademarks ending in "-" indicate slug cannot BEGIN with that term.
    193                 $message = sprintf(
    194                     /* translators: 1: plugin slug, 2: trademarked term, 3: 'Plugin Name:', 4: plugin email address */
    195                     __( 'Your chosen plugin name - %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. In order to proceed with this submission, you must change the %3$s line in your main plugin file and readme to end with  "-%2$s" instead. Once you\'ve finished, you may upload the plugin again. 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' ),
    196                     '<code>' . esc_html( $this->plugin['Name'] ) . '</code>',
    197                     trim( $has_trademarked_slug, '-' ),
    198                     '<code>Plugin Name:</code>',
    199                     '<code>plugins@wordpress.org</code>'
    200                 );
    201             }
    202 
    203             return new WP_Error( 'trademarked_name', $error . ' ' . $message );
     178            $trademark_context    = $this->plugin_slug;
     179        }
     180
     181        if ( $has_trademarked_slug && ! $has_upload_token ) {
     182            $error = Readme_Validator::instance()->translate_code_to_message(
     183                'trademarked_slug',
     184                [
     185                    'trademark' => $has_trademarked_slug,
     186                    'context'   => $trademark_context,
     187                ]
     188            );
     189
     190            $to_proceed_text = sprintf(
     191                /* translators: 1: Plugin Name header */
     192                __( 'To proceed with this submission you must change your %1$s line in both your main plugin file and readme to abide by these requirements. Once you\'ve finished, you may upload the plugin again. Do not attempt to work around this by removing letters (i.e. WordPess) or using numbers (4 instead of A). Those are seen as intentional actions to avoid our restrictions, and are not permitted.', 'wporg-plugins' ),
     193                '<code>Plugin Name:</code>'
     194            );
     195            $in_error_text   = sprintf(
     196                /* translators: plugins@wordpress.org */
     197                __( 'If you feel this is in error, such as you legally own the trademark for the term, please email us at %1$s and explain your situation.', 'wporg-plugins' ),
     198                'plugins@wordpress.org'
     199            );
     200
     201            return new WP_Error( 'trademarked_name', "{$error} {$to_proceed_text} {$in_error_text}" );
    204202        }
    205203
Note: See TracChangeset for help on using the changeset viewer.