Changeset 13462
- Timestamp:
- 04/05/2024 04:55:33 AM (4 months ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-upload.php
r13460 r13462 6 6 use WordPressdotorg\Plugin_Directory\API\Base; 7 7 use WordPressdotorg\Plugin_Directory\Shortcodes\Upload_Handler; 8 9 8 10 use WP_REST_Server; 9 11 use WP_Error; … … 141 143 } 142 144 143 // Duplicated from Upload handler.144 145 // Make sure it doesn't use a TRADEMARK protected slug. 145 146 $has_trademarked_slug = Trademarks::check_slug( $slug, wp_get_current_user() ); 146 147 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 ); 168 158 } 169 159 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-trademarks.php
r13460 r13462 171 171 * @param string $check The plugin name to check. 172 172 * @param array|WP_User|WP_Post $exceptions An array of exceptions to the trademark checks, or a WP_User or WP_Post object to fetch their exceptions. 173 * @return string|false The trademarked slug if found, false otherwise.173 * @return |false The trademarked slug if found, false otherwise. 174 174 */ 175 175 public static function check( $check, $exceptions = [] ) { … … 188 188 * @param string $plugin_slug The slug-like-text to check. 189 189 * @param array|WP_User|WP_Post $exceptions An array of exceptions to the trademark checks, or a WP_User or WP_Post object to fetch their exceptions. 190 * @return string|false The trademarked slug if found, false otherwise.190 * @return |false The trademarked slug if found, false otherwise. 191 191 */ 192 192 public static function check_slug( $plugin_slug, $exceptions = [] ) { … … 220 220 } 221 221 222 $has_trademarked_slug = false;222 $has_trademarked_slug = ; 223 223 224 224 foreach ( $trademarked_slugs as $trademark ) { … … 226 226 // Trademarks ending in "-" indicate slug cannot begin with that term. 227 227 if ( str_starts_with( $plugin_slug, $trademark ) ) { 228 $has_trademarked_slug = $trademark; 229 break; 228 $has_trademarked_slug[] = $trademark; 230 229 } 231 230 … … 246 245 247 246 // The term cannot exist anywhere in the plugin slug, and it's not a for-use exception. 248 $has_trademarked_slug = $trademark; 249 break; 247 $has_trademarked_slug[] = $trademark; 250 248 } 251 249 } … … 254 252 foreach ( $portmanteaus as $portmanteau ) { 255 253 if ( str_starts_with( $plugin_slug, $portmanteau ) ) { 256 $has_trademarked_slug = $portmanteau; 257 break; 254 $has_trademarked_slug[] = $portmanteau . '-'; // State that the portmanteau cannnot start the text. 258 255 } 259 256 } 260 257 261 return $has_trademarked_slug;258 return ; 262 259 } 263 260 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-validator.php
r13460 r13462 396 396 397 397 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>' 409 420 ); 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>' 418 433 ); 419 434 } 435 436 420 437 421 438 /* The are not generated by the Readme Parser, but rather the import parser. */ -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php
r13460 r13462 6 6 use WordPressdotorg\Plugin_Directory\Readme\Parser; 7 7 use WordPressdotorg\Plugin_Directory\Plugin_Directory; 8 8 9 use WordPressdotorg\Plugin_Directory\Tools; 9 10 use WordPressdotorg\Plugin_Directory\Tools\Filesystem; … … 168 169 } 169 170 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. 172 177 $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}" ); 204 202 } 205 203
Note: See TracChangeset
for help on using the changeset viewer.